Files
e-tib.com/node_modules/.pnpm/react-email@5.2.10/node_modules/react-email/dist/index.mjs
Marc Mintel d14122005d Initial commit: E-TIB production hardening & E2E foundation
Former-commit-id: ef04fca3d76375630c05aac117bf586953f3b657
2026-04-28 19:11:38 +02:00

7326 lines
265 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
import { createRequire } from "node:module";
import { spawn } from "node:child_process";
import { program } from "commander";
import * as fs$1 from "node:fs";
import fs, { existsSync, promises, statSync, unlinkSync, writeFileSync } from "node:fs";
import * as path$2 from "node:path";
import path from "node:path";
import url, { fileURLToPath } from "node:url";
import * as fsp$1 from "node:fs/promises";
import fsp from "node:fs/promises";
import { F_OK } from "node:constants";
import * as nativeFs$1 from "fs";
import nativeFs from "fs";
import path$1, { basename, dirname, normalize, posix, relative, resolve, sep } from "path";
import { fileURLToPath as fileURLToPath$1 } from "url";
import { createRequire as createRequire$1 } from "module";
import logSymbols from "log-symbols";
import { addDevDependency, installDependencies, runScript } from "nypm";
import ora from "ora";
import { createJiti } from "jiti";
import prompts from "prompts";
import { watch } from "chokidar";
import debounce from "debounce";
import { Server } from "socket.io";
import { parse } from "@babel/parser";
import traverseModule from "@babel/traverse";
import { createMatchPath, loadConfig } from "tsconfig-paths";
import http from "node:http";
import os from "node:os";
import Conf from "conf";
import * as nodeUtil from "node:util";
import { lookup } from "mime-types";
import { build } from "esbuild";
import { glob } from "glob";
import normalize$1 from "normalize-path";
//#region rolldown:runtime
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (var keys = __getOwnPropNames(from), i$1 = 0, n = keys.length, key; i$1 < n; i$1++) {
key = keys[i$1];
if (!__hasOwnProp.call(to, key) && key !== except) {
__defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
}
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
var __require$1 = /* @__PURE__ */ createRequire(import.meta.url);
//#endregion
//#region ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
var __require = /* @__PURE__ */ createRequire$1(import.meta.url);
function cleanPath(path$3) {
let normalized = normalize(path$3);
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
return normalized;
}
const SLASHES_REGEX = /[\\/]/g;
function convertSlashes(path$3, separator) {
return path$3.replace(SLASHES_REGEX, separator);
}
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
function isRootDirectory(path$3) {
return path$3 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$3);
}
function normalizePath(path$3, options) {
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
const pathNeedsCleaning = process.platform === "win32" && path$3.includes("/") || path$3.startsWith(".");
if (resolvePaths) path$3 = resolve(path$3);
if (normalizePath$1 || pathNeedsCleaning) path$3 = cleanPath(path$3);
if (path$3 === ".") return "";
return convertSlashes(path$3[path$3.length - 1] !== pathSeparator ? path$3 + pathSeparator : path$3, pathSeparator);
}
function joinPathWithBasePath(filename, directoryPath) {
return directoryPath + filename;
}
function joinPathWithRelativePath(root, options) {
return function(filename, directoryPath) {
if (directoryPath.startsWith(root)) return directoryPath.slice(root.length) + filename;
else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
};
}
function joinPath(filename) {
return filename;
}
function joinDirectoryPath(filename, directoryPath, separator) {
return directoryPath + filename + separator;
}
function build$7(root, options) {
const { relativePaths, includeBasePath } = options;
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
}
function pushDirectoryWithRelativePath(root) {
return function(directoryPath, paths) {
paths.push(directoryPath.substring(root.length) || ".");
};
}
function pushDirectoryFilterWithRelativePath(root) {
return function(directoryPath, paths, filters) {
const relativePath = directoryPath.substring(root.length) || ".";
if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
};
}
const pushDirectory = (directoryPath, paths) => {
paths.push(directoryPath || ".");
};
const pushDirectoryFilter = (directoryPath, paths, filters) => {
const path$3 = directoryPath || ".";
if (filters.every((filter) => filter(path$3, true))) paths.push(path$3);
};
const empty$2 = () => {};
function build$6(root, options) {
const { includeDirs, filters, relativePaths } = options;
if (!includeDirs) return empty$2;
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
}
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
if (filters.every((filter) => filter(filename, false))) counts.files++;
};
const pushFileFilter = (filename, paths, _counts, filters) => {
if (filters.every((filter) => filter(filename, false))) paths.push(filename);
};
const pushFileCount = (_filename, _paths, counts, _filters) => {
counts.files++;
};
const pushFile = (filename, paths) => {
paths.push(filename);
};
const empty$1 = () => {};
function build$5(options) {
const { excludeFiles, filters, onlyCounts } = options;
if (excludeFiles) return empty$1;
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
else if (onlyCounts) return pushFileCount;
else return pushFile;
}
const getArray = (paths) => {
return paths;
};
const getArrayGroup = () => {
return [""].slice(0, 0);
};
function build$4(options) {
return options.group ? getArrayGroup : getArray;
}
const groupFiles = (groups, directory, files) => {
groups.push({
directory,
files,
dir: directory
});
};
const empty = () => {};
function build$3(options) {
return options.group ? groupFiles : empty;
}
const resolveSymlinksAsync = function(path$3, state, callback$1) {
const { queue, fs: fs$2, options: { suppressErrors } } = state;
queue.enqueue();
fs$2.realpath(path$3, (error, resolvedPath) => {
if (error) return queue.dequeue(suppressErrors ? null : error, state);
fs$2.stat(resolvedPath, (error$1, stat) => {
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
if (stat.isDirectory() && isRecursive(path$3, resolvedPath, state)) return queue.dequeue(null, state);
callback$1(stat, resolvedPath);
queue.dequeue(null, state);
});
});
};
const resolveSymlinks = function(path$3, state, callback$1) {
const { queue, fs: fs$2, options: { suppressErrors } } = state;
queue.enqueue();
try {
const resolvedPath = fs$2.realpathSync(path$3);
const stat = fs$2.statSync(resolvedPath);
if (stat.isDirectory() && isRecursive(path$3, resolvedPath, state)) return;
callback$1(stat, resolvedPath);
} catch (e) {
if (!suppressErrors) throw e;
}
};
function build$2(options, isSynchronous) {
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
}
function isRecursive(path$3, resolved, state) {
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
let parent = dirname(path$3);
let depth = 1;
while (parent !== state.root && depth < 2) {
const resolvedPath = state.symlinks.get(parent);
if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth++;
else parent = dirname(parent);
}
state.symlinks.set(path$3, resolved);
return depth > 1;
}
function isRecursiveUsingRealPaths(resolved, state) {
return state.visited.includes(resolved + state.options.pathSeparator);
}
const onlyCountsSync = (state) => {
return state.counts;
};
const groupsSync = (state) => {
return state.groups;
};
const defaultSync = (state) => {
return state.paths;
};
const limitFilesSync = (state) => {
return state.paths.slice(0, state.options.maxFiles);
};
const onlyCountsAsync = (state, error, callback$1) => {
report(error, callback$1, state.counts, state.options.suppressErrors);
return null;
};
const defaultAsync = (state, error, callback$1) => {
report(error, callback$1, state.paths, state.options.suppressErrors);
return null;
};
const limitFilesAsync = (state, error, callback$1) => {
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
return null;
};
const groupsAsync = (state, error, callback$1) => {
report(error, callback$1, state.groups, state.options.suppressErrors);
return null;
};
function report(error, callback$1, output, suppressErrors) {
if (error && !suppressErrors) callback$1(error, output);
else callback$1(null, output);
}
function build$1$1(options, isSynchronous) {
const { onlyCounts, group, maxFiles } = options;
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
else if (group) return isSynchronous ? groupsSync : groupsAsync;
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
else return isSynchronous ? defaultSync : defaultAsync;
}
const readdirOpts = { withFileTypes: true };
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
state.queue.enqueue();
if (currentDepth < 0) return state.queue.dequeue(null, state);
const { fs: fs$2 } = state;
state.visited.push(crawlPath);
state.counts.directories++;
fs$2.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
callback$1(entries, directoryPath, currentDepth);
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
});
};
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
const { fs: fs$2 } = state;
if (currentDepth < 0) return;
state.visited.push(crawlPath);
state.counts.directories++;
let entries = [];
try {
entries = fs$2.readdirSync(crawlPath || ".", readdirOpts);
} catch (e) {
if (!state.options.suppressErrors) throw e;
}
callback$1(entries, directoryPath, currentDepth);
};
function build$8(isSynchronous) {
return isSynchronous ? walkSync : walkAsync;
}
/**
* This is a custom stateless queue to track concurrent async fs calls.
* It increments a counter whenever a call is queued and decrements it
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
*/
var Queue = class {
count = 0;
constructor(onQueueEmpty) {
this.onQueueEmpty = onQueueEmpty;
}
enqueue() {
this.count++;
return this.count;
}
dequeue(error, output) {
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
this.onQueueEmpty(error, output);
if (error) {
output.controller.abort();
this.onQueueEmpty = void 0;
}
}
}
};
var Counter = class {
_files = 0;
_directories = 0;
set files(num) {
this._files = num;
}
get files() {
return this._files;
}
set directories(num) {
this._directories = num;
}
get directories() {
return this._directories;
}
/**
* @deprecated use `directories` instead
*/
/* c8 ignore next 3 */
get dirs() {
return this._directories;
}
};
/**
* AbortController is not supported on Node 14 so we use this until we can drop
* support for Node 14.
*/
var Aborter = class {
aborted = false;
abort() {
this.aborted = true;
}
};
var Walker = class {
root;
isSynchronous;
state;
joinPath;
pushDirectory;
pushFile;
getArray;
groupFiles;
resolveSymlink;
walkDirectory;
callbackInvoker;
constructor(root, options, callback$1) {
this.isSynchronous = !callback$1;
this.callbackInvoker = build$1$1(options, this.isSynchronous);
this.root = normalizePath(root, options);
this.state = {
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
paths: [""].slice(0, 0),
groups: [],
counts: new Counter(),
options,
queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
symlinks: /* @__PURE__ */ new Map(),
visited: [""].slice(0, 0),
controller: new Aborter(),
fs: options.fs || nativeFs$1
};
this.joinPath = build$7(this.root, options);
this.pushDirectory = build$6(this.root, options);
this.pushFile = build$5(options);
this.getArray = build$4(options);
this.groupFiles = build$3(options);
this.resolveSymlink = build$2(options, this.isSynchronous);
this.walkDirectory = build$8(this.isSynchronous);
}
start() {
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
}
walk = (entries, directoryPath, depth) => {
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
const files = this.getArray(this.state.paths);
for (let i$1 = 0; i$1 < entries.length; ++i$1) {
const entry = entries[i$1];
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
const filename = this.joinPath(entry.name, directoryPath);
this.pushFile(filename, files, this.state.counts, filters);
} else if (entry.isDirectory()) {
let path$3 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
if (exclude && exclude(entry.name, path$3)) continue;
this.pushDirectory(path$3, paths, filters);
this.walkDirectory(this.state, path$3, path$3, depth - 1, this.walk);
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
let path$3 = joinPathWithBasePath(entry.name, directoryPath);
this.resolveSymlink(path$3, this.state, (stat, resolvedPath) => {
if (stat.isDirectory()) {
resolvedPath = normalizePath(resolvedPath, this.state.options);
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$3 + pathSeparator)) return;
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$3 + pathSeparator, depth - 1, this.walk);
} else {
resolvedPath = useRealPaths ? resolvedPath : path$3;
const filename = basename(resolvedPath);
const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
resolvedPath = this.joinPath(filename, directoryPath$1);
this.pushFile(resolvedPath, files, this.state.counts, filters);
}
});
}
}
this.groupFiles(this.state.groups, directoryPath, files);
};
};
function promise(root, options) {
return new Promise((resolve$1, reject) => {
callback(root, options, (err, output) => {
if (err) return reject(err);
resolve$1(output);
});
});
}
function callback(root, options, callback$1) {
new Walker(root, options, callback$1).start();
}
function sync(root, options) {
return new Walker(root, options).start();
}
var APIBuilder = class {
constructor(root, options) {
this.root = root;
this.options = options;
}
withPromise() {
return promise(this.root, this.options);
}
withCallback(cb) {
callback(this.root, this.options, cb);
}
sync() {
return sync(this.root, this.options);
}
};
let pm = null;
/* c8 ignore next 6 */
try {
__require.resolve("picomatch");
pm = __require("picomatch");
} catch {}
var Builder = class {
globCache = {};
options = {
maxDepth: Infinity,
suppressErrors: true,
pathSeparator: sep,
filters: []
};
globFunction;
constructor(options) {
this.options = {
...this.options,
...options
};
this.globFunction = this.options.globFunction;
}
group() {
this.options.group = true;
return this;
}
withPathSeparator(separator) {
this.options.pathSeparator = separator;
return this;
}
withBasePath() {
this.options.includeBasePath = true;
return this;
}
withRelativePaths() {
this.options.relativePaths = true;
return this;
}
withDirs() {
this.options.includeDirs = true;
return this;
}
withMaxDepth(depth) {
this.options.maxDepth = depth;
return this;
}
withMaxFiles(limit) {
this.options.maxFiles = limit;
return this;
}
withFullPaths() {
this.options.resolvePaths = true;
this.options.includeBasePath = true;
return this;
}
withErrors() {
this.options.suppressErrors = false;
return this;
}
withSymlinks({ resolvePaths = true } = {}) {
this.options.resolveSymlinks = true;
this.options.useRealPaths = resolvePaths;
return this.withFullPaths();
}
withAbortSignal(signal) {
this.options.signal = signal;
return this;
}
normalize() {
this.options.normalizePath = true;
return this;
}
filter(predicate) {
this.options.filters.push(predicate);
return this;
}
onlyDirs() {
this.options.excludeFiles = true;
this.options.includeDirs = true;
return this;
}
exclude(predicate) {
this.options.exclude = predicate;
return this;
}
onlyCounts() {
this.options.onlyCounts = true;
return this;
}
crawl(root) {
return new APIBuilder(root || ".", this.options);
}
withGlobFunction(fn) {
this.globFunction = fn;
return this;
}
/**
* @deprecated Pass options using the constructor instead:
* ```ts
* new fdir(options).crawl("/path/to/root");
* ```
* This method will be removed in v7.0
*/
/* c8 ignore next 4 */
crawlWithOptions(root, options) {
this.options = {
...this.options,
...options
};
return new APIBuilder(root || ".", this.options);
}
glob(...patterns) {
if (this.globFunction) return this.globWithOptions(patterns);
return this.globWithOptions(patterns, ...[{ dot: true }]);
}
globWithOptions(patterns, ...options) {
const globFn = this.globFunction || pm;
/* c8 ignore next 5 */
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
var isMatch = this.globCache[patterns.join("\0")];
if (!isMatch) {
isMatch = globFn(patterns, ...options);
this.globCache[patterns.join("\0")] = isMatch;
}
this.options.filters.push((path$3) => isMatch(path$3));
return this;
}
};
//#endregion
//#region ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const WIN_SLASH = "\\\\/";
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
/**
* Posix glob regex
*/
const DOT_LITERAL = "\\.";
const PLUS_LITERAL = "\\+";
const QMARK_LITERAL = "\\?";
const SLASH_LITERAL = "\\/";
const ONE_CHAR = "(?=.)";
const QMARK = "[^/]";
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
const POSIX_CHARS = {
DOT_LITERAL,
PLUS_LITERAL,
QMARK_LITERAL,
SLASH_LITERAL,
ONE_CHAR,
QMARK,
END_ANCHOR,
DOTS_SLASH,
NO_DOT: `(?!${DOT_LITERAL})`,
NO_DOTS: `(?!${START_ANCHOR}${DOTS_SLASH})`,
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`,
NO_DOTS_SLASH: `(?!${DOTS_SLASH})`,
QMARK_NO_DOT: `[^.${SLASH_LITERAL}]`,
STAR: `${QMARK}*?`,
START_ANCHOR,
SEP: "/"
};
/**
* Windows glob regex
*/
const WINDOWS_CHARS = {
...POSIX_CHARS,
SLASH_LITERAL: `[${WIN_SLASH}]`,
QMARK: WIN_NO_SLASH,
STAR: `${WIN_NO_SLASH}*?`,
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
NO_DOT: `(?!${DOT_LITERAL})`,
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
SEP: "\\"
};
/**
* POSIX Bracket Regex
*/
const POSIX_REGEX_SOURCE = {
alnum: "a-zA-Z0-9",
alpha: "a-zA-Z",
ascii: "\\x00-\\x7F",
blank: " \\t",
cntrl: "\\x00-\\x1F\\x7F",
digit: "0-9",
graph: "\\x21-\\x7E",
lower: "a-z",
print: "\\x20-\\x7E ",
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
space: " \\t\\r\\n\\v\\f",
upper: "A-Z",
word: "A-Za-z0-9_",
xdigit: "A-Fa-f0-9"
};
module.exports = {
MAX_LENGTH: 1024 * 64,
POSIX_REGEX_SOURCE,
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
REPLACEMENTS: {
__proto__: null,
"***": "*",
"**/**": "**",
"**/**/**": "**"
},
CHAR_0: 48,
CHAR_9: 57,
CHAR_UPPERCASE_A: 65,
CHAR_LOWERCASE_A: 97,
CHAR_UPPERCASE_Z: 90,
CHAR_LOWERCASE_Z: 122,
CHAR_LEFT_PARENTHESES: 40,
CHAR_RIGHT_PARENTHESES: 41,
CHAR_ASTERISK: 42,
CHAR_AMPERSAND: 38,
CHAR_AT: 64,
CHAR_BACKWARD_SLASH: 92,
CHAR_CARRIAGE_RETURN: 13,
CHAR_CIRCUMFLEX_ACCENT: 94,
CHAR_COLON: 58,
CHAR_COMMA: 44,
CHAR_DOT: 46,
CHAR_DOUBLE_QUOTE: 34,
CHAR_EQUAL: 61,
CHAR_EXCLAMATION_MARK: 33,
CHAR_FORM_FEED: 12,
CHAR_FORWARD_SLASH: 47,
CHAR_GRAVE_ACCENT: 96,
CHAR_HASH: 35,
CHAR_HYPHEN_MINUS: 45,
CHAR_LEFT_ANGLE_BRACKET: 60,
CHAR_LEFT_CURLY_BRACE: 123,
CHAR_LEFT_SQUARE_BRACKET: 91,
CHAR_LINE_FEED: 10,
CHAR_NO_BREAK_SPACE: 160,
CHAR_PERCENT: 37,
CHAR_PLUS: 43,
CHAR_QUESTION_MARK: 63,
CHAR_RIGHT_ANGLE_BRACKET: 62,
CHAR_RIGHT_CURLY_BRACE: 125,
CHAR_RIGHT_SQUARE_BRACKET: 93,
CHAR_SEMICOLON: 59,
CHAR_SINGLE_QUOTE: 39,
CHAR_SPACE: 32,
CHAR_TAB: 9,
CHAR_UNDERSCORE: 95,
CHAR_VERTICAL_LINE: 124,
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
extglobChars(chars) {
return {
"!": {
type: "negate",
open: "(?:(?!(?:",
close: `))${chars.STAR})`
},
"?": {
type: "qmark",
open: "(?:",
close: ")?"
},
"+": {
type: "plus",
open: "(?:",
close: ")+"
},
"*": {
type: "star",
open: "(?:",
close: ")*"
},
"@": {
type: "at",
open: "(?:",
close: ")"
}
};
},
globChars(win32) {
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
}
};
}));
//#endregion
//#region ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
exports.hasRegexChars = (str$1) => REGEX_SPECIAL_CHARS.test(str$1);
exports.isRegexChar = (str$1) => str$1.length === 1 && exports.hasRegexChars(str$1);
exports.escapeRegex = (str$1) => str$1.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
exports.toPosixSlashes = (str$1) => str$1.replace(REGEX_BACKSLASH, "/");
exports.isWindows = () => {
if (typeof navigator !== "undefined" && navigator.platform) {
const platform = navigator.platform.toLowerCase();
return platform === "win32" || platform === "windows";
}
if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
return false;
};
exports.removeBackslashes = (str$1) => {
return str$1.replace(REGEX_REMOVE_BACKSLASH, (match) => {
return match === "\\" ? "" : match;
});
};
exports.escapeLast = (input, char, lastIdx) => {
const idx = input.lastIndexOf(char, lastIdx);
if (idx === -1) return input;
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
};
exports.removePrefix = (input, state = {}) => {
let output = input;
if (output.startsWith("./")) {
output = output.slice(2);
state.prefix = "./";
}
return output;
};
exports.wrapOutput = (input, state = {}, options = {}) => {
let output = `${options.contains ? "" : "^"}(?:${input})${options.contains ? "" : "$"}`;
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
return output;
};
exports.basename = (path$3, { windows } = {}) => {
const segs = path$3.split(windows ? /[\\/]/ : "/");
const last = segs[segs.length - 1];
if (last === "") return segs[segs.length - 2];
return last;
};
}));
//#endregion
//#region ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const utils = require_utils$1();
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
const isPathSeparator = (code) => {
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
};
const depth = (token) => {
if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
};
/**
* Quickly scans a glob pattern and returns an object with a handful of
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
*
* ```js
* const pm = require('picomatch');
* console.log(pm.scan('foo/bar/*.js'));
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
* ```
* @param {String} `str`
* @param {Object} `options`
* @return {Object} Returns an object with tokens and regex source string.
* @api public
*/
const scan = (input, options) => {
const opts = options || {};
const length = input.length - 1;
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
const slashes = [];
const tokens = [];
const parts = [];
let str$1 = input;
let index = -1;
let start$1 = 0;
let lastIndex = 0;
let isBrace = false;
let isBracket = false;
let isGlob = false;
let isExtglob = false;
let isGlobstar = false;
let braceEscaped = false;
let backslashes = false;
let negated = false;
let negatedExtglob = false;
let finished = false;
let braces = 0;
let prev;
let code;
let token = {
value: "",
depth: 0,
isGlob: false
};
const eos = () => index >= length;
const peek = () => str$1.charCodeAt(index + 1);
const advance = () => {
prev = code;
return str$1.charCodeAt(++index);
};
while (index < length) {
code = advance();
let next;
if (code === CHAR_BACKWARD_SLASH) {
backslashes = token.backslashes = true;
code = advance();
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
continue;
}
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
braces++;
while (eos() !== true && (code = advance())) {
if (code === CHAR_BACKWARD_SLASH) {
backslashes = token.backslashes = true;
advance();
continue;
}
if (code === CHAR_LEFT_CURLY_BRACE) {
braces++;
continue;
}
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
isBrace = token.isBrace = true;
isGlob = token.isGlob = true;
finished = true;
if (scanToEnd === true) continue;
break;
}
if (braceEscaped !== true && code === CHAR_COMMA) {
isBrace = token.isBrace = true;
isGlob = token.isGlob = true;
finished = true;
if (scanToEnd === true) continue;
break;
}
if (code === CHAR_RIGHT_CURLY_BRACE) {
braces--;
if (braces === 0) {
braceEscaped = false;
isBrace = token.isBrace = true;
finished = true;
break;
}
}
}
if (scanToEnd === true) continue;
break;
}
if (code === CHAR_FORWARD_SLASH) {
slashes.push(index);
tokens.push(token);
token = {
value: "",
depth: 0,
isGlob: false
};
if (finished === true) continue;
if (prev === CHAR_DOT && index === start$1 + 1) {
start$1 += 2;
continue;
}
lastIndex = index + 1;
continue;
}
if (opts.noext !== true) {
if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) {
isGlob = token.isGlob = true;
isExtglob = token.isExtglob = true;
finished = true;
if (code === CHAR_EXCLAMATION_MARK && index === start$1) negatedExtglob = true;
if (scanToEnd === true) {
while (eos() !== true && (code = advance())) {
if (code === CHAR_BACKWARD_SLASH) {
backslashes = token.backslashes = true;
code = advance();
continue;
}
if (code === CHAR_RIGHT_PARENTHESES) {
isGlob = token.isGlob = true;
finished = true;
break;
}
}
continue;
}
break;
}
}
if (code === CHAR_ASTERISK) {
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
isGlob = token.isGlob = true;
finished = true;
if (scanToEnd === true) continue;
break;
}
if (code === CHAR_QUESTION_MARK) {
isGlob = token.isGlob = true;
finished = true;
if (scanToEnd === true) continue;
break;
}
if (code === CHAR_LEFT_SQUARE_BRACKET) {
while (eos() !== true && (next = advance())) {
if (next === CHAR_BACKWARD_SLASH) {
backslashes = token.backslashes = true;
advance();
continue;
}
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
isBracket = token.isBracket = true;
isGlob = token.isGlob = true;
finished = true;
break;
}
}
if (scanToEnd === true) continue;
break;
}
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start$1) {
negated = token.negated = true;
start$1++;
continue;
}
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
isGlob = token.isGlob = true;
if (scanToEnd === true) {
while (eos() !== true && (code = advance())) {
if (code === CHAR_LEFT_PARENTHESES) {
backslashes = token.backslashes = true;
code = advance();
continue;
}
if (code === CHAR_RIGHT_PARENTHESES) {
finished = true;
break;
}
}
continue;
}
break;
}
if (isGlob === true) {
finished = true;
if (scanToEnd === true) continue;
break;
}
}
if (opts.noext === true) {
isExtglob = false;
isGlob = false;
}
let base = str$1;
let prefix = "";
let glob$2 = "";
if (start$1 > 0) {
prefix = str$1.slice(0, start$1);
str$1 = str$1.slice(start$1);
lastIndex -= start$1;
}
if (base && isGlob === true && lastIndex > 0) {
base = str$1.slice(0, lastIndex);
glob$2 = str$1.slice(lastIndex);
} else if (isGlob === true) {
base = "";
glob$2 = str$1;
} else base = str$1;
if (base && base !== "" && base !== "/" && base !== str$1) {
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
}
if (opts.unescape === true) {
if (glob$2) glob$2 = utils.removeBackslashes(glob$2);
if (base && backslashes === true) base = utils.removeBackslashes(base);
}
const state = {
prefix,
input,
start: start$1,
base,
glob: glob$2,
isBrace,
isBracket,
isGlob,
isExtglob,
isGlobstar,
negated,
negatedExtglob
};
if (opts.tokens === true) {
state.maxDepth = 0;
if (!isPathSeparator(code)) tokens.push(token);
state.tokens = tokens;
}
if (opts.parts === true || opts.tokens === true) {
let prevIndex;
for (let idx = 0; idx < slashes.length; idx++) {
const n = prevIndex ? prevIndex + 1 : start$1;
const i$1 = slashes[idx];
const value = input.slice(n, i$1);
if (opts.tokens) {
if (idx === 0 && start$1 !== 0) {
tokens[idx].isPrefix = true;
tokens[idx].value = prefix;
} else tokens[idx].value = value;
depth(tokens[idx]);
state.maxDepth += tokens[idx].depth;
}
if (idx !== 0 || value !== "") parts.push(value);
prevIndex = i$1;
}
if (prevIndex && prevIndex + 1 < input.length) {
const value = input.slice(prevIndex + 1);
parts.push(value);
if (opts.tokens) {
tokens[tokens.length - 1].value = value;
depth(tokens[tokens.length - 1]);
state.maxDepth += tokens[tokens.length - 1].depth;
}
}
state.slashes = slashes;
state.parts = parts;
}
return state;
};
module.exports = scan;
}));
//#endregion
//#region ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const constants = require_constants();
const utils = require_utils$1();
/**
* Constants
*/
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
/**
* Helpers
*/
const expandRange = (args, options) => {
if (typeof options.expandRange === "function") return options.expandRange(...args, options);
args.sort();
const value = `[${args.join("-")}]`;
try {
new RegExp(value);
} catch (ex) {
return args.map((v) => utils.escapeRegex(v)).join("..");
}
return value;
};
/**
* Create the message for a syntax error
*/
const syntaxError = (type$2, char) => {
return `Missing ${type$2}: "${char}" - use "\\\\${char}" to match literal characters`;
};
/**
* Parse the given input string.
* @param {String} input
* @param {Object} options
* @return {Object}
*/
const parse = (input, options) => {
if (typeof input !== "string") throw new TypeError("Expected a string");
input = REPLACEMENTS[input] || input;
const opts = { ...options };
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
let len = input.length;
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
const bos = {
type: "bos",
value: "",
output: opts.prepend || ""
};
const tokens = [bos];
const capture = opts.capture ? "" : "?:";
const PLATFORM_CHARS = constants.globChars(opts.windows);
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
const globstar = (opts$1) => {
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
};
const nodot = opts.dot ? "" : NO_DOT;
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
let star = opts.bash === true ? globstar(opts) : STAR;
if (opts.capture) star = `(${star})`;
if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
const state = {
input,
index: -1,
start: 0,
dot: opts.dot === true,
consumed: "",
output: "",
prefix: "",
backtrack: false,
negated: false,
brackets: 0,
braces: 0,
parens: 0,
quotes: 0,
globstar: false,
tokens
};
input = utils.removePrefix(input, state);
len = input.length;
const extglobs = [];
const braces = [];
const stack = [];
let prev = bos;
let value;
/**
* Tokenizing helpers
*/
const eos = () => state.index === len - 1;
const peek = state.peek = (n = 1) => input[state.index + n];
const advance = state.advance = () => input[++state.index] || "";
const remaining = () => input.slice(state.index + 1);
const consume = (value$1 = "", num = 0) => {
state.consumed += value$1;
state.index += num;
};
const append = (token) => {
state.output += token.output != null ? token.output : token.value;
consume(token.value);
};
const negate = () => {
let count = 1;
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
advance();
state.start++;
count++;
}
if (count % 2 === 0) return false;
state.negated = true;
state.start++;
return true;
};
const increment = (type$2) => {
state[type$2]++;
stack.push(type$2);
};
const decrement = (type$2) => {
state[type$2]--;
stack.pop();
};
/**
* Push tokens onto the tokens array. This helper speeds up
* tokenizing by 1) helping us avoid backtracking as much as possible,
* and 2) helping us avoid creating extra tokens when consecutive
* characters are plain text. This improves performance and simplifies
* lookbehinds.
*/
const push = (tok) => {
if (prev.type === "globstar") {
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
state.output = state.output.slice(0, -prev.output.length);
prev.type = "star";
prev.value = "*";
prev.output = star;
state.output += prev.output;
}
}
if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
if (tok.value || tok.output) append(tok);
if (prev && prev.type === "text" && tok.type === "text") {
prev.output = (prev.output || prev.value) + tok.value;
prev.value += tok.value;
return;
}
tok.prev = prev;
tokens.push(tok);
prev = tok;
};
const extglobOpen = (type$2, value$1) => {
const token = {
...EXTGLOB_CHARS[value$1],
conditions: 1,
inner: ""
};
token.prev = prev;
token.parens = state.parens;
token.output = state.output;
const output = (opts.capture ? "(" : "") + token.open;
increment("parens");
push({
type: type$2,
value: value$1,
output: state.output ? "" : ONE_CHAR
});
push({
type: "paren",
extglob: true,
value: advance(),
output
});
extglobs.push(token);
};
const extglobClose = (token) => {
let output = token.close + (opts.capture ? ")" : "");
let rest;
if (token.type === "negate") {
let extglobStar = star;
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse(rest, {
...options,
fastpaths: false
}).output})${extglobStar})`;
if (token.prev.type === "bos") state.negatedExtglob = true;
}
push({
type: "paren",
extglob: true,
value,
output
});
decrement("parens");
};
/**
* Fast paths
*/
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
let backslashes = false;
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
if (first === "\\") {
backslashes = true;
return m;
}
if (first === "?") {
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : "");
if (index === 0) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
return QMARK.repeat(chars.length);
}
if (first === ".") return DOT_LITERAL.repeat(chars.length);
if (first === "*") {
if (esc) return esc + first + (rest ? star : "");
return star;
}
return esc ? m : `\\${m}`;
});
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
else output = output.replace(/\\+/g, (m) => {
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
});
if (output === input && opts.contains === true) {
state.output = input;
return state;
}
state.output = utils.wrapOutput(output, state, options);
return state;
}
/**
* Tokenize input until we reach end-of-string
*/
while (!eos()) {
value = advance();
if (value === "\0") continue;
/**
* Escaped characters
*/
if (value === "\\") {
const next = peek();
if (next === "/" && opts.bash !== true) continue;
if (next === "." || next === ";") continue;
if (!next) {
value += "\\";
push({
type: "text",
value
});
continue;
}
const match = /^\\+/.exec(remaining());
let slashes = 0;
if (match && match[0].length > 2) {
slashes = match[0].length;
state.index += slashes;
if (slashes % 2 !== 0) value += "\\";
}
if (opts.unescape === true) value = advance();
else value += advance();
if (state.brackets === 0) {
push({
type: "text",
value
});
continue;
}
}
/**
* If we're inside a regex character class, continue
* until we reach the closing bracket.
*/
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
if (opts.posix !== false && value === ":") {
const inner = prev.value.slice(1);
if (inner.includes("[")) {
prev.posix = true;
if (inner.includes(":")) {
const idx = prev.value.lastIndexOf("[");
const pre = prev.value.slice(0, idx);
const posix$1 = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
if (posix$1) {
prev.value = pre + posix$1;
state.backtrack = true;
advance();
if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR;
continue;
}
}
}
}
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
prev.value += value;
append({ value });
continue;
}
/**
* If we're inside a quoted string, continue
* until we reach the closing double quote.
*/
if (state.quotes === 1 && value !== "\"") {
value = utils.escapeRegex(value);
prev.value += value;
append({ value });
continue;
}
/**
* Double quotes
*/
if (value === "\"") {
state.quotes = state.quotes === 1 ? 0 : 1;
if (opts.keepQuotes === true) push({
type: "text",
value
});
continue;
}
/**
* Parentheses
*/
if (value === "(") {
increment("parens");
push({
type: "paren",
value
});
continue;
}
if (value === ")") {
if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
const extglob = extglobs[extglobs.length - 1];
if (extglob && state.parens === extglob.parens + 1) {
extglobClose(extglobs.pop());
continue;
}
push({
type: "paren",
value,
output: state.parens ? ")" : "\\)"
});
decrement("parens");
continue;
}
/**
* Square brackets
*/
if (value === "[") {
if (opts.nobracket === true || !remaining().includes("]")) {
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
value = `\\${value}`;
} else increment("brackets");
push({
type: "bracket",
value
});
continue;
}
if (value === "]") {
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
push({
type: "text",
value,
output: `\\${value}`
});
continue;
}
if (state.brackets === 0) {
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
push({
type: "text",
value,
output: `\\${value}`
});
continue;
}
decrement("brackets");
const prevValue = prev.value.slice(1);
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
prev.value += value;
append({ value });
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) continue;
const escaped = utils.escapeRegex(prev.value);
state.output = state.output.slice(0, -prev.value.length);
if (opts.literalBrackets === true) {
state.output += escaped;
prev.value = escaped;
continue;
}
prev.value = `(${capture}${escaped}|${prev.value})`;
state.output += prev.value;
continue;
}
/**
* Braces
*/
if (value === "{" && opts.nobrace !== true) {
increment("braces");
const open = {
type: "brace",
value,
output: "(",
outputIndex: state.output.length,
tokensIndex: state.tokens.length
};
braces.push(open);
push(open);
continue;
}
if (value === "}") {
const brace = braces[braces.length - 1];
if (opts.nobrace === true || !brace) {
push({
type: "text",
value,
output: value
});
continue;
}
let output = ")";
if (brace.dots === true) {
const arr = tokens.slice();
const range = [];
for (let i$1 = arr.length - 1; i$1 >= 0; i$1--) {
tokens.pop();
if (arr[i$1].type === "brace") break;
if (arr[i$1].type !== "dots") range.unshift(arr[i$1].value);
}
output = expandRange(range, opts);
state.backtrack = true;
}
if (brace.comma !== true && brace.dots !== true) {
const out = state.output.slice(0, brace.outputIndex);
const toks = state.tokens.slice(brace.tokensIndex);
brace.value = brace.output = "\\{";
value = output = "\\}";
state.output = out;
for (const t of toks) state.output += t.output || t.value;
}
push({
type: "brace",
value,
output
});
decrement("braces");
braces.pop();
continue;
}
/**
* Pipes
*/
if (value === "|") {
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
push({
type: "text",
value
});
continue;
}
/**
* Commas
*/
if (value === ",") {
let output = value;
const brace = braces[braces.length - 1];
if (brace && stack[stack.length - 1] === "braces") {
brace.comma = true;
output = "|";
}
push({
type: "comma",
value,
output
});
continue;
}
/**
* Slashes
*/
if (value === "/") {
if (prev.type === "dot" && state.index === state.start + 1) {
state.start = state.index + 1;
state.consumed = "";
state.output = "";
tokens.pop();
prev = bos;
continue;
}
push({
type: "slash",
value,
output: SLASH_LITERAL
});
continue;
}
/**
* Dots
*/
if (value === ".") {
if (state.braces > 0 && prev.type === "dot") {
if (prev.value === ".") prev.output = DOT_LITERAL;
const brace = braces[braces.length - 1];
prev.type = "dots";
prev.output += value;
prev.value += value;
brace.dots = true;
continue;
}
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
push({
type: "text",
value,
output: DOT_LITERAL
});
continue;
}
push({
type: "dot",
value,
output: DOT_LITERAL
});
continue;
}
/**
* Question marks
*/
if (value === "?") {
if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
extglobOpen("qmark", value);
continue;
}
if (prev && prev.type === "paren") {
const next = peek();
let output = value;
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
push({
type: "text",
value,
output
});
continue;
}
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
push({
type: "qmark",
value,
output: QMARK_NO_DOT
});
continue;
}
push({
type: "qmark",
value,
output: QMARK
});
continue;
}
/**
* Exclamation
*/
if (value === "!") {
if (opts.noextglob !== true && peek() === "(") {
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
extglobOpen("negate", value);
continue;
}
}
if (opts.nonegate !== true && state.index === 0) {
negate();
continue;
}
}
/**
* Plus
*/
if (value === "+") {
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
extglobOpen("plus", value);
continue;
}
if (prev && prev.value === "(" || opts.regex === false) {
push({
type: "plus",
value,
output: PLUS_LITERAL
});
continue;
}
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
push({
type: "plus",
value
});
continue;
}
push({
type: "plus",
value: PLUS_LITERAL
});
continue;
}
/**
* Plain text
*/
if (value === "@") {
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
push({
type: "at",
extglob: true,
value,
output: ""
});
continue;
}
push({
type: "text",
value
});
continue;
}
/**
* Plain text
*/
if (value !== "*") {
if (value === "$" || value === "^") value = `\\${value}`;
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
if (match) {
value += match[0];
state.index += match[0].length;
}
push({
type: "text",
value
});
continue;
}
/**
* Stars
*/
if (prev && (prev.type === "globstar" || prev.star === true)) {
prev.type = "star";
prev.star = true;
prev.value += value;
prev.output = star;
state.backtrack = true;
state.globstar = true;
consume(value);
continue;
}
let rest = remaining();
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
extglobOpen("star", value);
continue;
}
if (prev.type === "star") {
if (opts.noglobstar === true) {
consume(value);
continue;
}
const prior = prev.prev;
const before = prior.prev;
const isStart = prior.type === "slash" || prior.type === "bos";
const afterStar = before && (before.type === "star" || before.type === "globstar");
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
push({
type: "star",
value,
output: ""
});
continue;
}
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
push({
type: "star",
value,
output: ""
});
continue;
}
while (rest.slice(0, 3) === "/**") {
const after = input[state.index + 4];
if (after && after !== "/") break;
rest = rest.slice(3);
consume("/**", 3);
}
if (prior.type === "bos" && eos()) {
prev.type = "globstar";
prev.value += value;
prev.output = globstar(opts);
state.output = prev.output;
state.globstar = true;
consume(value);
continue;
}
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
state.output = state.output.slice(0, -(prior.output + prev.output).length);
prior.output = `(?:${prior.output}`;
prev.type = "globstar";
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
prev.value += value;
state.globstar = true;
state.output += prior.output + prev.output;
consume(value);
continue;
}
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
const end = rest[1] !== void 0 ? "|$" : "";
state.output = state.output.slice(0, -(prior.output + prev.output).length);
prior.output = `(?:${prior.output}`;
prev.type = "globstar";
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
prev.value += value;
state.output += prior.output + prev.output;
state.globstar = true;
consume(value + advance());
push({
type: "slash",
value: "/",
output: ""
});
continue;
}
if (prior.type === "bos" && rest[0] === "/") {
prev.type = "globstar";
prev.value += value;
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
state.output = prev.output;
state.globstar = true;
consume(value + advance());
push({
type: "slash",
value: "/",
output: ""
});
continue;
}
state.output = state.output.slice(0, -prev.output.length);
prev.type = "globstar";
prev.output = globstar(opts);
prev.value += value;
state.output += prev.output;
state.globstar = true;
consume(value);
continue;
}
const token = {
type: "star",
value,
output: star
};
if (opts.bash === true) {
token.output = ".*?";
if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
push(token);
continue;
}
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
token.output = value;
push(token);
continue;
}
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
if (prev.type === "dot") {
state.output += NO_DOT_SLASH;
prev.output += NO_DOT_SLASH;
} else if (opts.dot === true) {
state.output += NO_DOTS_SLASH;
prev.output += NO_DOTS_SLASH;
} else {
state.output += nodot;
prev.output += nodot;
}
if (peek() !== "*") {
state.output += ONE_CHAR;
prev.output += ONE_CHAR;
}
}
push(token);
}
while (state.brackets > 0) {
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
state.output = utils.escapeLast(state.output, "[");
decrement("brackets");
}
while (state.parens > 0) {
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
state.output = utils.escapeLast(state.output, "(");
decrement("parens");
}
while (state.braces > 0) {
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
state.output = utils.escapeLast(state.output, "{");
decrement("braces");
}
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
type: "maybe_slash",
value: "",
output: `${SLASH_LITERAL}?`
});
if (state.backtrack === true) {
state.output = "";
for (const token of state.tokens) {
state.output += token.output != null ? token.output : token.value;
if (token.suffix) state.output += token.suffix;
}
}
return state;
};
/**
* Fast paths for creating regular expressions for common glob patterns.
* This can significantly speed up processing and has very little downside
* impact when none of the fast paths match.
*/
parse.fastpaths = (input, options) => {
const opts = { ...options };
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
const len = input.length;
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
input = REPLACEMENTS[input] || input;
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
const nodot = opts.dot ? NO_DOTS : NO_DOT;
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
const capture = opts.capture ? "" : "?:";
const state = {
negated: false,
prefix: ""
};
let star = opts.bash === true ? ".*?" : STAR;
if (opts.capture) star = `(${star})`;
const globstar = (opts$1) => {
if (opts$1.noglobstar === true) return star;
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
};
const create = (str$1) => {
switch (str$1) {
case "*": return `${nodot}${ONE_CHAR}${star}`;
case ".*": return `${DOT_LITERAL}${ONE_CHAR}${star}`;
case "*.*": return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
case "*/*": return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
case "**": return nodot + globstar(opts);
case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
default: {
const match = /^(.*?)\.(\w+)$/.exec(str$1);
if (!match) return;
const source$1 = create(match[1]);
if (!source$1) return;
return source$1 + DOT_LITERAL + match[2];
}
}
};
let source = create(utils.removePrefix(input, state));
if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL}?`;
return source;
};
module.exports = parse;
}));
//#endregion
//#region ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const scan = require_scan();
const parse = require_parse$1();
const utils = require_utils$1();
const constants = require_constants();
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
/**
* Creates a matcher function from one or more glob patterns. The
* returned function takes a string to match as its first argument,
* and returns true if the string is a match. The returned matcher
* function also takes a boolean as the second argument that, when true,
* returns an object with additional information.
*
* ```js
* const picomatch = require('picomatch');
* // picomatch(glob[, options]);
*
* const isMatch = picomatch('*.!(*a)');
* console.log(isMatch('a.a')); //=> false
* console.log(isMatch('a.b')); //=> true
* ```
* @name picomatch
* @param {String|Array} `globs` One or more glob patterns.
* @param {Object=} `options`
* @return {Function=} Returns a matcher function.
* @api public
*/
const picomatch = (glob$2, options, returnState = false) => {
if (Array.isArray(glob$2)) {
const fns = glob$2.map((input) => picomatch(input, options, returnState));
const arrayMatcher = (str$1) => {
for (const isMatch of fns) {
const state$1 = isMatch(str$1);
if (state$1) return state$1;
}
return false;
};
return arrayMatcher;
}
const isState = isObject(glob$2) && glob$2.tokens && glob$2.input;
if (glob$2 === "" || typeof glob$2 !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
const opts = options || {};
const posix$1 = opts.windows;
const regex = isState ? picomatch.compileRe(glob$2, options) : picomatch.makeRe(glob$2, options, false, true);
const state = regex.state;
delete regex.state;
let isIgnored = () => false;
if (opts.ignore) {
const ignoreOpts = {
...options,
ignore: null,
onMatch: null,
onResult: null
};
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
}
const matcher = (input, returnObject = false) => {
const { isMatch, match, output } = picomatch.test(input, regex, options, {
glob: glob$2,
posix: posix$1
});
const result = {
glob: glob$2,
state,
regex,
posix: posix$1,
input,
output,
match,
isMatch
};
if (typeof opts.onResult === "function") opts.onResult(result);
if (isMatch === false) {
result.isMatch = false;
return returnObject ? result : false;
}
if (isIgnored(input)) {
if (typeof opts.onIgnore === "function") opts.onIgnore(result);
result.isMatch = false;
return returnObject ? result : false;
}
if (typeof opts.onMatch === "function") opts.onMatch(result);
return returnObject ? result : true;
};
if (returnState) matcher.state = state;
return matcher;
};
/**
* Test `input` with the given `regex`. This is used by the main
* `picomatch()` function to test the input string.
*
* ```js
* const picomatch = require('picomatch');
* // picomatch.test(input, regex[, options]);
*
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
* ```
* @param {String} `input` String to test.
* @param {RegExp} `regex`
* @return {Object} Returns an object with matching info.
* @api public
*/
picomatch.test = (input, regex, options, { glob: glob$2, posix: posix$1 } = {}) => {
if (typeof input !== "string") throw new TypeError("Expected input to be a string");
if (input === "") return {
isMatch: false,
output: ""
};
const opts = options || {};
const format = opts.format || (posix$1 ? utils.toPosixSlashes : null);
let match = input === glob$2;
let output = match && format ? format(input) : input;
if (match === false) {
output = format ? format(input) : input;
match = output === glob$2;
}
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix$1);
else match = regex.exec(output);
return {
isMatch: Boolean(match),
match,
output
};
};
/**
* Match the basename of a filepath.
*
* ```js
* const picomatch = require('picomatch');
* // picomatch.matchBase(input, glob[, options]);
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
* ```
* @param {String} `input` String to test.
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
* @return {Boolean}
* @api public
*/
picomatch.matchBase = (input, glob$2, options) => {
return (glob$2 instanceof RegExp ? glob$2 : picomatch.makeRe(glob$2, options)).test(utils.basename(input));
};
/**
* Returns true if **any** of the given glob `patterns` match the specified `string`.
*
* ```js
* const picomatch = require('picomatch');
* // picomatch.isMatch(string, patterns[, options]);
*
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
* ```
* @param {String|Array} str The string to test.
* @param {String|Array} patterns One or more glob patterns to use for matching.
* @param {Object} [options] See available [options](#options).
* @return {Boolean} Returns true if any patterns match `str`
* @api public
*/
picomatch.isMatch = (str$1, patterns, options) => picomatch(patterns, options)(str$1);
/**
* Parse a glob pattern to create the source string for a regular
* expression.
*
* ```js
* const picomatch = require('picomatch');
* const result = picomatch.parse(pattern[, options]);
* ```
* @param {String} `pattern`
* @param {Object} `options`
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
* @api public
*/
picomatch.parse = (pattern, options) => {
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
return parse(pattern, {
...options,
fastpaths: false
});
};
/**
* Scan a glob pattern to separate the pattern into segments.
*
* ```js
* const picomatch = require('picomatch');
* // picomatch.scan(input[, options]);
*
* const result = picomatch.scan('!./foo/*.js');
* console.log(result);
* { prefix: '!./',
* input: '!./foo/*.js',
* start: 3,
* base: 'foo',
* glob: '*.js',
* isBrace: false,
* isBracket: false,
* isGlob: true,
* isExtglob: false,
* isGlobstar: false,
* negated: true }
* ```
* @param {String} `input` Glob pattern to scan.
* @param {Object} `options`
* @return {Object} Returns an object with
* @api public
*/
picomatch.scan = (input, options) => scan(input, options);
/**
* Compile a regular expression from the `state` object returned by the
* [parse()](#parse) method.
*
* @param {Object} `state`
* @param {Object} `options`
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
* @return {RegExp}
* @api public
*/
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
if (returnOutput === true) return state.output;
const opts = options || {};
const prepend = opts.contains ? "" : "^";
const append = opts.contains ? "" : "$";
let source = `${prepend}(?:${state.output})${append}`;
if (state && state.negated === true) source = `^(?!${source}).*$`;
const regex = picomatch.toRegex(source, options);
if (returnState === true) regex.state = state;
return regex;
};
/**
* Create a regular expression from a parsed glob pattern.
*
* ```js
* const picomatch = require('picomatch');
* const state = picomatch.parse('*.js');
* // picomatch.compileRe(state[, options]);
*
* console.log(picomatch.compileRe(state));
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
* ```
* @param {String} `state` The object returned from the `.parse` method.
* @param {Object} `options`
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
* @return {RegExp} Returns a regex created from the given pattern.
* @api public
*/
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
let parsed = {
negated: false,
fastpaths: true
};
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
if (!parsed.output) parsed = parse(input, options);
return picomatch.compileRe(parsed, options, returnOutput, returnState);
};
/**
* Create a regular expression from the given regex source string.
*
* ```js
* const picomatch = require('picomatch');
* // picomatch.toRegex(source[, options]);
*
* const { output } = picomatch.parse('*.js');
* console.log(picomatch.toRegex(output));
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
* ```
* @param {String} `source` Regular expression source string.
* @param {Object} `options`
* @return {RegExp}
* @api public
*/
picomatch.toRegex = (source, options) => {
try {
const opts = options || {};
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
} catch (err) {
if (options && options.debug === true) throw err;
return /$^/;
}
};
/**
* Picomatch constants.
* @return {Object}
*/
picomatch.constants = constants;
/**
* Expose "picomatch"
*/
module.exports = picomatch;
}));
//#endregion
//#region ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const pico = require_picomatch$1();
const utils = require_utils$1();
function picomatch(glob$2, options, returnState = false) {
if (options && (options.windows === null || options.windows === void 0)) options = {
...options,
windows: utils.isWindows()
};
return pico(glob$2, options, returnState);
}
Object.assign(picomatch, pico);
module.exports = picomatch;
}));
//#endregion
//#region ../../node_modules/.pnpm/tinyglobby@0.2.15/node_modules/tinyglobby/dist/index.mjs
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
const isReadonlyArray = Array.isArray;
const isWin = process.platform === "win32";
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
function getPartialMatcher(patterns, options = {}) {
const patternsCount = patterns.length;
const patternsParts = Array(patternsCount);
const matchers = Array(patternsCount);
const globstarEnabled = !options.noglobstar;
for (let i$1 = 0; i$1 < patternsCount; i$1++) {
const parts = splitPattern(patterns[i$1]);
patternsParts[i$1] = parts;
const partsCount = parts.length;
const partMatchers = Array(partsCount);
for (let j = 0; j < partsCount; j++) partMatchers[j] = (0, import_picomatch.default)(parts[j], options);
matchers[i$1] = partMatchers;
}
return (input) => {
const inputParts = input.split("/");
if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
for (let i$1 = 0; i$1 < patterns.length; i$1++) {
const patternParts = patternsParts[i$1];
const matcher = matchers[i$1];
const inputPatternCount = inputParts.length;
const minParts = Math.min(inputPatternCount, patternParts.length);
let j = 0;
while (j < minParts) {
const part = patternParts[j];
if (part.includes("/")) return true;
if (!matcher[j](inputParts[j])) break;
if (globstarEnabled && part === "**") return true;
j++;
}
if (j === inputPatternCount) return true;
}
return false;
};
}
/* node:coverage ignore next 2 */
const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
const isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
function buildFormat(cwd, root, absolute) {
if (cwd === root || root.startsWith(`${cwd}/`)) {
if (absolute) {
const start$1 = isRoot(cwd) ? cwd.length : cwd.length + 1;
return (p, isDir) => p.slice(start$1, isDir ? -1 : void 0) || ".";
}
const prefix = root.slice(cwd.length + 1);
if (prefix) return (p, isDir) => {
if (p === ".") return prefix;
const result = `${prefix}/${p}`;
return isDir ? result.slice(0, -1) : result;
};
return (p, isDir) => isDir && p !== "." ? p.slice(0, -1) : p;
}
if (absolute) return (p) => posix.relative(cwd, p) || ".";
return (p) => posix.relative(cwd, `${root}/${p}`) || ".";
}
function buildRelative(cwd, root) {
if (root.startsWith(`${cwd}/`)) {
const prefix = root.slice(cwd.length + 1);
return (p) => `${prefix}/${p}`;
}
return (p) => {
const result = posix.relative(cwd, `${root}/${p}`);
if (p.endsWith("/") && result !== "") return `${result}/`;
return result || ".";
};
}
const splitPatternOptions = { parts: true };
function splitPattern(path$1$1) {
var _result$parts;
const result = import_picomatch.default.scan(path$1$1, splitPatternOptions);
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1$1];
}
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
const escapePosixPath = (path$1$1) => path$1$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
const escapeWin32Path = (path$1$1) => path$1$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
/**
* Escapes a path's special characters depending on the platform.
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
*/
/* node:coverage ignore next */
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
/**
* Checks if a pattern has dynamic parts.
*
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
*
* - Doesn't necessarily return `false` on patterns that include `\`.
* - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
* - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
* - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
*
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
*/
function isDynamicPattern(pattern, options) {
if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
const scan = import_picomatch.default.scan(pattern);
return scan.isGlob || scan.negated;
}
function log(...tasks) {
console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
}
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
const BACKSLASHES = /\\/g;
function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
let result = pattern;
if (pattern.endsWith("/")) result = pattern.slice(0, -1);
if (!result.endsWith("*") && expandDirectories) result += "/**";
const escapedCwd = escapePath(cwd);
if (path$1.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = posix.relative(escapedCwd, result);
else result = posix.normalize(result);
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
const parts = splitPattern(result);
if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
const n = (parentDirectoryMatch[0].length + 1) / 3;
let i$1 = 0;
const cwdParts = escapedCwd.split("/");
while (i$1 < n && parts[i$1 + n] === cwdParts[cwdParts.length + i$1 - n]) {
result = result.slice(0, (n - i$1 - 1) * 3) + result.slice((n - i$1) * 3 + parts[i$1 + n].length + 1) || ".";
i$1++;
}
const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(i$1 * 3));
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
props.root = potentialRoot;
props.depthOffset = -n + i$1;
}
}
if (!isIgnore && props.depthOffset >= 0) {
var _props$commonPath;
(_props$commonPath = props.commonPath) !== null && _props$commonPath !== void 0 || (props.commonPath = parts);
const newCommonPath = [];
const length = Math.min(props.commonPath.length, parts.length);
for (let i$1 = 0; i$1 < length; i$1++) {
const part = parts[i$1];
if (part === "**" && !parts[i$1 + 1]) {
newCommonPath.pop();
break;
}
if (part !== props.commonPath[i$1] || isDynamicPattern(part) || i$1 === parts.length - 1) break;
newCommonPath.push(part);
}
props.depthOffset = newCommonPath.length;
props.commonPath = newCommonPath;
props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
}
return result;
}
function processPatterns({ patterns = ["**/*"], ignore = [], expandDirectories = true }, cwd, props) {
if (typeof patterns === "string") patterns = [patterns];
if (typeof ignore === "string") ignore = [ignore];
const matchPatterns = [];
const ignorePatterns = [];
for (const pattern of ignore) {
if (!pattern) continue;
if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
}
for (const pattern of patterns) {
if (!pattern) continue;
if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
}
return {
match: matchPatterns,
ignore: ignorePatterns
};
}
function formatPaths(paths, relative$1) {
for (let i$1 = paths.length - 1; i$1 >= 0; i$1--) {
const path$1$1 = paths[i$1];
paths[i$1] = relative$1(path$1$1);
}
return paths;
}
function normalizeCwd(cwd) {
if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
if (cwd instanceof URL) return fileURLToPath$1(cwd).replace(BACKSLASHES, "/");
return path$1.resolve(cwd).replace(BACKSLASHES, "/");
}
function getCrawler(patterns, inputOptions = {}) {
const options = process.env.TINYGLOBBY_DEBUG ? {
...inputOptions,
debug: true
} : inputOptions;
const cwd = normalizeCwd(options.cwd);
if (options.debug) log("globbing with:", {
patterns,
options,
cwd
});
if (Array.isArray(patterns) && patterns.length === 0) return [{
sync: () => [],
withPromise: async () => []
}, false];
const props = {
root: cwd,
commonPath: null,
depthOffset: 0
};
const processed = processPatterns({
...options,
patterns
}, cwd, props);
if (options.debug) log("internal processing patterns:", processed);
const matchOptions = {
dot: options.dot,
nobrace: options.braceExpansion === false,
nocase: options.caseSensitiveMatch === false,
noextglob: options.extglob === false,
noglobstar: options.globstar === false,
posix: true
};
const matcher = (0, import_picomatch.default)(processed.match, {
...matchOptions,
ignore: processed.ignore
});
const ignore = (0, import_picomatch.default)(processed.ignore, matchOptions);
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
const format = buildFormat(cwd, props.root, options.absolute);
const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
const fdirOptions = {
filters: [options.debug ? (p, isDirectory) => {
const path$1$1 = format(p, isDirectory);
const matches = matcher(path$1$1);
if (matches) log(`matched ${path$1$1}`);
return matches;
} : (p, isDirectory) => matcher(format(p, isDirectory))],
exclude: options.debug ? (_, p) => {
const relativePath = formatExclude(p, true);
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
if (skipped) log(`skipped ${p}`);
else log(`crawling ${p}`);
return skipped;
} : (_, p) => {
const relativePath = formatExclude(p, true);
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
},
fs: options.fs ? {
readdir: options.fs.readdir || nativeFs.readdir,
readdirSync: options.fs.readdirSync || nativeFs.readdirSync,
realpath: options.fs.realpath || nativeFs.realpath,
realpathSync: options.fs.realpathSync || nativeFs.realpathSync,
stat: options.fs.stat || nativeFs.stat,
statSync: options.fs.statSync || nativeFs.statSync
} : void 0,
pathSeparator: "/",
relativePaths: true,
resolveSymlinks: true,
signal: options.signal
};
if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
if (options.absolute) {
fdirOptions.relativePaths = false;
fdirOptions.resolvePaths = true;
fdirOptions.includeBasePath = true;
}
if (options.followSymbolicLinks === false) {
fdirOptions.resolveSymlinks = false;
fdirOptions.excludeSymlinks = true;
}
if (options.onlyDirectories) {
fdirOptions.excludeFiles = true;
fdirOptions.includeDirs = true;
} else if (options.onlyFiles === false) fdirOptions.includeDirs = true;
props.root = props.root.replace(BACKSLASHES, "");
const root = props.root;
if (options.debug) log("internal properties:", props);
const relative$1 = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
return [new Builder(fdirOptions).crawl(root), relative$1];
}
async function glob$1(patternsOrOptions, options) {
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
const opts = isModern ? options : patternsOrOptions;
const [crawler, relative$1] = getCrawler(isModern ? patternsOrOptions : patternsOrOptions.patterns, opts);
if (!relative$1) return crawler.withPromise();
return formatPaths(await crawler.withPromise(), relative$1);
}
function globSync(patternsOrOptions, options) {
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
const opts = isModern ? options : patternsOrOptions;
const [crawler, relative$1] = getCrawler(isModern ? patternsOrOptions : patternsOrOptions.patterns, opts);
if (!relative$1) return crawler.sync();
return formatPaths(crawler.sync(), relative$1);
}
//#endregion
//#region ../../node_modules/.pnpm/js-yaml@4.1.1/node_modules/js-yaml/dist/js-yaml.mjs
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
function isNothing(subject) {
return typeof subject === "undefined" || subject === null;
}
function isObject(subject) {
return typeof subject === "object" && subject !== null;
}
function toArray(sequence) {
if (Array.isArray(sequence)) return sequence;
else if (isNothing(sequence)) return [];
return [sequence];
}
function extend(target, source) {
var index, length, key, sourceKeys;
if (source) {
sourceKeys = Object.keys(source);
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
key = sourceKeys[index];
target[key] = source[key];
}
}
return target;
}
function repeat(string, count) {
var result = "", cycle;
for (cycle = 0; cycle < count; cycle += 1) result += string;
return result;
}
function isNegativeZero(number) {
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
}
var common = {
isNothing,
isObject,
toArray,
repeat,
isNegativeZero,
extend
};
function formatError(exception$1, compact) {
var where = "", message = exception$1.reason || "(unknown reason)";
if (!exception$1.mark) return message;
if (exception$1.mark.name) where += "in \"" + exception$1.mark.name + "\" ";
where += "(" + (exception$1.mark.line + 1) + ":" + (exception$1.mark.column + 1) + ")";
if (!compact && exception$1.mark.snippet) where += "\n\n" + exception$1.mark.snippet;
return message + " " + where;
}
function YAMLException$1(reason, mark) {
Error.call(this);
this.name = "YAMLException";
this.reason = reason;
this.mark = mark;
this.message = formatError(this, false);
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
else this.stack = (/* @__PURE__ */ new Error()).stack || "";
}
YAMLException$1.prototype = Object.create(Error.prototype);
YAMLException$1.prototype.constructor = YAMLException$1;
YAMLException$1.prototype.toString = function toString(compact) {
return this.name + ": " + formatError(this, compact);
};
var exception = YAMLException$1;
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
var head = "";
var tail = "";
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
if (position - lineStart > maxHalfLength) {
head = " ... ";
lineStart = position - maxHalfLength + head.length;
}
if (lineEnd - position > maxHalfLength) {
tail = " ...";
lineEnd = position + maxHalfLength - tail.length;
}
return {
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
pos: position - lineStart + head.length
};
}
function padStart(string, max) {
return common.repeat(" ", max - string.length) + string;
}
function makeSnippet(mark, options) {
options = Object.create(options || null);
if (!mark.buffer) return null;
if (!options.maxLength) options.maxLength = 79;
if (typeof options.indent !== "number") options.indent = 1;
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
var re = /\r?\n|\r|\0/g;
var lineStarts = [0];
var lineEnds = [];
var match;
var foundLineNo = -1;
while (match = re.exec(mark.buffer)) {
lineEnds.push(match.index);
lineStarts.push(match.index + match[0].length);
if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
}
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
var result = "", i$1, line;
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
for (i$1 = 1; i$1 <= options.linesBefore; i$1++) {
if (foundLineNo - i$1 < 0) break;
line = getLine(mark.buffer, lineStarts[foundLineNo - i$1], lineEnds[foundLineNo - i$1], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i$1]), maxLineLength);
result = common.repeat(" ", options.indent) + padStart((mark.line - i$1 + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
}
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
for (i$1 = 1; i$1 <= options.linesAfter; i$1++) {
if (foundLineNo + i$1 >= lineEnds.length) break;
line = getLine(mark.buffer, lineStarts[foundLineNo + i$1], lineEnds[foundLineNo + i$1], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i$1]), maxLineLength);
result += common.repeat(" ", options.indent) + padStart((mark.line + i$1 + 1).toString(), lineNoLength) + " | " + line.str + "\n";
}
return result.replace(/\n$/, "");
}
var snippet = makeSnippet;
var TYPE_CONSTRUCTOR_OPTIONS = [
"kind",
"multi",
"resolve",
"construct",
"instanceOf",
"predicate",
"represent",
"representName",
"defaultStyle",
"styleAliases"
];
var YAML_NODE_KINDS = [
"scalar",
"sequence",
"mapping"
];
function compileStyleAliases(map$1) {
var result = {};
if (map$1 !== null) Object.keys(map$1).forEach(function(style) {
map$1[style].forEach(function(alias) {
result[String(alias)] = style;
});
});
return result;
}
function Type$1(tag, options) {
options = options || {};
Object.keys(options).forEach(function(name$1) {
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name$1) === -1) throw new exception("Unknown option \"" + name$1 + "\" is met in definition of \"" + tag + "\" YAML type.");
});
this.options = options;
this.tag = tag;
this.kind = options["kind"] || null;
this.resolve = options["resolve"] || function() {
return true;
};
this.construct = options["construct"] || function(data) {
return data;
};
this.instanceOf = options["instanceOf"] || null;
this.predicate = options["predicate"] || null;
this.represent = options["represent"] || null;
this.representName = options["representName"] || null;
this.defaultStyle = options["defaultStyle"] || null;
this.multi = options["multi"] || false;
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) throw new exception("Unknown kind \"" + this.kind + "\" is specified for \"" + tag + "\" YAML type.");
}
var type$1 = Type$1;
function compileList(schema$1, name$1) {
var result = [];
schema$1[name$1].forEach(function(currentType) {
var newIndex = result.length;
result.forEach(function(previousType, previousIndex) {
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) newIndex = previousIndex;
});
result[newIndex] = currentType;
});
return result;
}
function compileMap() {
var result = {
scalar: {},
sequence: {},
mapping: {},
fallback: {},
multi: {
scalar: [],
sequence: [],
mapping: [],
fallback: []
}
}, index, length;
function collectType(type$2) {
if (type$2.multi) {
result.multi[type$2.kind].push(type$2);
result.multi["fallback"].push(type$2);
} else result[type$2.kind][type$2.tag] = result["fallback"][type$2.tag] = type$2;
}
for (index = 0, length = arguments.length; index < length; index += 1) arguments[index].forEach(collectType);
return result;
}
function Schema$1(definition) {
return this.extend(definition);
}
Schema$1.prototype.extend = function extend$1(definition) {
var implicit = [];
var explicit = [];
if (definition instanceof type$1) explicit.push(definition);
else if (Array.isArray(definition)) explicit = explicit.concat(definition);
else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
if (definition.implicit) implicit = implicit.concat(definition.implicit);
if (definition.explicit) explicit = explicit.concat(definition.explicit);
} else throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
implicit.forEach(function(type$1$1) {
if (!(type$1$1 instanceof type$1)) throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
if (type$1$1.loadKind && type$1$1.loadKind !== "scalar") throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
if (type$1$1.multi) throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
});
explicit.forEach(function(type$1$1) {
if (!(type$1$1 instanceof type$1)) throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
});
var result = Object.create(Schema$1.prototype);
result.implicit = (this.implicit || []).concat(implicit);
result.explicit = (this.explicit || []).concat(explicit);
result.compiledImplicit = compileList(result, "implicit");
result.compiledExplicit = compileList(result, "explicit");
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
return result;
};
var schema = Schema$1;
var str = new type$1("tag:yaml.org,2002:str", {
kind: "scalar",
construct: function(data) {
return data !== null ? data : "";
}
});
var seq = new type$1("tag:yaml.org,2002:seq", {
kind: "sequence",
construct: function(data) {
return data !== null ? data : [];
}
});
var map = new type$1("tag:yaml.org,2002:map", {
kind: "mapping",
construct: function(data) {
return data !== null ? data : {};
}
});
var failsafe = new schema({ explicit: [
str,
seq,
map
] });
function resolveYamlNull(data) {
if (data === null) return true;
var max = data.length;
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
}
function constructYamlNull() {
return null;
}
function isNull(object) {
return object === null;
}
var _null = new type$1("tag:yaml.org,2002:null", {
kind: "scalar",
resolve: resolveYamlNull,
construct: constructYamlNull,
predicate: isNull,
represent: {
canonical: function() {
return "~";
},
lowercase: function() {
return "null";
},
uppercase: function() {
return "NULL";
},
camelcase: function() {
return "Null";
},
empty: function() {
return "";
}
},
defaultStyle: "lowercase"
});
function resolveYamlBoolean(data) {
if (data === null) return false;
var max = data.length;
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
}
function constructYamlBoolean(data) {
return data === "true" || data === "True" || data === "TRUE";
}
function isBoolean(object) {
return Object.prototype.toString.call(object) === "[object Boolean]";
}
var bool = new type$1("tag:yaml.org,2002:bool", {
kind: "scalar",
resolve: resolveYamlBoolean,
construct: constructYamlBoolean,
predicate: isBoolean,
represent: {
lowercase: function(object) {
return object ? "true" : "false";
},
uppercase: function(object) {
return object ? "TRUE" : "FALSE";
},
camelcase: function(object) {
return object ? "True" : "False";
}
},
defaultStyle: "lowercase"
});
function isHexCode(c) {
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
}
function isOctCode(c) {
return 48 <= c && c <= 55;
}
function isDecCode(c) {
return 48 <= c && c <= 57;
}
function resolveYamlInteger(data) {
if (data === null) return false;
var max = data.length, index = 0, hasDigits = false, ch;
if (!max) return false;
ch = data[index];
if (ch === "-" || ch === "+") ch = data[++index];
if (ch === "0") {
if (index + 1 === max) return true;
ch = data[++index];
if (ch === "b") {
index++;
for (; index < max; index++) {
ch = data[index];
if (ch === "_") continue;
if (ch !== "0" && ch !== "1") return false;
hasDigits = true;
}
return hasDigits && ch !== "_";
}
if (ch === "x") {
index++;
for (; index < max; index++) {
ch = data[index];
if (ch === "_") continue;
if (!isHexCode(data.charCodeAt(index))) return false;
hasDigits = true;
}
return hasDigits && ch !== "_";
}
if (ch === "o") {
index++;
for (; index < max; index++) {
ch = data[index];
if (ch === "_") continue;
if (!isOctCode(data.charCodeAt(index))) return false;
hasDigits = true;
}
return hasDigits && ch !== "_";
}
}
if (ch === "_") return false;
for (; index < max; index++) {
ch = data[index];
if (ch === "_") continue;
if (!isDecCode(data.charCodeAt(index))) return false;
hasDigits = true;
}
if (!hasDigits || ch === "_") return false;
return true;
}
function constructYamlInteger(data) {
var value = data, sign = 1, ch;
if (value.indexOf("_") !== -1) value = value.replace(/_/g, "");
ch = value[0];
if (ch === "-" || ch === "+") {
if (ch === "-") sign = -1;
value = value.slice(1);
ch = value[0];
}
if (value === "0") return 0;
if (ch === "0") {
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
}
return sign * parseInt(value, 10);
}
function isInteger(object) {
return Object.prototype.toString.call(object) === "[object Number]" && object % 1 === 0 && !common.isNegativeZero(object);
}
var int = new type$1("tag:yaml.org,2002:int", {
kind: "scalar",
resolve: resolveYamlInteger,
construct: constructYamlInteger,
predicate: isInteger,
represent: {
binary: function(obj) {
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
},
octal: function(obj) {
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
},
decimal: function(obj) {
return obj.toString(10);
},
hexadecimal: function(obj) {
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
}
},
defaultStyle: "decimal",
styleAliases: {
binary: [2, "bin"],
octal: [8, "oct"],
decimal: [10, "dec"],
hexadecimal: [16, "hex"]
}
});
var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
function resolveYamlFloat(data) {
if (data === null) return false;
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") return false;
return true;
}
function constructYamlFloat(data) {
var value = data.replace(/_/g, "").toLowerCase(), sign = value[0] === "-" ? -1 : 1;
if ("+-".indexOf(value[0]) >= 0) value = value.slice(1);
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
else if (value === ".nan") return NaN;
return sign * parseFloat(value, 10);
}
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
function representYamlFloat(object, style) {
var res;
if (isNaN(object)) switch (style) {
case "lowercase": return ".nan";
case "uppercase": return ".NAN";
case "camelcase": return ".NaN";
}
else if (Number.POSITIVE_INFINITY === object) switch (style) {
case "lowercase": return ".inf";
case "uppercase": return ".INF";
case "camelcase": return ".Inf";
}
else if (Number.NEGATIVE_INFINITY === object) switch (style) {
case "lowercase": return "-.inf";
case "uppercase": return "-.INF";
case "camelcase": return "-.Inf";
}
else if (common.isNegativeZero(object)) return "-0.0";
res = object.toString(10);
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
}
function isFloat(object) {
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
}
var float = new type$1("tag:yaml.org,2002:float", {
kind: "scalar",
resolve: resolveYamlFloat,
construct: constructYamlFloat,
predicate: isFloat,
represent: representYamlFloat,
defaultStyle: "lowercase"
});
var json = failsafe.extend({ implicit: [
_null,
bool,
int,
float
] });
var core = json;
var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
function resolveYamlTimestamp(data) {
if (data === null) return false;
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
return false;
}
function constructYamlTimestamp(data) {
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
match = YAML_DATE_REGEXP.exec(data);
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
if (match === null) throw new Error("Date resolve error");
year = +match[1];
month = +match[2] - 1;
day = +match[3];
if (!match[4]) return new Date(Date.UTC(year, month, day));
hour = +match[4];
minute = +match[5];
second = +match[6];
if (match[7]) {
fraction = match[7].slice(0, 3);
while (fraction.length < 3) fraction += "0";
fraction = +fraction;
}
if (match[9]) {
tz_hour = +match[10];
tz_minute = +(match[11] || 0);
delta = (tz_hour * 60 + tz_minute) * 6e4;
if (match[9] === "-") delta = -delta;
}
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
if (delta) date.setTime(date.getTime() - delta);
return date;
}
function representYamlTimestamp(object) {
return object.toISOString();
}
var timestamp = new type$1("tag:yaml.org,2002:timestamp", {
kind: "scalar",
resolve: resolveYamlTimestamp,
construct: constructYamlTimestamp,
instanceOf: Date,
represent: representYamlTimestamp
});
function resolveYamlMerge(data) {
return data === "<<" || data === null;
}
var merge = new type$1("tag:yaml.org,2002:merge", {
kind: "scalar",
resolve: resolveYamlMerge
});
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
function resolveYamlBinary(data) {
if (data === null) return false;
var code, idx, bitlen = 0, max = data.length, map$1 = BASE64_MAP;
for (idx = 0; idx < max; idx++) {
code = map$1.indexOf(data.charAt(idx));
if (code > 64) continue;
if (code < 0) return false;
bitlen += 6;
}
return bitlen % 8 === 0;
}
function constructYamlBinary(data) {
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map$1 = BASE64_MAP, bits = 0, result = [];
for (idx = 0; idx < max; idx++) {
if (idx % 4 === 0 && idx) {
result.push(bits >> 16 & 255);
result.push(bits >> 8 & 255);
result.push(bits & 255);
}
bits = bits << 6 | map$1.indexOf(input.charAt(idx));
}
tailbits = max % 4 * 6;
if (tailbits === 0) {
result.push(bits >> 16 & 255);
result.push(bits >> 8 & 255);
result.push(bits & 255);
} else if (tailbits === 18) {
result.push(bits >> 10 & 255);
result.push(bits >> 2 & 255);
} else if (tailbits === 12) result.push(bits >> 4 & 255);
return new Uint8Array(result);
}
function representYamlBinary(object) {
var result = "", bits = 0, idx, tail, max = object.length, map$1 = BASE64_MAP;
for (idx = 0; idx < max; idx++) {
if (idx % 3 === 0 && idx) {
result += map$1[bits >> 18 & 63];
result += map$1[bits >> 12 & 63];
result += map$1[bits >> 6 & 63];
result += map$1[bits & 63];
}
bits = (bits << 8) + object[idx];
}
tail = max % 3;
if (tail === 0) {
result += map$1[bits >> 18 & 63];
result += map$1[bits >> 12 & 63];
result += map$1[bits >> 6 & 63];
result += map$1[bits & 63];
} else if (tail === 2) {
result += map$1[bits >> 10 & 63];
result += map$1[bits >> 4 & 63];
result += map$1[bits << 2 & 63];
result += map$1[64];
} else if (tail === 1) {
result += map$1[bits >> 2 & 63];
result += map$1[bits << 4 & 63];
result += map$1[64];
result += map$1[64];
}
return result;
}
function isBinary(obj) {
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
}
var binary = new type$1("tag:yaml.org,2002:binary", {
kind: "scalar",
resolve: resolveYamlBinary,
construct: constructYamlBinary,
predicate: isBinary,
represent: representYamlBinary
});
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
var _toString$2 = Object.prototype.toString;
function resolveYamlOmap(data) {
if (data === null) return true;
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
for (index = 0, length = object.length; index < length; index += 1) {
pair = object[index];
pairHasKey = false;
if (_toString$2.call(pair) !== "[object Object]") return false;
for (pairKey in pair) if (_hasOwnProperty$3.call(pair, pairKey)) if (!pairHasKey) pairHasKey = true;
else return false;
if (!pairHasKey) return false;
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
else return false;
}
return true;
}
function constructYamlOmap(data) {
return data !== null ? data : [];
}
var omap = new type$1("tag:yaml.org,2002:omap", {
kind: "sequence",
resolve: resolveYamlOmap,
construct: constructYamlOmap
});
var _toString$1 = Object.prototype.toString;
function resolveYamlPairs(data) {
if (data === null) return true;
var index, length, pair, keys, result, object = data;
result = new Array(object.length);
for (index = 0, length = object.length; index < length; index += 1) {
pair = object[index];
if (_toString$1.call(pair) !== "[object Object]") return false;
keys = Object.keys(pair);
if (keys.length !== 1) return false;
result[index] = [keys[0], pair[keys[0]]];
}
return true;
}
function constructYamlPairs(data) {
if (data === null) return [];
var index, length, pair, keys, result, object = data;
result = new Array(object.length);
for (index = 0, length = object.length; index < length; index += 1) {
pair = object[index];
keys = Object.keys(pair);
result[index] = [keys[0], pair[keys[0]]];
}
return result;
}
var pairs = new type$1("tag:yaml.org,2002:pairs", {
kind: "sequence",
resolve: resolveYamlPairs,
construct: constructYamlPairs
});
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
function resolveYamlSet(data) {
if (data === null) return true;
var key, object = data;
for (key in object) if (_hasOwnProperty$2.call(object, key)) {
if (object[key] !== null) return false;
}
return true;
}
function constructYamlSet(data) {
return data !== null ? data : {};
}
var set = new type$1("tag:yaml.org,2002:set", {
kind: "mapping",
resolve: resolveYamlSet,
construct: constructYamlSet
});
var _default = core.extend({
implicit: [timestamp, merge],
explicit: [
binary,
omap,
pairs,
set
]
});
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
var CONTEXT_FLOW_IN = 1;
var CONTEXT_FLOW_OUT = 2;
var CONTEXT_BLOCK_IN = 3;
var CONTEXT_BLOCK_OUT = 4;
var CHOMPING_CLIP = 1;
var CHOMPING_STRIP = 2;
var CHOMPING_KEEP = 3;
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
function _class(obj) {
return Object.prototype.toString.call(obj);
}
function is_EOL(c) {
return c === 10 || c === 13;
}
function is_WHITE_SPACE(c) {
return c === 9 || c === 32;
}
function is_WS_OR_EOL(c) {
return c === 9 || c === 32 || c === 10 || c === 13;
}
function is_FLOW_INDICATOR(c) {
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
}
function fromHexCode(c) {
var lc;
if (48 <= c && c <= 57) return c - 48;
lc = c | 32;
if (97 <= lc && lc <= 102) return lc - 97 + 10;
return -1;
}
function escapedHexLen(c) {
if (c === 120) return 2;
if (c === 117) return 4;
if (c === 85) return 8;
return 0;
}
function fromDecimalCode(c) {
if (48 <= c && c <= 57) return c - 48;
return -1;
}
function simpleEscapeSequence(c) {
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? "\"" : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "…" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
}
function charFromCodepoint(c) {
if (c <= 65535) return String.fromCharCode(c);
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
}
function setProperty(object, key, value) {
if (key === "__proto__") Object.defineProperty(object, key, {
configurable: true,
enumerable: true,
writable: true,
value
});
else object[key] = value;
}
var simpleEscapeCheck = new Array(256);
var simpleEscapeMap = new Array(256);
for (var i = 0; i < 256; i++) {
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
simpleEscapeMap[i] = simpleEscapeSequence(i);
}
function State$1(input, options) {
this.input = input;
this.filename = options["filename"] || null;
this.schema = options["schema"] || _default;
this.onWarning = options["onWarning"] || null;
this.legacy = options["legacy"] || false;
this.json = options["json"] || false;
this.listener = options["listener"] || null;
this.implicitTypes = this.schema.compiledImplicit;
this.typeMap = this.schema.compiledTypeMap;
this.length = input.length;
this.position = 0;
this.line = 0;
this.lineStart = 0;
this.lineIndent = 0;
this.firstTabInLine = -1;
this.documents = [];
}
function generateError(state, message) {
var mark = {
name: state.filename,
buffer: state.input.slice(0, -1),
position: state.position,
line: state.line,
column: state.position - state.lineStart
};
mark.snippet = snippet(mark);
return new exception(message, mark);
}
function throwError(state, message) {
throw generateError(state, message);
}
function throwWarning(state, message) {
if (state.onWarning) state.onWarning.call(null, generateError(state, message));
}
var directiveHandlers = {
YAML: function handleYamlDirective(state, name$1, args) {
var match, major, minor;
if (state.version !== null) throwError(state, "duplication of %YAML directive");
if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
if (match === null) throwError(state, "ill-formed argument of the YAML directive");
major = parseInt(match[1], 10);
minor = parseInt(match[2], 10);
if (major !== 1) throwError(state, "unacceptable YAML version of the document");
state.version = args[0];
state.checkLineBreaks = minor < 2;
if (minor !== 1 && minor !== 2) throwWarning(state, "unsupported YAML version of the document");
},
TAG: function handleTagDirective(state, name$1, args) {
var handle, prefix;
if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
handle = args[0];
prefix = args[1];
if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
if (_hasOwnProperty$1.call(state.tagMap, handle)) throwError(state, "there is a previously declared suffix for \"" + handle + "\" tag handle");
if (!PATTERN_TAG_URI.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
try {
prefix = decodeURIComponent(prefix);
} catch (err) {
throwError(state, "tag prefix is malformed: " + prefix);
}
state.tagMap[handle] = prefix;
}
};
function captureSegment(state, start$1, end, checkJson) {
var _position, _length, _character, _result;
if (start$1 < end) {
_result = state.input.slice(start$1, end);
if (checkJson) for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
_character = _result.charCodeAt(_position);
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) throwError(state, "expected valid JSON character");
}
else if (PATTERN_NON_PRINTABLE.test(_result)) throwError(state, "the stream contains non-printable characters");
state.result += _result;
}
}
function mergeMappings(state, destination, source, overridableKeys) {
var sourceKeys, key, index, quantity;
if (!common.isObject(source)) throwError(state, "cannot merge mappings; the provided source object is unacceptable");
sourceKeys = Object.keys(source);
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
key = sourceKeys[index];
if (!_hasOwnProperty$1.call(destination, key)) {
setProperty(destination, key, source[key]);
overridableKeys[key] = true;
}
}
}
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
var index, quantity;
if (Array.isArray(keyNode)) {
keyNode = Array.prototype.slice.call(keyNode);
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
if (Array.isArray(keyNode[index])) throwError(state, "nested arrays are not supported inside keys");
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") keyNode[index] = "[object Object]";
}
}
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") keyNode = "[object Object]";
keyNode = String(keyNode);
if (_result === null) _result = {};
if (keyTag === "tag:yaml.org,2002:merge") if (Array.isArray(valueNode)) for (index = 0, quantity = valueNode.length; index < quantity; index += 1) mergeMappings(state, _result, valueNode[index], overridableKeys);
else mergeMappings(state, _result, valueNode, overridableKeys);
else {
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
state.line = startLine || state.line;
state.lineStart = startLineStart || state.lineStart;
state.position = startPos || state.position;
throwError(state, "duplicated mapping key");
}
setProperty(_result, keyNode, valueNode);
delete overridableKeys[keyNode];
}
return _result;
}
function readLineBreak(state) {
var ch = state.input.charCodeAt(state.position);
if (ch === 10) state.position++;
else if (ch === 13) {
state.position++;
if (state.input.charCodeAt(state.position) === 10) state.position++;
} else throwError(state, "a line break is expected");
state.line += 1;
state.lineStart = state.position;
state.firstTabInLine = -1;
}
function skipSeparationSpace(state, allowComments, checkIndent) {
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
while (ch !== 0) {
while (is_WHITE_SPACE(ch)) {
if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
ch = state.input.charCodeAt(++state.position);
}
if (allowComments && ch === 35) do
ch = state.input.charCodeAt(++state.position);
while (ch !== 10 && ch !== 13 && ch !== 0);
if (is_EOL(ch)) {
readLineBreak(state);
ch = state.input.charCodeAt(state.position);
lineBreaks++;
state.lineIndent = 0;
while (ch === 32) {
state.lineIndent++;
ch = state.input.charCodeAt(++state.position);
}
} else break;
}
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) throwWarning(state, "deficient indentation");
return lineBreaks;
}
function testDocumentSeparator(state) {
var _position = state.position, ch = state.input.charCodeAt(_position);
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
_position += 3;
ch = state.input.charCodeAt(_position);
if (ch === 0 || is_WS_OR_EOL(ch)) return true;
}
return false;
}
function writeFoldedLines(state, count) {
if (count === 1) state.result += " ";
else if (count > 1) state.result += common.repeat("\n", count - 1);
}
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch = state.input.charCodeAt(state.position);
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) return false;
if (ch === 63 || ch === 45) {
following = state.input.charCodeAt(state.position + 1);
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) return false;
}
state.kind = "scalar";
state.result = "";
captureStart = captureEnd = state.position;
hasPendingContent = false;
while (ch !== 0) {
if (ch === 58) {
following = state.input.charCodeAt(state.position + 1);
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) break;
} else if (ch === 35) {
preceding = state.input.charCodeAt(state.position - 1);
if (is_WS_OR_EOL(preceding)) break;
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) break;
else if (is_EOL(ch)) {
_line = state.line;
_lineStart = state.lineStart;
_lineIndent = state.lineIndent;
skipSeparationSpace(state, false, -1);
if (state.lineIndent >= nodeIndent) {
hasPendingContent = true;
ch = state.input.charCodeAt(state.position);
continue;
} else {
state.position = captureEnd;
state.line = _line;
state.lineStart = _lineStart;
state.lineIndent = _lineIndent;
break;
}
}
if (hasPendingContent) {
captureSegment(state, captureStart, captureEnd, false);
writeFoldedLines(state, state.line - _line);
captureStart = captureEnd = state.position;
hasPendingContent = false;
}
if (!is_WHITE_SPACE(ch)) captureEnd = state.position + 1;
ch = state.input.charCodeAt(++state.position);
}
captureSegment(state, captureStart, captureEnd, false);
if (state.result) return true;
state.kind = _kind;
state.result = _result;
return false;
}
function readSingleQuotedScalar(state, nodeIndent) {
var ch = state.input.charCodeAt(state.position), captureStart, captureEnd;
if (ch !== 39) return false;
state.kind = "scalar";
state.result = "";
state.position++;
captureStart = captureEnd = state.position;
while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 39) {
captureSegment(state, captureStart, state.position, true);
ch = state.input.charCodeAt(++state.position);
if (ch === 39) {
captureStart = state.position;
state.position++;
captureEnd = state.position;
} else return true;
} else if (is_EOL(ch)) {
captureSegment(state, captureStart, captureEnd, true);
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
captureStart = captureEnd = state.position;
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
else {
state.position++;
captureEnd = state.position;
}
throwError(state, "unexpected end of the stream within a single quoted scalar");
}
function readDoubleQuotedScalar(state, nodeIndent) {
var captureStart, captureEnd, hexLength, hexResult, tmp, ch = state.input.charCodeAt(state.position);
if (ch !== 34) return false;
state.kind = "scalar";
state.result = "";
state.position++;
captureStart = captureEnd = state.position;
while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 34) {
captureSegment(state, captureStart, state.position, true);
state.position++;
return true;
} else if (ch === 92) {
captureSegment(state, captureStart, state.position, true);
ch = state.input.charCodeAt(++state.position);
if (is_EOL(ch)) skipSeparationSpace(state, false, nodeIndent);
else if (ch < 256 && simpleEscapeCheck[ch]) {
state.result += simpleEscapeMap[ch];
state.position++;
} else if ((tmp = escapedHexLen(ch)) > 0) {
hexLength = tmp;
hexResult = 0;
for (; hexLength > 0; hexLength--) {
ch = state.input.charCodeAt(++state.position);
if ((tmp = fromHexCode(ch)) >= 0) hexResult = (hexResult << 4) + tmp;
else throwError(state, "expected hexadecimal character");
}
state.result += charFromCodepoint(hexResult);
state.position++;
} else throwError(state, "unknown escape sequence");
captureStart = captureEnd = state.position;
} else if (is_EOL(ch)) {
captureSegment(state, captureStart, captureEnd, true);
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
captureStart = captureEnd = state.position;
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
else {
state.position++;
captureEnd = state.position;
}
throwError(state, "unexpected end of the stream within a double quoted scalar");
}
function readFlowCollection(state, nodeIndent) {
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch = state.input.charCodeAt(state.position);
if (ch === 91) {
terminator = 93;
isMapping = false;
_result = [];
} else if (ch === 123) {
terminator = 125;
isMapping = true;
_result = {};
} else return false;
if (state.anchor !== null) state.anchorMap[state.anchor] = _result;
ch = state.input.charCodeAt(++state.position);
while (ch !== 0) {
skipSeparationSpace(state, true, nodeIndent);
ch = state.input.charCodeAt(state.position);
if (ch === terminator) {
state.position++;
state.tag = _tag;
state.anchor = _anchor;
state.kind = isMapping ? "mapping" : "sequence";
state.result = _result;
return true;
} else if (!readNext) throwError(state, "missed comma between flow collection entries");
else if (ch === 44) throwError(state, "expected the node content, but found ','");
keyTag = keyNode = valueNode = null;
isPair = isExplicitPair = false;
if (ch === 63) {
following = state.input.charCodeAt(state.position + 1);
if (is_WS_OR_EOL(following)) {
isPair = isExplicitPair = true;
state.position++;
skipSeparationSpace(state, true, nodeIndent);
}
}
_line = state.line;
_lineStart = state.lineStart;
_pos = state.position;
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
keyTag = state.tag;
keyNode = state.result;
skipSeparationSpace(state, true, nodeIndent);
ch = state.input.charCodeAt(state.position);
if ((isExplicitPair || state.line === _line) && ch === 58) {
isPair = true;
ch = state.input.charCodeAt(++state.position);
skipSeparationSpace(state, true, nodeIndent);
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
valueNode = state.result;
}
if (isMapping) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
else if (isPair) _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
else _result.push(keyNode);
skipSeparationSpace(state, true, nodeIndent);
ch = state.input.charCodeAt(state.position);
if (ch === 44) {
readNext = true;
ch = state.input.charCodeAt(++state.position);
} else readNext = false;
}
throwError(state, "unexpected end of the stream within a flow collection");
}
function readBlockScalar(state, nodeIndent) {
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch = state.input.charCodeAt(state.position);
if (ch === 124) folding = false;
else if (ch === 62) folding = true;
else return false;
state.kind = "scalar";
state.result = "";
while (ch !== 0) {
ch = state.input.charCodeAt(++state.position);
if (ch === 43 || ch === 45) if (CHOMPING_CLIP === chomping) chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
else throwError(state, "repeat of a chomping mode identifier");
else if ((tmp = fromDecimalCode(ch)) >= 0) if (tmp === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
else if (!detectedIndent) {
textIndent = nodeIndent + tmp - 1;
detectedIndent = true;
} else throwError(state, "repeat of an indentation width identifier");
else break;
}
if (is_WHITE_SPACE(ch)) {
do
ch = state.input.charCodeAt(++state.position);
while (is_WHITE_SPACE(ch));
if (ch === 35) do
ch = state.input.charCodeAt(++state.position);
while (!is_EOL(ch) && ch !== 0);
}
while (ch !== 0) {
readLineBreak(state);
state.lineIndent = 0;
ch = state.input.charCodeAt(state.position);
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
state.lineIndent++;
ch = state.input.charCodeAt(++state.position);
}
if (!detectedIndent && state.lineIndent > textIndent) textIndent = state.lineIndent;
if (is_EOL(ch)) {
emptyLines++;
continue;
}
if (state.lineIndent < textIndent) {
if (chomping === CHOMPING_KEEP) state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
else if (chomping === CHOMPING_CLIP) {
if (didReadContent) state.result += "\n";
}
break;
}
if (folding) if (is_WHITE_SPACE(ch)) {
atMoreIndented = true;
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
} else if (atMoreIndented) {
atMoreIndented = false;
state.result += common.repeat("\n", emptyLines + 1);
} else if (emptyLines === 0) {
if (didReadContent) state.result += " ";
} else state.result += common.repeat("\n", emptyLines);
else state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
didReadContent = true;
detectedIndent = true;
emptyLines = 0;
captureStart = state.position;
while (!is_EOL(ch) && ch !== 0) ch = state.input.charCodeAt(++state.position);
captureSegment(state, captureStart, state.position, false);
}
return true;
}
function readBlockSequence(state, nodeIndent) {
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
if (state.firstTabInLine !== -1) return false;
if (state.anchor !== null) state.anchorMap[state.anchor] = _result;
ch = state.input.charCodeAt(state.position);
while (ch !== 0) {
if (state.firstTabInLine !== -1) {
state.position = state.firstTabInLine;
throwError(state, "tab characters must not be used in indentation");
}
if (ch !== 45) break;
following = state.input.charCodeAt(state.position + 1);
if (!is_WS_OR_EOL(following)) break;
detected = true;
state.position++;
if (skipSeparationSpace(state, true, -1)) {
if (state.lineIndent <= nodeIndent) {
_result.push(null);
ch = state.input.charCodeAt(state.position);
continue;
}
}
_line = state.line;
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
_result.push(state.result);
skipSeparationSpace(state, true, -1);
ch = state.input.charCodeAt(state.position);
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a sequence entry");
else if (state.lineIndent < nodeIndent) break;
}
if (detected) {
state.tag = _tag;
state.anchor = _anchor;
state.kind = "sequence";
state.result = _result;
return true;
}
return false;
}
function readBlockMapping(state, nodeIndent, flowIndent) {
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
if (state.firstTabInLine !== -1) return false;
if (state.anchor !== null) state.anchorMap[state.anchor] = _result;
ch = state.input.charCodeAt(state.position);
while (ch !== 0) {
if (!atExplicitKey && state.firstTabInLine !== -1) {
state.position = state.firstTabInLine;
throwError(state, "tab characters must not be used in indentation");
}
following = state.input.charCodeAt(state.position + 1);
_line = state.line;
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
if (ch === 63) {
if (atExplicitKey) {
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
keyTag = keyNode = valueNode = null;
}
detected = true;
atExplicitKey = true;
allowCompact = true;
} else if (atExplicitKey) {
atExplicitKey = false;
allowCompact = true;
} else throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
state.position += 1;
ch = following;
} else {
_keyLine = state.line;
_keyLineStart = state.lineStart;
_keyPos = state.position;
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
if (state.line === _line) {
ch = state.input.charCodeAt(state.position);
while (is_WHITE_SPACE(ch)) ch = state.input.charCodeAt(++state.position);
if (ch === 58) {
ch = state.input.charCodeAt(++state.position);
if (!is_WS_OR_EOL(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
if (atExplicitKey) {
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
keyTag = keyNode = valueNode = null;
}
detected = true;
atExplicitKey = false;
allowCompact = false;
keyTag = state.tag;
keyNode = state.result;
} else if (detected) throwError(state, "can not read an implicit mapping pair; a colon is missed");
else {
state.tag = _tag;
state.anchor = _anchor;
return true;
}
} else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
else {
state.tag = _tag;
state.anchor = _anchor;
return true;
}
}
if (state.line === _line || state.lineIndent > nodeIndent) {
if (atExplicitKey) {
_keyLine = state.line;
_keyLineStart = state.lineStart;
_keyPos = state.position;
}
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) if (atExplicitKey) keyNode = state.result;
else valueNode = state.result;
if (!atExplicitKey) {
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
keyTag = keyNode = valueNode = null;
}
skipSeparationSpace(state, true, -1);
ch = state.input.charCodeAt(state.position);
}
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
else if (state.lineIndent < nodeIndent) break;
}
if (atExplicitKey) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
if (detected) {
state.tag = _tag;
state.anchor = _anchor;
state.kind = "mapping";
state.result = _result;
}
return detected;
}
function readTagProperty(state) {
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch = state.input.charCodeAt(state.position);
if (ch !== 33) return false;
if (state.tag !== null) throwError(state, "duplication of a tag property");
ch = state.input.charCodeAt(++state.position);
if (ch === 60) {
isVerbatim = true;
ch = state.input.charCodeAt(++state.position);
} else if (ch === 33) {
isNamed = true;
tagHandle = "!!";
ch = state.input.charCodeAt(++state.position);
} else tagHandle = "!";
_position = state.position;
if (isVerbatim) {
do
ch = state.input.charCodeAt(++state.position);
while (ch !== 0 && ch !== 62);
if (state.position < state.length) {
tagName = state.input.slice(_position, state.position);
ch = state.input.charCodeAt(++state.position);
} else throwError(state, "unexpected end of the stream within a verbatim tag");
} else {
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
if (ch === 33) if (!isNamed) {
tagHandle = state.input.slice(_position - 1, state.position + 1);
if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
isNamed = true;
_position = state.position + 1;
} else throwError(state, "tag suffix cannot contain exclamation marks");
ch = state.input.charCodeAt(++state.position);
}
tagName = state.input.slice(_position, state.position);
if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
}
if (tagName && !PATTERN_TAG_URI.test(tagName)) throwError(state, "tag name cannot contain such characters: " + tagName);
try {
tagName = decodeURIComponent(tagName);
} catch (err) {
throwError(state, "tag name is malformed: " + tagName);
}
if (isVerbatim) state.tag = tagName;
else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) state.tag = state.tagMap[tagHandle] + tagName;
else if (tagHandle === "!") state.tag = "!" + tagName;
else if (tagHandle === "!!") state.tag = "tag:yaml.org,2002:" + tagName;
else throwError(state, "undeclared tag handle \"" + tagHandle + "\"");
return true;
}
function readAnchorProperty(state) {
var _position, ch = state.input.charCodeAt(state.position);
if (ch !== 38) return false;
if (state.anchor !== null) throwError(state, "duplication of an anchor property");
ch = state.input.charCodeAt(++state.position);
_position = state.position;
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) ch = state.input.charCodeAt(++state.position);
if (state.position === _position) throwError(state, "name of an anchor node must contain at least one character");
state.anchor = state.input.slice(_position, state.position);
return true;
}
function readAlias(state) {
var _position, alias, ch = state.input.charCodeAt(state.position);
if (ch !== 42) return false;
ch = state.input.charCodeAt(++state.position);
_position = state.position;
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) ch = state.input.charCodeAt(++state.position);
if (state.position === _position) throwError(state, "name of an alias node must contain at least one character");
alias = state.input.slice(_position, state.position);
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) throwError(state, "unidentified alias \"" + alias + "\"");
state.result = state.anchorMap[alias];
skipSeparationSpace(state, true, -1);
return true;
}
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type$2, flowIndent, blockIndent;
if (state.listener !== null) state.listener("open", state);
state.tag = null;
state.anchor = null;
state.kind = null;
state.result = null;
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
if (allowToSeek) {
if (skipSeparationSpace(state, true, -1)) {
atNewLine = true;
if (state.lineIndent > parentIndent) indentStatus = 1;
else if (state.lineIndent === parentIndent) indentStatus = 0;
else if (state.lineIndent < parentIndent) indentStatus = -1;
}
}
if (indentStatus === 1) while (readTagProperty(state) || readAnchorProperty(state)) if (skipSeparationSpace(state, true, -1)) {
atNewLine = true;
allowBlockCollections = allowBlockStyles;
if (state.lineIndent > parentIndent) indentStatus = 1;
else if (state.lineIndent === parentIndent) indentStatus = 0;
else if (state.lineIndent < parentIndent) indentStatus = -1;
} else allowBlockCollections = false;
if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) flowIndent = parentIndent;
else flowIndent = parentIndent + 1;
blockIndent = state.position - state.lineStart;
if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) hasContent = true;
else {
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) hasContent = true;
else if (readAlias(state)) {
hasContent = true;
if (state.tag !== null || state.anchor !== null) throwError(state, "alias node should not have any properties");
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
hasContent = true;
if (state.tag === null) state.tag = "?";
}
if (state.anchor !== null) state.anchorMap[state.anchor] = state.result;
}
else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
}
if (state.tag === null) {
if (state.anchor !== null) state.anchorMap[state.anchor] = state.result;
} else if (state.tag === "?") {
if (state.result !== null && state.kind !== "scalar") throwError(state, "unacceptable node kind for !<?> tag; it should be \"scalar\", not \"" + state.kind + "\"");
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
type$2 = state.implicitTypes[typeIndex];
if (type$2.resolve(state.result)) {
state.result = type$2.construct(state.result);
state.tag = type$2.tag;
if (state.anchor !== null) state.anchorMap[state.anchor] = state.result;
break;
}
}
} else if (state.tag !== "!") {
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) type$2 = state.typeMap[state.kind || "fallback"][state.tag];
else {
type$2 = null;
typeList = state.typeMap.multi[state.kind || "fallback"];
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
type$2 = typeList[typeIndex];
break;
}
}
if (!type$2) throwError(state, "unknown tag !<" + state.tag + ">");
if (state.result !== null && type$2.kind !== state.kind) throwError(state, "unacceptable node kind for !<" + state.tag + "> tag; it should be \"" + type$2.kind + "\", not \"" + state.kind + "\"");
if (!type$2.resolve(state.result, state.tag)) throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
else {
state.result = type$2.construct(state.result, state.tag);
if (state.anchor !== null) state.anchorMap[state.anchor] = state.result;
}
}
if (state.listener !== null) state.listener("close", state);
return state.tag !== null || state.anchor !== null || hasContent;
}
function readDocument(state) {
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
state.version = null;
state.checkLineBreaks = state.legacy;
state.tagMap = Object.create(null);
state.anchorMap = Object.create(null);
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
skipSeparationSpace(state, true, -1);
ch = state.input.charCodeAt(state.position);
if (state.lineIndent > 0 || ch !== 37) break;
hasDirectives = true;
ch = state.input.charCodeAt(++state.position);
_position = state.position;
while (ch !== 0 && !is_WS_OR_EOL(ch)) ch = state.input.charCodeAt(++state.position);
directiveName = state.input.slice(_position, state.position);
directiveArgs = [];
if (directiveName.length < 1) throwError(state, "directive name must not be less than one character in length");
while (ch !== 0) {
while (is_WHITE_SPACE(ch)) ch = state.input.charCodeAt(++state.position);
if (ch === 35) {
do
ch = state.input.charCodeAt(++state.position);
while (ch !== 0 && !is_EOL(ch));
break;
}
if (is_EOL(ch)) break;
_position = state.position;
while (ch !== 0 && !is_WS_OR_EOL(ch)) ch = state.input.charCodeAt(++state.position);
directiveArgs.push(state.input.slice(_position, state.position));
}
if (ch !== 0) readLineBreak(state);
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) directiveHandlers[directiveName](state, directiveName, directiveArgs);
else throwWarning(state, "unknown document directive \"" + directiveName + "\"");
}
skipSeparationSpace(state, true, -1);
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
state.position += 3;
skipSeparationSpace(state, true, -1);
} else if (hasDirectives) throwError(state, "directives end mark is expected");
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
skipSeparationSpace(state, true, -1);
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) throwWarning(state, "non-ASCII line breaks are interpreted as content");
state.documents.push(state.result);
if (state.position === state.lineStart && testDocumentSeparator(state)) {
if (state.input.charCodeAt(state.position) === 46) {
state.position += 3;
skipSeparationSpace(state, true, -1);
}
return;
}
if (state.position < state.length - 1) throwError(state, "end of the stream or a document separator is expected");
else return;
}
function loadDocuments(input, options) {
input = String(input);
options = options || {};
if (input.length !== 0) {
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) input += "\n";
if (input.charCodeAt(0) === 65279) input = input.slice(1);
}
var state = new State$1(input, options);
var nullpos = input.indexOf("\0");
if (nullpos !== -1) {
state.position = nullpos;
throwError(state, "null byte is not allowed in input");
}
state.input += "\0";
while (state.input.charCodeAt(state.position) === 32) {
state.lineIndent += 1;
state.position += 1;
}
while (state.position < state.length - 1) readDocument(state);
return state.documents;
}
function loadAll$1(input, iterator, options) {
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
options = iterator;
iterator = null;
}
var documents = loadDocuments(input, options);
if (typeof iterator !== "function") return documents;
for (var index = 0, length = documents.length; index < length; index += 1) iterator(documents[index]);
}
function load$1(input, options) {
var documents = loadDocuments(input, options);
if (documents.length === 0) return;
else if (documents.length === 1) return documents[0];
throw new exception("expected a single document in the stream, but found more");
}
var loader = {
loadAll: loadAll$1,
load: load$1
};
var _toString = Object.prototype.toString;
var _hasOwnProperty = Object.prototype.hasOwnProperty;
var CHAR_BOM = 65279;
var CHAR_TAB = 9;
var CHAR_LINE_FEED = 10;
var CHAR_CARRIAGE_RETURN = 13;
var CHAR_SPACE = 32;
var CHAR_EXCLAMATION = 33;
var CHAR_DOUBLE_QUOTE = 34;
var CHAR_SHARP = 35;
var CHAR_PERCENT = 37;
var CHAR_AMPERSAND = 38;
var CHAR_SINGLE_QUOTE = 39;
var CHAR_ASTERISK = 42;
var CHAR_COMMA = 44;
var CHAR_MINUS = 45;
var CHAR_COLON = 58;
var CHAR_EQUALS = 61;
var CHAR_GREATER_THAN = 62;
var CHAR_QUESTION = 63;
var CHAR_COMMERCIAL_AT = 64;
var CHAR_LEFT_SQUARE_BRACKET = 91;
var CHAR_RIGHT_SQUARE_BRACKET = 93;
var CHAR_GRAVE_ACCENT = 96;
var CHAR_LEFT_CURLY_BRACKET = 123;
var CHAR_VERTICAL_LINE = 124;
var CHAR_RIGHT_CURLY_BRACKET = 125;
var ESCAPE_SEQUENCES = {};
ESCAPE_SEQUENCES[0] = "\\0";
ESCAPE_SEQUENCES[7] = "\\a";
ESCAPE_SEQUENCES[8] = "\\b";
ESCAPE_SEQUENCES[9] = "\\t";
ESCAPE_SEQUENCES[10] = "\\n";
ESCAPE_SEQUENCES[11] = "\\v";
ESCAPE_SEQUENCES[12] = "\\f";
ESCAPE_SEQUENCES[13] = "\\r";
ESCAPE_SEQUENCES[27] = "\\e";
ESCAPE_SEQUENCES[34] = "\\\"";
ESCAPE_SEQUENCES[92] = "\\\\";
ESCAPE_SEQUENCES[133] = "\\N";
ESCAPE_SEQUENCES[160] = "\\_";
ESCAPE_SEQUENCES[8232] = "\\L";
ESCAPE_SEQUENCES[8233] = "\\P";
var DEPRECATED_BOOLEANS_SYNTAX = [
"y",
"Y",
"yes",
"Yes",
"YES",
"on",
"On",
"ON",
"n",
"N",
"no",
"No",
"NO",
"off",
"Off",
"OFF"
];
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
function compileStyleMap(schema$1, map$1) {
var result, keys, index, length, tag, style, type$2;
if (map$1 === null) return {};
result = {};
keys = Object.keys(map$1);
for (index = 0, length = keys.length; index < length; index += 1) {
tag = keys[index];
style = String(map$1[tag]);
if (tag.slice(0, 2) === "!!") tag = "tag:yaml.org,2002:" + tag.slice(2);
type$2 = schema$1.compiledTypeMap["fallback"][tag];
if (type$2 && _hasOwnProperty.call(type$2.styleAliases, style)) style = type$2.styleAliases[style];
result[tag] = style;
}
return result;
}
function encodeHex(character) {
var string = character.toString(16).toUpperCase(), handle, length;
if (character <= 255) {
handle = "x";
length = 2;
} else if (character <= 65535) {
handle = "u";
length = 4;
} else if (character <= 4294967295) {
handle = "U";
length = 8;
} else throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
return "\\" + handle + common.repeat("0", length - string.length) + string;
}
var QUOTING_TYPE_SINGLE = 1, QUOTING_TYPE_DOUBLE = 2;
function State(options) {
this.schema = options["schema"] || _default;
this.indent = Math.max(1, options["indent"] || 2);
this.noArrayIndent = options["noArrayIndent"] || false;
this.skipInvalid = options["skipInvalid"] || false;
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
this.sortKeys = options["sortKeys"] || false;
this.lineWidth = options["lineWidth"] || 80;
this.noRefs = options["noRefs"] || false;
this.noCompatMode = options["noCompatMode"] || false;
this.condenseFlow = options["condenseFlow"] || false;
this.quotingType = options["quotingType"] === "\"" ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
this.forceQuotes = options["forceQuotes"] || false;
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
this.implicitTypes = this.schema.compiledImplicit;
this.explicitTypes = this.schema.compiledExplicit;
this.tag = null;
this.result = "";
this.duplicates = [];
this.usedDuplicates = null;
}
function indentString(string, spaces) {
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
while (position < length) {
next = string.indexOf("\n", position);
if (next === -1) {
line = string.slice(position);
position = length;
} else {
line = string.slice(position, next + 1);
position = next + 1;
}
if (line.length && line !== "\n") result += ind;
result += line;
}
return result;
}
function generateNextLine(state, level) {
return "\n" + common.repeat(" ", state.indent * level);
}
function testImplicitResolving(state, str$1) {
var index, length, type$2;
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
type$2 = state.implicitTypes[index];
if (type$2.resolve(str$1)) return true;
}
return false;
}
function isWhitespace(c) {
return c === CHAR_SPACE || c === CHAR_TAB;
}
function isPrintable(c) {
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
}
function isNsCharOrWhitespace(c) {
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
}
function isPlainSafe(c, prev, inblock) {
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
return (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar;
}
function isPlainSafeFirst(c) {
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
}
function isPlainSafeLast(c) {
return !isWhitespace(c) && c !== CHAR_COLON;
}
function codePointAt(string, pos) {
var first = string.charCodeAt(pos), second;
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
second = string.charCodeAt(pos + 1);
if (second >= 56320 && second <= 57343) return (first - 55296) * 1024 + second - 56320 + 65536;
}
return first;
}
function needIndentIndicator(string) {
return /^\n* /.test(string);
}
var STYLE_PLAIN = 1, STYLE_SINGLE = 2, STYLE_LITERAL = 3, STYLE_FOLDED = 4, STYLE_DOUBLE = 5;
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
var i$1;
var char = 0;
var prevChar = null;
var hasLineBreak = false;
var hasFoldableLine = false;
var shouldTrackWidth = lineWidth !== -1;
var previousLineBreak = -1;
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
if (singleLineOnly || forceQuotes) for (i$1 = 0; i$1 < string.length; char >= 65536 ? i$1 += 2 : i$1++) {
char = codePointAt(string, i$1);
if (!isPrintable(char)) return STYLE_DOUBLE;
plain = plain && isPlainSafe(char, prevChar, inblock);
prevChar = char;
}
else {
for (i$1 = 0; i$1 < string.length; char >= 65536 ? i$1 += 2 : i$1++) {
char = codePointAt(string, i$1);
if (char === CHAR_LINE_FEED) {
hasLineBreak = true;
if (shouldTrackWidth) {
hasFoldableLine = hasFoldableLine || i$1 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
previousLineBreak = i$1;
}
} else if (!isPrintable(char)) return STYLE_DOUBLE;
plain = plain && isPlainSafe(char, prevChar, inblock);
prevChar = char;
}
hasFoldableLine = hasFoldableLine || shouldTrackWidth && i$1 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
}
if (!hasLineBreak && !hasFoldableLine) {
if (plain && !forceQuotes && !testAmbiguousType(string)) return STYLE_PLAIN;
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
}
if (indentPerLevel > 9 && needIndentIndicator(string)) return STYLE_DOUBLE;
if (!forceQuotes) return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
}
function writeScalar(state, string, level, iskey, inblock) {
state.dump = function() {
if (string.length === 0) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"\"" : "''";
if (!state.noCompatMode) {
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"" + string + "\"" : "'" + string + "'";
}
var indent = state.indent * Math.max(1, level);
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
function testAmbiguity(string$1) {
return testImplicitResolving(state, string$1);
}
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
case STYLE_PLAIN: return string;
case STYLE_SINGLE: return "'" + string.replace(/'/g, "''") + "'";
case STYLE_LITERAL: return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
case STYLE_FOLDED: return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
case STYLE_DOUBLE: return "\"" + escapeString(string) + "\"";
default: throw new exception("impossible error: invalid scalar style");
}
}();
}
function blockHeader(string, indentPerLevel) {
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
var clip = string[string.length - 1] === "\n";
return indentIndicator + (clip && (string[string.length - 2] === "\n" || string === "\n") ? "+" : clip ? "" : "-") + "\n";
}
function dropEndingNewline(string) {
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
}
function foldString(string, width) {
var lineRe = /(\n+)([^\n]*)/g;
var result = function() {
var nextLF = string.indexOf("\n");
nextLF = nextLF !== -1 ? nextLF : string.length;
lineRe.lastIndex = nextLF;
return foldLine(string.slice(0, nextLF), width);
}();
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
var moreIndented;
var match;
while (match = lineRe.exec(string)) {
var prefix = match[1], line = match[2];
moreIndented = line[0] === " ";
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
prevMoreIndented = moreIndented;
}
return result;
}
function foldLine(line, width) {
if (line === "" || line[0] === " ") return line;
var breakRe = / [^ ]/g;
var match;
var start$1 = 0, end, curr = 0, next = 0;
var result = "";
while (match = breakRe.exec(line)) {
next = match.index;
if (next - start$1 > width) {
end = curr > start$1 ? curr : next;
result += "\n" + line.slice(start$1, end);
start$1 = end + 1;
}
curr = next;
}
result += "\n";
if (line.length - start$1 > width && curr > start$1) result += line.slice(start$1, curr) + "\n" + line.slice(curr + 1);
else result += line.slice(start$1);
return result.slice(1);
}
function escapeString(string) {
var result = "";
var char = 0;
var escapeSeq;
for (var i$1 = 0; i$1 < string.length; char >= 65536 ? i$1 += 2 : i$1++) {
char = codePointAt(string, i$1);
escapeSeq = ESCAPE_SEQUENCES[char];
if (!escapeSeq && isPrintable(char)) {
result += string[i$1];
if (char >= 65536) result += string[i$1 + 1];
} else result += escapeSeq || encodeHex(char);
}
return result;
}
function writeFlowSequence(state, level, object) {
var _result = "", _tag = state.tag, index, length, value;
for (index = 0, length = object.length; index < length; index += 1) {
value = object[index];
if (state.replacer) value = state.replacer.call(object, String(index), value);
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
_result += state.dump;
}
}
state.tag = _tag;
state.dump = "[" + _result + "]";
}
function writeBlockSequence(state, level, object, compact) {
var _result = "", _tag = state.tag, index, length, value;
for (index = 0, length = object.length; index < length; index += 1) {
value = object[index];
if (state.replacer) value = state.replacer.call(object, String(index), value);
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
if (!compact || _result !== "") _result += generateNextLine(state, level);
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) _result += "-";
else _result += "- ";
_result += state.dump;
}
}
state.tag = _tag;
state.dump = _result || "[]";
}
function writeFlowMapping(state, level, object) {
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
pairBuffer = "";
if (_result !== "") pairBuffer += ", ";
if (state.condenseFlow) pairBuffer += "\"";
objectKey = objectKeyList[index];
objectValue = object[objectKey];
if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
if (!writeNode(state, level, objectKey, false, false)) continue;
if (state.dump.length > 1024) pairBuffer += "? ";
pairBuffer += state.dump + (state.condenseFlow ? "\"" : "") + ":" + (state.condenseFlow ? "" : " ");
if (!writeNode(state, level, objectValue, false, false)) continue;
pairBuffer += state.dump;
_result += pairBuffer;
}
state.tag = _tag;
state.dump = "{" + _result + "}";
}
function writeBlockMapping(state, level, object, compact) {
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
if (state.sortKeys === true) objectKeyList.sort();
else if (typeof state.sortKeys === "function") objectKeyList.sort(state.sortKeys);
else if (state.sortKeys) throw new exception("sortKeys must be a boolean or a function");
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
pairBuffer = "";
if (!compact || _result !== "") pairBuffer += generateNextLine(state, level);
objectKey = objectKeyList[index];
objectValue = object[objectKey];
if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
if (!writeNode(state, level + 1, objectKey, true, true, true)) continue;
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
if (explicitPair) if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += "?";
else pairBuffer += "? ";
pairBuffer += state.dump;
if (explicitPair) pairBuffer += generateNextLine(state, level);
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) continue;
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += ":";
else pairBuffer += ": ";
pairBuffer += state.dump;
_result += pairBuffer;
}
state.tag = _tag;
state.dump = _result || "{}";
}
function detectType(state, object, explicit) {
var _result, typeList = explicit ? state.explicitTypes : state.implicitTypes, index, length, type$2, style;
for (index = 0, length = typeList.length; index < length; index += 1) {
type$2 = typeList[index];
if ((type$2.instanceOf || type$2.predicate) && (!type$2.instanceOf || typeof object === "object" && object instanceof type$2.instanceOf) && (!type$2.predicate || type$2.predicate(object))) {
if (explicit) if (type$2.multi && type$2.representName) state.tag = type$2.representName(object);
else state.tag = type$2.tag;
else state.tag = "?";
if (type$2.represent) {
style = state.styleMap[type$2.tag] || type$2.defaultStyle;
if (_toString.call(type$2.represent) === "[object Function]") _result = type$2.represent(object, style);
else if (_hasOwnProperty.call(type$2.represent, style)) _result = type$2.represent[style](object, style);
else throw new exception("!<" + type$2.tag + "> tag resolver accepts not \"" + style + "\" style");
state.dump = _result;
}
return true;
}
}
return false;
}
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
state.tag = null;
state.dump = object;
if (!detectType(state, object, false)) detectType(state, object, true);
var type$2 = _toString.call(state.dump);
var inblock = block;
var tagStr;
if (block) block = state.flowLevel < 0 || state.flowLevel > level;
var objectOrArray = type$2 === "[object Object]" || type$2 === "[object Array]", duplicateIndex, duplicate;
if (objectOrArray) {
duplicateIndex = state.duplicates.indexOf(object);
duplicate = duplicateIndex !== -1;
}
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) compact = false;
if (duplicate && state.usedDuplicates[duplicateIndex]) state.dump = "*ref_" + duplicateIndex;
else {
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) state.usedDuplicates[duplicateIndex] = true;
if (type$2 === "[object Object]") if (block && Object.keys(state.dump).length !== 0) {
writeBlockMapping(state, level, state.dump, compact);
if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
} else {
writeFlowMapping(state, level, state.dump);
if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
}
else if (type$2 === "[object Array]") if (block && state.dump.length !== 0) {
if (state.noArrayIndent && !isblockseq && level > 0) writeBlockSequence(state, level - 1, state.dump, compact);
else writeBlockSequence(state, level, state.dump, compact);
if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
} else {
writeFlowSequence(state, level, state.dump);
if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
}
else if (type$2 === "[object String]") {
if (state.tag !== "?") writeScalar(state, state.dump, level, iskey, inblock);
} else if (type$2 === "[object Undefined]") return false;
else {
if (state.skipInvalid) return false;
throw new exception("unacceptable kind of an object to dump " + type$2);
}
if (state.tag !== null && state.tag !== "?") {
tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
if (state.tag[0] === "!") tagStr = "!" + tagStr;
else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") tagStr = "!!" + tagStr.slice(18);
else tagStr = "!<" + tagStr + ">";
state.dump = tagStr + " " + state.dump;
}
}
return true;
}
function getDuplicateReferences(object, state) {
var objects = [], duplicatesIndexes = [], index, length;
inspectNode(object, objects, duplicatesIndexes);
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) state.duplicates.push(objects[duplicatesIndexes[index]]);
state.usedDuplicates = new Array(length);
}
function inspectNode(object, objects, duplicatesIndexes) {
var objectKeyList, index, length;
if (object !== null && typeof object === "object") {
index = objects.indexOf(object);
if (index !== -1) {
if (duplicatesIndexes.indexOf(index) === -1) duplicatesIndexes.push(index);
} else {
objects.push(object);
if (Array.isArray(object)) for (index = 0, length = object.length; index < length; index += 1) inspectNode(object[index], objects, duplicatesIndexes);
else {
objectKeyList = Object.keys(object);
for (index = 0, length = objectKeyList.length; index < length; index += 1) inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
}
}
}
}
function dump$1(input, options) {
options = options || {};
var state = new State(options);
if (!state.noRefs) getDuplicateReferences(input, state);
var value = input;
if (state.replacer) value = state.replacer.call({ "": value }, "", value);
if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
return "";
}
var dumper = { dump: dump$1 };
function renamed(from, to) {
return function() {
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
};
}
var Type = type$1;
var Schema = schema;
var FAILSAFE_SCHEMA = failsafe;
var JSON_SCHEMA = json;
var CORE_SCHEMA = core;
var DEFAULT_SCHEMA = _default;
var load = loader.load;
var loadAll = loader.loadAll;
var dump = dumper.dump;
var YAMLException = exception;
var types = {
binary,
float,
map,
null: _null,
pairs,
set,
timestamp,
bool,
int,
merge,
omap,
seq,
str
};
var safeLoad = renamed("safeLoad", "load");
var safeLoadAll = renamed("safeLoadAll", "loadAll");
var safeDump = renamed("safeDump", "dump");
var jsYaml = {
Type,
Schema,
FAILSAFE_SCHEMA,
JSON_SCHEMA,
CORE_SCHEMA,
DEFAULT_SCHEMA,
load,
loadAll,
dump,
YAMLException,
types,
safeLoad,
safeLoadAll,
safeDump
};
//#endregion
//#region ../../node_modules/.pnpm/jju@1.4.0/node_modules/jju/lib/unicode.js
var require_unicode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var Uni = module.exports;
module.exports.isWhiteSpace = function isWhiteSpace(x) {
return x === " " || x === "\xA0" || x === "" || x >= " " && x <= "\r" || x === "" || x >= " " && x <= "" || x === "\u2028" || x === "\u2029" || x === "" || x === "" || x === " ";
};
module.exports.isWhiteSpaceJSON = function isWhiteSpaceJSON(x) {
return x === " " || x === " " || x === "\n" || x === "\r";
};
module.exports.isLineTerminator = function isLineTerminator(x) {
return x === "\n" || x === "\r" || x === "\u2028" || x === "\u2029";
};
module.exports.isLineTerminatorJSON = function isLineTerminatorJSON(x) {
return x === "\n" || x === "\r";
};
module.exports.isIdentifierStart = function isIdentifierStart(x) {
return x === "$" || x === "_" || x >= "A" && x <= "Z" || x >= "a" && x <= "z" || x >= "€" && Uni.NonAsciiIdentifierStart.test(x);
};
module.exports.isIdentifierPart = function isIdentifierPart(x) {
return x === "$" || x === "_" || x >= "A" && x <= "Z" || x >= "a" && x <= "z" || x >= "0" && x <= "9" || x >= "€" && Uni.NonAsciiIdentifierPart.test(x);
};
module.exports.NonAsciiIdentifierStart = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
module.exports.NonAsciiIdentifierPart = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
}));
//#endregion
//#region ../../node_modules/.pnpm/jju@1.4.0/node_modules/jju/lib/parse.js
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var Uni = require_unicode();
function isHexDigit(x) {
return x >= "0" && x <= "9" || x >= "A" && x <= "F" || x >= "a" && x <= "f";
}
function isOctDigit(x) {
return x >= "0" && x <= "7";
}
function isDecDigit(x) {
return x >= "0" && x <= "9";
}
var unescapeMap = {
"'": "'",
"\"": "\"",
"\\": "\\",
"b": "\b",
"f": "\f",
"n": "\n",
"r": "\r",
"t": " ",
"v": "\v",
"/": "/"
};
function formatError(input, msg, position, lineno, column, json5) {
var result = msg + " at " + (lineno + 1) + ":" + (column + 1), tmppos = position - column - 1, srcline = "", underline = "";
var isLineTerminator = json5 ? Uni.isLineTerminator : Uni.isLineTerminatorJSON;
if (tmppos < position - 70) tmppos = position - 70;
while (1) {
var chr = input[++tmppos];
if (isLineTerminator(chr) || tmppos === input.length) {
if (position >= tmppos) underline += "^";
break;
}
srcline += chr;
if (position === tmppos) underline += "^";
else if (position > tmppos) underline += input[tmppos] === " " ? " " : " ";
if (srcline.length > 78) break;
}
return result + "\n" + srcline + "\n" + underline;
}
function parse(input, options) {
var json5 = false;
var cjson = false;
if (options.legacy || options.mode === "json") {} else if (options.mode === "cjson") cjson = true;
else if (options.mode === "json5") json5 = true;
else json5 = true;
var isLineTerminator = json5 ? Uni.isLineTerminator : Uni.isLineTerminatorJSON;
var isWhiteSpace = json5 ? Uni.isWhiteSpace : Uni.isWhiteSpaceJSON;
var length = input.length, lineno = 0, linestart = 0, position = 0, stack = [];
var tokenStart = function() {};
var tokenEnd = function(v) {
return v;
};
if (options._tokenize) (function() {
var start$1 = null;
tokenStart = function() {
if (start$1 !== null) throw Error("internal error, token overlap");
start$1 = position;
};
tokenEnd = function(v, type$2) {
if (start$1 != position) {
var hash = {
raw: input.substr(start$1, position - start$1),
type: type$2,
stack: stack.slice(0)
};
if (v !== void 0) hash.value = v;
options._tokenize.call(null, hash);
}
start$1 = null;
return v;
};
})();
function fail(msg) {
var column = position - linestart;
if (!msg) {
if (position < length) {
var token = "'" + JSON.stringify(input[position]).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\"") + "'";
if (!msg) msg = "Unexpected token " + token;
} else if (!msg) msg = "Unexpected end of input";
}
var error = SyntaxError(formatError(input, msg, position, lineno, column, json5));
error.row = lineno + 1;
error.column = column + 1;
throw error;
}
function newline(chr) {
if (chr === "\r" && input[position] === "\n") position++;
linestart = position;
lineno++;
}
function parseGeneric() {
while (position < length) {
tokenStart();
var chr = input[position++];
if (chr === "\"" || chr === "'" && json5) return tokenEnd(parseString(chr), "literal");
else if (chr === "{") {
tokenEnd(void 0, "separator");
return parseObject();
} else if (chr === "[") {
tokenEnd(void 0, "separator");
return parseArray();
} else if (chr === "-" || chr === "." || isDecDigit(chr) || json5 && (chr === "+" || chr === "I" || chr === "N")) return tokenEnd(parseNumber(), "literal");
else if (chr === "n") {
parseKeyword("null");
return tokenEnd(null, "literal");
} else if (chr === "t") {
parseKeyword("true");
return tokenEnd(true, "literal");
} else if (chr === "f") {
parseKeyword("false");
return tokenEnd(false, "literal");
} else {
position--;
return tokenEnd(void 0);
}
}
}
function parseKey() {
var result;
while (position < length) {
tokenStart();
var chr = input[position++];
if (chr === "\"" || chr === "'" && json5) return tokenEnd(parseString(chr), "key");
else if (chr === "{") {
tokenEnd(void 0, "separator");
return parseObject();
} else if (chr === "[") {
tokenEnd(void 0, "separator");
return parseArray();
} else if (chr === "." || isDecDigit(chr)) return tokenEnd(parseNumber(true), "key");
else if (json5 && Uni.isIdentifierStart(chr) || chr === "\\" && input[position] === "u") {
var rollback = position - 1;
var result = parseIdentifier();
if (result === void 0) {
position = rollback;
return tokenEnd(void 0);
} else return tokenEnd(result, "key");
} else {
position--;
return tokenEnd(void 0);
}
}
}
function skipWhiteSpace() {
tokenStart();
while (position < length) {
var chr = input[position++];
if (isLineTerminator(chr)) {
position--;
tokenEnd(void 0, "whitespace");
tokenStart();
position++;
newline(chr);
tokenEnd(void 0, "newline");
tokenStart();
} else if (isWhiteSpace(chr)) {} else if (chr === "/" && (json5 || cjson) && (input[position] === "/" || input[position] === "*")) {
position--;
tokenEnd(void 0, "whitespace");
tokenStart();
position++;
skipComment(input[position++] === "*");
tokenEnd(void 0, "comment");
tokenStart();
} else {
position--;
break;
}
}
return tokenEnd(void 0, "whitespace");
}
function skipComment(multi) {
while (position < length) {
var chr = input[position++];
if (isLineTerminator(chr)) {
if (!multi) {
position--;
return;
}
newline(chr);
} else if (chr === "*" && multi) {
if (input[position] === "/") {
position++;
return;
}
}
}
if (multi) fail("Unclosed multiline comment");
}
function parseKeyword(keyword) {
var _pos = position;
var len = keyword.length;
for (var i$1 = 1; i$1 < len; i$1++) {
if (position >= length || keyword[i$1] != input[position]) {
position = _pos - 1;
fail();
}
position++;
}
}
function parseObject() {
var result = options.null_prototype ? Object.create(null) : {}, empty_object = {}, is_non_empty = false;
while (position < length) {
skipWhiteSpace();
var item1 = parseKey();
skipWhiteSpace();
tokenStart();
var chr = input[position++];
tokenEnd(void 0, "separator");
if (chr === "}" && item1 === void 0) {
if (!json5 && is_non_empty) {
position--;
fail("Trailing comma in object");
}
return result;
} else if (chr === ":" && item1 !== void 0) {
skipWhiteSpace();
stack.push(item1);
var item2 = parseGeneric();
stack.pop();
if (item2 === void 0) fail("No value found for key " + item1);
if (typeof item1 !== "string") {
if (!json5 || typeof item1 !== "number") fail("Wrong key type: " + item1);
}
if ((item1 in empty_object || empty_object[item1] != null) && options.reserved_keys !== "replace") {
if (options.reserved_keys === "throw") fail("Reserved key: " + item1);
} else {
if (typeof options.reviver === "function") item2 = options.reviver.call(null, item1, item2);
if (item2 !== void 0) {
is_non_empty = true;
Object.defineProperty(result, item1, {
value: item2,
enumerable: true,
configurable: true,
writable: true
});
}
}
skipWhiteSpace();
tokenStart();
var chr = input[position++];
tokenEnd(void 0, "separator");
if (chr === ",") continue;
else if (chr === "}") return result;
else fail();
} else {
position--;
fail();
}
}
fail();
}
function parseArray() {
var result = [];
while (position < length) {
skipWhiteSpace();
stack.push(result.length);
var item = parseGeneric();
stack.pop();
skipWhiteSpace();
tokenStart();
var chr = input[position++];
tokenEnd(void 0, "separator");
if (item !== void 0) {
if (typeof options.reviver === "function") item = options.reviver.call(null, String(result.length), item);
if (item === void 0) {
result.length++;
item = true;
} else result.push(item);
}
if (chr === ",") {
if (item === void 0) fail("Elisions are not supported");
} else if (chr === "]") {
if (!json5 && item === void 0 && result.length) {
position--;
fail("Trailing comma in array");
}
return result;
} else {
position--;
fail();
}
}
}
function parseNumber() {
position--;
var start$1 = position, chr = input[position++];
var to_num = function(is_octal$1) {
var str$1 = input.substr(start$1, position - start$1);
if (is_octal$1) var result = parseInt(str$1.replace(/^0o?/, ""), 8);
else var result = Number(str$1);
if (Number.isNaN(result)) {
position--;
fail("Bad numeric literal - \"" + input.substr(start$1, position - start$1 + 1) + "\"");
} else if (!json5 && !str$1.match(/^-?(0|[1-9][0-9]*)(\.[0-9]+)?(e[+-]?[0-9]+)?$/i)) {
position--;
fail("Non-json numeric literal - \"" + input.substr(start$1, position - start$1 + 1) + "\"");
} else return result;
};
if (chr === "-" || chr === "+" && json5) chr = input[position++];
if (chr === "N" && json5) {
parseKeyword("NaN");
return NaN;
}
if (chr === "I" && json5) {
parseKeyword("Infinity");
return to_num();
}
if (chr >= "1" && chr <= "9") {
while (position < length && isDecDigit(input[position])) position++;
chr = input[position++];
}
if (chr === "0") {
chr = input[position++];
var is_octal = chr === "o" || chr === "O" || isOctDigit(chr);
var is_hex = chr === "x" || chr === "X";
if (json5 && (is_octal || is_hex)) {
while (position < length && (is_hex ? isHexDigit : isOctDigit)(input[position])) position++;
var sign = 1;
if (input[start$1] === "-") {
sign = -1;
start$1++;
} else if (input[start$1] === "+") start$1++;
return sign * to_num(is_octal);
}
}
if (chr === ".") {
while (position < length && isDecDigit(input[position])) position++;
chr = input[position++];
}
if (chr === "e" || chr === "E") {
chr = input[position++];
if (chr === "-" || chr === "+") position++;
while (position < length && isDecDigit(input[position])) position++;
chr = input[position++];
}
position--;
return to_num();
}
function parseIdentifier() {
position--;
var result = "";
while (position < length) {
var chr = input[position++];
if (chr === "\\" && input[position] === "u" && isHexDigit(input[position + 1]) && isHexDigit(input[position + 2]) && isHexDigit(input[position + 3]) && isHexDigit(input[position + 4])) {
chr = String.fromCharCode(parseInt(input.substr(position + 1, 4), 16));
position += 5;
}
if (result.length) if (Uni.isIdentifierPart(chr)) result += chr;
else {
position--;
return result;
}
else if (Uni.isIdentifierStart(chr)) result += chr;
else return;
}
fail();
}
function parseString(endChar) {
var result = "";
while (position < length) {
var chr = input[position++];
if (chr === endChar) return result;
else if (chr === "\\") {
if (position >= length) fail();
chr = input[position++];
if (unescapeMap[chr] && (json5 || chr != "v" && chr != "'")) result += unescapeMap[chr];
else if (json5 && isLineTerminator(chr)) newline(chr);
else if (chr === "u" || chr === "x" && json5) {
var off = chr === "u" ? 4 : 2;
for (var i$1 = 0; i$1 < off; i$1++) {
if (position >= length) fail();
if (!isHexDigit(input[position])) fail("Bad escape sequence");
position++;
}
result += String.fromCharCode(parseInt(input.substr(position - off, off), 16));
} else if (json5 && isOctDigit(chr)) {
if (chr < "4" && isOctDigit(input[position]) && isOctDigit(input[position + 1])) var digits = 3;
else if (isOctDigit(input[position])) var digits = 2;
else var digits = 1;
position += digits - 1;
result += String.fromCharCode(parseInt(input.substr(position - digits, digits), 8));
} else if (json5) result += chr;
else {
position--;
fail();
}
} else if (isLineTerminator(chr)) fail();
else {
if (!json5 && chr.charCodeAt(0) < 32) {
position--;
fail("Unexpected control character");
}
result += chr;
}
}
fail();
}
skipWhiteSpace();
var return_value = parseGeneric();
if (return_value !== void 0 || position < length) {
skipWhiteSpace();
if (position >= length) {
if (typeof options.reviver === "function") return_value = options.reviver.call(null, "", return_value);
return return_value;
} else fail();
} else if (position) fail("No data, only a whitespace");
else fail("No data, empty input");
}
module.exports.parse = function parseJSON(input, options) {
if (typeof options === "function") options = { reviver: options };
if (input === void 0) return;
if (typeof input !== "string") input = String(input);
if (options == null) options = {};
if (options.reserved_keys == null) options.reserved_keys = "ignore";
if (options.reserved_keys === "throw" || options.reserved_keys === "ignore") {
if (options.null_prototype == null) options.null_prototype = true;
}
try {
return parse(input, options);
} catch (err) {
if (err instanceof SyntaxError && err.row != null && err.column != null) {
var old_err = err;
err = SyntaxError(old_err.message);
err.column = old_err.column;
err.row = old_err.row;
}
throw err;
}
};
module.exports.tokenize = function tokenizeJSON(input, options) {
if (options == null) options = {};
options._tokenize = function(smth) {
if (options._addstack) smth.stack.unshift.apply(smth.stack, options._addstack);
tokens.push(smth);
};
var tokens = [];
tokens.data = module.exports.parse(input, options);
return tokens;
};
}));
//#endregion
//#region ../../node_modules/.pnpm/jju@1.4.0/node_modules/jju/lib/stringify.js
var require_stringify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var Uni = require_unicode();
if (!(function f() {}).name) Object.defineProperty((function() {}).constructor.prototype, "name", { get: function() {
var name$1 = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
Object.defineProperty(this, "name", { value: name$1 });
return name$1;
} });
var special_chars = {
0: "\\0",
8: "\\b",
9: "\\t",
10: "\\n",
11: "\\v",
12: "\\f",
13: "\\r",
92: "\\\\"
};
var hasOwnProperty = Object.prototype.hasOwnProperty;
var escapable = /[\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
function _stringify(object, options, recursiveLvl, currentKey) {
var json5 = options.mode === "json5" || !options.mode;
function indent(str$2, add) {
var prefix = options._prefix ? options._prefix : "";
if (!options.indent) return prefix + str$2;
var result = "";
var count = recursiveLvl + (add || 0);
for (var i$1 = 0; i$1 < count; i$1++) result += options.indent;
return prefix + result + str$2 + (add ? "\n" : "");
}
function _stringify_key(key) {
if (options.quote_keys) return _stringify_str(key);
if (String(Number(key)) == key && key[0] != "-") return key;
if (key == "") return _stringify_str(key);
var result = "";
for (var i$1 = 0; i$1 < key.length; i$1++) {
if (i$1 > 0) {
if (!Uni.isIdentifierPart(key[i$1])) return _stringify_str(key);
} else if (!Uni.isIdentifierStart(key[i$1])) return _stringify_str(key);
var chr = key.charCodeAt(i$1);
if (options.ascii) if (chr < 128) result += key[i$1];
else result += "\\u" + ("0000" + chr.toString(16)).slice(-4);
else if (escapable.exec(key[i$1])) result += "\\u" + ("0000" + chr.toString(16)).slice(-4);
else result += key[i$1];
}
return result;
}
function _stringify_str(key) {
var quote = options.quote;
var quoteChr = quote.charCodeAt(0);
var result = "";
for (var i$1 = 0; i$1 < key.length; i$1++) {
var chr = key.charCodeAt(i$1);
if (chr < 16) if (chr === 0 && json5) result += "\\0";
else if (chr >= 8 && chr <= 13 && (json5 || chr !== 11)) result += special_chars[chr];
else if (json5) result += "\\x0" + chr.toString(16);
else result += "\\u000" + chr.toString(16);
else if (chr < 32) if (json5) result += "\\x" + chr.toString(16);
else result += "\\u00" + chr.toString(16);
else if (chr >= 32 && chr < 128) if (chr === 47 && i$1 && key[i$1 - 1] === "<") result += "\\" + key[i$1];
else if (chr === 92) result += "\\\\";
else if (chr === quoteChr) result += "\\" + quote;
else result += key[i$1];
else if (options.ascii || Uni.isLineTerminator(key[i$1]) || escapable.exec(key[i$1])) if (chr < 256) if (json5) result += "\\x" + chr.toString(16);
else result += "\\u00" + chr.toString(16);
else if (chr < 4096) result += "\\u0" + chr.toString(16);
else if (chr < 65536) result += "\\u" + chr.toString(16);
else throw Error("weird codepoint");
else result += key[i$1];
}
return quote + result + quote;
}
function _stringify_object() {
if (object === null) return "null";
var result = [], len = 0, braces;
if (Array.isArray(object)) {
braces = "[]";
for (var i$1 = 0; i$1 < object.length; i$1++) {
var s = _stringify(object[i$1], options, recursiveLvl + 1, String(i$1));
if (s === void 0) s = "null";
len += s.length + 2;
result.push(s + ",");
}
} else {
braces = "{}";
var fn = function(key) {
var t = _stringify(object[key], options, recursiveLvl + 1, key);
if (t !== void 0) {
t = _stringify_key(key) + ":" + (options.indent ? " " : "") + t + ",";
len += t.length + 1;
result.push(t);
}
};
if (Array.isArray(options.replacer)) {
for (var i$1 = 0; i$1 < options.replacer.length; i$1++) if (hasOwnProperty.call(object, options.replacer[i$1])) fn(options.replacer[i$1]);
} else {
var keys = Object.keys(object);
if (options.sort_keys) keys = keys.sort(typeof options.sort_keys === "function" ? options.sort_keys : void 0);
keys.forEach(fn);
}
}
len -= 2;
if (options.indent && (len > options._splitMax - recursiveLvl * options.indent.length || len > options._splitMin)) {
if (options.no_trailing_comma && result.length) result[result.length - 1] = result[result.length - 1].substring(0, result[result.length - 1].length - 1);
var innerStuff = result.map(function(x) {
return indent(x, 1);
}).join("");
return braces[0] + (options.indent ? "\n" : "") + innerStuff + indent(braces[1]);
} else {
if (result.length) result[result.length - 1] = result[result.length - 1].substring(0, result[result.length - 1].length - 1);
var innerStuff = result.join(options.indent ? " " : "");
return braces[0] + innerStuff + braces[1];
}
}
function _stringify_nonobject(object$1) {
if (typeof options.replacer === "function") object$1 = options.replacer.call(null, currentKey, object$1);
switch (typeof object$1) {
case "string": return _stringify_str(object$1);
case "number":
if (object$1 === 0 && 1 / object$1 < 0) return "-0";
if (!json5 && !Number.isFinite(object$1)) return "null";
return object$1.toString();
case "boolean": return object$1.toString();
case "undefined": return;
case "function":
default: return JSON.stringify(object$1);
}
}
if (options._stringify_key) return _stringify_key(object);
if (typeof object === "object") {
if (object === null) return "null";
var str$1;
if (typeof (str$1 = object.toJSON5) === "function" && options.mode !== "json") object = str$1.call(object, currentKey);
else if (typeof (str$1 = object.toJSON) === "function") object = str$1.call(object, currentKey);
if (object === null) return "null";
if (typeof object !== "object") return _stringify_nonobject(object);
if (object.constructor === Number || object.constructor === Boolean || object.constructor === String) {
object = object.valueOf();
return _stringify_nonobject(object);
} else if (object.constructor === Date) return _stringify_nonobject(object.toISOString());
else {
if (typeof options.replacer === "function") {
object = options.replacer.call(null, currentKey, object);
if (typeof object !== "object") return _stringify_nonobject(object);
}
return _stringify_object(object);
}
} else return _stringify_nonobject(object);
}
module.exports.stringify = function stringifyJSON(object, options, _space) {
if (typeof options === "function" || Array.isArray(options)) options = { replacer: options };
else if (typeof options === "object" && options !== null) {} else options = {};
if (_space != null) options.indent = _space;
if (options.indent == null) options.indent = " ";
if (options.quote == null) options.quote = "'";
if (options.ascii == null) options.ascii = false;
if (options.mode == null) options.mode = "json5";
if (options.mode === "json" || options.mode === "cjson") {
options.quote = "\"";
options.no_trailing_comma = true;
options.quote_keys = true;
}
if (typeof options.indent === "object") {
if (options.indent.constructor === Number || options.indent.constructor === Boolean || options.indent.constructor === String) options.indent = options.indent.valueOf();
}
if (typeof options.indent === "number") if (options.indent >= 0) options.indent = Array(Math.min(~~options.indent, 10) + 1).join(" ");
else options.indent = false;
else if (typeof options.indent === "string") options.indent = options.indent.substr(0, 10);
if (options._splitMin == null) options._splitMin = 50;
if (options._splitMax == null) options._splitMax = 70;
return _stringify(object, options, 0, "");
};
}));
//#endregion
//#region ../../node_modules/.pnpm/jju@1.4.0/node_modules/jju/lib/analyze.js
var require_analyze = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var tokenize = require_parse().tokenize;
module.exports.analyze = function analyzeJSON(input, options) {
if (options == null) options = {};
if (!Array.isArray(input)) input = tokenize(input, options);
var result = {
has_whitespace: false,
has_comments: false,
has_newlines: false,
has_trailing_comma: false,
indent: "",
newline: "\n",
quote: "\"",
quote_keys: true
};
var stats = {
indent: {},
newline: {},
quote: {}
};
for (var i$1 = 0; i$1 < input.length; i$1++) {
if (input[i$1].type === "newline") {
if (input[i$1 + 1] && input[i$1 + 1].type === "whitespace") {
if (input[i$1 + 1].raw[0] === " ") stats.indent[" "] = (stats.indent[" "] || 0) + 1;
if (input[i$1 + 1].raw.match(/^\x20+$/)) {
var ws_len = input[i$1 + 1].raw.length;
var indent_len = input[i$1 + 1].stack.length + 1;
if (ws_len % indent_len === 0) {
var t = Array(ws_len / indent_len + 1).join(" ");
stats.indent[t] = (stats.indent[t] || 0) + 1;
}
}
}
stats.newline[input[i$1].raw] = (stats.newline[input[i$1].raw] || 0) + 1;
}
if (input[i$1].type === "newline") result.has_newlines = true;
if (input[i$1].type === "whitespace") result.has_whitespace = true;
if (input[i$1].type === "comment") result.has_comments = true;
if (input[i$1].type === "key") {
if (input[i$1].raw[0] !== "\"" && input[i$1].raw[0] !== "'") result.quote_keys = false;
}
if (input[i$1].type === "key" || input[i$1].type === "literal") {
if (input[i$1].raw[0] === "\"" || input[i$1].raw[0] === "'") stats.quote[input[i$1].raw[0]] = (stats.quote[input[i$1].raw[0]] || 0) + 1;
}
if (input[i$1].type === "separator" && input[i$1].raw === ",") for (var j = i$1 + 1; j < input.length; j++) {
if (input[j].type === "literal" || input[j].type === "key") break;
if (input[j].type === "separator") result.has_trailing_comma = true;
}
}
for (var k in stats) if (Object.keys(stats[k]).length) result[k] = Object.keys(stats[k]).reduce(function(a, b) {
return stats[k][a] > stats[k][b] ? a : b;
});
return result;
};
}));
//#endregion
//#region ../../node_modules/.pnpm/jju@1.4.0/node_modules/jju/lib/document.js
var require_document = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var assert = __require$1("assert");
var tokenize = require_parse().tokenize;
var stringify = require_stringify().stringify;
var analyze = require_analyze().analyze;
function isObject(x) {
return typeof x === "object" && x !== null;
}
function value_to_tokenlist(value, stack, options, is_key, indent) {
options = Object.create(options);
options._stringify_key = !!is_key;
if (indent) options._prefix = indent.prefix.map(function(x) {
return x.raw;
}).join("");
if (options._splitMin == null) options._splitMin = 0;
if (options._splitMax == null) options._splitMax = 0;
var stringified = stringify(value, options);
if (is_key) return [{
raw: stringified,
type: "key",
stack,
value
}];
options._addstack = stack;
var result = tokenize(stringified, { _addstack: stack });
result.data = null;
return result;
}
function arg_to_path(path$3) {
if (typeof path$3 === "number") path$3 = String(path$3);
if (path$3 === "") path$3 = [];
if (typeof path$3 === "string") path$3 = path$3.split(".");
if (!Array.isArray(path$3)) throw Error("Invalid path type, string or array expected");
return path$3;
}
function find_element_in_tokenlist(element, lvl, tokens, begin, end) {
while (tokens[begin].stack[lvl] != element) if (begin++ >= end) return false;
while (tokens[end].stack[lvl] != element) if (end-- < begin) return false;
return [begin, end];
}
function is_whitespace(token_type) {
return token_type === "whitespace" || token_type === "newline" || token_type === "comment";
}
function find_first_non_ws_token(tokens, begin, end) {
while (is_whitespace(tokens[begin].type)) if (begin++ >= end) return false;
return begin;
}
function find_last_non_ws_token(tokens, begin, end) {
while (is_whitespace(tokens[end].type)) if (end-- < begin) return false;
return end;
}
function detect_indent_style(tokens, is_array, begin, end, level) {
var result = {
sep1: [],
sep2: [],
suffix: [],
prefix: [],
newline: []
};
if (tokens[end].type === "separator" && tokens[end].stack.length !== level + 1 && tokens[end].raw !== ",") return result;
if (tokens[end].type === "separator") end = find_last_non_ws_token(tokens, begin, end - 1);
if (end === false) return result;
while (tokens[end].stack.length > level) end--;
if (!is_array) {
while (is_whitespace(tokens[end].type)) {
if (end < begin) return result;
if (tokens[end].type === "whitespace") result.sep2.unshift(tokens[end]);
else return result;
end--;
}
assert.equal(tokens[end].type, "separator");
assert.equal(tokens[end].raw, ":");
while (is_whitespace(tokens[--end].type)) {
if (end < begin) return result;
if (tokens[end].type === "whitespace") result.sep1.unshift(tokens[end]);
else return result;
}
assert.equal(tokens[end].type, "key");
end--;
}
while (is_whitespace(tokens[end].type)) {
if (end < begin) return result;
if (tokens[end].type === "whitespace") result.prefix.unshift(tokens[end]);
else if (tokens[end].type === "newline") {
result.newline.unshift(tokens[end]);
return result;
} else return result;
end--;
}
return result;
}
function Document(text, options) {
var self = Object.create(Document.prototype);
if (options == null) options = {};
var tokens = self._tokens = tokenize(text, options);
self._data = tokens.data;
tokens.data = null;
self._options = options;
var stats = analyze(text, options);
if (options.indent == null) options.indent = stats.indent;
if (options.quote == null) options.quote = stats.quote;
if (options.quote_keys == null) options.quote_keys = stats.quote_keys;
if (options.no_trailing_comma == null) options.no_trailing_comma = !stats.has_trailing_comma;
return self;
}
function check_if_can_be_placed(key, object, is_unset) {
function error(add) {
return Error("You can't " + (is_unset ? "unset" : "set") + " key '" + key + "'" + add);
}
if (!isObject(object)) throw error(" of an non-object");
if (Array.isArray(object)) if (String(key).match(/^\d+$/)) {
key = Number(String(key));
if (object.length < key || is_unset && object.length === key) throw error(", out of bounds");
else if (is_unset && object.length !== key + 1) throw error(" in the middle of an array");
else return true;
} else throw error(" of an array");
else return true;
}
Document.prototype.set = function(path$3, value) {
path$3 = arg_to_path(path$3);
if (path$3.length === 0) {
if (value === void 0) throw Error("can't remove root document");
this._data = value;
var new_key = false;
} else {
var data = this._data;
for (var i$1 = 0; i$1 < path$3.length - 1; i$1++) {
check_if_can_be_placed(path$3[i$1], data, false);
data = data[path$3[i$1]];
}
if (i$1 === path$3.length - 1) check_if_can_be_placed(path$3[i$1], data, value === void 0);
var new_key = !(path$3[i$1] in data);
if (value === void 0) if (Array.isArray(data)) data.pop();
else delete data[path$3[i$1]];
else data[path$3[i$1]] = value;
}
if (!this._tokens.length) this._tokens = [{
raw: "",
type: "literal",
stack: [],
value: void 0
}];
var position = [find_first_non_ws_token(this._tokens, 0, this._tokens.length - 1), find_last_non_ws_token(this._tokens, 0, this._tokens.length - 1)];
for (var i$1 = 0; i$1 < path$3.length - 1; i$1++) {
position = find_element_in_tokenlist(path$3[i$1], i$1, this._tokens, position[0], position[1]);
if (position == false) throw Error("internal error, please report this");
}
if (path$3.length === 0) var newtokens = value_to_tokenlist(value, path$3, this._options);
else if (!new_key) {
var pos_old = position;
position = find_element_in_tokenlist(path$3[i$1], i$1, this._tokens, position[0], position[1]);
if (value === void 0 && position !== false) {
var newtokens = [];
if (!Array.isArray(data)) {
var pos2 = find_last_non_ws_token(this._tokens, pos_old[0], position[0] - 1);
assert.equal(this._tokens[pos2].type, "separator");
assert.equal(this._tokens[pos2].raw, ":");
position[0] = pos2;
var pos2 = find_last_non_ws_token(this._tokens, pos_old[0], position[0] - 1);
assert.equal(this._tokens[pos2].type, "key");
assert.equal(this._tokens[pos2].value, path$3[path$3.length - 1]);
position[0] = pos2;
}
var pos2 = find_last_non_ws_token(this._tokens, pos_old[0], position[0] - 1);
assert.equal(this._tokens[pos2].type, "separator");
if (this._tokens[pos2].raw === ",") position[0] = pos2;
else {
pos2 = find_first_non_ws_token(this._tokens, position[1] + 1, pos_old[1]);
assert.equal(this._tokens[pos2].type, "separator");
if (this._tokens[pos2].raw === ",") position[1] = pos2;
}
} else {
var indent = pos2 !== false ? detect_indent_style(this._tokens, Array.isArray(data), pos_old[0], position[1] - 1, i$1) : {};
var newtokens = value_to_tokenlist(value, path$3, this._options, false, indent);
}
} else {
var path_1 = path$3.slice(0, i$1);
var pos2 = find_last_non_ws_token(this._tokens, position[0] + 1, position[1] - 1);
assert(pos2 !== false);
var indent = pos2 !== false ? detect_indent_style(this._tokens, Array.isArray(data), position[0] + 1, pos2, i$1) : {};
var newtokens = value_to_tokenlist(value, path$3, this._options, false, indent);
var prefix = [];
if (indent.newline && indent.newline.length) prefix = prefix.concat(indent.newline);
if (indent.prefix && indent.prefix.length) prefix = prefix.concat(indent.prefix);
if (!Array.isArray(data)) {
prefix = prefix.concat(value_to_tokenlist(path$3[path$3.length - 1], path_1, this._options, true));
if (indent.sep1 && indent.sep1.length) prefix = prefix.concat(indent.sep1);
prefix.push({
raw: ":",
type: "separator",
stack: path_1
});
if (indent.sep2 && indent.sep2.length) prefix = prefix.concat(indent.sep2);
}
newtokens.unshift.apply(newtokens, prefix);
if (this._tokens[pos2].type === "separator" && this._tokens[pos2].stack.length === path$3.length - 1) {
if (this._tokens[pos2].raw === ",") newtokens.push({
raw: ",",
type: "separator",
stack: path_1
});
} else newtokens.unshift({
raw: ",",
type: "separator",
stack: path_1
});
if (indent.suffix && indent.suffix.length) newtokens.push.apply(newtokens, indent.suffix);
assert.equal(this._tokens[position[1]].type, "separator");
position[0] = pos2 + 1;
position[1] = pos2;
}
newtokens.unshift(position[1] - position[0] + 1);
newtokens.unshift(position[0]);
this._tokens.splice.apply(this._tokens, newtokens);
return this;
};
Document.prototype.unset = function(path$3) {
return this.set(path$3, void 0);
};
Document.prototype.get = function(path$3) {
path$3 = arg_to_path(path$3);
var data = this._data;
for (var i$1 = 0; i$1 < path$3.length; i$1++) {
if (!isObject(data)) return void 0;
data = data[path$3[i$1]];
}
return data;
};
Document.prototype.has = function(path$3) {
path$3 = arg_to_path(path$3);
var data = this._data;
for (var i$1 = 0; i$1 < path$3.length; i$1++) {
if (!isObject(data)) return false;
data = data[path$3[i$1]];
}
return data !== void 0;
};
Document.prototype.update = function(value) {
var self = this;
change([], self._data, value);
return self;
function change(path$3, old_data, new_data) {
if (!isObject(new_data) || !isObject(old_data)) {
if (new_data !== old_data) self.set(path$3, new_data);
} else if (Array.isArray(new_data) != Array.isArray(old_data)) self.set(path$3, new_data);
else if (Array.isArray(new_data)) if (new_data.length > old_data.length) for (var i$1 = 0; i$1 < new_data.length; i$1++) {
path$3.push(String(i$1));
change(path$3, old_data[i$1], new_data[i$1]);
path$3.pop();
}
else for (var i$1 = old_data.length - 1; i$1 >= 0; i$1--) {
path$3.push(String(i$1));
change(path$3, old_data[i$1], new_data[i$1]);
path$3.pop();
}
else {
for (var i$1 in new_data) {
path$3.push(String(i$1));
change(path$3, old_data[i$1], new_data[i$1]);
path$3.pop();
}
for (var i$1 in old_data) {
if (i$1 in new_data) continue;
path$3.push(String(i$1));
change(path$3, old_data[i$1], new_data[i$1]);
path$3.pop();
}
}
}
};
Document.prototype.toString = function() {
return this._tokens.map(function(x) {
return x.raw;
}).join("");
};
module.exports.Document = Document;
module.exports.update = function updateJSON(source, new_value, options) {
return Document(source, options).update(new_value).toString();
};
}));
//#endregion
//#region ../../node_modules/.pnpm/jju@1.4.0/node_modules/jju/lib/utils.js
var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var FS = __require$1("fs");
var jju = require_jju();
module.exports.register = function() {
var r = __require$1, e = "extensions";
r[e][".json5"] = function(m, f) {
m.exports = jju.parse(FS.readFileSync(f, "utf8"));
};
};
module.exports.patch_JSON_parse = function() {
var _parse = JSON.parse;
JSON.parse = function(text, rev) {
try {
return _parse(text, rev);
} catch (err) {
require_jju().parse(text, {
mode: "json",
legacy: true,
reviver: rev,
reserved_keys: "replace",
null_prototype: false
});
throw err;
}
};
};
module.exports.middleware = function() {
return function(req, res, next) {
throw Error("this function is removed, use express-json5 instead");
};
};
}));
//#endregion
//#region ../../node_modules/.pnpm/jju@1.4.0/node_modules/jju/index.js
var require_jju = /* @__PURE__ */ __commonJSMin(((exports, module) => {
module.exports.__defineGetter__("parse", function() {
return require_parse().parse;
});
module.exports.__defineGetter__("stringify", function() {
return require_stringify().stringify;
});
module.exports.__defineGetter__("tokenize", function() {
return require_parse().tokenize;
});
module.exports.__defineGetter__("update", function() {
return require_document().update;
});
module.exports.__defineGetter__("analyze", function() {
return require_analyze().analyze;
});
module.exports.__defineGetter__("utils", function() {
return require_utils();
});
}));
/**package
{ "name": "jju",
"version": "0.0.0",
"dependencies": {"js-yaml": "*"},
"scripts": {"postinstall": "js-yaml package.yaml > package.json ; npm install"}
}
**/
//#endregion
//#region ../../node_modules/.pnpm/@manypkg+tools@2.1.0/node_modules/@manypkg/tools/dist/manypkg-tools.js
var import_jju = /* @__PURE__ */ __toESM(require_jju(), 1);
/**
* A package.json access type.
*/
/**
* An in-memory representation of a package.json file.
*/
/**
* An individual package json structure, along with the directory it lives in,
* relative to the root of the current monorepo.
*/
/**
* A collection of packages, along with the monorepo tool used to load them,
* and (if supported by the tool) the associated "root" package.
*/
/**
* An object representing the root of a specific monorepo, with the root
* directory and associated monorepo tool.
*
* Note that this type is currently not used by Tool definitions directly,
* but it is the suggested way to pass around a reference to a monorepo root
* directory and associated tool.
*/
/**
* Monorepo tools may throw this error if a caller attempts to get the package
* collection from a directory that is not a valid monorepo root.
*/
var InvalidMonorepoError = class extends Error {};
/**
* A monorepo tool is a specific implementation of monorepos, whether provided built-in
* by a package manager or via some other wrapper.
*
* Each tool defines a common interface for detecting whether a directory is
* a valid instance of this type of monorepo, how to retrieve the packages, etc.
*/
const readJson = async (directory, file) => JSON.parse(await fsp.readFile(path.join(directory, file), "utf-8"));
const readJsonSync = (directory, file) => JSON.parse(fs.readFileSync(path.join(directory, file), "utf-8"));
/**
* This internal method takes a list of one or more directory globs and the absolute path
* to the root directory, and returns a list of all matching relative directories that
* contain a `package.json` file.
*/
async function expandPackageGlobs(packageGlobs, directory) {
const directories = (await glob$1(packageGlobs, {
cwd: directory,
onlyDirectories: true,
ignore: ["**/node_modules"],
expandDirectories: false
})).map((p) => path.resolve(directory, p)).sort();
return (await Promise.all(directories.map((dir) => fsp.readFile(path.join(dir, "package.json"), "utf-8").catch((err) => {
if (err && err.code === "ENOENT") return;
throw err;
}).then((result) => {
if (result) return {
dir: path.resolve(dir),
relativeDir: path.relative(directory, dir),
packageJson: JSON.parse(result)
};
})))).filter((pkg) => pkg);
}
/**
* A synchronous version of {@link expandPackagesGlobs}.
*/
function expandPackageGlobsSync(packageGlobs, directory) {
return globSync(packageGlobs, {
cwd: directory,
onlyDirectories: true,
ignore: ["**/node_modules"],
expandDirectories: false
}).map((p) => path.resolve(directory, p)).sort().map((dir) => {
try {
const packageJson = readJsonSync(dir, "package.json");
return {
dir: path.resolve(dir),
relativeDir: path.relative(directory, dir),
packageJson
};
} catch (err) {
if (err && err.code === "ENOENT") return;
throw err;
}
}).filter((pkg) => pkg);
}
async function hasBunLockFile(directory) {
try {
await Promise.any([fsp$1.access(path$2.join(directory, "bun.lockb"), F_OK), fsp$1.access(path$2.join(directory, "bun.lock"), F_OK)]);
return true;
} catch (err) {
return false;
}
}
function hasBunLockFileSync(directory) {
try {
fs$1.accessSync(path$2.join(directory, "bun.lockb"), F_OK);
return true;
} catch (err) {
try {
fs$1.accessSync(path$2.join(directory, "bun.lock"), F_OK);
return true;
} catch (err$1) {
return false;
}
}
}
const BunTool = {
type: "bun",
async isMonorepoRoot(directory) {
try {
const [pkgJson, hasLockFile] = await Promise.all([readJson(directory, "package.json"), hasBunLockFile(directory)]);
if (pkgJson.workspaces && hasLockFile) {
if (Array.isArray(pkgJson.workspaces)) return true;
}
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
isMonorepoRootSync(directory) {
try {
if (!hasBunLockFileSync(directory)) return false;
const pkgJson = readJsonSync(directory, "package.json");
if (pkgJson.workspaces) {
if (Array.isArray(pkgJson.workspaces)) return true;
}
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
async getPackages(directory) {
const rootDir = path$2.resolve(directory);
try {
const pkgJson = await readJson(rootDir, "package.json");
return {
tool: BunTool,
packages: await expandPackageGlobs(pkgJson.workspaces || [], rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${BunTool.type} monorepo root`);
throw err;
}
},
getPackagesSync(directory) {
const rootDir = path$2.resolve(directory);
try {
const pkgJson = readJsonSync(rootDir, "package.json");
return {
tool: BunTool,
packages: expandPackageGlobsSync(pkgJson.workspaces || [], rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${BunTool.type} monorepo root`);
throw err;
}
}
};
const LernaTool = {
type: "lerna",
async isMonorepoRoot(directory) {
try {
if ((await readJson(directory, "lerna.json")).useWorkspaces !== true) return true;
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
isMonorepoRootSync(directory) {
try {
if (readJsonSync(directory, "lerna.json").useWorkspaces !== true) return true;
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
async getPackages(directory) {
const rootDir = path.resolve(directory);
try {
const lernaJson = await readJson(rootDir, "lerna.json");
const pkgJson = await readJson(rootDir, "package.json");
return {
tool: LernaTool,
packages: await expandPackageGlobs(lernaJson.packages || ["packages/*"], rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${LernaTool.type} monorepo root: missing lerna.json and/or package.json`);
throw err;
}
},
getPackagesSync(directory) {
const rootDir = path.resolve(directory);
try {
const lernaJson = readJsonSync(rootDir, "lerna.json");
const pkgJson = readJsonSync(rootDir, "package.json");
return {
tool: LernaTool,
packages: expandPackageGlobsSync(lernaJson.packages || ["packages/*"], rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${LernaTool.type} monorepo root: missing lerna.json and/or package.json`);
throw err;
}
}
};
const NpmTool = {
type: "npm",
async isMonorepoRoot(directory) {
try {
const [pkgJson] = await Promise.all([readJson(directory, "package.json"), fsp.access(path.join(directory, "package-lock.json"), F_OK)]);
if (pkgJson.workspaces) {
if (Array.isArray(pkgJson.workspaces)) return true;
}
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
isMonorepoRootSync(directory) {
try {
fs.accessSync(path.join(directory, "package-lock.json"), F_OK);
const pkgJson = readJsonSync(directory, "package.json");
if (pkgJson.workspaces) {
if (Array.isArray(pkgJson.workspaces)) return true;
}
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
async getPackages(directory) {
const rootDir = path.resolve(directory);
try {
const pkgJson = await readJson(rootDir, "package.json");
const packageGlobs = pkgJson.workspaces;
return {
tool: NpmTool,
packages: await expandPackageGlobs(packageGlobs, rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${NpmTool.type} monorepo root`);
throw err;
}
},
getPackagesSync(directory) {
const rootDir = path.resolve(directory);
try {
const pkgJson = readJsonSync(rootDir, "package.json");
const packageGlobs = pkgJson.workspaces;
return {
tool: NpmTool,
packages: expandPackageGlobsSync(packageGlobs, rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${NpmTool.type} monorepo root`);
throw err;
}
}
};
async function readYamlFile(path$3) {
return fsp.readFile(path$3, "utf8").then((data) => jsYaml.load(data));
}
function readYamlFileSync(path$3) {
return jsYaml.load(fs.readFileSync(path$3, "utf8"));
}
const PnpmTool = {
type: "pnpm",
async isMonorepoRoot(directory) {
try {
if ((await readYamlFile(path.join(directory, "pnpm-workspace.yaml"))).packages) return true;
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
isMonorepoRootSync(directory) {
try {
if (readYamlFileSync(path.join(directory, "pnpm-workspace.yaml")).packages) return true;
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
async getPackages(directory) {
const rootDir = path.resolve(directory);
try {
const manifest = await readYamlFile(path.join(rootDir, "pnpm-workspace.yaml"));
const pkgJson = await readJson(rootDir, "package.json");
const packageGlobs = manifest.packages;
return {
tool: PnpmTool,
packages: await expandPackageGlobs(packageGlobs, rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${PnpmTool.type} monorepo root: missing pnpm-workspace.yaml and/or package.json`);
throw err;
}
},
getPackagesSync(directory) {
const rootDir = path.resolve(directory);
try {
const manifest = readYamlFileSync(path.join(rootDir, "pnpm-workspace.yaml"));
const pkgJson = readJsonSync(rootDir, "package.json");
const packageGlobs = manifest.packages;
return {
tool: PnpmTool,
packages: expandPackageGlobsSync(packageGlobs, rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${PnpmTool.type} monorepo root: missing pnpm-workspace.yaml and/or package.json`);
throw err;
}
}
};
const RootTool = {
type: "root",
async isMonorepoRoot(_directory) {
return false;
},
isMonorepoRootSync(_directory) {
return false;
},
async getPackages(directory) {
const rootDir = path.resolve(directory);
try {
const pkg = {
dir: rootDir,
relativeDir: ".",
packageJson: await readJson(rootDir, "package.json")
};
return {
tool: RootTool,
packages: [pkg],
rootPackage: pkg,
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${RootTool.type} monorepo root`);
throw err;
}
},
getPackagesSync(directory) {
const rootDir = path.resolve(directory);
try {
const pkg = {
dir: rootDir,
relativeDir: ".",
packageJson: readJsonSync(rootDir, "package.json")
};
return {
tool: RootTool,
packages: [pkg],
rootPackage: pkg,
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${RootTool.type} monorepo root`);
throw err;
}
}
};
const RushTool = {
type: "rush",
async isMonorepoRoot(directory) {
try {
await fsp.access(path.join(directory, "rush.json"), F_OK);
return true;
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
},
isMonorepoRootSync(directory) {
try {
fs.accessSync(path.join(directory, "rush.json"), F_OK);
return true;
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
},
async getPackages(directory) {
const rootDir = path.resolve(directory);
try {
const rushText = await fsp.readFile(path.join(rootDir, "rush.json"), "utf8");
const directories = import_jju.default.parse(rushText).projects.map((project) => path.resolve(rootDir, project.projectFolder));
return {
tool: RushTool,
packages: await Promise.all(directories.map(async (dir) => {
return {
dir,
relativeDir: path.relative(directory, dir),
packageJson: await readJson(dir, "package.json")
};
})),
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${RushTool.type} monorepo root: missing rush.json`);
throw err;
}
},
getPackagesSync(directory) {
const rootDir = path.resolve(directory);
try {
const rushText = fs.readFileSync(path.join(rootDir, "rush.json"), "utf8");
return {
tool: RushTool,
packages: import_jju.default.parse(rushText).projects.map((project) => path.resolve(rootDir, project.projectFolder)).map((dir) => {
const packageJson = readJsonSync(dir, "package.json");
return {
dir,
relativeDir: path.relative(directory, dir),
packageJson
};
}),
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${RushTool.type} monorepo root: missing rush.json`);
throw err;
}
}
};
const YarnTool = {
type: "yarn",
async isMonorepoRoot(directory) {
try {
const [pkgJson] = await Promise.all([readJson(directory, "package.json"), fsp.access(path.join(directory, "yarn.lock"), F_OK)]);
if (pkgJson.workspaces) {
if (Array.isArray(pkgJson.workspaces) || Array.isArray(pkgJson.workspaces.packages)) return true;
}
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
isMonorepoRootSync(directory) {
try {
fs.accessSync(path.join(directory, "yarn.lock"), F_OK);
const pkgJson = readJsonSync(directory, "package.json");
if (pkgJson.workspaces) {
if (Array.isArray(pkgJson.workspaces) || Array.isArray(pkgJson.workspaces.packages)) return true;
}
} catch (err) {
if (err && err.code === "ENOENT") return false;
throw err;
}
return false;
},
async getPackages(directory) {
const rootDir = path.resolve(directory);
try {
const pkgJson = await readJson(rootDir, "package.json");
return {
tool: YarnTool,
packages: await expandPackageGlobs(Array.isArray(pkgJson.workspaces) ? pkgJson.workspaces : pkgJson.workspaces.packages, rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${YarnTool.type} monorepo root`);
throw err;
}
},
getPackagesSync(directory) {
const rootDir = path.resolve(directory);
try {
const pkgJson = readJsonSync(rootDir, "package.json");
return {
tool: YarnTool,
packages: expandPackageGlobsSync(Array.isArray(pkgJson.workspaces) ? pkgJson.workspaces : pkgJson.workspaces.packages, rootDir),
rootPackage: {
dir: rootDir,
relativeDir: ".",
packageJson: pkgJson
},
rootDir
};
} catch (err) {
if (err && err.code === "ENOENT") throw new InvalidMonorepoError(`Directory ${rootDir} is not a valid ${YarnTool.type} monorepo root`);
throw err;
}
}
};
//#endregion
//#region ../../node_modules/.pnpm/@manypkg+find-root@3.1.0/node_modules/@manypkg/find-root/dist/manypkg-find-root.js
/**
* A default ordering for monorepo tool checks.
*
* This ordering is designed to check the most typical package.json-based
* monorepo implementations first, with tools based on custom file schemas
* checked last.
*/
const DEFAULT_TOOLS = [
YarnTool,
PnpmTool,
NpmTool,
BunTool,
LernaTool,
RushTool,
RootTool
];
const isNoEntryError = (err) => !!err && typeof err === "object" && "code" in err && err.code === "ENOENT";
var NoPkgJsonFound = class extends Error {
constructor(directory) {
super(`No package.json could be found upwards from directory ${directory}`);
this.directory = directory;
}
};
var NoMatchingMonorepoFound = class extends Error {
constructor(directory) {
super(`No monorepo matching the list of supported monorepos could be found upwards from directory ${directory}`);
this.directory = directory;
}
};
/**
* Configuration options for `findRoot` and `findRootSync` functions.
*/
/**
* Given a starting folder, search that folder and its parents until a supported monorepo
* is found, and return a `MonorepoRoot` object with the discovered directory and a
* corresponding monorepo `Tool` object.
*
* By default, all predefined `Tool` implementations are included in the search -- the
* caller can provide a list of desired tools to restrict the types of monorepos discovered,
* or to provide a custom tool implementation.
*/
async function findRoot(cwd, options = {}) {
let monorepoRoot;
const tools = options.tools || DEFAULT_TOOLS;
await findUp(async (directory) => {
return Promise.all(tools.map(async (tool) => {
if (await tool.isMonorepoRoot(directory)) return {
tool: tool.type,
rootDir: directory
};
})).then((x) => x.find((value) => value)).then((result) => {
if (result) {
monorepoRoot = result;
return directory;
}
});
}, cwd);
if (monorepoRoot) return monorepoRoot;
if (!tools.includes(RootTool)) throw new NoMatchingMonorepoFound(cwd);
let rootDir = await findUp(async (directory) => {
try {
await fsp.access(path.join(directory, "package.json"));
return directory;
} catch (err) {
if (!isNoEntryError(err)) throw err;
}
}, cwd);
if (!rootDir) throw new NoPkgJsonFound(cwd);
return {
tool: RootTool.type,
rootDir
};
}
async function findUp(matcher, cwd) {
let directory = path.resolve(cwd);
const { root } = path.parse(directory);
while (directory && directory !== root) {
const filePath = await matcher(directory);
if (filePath) return path.resolve(directory, filePath);
directory = path.dirname(directory);
}
}
//#endregion
//#region ../../node_modules/.pnpm/@manypkg+get-packages@3.1.0/node_modules/@manypkg/get-packages/dist/manypkg-get-packages.js
var PackageJsonMissingNameError = class extends Error {
constructor(directories) {
super(`The following package.jsons are missing the "name" field:\n${directories.join("\n")}`);
this.directories = directories;
}
};
/**
* Configuration options for `getPackages` and `getPackagesSync` functions.
*/
/**
* Given a starting folder, search that folder and its parents until a supported monorepo
* is found, and return the collection of packages and a corresponding monorepo `Tool`
* object.
*
* By default, all predefined `Tool` implementations are included in the search -- the
* caller can provide a list of desired tools to restrict the types of monorepos discovered,
* or to provide a custom tool implementation.
*/
async function getPackages(dir, options) {
const monorepoRoot = await findRoot(dir, options);
const tool = (options?.tools || DEFAULT_TOOLS).find((t) => t.type === monorepoRoot.tool);
if (!tool) throw new Error(`Could not find ${monorepoRoot.tool} tool`);
const packages = await tool.getPackages(monorepoRoot.rootDir);
validatePackages(packages);
return packages;
}
function validatePackages(packages) {
const pkgJsonsMissingNameField = [];
for (const pkg of packages.packages) if (!pkg.packageJson.name) pkgJsonsMissingNameField.push(path.join(pkg.relativeDir, "package.json"));
if (pkgJsonsMissingNameField.length > 0) {
pkgJsonsMissingNameField.sort();
throw new PackageJsonMissingNameError(pkgJsonsMissingNameField);
}
}
//#endregion
//#region src/utils/get-emails-directory-metadata.ts
const isFileAnEmail = async (fullPath) => {
let fileHandle;
try {
fileHandle = await fs.promises.open(fullPath, "r");
} catch (exception$1) {
console.warn(exception$1);
return false;
}
if ((await fileHandle.stat()).isDirectory()) {
await fileHandle.close();
return false;
}
const { ext } = path.parse(fullPath);
if (![
".js",
".tsx",
".jsx"
].includes(ext)) {
await fileHandle.close();
return false;
}
const fileContents = await fileHandle.readFile("utf8");
await fileHandle.close();
const hasES6DefaultExport = /\bexport\s+default\b/gm.test(fileContents);
const hasCommonJSExport = /\bmodule\.exports\s*=/gm.test(fileContents);
const hasNamedExport = /\bexport\s+\{[^}]*\bdefault\b[^}]*\}/gm.test(fileContents);
return hasES6DefaultExport || hasCommonJSExport || hasNamedExport;
};
const mergeDirectoriesWithSubDirectories = (emailsDirectoryMetadata) => {
let currentResultingMergedDirectory = emailsDirectoryMetadata;
while (currentResultingMergedDirectory.emailFilenames.length === 0 && currentResultingMergedDirectory.subDirectories.length === 1) {
const onlySubDirectory = currentResultingMergedDirectory.subDirectories[0];
currentResultingMergedDirectory = {
...onlySubDirectory,
directoryName: path.join(currentResultingMergedDirectory.directoryName, onlySubDirectory.directoryName)
};
}
return currentResultingMergedDirectory;
};
const getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory, keepFileExtensions = false, isSubDirectory = false, baseDirectoryPath = absolutePathToEmailsDirectory) => {
if (!fs.existsSync(absolutePathToEmailsDirectory)) return;
const dirents = await fs.promises.readdir(absolutePathToEmailsDirectory, { withFileTypes: true });
const isEmailPredicates = await Promise.all(dirents.map((dirent) => isFileAnEmail(path.join(absolutePathToEmailsDirectory, dirent.name))));
const emailFilenames = dirents.filter((_, i$1) => isEmailPredicates[i$1]).map((dirent) => keepFileExtensions ? dirent.name : dirent.name.replace(path.extname(dirent.name), ""));
const subDirectories = await Promise.all(dirents.filter((dirent) => dirent.isDirectory() && !dirent.name.startsWith("_") && dirent.name !== "static").map((dirent) => {
return getEmailsDirectoryMetadata(path.join(absolutePathToEmailsDirectory, dirent.name), keepFileExtensions, true, baseDirectoryPath);
}));
const emailsMetadata = {
absolutePath: absolutePathToEmailsDirectory,
relativePath: path.relative(baseDirectoryPath, absolutePathToEmailsDirectory),
directoryName: absolutePathToEmailsDirectory.split(path.sep).pop(),
emailFilenames,
subDirectories
};
return isSubDirectory ? mergeDirectoriesWithSubDirectories(emailsMetadata) : emailsMetadata;
};
//#endregion
//#region package.json
var package_default = {
name: "react-email",
version: "5.2.10",
description: "A live preview of your emails right in your browser.",
bin: { "email": "./dist/index.mjs" },
type: "module",
scripts: {
"build": "tsdown",
"build:watch": "tsdown --watch src",
"clean": "rm -rf dist",
"test": "vitest run",
"test:watch": "vitest"
},
license: "MIT",
repository: {
"type": "git",
"url": "https://github.com/resend/react-email.git",
"directory": "packages/react-email"
},
keywords: ["react", "email"],
engines: { "node": ">=20.0.0" },
dependencies: {
"@babel/parser": "catalog:",
"@babel/traverse": "catalog:",
"chokidar": "^4.0.3",
"commander": "catalog:",
"conf": "^15.0.2",
"debounce": "^2.0.0",
"esbuild": "catalog:",
"glob": "^13.0.6",
"jiti": "2.4.2",
"log-symbols": "catalog:",
"mime-types": "^3.0.0",
"normalize-path": "^3.0.0",
"nypm": "catalog:",
"ora": "catalog:",
"prompts": "2.4.2",
"socket.io": "^4.8.1",
"tsconfig-paths": "4.2.0"
},
devDependencies: {
"@react-email/components": "workspace:*",
"@types/babel__core": "catalog:",
"@types/babel__traverse": "catalog:",
"@types/mime-types": "catalog:",
"@types/prompts": "2.4.9",
"next": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
"shlex": "3.0.0",
"tsx": "catalog:",
"typescript": "catalog:"
}
};
//#endregion
//#region src/utils/get-preview-server-location.ts
const ensurePreviewServerInstalled = async (message) => {
if ((await prompts({
type: "confirm",
name: "installPreviewServer",
message,
initial: true
})).installPreviewServer) {
console.log("Installing \"@react-email/preview-server\"");
await addDevDependency(`@react-email/preview-server@${package_default.version}`);
process.exit(0);
} else process.exit(0);
};
const getPreviewServerLocation = async () => {
const usersProject = createJiti(process.cwd());
let previewServerLocation;
try {
previewServerLocation = path.dirname(url.fileURLToPath(usersProject.esmResolve("@react-email/preview-server")));
} catch (_exception) {
await ensurePreviewServerInstalled("To run the preview server, the package \"@react-email/preview-server\" must be installed. Would you like to install it?");
}
const { version: version$1 } = await usersProject.import("@react-email/preview-server");
if (version$1 !== package_default.version) await ensurePreviewServerInstalled(`To run the preview server, the version of "@react-email/preview-server" must match the version of "react-email" (${package_default.version}). Would you like to install it?`);
return previewServerLocation;
};
//#endregion
//#region src/utils/register-spinner-autostopping.ts
const spinners = /* @__PURE__ */ new Set();
process.on("SIGINT", () => {
spinners.forEach((spinner) => {
if (spinner.isSpinning) spinner.stop();
});
});
process.on("exit", (code) => {
if (code !== 0) spinners.forEach((spinner) => {
if (spinner.isSpinning) spinner.stopAndPersist({ symbol: logSymbols.error });
});
});
const registerSpinnerAutostopping = (spinner) => {
spinners.add(spinner);
};
//#endregion
//#region src/commands/build.ts
const isInReactEmailMonorepo = !path.dirname(fileURLToPath(import.meta.url)).includes("node_modules");
const setNextEnvironmentVariablesForBuild = async (emailsDirRelativePath, builtPreviewAppPath, usersProjectLocation) => {
let rootDir = "previewServerLocation";
if (isInReactEmailMonorepo) rootDir = `'${await getPackages(usersProjectLocation).then((p) => p.rootDir.replaceAll("\\", "/"))}'`;
const nextConfigContents = `
import path from 'path';
const emailsDirRelativePath = path.normalize('${emailsDirRelativePath}');
const userProjectLocation = '${process.cwd().replaceAll("\\", "/")}';
const previewServerLocation = '${builtPreviewAppPath.replaceAll("\\", "/")}';
const rootDir = ${rootDir};
/** @type {import('next').NextConfig} */
const nextConfig = {
env: {
NEXT_PUBLIC_IS_BUILDING: 'true',
REACT_EMAIL_INTERNAL_EMAILS_DIR_RELATIVE_PATH: emailsDirRelativePath,
REACT_EMAIL_INTERNAL_EMAILS_DIR_ABSOLUTE_PATH: path.resolve(userProjectLocation, emailsDirRelativePath),
REACT_EMAIL_INTERNAL_PREVIEW_SERVER_LOCATION: previewServerLocation,
REACT_EMAIL_INTERNAL_USER_PROJECT_LOCATION: userProjectLocation
},
turbopack: {
root: rootDir,
},
outputFileTracingRoot: rootDir,
serverExternalPackages: ['esbuild'],
typescript: {
ignoreBuildErrors: true
},
staticPageGenerationTimeout: 600,
}
export default nextConfig`;
await fs.promises.writeFile(path.resolve(builtPreviewAppPath, "./next.config.mjs"), nextConfigContents, "utf8");
};
const getEmailSlugsFromEmailDirectory = (emailDirectory, emailsDirectoryAbsolutePath) => {
const directoryPathRelativeToEmailsDirectory = emailDirectory.absolutePath.replace(emailsDirectoryAbsolutePath, "").trim();
const slugs = [];
for (const filename of emailDirectory.emailFilenames) slugs.push(path.join(directoryPathRelativeToEmailsDirectory, filename).split(path.sep).filter((segment) => segment.length > 0));
for (const directory of emailDirectory.subDirectories) slugs.push(...getEmailSlugsFromEmailDirectory(directory, emailsDirectoryAbsolutePath));
return slugs;
};
const forceSSGForEmailPreviews = async (emailsDirPath, builtPreviewAppPath) => {
const parameters = getEmailSlugsFromEmailDirectory(await getEmailsDirectoryMetadata(emailsDirPath), emailsDirPath).map((slug) => ({ slug }));
const removeForceDynamic = async (filePath) => {
const contents = await fs.promises.readFile(filePath, "utf8");
await fs.promises.writeFile(filePath, contents.replace("export const dynamic = 'force-dynamic';", ""), "utf8");
};
await removeForceDynamic(path.resolve(builtPreviewAppPath, "./src/app/layout.tsx"));
await removeForceDynamic(path.resolve(builtPreviewAppPath, "./src/app/preview/[...slug]/page.tsx"));
await fs.promises.appendFile(path.resolve(builtPreviewAppPath, "./src/app/preview/[...slug]/page.tsx"), `
export function generateStaticParams() {
return Promise.resolve(
${JSON.stringify(parameters)}
);
}`, "utf8");
};
const updatePackageJson = async (builtPreviewAppPath) => {
const packageJsonPath = path.resolve(builtPreviewAppPath, "./package.json");
const packageJson = JSON.parse(await fs.promises.readFile(packageJsonPath, "utf8"));
packageJson.scripts.build = "cross-env NODE_OPTIONS=\"--experimental-vm-modules --disable-warning=ExperimentalWarning\" next build";
packageJson.scripts.start = "cross-env NODE_OPTIONS=\"--experimental-vm-modules --disable-warning=ExperimentalWarning\" next start";
delete packageJson.scripts.postbuild;
packageJson.name = "preview-server";
for (const [dependency, version$1] of Object.entries(packageJson.devDependencies)) packageJson.devDependencies[dependency] = version$1.replace("workspace:", "");
delete packageJson.devDependencies["@react-email/components"];
delete packageJson.scripts.prepare;
await fs.promises.writeFile(packageJsonPath, JSON.stringify(packageJson), "utf8");
};
const build$1 = async ({ dir: emailsDirRelativePath, packageManager }) => {
try {
const usersProjectLocation = process.cwd();
const previewServerLocation = await getPreviewServerLocation();
const spinner = ora({
text: "Starting build process...",
prefixText: " "
}).start();
registerSpinnerAutostopping(spinner);
spinner.text = `Checking if ${emailsDirRelativePath} folder exists`;
if (!fs.existsSync(emailsDirRelativePath)) process.exit(1);
const emailsDirPath = path.join(usersProjectLocation, emailsDirRelativePath);
const staticPath = path.join(emailsDirPath, "static");
const builtPreviewAppPath = path.join(usersProjectLocation, ".react-email");
if (fs.existsSync(builtPreviewAppPath)) {
spinner.text = "Deleting pre-existing `.react-email` folder";
await fs.promises.rm(builtPreviewAppPath, { recursive: true });
}
spinner.text = "Copying preview app from CLI to `.react-email`";
await fs.promises.cp(previewServerLocation, builtPreviewAppPath, {
recursive: true,
filter: (source) => {
const relativeSource = path.relative(previewServerLocation, source);
return !/\.next/.test(relativeSource) && !/\.turbo/.test(relativeSource) && (isInReactEmailMonorepo || !/node_modules/.test(relativeSource));
}
});
if (fs.existsSync(staticPath)) {
spinner.text = "Copying `static` folder into `.react-email/public/static`";
const builtStaticDirectory = path.resolve(builtPreviewAppPath, "./public/static");
await fs.promises.cp(staticPath, builtStaticDirectory, { recursive: true });
}
spinner.text = "Setting Next environment variables for preview app to work properly";
await setNextEnvironmentVariablesForBuild(emailsDirRelativePath, builtPreviewAppPath, usersProjectLocation);
spinner.text = "Setting server side generation for the email preview pages";
await forceSSGForEmailPreviews(emailsDirPath, builtPreviewAppPath);
spinner.text = "Updating package.json's build and start scripts";
await updatePackageJson(builtPreviewAppPath);
if (!isInReactEmailMonorepo) {
spinner.text = "Installing dependencies on `.react-email`";
await installDependencies({
cwd: builtPreviewAppPath,
silent: true,
packageManager
});
}
spinner.stopAndPersist({
text: "Successfully prepared `.react-email` for `next build`",
symbol: logSymbols.success
});
await runScript("build", {
packageManager,
cwd: builtPreviewAppPath
});
} catch (error) {
console.log(error);
process.exit(1);
}
};
//#endregion
//#region src/utils/preview/hot-reloading/get-imported-modules.ts
const traverse = typeof traverseModule === "function" ? traverseModule : traverseModule.default;
const getImportedModules = (contents) => {
const importedPaths = [];
traverse(parse(contents, {
sourceType: "unambiguous",
strictMode: false,
errorRecovery: true,
plugins: [
"jsx",
"typescript",
"decorators"
]
}), {
ImportDeclaration({ node }) {
importedPaths.push(node.source.value);
},
ExportAllDeclaration({ node }) {
importedPaths.push(node.source.value);
},
ExportNamedDeclaration({ node }) {
if (node.source) importedPaths.push(node.source.value);
},
TSExternalModuleReference({ node }) {
importedPaths.push(node.expression.value);
},
CallExpression({ node }) {
if ("name" in node.callee && node.callee.name === "require") {
if (node.arguments.length === 1) {
const importPathNode = node.arguments[0];
if (importPathNode.type === "StringLiteral") importedPaths.push(importPathNode.value);
}
}
}
});
return importedPaths;
};
//#endregion
//#region src/utils/preview/hot-reloading/resolve-path-aliases.ts
const resolvePathAliases = (importPaths, projectPath) => {
const configLoadResult = loadConfig(projectPath);
if (configLoadResult.resultType === "success") {
const matchPath = createMatchPath(configLoadResult.absoluteBaseUrl, configLoadResult.paths);
return importPaths.map((importedPath) => {
const unaliasedPath = matchPath(importedPath, void 0, void 0, [
".tsx",
".ts",
".js",
".jsx",
".cjs",
".mjs"
]);
if (unaliasedPath) return `./${path.relative(projectPath, unaliasedPath)}`;
return importedPath;
});
}
return importPaths;
};
//#endregion
//#region src/utils/preview/hot-reloading/create-dependency-graph.ts
const readAllFilesInsideDirectory = async (directory) => {
let allFilePaths = [];
const topLevelDirents = await promises.readdir(directory, { withFileTypes: true });
for await (const dirent of topLevelDirents) {
const pathToDirent = path.join(directory, dirent.name);
if (dirent.isDirectory()) allFilePaths = allFilePaths.concat(await readAllFilesInsideDirectory(pathToDirent));
else allFilePaths.push(pathToDirent);
}
return allFilePaths;
};
const javascriptExtensions = [
".js",
".ts",
".jsx",
".tsx",
".mjs",
".cjs"
];
const isJavascriptModule = (filePath) => {
const extensionName = path.extname(filePath);
return javascriptExtensions.includes(extensionName);
};
const checkFileExtensionsUntilItExists = (pathWithoutExtension) => {
if (existsSync(`${pathWithoutExtension}.ts`)) return `${pathWithoutExtension}.ts`;
if (existsSync(`${pathWithoutExtension}.tsx`)) return `${pathWithoutExtension}.tsx`;
if (existsSync(`${pathWithoutExtension}.js`)) return `${pathWithoutExtension}.js`;
if (existsSync(`${pathWithoutExtension}.jsx`)) return `${pathWithoutExtension}.jsx`;
if (existsSync(`${pathWithoutExtension}.mjs`)) return `${pathWithoutExtension}.mjs`;
if (existsSync(`${pathWithoutExtension}.cjs`)) return `${pathWithoutExtension}.cjs`;
};
/**
* Creates a stateful dependency graph that is structured in a way that you can get
* the dependents of a module from its path.
*
* Stateful in the sense that it provides a `getter` and an "`updater`". The updater
* will receive changes to the files, that can be perceived through some file watching mechanism,
* so that it doesn't need to recompute the entire dependency graph but only the parts changed.
*/
const createDependencyGraph = async (directory) => {
const modulePaths = (await readAllFilesInsideDirectory(directory)).filter(isJavascriptModule);
const graph = Object.fromEntries(modulePaths.map((path$3) => [path$3, {
path: path$3,
dependencyPaths: [],
dependentPaths: [],
moduleDependencies: []
}]));
const getDependencyPaths = async (filePath) => {
const contents = await promises.readFile(filePath, "utf8");
const importedPathsRelativeToDirectory = (isJavascriptModule(filePath) ? resolvePathAliases(getImportedModules(contents), path.dirname(filePath)) : []).map((dependencyPath) => {
if (!dependencyPath.startsWith(".") || path.isAbsolute(dependencyPath)) return dependencyPath;
let pathToDependencyFromDirectory = path.resolve(path.dirname(filePath), dependencyPath);
let isDirectory = false;
try {
isDirectory = statSync(pathToDependencyFromDirectory).isDirectory();
} catch (_) {}
if (isDirectory) {
const pathWithExtension = checkFileExtensionsUntilItExists(`${pathToDependencyFromDirectory}/index`);
if (pathWithExtension) pathToDependencyFromDirectory = pathWithExtension;
else console.warn(`Could not find index file for directory at ${pathToDependencyFromDirectory}. This is probably going to cause issues with both hot reloading and your code.`);
}
const extension = path.extname(pathToDependencyFromDirectory);
const pathWithEnsuredExtension = (() => {
if (extension.length > 0 && existsSync(pathToDependencyFromDirectory)) return pathToDependencyFromDirectory;
if (javascriptExtensions.includes(extension)) return checkFileExtensionsUntilItExists(pathToDependencyFromDirectory.replace(extension, ""));
return checkFileExtensionsUntilItExists(pathToDependencyFromDirectory);
})();
if (pathWithEnsuredExtension) pathToDependencyFromDirectory = pathWithEnsuredExtension;
else console.warn(`Could not find file at ${pathToDependencyFromDirectory}`);
return pathToDependencyFromDirectory;
});
const moduleDependencies = importedPathsRelativeToDirectory.filter((dependencyPath) => !dependencyPath.startsWith(".") && !path.isAbsolute(dependencyPath));
return {
dependencyPaths: importedPathsRelativeToDirectory.filter((dependencyPath) => dependencyPath.startsWith(".") || path.isAbsolute(dependencyPath)),
moduleDependencies
};
};
const updateModuleDependenciesInGraph = async (moduleFilePath) => {
if (graph[moduleFilePath] === void 0) graph[moduleFilePath] = {
path: moduleFilePath,
dependencyPaths: [],
dependentPaths: [],
moduleDependencies: []
};
const { moduleDependencies, dependencyPaths: newDependencyPaths } = await getDependencyPaths(moduleFilePath);
graph[moduleFilePath].moduleDependencies = moduleDependencies;
for (const dependencyPath of graph[moduleFilePath].dependencyPaths) {
if (newDependencyPaths.includes(dependencyPath)) continue;
const dependencyModule = graph[dependencyPath];
if (dependencyModule !== void 0) dependencyModule.dependentPaths = dependencyModule.dependentPaths.filter((dependentPath) => dependentPath !== moduleFilePath);
}
graph[moduleFilePath].dependencyPaths = newDependencyPaths;
for await (const dependencyPath of newDependencyPaths) {
if (graph[dependencyPath] === void 0) await updateModuleDependenciesInGraph(dependencyPath);
const dependencyModule = graph[dependencyPath];
if (dependencyModule === void 0) throw new Error(`Loading the dependency path ${dependencyPath} did not initialize it at all. This is a bug in React Email.`);
if (!dependencyModule.dependentPaths.includes(moduleFilePath)) dependencyModule.dependentPaths.push(moduleFilePath);
}
};
for (const filePath of modulePaths) await updateModuleDependenciesInGraph(filePath);
const removeModuleFromGraph = (filePath) => {
const module$1 = graph[filePath];
if (module$1) {
for (const dependencyPath of module$1.dependencyPaths) if (graph[dependencyPath]) graph[dependencyPath].dependentPaths = graph[dependencyPath].dependentPaths.filter((dependentPath) => dependentPath !== filePath);
delete graph[filePath];
}
};
return [
graph,
async (event, pathToModified) => {
switch (event) {
case "change":
if (isJavascriptModule(pathToModified)) await updateModuleDependenciesInGraph(pathToModified);
break;
case "add":
if (isJavascriptModule(pathToModified)) await updateModuleDependenciesInGraph(pathToModified);
break;
case "addDir": {
const modulesInsideAddedDirectory = (await readAllFilesInsideDirectory(pathToModified)).filter(isJavascriptModule);
for await (const filePath of modulesInsideAddedDirectory) await updateModuleDependenciesInGraph(filePath);
break;
}
case "unlink":
if (isJavascriptModule(pathToModified)) removeModuleFromGraph(pathToModified);
break;
case "unlinkDir": {
const modulesInsideDeletedDirectory = (await readAllFilesInsideDirectory(pathToModified)).filter(isJavascriptModule);
for await (const filePath of modulesInsideDeletedDirectory) removeModuleFromGraph(filePath);
break;
}
}
},
{ resolveDependentsOf: function resolveDependentsOf(pathToModule) {
const dependentPaths = /* @__PURE__ */ new Set();
const stack = [pathToModule];
while (stack.length > 0) {
const moduleEntry = graph[stack.pop()];
if (!moduleEntry) continue;
for (const dependentPath of moduleEntry.dependentPaths) {
if (dependentPaths.has(dependentPath) || dependentPath === pathToModule) continue;
dependentPaths.add(dependentPath);
stack.push(dependentPath);
}
}
return [...dependentPaths.values()];
} }
];
};
//#endregion
//#region src/utils/preview/hot-reloading/setup-hot-reloading.ts
const setupHotreloading = async (devServer$1, emailDirRelativePath) => {
let clients = [];
new Server(devServer$1).on("connection", (client) => {
clients.push(client);
client.on("disconnect", () => {
clients = clients.filter((item) => item !== client);
});
});
let changes = [];
const reload = debounce(() => {
clients.forEach((client) => {
client.emit("reload", changes.filter((change) => path.resolve(absolutePathToEmailsDirectory, change.filename).startsWith(absolutePathToEmailsDirectory)));
});
changes = [];
}, 150);
const absolutePathToEmailsDirectory = path.resolve(process.cwd(), emailDirRelativePath);
const [dependencyGraph, updateDependencyGraph, { resolveDependentsOf }] = await createDependencyGraph(absolutePathToEmailsDirectory);
const watcher = watch("", {
ignoreInitial: true,
cwd: absolutePathToEmailsDirectory
});
const getFilesOutsideEmailsDirectory = () => Object.keys(dependencyGraph).filter((p) => path.relative(absolutePathToEmailsDirectory, p).startsWith(".."));
let filesOutsideEmailsDirectory = getFilesOutsideEmailsDirectory();
for (const p of filesOutsideEmailsDirectory) watcher.add(p);
const exit = async () => {
await watcher.close();
};
process.on("SIGINT", exit);
process.on("uncaughtException", exit);
watcher.on("all", async (event, relativePathToChangeTarget) => {
if (relativePathToChangeTarget.split(path.sep).length === 0) return;
const pathToChangeTarget = path.resolve(absolutePathToEmailsDirectory, relativePathToChangeTarget);
await updateDependencyGraph(event, pathToChangeTarget);
const newFilesOutsideEmailsDirectory = getFilesOutsideEmailsDirectory();
for (const p of filesOutsideEmailsDirectory) if (!newFilesOutsideEmailsDirectory.includes(p)) watcher.unwatch(p);
for (const p of newFilesOutsideEmailsDirectory) if (!filesOutsideEmailsDirectory.includes(p)) watcher.add(p);
filesOutsideEmailsDirectory = newFilesOutsideEmailsDirectory;
changes.push({
event,
filename: relativePathToChangeTarget
});
for (const dependentPath of resolveDependentsOf(pathToChangeTarget)) changes.push({
event: "change",
filename: path.relative(absolutePathToEmailsDirectory, dependentPath)
});
reload();
});
return watcher;
};
//#endregion
//#region src/utils/conf.ts
const encryptionKey = "h2#x658}1#qY(@!:7,BD1J)q12$[tM25";
const conf = new Conf({
projectName: "react-email",
encryptionKey
});
//#endregion
//#region src/utils/style-text.ts
/**
* Centralized fallback for Node versions (<20.12.0) without util.styleText.
* Returns the original text when styleText is unavailable.
*/
const styleText = nodeUtil.styleText ? nodeUtil.styleText : (_, text) => text;
//#endregion
//#region src/utils/preview/get-env-variables-for-preview-app.ts
const getEnvVariablesForPreviewApp = (relativePathToEmailsDirectory, previewServerLocation, cwd, resendApiKey) => {
return {
REACT_EMAIL_INTERNAL_EMAILS_DIR_RELATIVE_PATH: relativePathToEmailsDirectory,
REACT_EMAIL_INTERNAL_EMAILS_DIR_ABSOLUTE_PATH: path.resolve(cwd, relativePathToEmailsDirectory),
REACT_EMAIL_INTERNAL_PREVIEW_SERVER_LOCATION: previewServerLocation,
REACT_EMAIL_INTERNAL_USER_PROJECT_LOCATION: cwd,
REACT_EMAIL_INTERNAL_RESEND_API_KEY: resendApiKey
};
};
//#endregion
//#region src/utils/preview/serve-static-file.ts
const serveStaticFile = async (res, parsedUrl, staticDirRelativePath) => {
const pathname = parsedUrl.pathname.replace("/static", "./static");
const ext = path.parse(pathname).ext;
const staticBaseDir = path.resolve(process.cwd(), staticDirRelativePath);
const fileAbsolutePath = path.resolve(staticBaseDir, pathname);
if (!fileAbsolutePath.startsWith(staticBaseDir)) {
res.statusCode = 403;
res.end();
return;
}
try {
const fileHandle = await promises.open(fileAbsolutePath, "r");
const fileData = await promises.readFile(fileHandle);
res.setHeader("Content-type", lookup(ext) || "text/plain");
res.end(fileData);
fileHandle.close();
} catch (exception$1) {
if (!existsSync(fileAbsolutePath)) {
res.statusCode = 404;
res.end();
} else {
const sanitizedFilePath = fileAbsolutePath.replace(/\n|\r/g, "");
console.error(`Could not read file at %s to be served, here's the exception:`, sanitizedFilePath, exception$1);
res.statusCode = 500;
res.end("Could not read file to be served! Check your terminal for more information.");
}
}
};
//#endregion
//#region src/utils/preview/start-dev-server.ts
let devServer;
const safeAsyncServerListen = (server, port) => {
return new Promise((resolve$1) => {
server.listen(port, () => {
resolve$1({ portAlreadyInUse: false });
});
server.on("error", (e) => {
if (e.code === "EADDRINUSE") resolve$1({ portAlreadyInUse: true });
});
});
};
const startDevServer = async (emailsDirRelativePath, staticBaseDirRelativePath, port) => {
const [majorNodeVersion] = process.versions.node.split(".");
if (majorNodeVersion && Number.parseInt(majorNodeVersion, 10) < 20) {
console.error(` ${logSymbols.error} Node ${majorNodeVersion} is not supported. Please upgrade to Node 20 or higher.`);
process.exit(1);
}
const previewServerLocation = await getPreviewServerLocation();
const previewServer = createJiti(previewServerLocation);
devServer = http.createServer((req, res) => {
if (!req.url) {
res.end(404);
return;
}
const parsedUrl = url.parse(req.url, true);
res.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store");
res.setHeader("Pragma", "no-cache");
res.setHeader("Expires", "-1");
try {
if (parsedUrl.path?.includes("static/") && !parsedUrl.path.includes("_next/static/")) serveStaticFile(res, parsedUrl, staticBaseDirRelativePath);
else if (!isNextReady) nextReadyPromise.then(() => nextHandleRequest?.(req, res, parsedUrl));
else nextHandleRequest?.(req, res, parsedUrl);
} catch (e) {
console.error("caught error", e);
res.writeHead(500);
res.end();
}
});
const { portAlreadyInUse } = await safeAsyncServerListen(devServer, port);
if (!portAlreadyInUse) {
console.log(styleText("greenBright", ` React Email ${package_default.version}`));
console.log(` Running preview at: http://localhost:${port}\n`);
} else {
const nextPortToTry = port + 1;
console.warn(` ${logSymbols.warning} Port ${port} is already in use, trying ${nextPortToTry}`);
return startDevServer(emailsDirRelativePath, staticBaseDirRelativePath, nextPortToTry);
}
devServer.on("close", async () => {
await app.close();
});
devServer.on("error", (e) => {
spinner.stopAndPersist({
symbol: logSymbols.error,
text: `Preview Server had an error: ${e}`
});
process.exit(1);
});
const spinner = ora({
text: "Getting react-email preview server ready...\n",
prefixText: " "
}).start();
registerSpinnerAutostopping(spinner);
const timeBeforeNextReady = performance.now();
process.env = {
NODE_ENV: "development",
...process.env,
...getEnvVariablesForPreviewApp(path.normalize(emailsDirRelativePath), previewServerLocation, process.cwd(), conf.get("resendApiKey"))
};
if (!process.env.ESBUILD_BINARY_PATH) try {
const esbuild = createJiti(previewServer.esmResolve("esbuild"));
const subpath = process.platform === "win32" ? "esbuild.exe" : "bin/esbuild";
const esbuildBinaryPath = url.fileURLToPath(esbuild.esmResolve(`@esbuild/${process.platform}-${os.arch()}/${subpath}`));
process.env.ESBUILD_BINARY_PATH = esbuildBinaryPath;
} catch (_exception) {}
const app = (await previewServer.import("next", { default: true }))({
dev: false,
conf: { images: { unoptimized: true } },
hostname: "localhost",
port,
dir: previewServerLocation
});
let isNextReady = false;
const nextReadyPromise = app.prepare();
try {
await nextReadyPromise;
} catch (exception$1) {
spinner.stopAndPersist({
symbol: logSymbols.error,
text: ` Preview Server had an error: ${exception$1}`
});
process.exit(1);
}
isNextReady = true;
const nextHandleRequest = app.getRequestHandler();
const secondsToNextReady = ((performance.now() - timeBeforeNextReady) / 1e3).toFixed(1);
spinner.stopAndPersist({
text: `Ready in ${secondsToNextReady}s\n`,
symbol: logSymbols.success
});
return devServer;
};
const makeExitHandler = (options) => (codeSignalOrError) => {
if (typeof devServer !== "undefined") {
console.log("\nshutting down dev server");
devServer.close();
devServer = void 0;
}
if (codeSignalOrError instanceof Error) console.error(codeSignalOrError);
if (options?.shouldKillProcess) process.exit(options.killWithErrorCode ? 1 : 0);
};
process.on("exit", makeExitHandler());
process.on("SIGINT", makeExitHandler({
shouldKillProcess: true,
killWithErrorCode: false
}));
process.on("SIGUSR1", makeExitHandler({
shouldKillProcess: true,
killWithErrorCode: false
}));
process.on("SIGUSR2", makeExitHandler({
shouldKillProcess: true,
killWithErrorCode: false
}));
process.on("uncaughtException", makeExitHandler({
shouldKillProcess: true,
killWithErrorCode: true
}));
//#endregion
//#region src/utils/tree.ts
const SYMBOLS = {
BRANCH: "├── ",
EMPTY: "",
INDENT: " ",
LAST_BRANCH: "└── ",
VERTICAL: "│ "
};
const getTreeLines = async (dirPath, depth, currentDepth = 0) => {
const base = process.cwd();
const dirFullpath = path.resolve(base, dirPath);
let lines = [path.basename(dirFullpath)];
if ((await promises.stat(dirFullpath)).isDirectory() && currentDepth < depth) {
const childDirents = await promises.readdir(dirFullpath, { withFileTypes: true });
childDirents.sort((a, b) => {
if (a.isDirectory() && b.isFile()) return -1;
if (a.isFile() && b.isDirectory()) return 1;
return b.name > a.name ? -1 : 1;
});
for (let i$1 = 0; i$1 < childDirents.length; i$1++) {
const dirent = childDirents[i$1];
const isLast = i$1 === childDirents.length - 1;
const branchingSymbol = isLast ? SYMBOLS.LAST_BRANCH : SYMBOLS.BRANCH;
const verticalSymbol = isLast ? SYMBOLS.INDENT : SYMBOLS.VERTICAL;
if (dirent.isFile()) lines.push(`${branchingSymbol}${dirent.name}`);
else {
const treeLinesForSubDirectory = await getTreeLines(path.join(dirFullpath, dirent.name), depth, currentDepth + 1);
lines = lines.concat(treeLinesForSubDirectory.map((line, index) => index === 0 ? `${branchingSymbol}${line}` : `${verticalSymbol}${line}`));
}
}
}
return lines;
};
const tree = async (dirPath, depth) => {
return (await getTreeLines(dirPath, depth)).join(os.EOL);
};
//#endregion
//#region src/commands/dev.ts
const dev = async ({ dir: emailsDirRelativePath, port }) => {
try {
if (!fs.existsSync(emailsDirRelativePath)) {
console.error(`Missing ${emailsDirRelativePath} folder`);
process.exit(1);
}
await setupHotreloading(await startDevServer(emailsDirRelativePath, emailsDirRelativePath, Number.parseInt(port, 10)), emailsDirRelativePath);
} catch (error) {
console.log(error);
process.exit(1);
}
};
//#endregion
//#region src/utils/esbuild/escape-string-for-regex.ts
function escapeStringForRegex(string) {
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
}
//#endregion
//#region src/utils/esbuild/renderring-utilities-exporter.ts
/**
* Made to export the `render` function out of the user's email template
* so that issues like https://github.com/resend/react-email/issues/649 don't
* happen.
*
* This also exports the `createElement` from the user's React version as well
* to avoid mismatches.
*
* This avoids multiple versions of React being involved, i.e., the version
* in the CLI vs. the version the user has on their emails.
*/
const renderingUtilitiesExporter = (emailTemplates) => ({
name: "rendering-utilities-exporter",
setup: (b) => {
b.onLoad({ filter: new RegExp(emailTemplates.map((emailPath) => escapeStringForRegex(emailPath)).join("|")) }, async ({ path: pathToFile }) => {
return {
contents: `${await promises.readFile(pathToFile, "utf8")};
export { render } from 'react-email-module-that-will-export-render'
export { createElement as reactEmailCreateReactElement } from 'react';
`,
loader: path.extname(pathToFile).slice(1)
};
});
b.onResolve({ filter: /^react-email-module-that-will-export-render$/ }, async (args) => {
const options = {
kind: "import-statement",
importer: args.importer,
resolveDir: args.resolveDir,
namespace: args.namespace
};
let result = await b.resolve("@react-email/render", options);
if (result.errors.length === 0) return result;
result = await b.resolve("@react-email/components", options);
if (result.errors.length > 0 && result.errors[0]) result.errors[0].text = "Failed trying to import `render` from either `@react-email/render` or `@react-email/components` to be able to render your email template.\n Maybe you don't have either of them installed?";
return result;
});
}
});
//#endregion
//#region src/commands/export.ts
const getEmailTemplatesFromDirectory = (emailDirectory) => {
const templatePaths = [];
for (const filename of emailDirectory.emailFilenames) templatePaths.push(path.join(emailDirectory.absolutePath, filename));
for (const directory of emailDirectory.subDirectories) templatePaths.push(...getEmailTemplatesFromDirectory(directory));
return templatePaths;
};
const require$1 = createRequire(url.fileURLToPath(import.meta.url));
const exportTemplates = async (pathToWhereEmailMarkupShouldBeDumped, emailsDirectoryPath, options) => {
if (fs.existsSync(pathToWhereEmailMarkupShouldBeDumped)) fs.rmSync(pathToWhereEmailMarkupShouldBeDumped, { recursive: true });
let spinner;
if (!options.silent) {
spinner = ora("Preparing files...\n").start();
registerSpinnerAutostopping(spinner);
}
const emailsDirectoryMetadata = await getEmailsDirectoryMetadata(path.resolve(process.cwd(), emailsDirectoryPath), true);
if (typeof emailsDirectoryMetadata === "undefined") {
if (spinner) spinner.stopAndPersist({
symbol: logSymbols.error,
text: `Could not find the directory at ${emailsDirectoryPath}`
});
return;
}
const allTemplates = getEmailTemplatesFromDirectory(emailsDirectoryMetadata);
try {
await build({
bundle: true,
entryPoints: allTemplates,
format: "cjs",
jsx: "automatic",
loader: { ".js": "jsx" },
logLevel: "silent",
outExtension: { ".js": ".cjs" },
outdir: pathToWhereEmailMarkupShouldBeDumped,
platform: "node",
plugins: [renderingUtilitiesExporter(allTemplates)],
write: true
});
} catch (exception$1) {
if (spinner) spinner.stopAndPersist({
symbol: logSymbols.error,
text: "Failed to build emails"
});
const buildFailure = exception$1;
console.error(`\n${buildFailure.message}`);
process.exit(1);
}
if (spinner) spinner.succeed();
const allBuiltTemplates = glob.sync(normalize$1(`${pathToWhereEmailMarkupShouldBeDumped}/**/*.cjs`), { absolute: true });
for await (const template of allBuiltTemplates) try {
if (spinner) {
spinner.text = `rendering ${template.split("/").pop()}`;
spinner.render();
}
delete require$1.cache[template];
const emailModule = require$1(template);
const rendered = await emailModule.render(emailModule.reactEmailCreateReactElement(emailModule.default, {}), options);
writeFileSync(template.replace(".cjs", options.plainText ? ".txt" : ".html"), rendered);
unlinkSync(template);
} catch (exception$1) {
if (spinner) spinner.stopAndPersist({
symbol: logSymbols.error,
text: `failed when rendering ${template.split("/").pop()}`
});
console.error(exception$1);
process.exit(1);
}
if (spinner) {
spinner.succeed("Rendered all files");
spinner.text = "Copying static files";
spinner.render();
}
const staticDirectoryPath = path.join(emailsDirectoryPath, "static");
if (fs.existsSync(staticDirectoryPath)) {
const pathToDumpStaticFilesInto = path.join(pathToWhereEmailMarkupShouldBeDumped, "static");
if (fs.existsSync(pathToDumpStaticFilesInto)) await fs.promises.rm(pathToDumpStaticFilesInto, { recursive: true });
try {
await fs.promises.cp(staticDirectoryPath, pathToDumpStaticFilesInto, { recursive: true });
} catch (exception$1) {
console.error(exception$1);
if (spinner) spinner.stopAndPersist({
symbol: logSymbols.error,
text: "Failed to copy static files"
});
console.error(`Something went wrong while copying the file to ${pathToWhereEmailMarkupShouldBeDumped}/static, ${exception$1}`);
process.exit(1);
}
}
if (spinner && !options.silent) {
spinner.succeed();
const fileTree = await tree(pathToWhereEmailMarkupShouldBeDumped, 4);
console.log(fileTree);
spinner.stopAndPersist({
symbol: logSymbols.success,
text: "Successfully exported emails"
});
}
};
//#endregion
//#region src/commands/resend/reset.ts
async function resendReset() {
conf.delete("resendApiKey");
console.info(`${logSymbols.success} Resend API Key successfully deleted`);
}
//#endregion
//#region src/commands/resend/setup.ts
async function resendSetup() {
const previousValue = conf.get("resendApiKey");
if (typeof previousValue === "string" && previousValue.length > 0) console.info(`You already have a Resend API Key configured (${styleText("grey", previousValue.slice(0, 11))}...), continuing will replace it.`);
const { apiKey } = await prompts({
type: "password",
name: "apiKey",
message: "Enter your API Key (make sure it has \"Full Access\")"
});
if (apiKey?.trim().length > 0) {
conf.set("resendApiKey", apiKey);
console.info(`${logSymbols.success} Resend integration successfully set up`);
console.info(`You can always remove it with ${styleText("green", "npx react-email@latest resend reset")}`);
}
}
//#endregion
//#region src/commands/start.ts
const start = async () => {
try {
const previewServerLocation = await getPreviewServerLocation();
const usersProjectLocation = process.cwd();
const builtPreviewPath = path.resolve(usersProjectLocation, "./.react-email");
if (!fs.existsSync(builtPreviewPath)) {
console.error("Could not find .react-email, maybe you haven't ran email build?");
process.exit(1);
}
const nextStart = spawn("npx", [
"next",
"start",
builtPreviewPath
], {
cwd: previewServerLocation,
stdio: "inherit"
});
process.on("SIGINT", () => {
nextStart.kill("SIGINT");
});
nextStart.on("exit", (code) => {
process.exit(code ?? 0);
});
} catch (error) {
console.log(error);
process.exit(1);
}
};
//#endregion
//#region src/index.ts
const requiredFlags = ["--experimental-vm-modules", "--disable-warning=ExperimentalWarning"];
if (!requiredFlags.every((flag) => process.execArgv.includes(flag))) spawn(process.execPath, [
...requiredFlags,
...process.execArgv,
process.argv[1] ?? "",
...process.argv.slice(2)
], { stdio: "inherit" }).on("exit", (code) => {
process.exit(code ?? 0);
});
else {
program.name("react-email").description("A live preview of your emails right in your browser").version(package_default.version);
program.command("dev").description("Starts the preview email development app").option("-d, --dir <path>", "Directory with your email templates", "./emails").option("-p --port <port>", "Port to run dev server on", "3000").action(dev);
program.command("build").description("Copies the preview app for onto .react-email and builds it").option("-d, --dir <path>", "Directory with your email templates", "./emails").option("-p --packageManager <name>", "Package name to use on installation on `.react-email`", "npm").action(build$1);
program.command("start").description("Runs the built preview app that is inside of \".react-email\"").action(start);
program.command("export").description("Build the templates to the `out` directory").option("--outDir <path>", "Output directory", "out").option("-p, --pretty", "Pretty print the output", false).option("-t, --plainText", "Set output format as plain text", false).option("-d, --dir <path>", "Directory with your email templates", "./emails").option("-s, --silent", "To, or not to show a spinner with process information", false).action(({ outDir, pretty, plainText, silent, dir: srcDir }) => exportTemplates(outDir, srcDir, {
silent,
plainText,
pretty
}));
const resend = program.command("resend");
resend.command("setup").description("Sets up the integration between the React Email CLI, and your Resend account through an API Key").action(resendSetup);
resend.command("reset").description("Deletes your API Key from the React Email configuration").action(resendReset);
program.parse();
}
//#endregion
export { };