From 02f7e963624e7fa0b969d4701f90aedeec071a4e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 21 Aug 2021 07:09:43 -0700 Subject: [PATCH 1/4] tools: fix markdown linting This updates remark-preset-lint-node to 3.0.1, which actually works unlike the 3.0.0 version we're using. (Sorry about 3.0.0 not actually linting!) It also updates rollup and the rollup config. So this uses the latest everything as of this writing. --- tools/lint-md.js | 100790 +++++++-------- .../node-lint-md-cli-rollup/package-lock.json | 3854 +- .../node-lint-md-cli-rollup/rollup.config.js | 18 +- 3 files changed, 48677 insertions(+), 55985 deletions(-) diff --git a/tools/lint-md.js b/tools/lint-md.js index 1f865ab809a942..b7109dc74ef200 100644 --- a/tools/lint-md.js +++ b/tools/lint-md.js @@ -3,16 +3,22 @@ // Don't change this file manually, // it is generated from tools/node-lint-md-cli-rollup -var require$$0$a = require('stream'); -var require$$0$7 = require('path'); -var require$$0$5 = require('util'); -var require$$0$6 = require('os'); -var require$$1 = require('tty'); -var require$$0$8 = require('fs'); -var require$$1$1 = require('module'); -var require$$0$9 = require('events'); -var require$$5$2 = require('assert'); +var path$b = require('path'); +var require$$0$3 = require('fs'); var url = require('url'); +var process$2 = require('node:process'); +var stream = require('node:stream'); +var require$$0$2 = require('os'); +var tty$1 = require('tty'); +var require$$0$5 = require('events'); +var require$$0$4 = require('util'); +var require$$1 = require('stream'); +var path$c = require('node:path'); +var node_url = require('node:url'); +var assert$2 = require('assert'); +var fs$a = require('node:fs'); +var node_events = require('node:events'); +var process$1 = require('process'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } @@ -36,15 +42,19 @@ function _interopNamespace(e) { return Object.freeze(n); } -var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$a); -var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7); -var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$5); -var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6); +var path__default = /*#__PURE__*/_interopDefaultLegacy(path$b); +var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3); +var process__default$1 = /*#__PURE__*/_interopDefaultLegacy(process$2); +var stream__default = /*#__PURE__*/_interopDefaultLegacy(stream); +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$2); +var tty__default = /*#__PURE__*/_interopDefaultLegacy(tty$1); +var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5); +var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4); var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); -var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8); -var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1); -var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9); -var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5$2); +var path__default$1 = /*#__PURE__*/_interopDefaultLegacy(path$c); +var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$2); +var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$a); +var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1); var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -67,54492 +77,48223 @@ function commonjsRequire (path) { throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } -var cliEntry = {}; - -var vfileStatistics = statistics$2; - -// Get stats for a file, list of files, or list of messages. -function statistics$2(files) { - var result = {true: 0, false: 0, null: 0}; - - count(files); - - return { - fatal: result.true, - nonfatal: result.false + result.null, - warn: result.false, - info: result.null, - total: result.true + result.false + result.null - } +var ansiStyles$2 = {exports: {}}; - function count(value) { - if (value) { - if (value[0] && value[0].messages) { - // Multiple vfiles - countInAll(value); - } else { - // One vfile / messages - countAll(value.messages || value); - } - } - } +var colorName$1 = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; - function countInAll(files) { - var length = files.length; - var index = -1; +/* MIT license */ - while (++index < length) { - count(files[index].messages); - } - } +/* eslint-disable no-mixed-operators */ +const cssKeywords$1 = colorName$1; - function countAll(messages) { - var length = messages.length; - var index = -1; - var fatal; +// NOTE: conversions should only return primitive values (i.e. arrays, or +// values that give correct `typeof` results). +// do not use box values types (i.e. Number(), String(), etc.) - while (++index < length) { - fatal = messages[index].fatal; - result[fatal === null || fatal === undefined ? null : Boolean(fatal)]++; - } - } +const reverseKeywords$1 = {}; +for (const key of Object.keys(cssKeywords$1)) { + reverseKeywords$1[cssKeywords$1[key]] = key; } -var slice$4 = [].slice; - -var wrap_1 = wrap$3; - -// Wrap `fn`. -// Can be sync or async; return a promise, receive a completion handler, return -// new values and errors. -function wrap$3(fn, callback) { - var invoked; - - return wrapped - - function wrapped() { - var params = slice$4.call(arguments, 0); - var callback = fn.length > params.length; - var result; - - if (callback) { - params.push(done); - } - - try { - result = fn.apply(null, params); - } catch (error) { - // Well, this is quite the pickle. - // `fn` received a callback and invoked it (thus continuing the pipeline), - // but later also threw an error. - // We’re not about to restart the pipeline again, so the only thing left - // to do is to throw the thing instead. - if (callback && invoked) { - throw error - } +const convert$4 = { + rgb: {channels: 3, labels: 'rgb'}, + hsl: {channels: 3, labels: 'hsl'}, + hsv: {channels: 3, labels: 'hsv'}, + hwb: {channels: 3, labels: 'hwb'}, + cmyk: {channels: 4, labels: 'cmyk'}, + xyz: {channels: 3, labels: 'xyz'}, + lab: {channels: 3, labels: 'lab'}, + lch: {channels: 3, labels: 'lch'}, + hex: {channels: 1, labels: ['hex']}, + keyword: {channels: 1, labels: ['keyword']}, + ansi16: {channels: 1, labels: ['ansi16']}, + ansi256: {channels: 1, labels: ['ansi256']}, + hcg: {channels: 3, labels: ['h', 'c', 'g']}, + apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, + gray: {channels: 1, labels: ['gray']} +}; - return done(error) - } +var conversions$5 = convert$4; - if (!callback) { - if (result && typeof result.then === 'function') { - result.then(then, done); - } else if (result instanceof Error) { - done(result); - } else { - then(result); - } - } - } +// Hide .channels and .labels properties +for (const model of Object.keys(convert$4)) { + if (!('channels' in convert$4[model])) { + throw new Error('missing channels property: ' + model); + } - // Invoke `next`, only once. - function done() { - if (!invoked) { - invoked = true; + if (!('labels' in convert$4[model])) { + throw new Error('missing channel labels property: ' + model); + } - callback.apply(null, arguments); - } - } + if (convert$4[model].labels.length !== convert$4[model].channels) { + throw new Error('channel and label counts mismatch: ' + model); + } - // Invoke `done` with one value. - // Tracks if an error is passed, too. - function then(value) { - done(null, value); - } + const {channels, labels} = convert$4[model]; + delete convert$4[model].channels; + delete convert$4[model].labels; + Object.defineProperty(convert$4[model], 'channels', {value: channels}); + Object.defineProperty(convert$4[model], 'labels', {value: labels}); } -var wrap$2 = wrap_1; - -var trough_1 = trough$4; - -trough$4.wrap = wrap$2; +convert$4.rgb.hsl = function (rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const min = Math.min(r, g, b); + const max = Math.max(r, g, b); + const delta = max - min; + let h; + let s; -var slice$3 = [].slice; + if (max === min) { + h = 0; + } else if (r === max) { + h = (g - b) / delta; + } else if (g === max) { + h = 2 + (b - r) / delta; + } else if (b === max) { + h = 4 + (r - g) / delta; + } -// Create new middleware. -function trough$4() { - var fns = []; - var middleware = {}; + h = Math.min(h * 60, 360); - middleware.run = run; - middleware.use = use; + if (h < 0) { + h += 360; + } - return middleware + const l = (min + max) / 2; - // Run `fns`. Last argument must be a completion handler. - function run() { - var index = -1; - var input = slice$3.call(arguments, 0, -1); - var done = arguments[arguments.length - 1]; + if (max === min) { + s = 0; + } else if (l <= 0.5) { + s = delta / (max + min); + } else { + s = delta / (2 - max - min); + } - if (typeof done !== 'function') { - throw new Error('Expected function as last argument, not ' + done) - } + return [h, s * 100, l * 100]; +}; - next.apply(null, [null].concat(input)); +convert$4.rgb.hsv = function (rgb) { + let rdif; + let gdif; + let bdif; + let h; + let s; - // Run the next `fn`, if any. - function next(err) { - var fn = fns[++index]; - var params = slice$3.call(arguments, 0); - var values = params.slice(1); - var length = input.length; - var pos = -1; + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const v = Math.max(r, g, b); + const diff = v - Math.min(r, g, b); + const diffc = function (c) { + return (v - c) / 6 / diff + 1 / 2; + }; - if (err) { - done(err); - return - } + if (diff === 0) { + h = 0; + s = 0; + } else { + s = diff / v; + rdif = diffc(r); + gdif = diffc(g); + bdif = diffc(b); - // Copy non-nully input into values. - while (++pos < length) { - if (values[pos] === null || values[pos] === undefined) { - values[pos] = input[pos]; - } - } + if (r === v) { + h = bdif - gdif; + } else if (g === v) { + h = (1 / 3) + rdif - bdif; + } else if (b === v) { + h = (2 / 3) + gdif - rdif; + } - input = values; + if (h < 0) { + h += 1; + } else if (h > 1) { + h -= 1; + } + } - // Next or done. - if (fn) { - wrap$2(fn, next).apply(null, input); - } else { - done.apply(null, [null].concat(input)); - } - } - } + return [ + h * 360, + s * 100, + v * 100 + ]; +}; - // Add `fn` to the list. - function use(fn) { - if (typeof fn !== 'function') { - throw new Error('Expected `fn` to be a function, not ' + fn) - } +convert$4.rgb.hwb = function (rgb) { + const r = rgb[0]; + const g = rgb[1]; + let b = rgb[2]; + const h = convert$4.rgb.hsl(rgb)[0]; + const w = 1 / 255 * Math.min(r, Math.min(g, b)); - fns.push(fn); + b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); - return middleware - } -} + return [h, w * 100, b * 100]; +}; -var jsYaml$2 = {}; +convert$4.rgb.cmyk = function (rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; -var loader$2 = {}; + const k = Math.min(1 - r, 1 - g, 1 - b); + const c = (1 - r - k) / (1 - k) || 0; + const m = (1 - g - k) / (1 - k) || 0; + const y = (1 - b - k) / (1 - k) || 0; -var common$b = {}; + return [c * 100, m * 100, y * 100, k * 100]; +}; -function isNothing$1(subject) { - return (typeof subject === 'undefined') || (subject === null); +function comparativeDistance$1(x, y) { + /* + See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance + */ + return ( + ((x[0] - y[0]) ** 2) + + ((x[1] - y[1]) ** 2) + + ((x[2] - y[2]) ** 2) + ); } +convert$4.rgb.keyword = function (rgb) { + const reversed = reverseKeywords$1[rgb]; + if (reversed) { + return reversed; + } -function isObject$4(subject) { - return (typeof subject === 'object') && (subject !== null); -} + let currentClosestDistance = Infinity; + let currentClosestKeyword; + for (const keyword of Object.keys(cssKeywords$1)) { + const value = cssKeywords$1[keyword]; -function toArray$1(sequence) { - if (Array.isArray(sequence)) return sequence; - else if (isNothing$1(sequence)) return []; + // Compute comparative distance + const distance = comparativeDistance$1(rgb, value); - return [ sequence ]; -} + // Check if its less, if so set as closest + if (distance < currentClosestDistance) { + currentClosestDistance = distance; + currentClosestKeyword = keyword; + } + } + return currentClosestKeyword; +}; -function extend$4(target, source) { - var index, length, key, sourceKeys; +convert$4.keyword.rgb = function (keyword) { + return cssKeywords$1[keyword]; +}; - if (source) { - sourceKeys = Object.keys(source); +convert$4.rgb.xyz = function (rgb) { + let r = rgb[0] / 255; + let g = rgb[1] / 255; + let b = rgb[2] / 255; - for (index = 0, length = sourceKeys.length; index < length; index += 1) { - key = sourceKeys[index]; - target[key] = source[key]; - } - } + // Assume sRGB + r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92); + g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92); + b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92); - return target; -} + const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); + const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); + const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); + return [x * 100, y * 100, z * 100]; +}; -function repeat$8(string, count) { - var result = '', cycle; +convert$4.rgb.lab = function (rgb) { + const xyz = convert$4.rgb.xyz(rgb); + let x = xyz[0]; + let y = xyz[1]; + let z = xyz[2]; - for (cycle = 0; cycle < count; cycle += 1) { - result += string; - } + x /= 95.047; + y /= 100; + z /= 108.883; - return result; -} + x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); + const l = (116 * y) - 16; + const a = 500 * (x - y); + const b = 200 * (y - z); -function isNegativeZero$1(number) { - return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); -} + return [l, a, b]; +}; +convert$4.hsl.rgb = function (hsl) { + const h = hsl[0] / 360; + const s = hsl[1] / 100; + const l = hsl[2] / 100; + let t2; + let t3; + let val; -common$b.isNothing = isNothing$1; -common$b.isObject = isObject$4; -common$b.toArray = toArray$1; -common$b.repeat = repeat$8; -common$b.isNegativeZero = isNegativeZero$1; -common$b.extend = extend$4; + if (s === 0) { + val = l * 255; + return [val, val, val]; + } -function YAMLException$6(reason, mark) { - // Super constructor - Error.call(this); + if (l < 0.5) { + t2 = l * (1 + s); + } else { + t2 = l + s - l * s; + } - this.name = 'YAMLException'; - this.reason = reason; - this.mark = mark; - this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : ''); + const t1 = 2 * l - t2; - // Include stack trace in error object - if (Error.captureStackTrace) { - // Chrome and NodeJS - Error.captureStackTrace(this, this.constructor); - } else { - // FF, IE 10+ and Safari 6+. Fallback for others - this.stack = (new Error()).stack || ''; - } -} + const rgb = [0, 0, 0]; + for (let i = 0; i < 3; i++) { + t3 = h + 1 / 3 * -(i - 1); + if (t3 < 0) { + t3++; + } + if (t3 > 1) { + t3--; + } -// Inherit from Error -YAMLException$6.prototype = Object.create(Error.prototype); -YAMLException$6.prototype.constructor = YAMLException$6; + if (6 * t3 < 1) { + val = t1 + (t2 - t1) * 6 * t3; + } else if (2 * t3 < 1) { + val = t2; + } else if (3 * t3 < 2) { + val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; + } else { + val = t1; + } + rgb[i] = val * 255; + } -YAMLException$6.prototype.toString = function toString(compact) { - var result = this.name + ': '; + return rgb; +}; - result += this.reason || '(unknown reason)'; +convert$4.hsl.hsv = function (hsl) { + const h = hsl[0]; + let s = hsl[1] / 100; + let l = hsl[2] / 100; + let smin = s; + const lmin = Math.max(l, 0.01); - if (!compact && this.mark) { - result += ' ' + this.mark.toString(); - } + l *= 2; + s *= (l <= 1) ? l : 2 - l; + smin *= lmin <= 1 ? lmin : 2 - lmin; + const v = (l + s) / 2; + const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); - return result; + return [h, sv * 100, v * 100]; }; +convert$4.hsv.rgb = function (hsv) { + const h = hsv[0] / 60; + const s = hsv[1] / 100; + let v = hsv[2] / 100; + const hi = Math.floor(h) % 6; -var exception$1 = YAMLException$6; - -var common$a = common$b; - + const f = h - Math.floor(h); + const p = 255 * v * (1 - s); + const q = 255 * v * (1 - (s * f)); + const t = 255 * v * (1 - (s * (1 - f))); + v *= 255; -function Mark$1(name, buffer, position, line, column) { - this.name = name; - this.buffer = buffer; - this.position = position; - this.line = line; - this.column = column; -} + switch (hi) { + case 0: + return [v, t, p]; + case 1: + return [q, v, p]; + case 2: + return [p, v, t]; + case 3: + return [p, q, v]; + case 4: + return [t, p, v]; + case 5: + return [v, p, q]; + } +}; +convert$4.hsv.hsl = function (hsv) { + const h = hsv[0]; + const s = hsv[1] / 100; + const v = hsv[2] / 100; + const vmin = Math.max(v, 0.01); + let sl; + let l; -Mark$1.prototype.getSnippet = function getSnippet(indent, maxLength) { - var head, start, tail, end, snippet; + l = (2 - s) * v; + const lmin = (2 - s) * vmin; + sl = s * vmin; + sl /= (lmin <= 1) ? lmin : 2 - lmin; + sl = sl || 0; + l /= 2; - if (!this.buffer) return null; + return [h, sl * 100, l * 100]; +}; - indent = indent || 4; - maxLength = maxLength || 75; +// http://dev.w3.org/csswg/css-color/#hwb-to-rgb +convert$4.hwb.rgb = function (hwb) { + const h = hwb[0] / 360; + let wh = hwb[1] / 100; + let bl = hwb[2] / 100; + const ratio = wh + bl; + let f; - head = ''; - start = this.position; + // Wh + bl cant be > 1 + if (ratio > 1) { + wh /= ratio; + bl /= ratio; + } - while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) { - start -= 1; - if (this.position - start > (maxLength / 2 - 1)) { - head = ' ... '; - start += 5; - break; - } - } + const i = Math.floor(6 * h); + const v = 1 - bl; + f = 6 * h - i; - tail = ''; - end = this.position; + if ((i & 0x01) !== 0) { + f = 1 - f; + } - while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) { - end += 1; - if (end - this.position > (maxLength / 2 - 1)) { - tail = ' ... '; - end -= 5; - break; - } - } + const n = wh + f * (v - wh); // Linear interpolation - snippet = this.buffer.slice(start, end); + let r; + let g; + let b; + /* eslint-disable max-statements-per-line,no-multi-spaces */ + switch (i) { + default: + case 6: + case 0: r = v; g = n; b = wh; break; + case 1: r = n; g = v; b = wh; break; + case 2: r = wh; g = v; b = n; break; + case 3: r = wh; g = n; b = v; break; + case 4: r = n; g = wh; b = v; break; + case 5: r = v; g = wh; b = n; break; + } + /* eslint-enable max-statements-per-line,no-multi-spaces */ - return common$a.repeat(' ', indent) + head + snippet + tail + '\n' + - common$a.repeat(' ', indent + this.position - start + head.length) + '^'; + return [r * 255, g * 255, b * 255]; }; +convert$4.cmyk.rgb = function (cmyk) { + const c = cmyk[0] / 100; + const m = cmyk[1] / 100; + const y = cmyk[2] / 100; + const k = cmyk[3] / 100; -Mark$1.prototype.toString = function toString(compact) { - var snippet, where = ''; + const r = 1 - Math.min(1, c * (1 - k) + k); + const g = 1 - Math.min(1, m * (1 - k) + k); + const b = 1 - Math.min(1, y * (1 - k) + k); - if (this.name) { - where += 'in "' + this.name + '" '; - } + return [r * 255, g * 255, b * 255]; +}; - where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1); +convert$4.xyz.rgb = function (xyz) { + const x = xyz[0] / 100; + const y = xyz[1] / 100; + const z = xyz[2] / 100; + let r; + let g; + let b; - if (!compact) { - snippet = this.getSnippet(); + r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); + g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); + b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); - if (snippet) { - where += ':\n' + snippet; - } - } + // Assume sRGB + r = r > 0.0031308 + ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055) + : r * 12.92; - return where; -}; + g = g > 0.0031308 + ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055) + : g * 12.92; + b = b > 0.0031308 + ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055) + : b * 12.92; -var mark$1 = Mark$1; + r = Math.min(Math.max(0, r), 1); + g = Math.min(Math.max(0, g), 1); + b = Math.min(Math.max(0, b), 1); -var YAMLException$5 = exception$1; + return [r * 255, g * 255, b * 255]; +}; -var TYPE_CONSTRUCTOR_OPTIONS$1 = [ - 'kind', - 'resolve', - 'construct', - 'instanceOf', - 'predicate', - 'represent', - 'defaultStyle', - 'styleAliases' -]; +convert$4.xyz.lab = function (xyz) { + let x = xyz[0]; + let y = xyz[1]; + let z = xyz[2]; -var YAML_NODE_KINDS$1 = [ - 'scalar', - 'sequence', - 'mapping' -]; + x /= 95.047; + y /= 100; + z /= 108.883; -function compileStyleAliases$1(map) { - var result = {}; + x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); - if (map !== null) { - Object.keys(map).forEach(function (style) { - map[style].forEach(function (alias) { - result[String(alias)] = style; - }); - }); - } + const l = (116 * y) - 16; + const a = 500 * (x - y); + const b = 200 * (y - z); - return result; -} + return [l, a, b]; +}; -function Type$j(tag, options) { - options = options || {}; +convert$4.lab.xyz = function (lab) { + const l = lab[0]; + const a = lab[1]; + const b = lab[2]; + let x; + let y; + let z; - Object.keys(options).forEach(function (name) { - if (TYPE_CONSTRUCTOR_OPTIONS$1.indexOf(name) === -1) { - throw new YAMLException$5('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); - } - }); + y = (l + 16) / 116; + x = a / 500 + y; + z = y - b / 200; - // TODO: Add tag format check. - 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.defaultStyle = options['defaultStyle'] || null; - this.styleAliases = compileStyleAliases$1(options['styleAliases'] || null); + const y2 = y ** 3; + const x2 = x ** 3; + const z2 = z ** 3; + y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; + x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; + z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; - if (YAML_NODE_KINDS$1.indexOf(this.kind) === -1) { - throw new YAMLException$5('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); - } -} + x *= 95.047; + y *= 100; + z *= 108.883; -var type$1 = Type$j; + return [x, y, z]; +}; -/*eslint-disable max-len*/ +convert$4.lab.lch = function (lab) { + const l = lab[0]; + const a = lab[1]; + const b = lab[2]; + let h; -var common$9 = common$b; -var YAMLException$4 = exception$1; -var Type$i = type$1; + const hr = Math.atan2(b, a); + h = hr * 360 / 2 / Math.PI; + if (h < 0) { + h += 360; + } -function compileList$1(schema, name, result) { - var exclude = []; + const c = Math.sqrt(a * a + b * b); - schema.include.forEach(function (includedSchema) { - result = compileList$1(includedSchema, name, result); - }); + return [l, c, h]; +}; - schema[name].forEach(function (currentType) { - result.forEach(function (previousType, previousIndex) { - if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) { - exclude.push(previousIndex); - } - }); +convert$4.lch.lab = function (lch) { + const l = lch[0]; + const c = lch[1]; + const h = lch[2]; - result.push(currentType); - }); + const hr = h / 360 * 2 * Math.PI; + const a = c * Math.cos(hr); + const b = c * Math.sin(hr); - return result.filter(function (type, index) { - return exclude.indexOf(index) === -1; - }); -} + return [l, a, b]; +}; +convert$4.rgb.ansi16 = function (args, saturation = null) { + const [r, g, b] = args; + let value = saturation === null ? convert$4.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization -function compileMap$1(/* lists... */) { - var result = { - scalar: {}, - sequence: {}, - mapping: {}, - fallback: {} - }, index, length; + value = Math.round(value / 50); - function collectType(type) { - result[type.kind][type.tag] = result['fallback'][type.tag] = type; - } + if (value === 0) { + return 30; + } - for (index = 0, length = arguments.length; index < length; index += 1) { - arguments[index].forEach(collectType); - } - return result; -} + let ansi = 30 + + ((Math.round(b / 255) << 2) + | (Math.round(g / 255) << 1) + | Math.round(r / 255)); + if (value === 2) { + ansi += 60; + } -function Schema$7(definition) { - this.include = definition.include || []; - this.implicit = definition.implicit || []; - this.explicit = definition.explicit || []; + return ansi; +}; - this.implicit.forEach(function (type) { - if (type.loadKind && type.loadKind !== 'scalar') { - throw new YAMLException$4('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); - } - }); +convert$4.hsv.ansi16 = function (args) { + // Optimization here; we already know the value and don't need to get + // it converted for us. + return convert$4.rgb.ansi16(convert$4.hsv.rgb(args), args[2]); +}; - this.compiledImplicit = compileList$1(this, 'implicit', []); - this.compiledExplicit = compileList$1(this, 'explicit', []); - this.compiledTypeMap = compileMap$1(this.compiledImplicit, this.compiledExplicit); -} +convert$4.rgb.ansi256 = function (args) { + const r = args[0]; + const g = args[1]; + const b = args[2]; + // We use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r === g && g === b) { + if (r < 8) { + return 16; + } -Schema$7.DEFAULT = null; + if (r > 248) { + return 231; + } + return Math.round(((r - 8) / 247) * 24) + 232; + } -Schema$7.create = function createSchema() { - var schemas, types; + const ansi = 16 + + (36 * Math.round(r / 255 * 5)) + + (6 * Math.round(g / 255 * 5)) + + Math.round(b / 255 * 5); - switch (arguments.length) { - case 1: - schemas = Schema$7.DEFAULT; - types = arguments[0]; - break; + return ansi; +}; - case 2: - schemas = arguments[0]; - types = arguments[1]; - break; +convert$4.ansi16.rgb = function (args) { + let color = args % 10; - default: - throw new YAMLException$4('Wrong number of arguments for Schema.create function'); - } + // Handle greyscale + if (color === 0 || color === 7) { + if (args > 50) { + color += 3.5; + } - schemas = common$9.toArray(schemas); - types = common$9.toArray(types); + color = color / 10.5 * 255; - if (!schemas.every(function (schema) { return schema instanceof Schema$7; })) { - throw new YAMLException$4('Specified list of super schemas (or a single Schema object) contains a non-Schema object.'); - } + return [color, color, color]; + } - if (!types.every(function (type) { return type instanceof Type$i; })) { - throw new YAMLException$4('Specified list of YAML types (or a single Type object) contains a non-Type object.'); - } + const mult = (~~(args > 50) + 1) * 0.5; + const r = ((color & 1) * mult) * 255; + const g = (((color >> 1) & 1) * mult) * 255; + const b = (((color >> 2) & 1) * mult) * 255; - return new Schema$7({ - include: schemas, - explicit: types - }); + return [r, g, b]; }; +convert$4.ansi256.rgb = function (args) { + // Handle greyscale + if (args >= 232) { + const c = (args - 232) * 10 + 8; + return [c, c, c]; + } -var schema$2 = Schema$7; + args -= 16; -var Type$h = type$1; + let rem; + const r = Math.floor(args / 36) / 5 * 255; + const g = Math.floor((rem = args % 36) / 6) / 5 * 255; + const b = (rem % 6) / 5 * 255; -var str$1 = new Type$h('tag:yaml.org,2002:str', { - kind: 'scalar', - construct: function (data) { return data !== null ? data : ''; } -}); + return [r, g, b]; +}; -var Type$g = type$1; +convert$4.rgb.hex = function (args) { + const integer = ((Math.round(args[0]) & 0xFF) << 16) + + ((Math.round(args[1]) & 0xFF) << 8) + + (Math.round(args[2]) & 0xFF); -var seq$1 = new Type$g('tag:yaml.org,2002:seq', { - kind: 'sequence', - construct: function (data) { return data !== null ? data : []; } -}); + const string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; -var Type$f = type$1; +convert$4.hex.rgb = function (args) { + const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); + if (!match) { + return [0, 0, 0]; + } -var map$7 = new Type$f('tag:yaml.org,2002:map', { - kind: 'mapping', - construct: function (data) { return data !== null ? data : {}; } -}); + let colorString = match[0]; -var Schema$6 = schema$2; + if (match[0].length === 3) { + colorString = colorString.split('').map(char => { + return char + char; + }).join(''); + } + const integer = parseInt(colorString, 16); + const r = (integer >> 16) & 0xFF; + const g = (integer >> 8) & 0xFF; + const b = integer & 0xFF; -var failsafe$1 = new Schema$6({ - explicit: [ - str$1, - seq$1, - map$7 - ] -}); + return [r, g, b]; +}; -var Type$e = type$1; +convert$4.rgb.hcg = function (rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const max = Math.max(Math.max(r, g), b); + const min = Math.min(Math.min(r, g), b); + const chroma = (max - min); + let grayscale; + let hue; -function resolveYamlNull$1(data) { - if (data === null) return true; + if (chroma < 1) { + grayscale = min / (1 - chroma); + } else { + grayscale = 0; + } - var max = data.length; + if (chroma <= 0) { + hue = 0; + } else + if (max === r) { + hue = ((g - b) / chroma) % 6; + } else + if (max === g) { + hue = 2 + (b - r) / chroma; + } else { + hue = 4 + (r - g) / chroma; + } - return (max === 1 && data === '~') || - (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); -} + hue /= 6; + hue %= 1; -function constructYamlNull$1() { - return null; -} + return [hue * 360, chroma * 100, grayscale * 100]; +}; -function isNull$1(object) { - return object === null; -} +convert$4.hsl.hcg = function (hsl) { + const s = hsl[1] / 100; + const l = hsl[2] / 100; -var _null$1 = new Type$e('tag:yaml.org,2002:null', { - kind: 'scalar', - resolve: resolveYamlNull$1, - construct: constructYamlNull$1, - predicate: isNull$1, - represent: { - canonical: function () { return '~'; }, - lowercase: function () { return 'null'; }, - uppercase: function () { return 'NULL'; }, - camelcase: function () { return 'Null'; } - }, - defaultStyle: 'lowercase' -}); + const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l)); -var Type$d = type$1; + let f = 0; + if (c < 1.0) { + f = (l - 0.5 * c) / (1.0 - c); + } -function resolveYamlBoolean$1(data) { - if (data === null) return false; + return [hsl[0], c * 100, f * 100]; +}; - var max = data.length; +convert$4.hsv.hcg = function (hsv) { + const s = hsv[1] / 100; + const v = hsv[2] / 100; - return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || - (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); -} + const c = s * v; + let f = 0; -function constructYamlBoolean$1(data) { - return data === 'true' || - data === 'True' || - data === 'TRUE'; -} + if (c < 1.0) { + f = (v - c) / (1 - c); + } -function isBoolean$1(object) { - return Object.prototype.toString.call(object) === '[object Boolean]'; -} + return [hsv[0], c * 100, f * 100]; +}; -var bool$1 = new Type$d('tag:yaml.org,2002:bool', { - kind: 'scalar', - resolve: resolveYamlBoolean$1, - construct: constructYamlBoolean$1, - predicate: isBoolean$1, - represent: { - lowercase: function (object) { return object ? 'true' : 'false'; }, - uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, - camelcase: function (object) { return object ? 'True' : 'False'; } - }, - defaultStyle: 'lowercase' -}); +convert$4.hcg.rgb = function (hcg) { + const h = hcg[0] / 360; + const c = hcg[1] / 100; + const g = hcg[2] / 100; -var common$8 = common$b; -var Type$c = type$1; + if (c === 0.0) { + return [g * 255, g * 255, g * 255]; + } -function isHexCode$1(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || - ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || - ((0x61/* a */ <= c) && (c <= 0x66/* f */)); -} + const pure = [0, 0, 0]; + const hi = (h % 1) * 6; + const v = hi % 1; + const w = 1 - v; + let mg = 0; -function isOctCode$1(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); -} + /* eslint-disable max-statements-per-line */ + switch (Math.floor(hi)) { + case 0: + pure[0] = 1; pure[1] = v; pure[2] = 0; break; + case 1: + pure[0] = w; pure[1] = 1; pure[2] = 0; break; + case 2: + pure[0] = 0; pure[1] = 1; pure[2] = v; break; + case 3: + pure[0] = 0; pure[1] = w; pure[2] = 1; break; + case 4: + pure[0] = v; pure[1] = 0; pure[2] = 1; break; + default: + pure[0] = 1; pure[1] = 0; pure[2] = w; + } + /* eslint-enable max-statements-per-line */ -function isDecCode$1(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); -} + mg = (1.0 - c) * g; -function resolveYamlInteger$1(data) { - if (data === null) return false; + return [ + (c * pure[0] + mg) * 255, + (c * pure[1] + mg) * 255, + (c * pure[2] + mg) * 255 + ]; +}; - var max = data.length, - index = 0, - hasDigits = false, - ch; +convert$4.hcg.hsv = function (hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; - if (!max) return false; + const v = c + g * (1.0 - c); + let f = 0; - ch = data[index]; + if (v > 0.0) { + f = c / v; + } - // sign - if (ch === '-' || ch === '+') { - ch = data[++index]; - } + return [hcg[0], f * 100, v * 100]; +}; - if (ch === '0') { - // 0 - if (index + 1 === max) return true; - ch = data[++index]; +convert$4.hcg.hsl = function (hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; - // base 2, base 8, base 16 + const l = g * (1.0 - c) + 0.5 * c; + let s = 0; - if (ch === 'b') { - // base 2 - index++; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (ch !== '0' && ch !== '1') return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } + if (l > 0.0 && l < 0.5) { + s = c / (2 * l); + } else + if (l >= 0.5 && l < 1.0) { + s = c / (2 * (1 - l)); + } + return [hcg[0], s * 100, l * 100]; +}; - if (ch === 'x') { - // base 16 - index++; +convert$4.hcg.hwb = function (hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; + const v = c + g * (1.0 - c); + return [hcg[0], (v - c) * 100, (1 - v) * 100]; +}; - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isHexCode$1(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } +convert$4.hwb.hcg = function (hwb) { + const w = hwb[1] / 100; + const b = hwb[2] / 100; + const v = 1 - b; + const c = v - w; + let g = 0; - // base 8 - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isOctCode$1(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } + if (c < 1) { + g = (v - c) / (1 - c); + } - // base 10 (except 0) or base 60 + return [hwb[0], c * 100, g * 100]; +}; - // value should not start with `_`; - if (ch === '_') return false; +convert$4.apple.rgb = function (apple) { + return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; +}; - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (ch === ':') break; - if (!isDecCode$1(data.charCodeAt(index))) { - return false; - } - hasDigits = true; - } +convert$4.rgb.apple = function (rgb) { + return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; +}; - // Should have digits and should not end with `_` - if (!hasDigits || ch === '_') return false; +convert$4.gray.rgb = function (args) { + return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; +}; - // if !base60 - done; - if (ch !== ':') return true; +convert$4.gray.hsl = function (args) { + return [0, 0, args[0]]; +}; - // base60 almost not used, no needs to optimize - return /^(:[0-5]?[0-9])+$/.test(data.slice(index)); -} +convert$4.gray.hsv = convert$4.gray.hsl; -function constructYamlInteger$1(data) { - var value = data, sign = 1, ch, base, digits = []; +convert$4.gray.hwb = function (gray) { + return [0, 100, gray[0]]; +}; - if (value.indexOf('_') !== -1) { - value = value.replace(/_/g, ''); - } +convert$4.gray.cmyk = function (gray) { + return [0, 0, 0, gray[0]]; +}; - ch = value[0]; +convert$4.gray.lab = function (gray) { + return [gray[0], 0, 0]; +}; - if (ch === '-' || ch === '+') { - if (ch === '-') sign = -1; - value = value.slice(1); - ch = value[0]; - } +convert$4.gray.hex = function (gray) { + const val = Math.round(gray[0] / 100 * 255) & 0xFF; + const integer = (val << 16) + (val << 8) + val; - if (value === '0') return 0; + const string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; - if (ch === '0') { - if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); - if (value[1] === 'x') return sign * parseInt(value, 16); - return sign * parseInt(value, 8); - } +convert$4.rgb.gray = function (rgb) { + const val = (rgb[0] + rgb[1] + rgb[2]) / 3; + return [val / 255 * 100]; +}; - if (value.indexOf(':') !== -1) { - value.split(':').forEach(function (v) { - digits.unshift(parseInt(v, 10)); - }); +const conversions$4 = conversions$5; - value = 0; - base = 1; +/* + This function routes a model to all other models. - digits.forEach(function (d) { - value += (d * base); - base *= 60; - }); + all functions that are routed have a property `.conversion` attached + to the returned synthetic function. This property is an array + of strings, each with the steps in between the 'from' and 'to' + color models (inclusive). - return sign * value; + conversions that are not possible simply are not included. +*/ - } +function buildGraph$1() { + const graph = {}; + // https://jsperf.com/object-keys-vs-for-in-with-closure/3 + const models = Object.keys(conversions$4); - return sign * parseInt(value, 10); -} + for (let len = models.length, i = 0; i < len; i++) { + graph[models[i]] = { + // http://jsperf.com/1-vs-infinity + // micro-opt, but this is simple. + distance: -1, + parent: null + }; + } -function isInteger$1(object) { - return (Object.prototype.toString.call(object)) === '[object Number]' && - (object % 1 === 0 && !common$8.isNegativeZero(object)); + return graph; } -var int$4 = new Type$c('tag:yaml.org,2002:int', { - kind: 'scalar', - resolve: resolveYamlInteger$1, - construct: constructYamlInteger$1, - predicate: isInteger$1, - represent: { - binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, - octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); }, - decimal: function (obj) { return obj.toString(10); }, - /* eslint-disable max-len */ - 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' ] - } -}); +// https://en.wikipedia.org/wiki/Breadth-first_search +function deriveBFS$1(fromModel) { + const graph = buildGraph$1(); + const queue = [fromModel]; // Unshift -> queue -> pop -var common$7 = common$b; -var Type$b = type$1; + graph[fromModel].distance = 0; -var YAML_FLOAT_PATTERN$1 = new RegExp( - // 2.5e4, 2.5 and integers - '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + - // .2e4, .2 - // special case, seems not from spec - '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + - // 20:59 - '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + - // .inf - '|[-+]?\\.(?:inf|Inf|INF)' + - // .nan - '|\\.(?:nan|NaN|NAN))$'); + while (queue.length) { + const current = queue.pop(); + const adjacents = Object.keys(conversions$4[current]); -function resolveYamlFloat$1(data) { - if (data === null) return false; + for (let len = adjacents.length, i = 0; i < len; i++) { + const adjacent = adjacents[i]; + const node = graph[adjacent]; - if (!YAML_FLOAT_PATTERN$1.test(data) || - // Quick hack to not allow integers end with `_` - // Probably should update regexp & check speed - data[data.length - 1] === '_') { - return false; - } + if (node.distance === -1) { + node.distance = graph[current].distance + 1; + node.parent = current; + queue.unshift(adjacent); + } + } + } - return true; + return graph; } -function constructYamlFloat$1(data) { - var value, sign, base, digits; - - value = data.replace(/_/g, '').toLowerCase(); - sign = value[0] === '-' ? -1 : 1; - digits = []; +function link$2(from, to) { + return function (args) { + return to(from(args)); + }; +} - if ('+-'.indexOf(value[0]) >= 0) { - value = value.slice(1); - } +function wrapConversion$1(toModel, graph) { + const path = [graph[toModel].parent, toModel]; + let fn = conversions$4[graph[toModel].parent][toModel]; - if (value === '.inf') { - return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + let cur = graph[toModel].parent; + while (graph[cur].parent) { + path.unshift(graph[cur].parent); + fn = link$2(conversions$4[graph[cur].parent][cur], fn); + cur = graph[cur].parent; + } - } else if (value === '.nan') { - return NaN; + fn.conversion = path; + return fn; +} - } else if (value.indexOf(':') >= 0) { - value.split(':').forEach(function (v) { - digits.unshift(parseFloat(v, 10)); - }); +var route$3 = function (fromModel) { + const graph = deriveBFS$1(fromModel); + const conversion = {}; - value = 0.0; - base = 1; + const models = Object.keys(graph); + for (let len = models.length, i = 0; i < len; i++) { + const toModel = models[i]; + const node = graph[toModel]; - digits.forEach(function (d) { - value += d * base; - base *= 60; - }); + if (node.parent === null) { + // No possible conversion, or this node is the source model. + continue; + } - return sign * value; + conversion[toModel] = wrapConversion$1(toModel, graph); + } - } - return sign * parseFloat(value, 10); -} + return conversion; +}; +const conversions$3 = conversions$5; +const route$2 = route$3; -var SCIENTIFIC_WITHOUT_DOT$1 = /^[-+]?[0-9]+e/; +const convert$3 = {}; -function representYamlFloat$1(object, style) { - var res; +const models$1 = Object.keys(conversions$3); - 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$7.isNegativeZero(object)) { - return '-0.0'; - } +function wrapRaw$1(fn) { + const wrappedFn = function (...args) { + const arg0 = args[0]; + if (arg0 === undefined || arg0 === null) { + return arg0; + } - res = object.toString(10); + if (arg0.length > 1) { + args = arg0; + } - // JS stringifier can build scientific format without dots: 5e-100, - // while YAML requres dot: 5.e-100. Fix it with simple hack + return fn(args); + }; - return SCIENTIFIC_WITHOUT_DOT$1.test(res) ? res.replace('e', '.e') : res; -} + // Preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } -function isFloat$1(object) { - return (Object.prototype.toString.call(object) === '[object Number]') && - (object % 1 !== 0 || common$7.isNegativeZero(object)); + return wrappedFn; } -var float$1 = new Type$b('tag:yaml.org,2002:float', { - kind: 'scalar', - resolve: resolveYamlFloat$1, - construct: constructYamlFloat$1, - predicate: isFloat$1, - represent: representYamlFloat$1, - defaultStyle: 'lowercase' -}); - -var Schema$5 = schema$2; +function wrapRounded$1(fn) { + const wrappedFn = function (...args) { + const arg0 = args[0]; + if (arg0 === undefined || arg0 === null) { + return arg0; + } -var json$3 = new Schema$5({ - include: [ - failsafe$1 - ], - implicit: [ - _null$1, - bool$1, - int$4, - float$1 - ] -}); + if (arg0.length > 1) { + args = arg0; + } -var Schema$4 = schema$2; + const result = fn(args); + // We're assuming the result is an array here. + // see notice in conversions.js; don't use box types + // in conversion functions. + if (typeof result === 'object') { + for (let len = result.length, i = 0; i < len; i++) { + result[i] = Math.round(result[i]); + } + } -var core$4 = new Schema$4({ - include: [ - json$3 - ] -}); + return result; + }; -var Type$a = type$1; + // Preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } -var YAML_DATE_REGEXP$1 = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9])' + // [2] month - '-([0-9][0-9])$'); // [3] day + return wrappedFn; +} -var YAML_TIMESTAMP_REGEXP$1 = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9]?)' + // [2] month - '-([0-9][0-9]?)' + // [3] day - '(?:[Tt]|[ \\t]+)' + // ... - '([0-9][0-9]?)' + // [4] hour - ':([0-9][0-9])' + // [5] minute - ':([0-9][0-9])' + // [6] second - '(?:\\.([0-9]*))?' + // [7] fraction - '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour - '(?::([0-9][0-9]))?))?$'); // [11] tz_minute +models$1.forEach(fromModel => { + convert$3[fromModel] = {}; -function resolveYamlTimestamp$1(data) { - if (data === null) return false; - if (YAML_DATE_REGEXP$1.exec(data) !== null) return true; - if (YAML_TIMESTAMP_REGEXP$1.exec(data) !== null) return true; - return false; -} + Object.defineProperty(convert$3[fromModel], 'channels', {value: conversions$3[fromModel].channels}); + Object.defineProperty(convert$3[fromModel], 'labels', {value: conversions$3[fromModel].labels}); -function constructYamlTimestamp$1(data) { - var match, year, month, day, hour, minute, second, fraction = 0, - delta = null, tz_hour, tz_minute, date; + const routes = route$2(fromModel); + const routeModels = Object.keys(routes); - match = YAML_DATE_REGEXP$1.exec(data); - if (match === null) match = YAML_TIMESTAMP_REGEXP$1.exec(data); + routeModels.forEach(toModel => { + const fn = routes[toModel]; - if (match === null) throw new Error('Date resolve error'); + convert$3[fromModel][toModel] = wrapRounded$1(fn); + convert$3[fromModel][toModel].raw = wrapRaw$1(fn); + }); +}); - // match: [1] year [2] month [3] day +var colorConvert$1 = convert$3; - year = +(match[1]); - month = +(match[2]) - 1; // JS month starts with 0 - day = +(match[3]); +(function (module) { - if (!match[4]) { // no hour - return new Date(Date.UTC(year, month, day)); - } +const wrapAnsi16 = (fn, offset) => (...args) => { + const code = fn(...args); + return `\u001B[${code + offset}m`; +}; - // match: [4] hour [5] minute [6] second [7] fraction +const wrapAnsi256 = (fn, offset) => (...args) => { + const code = fn(...args); + return `\u001B[${38 + offset};5;${code}m`; +}; - hour = +(match[4]); - minute = +(match[5]); - second = +(match[6]); +const wrapAnsi16m = (fn, offset) => (...args) => { + const rgb = fn(...args); + return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; +}; - if (match[7]) { - fraction = match[7].slice(0, 3); - while (fraction.length < 3) { // milli-seconds - fraction += '0'; - } - fraction = +fraction; - } +const ansi2ansi = n => n; +const rgb2rgb = (r, g, b) => [r, g, b]; - // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute +const setLazyProperty = (object, property, get) => { + Object.defineProperty(object, property, { + get: () => { + const value = get(); - if (match[9]) { - tz_hour = +(match[10]); - tz_minute = +(match[11] || 0); - delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds - if (match[9] === '-') delta = -delta; - } + Object.defineProperty(object, property, { + value, + enumerable: true, + configurable: true + }); - date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + return value; + }, + enumerable: true, + configurable: true + }); +}; - if (delta) date.setTime(date.getTime() - delta); +/** @type {typeof import('color-convert')} */ +let colorConvert; +const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => { + if (colorConvert === undefined) { + colorConvert = colorConvert$1; + } - return date; -} + const offset = isBackground ? 10 : 0; + const styles = {}; -function representYamlTimestamp$1(object /*, style*/) { - return object.toISOString(); -} + for (const [sourceSpace, suite] of Object.entries(colorConvert)) { + const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace; + if (sourceSpace === targetSpace) { + styles[name] = wrap(identity, offset); + } else if (typeof suite === 'object') { + styles[name] = wrap(suite[targetSpace], offset); + } + } -var timestamp$1 = new Type$a('tag:yaml.org,2002:timestamp', { - kind: 'scalar', - resolve: resolveYamlTimestamp$1, - construct: constructYamlTimestamp$1, - instanceOf: Date, - represent: representYamlTimestamp$1 -}); + return styles; +}; -var Type$9 = type$1; +function assembleStyles() { + const codes = new Map(); + const styles = { + modifier: { + reset: [0, 0], + // 21 isn't widely supported and 22 does the same thing + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + color: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], -function resolveYamlMerge$1(data) { - return data === '<<' || data === null; -} + // Bright color + blackBright: [90, 39], + redBright: [91, 39], + greenBright: [92, 39], + yellowBright: [93, 39], + blueBright: [94, 39], + magentaBright: [95, 39], + cyanBright: [96, 39], + whiteBright: [97, 39] + }, + bgColor: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], -var merge$2 = new Type$9('tag:yaml.org,2002:merge', { - kind: 'scalar', - resolve: resolveYamlMerge$1 -}); + // Bright color + bgBlackBright: [100, 49], + bgRedBright: [101, 49], + bgGreenBright: [102, 49], + bgYellowBright: [103, 49], + bgBlueBright: [104, 49], + bgMagentaBright: [105, 49], + bgCyanBright: [106, 49], + bgWhiteBright: [107, 49] + } + }; -/*eslint-disable no-bitwise*/ + // Alias bright black as gray (and grey) + styles.color.gray = styles.color.blackBright; + styles.bgColor.bgGray = styles.bgColor.bgBlackBright; + styles.color.grey = styles.color.blackBright; + styles.bgColor.bgGrey = styles.bgColor.bgBlackBright; -var NodeBuffer; + for (const [groupName, group] of Object.entries(styles)) { + for (const [styleName, style] of Object.entries(group)) { + styles[styleName] = { + open: `\u001B[${style[0]}m`, + close: `\u001B[${style[1]}m` + }; -try { - // A trick for browserified version, to not include `Buffer` shim - var _require$1 = commonjsRequire; - NodeBuffer = _require$1('buffer').Buffer; -} catch (__) {} + group[styleName] = styles[styleName]; -var Type$8 = type$1; + codes.set(style[0], style[1]); + } + Object.defineProperty(styles, groupName, { + value: group, + enumerable: false + }); + } -// [ 64, 65, 66 ] -> [ padding, CR, LF ] -var BASE64_MAP$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; + Object.defineProperty(styles, 'codes', { + value: codes, + enumerable: false + }); + styles.color.close = '\u001B[39m'; + styles.bgColor.close = '\u001B[49m'; -function resolveYamlBinary$1(data) { - if (data === null) return false; + setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false)); + setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false)); + setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false)); + setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true)); + setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true)); + setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true)); - var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP$1; + return styles; +} - // Convert one by one. - for (idx = 0; idx < max; idx++) { - code = map.indexOf(data.charAt(idx)); +// Make the export immutable +Object.defineProperty(module, 'exports', { + enumerable: true, + get: assembleStyles +}); +}(ansiStyles$2)); - // Skip CR/LF - if (code > 64) continue; +var hasFlag$4 = (flag, argv = process.argv) => { + const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); + const position = argv.indexOf(prefix + flag); + const terminatorPosition = argv.indexOf('--'); + return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); +}; - // Fail on illegal characters - if (code < 0) return false; +const os$2 = require$$0__default['default']; +const tty = tty__default['default']; +const hasFlag$3 = hasFlag$4; - bitlen += 6; - } +const {env: env$2} = process; - // If there are any bits left, source was corrupted - return (bitlen % 8) === 0; +let forceColor$1; +if (hasFlag$3('no-color') || + hasFlag$3('no-colors') || + hasFlag$3('color=false') || + hasFlag$3('color=never')) { + forceColor$1 = 0; +} else if (hasFlag$3('color') || + hasFlag$3('colors') || + hasFlag$3('color=true') || + hasFlag$3('color=always')) { + forceColor$1 = 1; } -function constructYamlBinary$1(data) { - var idx, tailbits, - input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan - max = input.length, - map = BASE64_MAP$1, - bits = 0, - result = []; - - // Collect by 6*4 bits (3 bytes) - - for (idx = 0; idx < max; idx++) { - if ((idx % 4 === 0) && idx) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); - } - - bits = (bits << 6) | map.indexOf(input.charAt(idx)); - } - - // Dump tail - - tailbits = (max % 4) * 6; - - if (tailbits === 0) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); - } else if (tailbits === 18) { - result.push((bits >> 10) & 0xFF); - result.push((bits >> 2) & 0xFF); - } else if (tailbits === 12) { - result.push((bits >> 4) & 0xFF); - } - - // Wrap into Buffer for NodeJS and leave Array for browser - if (NodeBuffer) { - // Support node 6.+ Buffer API when available - return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result); - } - - return result; +if ('FORCE_COLOR' in env$2) { + if (env$2.FORCE_COLOR === 'true') { + forceColor$1 = 1; + } else if (env$2.FORCE_COLOR === 'false') { + forceColor$1 = 0; + } else { + forceColor$1 = env$2.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env$2.FORCE_COLOR, 10), 3); + } } -function representYamlBinary$1(object /*, style*/) { - var result = '', bits = 0, idx, tail, - max = object.length, - map = BASE64_MAP$1; +function translateLevel$2(level) { + if (level === 0) { + return false; + } - // Convert every three bytes to 4 ASCII characters. + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; +} - for (idx = 0; idx < max; idx++) { - if ((idx % 3 === 0) && idx) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; - } +function supportsColor$2(haveStream, streamIsTTY) { + if (forceColor$1 === 0) { + return 0; + } - bits = (bits << 8) + object[idx]; - } + if (hasFlag$3('color=16m') || + hasFlag$3('color=full') || + hasFlag$3('color=truecolor')) { + return 3; + } - // Dump tail + if (hasFlag$3('color=256')) { + return 2; + } - tail = max % 3; + if (haveStream && !streamIsTTY && forceColor$1 === undefined) { + return 0; + } - if (tail === 0) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; - } else if (tail === 2) { - result += map[(bits >> 10) & 0x3F]; - result += map[(bits >> 4) & 0x3F]; - result += map[(bits << 2) & 0x3F]; - result += map[64]; - } else if (tail === 1) { - result += map[(bits >> 2) & 0x3F]; - result += map[(bits << 4) & 0x3F]; - result += map[64]; - result += map[64]; - } + const min = forceColor$1 || 0; - return result; -} + if (env$2.TERM === 'dumb') { + return min; + } -function isBinary$1(object) { - return NodeBuffer && NodeBuffer.isBuffer(object); -} + if (process.platform === 'win32') { + // Windows 10 build 10586 is the first Windows release that supports 256 colors. + // Windows 10 build 14931 is the first release that supports 16m/TrueColor. + const osRelease = os$2.release().split('.'); + if ( + Number(osRelease[0]) >= 10 && + Number(osRelease[2]) >= 10586 + ) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } -var binary$1 = new Type$8('tag:yaml.org,2002:binary', { - kind: 'scalar', - resolve: resolveYamlBinary$1, - construct: constructYamlBinary$1, - predicate: isBinary$1, - represent: representYamlBinary$1 -}); + return 1; + } -var Type$7 = type$1; + if ('CI' in env$2) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env$2) || env$2.CI_NAME === 'codeship') { + return 1; + } -var _hasOwnProperty$7 = Object.prototype.hasOwnProperty; -var _toString$5 = Object.prototype.toString; + return min; + } -function resolveYamlOmap$1(data) { - if (data === null) return true; + if ('TEAMCITY_VERSION' in env$2) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$2.TEAMCITY_VERSION) ? 1 : 0; + } - var objectKeys = [], index, length, pair, pairKey, pairHasKey, - object = data; + if (env$2.COLORTERM === 'truecolor') { + return 3; + } - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - pairHasKey = false; + if ('TERM_PROGRAM' in env$2) { + const version = parseInt((env$2.TERM_PROGRAM_VERSION || '').split('.')[0], 10); - if (_toString$5.call(pair) !== '[object Object]') return false; + switch (env$2.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Apple_Terminal': + return 2; + // No default + } + } - for (pairKey in pair) { - if (_hasOwnProperty$7.call(pair, pairKey)) { - if (!pairHasKey) pairHasKey = true; - else return false; - } - } + if (/-256(color)?$/i.test(env$2.TERM)) { + return 2; + } - if (!pairHasKey) return false; + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) { + return 1; + } - if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); - else return false; - } + if ('COLORTERM' in env$2) { + return 1; + } - return true; + return min; } -function constructYamlOmap$1(data) { - return data !== null ? data : []; +function getSupportLevel$1(stream) { + const level = supportsColor$2(stream, stream && stream.isTTY); + return translateLevel$2(level); } -var omap$1 = new Type$7('tag:yaml.org,2002:omap', { - kind: 'sequence', - resolve: resolveYamlOmap$1, - construct: constructYamlOmap$1 -}); - -var Type$6 = type$1; - -var _toString$4 = Object.prototype.toString; - -function resolveYamlPairs$1(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]; +var supportsColor_1$1 = { + supportsColor: getSupportLevel$1, + stdout: translateLevel$2(supportsColor$2(true, tty.isatty(1))), + stderr: translateLevel$2(supportsColor$2(true, tty.isatty(2))) +}; - if (_toString$4.call(pair) !== '[object Object]') return false; +const stringReplaceAll$1 = (string, substring, replacer) => { + let index = string.indexOf(substring); + if (index === -1) { + return string; + } - keys = Object.keys(pair); + const substringLength = substring.length; + let endIndex = 0; + let returnValue = ''; + do { + returnValue += string.substr(endIndex, index - endIndex) + substring + replacer; + endIndex = index + substringLength; + index = string.indexOf(substring, endIndex); + } while (index !== -1); - if (keys.length !== 1) return false; + returnValue += string.substr(endIndex); + return returnValue; +}; - result[index] = [ keys[0], pair[keys[0]] ]; - } +const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => { + let endIndex = 0; + let returnValue = ''; + do { + const gotCR = string[index - 1] === '\r'; + returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix; + endIndex = index + 1; + index = string.indexOf('\n', endIndex); + } while (index !== -1); - return true; -} + returnValue += string.substr(endIndex); + return returnValue; +}; -function constructYamlPairs$1(data) { - if (data === null) return []; +var util$4 = { + stringReplaceAll: stringReplaceAll$1, + stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1 +}; - var index, length, pair, keys, result, - object = data; +const TEMPLATE_REGEX$1 = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; +const STYLE_REGEX$1 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; +const STRING_REGEX$1 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; +const ESCAPE_REGEX$1 = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi; - result = new Array(object.length); +const ESCAPES$1 = new Map([ + ['n', '\n'], + ['r', '\r'], + ['t', '\t'], + ['b', '\b'], + ['f', '\f'], + ['v', '\v'], + ['0', '\0'], + ['\\', '\\'], + ['e', '\u001B'], + ['a', '\u0007'] +]); - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; +function unescape$1(c) { + const u = c[0] === 'u'; + const bracket = c[1] === '{'; - keys = Object.keys(pair); + if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) { + return String.fromCharCode(parseInt(c.slice(1), 16)); + } - result[index] = [ keys[0], pair[keys[0]] ]; - } + if (u && bracket) { + return String.fromCodePoint(parseInt(c.slice(2, -1), 16)); + } - return result; + return ESCAPES$1.get(c) || c; } -var pairs$1 = new Type$6('tag:yaml.org,2002:pairs', { - kind: 'sequence', - resolve: resolveYamlPairs$1, - construct: constructYamlPairs$1 -}); +function parseArguments$1(name, arguments_) { + const results = []; + const chunks = arguments_.trim().split(/\s*,\s*/g); + let matches; -var Type$5 = type$1; + for (const chunk of chunks) { + const number = Number(chunk); + if (!Number.isNaN(number)) { + results.push(number); + } else if ((matches = chunk.match(STRING_REGEX$1))) { + results.push(matches[2].replace(ESCAPE_REGEX$1, (m, escape, character) => escape ? unescape$1(escape) : character)); + } else { + throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); + } + } -var _hasOwnProperty$6 = Object.prototype.hasOwnProperty; + return results; +} -function resolveYamlSet$1(data) { - if (data === null) return true; +function parseStyle$1(style) { + STYLE_REGEX$1.lastIndex = 0; - var key, object = data; + const results = []; + let matches; - for (key in object) { - if (_hasOwnProperty$6.call(object, key)) { - if (object[key] !== null) return false; - } - } + while ((matches = STYLE_REGEX$1.exec(style)) !== null) { + const name = matches[1]; - return true; -} + if (matches[2]) { + const args = parseArguments$1(name, matches[2]); + results.push([name].concat(args)); + } else { + results.push([name]); + } + } -function constructYamlSet$1(data) { - return data !== null ? data : {}; + return results; } -var set$1 = new Type$5('tag:yaml.org,2002:set', { - kind: 'mapping', - resolve: resolveYamlSet$1, - construct: constructYamlSet$1 -}); +function buildStyle$1(chalk, styles) { + const enabled = {}; -var Schema$3 = schema$2; + for (const layer of styles) { + for (const style of layer.styles) { + enabled[style[0]] = layer.inverse ? null : style.slice(1); + } + } + let current = chalk; + for (const [styleName, styles] of Object.entries(enabled)) { + if (!Array.isArray(styles)) { + continue; + } -var default_safe = new Schema$3({ - include: [ - core$4 - ], - implicit: [ - timestamp$1, - merge$2 - ], - explicit: [ - binary$1, - omap$1, - pairs$1, - set$1 - ] -}); + if (!(styleName in current)) { + throw new Error(`Unknown Chalk style: ${styleName}`); + } -var Type$4 = type$1; + current = styles.length > 0 ? current[styleName](...styles) : current[styleName]; + } -function resolveJavascriptUndefined() { - return true; + return current; } -function constructJavascriptUndefined() { - /*eslint-disable no-undefined*/ - return undefined; -} +var templates$1 = (chalk, temporary) => { + const styles = []; + const chunks = []; + let chunk = []; -function representJavascriptUndefined() { - return ''; -} + // eslint-disable-next-line max-params + temporary.replace(TEMPLATE_REGEX$1, (m, escapeCharacter, inverse, style, close, character) => { + if (escapeCharacter) { + chunk.push(unescape$1(escapeCharacter)); + } else if (style) { + const string = chunk.join(''); + chunk = []; + chunks.push(styles.length === 0 ? string : buildStyle$1(chalk, styles)(string)); + styles.push({inverse, styles: parseStyle$1(style)}); + } else if (close) { + if (styles.length === 0) { + throw new Error('Found extraneous } in Chalk template literal'); + } -function isUndefined(object) { - return typeof object === 'undefined'; -} + chunks.push(buildStyle$1(chalk, styles)(chunk.join(''))); + chunk = []; + styles.pop(); + } else { + chunk.push(character); + } + }); -var _undefined = new Type$4('tag:yaml.org,2002:js/undefined', { - kind: 'scalar', - resolve: resolveJavascriptUndefined, - construct: constructJavascriptUndefined, - predicate: isUndefined, - represent: representJavascriptUndefined -}); + chunks.push(chunk.join('')); -var Type$3 = type$1; + if (styles.length > 0) { + const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; + throw new Error(errMessage); + } -function resolveJavascriptRegExp(data) { - if (data === null) return false; - if (data.length === 0) return false; + return chunks.join(''); +}; - var regexp = data, - tail = /\/([gim]*)$/.exec(data), - modifiers = ''; +const ansiStyles$1 = ansiStyles$2.exports; +const {stdout: stdoutColor, stderr: stderrColor} = supportsColor_1$1; +const { + stringReplaceAll, + stringEncaseCRLFWithFirstIndex +} = util$4; - // if regexp starts with '/' it can have modifiers and must be properly closed - // `/foo/gim` - modifiers tail can be maximum 3 chars - if (regexp[0] === '/') { - if (tail) modifiers = tail[1]; +const {isArray: isArray$2} = Array; - if (modifiers.length > 3) return false; - // if expression starts with /, is should be properly terminated - if (regexp[regexp.length - modifiers.length - 1] !== '/') return false; - } +// `supportsColor.level` → `ansiStyles.color[name]` mapping +const levelMapping = [ + 'ansi', + 'ansi', + 'ansi256', + 'ansi16m' +]; - return true; -} +const styles = Object.create(null); -function constructJavascriptRegExp(data) { - var regexp = data, - tail = /\/([gim]*)$/.exec(data), - modifiers = ''; +const applyOptions = (object, options = {}) => { + if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { + throw new Error('The `level` option should be an integer from 0 to 3'); + } - // `/foo/gim` - tail can be maximum 4 chars - if (regexp[0] === '/') { - if (tail) modifiers = tail[1]; - regexp = regexp.slice(1, regexp.length - modifiers.length - 1); - } + // Detect level if not set manually + const colorLevel = stdoutColor ? stdoutColor.level : 0; + object.level = options.level === undefined ? colorLevel : options.level; +}; - return new RegExp(regexp, modifiers); +class ChalkClass { + constructor(options) { + // eslint-disable-next-line no-constructor-return + return chalkFactory(options); + } } -function representJavascriptRegExp(object /*, style*/) { - var result = '/' + object.source + '/'; +const chalkFactory = options => { + const chalk = {}; + applyOptions(chalk, options); - if (object.global) result += 'g'; - if (object.multiline) result += 'm'; - if (object.ignoreCase) result += 'i'; + chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_); - return result; -} + Object.setPrototypeOf(chalk, Chalk.prototype); + Object.setPrototypeOf(chalk.template, chalk); -function isRegExp(object) { - return Object.prototype.toString.call(object) === '[object RegExp]'; -} + chalk.template.constructor = () => { + throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.'); + }; -var regexp = new Type$3('tag:yaml.org,2002:js/regexp', { - kind: 'scalar', - resolve: resolveJavascriptRegExp, - construct: constructJavascriptRegExp, - predicate: isRegExp, - represent: representJavascriptRegExp -}); + chalk.template.Instance = ChalkClass; -var esprima; + return chalk.template; +}; -// Browserified version does not have esprima -// -// 1. For node.js just require module as deps -// 2. For browser try to require mudule via external AMD system. -// If not found - try to fallback to window.esprima. If not -// found too - then fail to parse. -// -try { - // workaround to exclude package from browserify list. - var _require = commonjsRequire; - esprima = _require('esprima'); -} catch (_) { - /* eslint-disable no-redeclare */ - /* global window */ - if (typeof window !== 'undefined') esprima = window.esprima; +function Chalk(options) { + return chalkFactory(options); } -var Type$2 = type$1; - -function resolveJavascriptFunction(data) { - if (data === null) return false; - - try { - var source = '(' + data + ')', - ast = esprima.parse(source, { range: true }); - - if (ast.type !== 'Program' || - ast.body.length !== 1 || - ast.body[0].type !== 'ExpressionStatement' || - (ast.body[0].expression.type !== 'ArrowFunctionExpression' && - ast.body[0].expression.type !== 'FunctionExpression')) { - return false; - } - - return true; - } catch (err) { - return false; - } +for (const [styleName, style] of Object.entries(ansiStyles$1)) { + styles[styleName] = { + get() { + const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty); + Object.defineProperty(this, styleName, {value: builder}); + return builder; + } + }; } -function constructJavascriptFunction(data) { - /*jslint evil:true*/ - - var source = '(' + data + ')', - ast = esprima.parse(source, { range: true }), - params = [], - body; - - if (ast.type !== 'Program' || - ast.body.length !== 1 || - ast.body[0].type !== 'ExpressionStatement' || - (ast.body[0].expression.type !== 'ArrowFunctionExpression' && - ast.body[0].expression.type !== 'FunctionExpression')) { - throw new Error('Failed to resolve function'); - } - - ast.body[0].expression.params.forEach(function (param) { - params.push(param.name); - }); - - body = ast.body[0].expression.body.range; +styles.visible = { + get() { + const builder = createBuilder(this, this._styler, true); + Object.defineProperty(this, 'visible', {value: builder}); + return builder; + } +}; - // Esprima's ranges include the first '{' and the last '}' characters on - // function expressions. So cut them out. - if (ast.body[0].expression.body.type === 'BlockStatement') { - /*eslint-disable no-new-func*/ - return new Function(params, source.slice(body[0] + 1, body[1] - 1)); - } - // ES6 arrow functions can omit the BlockStatement. In that case, just return - // the body. - /*eslint-disable no-new-func*/ - return new Function(params, 'return ' + source.slice(body[0], body[1])); -} +const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256']; -function representJavascriptFunction(object /*, style*/) { - return object.toString(); +for (const model of usedModels) { + styles[model] = { + get() { + const {level} = this; + return function (...arguments_) { + const styler = createStyler(ansiStyles$1.color[levelMapping[level]][model](...arguments_), ansiStyles$1.color.close, this._styler); + return createBuilder(this, styler, this._isEmpty); + }; + } + }; } -function isFunction(object) { - return Object.prototype.toString.call(object) === '[object Function]'; +for (const model of usedModels) { + const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); + styles[bgModel] = { + get() { + const {level} = this; + return function (...arguments_) { + const styler = createStyler(ansiStyles$1.bgColor[levelMapping[level]][model](...arguments_), ansiStyles$1.bgColor.close, this._styler); + return createBuilder(this, styler, this._isEmpty); + }; + } + }; } -var _function = new Type$2('tag:yaml.org,2002:js/function', { - kind: 'scalar', - resolve: resolveJavascriptFunction, - construct: constructJavascriptFunction, - predicate: isFunction, - represent: representJavascriptFunction +const proto = Object.defineProperties(() => {}, { + ...styles, + level: { + enumerable: true, + get() { + return this._generator.level; + }, + set(level) { + this._generator.level = level; + } + } }); -var Schema$2 = schema$2; - - -var default_full = Schema$2.DEFAULT = new Schema$2({ - include: [ - default_safe - ], - explicit: [ - _undefined, - regexp, - _function - ] -}); +const createStyler = (open, close, parent) => { + let openAll; + let closeAll; + if (parent === undefined) { + openAll = open; + closeAll = close; + } else { + openAll = parent.openAll + open; + closeAll = close + parent.closeAll; + } -/*eslint-disable max-len,no-use-before-define*/ + return { + open, + close, + openAll, + closeAll, + parent + }; +}; -var common$6 = common$b; -var YAMLException$3 = exception$1; -var Mark = mark$1; -var DEFAULT_SAFE_SCHEMA$1 = default_safe; -var DEFAULT_FULL_SCHEMA$1 = default_full; +const createBuilder = (self, _styler, _isEmpty) => { + const builder = (...arguments_) => { + if (isArray$2(arguments_[0]) && isArray$2(arguments_[0].raw)) { + // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}` + return applyStyle(builder, chalkTag(builder, ...arguments_)); + } + // Single argument is hot path, implicit coercion is faster than anything + // eslint-disable-next-line no-implicit-coercion + return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' ')); + }; -var _hasOwnProperty$5 = Object.prototype.hasOwnProperty; + // We alter the prototype because we must return a function, but there is + // no way to create a function with a different prototype + Object.setPrototypeOf(builder, proto); + builder._generator = self; + builder._styler = _styler; + builder._isEmpty = _isEmpty; -var CONTEXT_FLOW_IN$1 = 1; -var CONTEXT_FLOW_OUT$1 = 2; -var CONTEXT_BLOCK_IN$1 = 3; -var CONTEXT_BLOCK_OUT$1 = 4; + return builder; +}; +const applyStyle = (self, string) => { + if (self.level <= 0 || !string) { + return self._isEmpty ? '' : string; + } -var CHOMPING_CLIP$1 = 1; -var CHOMPING_STRIP$1 = 2; -var CHOMPING_KEEP$1 = 3; + let styler = self._styler; + if (styler === undefined) { + return string; + } -var PATTERN_NON_PRINTABLE$1 = /[\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$1 = /[\x85\u2028\u2029]/; -var PATTERN_FLOW_INDICATORS$1 = /[,\[\]\{\}]/; -var PATTERN_TAG_HANDLE$1 = /^(?:!|!!|![a-z\-]+!)$/i; -var PATTERN_TAG_URI$1 = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + const {openAll, closeAll} = styler; + if (string.indexOf('\u001B') !== -1) { + while (styler !== undefined) { + // Replace any instances already present with a re-opening code + // otherwise only the part of the string until said closing code + // will be colored, and the rest will simply be 'plain'. + string = stringReplaceAll(string, styler.close, styler.open); + styler = styler.parent; + } + } -function _class$1(obj) { return Object.prototype.toString.call(obj); } - -function is_EOL$1(c) { - return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); -} - -function is_WHITE_SPACE$1(c) { - return (c === 0x09/* Tab */) || (c === 0x20/* Space */); -} - -function is_WS_OR_EOL$1(c) { - return (c === 0x09/* Tab */) || - (c === 0x20/* Space */) || - (c === 0x0A/* LF */) || - (c === 0x0D/* CR */); -} - -function is_FLOW_INDICATOR$1(c) { - return c === 0x2C/* , */ || - c === 0x5B/* [ */ || - c === 0x5D/* ] */ || - c === 0x7B/* { */ || - c === 0x7D/* } */; -} - -function fromHexCode$1(c) { - var lc; - - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - /*eslint-disable no-bitwise*/ - lc = c | 0x20; + // We can move both next actions out of loop, because remaining actions in loop won't have + // any/visible effect on parts we add here. Close the styling before a linebreak and reopen + // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92 + const lfIndex = string.indexOf('\n'); + if (lfIndex !== -1) { + string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); + } - if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { - return lc - 0x61 + 10; - } + return openAll + string + closeAll; +}; - return -1; -} +let template; +const chalkTag = (chalk, ...strings) => { + const [firstString] = strings; -function escapedHexLen$1(c) { - if (c === 0x78/* x */) { return 2; } - if (c === 0x75/* u */) { return 4; } - if (c === 0x55/* U */) { return 8; } - return 0; -} + if (!isArray$2(firstString) || !isArray$2(firstString.raw)) { + // If chalk() was called by itself or with a string, + // return the string itself as a string. + return strings.join(' '); + } -function fromDecimalCode$1(c) { - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } + const arguments_ = strings.slice(1); + const parts = [firstString.raw[0]]; - return -1; -} + for (let i = 1; i < firstString.length; i++) { + parts.push( + String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), + String(firstString.raw[i]) + ); + } -function simpleEscapeSequence$1(c) { - /* eslint-disable indent */ - return (c === 0x30/* 0 */) ? '\x00' : - (c === 0x61/* a */) ? '\x07' : - (c === 0x62/* b */) ? '\x08' : - (c === 0x74/* t */) ? '\x09' : - (c === 0x09/* Tab */) ? '\x09' : - (c === 0x6E/* n */) ? '\x0A' : - (c === 0x76/* v */) ? '\x0B' : - (c === 0x66/* f */) ? '\x0C' : - (c === 0x72/* r */) ? '\x0D' : - (c === 0x65/* e */) ? '\x1B' : - (c === 0x20/* Space */) ? ' ' : - (c === 0x22/* " */) ? '\x22' : - (c === 0x2F/* / */) ? '/' : - (c === 0x5C/* \ */) ? '\x5C' : - (c === 0x4E/* N */) ? '\x85' : - (c === 0x5F/* _ */) ? '\xA0' : - (c === 0x4C/* L */) ? '\u2028' : - (c === 0x50/* P */) ? '\u2029' : ''; -} + if (template === undefined) { + template = templates$1; + } -function charFromCodepoint$1(c) { - if (c <= 0xFFFF) { - return String.fromCharCode(c); - } - // Encode UTF-16 surrogate pair - // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF - return String.fromCharCode( - ((c - 0x010000) >> 10) + 0xD800, - ((c - 0x010000) & 0x03FF) + 0xDC00 - ); -} + return template(chalk, parts.join('')); +}; -var simpleEscapeCheck$1 = new Array(256); // integer, for fast access -var simpleEscapeMap$1 = new Array(256); -for (var i$1 = 0; i$1 < 256; i$1++) { - simpleEscapeCheck$1[i$1] = simpleEscapeSequence$1(i$1) ? 1 : 0; - simpleEscapeMap$1[i$1] = simpleEscapeSequence$1(i$1); -} +Object.defineProperties(Chalk.prototype, styles); +const chalk$1 = Chalk(); // eslint-disable-line new-cap +chalk$1.supportsColor = stdoutColor; +chalk$1.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap +chalk$1.stderr.supportsColor = stderrColor; -function State$3(input, options) { - this.input = input; +var source$1 = chalk$1; - this.filename = options['filename'] || null; - this.schema = options['schema'] || DEFAULT_FULL_SCHEMA$1; - this.onWarning = options['onWarning'] || null; - this.legacy = options['legacy'] || false; - this.json = options['json'] || false; - this.listener = options['listener'] || null; +var chokidar = {}; - this.implicitTypes = this.schema.compiledImplicit; - this.typeMap = this.schema.compiledTypeMap; +var utils$7 = {}; - this.length = input.length; - this.position = 0; - this.line = 0; - this.lineStart = 0; - this.lineIndent = 0; +const path$a = path__default['default']; +const WIN_SLASH = '\\\\/'; +const WIN_NO_SLASH = `[^${WIN_SLASH}]`; - this.documents = []; +/** + * Posix glob regex + */ - /* - this.version; - this.checkLineBreaks; - this.tagMap; - this.anchorMap; - this.tag; - this.anchor; - this.kind; - this.result;*/ +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 NO_DOT = `(?!${DOT_LITERAL})`; +const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`; +const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`; +const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`; +const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`; +const STAR$1 = `${QMARK}*?`; -} +const POSIX_CHARS = { + DOT_LITERAL, + PLUS_LITERAL, + QMARK_LITERAL, + SLASH_LITERAL, + ONE_CHAR, + QMARK, + END_ANCHOR, + DOTS_SLASH, + NO_DOT, + NO_DOTS, + NO_DOT_SLASH, + NO_DOTS_SLASH, + QMARK_NO_DOT, + STAR: STAR$1, + START_ANCHOR +}; +/** + * Windows glob regex + */ -function generateError$1(state, message) { - return new YAMLException$3( - message, - new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart))); -} +const WINDOWS_CHARS = { + ...POSIX_CHARS, -function throwError$2(state, message) { - throw generateError$1(state, message); -} + 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}]|$)` +}; -function throwWarning$1(state, message) { - if (state.onWarning) { - state.onWarning.call(null, generateError$1(state, message)); - } -} +/** + * POSIX Bracket Regex + */ +const POSIX_REGEX_SOURCE$1 = { + 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' +}; -var directiveHandlers$1 = { +var constants$5 = { + MAX_LENGTH: 1024 * 64, + POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1, - YAML: function handleYamlDirective(state, name, args) { + // regular expressions + 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, - var match, major, minor; + // Replace globs with equivalent patterns to reduce parsing time. + REPLACEMENTS: { + '***': '*', + '**/**': '**', + '**/**/**': '**' + }, - if (state.version !== null) { - throwError$2(state, 'duplication of %YAML directive'); - } + // Digits + CHAR_0: 48, /* 0 */ + CHAR_9: 57, /* 9 */ - if (args.length !== 1) { - throwError$2(state, 'YAML directive accepts exactly one argument'); - } + // Alphabet chars. + CHAR_UPPERCASE_A: 65, /* A */ + CHAR_LOWERCASE_A: 97, /* a */ + CHAR_UPPERCASE_Z: 90, /* Z */ + CHAR_LOWERCASE_Z: 122, /* z */ - match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + CHAR_LEFT_PARENTHESES: 40, /* ( */ + CHAR_RIGHT_PARENTHESES: 41, /* ) */ - if (match === null) { - throwError$2(state, 'ill-formed argument of the YAML directive'); - } + CHAR_ASTERISK: 42, /* * */ - major = parseInt(match[1], 10); - minor = parseInt(match[2], 10); + // Non-alphabetic chars. + CHAR_AMPERSAND: 38, /* & */ + CHAR_AT: 64, /* @ */ + CHAR_BACKWARD_SLASH: 92, /* \ */ + CHAR_CARRIAGE_RETURN: 13, /* \r */ + 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, /* \f */ + 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, /* \n */ + CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */ + 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, /* \t */ + CHAR_UNDERSCORE: 95, /* _ */ + CHAR_VERTICAL_LINE: 124, /* | */ + CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */ - if (major !== 1) { - throwError$2(state, 'unacceptable YAML version of the document'); - } + SEP: path$a.sep, - state.version = args[0]; - state.checkLineBreaks = (minor < 2); + /** + * Create EXTGLOB_CHARS + */ - if (minor !== 1 && minor !== 2) { - throwWarning$1(state, 'unsupported YAML version of the document'); - } + 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: ')' } + }; }, - TAG: function handleTagDirective(state, name, args) { - - var handle, prefix; + /** + * Create GLOB_CHARS + */ - if (args.length !== 2) { - throwError$2(state, 'TAG directive accepts exactly two arguments'); - } + globChars(win32) { + return win32 === true ? WINDOWS_CHARS : POSIX_CHARS; + } +}; - handle = args[0]; - prefix = args[1]; +(function (exports) { - if (!PATTERN_TAG_HANDLE$1.test(handle)) { - throwError$2(state, 'ill-formed tag handle (first argument) of the TAG directive'); - } +const path = path__default['default']; +const win32 = process.platform === 'win32'; +const { + REGEX_BACKSLASH, + REGEX_REMOVE_BACKSLASH, + REGEX_SPECIAL_CHARS, + REGEX_SPECIAL_CHARS_GLOBAL +} = constants$5; - if (_hasOwnProperty$5.call(state.tagMap, handle)) { - throwError$2(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); - } +exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); +exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str); +exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str); +exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1'); +exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/'); - if (!PATTERN_TAG_URI$1.test(prefix)) { - throwError$2(state, 'ill-formed tag prefix (second argument) of the TAG directive'); - } +exports.removeBackslashes = str => { + return str.replace(REGEX_REMOVE_BACKSLASH, match => { + return match === '\\' ? '' : match; + }); +}; - state.tagMap[handle] = prefix; +exports.supportsLookbehinds = () => { + const segs = process.version.slice(1).split('.').map(Number); + if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) { + return true; } + return false; }; +exports.isWindows = options => { + if (options && typeof options.windows === 'boolean') { + return options.windows; + } + return win32 === true || path.sep === '\\'; +}; -function captureSegment$1(state, start, end, checkJson) { - var _position, _length, _character, _result; - - if (start < end) { - _result = state.input.slice(start, end); - - if (checkJson) { - for (_position = 0, _length = _result.length; _position < _length; _position += 1) { - _character = _result.charCodeAt(_position); - if (!(_character === 0x09 || - (0x20 <= _character && _character <= 0x10FFFF))) { - throwError$2(state, 'expected valid JSON character'); - } - } - } else if (PATTERN_NON_PRINTABLE$1.test(_result)) { - throwError$2(state, 'the stream contains non-printable characters'); - } +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)}`; +}; - state.result += _result; +exports.removePrefix = (input, state = {}) => { + let output = input; + if (output.startsWith('./')) { + output = output.slice(2); + state.prefix = './'; } -} + return output; +}; -function mergeMappings$1(state, destination, source, overridableKeys) { - var sourceKeys, key, index, quantity; +exports.wrapOutput = (input, state = {}, options = {}) => { + const prepend = options.contains ? '' : '^'; + const append = options.contains ? '' : '$'; - if (!common$6.isObject(source)) { - throwError$2(state, 'cannot merge mappings; the provided source object is unacceptable'); + let output = `${prepend}(?:${input})${append}`; + if (state.negated === true) { + output = `(?:^(?!${output}).*$)`; } + return output; +}; +}(utils$7)); - sourceKeys = Object.keys(source); +const utils$6 = utils$7; +const { + CHAR_ASTERISK: CHAR_ASTERISK$1, /* * */ + CHAR_AT, /* @ */ + CHAR_BACKWARD_SLASH, /* \ */ + CHAR_COMMA: CHAR_COMMA$2, /* , */ + CHAR_DOT: CHAR_DOT$1, /* . */ + CHAR_EXCLAMATION_MARK, /* ! */ + CHAR_FORWARD_SLASH, /* / */ + CHAR_LEFT_CURLY_BRACE: CHAR_LEFT_CURLY_BRACE$1, /* { */ + CHAR_LEFT_PARENTHESES: CHAR_LEFT_PARENTHESES$1, /* ( */ + CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$2, /* [ */ + CHAR_PLUS, /* + */ + CHAR_QUESTION_MARK, /* ? */ + CHAR_RIGHT_CURLY_BRACE: CHAR_RIGHT_CURLY_BRACE$1, /* } */ + CHAR_RIGHT_PARENTHESES: CHAR_RIGHT_PARENTHESES$1, /* ) */ + CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$2 /* ] */ +} = constants$5; - for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { - key = sourceKeys[index]; +const isPathSeparator = code => { + return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH; +}; - if (!_hasOwnProperty$5.call(destination, key)) { - destination[key] = source[key]; - overridableKeys[key] = true; - } +const depth = token => { + if (token.isPrefix !== true) { + token.depth = token.isGlobstar ? Infinity : 1; } -} - -function storeMappingPair$1(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) { - var index, quantity; +}; - // The output is a plain object here, so keys can only be strings. - // We need to convert keyNode to a string, but doing so can hang the process - // (deeply nested arrays that explode exponentially using aliases). - if (Array.isArray(keyNode)) { - keyNode = Array.prototype.slice.call(keyNode); +/** + * 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), and `negated` (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 + */ - for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { - if (Array.isArray(keyNode[index])) { - throwError$2(state, 'nested arrays are not supported inside keys'); - } +const scan$1 = (input, options) => { + const opts = options || {}; - if (typeof keyNode === 'object' && _class$1(keyNode[index]) === '[object Object]') { - keyNode[index] = '[object Object]'; - } - } - } + const length = input.length - 1; + const scanToEnd = opts.parts === true || opts.scanToEnd === true; + const slashes = []; + const tokens = []; + const parts = []; - // Avoid code execution in load() via toString property - // (still use its own toString for arrays, timestamps, - // and whatever user schema extensions happen to have @@toStringTag) - if (typeof keyNode === 'object' && _class$1(keyNode) === '[object Object]') { - keyNode = '[object Object]'; - } + let str = input; + let index = -1; + let start = 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 finished = false; + let braces = 0; + let prev; + let code; + let token = { value: '', depth: 0, isGlob: false }; + const eos = () => index >= length; + const peek = () => str.charCodeAt(index + 1); + const advance = () => { + prev = code; + return str.charCodeAt(++index); + }; - keyNode = String(keyNode); + while (index < length) { + code = advance(); + let next; - if (_result === null) { - _result = {}; - } + if (code === CHAR_BACKWARD_SLASH) { + backslashes = token.backslashes = true; + code = advance(); - if (keyTag === 'tag:yaml.org,2002:merge') { - if (Array.isArray(valueNode)) { - for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { - mergeMappings$1(state, _result, valueNode[index], overridableKeys); + if (code === CHAR_LEFT_CURLY_BRACE$1) { + braceEscaped = true; } - } else { - mergeMappings$1(state, _result, valueNode, overridableKeys); - } - } else { - if (!state.json && - !_hasOwnProperty$5.call(overridableKeys, keyNode) && - _hasOwnProperty$5.call(_result, keyNode)) { - state.line = startLine || state.line; - state.position = startPos || state.position; - throwError$2(state, 'duplicated mapping key'); + continue; } - _result[keyNode] = valueNode; - delete overridableKeys[keyNode]; - } - return _result; -} + if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE$1) { + braces++; -function readLineBreak$1(state) { - var ch; + while (eos() !== true && (code = advance())) { + if (code === CHAR_BACKWARD_SLASH) { + backslashes = token.backslashes = true; + advance(); + continue; + } - ch = state.input.charCodeAt(state.position); + if (code === CHAR_LEFT_CURLY_BRACE$1) { + braces++; + continue; + } - if (ch === 0x0A/* LF */) { - state.position++; - } else if (ch === 0x0D/* CR */) { - state.position++; - if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { - state.position++; - } - } else { - throwError$2(state, 'a line break is expected'); - } + if (braceEscaped !== true && code === CHAR_DOT$1 && (code = advance()) === CHAR_DOT$1) { + isBrace = token.isBrace = true; + isGlob = token.isGlob = true; + finished = true; - state.line += 1; - state.lineStart = state.position; -} + if (scanToEnd === true) { + continue; + } -function skipSeparationSpace$1(state, allowComments, checkIndent) { - var lineBreaks = 0, - ch = state.input.charCodeAt(state.position); + break; + } - while (ch !== 0) { - while (is_WHITE_SPACE$1(ch)) { - ch = state.input.charCodeAt(++state.position); - } + if (braceEscaped !== true && code === CHAR_COMMA$2) { + isBrace = token.isBrace = true; + isGlob = token.isGlob = true; + finished = true; - if (allowComments && ch === 0x23/* # */) { - do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); - } + if (scanToEnd === true) { + continue; + } - if (is_EOL$1(ch)) { - readLineBreak$1(state); + break; + } - ch = state.input.charCodeAt(state.position); - lineBreaks++; - state.lineIndent = 0; + if (code === CHAR_RIGHT_CURLY_BRACE$1) { + braces--; - while (ch === 0x20/* Space */) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); + if (braces === 0) { + braceEscaped = false; + isBrace = token.isBrace = true; + finished = true; + break; + } + } } - } else { + + if (scanToEnd === true) { + continue; + } + break; } - } - - if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { - throwWarning$1(state, 'deficient indentation'); - } - return lineBreaks; -} + if (code === CHAR_FORWARD_SLASH) { + slashes.push(index); + tokens.push(token); + token = { value: '', depth: 0, isGlob: false }; -function testDocumentSeparator$1(state) { - var _position = state.position, - ch; + if (finished === true) continue; + if (prev === CHAR_DOT$1 && index === (start + 1)) { + start += 2; + continue; + } - ch = state.input.charCodeAt(_position); + lastIndex = index + 1; + continue; + } - // Condition state.position === state.lineStart is tested - // in parent on each call, for efficiency. No needs to test here again. - if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && - ch === state.input.charCodeAt(_position + 1) && - ch === state.input.charCodeAt(_position + 2)) { + if (opts.noext !== true) { + const isExtglobChar = code === CHAR_PLUS + || code === CHAR_AT + || code === CHAR_ASTERISK$1 + || code === CHAR_QUESTION_MARK + || code === CHAR_EXCLAMATION_MARK; - _position += 3; + if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES$1) { + isGlob = token.isGlob = true; + isExtglob = token.isExtglob = true; + finished = true; - ch = state.input.charCodeAt(_position); + if (scanToEnd === true) { + while (eos() !== true && (code = advance())) { + if (code === CHAR_BACKWARD_SLASH) { + backslashes = token.backslashes = true; + code = advance(); + continue; + } - if (ch === 0 || is_WS_OR_EOL$1(ch)) { - return true; + if (code === CHAR_RIGHT_PARENTHESES$1) { + isGlob = token.isGlob = true; + finished = true; + break; + } + } + continue; + } + break; + } } - } - - return false; -} -function writeFoldedLines$1(state, count) { - if (count === 1) { - state.result += ' '; - } else if (count > 1) { - state.result += common$6.repeat('\n', count - 1); - } -} + if (code === CHAR_ASTERISK$1) { + if (prev === CHAR_ASTERISK$1) isGlobstar = token.isGlobstar = true; + isGlob = token.isGlob = true; + finished = true; + if (scanToEnd === true) { + continue; + } + break; + } -function readPlainScalar$1(state, nodeIndent, withinFlowCollection) { - var preceding, - following, - captureStart, - captureEnd, - hasPendingContent, - _line, - _lineStart, - _lineIndent, - _kind = state.kind, - _result = state.result, - ch; + if (code === CHAR_QUESTION_MARK) { + isGlob = token.isGlob = true; + finished = true; - ch = state.input.charCodeAt(state.position); + if (scanToEnd === true) { + continue; + } + break; + } - if (is_WS_OR_EOL$1(ch) || - is_FLOW_INDICATOR$1(ch) || - ch === 0x23/* # */ || - ch === 0x26/* & */ || - ch === 0x2A/* * */ || - ch === 0x21/* ! */ || - ch === 0x7C/* | */ || - ch === 0x3E/* > */ || - ch === 0x27/* ' */ || - ch === 0x22/* " */ || - ch === 0x25/* % */ || - ch === 0x40/* @ */ || - ch === 0x60/* ` */) { - return false; - } + if (code === CHAR_LEFT_SQUARE_BRACKET$2) { + while (eos() !== true && (next = advance())) { + if (next === CHAR_BACKWARD_SLASH) { + backslashes = token.backslashes = true; + advance(); + continue; + } - if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { - following = state.input.charCodeAt(state.position + 1); + if (next === CHAR_RIGHT_SQUARE_BRACKET$2) { + isBracket = token.isBracket = true; + isGlob = token.isGlob = true; + finished = true; - if (is_WS_OR_EOL$1(following) || - withinFlowCollection && is_FLOW_INDICATOR$1(following)) { - return false; + if (scanToEnd === true) { + continue; + } + break; + } + } } - } - - state.kind = 'scalar'; - state.result = ''; - captureStart = captureEnd = state.position; - hasPendingContent = false; - while (ch !== 0) { - if (ch === 0x3A/* : */) { - following = state.input.charCodeAt(state.position + 1); + if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) { + negated = token.negated = true; + start++; + continue; + } - if (is_WS_OR_EOL$1(following) || - withinFlowCollection && is_FLOW_INDICATOR$1(following)) { - break; - } + if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES$1) { + isGlob = token.isGlob = true; - } else if (ch === 0x23/* # */) { - preceding = state.input.charCodeAt(state.position - 1); + if (scanToEnd === true) { + while (eos() !== true && (code = advance())) { + if (code === CHAR_LEFT_PARENTHESES$1) { + backslashes = token.backslashes = true; + code = advance(); + continue; + } - if (is_WS_OR_EOL$1(preceding)) { - break; + if (code === CHAR_RIGHT_PARENTHESES$1) { + finished = true; + break; + } + } + continue; } - - } else if ((state.position === state.lineStart && testDocumentSeparator$1(state)) || - withinFlowCollection && is_FLOW_INDICATOR$1(ch)) { break; + } - } else if (is_EOL$1(ch)) { - _line = state.line; - _lineStart = state.lineStart; - _lineIndent = state.lineIndent; - skipSeparationSpace$1(state, false, -1); + if (isGlob === true) { + finished = true; - if (state.lineIndent >= nodeIndent) { - hasPendingContent = true; - ch = state.input.charCodeAt(state.position); + if (scanToEnd === true) { continue; - } else { - state.position = captureEnd; - state.line = _line; - state.lineStart = _lineStart; - state.lineIndent = _lineIndent; - break; } - } - - if (hasPendingContent) { - captureSegment$1(state, captureStart, captureEnd, false); - writeFoldedLines$1(state, state.line - _line); - captureStart = captureEnd = state.position; - hasPendingContent = false; - } - if (!is_WHITE_SPACE$1(ch)) { - captureEnd = state.position + 1; + break; } - - ch = state.input.charCodeAt(++state.position); } - captureSegment$1(state, captureStart, captureEnd, false); - - if (state.result) { - return true; + if (opts.noext === true) { + isExtglob = false; + isGlob = false; } - state.kind = _kind; - state.result = _result; - return false; -} - -function readSingleQuotedScalar$1(state, nodeIndent) { - var ch, - captureStart, captureEnd; - - ch = state.input.charCodeAt(state.position); + let base = str; + let prefix = ''; + let glob = ''; - if (ch !== 0x27/* ' */) { - return false; + if (start > 0) { + prefix = str.slice(0, start); + str = str.slice(start); + lastIndex -= start; } - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; + if (base && isGlob === true && lastIndex > 0) { + base = str.slice(0, lastIndex); + glob = str.slice(lastIndex); + } else if (isGlob === true) { + base = ''; + glob = str; + } else { + base = str; + } - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x27/* ' */) { - captureSegment$1(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); + if (base && base !== '' && base !== '/' && base !== str) { + if (isPathSeparator(base.charCodeAt(base.length - 1))) { + base = base.slice(0, -1); + } + } - if (ch === 0x27/* ' */) { - captureStart = state.position; - state.position++; - captureEnd = state.position; - } else { - return true; - } + if (opts.unescape === true) { + if (glob) glob = utils$6.removeBackslashes(glob); - } else if (is_EOL$1(ch)) { - captureSegment$1(state, captureStart, captureEnd, true); - writeFoldedLines$1(state, skipSeparationSpace$1(state, false, nodeIndent)); - captureStart = captureEnd = state.position; + if (base && backslashes === true) { + base = utils$6.removeBackslashes(base); + } + } - } else if (state.position === state.lineStart && testDocumentSeparator$1(state)) { - throwError$2(state, 'unexpected end of the document within a single quoted scalar'); + const state = { + prefix, + input, + start, + base, + glob, + isBrace, + isBracket, + isGlob, + isExtglob, + isGlobstar, + negated + }; - } else { - state.position++; - captureEnd = state.position; + if (opts.tokens === true) { + state.maxDepth = 0; + if (!isPathSeparator(code)) { + tokens.push(token); } + state.tokens = tokens; } - throwError$2(state, 'unexpected end of the stream within a single quoted scalar'); -} - -function readDoubleQuotedScalar$1(state, nodeIndent) { - var captureStart, - captureEnd, - hexLength, - hexResult, - tmp, - ch; + if (opts.parts === true || opts.tokens === true) { + let prevIndex; - ch = state.input.charCodeAt(state.position); + for (let idx = 0; idx < slashes.length; idx++) { + const n = prevIndex ? prevIndex + 1 : start; + const i = slashes[idx]; + const value = input.slice(n, i); + if (opts.tokens) { + if (idx === 0 && start !== 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; + } - if (ch !== 0x22/* " */) { - return false; - } + if (prevIndex && prevIndex + 1 < input.length) { + const value = input.slice(prevIndex + 1); + parts.push(value); - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; + if (opts.tokens) { + tokens[tokens.length - 1].value = value; + depth(tokens[tokens.length - 1]); + state.maxDepth += tokens[tokens.length - 1].depth; + } + } - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x22/* " */) { - captureSegment$1(state, captureStart, state.position, true); - state.position++; - return true; + state.slashes = slashes; + state.parts = parts; + } - } else if (ch === 0x5C/* \ */) { - captureSegment$1(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); + return state; +}; - if (is_EOL$1(ch)) { - skipSeparationSpace$1(state, false, nodeIndent); +var scan_1 = scan$1; - // TODO: rework to inline fn with no type cast? - } else if (ch < 256 && simpleEscapeCheck$1[ch]) { - state.result += simpleEscapeMap$1[ch]; - state.position++; +const constants$4 = constants$5; +const utils$5 = utils$7; - } else if ((tmp = escapedHexLen$1(ch)) > 0) { - hexLength = tmp; - hexResult = 0; +/** + * Constants + */ - for (; hexLength > 0; hexLength--) { - ch = state.input.charCodeAt(++state.position); +const { + MAX_LENGTH: MAX_LENGTH$4, + POSIX_REGEX_SOURCE, + REGEX_NON_SPECIAL_CHARS, + REGEX_SPECIAL_CHARS_BACKREF, + REPLACEMENTS +} = constants$4; - if ((tmp = fromHexCode$1(ch)) >= 0) { - hexResult = (hexResult << 4) + tmp; +/** + * Helpers + */ - } else { - throwError$2(state, 'expected hexadecimal character'); - } - } +const expandRange = (args, options) => { + if (typeof options.expandRange === 'function') { + return options.expandRange(...args, options); + } - state.result += charFromCodepoint$1(hexResult); + args.sort(); + const value = `[${args.join('-')}]`; - state.position++; + try { + /* eslint-disable-next-line no-new */ + new RegExp(value); + } catch (ex) { + return args.map(v => utils$5.escapeRegex(v)).join('..'); + } - } else { - throwError$2(state, 'unknown escape sequence'); - } + return value; +}; - captureStart = captureEnd = state.position; +/** + * Create the message for a syntax error + */ - } else if (is_EOL$1(ch)) { - captureSegment$1(state, captureStart, captureEnd, true); - writeFoldedLines$1(state, skipSeparationSpace$1(state, false, nodeIndent)); - captureStart = captureEnd = state.position; +const syntaxError$1 = (type, char) => { + return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`; +}; - } else if (state.position === state.lineStart && testDocumentSeparator$1(state)) { - throwError$2(state, 'unexpected end of the document within a double quoted scalar'); +/** + * Parse the given input string. + * @param {String} input + * @param {Object} options + * @return {Object} + */ - } else { - state.position++; - captureEnd = state.position; - } +const parse$e = (input, options) => { + if (typeof input !== 'string') { + throw new TypeError('Expected a string'); } - throwError$2(state, 'unexpected end of the stream within a double quoted scalar'); -} - -function readFlowCollection$1(state, nodeIndent) { - var readNext = true, - _line, - _tag = state.tag, - _result, - _anchor = state.anchor, - following, - terminator, - isPair, - isExplicitPair, - isMapping, - overridableKeys = {}, - keyNode, - keyTag, - valueNode, - ch; - - ch = state.input.charCodeAt(state.position); + input = REPLACEMENTS[input] || input; - if (ch === 0x5B/* [ */) { - terminator = 0x5D;/* ] */ - isMapping = false; - _result = []; - } else if (ch === 0x7B/* { */) { - terminator = 0x7D;/* } */ - isMapping = true; - _result = {}; - } else { - return false; - } + const opts = { ...options }; + const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$4, opts.maxLength) : MAX_LENGTH$4; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; + let len = input.length; + if (len > max) { + throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); } - ch = state.input.charCodeAt(++state.position); + const bos = { type: 'bos', value: '', output: opts.prepend || '' }; + const tokens = [bos]; - while (ch !== 0) { - skipSeparationSpace$1(state, true, nodeIndent); + const capture = opts.capture ? '' : '?:'; + const win32 = utils$5.isWindows(options); - ch = state.input.charCodeAt(state.position); + // create constants based on platform, for windows or posix + const PLATFORM_CHARS = constants$4.globChars(win32); + const EXTGLOB_CHARS = constants$4.extglobChars(PLATFORM_CHARS); - 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$2(state, 'missed comma between flow collection entries'); - } + 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; - keyTag = keyNode = valueNode = null; - isPair = isExplicitPair = false; + const globstar = (opts) => { + return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; + }; - if (ch === 0x3F/* ? */) { - following = state.input.charCodeAt(state.position + 1); + const nodot = opts.dot ? '' : NO_DOT; + const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT; + let star = opts.bash === true ? globstar(opts) : STAR; - if (is_WS_OR_EOL$1(following)) { - isPair = isExplicitPair = true; - state.position++; - skipSeparationSpace$1(state, true, nodeIndent); - } - } + if (opts.capture) { + star = `(${star})`; + } - _line = state.line; - composeNode$1(state, nodeIndent, CONTEXT_FLOW_IN$1, false, true); - keyTag = state.tag; - keyNode = state.result; - skipSeparationSpace$1(state, true, nodeIndent); + // minimatch options support + if (typeof opts.noext === 'boolean') { + opts.noextglob = opts.noext; + } - ch = state.input.charCodeAt(state.position); + 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 + }; - if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { - isPair = true; - ch = state.input.charCodeAt(++state.position); - skipSeparationSpace$1(state, true, nodeIndent); - composeNode$1(state, nodeIndent, CONTEXT_FLOW_IN$1, false, true); - valueNode = state.result; - } + input = utils$5.removePrefix(input, state); + len = input.length; - if (isMapping) { - storeMappingPair$1(state, _result, overridableKeys, keyTag, keyNode, valueNode); - } else if (isPair) { - _result.push(storeMappingPair$1(state, null, overridableKeys, keyTag, keyNode, valueNode)); - } else { - _result.push(keyNode); - } + const extglobs = []; + const braces = []; + const stack = []; + let prev = bos; + let value; - skipSeparationSpace$1(state, true, nodeIndent); + /** + * Tokenizing helpers + */ - ch = state.input.charCodeAt(state.position); + 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 = '', num = 0) => { + state.consumed += value; + state.index += num; + }; + const append = token => { + state.output += token.output != null ? token.output : token.value; + consume(token.value); + }; - if (ch === 0x2C/* , */) { - readNext = true; - ch = state.input.charCodeAt(++state.position); - } else { - readNext = false; - } - } + const negate = () => { + let count = 1; - throwError$2(state, 'unexpected end of the stream within a flow collection'); -} + while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) { + advance(); + state.start++; + count++; + } -function readBlockScalar$1(state, nodeIndent) { - var captureStart, - folding, - chomping = CHOMPING_CLIP$1, - didReadContent = false, - detectedIndent = false, - textIndent = nodeIndent, - emptyLines = 0, - atMoreIndented = false, - tmp, - ch; + if (count % 2 === 0) { + return false; + } - ch = state.input.charCodeAt(state.position); + state.negated = true; + state.start++; + return true; + }; - if (ch === 0x7C/* | */) { - folding = false; - } else if (ch === 0x3E/* > */) { - folding = true; - } else { - return false; - } + const increment = type => { + state[type]++; + stack.push(type); + }; - state.kind = 'scalar'; - state.result = ''; + const decrement = type => { + state[type]--; + stack.pop(); + }; - while (ch !== 0) { - ch = state.input.charCodeAt(++state.position); + /** + * 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. + */ - if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { - if (CHOMPING_CLIP$1 === chomping) { - chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP$1 : CHOMPING_STRIP$1; - } else { - throwError$2(state, 'repeat of a chomping mode identifier'); - } + 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')); - } else if ((tmp = fromDecimalCode$1(ch)) >= 0) { - if (tmp === 0) { - throwError$2(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$2(state, 'repeat of an indentation width identifier'); + 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; } - - } else { - break; } - } - if (is_WHITE_SPACE$1(ch)) { - do { ch = state.input.charCodeAt(++state.position); } - while (is_WHITE_SPACE$1(ch)); + if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { + extglobs[extglobs.length - 1].inner += tok.value; + } - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (!is_EOL$1(ch) && (ch !== 0)); + if (tok.value || tok.output) append(tok); + if (prev && prev.type === 'text' && tok.type === 'text') { + prev.value += tok.value; + prev.output = (prev.output || '') + tok.value; + return; } - } - while (ch !== 0) { - readLineBreak$1(state); - state.lineIndent = 0; + tok.prev = prev; + tokens.push(tok); + prev = tok; + }; - ch = state.input.charCodeAt(state.position); + const extglobOpen = (type, value) => { + const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' }; - while ((!detectedIndent || state.lineIndent < textIndent) && - (ch === 0x20/* Space */)) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } + token.prev = prev; + token.parens = state.parens; + token.output = state.output; + const output = (opts.capture ? '(' : '') + token.open; - if (!detectedIndent && state.lineIndent > textIndent) { - textIndent = state.lineIndent; - } + increment('parens'); + push({ type, value, output: state.output ? '' : ONE_CHAR }); + push({ type: 'paren', extglob: true, value: advance(), output }); + extglobs.push(token); + }; - if (is_EOL$1(ch)) { - emptyLines++; - continue; - } + const extglobClose = token => { + let output = token.close + (opts.capture ? ')' : ''); - // End of the scalar. - if (state.lineIndent < textIndent) { + if (token.type === 'negate') { + let extglobStar = star; - // Perform the chomping. - if (chomping === CHOMPING_KEEP$1) { - state.result += common$6.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } else if (chomping === CHOMPING_CLIP$1) { - if (didReadContent) { // i.e. only if the scalar is not empty. - state.result += '\n'; - } + if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { + extglobStar = globstar(opts); } - // Break this `while` cycle and go to the funciton's epilogue. - break; + if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { + output = token.close = `)$))${extglobStar}`; + } + + if (token.prev.type === 'bos' && eos()) { + state.negatedExtglob = true; + } } - // Folded style: use fancy rules to handle line breaks. - if (folding) { + push({ type: 'paren', extglob: true, value, output }); + decrement('parens'); + }; - // Lines starting with white space characters (more-indented lines) are not folded. - if (is_WHITE_SPACE$1(ch)) { - atMoreIndented = true; - // except for the first content line (cf. Example 8.1) - state.result += common$6.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + /** + * Fast paths + */ - // End of more-indented block. - } else if (atMoreIndented) { - atMoreIndented = false; - state.result += common$6.repeat('\n', emptyLines + 1); + if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { + let backslashes = false; - // Just one line break - perceive as the same line. - } else if (emptyLines === 0) { - if (didReadContent) { // i.e. only if we have already read some scalar content. - state.result += ' '; - } + let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { + if (first === '\\') { + backslashes = true; + return m; + } - // Several line breaks - perceive as different lines. - } else { - state.result += common$6.repeat('\n', emptyLines); + 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); } - // Literal style: just add exact number of line breaks between content lines. - } else { - // Keep all line breaks except the header line break. - state.result += common$6.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } + if (first === '.') { + return DOT_LITERAL.repeat(chars.length); + } - didReadContent = true; - detectedIndent = true; - emptyLines = 0; - captureStart = state.position; + if (first === '*') { + if (esc) { + return esc + first + (rest ? star : ''); + } + return star; + } + return esc ? m : `\\${m}`; + }); - while (!is_EOL$1(ch) && (ch !== 0)) { - ch = state.input.charCodeAt(++state.position); + if (backslashes === true) { + if (opts.unescape === true) { + output = output.replace(/\\/g, ''); + } else { + output = output.replace(/\\+/g, m => { + return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : ''); + }); + } } - captureSegment$1(state, captureStart, state.position, false); - } - - return true; -} - -function readBlockSequence$1(state, nodeIndent) { - var _line, - _tag = state.tag, - _anchor = state.anchor, - _result = [], - following, - detected = false, - ch; + if (output === input && opts.contains === true) { + state.output = input; + return state; + } - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; + state.output = utils$5.wrapOutput(output, state, options); + return state; } - ch = state.input.charCodeAt(state.position); + /** + * Tokenize input until we reach end-of-string + */ - while (ch !== 0) { + while (!eos()) { + value = advance(); - if (ch !== 0x2D/* - */) { - break; + if (value === '\u0000') { + continue; } - following = state.input.charCodeAt(state.position + 1); - - if (!is_WS_OR_EOL$1(following)) { - break; - } + /** + * Escaped characters + */ - detected = true; - state.position++; + if (value === '\\') { + const next = peek(); - if (skipSeparationSpace$1(state, true, -1)) { - if (state.lineIndent <= nodeIndent) { - _result.push(null); - ch = state.input.charCodeAt(state.position); + if (next === '/' && opts.bash !== true) { continue; } - } - - _line = state.line; - composeNode$1(state, nodeIndent, CONTEXT_BLOCK_IN$1, false, true); - _result.push(state.result); - skipSeparationSpace$1(state, true, -1); - - ch = state.input.charCodeAt(state.position); - - if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError$2(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$1(state, nodeIndent, flowIndent) { - var following, - allowCompact, - _line, - _pos, - _tag = state.tag, - _anchor = state.anchor, - _result = {}, - overridableKeys = {}, - keyTag = null, - keyNode = null, - valueNode = null, - atExplicitKey = false, - detected = false, - ch; - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - ch = state.input.charCodeAt(state.position); + if (next === '.' || next === ';') { + continue; + } - while (ch !== 0) { - following = state.input.charCodeAt(state.position + 1); - _line = state.line; // Save the current line. - _pos = state.position; + if (!next) { + value += '\\'; + push({ type: 'text', value }); + continue; + } - // - // Explicit notation case. There are two separate blocks: - // first for the key (denoted by "?") and second for the value (denoted by ":") - // - if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL$1(following)) { + // collapse slashes to reduce potential for exploits + const match = /^\\+/.exec(remaining()); + let slashes = 0; - if (ch === 0x3F/* ? */) { - if (atExplicitKey) { - storeMappingPair$1(state, _result, overridableKeys, keyTag, keyNode, null); - keyTag = keyNode = valueNode = null; + if (match && match[0].length > 2) { + slashes = match[0].length; + state.index += slashes; + if (slashes % 2 !== 0) { + value += '\\'; } + } - detected = true; - atExplicitKey = true; - allowCompact = true; - - } else if (atExplicitKey) { - // i.e. 0x3A/* : */ === character after the explicit key. - atExplicitKey = false; - allowCompact = true; - + if (opts.unescape === true) { + value = advance() || ''; } else { - throwError$2(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + value += advance() || ''; } - state.position += 1; - ch = following; - - // - // Implicit notation case. Flow-style node as the key first, then ":", and the value. - // - } else if (composeNode$1(state, flowIndent, CONTEXT_FLOW_OUT$1, false, true)) { - - if (state.line === _line) { - ch = state.input.charCodeAt(state.position); + if (state.brackets === 0) { + push({ type: 'text', value }); + continue; + } + } - while (is_WHITE_SPACE$1(ch)) { - ch = state.input.charCodeAt(++state.position); - } + /** + * If we're inside a regex character class, continue + * until we reach the closing bracket. + */ - if (ch === 0x3A/* : */) { - ch = state.input.charCodeAt(++state.position); + 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 (!is_WS_OR_EOL$1(ch)) { - throwError$2(state, 'a whitespace character is expected after the key-value separator within a block mapping'); - } + if (inner.includes(':')) { + const idx = prev.value.lastIndexOf('['); + const pre = prev.value.slice(0, idx); + const rest = prev.value.slice(idx + 2); + const posix = POSIX_REGEX_SOURCE[rest]; + if (posix) { + prev.value = pre + posix; + state.backtrack = true; + advance(); - if (atExplicitKey) { - storeMappingPair$1(state, _result, overridableKeys, keyTag, keyNode, null); - keyTag = keyNode = valueNode = null; + if (!bos.output && tokens.indexOf(prev) === 1) { + bos.output = ONE_CHAR; + } + continue; + } } - - detected = true; - atExplicitKey = false; - allowCompact = false; - keyTag = state.tag; - keyNode = state.result; - - } else if (detected) { - throwError$2(state, 'can not read an implicit mapping pair; a colon is missed'); - - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. } - - } else if (detected) { - throwError$2(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; // Keep the result of `composeNode`. } - } else { - break; // Reading is done. Go to the epilogue. - } + if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) { + value = `\\${value}`; + } - // - // Common reading code for both explicit and implicit notations. - // - if (state.line === _line || state.lineIndent > nodeIndent) { - if (composeNode$1(state, nodeIndent, CONTEXT_BLOCK_OUT$1, true, allowCompact)) { - if (atExplicitKey) { - keyNode = state.result; - } else { - valueNode = state.result; - } + if (value === ']' && (prev.value === '[' || prev.value === '[^')) { + value = `\\${value}`; } - if (!atExplicitKey) { - storeMappingPair$1(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos); - keyTag = keyNode = valueNode = null; + if (opts.posix === true && value === '!' && prev.value === '[') { + value = '^'; } - skipSeparationSpace$1(state, true, -1); - ch = state.input.charCodeAt(state.position); + prev.value += value; + append({ value }); + continue; } - if (state.lineIndent > nodeIndent && (ch !== 0)) { - throwError$2(state, 'bad indentation of a mapping entry'); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - - // - // Epilogue. - // - - // Special case: last mapping's node contains only the key in explicit notation. - if (atExplicitKey) { - storeMappingPair$1(state, _result, overridableKeys, keyTag, keyNode, null); - } - - // Expose the resulting mapping. - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'mapping'; - state.result = _result; - } - - return detected; -} - -function readTagProperty$1(state) { - var _position, - isVerbatim = false, - isNamed = false, - tagHandle, - tagName, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x21/* ! */) return false; + /** + * If we're inside a quoted string, continue + * until we reach the closing double quote. + */ - if (state.tag !== null) { - throwError$2(state, 'duplication of a tag property'); - } + if (state.quotes === 1 && value !== '"') { + value = utils$5.escapeRegex(value); + prev.value += value; + append({ value }); + continue; + } - ch = state.input.charCodeAt(++state.position); + /** + * Double quotes + */ - if (ch === 0x3C/* < */) { - isVerbatim = true; - ch = state.input.charCodeAt(++state.position); + if (value === '"') { + state.quotes = state.quotes === 1 ? 0 : 1; + if (opts.keepQuotes === true) { + push({ type: 'text', value }); + } + continue; + } - } else if (ch === 0x21/* ! */) { - isNamed = true; - tagHandle = '!!'; - ch = state.input.charCodeAt(++state.position); + /** + * Parentheses + */ - } else { - tagHandle = '!'; - } + if (value === '(') { + increment('parens'); + push({ type: 'paren', value }); + continue; + } - _position = state.position; + if (value === ')') { + if (state.parens === 0 && opts.strictBrackets === true) { + throw new SyntaxError(syntaxError$1('opening', '(')); + } - if (isVerbatim) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && ch !== 0x3E/* > */); + const extglob = extglobs[extglobs.length - 1]; + if (extglob && state.parens === extglob.parens + 1) { + extglobClose(extglobs.pop()); + continue; + } - if (state.position < state.length) { - tagName = state.input.slice(_position, state.position); - ch = state.input.charCodeAt(++state.position); - } else { - throwError$2(state, 'unexpected end of the stream within a verbatim tag'); + push({ type: 'paren', value, output: state.parens ? ')' : '\\)' }); + decrement('parens'); + continue; } - } else { - while (ch !== 0 && !is_WS_OR_EOL$1(ch)) { - - if (ch === 0x21/* ! */) { - if (!isNamed) { - tagHandle = state.input.slice(_position - 1, state.position + 1); - if (!PATTERN_TAG_HANDLE$1.test(tagHandle)) { - throwError$2(state, 'named tag handle cannot contain such characters'); - } + /** + * Square brackets + */ - isNamed = true; - _position = state.position + 1; - } else { - throwError$2(state, 'tag suffix cannot contain exclamation marks'); + if (value === '[') { + if (opts.nobracket === true || !remaining().includes(']')) { + if (opts.nobracket !== true && opts.strictBrackets === true) { + throw new SyntaxError(syntaxError$1('closing', ']')); } - } - ch = state.input.charCodeAt(++state.position); - } - - tagName = state.input.slice(_position, state.position); + value = `\\${value}`; + } else { + increment('brackets'); + } - if (PATTERN_FLOW_INDICATORS$1.test(tagName)) { - throwError$2(state, 'tag suffix cannot contain flow indicator characters'); + push({ type: 'bracket', value }); + continue; } - } - if (tagName && !PATTERN_TAG_URI$1.test(tagName)) { - throwError$2(state, 'tag name cannot contain such characters: ' + tagName); - } + if (value === ']') { + if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) { + push({ type: 'text', value, output: `\\${value}` }); + continue; + } - if (isVerbatim) { - state.tag = tagName; + if (state.brackets === 0) { + if (opts.strictBrackets === true) { + throw new SyntaxError(syntaxError$1('opening', '[')); + } - } else if (_hasOwnProperty$5.call(state.tagMap, tagHandle)) { - state.tag = state.tagMap[tagHandle] + tagName; + push({ type: 'text', value, output: `\\${value}` }); + continue; + } - } else if (tagHandle === '!') { - state.tag = '!' + tagName; + decrement('brackets'); - } else if (tagHandle === '!!') { - state.tag = 'tag:yaml.org,2002:' + tagName; + const prevValue = prev.value.slice(1); + if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { + value = `/${value}`; + } - } else { - throwError$2(state, 'undeclared tag handle "' + tagHandle + '"'); - } + prev.value += value; + append({ value }); - return true; -} + // when literal brackets are explicitly disabled + // assume we should match with a regex character class + if (opts.literalBrackets === false || utils$5.hasRegexChars(prevValue)) { + continue; + } -function readAnchorProperty$1(state) { - var _position, - ch; + const escaped = utils$5.escapeRegex(prev.value); + state.output = state.output.slice(0, -prev.value.length); - ch = state.input.charCodeAt(state.position); + // when literal brackets are explicitly enabled + // assume we should escape the brackets to match literal characters + if (opts.literalBrackets === true) { + state.output += escaped; + prev.value = escaped; + continue; + } - if (ch !== 0x26/* & */) return false; + // when the user specifies nothing, try to match both + prev.value = `(${capture}${escaped}|${prev.value})`; + state.output += prev.value; + continue; + } - if (state.anchor !== null) { - throwError$2(state, 'duplication of an anchor property'); - } + /** + * Braces + */ - ch = state.input.charCodeAt(++state.position); - _position = state.position; + if (value === '{' && opts.nobrace !== true) { + increment('braces'); - while (ch !== 0 && !is_WS_OR_EOL$1(ch) && !is_FLOW_INDICATOR$1(ch)) { - ch = state.input.charCodeAt(++state.position); - } + const open = { + type: 'brace', + value, + output: '(', + outputIndex: state.output.length, + tokensIndex: state.tokens.length + }; - if (state.position === _position) { - throwError$2(state, 'name of an anchor node must contain at least one character'); - } + braces.push(open); + push(open); + continue; + } - state.anchor = state.input.slice(_position, state.position); - return true; -} + if (value === '}') { + const brace = braces[braces.length - 1]; -function readAlias$1(state) { - var _position, alias, - ch; + if (opts.nobrace === true || !brace) { + push({ type: 'text', value, output: value }); + continue; + } - ch = state.input.charCodeAt(state.position); + let output = ')'; - if (ch !== 0x2A/* * */) return false; + if (brace.dots === true) { + const arr = tokens.slice(); + const range = []; - ch = state.input.charCodeAt(++state.position); - _position = state.position; + for (let i = arr.length - 1; i >= 0; i--) { + tokens.pop(); + if (arr[i].type === 'brace') { + break; + } + if (arr[i].type !== 'dots') { + range.unshift(arr[i].value); + } + } - while (ch !== 0 && !is_WS_OR_EOL$1(ch) && !is_FLOW_INDICATOR$1(ch)) { - ch = state.input.charCodeAt(++state.position); - } + output = expandRange(range, opts); + state.backtrack = true; + } - if (state.position === _position) { - throwError$2(state, 'name of an alias node must contain at least one character'); - } + 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); + } + } - alias = state.input.slice(_position, state.position); + push({ type: 'brace', value, output }); + decrement('braces'); + braces.pop(); + continue; + } - if (!_hasOwnProperty$5.call(state.anchorMap, alias)) { - throwError$2(state, 'unidentified alias "' + alias + '"'); - } + /** + * Pipes + */ - state.result = state.anchorMap[alias]; - skipSeparationSpace$1(state, true, -1); - return true; -} + if (value === '|') { + if (extglobs.length > 0) { + extglobs[extglobs.length - 1].conditions++; + } + push({ type: 'text', value }); + continue; + } -function composeNode$1(state, parentIndent, nodeContext, allowToSeek, allowCompact) { - var allowBlockStyles, - allowBlockScalars, - allowBlockCollections, - indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; + if (value === '/') { + // if the beginning of the glob is "./", advance the start + // to the current index, and don't add the "./" characters + // to the state. This greatly simplifies lookbehinds when + // checking for BOS characters like "!" and "." (not "./") + if (prev.type === 'dot' && state.index === state.start + 1) { + state.start = state.index + 1; + state.consumed = ''; + state.output = ''; + tokens.pop(); + prev = bos; // reset "prev" to the first token + continue; } + + push({ type: 'slash', value, output: SLASH_LITERAL }); + continue; } - } - if (indentStatus === 1) { - while (readTagProperty$1(state) || readAnchorProperty$1(state)) { - if (skipSeparationSpace$1(state, true, -1)) { - atNewLine = true; - allowBlockCollections = allowBlockStyles; + /** + * Dots + */ - if (state.lineIndent > parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } else { - allowBlockCollections = false; + 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 (allowBlockCollections) { - allowBlockCollections = atNewLine || allowCompact; - } + if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') { + push({ type: 'text', value, output: DOT_LITERAL }); + continue; + } - if (indentStatus === 1 || CONTEXT_BLOCK_OUT$1 === nodeContext) { - if (CONTEXT_FLOW_IN$1 === nodeContext || CONTEXT_FLOW_OUT$1 === nodeContext) { - flowIndent = parentIndent; - } else { - flowIndent = parentIndent + 1; + push({ type: 'dot', value, output: DOT_LITERAL }); + continue; } - blockIndent = state.position - state.lineStart; - - if (indentStatus === 1) { - if (allowBlockCollections && - (readBlockSequence$1(state, blockIndent) || - readBlockMapping$1(state, blockIndent, flowIndent)) || - readFlowCollection$1(state, flowIndent)) { - hasContent = true; - } else { - if ((allowBlockScalars && readBlockScalar$1(state, flowIndent)) || - readSingleQuotedScalar$1(state, flowIndent) || - readDoubleQuotedScalar$1(state, flowIndent)) { - hasContent = true; - - } else if (readAlias$1(state)) { - hasContent = true; + /** + * Question marks + */ - if (state.tag !== null || state.anchor !== null) { - throwError$2(state, 'alias node should not have any properties'); - } + if (value === '?') { + const isGroup = prev && prev.value === '('; + if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { + extglobOpen('qmark', value); + continue; + } - } else if (readPlainScalar$1(state, flowIndent, CONTEXT_FLOW_IN$1 === nodeContext)) { - hasContent = true; + if (prev && prev.type === 'paren') { + const next = peek(); + let output = value; - if (state.tag === null) { - state.tag = '?'; - } + if (next === '<' && !utils$5.supportsLookbehinds()) { + throw new Error('Node.js v10 or higher is required for regex lookbehinds'); } - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; + if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) { + output = `\\${value}`; } + + push({ type: 'text', value, output }); + continue; } - } else if (indentStatus === 0) { - // Special case: block sequences are allowed to have same indentation level as the parent. - // http://www.yaml.org/spec/1.2/spec.html#id2799784 - hasContent = allowBlockCollections && readBlockSequence$1(state, blockIndent); - } - } - if (state.tag !== null && state.tag !== '!') { - if (state.tag === '?') { - // Implicit resolving is not allowed for non-scalar types, and '?' - // non-specific tag is only automatically assigned to plain scalars. - // - // We only need to check kind conformity in case user explicitly assigns '?' - // tag, for example like this: "! [0]" - // - if (state.result !== null && state.kind !== 'scalar') { - throwError$2(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) { + push({ type: 'qmark', value, output: QMARK_NO_DOT }); + continue; } - for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { - type = state.implicitTypes[typeIndex]; + push({ type: 'qmark', value, output: QMARK }); + continue; + } - if (type.resolve(state.result)) { // `state.result` updated in resolver if matched - state.result = type.construct(state.result); - state.tag = type.tag; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - break; - } - } - } else if (_hasOwnProperty$5.call(state.typeMap[state.kind || 'fallback'], state.tag)) { - type = state.typeMap[state.kind || 'fallback'][state.tag]; + /** + * Exclamation + */ - if (state.result !== null && type.kind !== state.kind) { - throwError$2(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + if (value === '!') { + if (opts.noextglob !== true && peek() === '(') { + if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) { + extglobOpen('negate', value); + continue; + } } - if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched - throwError$2(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); - } else { - state.result = type.construct(state.result); - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } + if (opts.nonegate !== true && state.index === 0) { + negate(); + continue; } - } else { - throwError$2(state, 'unknown tag !<' + state.tag + '>'); } - } - - if (state.listener !== null) { - state.listener('close', state); - } - return state.tag !== null || state.anchor !== null || hasContent; -} -function readDocument$1(state) { - var documentStart = state.position, - _position, - directiveName, - directiveArgs, - hasDirectives = false, - ch; + /** + * Plus + */ - state.version = null; - state.checkLineBreaks = state.legacy; - state.tagMap = {}; - state.anchorMap = {}; + if (value === '+') { + if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { + extglobOpen('plus', value); + continue; + } - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - skipSeparationSpace$1(state, true, -1); + if ((prev && prev.value === '(') || opts.regex === false) { + push({ type: 'plus', value, output: PLUS_LITERAL }); + continue; + } - ch = state.input.charCodeAt(state.position); + if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) { + push({ type: 'plus', value }); + continue; + } - if (state.lineIndent > 0 || ch !== 0x25/* % */) { - break; + push({ type: 'plus', value: PLUS_LITERAL }); + continue; } - hasDirectives = true; - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL$1(ch)) { - ch = state.input.charCodeAt(++state.position); - } + /** + * Plain text + */ - directiveName = state.input.slice(_position, state.position); - directiveArgs = []; + if (value === '@') { + if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { + push({ type: 'at', extglob: true, value, output: '' }); + continue; + } - if (directiveName.length < 1) { - throwError$2(state, 'directive name must not be less than one character in length'); + push({ type: 'text', value }); + continue; } - while (ch !== 0) { - while (is_WHITE_SPACE$1(ch)) { - ch = state.input.charCodeAt(++state.position); - } + /** + * Plain text + */ - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && !is_EOL$1(ch)); - break; + if (value !== '*') { + if (value === '$' || value === '^') { + value = `\\${value}`; } - if (is_EOL$1(ch)) break; - - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL$1(ch)) { - ch = state.input.charCodeAt(++state.position); + const match = REGEX_NON_SPECIAL_CHARS.exec(remaining()); + if (match) { + value += match[0]; + state.index += match[0].length; } - directiveArgs.push(state.input.slice(_position, state.position)); + push({ type: 'text', value }); + continue; } - if (ch !== 0) readLineBreak$1(state); - - if (_hasOwnProperty$5.call(directiveHandlers$1, directiveName)) { - directiveHandlers$1[directiveName](state, directiveName, directiveArgs); - } else { - throwWarning$1(state, 'unknown document directive "' + directiveName + '"'); + /** + * 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; } - } - skipSeparationSpace$1(state, true, -1); + let rest = remaining(); + if (opts.noextglob !== true && /^\([^?]/.test(rest)) { + extglobOpen('star', value); + continue; + } - if (state.lineIndent === 0 && - state.input.charCodeAt(state.position) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { - state.position += 3; - skipSeparationSpace$1(state, true, -1); + if (prev.type === 'star') { + if (opts.noglobstar === true) { + consume(value); + continue; + } - } else if (hasDirectives) { - throwError$2(state, 'directives end mark is expected'); - } + 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'); - composeNode$1(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT$1, false, true); - skipSeparationSpace$1(state, true, -1); + if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) { + push({ type: 'star', value, output: '' }); + continue; + } - if (state.checkLineBreaks && - PATTERN_NON_ASCII_LINE_BREAKS$1.test(state.input.slice(documentStart, state.position))) { - throwWarning$1(state, 'non-ASCII line breaks are interpreted as content'); - } + 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; + } - state.documents.push(state.result); + // strip consecutive `/**/` + 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 (state.position === state.lineStart && testDocumentSeparator$1(state)) { + 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}`; - if (state.input.charCodeAt(state.position) === 0x2E/* . */) { - state.position += 3; - skipSeparationSpace$1(state, true, -1); - } - return; - } + 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 (state.position < (state.length - 1)) { - throwError$2(state, 'end of the stream or a document separator is expected'); - } else { - return; - } -} + 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}`; -function loadDocuments$1(input, options) { - input = String(input); - options = options || {}; + prev.type = 'globstar'; + prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; + prev.value += value; - if (input.length !== 0) { + state.output += prior.output + prev.output; + state.globstar = true; - // Add tailing `\n` if not exists - if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && - input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { - input += '\n'; + 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; + } + + // remove single star from output + state.output = state.output.slice(0, -prev.output.length); + + // reset previous token to globstar + prev.type = 'globstar'; + prev.output = globstar(opts); + prev.value += value; + + // reset output with globstar + state.output += prev.output; + state.globstar = true; + consume(value); + continue; } - // Strip BOM - if (input.charCodeAt(0) === 0xFEFF) { - input = input.slice(1); + 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; } - } - var state = new State$3(input, options); + if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { + token.output = value; + push(token); + continue; + } - var nullpos = input.indexOf('\0'); + 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; - if (nullpos !== -1) { - state.position = nullpos; - throwError$2(state, 'null byte is not allowed in input'); - } + } else if (opts.dot === true) { + state.output += NO_DOTS_SLASH; + prev.output += NO_DOTS_SLASH; - // Use 0 as string terminator. That significantly simplifies bounds check. - state.input += '\0'; + } else { + state.output += nodot; + prev.output += nodot; + } - while (state.input.charCodeAt(state.position) === 0x20/* Space */) { - state.lineIndent += 1; - state.position += 1; + if (peek() !== '*') { + state.output += ONE_CHAR; + prev.output += ONE_CHAR; + } + } + + push(token); } - while (state.position < (state.length - 1)) { - readDocument$1(state); + while (state.brackets > 0) { + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ']')); + state.output = utils$5.escapeLast(state.output, '['); + decrement('brackets'); } - return state.documents; -} + while (state.parens > 0) { + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ')')); + state.output = utils$5.escapeLast(state.output, '('); + decrement('parens'); + } + while (state.braces > 0) { + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', '}')); + state.output = utils$5.escapeLast(state.output, '{'); + decrement('braces'); + } -function loadAll$2(input, iterator, options) { - if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { - options = iterator; - iterator = null; + if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { + push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } - var documents = loadDocuments$1(input, options); + // rebuild the output if we had to backtrack at any point + if (state.backtrack === true) { + state.output = ''; - if (typeof iterator !== 'function') { - return documents; - } + for (const token of state.tokens) { + state.output += token.output != null ? token.output : token.value; - for (var index = 0, length = documents.length; index < length; index += 1) { - iterator(documents[index]); + if (token.suffix) { + state.output += token.suffix; + } + } } -} + return state; +}; -function load$5(input, options) { - var documents = loadDocuments$1(input, options); +/** + * 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. + */ - if (documents.length === 0) { - /*eslint-disable no-undefined*/ - return undefined; - } else if (documents.length === 1) { - return documents[0]; +parse$e.fastpaths = (input, options) => { + const opts = { ...options }; + const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$4, opts.maxLength) : MAX_LENGTH$4; + const len = input.length; + if (len > max) { + throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); } - throw new YAMLException$3('expected a single document in the stream, but found more'); -} + input = REPLACEMENTS[input] || input; + const win32 = utils$5.isWindows(options); -function safeLoadAll$1(input, iterator, options) { - if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') { - options = iterator; - iterator = null; - } + // create constants based on platform, for windows or posix + const { + DOT_LITERAL, + SLASH_LITERAL, + ONE_CHAR, + DOTS_SLASH, + NO_DOT, + NO_DOTS, + NO_DOTS_SLASH, + STAR, + START_ANCHOR + } = constants$4.globChars(win32); - return loadAll$2(input, iterator, common$6.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options)); -} + 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})`; + } -function safeLoad$1(input, options) { - return load$5(input, common$6.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options)); -} + const globstar = (opts) => { + if (opts.noglobstar === true) return star; + return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; + }; + const create = str => { + switch (str) { + case '*': + return `${nodot}${ONE_CHAR}${star}`; -loader$2.loadAll = loadAll$2; -loader$2.load = load$5; -loader$2.safeLoadAll = safeLoadAll$1; -loader$2.safeLoad = safeLoad$1; + case '.*': + return `${DOT_LITERAL}${ONE_CHAR}${star}`; -var dumper$2 = {}; + case '*.*': + return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; -/*eslint-disable no-use-before-define*/ + case '*/*': + return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`; -var common$5 = common$b; -var YAMLException$2 = exception$1; -var DEFAULT_FULL_SCHEMA = default_full; -var DEFAULT_SAFE_SCHEMA = default_safe; - -var _toString$3 = Object.prototype.toString; -var _hasOwnProperty$4 = Object.prototype.hasOwnProperty; - -var CHAR_TAB$1 = 0x09; /* Tab */ -var CHAR_LINE_FEED$1 = 0x0A; /* LF */ -var CHAR_CARRIAGE_RETURN$1 = 0x0D; /* CR */ -var CHAR_SPACE$1 = 0x20; /* Space */ -var CHAR_EXCLAMATION$1 = 0x21; /* ! */ -var CHAR_DOUBLE_QUOTE$2 = 0x22; /* " */ -var CHAR_SHARP$1 = 0x23; /* # */ -var CHAR_PERCENT$1 = 0x25; /* % */ -var CHAR_AMPERSAND$1 = 0x26; /* & */ -var CHAR_SINGLE_QUOTE$2 = 0x27; /* ' */ -var CHAR_ASTERISK$2 = 0x2A; /* * */ -var CHAR_COMMA$3 = 0x2C; /* , */ -var CHAR_MINUS$1 = 0x2D; /* - */ -var CHAR_COLON$1 = 0x3A; /* : */ -var CHAR_EQUALS$1 = 0x3D; /* = */ -var CHAR_GREATER_THAN$1 = 0x3E; /* > */ -var CHAR_QUESTION$1 = 0x3F; /* ? */ -var CHAR_COMMERCIAL_AT$1 = 0x40; /* @ */ -var CHAR_LEFT_SQUARE_BRACKET$3 = 0x5B; /* [ */ -var CHAR_RIGHT_SQUARE_BRACKET$3 = 0x5D; /* ] */ -var CHAR_GRAVE_ACCENT$1 = 0x60; /* ` */ -var CHAR_LEFT_CURLY_BRACKET$1 = 0x7B; /* { */ -var CHAR_VERTICAL_LINE$1 = 0x7C; /* | */ -var CHAR_RIGHT_CURLY_BRACKET$1 = 0x7D; /* } */ - -var ESCAPE_SEQUENCES$1 = {}; - -ESCAPE_SEQUENCES$1[0x00] = '\\0'; -ESCAPE_SEQUENCES$1[0x07] = '\\a'; -ESCAPE_SEQUENCES$1[0x08] = '\\b'; -ESCAPE_SEQUENCES$1[0x09] = '\\t'; -ESCAPE_SEQUENCES$1[0x0A] = '\\n'; -ESCAPE_SEQUENCES$1[0x0B] = '\\v'; -ESCAPE_SEQUENCES$1[0x0C] = '\\f'; -ESCAPE_SEQUENCES$1[0x0D] = '\\r'; -ESCAPE_SEQUENCES$1[0x1B] = '\\e'; -ESCAPE_SEQUENCES$1[0x22] = '\\"'; -ESCAPE_SEQUENCES$1[0x5C] = '\\\\'; -ESCAPE_SEQUENCES$1[0x85] = '\\N'; -ESCAPE_SEQUENCES$1[0xA0] = '\\_'; -ESCAPE_SEQUENCES$1[0x2028] = '\\L'; -ESCAPE_SEQUENCES$1[0x2029] = '\\P'; - -var DEPRECATED_BOOLEANS_SYNTAX$1 = [ - 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', - 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' -]; + case '**': + return nodot + globstar(opts); -function compileStyleMap$1(schema, map) { - var result, keys, index, length, tag, style, type; + case '**/*': + return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`; - if (map === null) return {}; + case '**/*.*': + return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; - result = {}; - keys = Object.keys(map); + case '**/.*': + return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`; - for (index = 0, length = keys.length; index < length; index += 1) { - tag = keys[index]; - style = String(map[tag]); + default: { + const match = /^(.*?)\.(\w+)$/.exec(str); + if (!match) return; - if (tag.slice(0, 2) === '!!') { - tag = 'tag:yaml.org,2002:' + tag.slice(2); - } - type = schema.compiledTypeMap['fallback'][tag]; + const source = create(match[1]); + if (!source) return; - if (type && _hasOwnProperty$4.call(type.styleAliases, style)) { - style = type.styleAliases[style]; + return source + DOT_LITERAL + match[2]; + } } + }; - result[tag] = style; + const output = utils$5.removePrefix(input, state); + let source = create(output); + + if (source && opts.strictSlashes !== true) { + source += `${SLASH_LITERAL}?`; } - return result; -} + return source; +}; -function encodeHex$1(character) { - var string, handle, length; +var parse_1$2 = parse$e; - string = character.toString(16).toUpperCase(); +const path$9 = path__default['default']; +const scan = scan_1; +const parse$d = parse_1$2; +const utils$4 = utils$7; +const constants$3 = constants$5; +const isObject$3 = val => val && typeof val === 'object' && !Array.isArray(val); - if (character <= 0xFF) { - handle = 'x'; - length = 2; - } else if (character <= 0xFFFF) { - handle = 'u'; - length = 4; - } else if (character <= 0xFFFFFFFF) { - handle = 'U'; - length = 8; - } else { - throw new YAMLException$2('code point within a string may not be greater than 0xFFFFFFFF'); +/** + * 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$3 = (glob, options, returnState = false) => { + if (Array.isArray(glob)) { + const fns = glob.map(input => picomatch$3(input, options, returnState)); + const arrayMatcher = str => { + for (const isMatch of fns) { + const state = isMatch(str); + if (state) return state; + } + return false; + }; + return arrayMatcher; } - return '\\' + handle + common$5.repeat('0', length - string.length) + string; -} + const isState = isObject$3(glob) && glob.tokens && glob.input; -function State$2(options) { - this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; - this.indent = Math.max(1, (options['indent'] || 2)); - this.noArrayIndent = options['noArrayIndent'] || false; - this.skipInvalid = options['skipInvalid'] || false; - this.flowLevel = (common$5.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); - this.styleMap = compileStyleMap$1(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; + if (glob === '' || (typeof glob !== 'string' && !isState)) { + throw new TypeError('Expected pattern to be a non-empty string'); + } - this.implicitTypes = this.schema.compiledImplicit; - this.explicitTypes = this.schema.compiledExplicit; + const opts = options || {}; + const posix = utils$4.isWindows(options); + const regex = isState + ? picomatch$3.compileRe(glob, options) + : picomatch$3.makeRe(glob, options, false, true); - this.tag = null; - this.result = ''; + const state = regex.state; + delete regex.state; - this.duplicates = []; - this.usedDuplicates = null; -} + let isIgnored = () => false; + if (opts.ignore) { + const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null }; + isIgnored = picomatch$3(opts.ignore, ignoreOpts, returnState); + } -// Indents every line in a string. Empty lines (\n only) are not indented. -function indentString$1(string, spaces) { - var ind = common$5.repeat(' ', spaces), - position = 0, - next = -1, - result = '', - line, - length = string.length; + const matcher = (input, returnObject = false) => { + const { isMatch, match, output } = picomatch$3.test(input, regex, options, { glob, posix }); + const result = { glob, state, regex, posix, input, output, match, isMatch }; - 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 (typeof opts.onResult === 'function') { + opts.onResult(result); } - if (line.length && line !== '\n') result += ind; + if (isMatch === false) { + result.isMatch = false; + return returnObject ? result : false; + } - result += line; - } + if (isIgnored(input)) { + if (typeof opts.onIgnore === 'function') { + opts.onIgnore(result); + } + result.isMatch = false; + return returnObject ? result : false; + } - return result; -} + if (typeof opts.onMatch === 'function') { + opts.onMatch(result); + } + return returnObject ? result : true; + }; -function generateNextLine$1(state, level) { - return '\n' + common$5.repeat(' ', state.indent * level); -} + if (returnState) { + matcher.state = state; + } -function testImplicitResolving$1(state, str) { - var index, length, type; + return matcher; +}; - for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { - type = state.implicitTypes[index]; +/** + * 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 + */ - if (type.resolve(str)) { - return true; - } +picomatch$3.test = (input, regex, options, { glob, posix } = {}) => { + if (typeof input !== 'string') { + throw new TypeError('Expected input to be a string'); } - return false; -} - -// [33] s-white ::= s-space | s-tab -function isWhitespace$1(c) { - return c === CHAR_SPACE$1 || c === CHAR_TAB$1; -} + if (input === '') { + return { isMatch: false, output: '' }; + } -// Returns true if the character can be printed without escaping. -// From YAML 1.2: "any allowed characters known to be non-printable -// should also be escaped. [However,] This isn’t mandatory" -// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. -function isPrintable$1(c) { - return (0x00020 <= c && c <= 0x00007E) - || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) - || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */) - || (0x10000 <= c && c <= 0x10FFFF); -} + const opts = options || {}; + const format = opts.format || (posix ? utils$4.toPosixSlashes : null); + let match = input === glob; + let output = (match && format) ? format(input) : input; -// [34] ns-char ::= nb-char - s-white -// [27] nb-char ::= c-printable - b-char - c-byte-order-mark -// [26] b-char ::= b-line-feed | b-carriage-return -// [24] b-line-feed ::= #xA /* LF */ -// [25] b-carriage-return ::= #xD /* CR */ -// [3] c-byte-order-mark ::= #xFEFF -function isNsChar(c) { - return isPrintable$1(c) && !isWhitespace$1(c) - // byte-order-mark - && c !== 0xFEFF - // b-char - && c !== CHAR_CARRIAGE_RETURN$1 - && c !== CHAR_LINE_FEED$1; -} - -// Simplified test for values allowed after the first character in plain style. -function isPlainSafe$1(c, prev) { - // Uses a subset of nb-char - c-flow-indicator - ":" - "#" - // where nb-char ::= c-printable - b-char - c-byte-order-mark. - return isPrintable$1(c) && c !== 0xFEFF - // - c-flow-indicator - && c !== CHAR_COMMA$3 - && c !== CHAR_LEFT_SQUARE_BRACKET$3 - && c !== CHAR_RIGHT_SQUARE_BRACKET$3 - && c !== CHAR_LEFT_CURLY_BRACKET$1 - && c !== CHAR_RIGHT_CURLY_BRACKET$1 - // - ":" - "#" - // /* An ns-char preceding */ "#" - && c !== CHAR_COLON$1 - && ((c !== CHAR_SHARP$1) || (prev && isNsChar(prev))); -} + if (match === false) { + output = format ? format(input) : input; + match = output === glob; + } -// Simplified test for values allowed as the first character in plain style. -function isPlainSafeFirst$1(c) { - // Uses a subset of ns-char - c-indicator - // where ns-char = nb-char - s-white. - return isPrintable$1(c) && c !== 0xFEFF - && !isWhitespace$1(c) // - s-white - // - (c-indicator ::= - // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” - && c !== CHAR_MINUS$1 - && c !== CHAR_QUESTION$1 - && c !== CHAR_COLON$1 - && c !== CHAR_COMMA$3 - && c !== CHAR_LEFT_SQUARE_BRACKET$3 - && c !== CHAR_RIGHT_SQUARE_BRACKET$3 - && c !== CHAR_LEFT_CURLY_BRACKET$1 - && c !== CHAR_RIGHT_CURLY_BRACKET$1 - // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” - && c !== CHAR_SHARP$1 - && c !== CHAR_AMPERSAND$1 - && c !== CHAR_ASTERISK$2 - && c !== CHAR_EXCLAMATION$1 - && c !== CHAR_VERTICAL_LINE$1 - && c !== CHAR_EQUALS$1 - && c !== CHAR_GREATER_THAN$1 - && c !== CHAR_SINGLE_QUOTE$2 - && c !== CHAR_DOUBLE_QUOTE$2 - // | “%” | “@” | “`”) - && c !== CHAR_PERCENT$1 - && c !== CHAR_COMMERCIAL_AT$1 - && c !== CHAR_GRAVE_ACCENT$1; -} + if (match === false || opts.capture === true) { + if (opts.matchBase === true || opts.basename === true) { + match = picomatch$3.matchBase(input, regex, options, posix); + } else { + match = regex.exec(output); + } + } -// Determines whether block indentation indicator is required. -function needIndentIndicator$1(string) { - var leadingSpaceRe = /^\n* /; - return leadingSpaceRe.test(string); -} - -var STYLE_PLAIN$1 = 1, - STYLE_SINGLE$1 = 2, - STYLE_LITERAL$1 = 3, - STYLE_FOLDED$1 = 4, - STYLE_DOUBLE$1 = 5; - -// Determines which scalar styles are possible and returns the preferred style. -// lineWidth = -1 => no limit. -// Pre-conditions: str.length > 0. -// Post-conditions: -// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. -// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). -// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). -function chooseScalarStyle$1(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) { - var i; - var char, prev_char; - var hasLineBreak = false; - var hasFoldableLine = false; // only checked if shouldTrackWidth - var shouldTrackWidth = lineWidth !== -1; - var previousLineBreak = -1; // count the first line correctly - var plain = isPlainSafeFirst$1(string.charCodeAt(0)) - && !isWhitespace$1(string.charCodeAt(string.length - 1)); - - if (singleLineOnly) { - // Case: no block styles. - // Check for disallowed characters to rule out plain and single. - for (i = 0; i < string.length; i++) { - char = string.charCodeAt(i); - if (!isPrintable$1(char)) { - return STYLE_DOUBLE$1; - } - prev_char = i > 0 ? string.charCodeAt(i - 1) : null; - plain = plain && isPlainSafe$1(char, prev_char); - } - } else { - // Case: block styles permitted. - for (i = 0; i < string.length; i++) { - char = string.charCodeAt(i); - if (char === CHAR_LINE_FEED$1) { - hasLineBreak = true; - // Check if any line can be folded. - if (shouldTrackWidth) { - hasFoldableLine = hasFoldableLine || - // Foldable line = too long, and not more-indented. - (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' '); - previousLineBreak = i; - } - } else if (!isPrintable$1(char)) { - return STYLE_DOUBLE$1; - } - prev_char = i > 0 ? string.charCodeAt(i - 1) : null; - plain = plain && isPlainSafe$1(char, prev_char); - } - // in case the end is missing a \n - hasFoldableLine = hasFoldableLine || (shouldTrackWidth && - (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' ')); - } - // Although every style can represent \n without escaping, prefer block styles - // for multiline, since they're more readable and they don't add empty lines. - // Also prefer folding a super-long line. - if (!hasLineBreak && !hasFoldableLine) { - // Strings interpretable as another type have to be quoted; - // e.g. the string 'true' vs. the boolean true. - return plain && !testAmbiguousType(string) - ? STYLE_PLAIN$1 : STYLE_SINGLE$1; - } - // Edge case: block indentation indicator can only have one digit. - if (indentPerLevel > 9 && needIndentIndicator$1(string)) { - return STYLE_DOUBLE$1; - } - // At this point we know block styles are valid. - // Prefer literal style unless we want to fold. - return hasFoldableLine ? STYLE_FOLDED$1 : STYLE_LITERAL$1; -} - -// Note: line breaking/folding is implemented for only the folded style. -// NB. We drop the last trailing newline (if any) of a returned block scalar -// since the dumper adds its own newline. This always works: -// • No ending newline => unaffected; already using strip "-" chomping. -// • Ending newline => removed then restored. -// Importantly, this keeps the "+" chomp indicator from gaining an extra line. -function writeScalar$1(state, string, level, iskey) { - state.dump = (function () { - if (string.length === 0) { - return "''"; - } - if (!state.noCompatMode && - DEPRECATED_BOOLEANS_SYNTAX$1.indexOf(string) !== -1) { - return "'" + string + "'"; - } + return { isMatch: Boolean(match), match, output }; +}; - var indent = state.indent * Math.max(1, level); // no 0-indent scalars - // As indentation gets deeper, let the width decrease monotonically - // to the lower bound min(state.lineWidth, 40). - // Note that this implies - // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. - // state.lineWidth > 40 + state.indent: width decreases until the lower bound. - // This behaves better than a constant minimum width which disallows narrower options, - // or an indent threshold which causes the width to suddenly increase. - var lineWidth = state.lineWidth === -1 - ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); +/** + * 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 + */ - // Without knowing if keys are implicit/explicit, assume implicit for safety. - var singleLineOnly = iskey - // No block styles in flow mode. - || (state.flowLevel > -1 && level >= state.flowLevel); - function testAmbiguity(string) { - return testImplicitResolving$1(state, string); - } +picomatch$3.matchBase = (input, glob, options, posix = utils$4.isWindows(options)) => { + const regex = glob instanceof RegExp ? glob : picomatch$3.makeRe(glob, options); + return regex.test(path$9.basename(input)); +}; - switch (chooseScalarStyle$1(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) { - case STYLE_PLAIN$1: - return string; - case STYLE_SINGLE$1: - return "'" + string.replace(/'/g, "''") + "'"; - case STYLE_LITERAL$1: - return '|' + blockHeader$1(string, state.indent) - + dropEndingNewline$1(indentString$1(string, indent)); - case STYLE_FOLDED$1: - return '>' + blockHeader$1(string, state.indent) - + dropEndingNewline$1(indentString$1(foldString$1(string, lineWidth), indent)); - case STYLE_DOUBLE$1: - return '"' + escapeString$1(string) + '"'; - default: - throw new YAMLException$2('impossible error: invalid scalar style'); - } - }()); -} +/** + * 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 + */ -// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. -function blockHeader$1(string, indentPerLevel) { - var indentIndicator = needIndentIndicator$1(string) ? String(indentPerLevel) : ''; +picomatch$3.isMatch = (str, patterns, options) => picomatch$3(patterns, options)(str); - // note the special case: the string '\n' counts as a "trailing" empty line. - var clip = string[string.length - 1] === '\n'; - var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); - var chomp = keep ? '+' : (clip ? '' : '-'); +/** + * 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 + */ - return indentIndicator + chomp + '\n'; -} +picomatch$3.parse = (pattern, options) => { + if (Array.isArray(pattern)) return pattern.map(p => picomatch$3.parse(p, options)); + return parse$d(pattern, { ...options, fastpaths: false }); +}; -// (See the note for writeScalar.) -function dropEndingNewline$1(string) { - return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; -} +/** + * 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 + */ -// Note: a long line without a suitable break point will exceed the width limit. -// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. -function foldString$1(string, width) { - // In folded style, $k$ consecutive newlines output as $k+1$ newlines— - // unless they're before or after a more-indented line, or at the very - // beginning or end, in which case $k$ maps to $k$. - // Therefore, parse each chunk as newline(s) followed by a content line. - var lineRe = /(\n+)([^\n]*)/g; +picomatch$3.scan = (input, options) => scan(input, options); - // first line (possibly an empty line) - var result = (function () { - var nextLF = string.indexOf('\n'); - nextLF = nextLF !== -1 ? nextLF : string.length; - lineRe.lastIndex = nextLF; - return foldLine$1(string.slice(0, nextLF), width); - }()); - // If we haven't reached the first content line yet, don't add an extra \n. - var prevMoreIndented = string[0] === '\n' || string[0] === ' '; - var moreIndented; +/** + * 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` + * @return {RegExp} Returns a regex created from the given pattern. + * @api public + */ - // rest of the lines - var match; - while ((match = lineRe.exec(string))) { - var prefix = match[1], line = match[2]; - moreIndented = (line[0] === ' '); - result += prefix - + (!prevMoreIndented && !moreIndented && line !== '' - ? '\n' : '') - + foldLine$1(line, width); - prevMoreIndented = moreIndented; +picomatch$3.compileRe = (parsed, options, returnOutput = false, returnState = false) => { + if (returnOutput === true) { + return parsed.output; } - return result; -} - -// Greedy line breaking. -// Picks the longest line under the limit each time, -// otherwise settles for the shortest line over the limit. -// NB. More-indented lines *cannot* be folded, as that would add an extra \n. -function foldLine$1(line, width) { - if (line === '' || line[0] === ' ') return line; - - // Since a more-indented line adds a \n, breaks can't be followed by a space. - var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. - var match; - // start is an inclusive index. end, curr, and next are exclusive. - var start = 0, end, curr = 0, next = 0; - var result = ''; + const opts = options || {}; + const prepend = opts.contains ? '' : '^'; + const append = opts.contains ? '' : '$'; - // Invariants: 0 <= start <= length-1. - // 0 <= curr <= next <= max(0, length-2). curr - start <= width. - // Inside the loop: - // A match implies length >= 2, so curr and next are <= length-2. - while ((match = breakRe.exec(line))) { - next = match.index; - // maintain invariant: curr - start <= width - if (next - start > width) { - end = (curr > start) ? curr : next; // derive end <= length-2 - result += '\n' + line.slice(start, end); - // skip the space that was output as \n - start = end + 1; // derive start <= length-1 - } - curr = next; + let source = `${prepend}(?:${parsed.output})${append}`; + if (parsed && parsed.negated === true) { + source = `^(?!${source}).*$`; } - // By the invariants, start <= length-1, so there is something left over. - // It is either the whole string or a part starting from non-whitespace. - result += '\n'; - // Insert a break if the remainder is too long and there is a break available. - if (line.length - start > width && curr > start) { - result += line.slice(start, curr) + '\n' + line.slice(curr + 1); - } else { - result += line.slice(start); + const regex = picomatch$3.toRegex(source, options); + if (returnState === true) { + regex.state = parsed; } - return result.slice(1); // drop extra \n joiner -} - -// Escapes a double-quoted string. -function escapeString$1(string) { - var result = ''; - var char, nextChar; - var escapeSeq; + return regex; +}; - for (var i = 0; i < string.length; i++) { - char = string.charCodeAt(i); - // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates"). - if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) { - nextChar = string.charCodeAt(i + 1); - if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) { - // Combine the surrogate pair and store it escaped. - result += encodeHex$1((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000); - // Advance index one extra since we already used that char here. - i++; continue; - } - } - escapeSeq = ESCAPE_SEQUENCES$1[char]; - result += !escapeSeq && isPrintable$1(char) - ? string[i] - : escapeSeq || encodeHex$1(char); +picomatch$3.makeRe = (input, options, returnOutput = false, returnState = false) => { + if (!input || typeof input !== 'string') { + throw new TypeError('Expected a non-empty string'); } - return result; -} - -function writeFlowSequence$1(state, level, object) { - var _result = '', - _tag = state.tag, - index, - length; + const opts = options || {}; + let parsed = { negated: false, fastpaths: true }; + let prefix = ''; + let output; - for (index = 0, length = object.length; index < length; index += 1) { - // Write only valid elements. - if (writeNode$1(state, level, object[index], false, false)) { - if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : ''); - _result += state.dump; - } + if (input.startsWith('./')) { + input = input.slice(2); + prefix = parsed.prefix = './'; } - state.tag = _tag; - state.dump = '[' + _result + ']'; -} - -function writeBlockSequence$1(state, level, object, compact) { - var _result = '', - _tag = state.tag, - index, - length; - - for (index = 0, length = object.length; index < length; index += 1) { - // Write only valid elements. - if (writeNode$1(state, level + 1, object[index], true, true)) { - if (!compact || index !== 0) { - _result += generateNextLine$1(state, level); - } - - if (state.dump && CHAR_LINE_FEED$1 === state.dump.charCodeAt(0)) { - _result += '-'; - } else { - _result += '- '; - } + if (opts.fastpaths !== false && (input[0] === '.' || input[0] === '*')) { + output = parse$d.fastpaths(input, options); + } - _result += state.dump; - } + if (output === undefined) { + parsed = parse$d(input, options); + parsed.prefix = prefix + (parsed.prefix || ''); + } else { + parsed.output = output; } - state.tag = _tag; - state.dump = _result || '[]'; // Empty sequence if no valid values. -} + return picomatch$3.compileRe(parsed, options, returnOutput, returnState); +}; -function writeFlowMapping$1(state, level, object) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - pairBuffer; +/** + * 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 + */ - for (index = 0, length = objectKeyList.length; index < length; index += 1) { +picomatch$3.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 /$^/; + } +}; - pairBuffer = ''; - if (index !== 0) pairBuffer += ', '; +/** + * Picomatch constants. + * @return {Object} + */ - if (state.condenseFlow) pairBuffer += '"'; +picomatch$3.constants = constants$3; - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; +/** + * Expose "picomatch" + */ - if (!writeNode$1(state, level, objectKey, false, false)) { - continue; // Skip this pair because of invalid key; - } +var picomatch_1 = picomatch$3; - if (state.dump.length > 1024) pairBuffer += '? '; +var picomatch$2 = picomatch_1; - pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); +const fs$9 = require$$0__default$1['default']; +const { Readable } = require$$1__default['default']; +const sysPath$3 = path__default['default']; +const { promisify: promisify$3 } = require$$0__default$2['default']; +const picomatch$1 = picomatch$2; - if (!writeNode$1(state, level, objectValue, false, false)) { - continue; // Skip this pair because of invalid value. - } +const readdir$1 = promisify$3(fs$9.readdir); +const stat$3 = promisify$3(fs$9.stat); +const lstat$2 = promisify$3(fs$9.lstat); +const realpath$2 = promisify$3(fs$9.realpath); - pairBuffer += state.dump; +/** + * @typedef {Object} EntryInfo + * @property {String} path + * @property {String} fullPath + * @property {fs.Stats=} stats + * @property {fs.Dirent=} dirent + * @property {String} basename + */ - // Both key and value are valid. - _result += pairBuffer; - } +const BANG$2 = '!'; +const RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR'; +const NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP', RECURSIVE_ERROR_CODE]); +const FILE_TYPE = 'files'; +const DIR_TYPE = 'directories'; +const FILE_DIR_TYPE = 'files_directories'; +const EVERYTHING_TYPE = 'all'; +const ALL_TYPES = [FILE_TYPE, DIR_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE]; - state.tag = _tag; - state.dump = '{' + _result + '}'; -} +const isNormalFlowError = error => NORMAL_FLOW_ERRORS.has(error.code); +const [maj, min] = process.versions.node.split('.').slice(0, 2).map(n => Number.parseInt(n, 10)); +const wantBigintFsStats = process.platform === 'win32' && (maj > 10 || (maj === 10 && min >= 5)); -function writeBlockMapping$1(state, level, object, compact) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - explicitPair, - pairBuffer; +const normalizeFilter = filter => { + if (filter === undefined) return; + if (typeof filter === 'function') return filter; - // Allow sorting keys so that the output file is deterministic - if (state.sortKeys === true) { - // Default sorting - objectKeyList.sort(); - } else if (typeof state.sortKeys === 'function') { - // Custom sort function - objectKeyList.sort(state.sortKeys); - } else if (state.sortKeys) { - // Something is wrong - throw new YAMLException$2('sortKeys must be a boolean or a function'); + if (typeof filter === 'string') { + const glob = picomatch$1(filter.trim()); + return entry => glob(entry.basename); } - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = ''; - - if (!compact || index !== 0) { - pairBuffer += generateNextLine$1(state, level); - } - - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; - - if (!writeNode$1(state, level + 1, objectKey, true, true, true)) { - continue; // Skip this pair because of invalid key. + if (Array.isArray(filter)) { + const positive = []; + const negative = []; + for (const item of filter) { + const trimmed = item.trim(); + if (trimmed.charAt(0) === BANG$2) { + negative.push(picomatch$1(trimmed.slice(1))); + } else { + positive.push(picomatch$1(trimmed)); + } } - explicitPair = (state.tag !== null && state.tag !== '?') || - (state.dump && state.dump.length > 1024); - - if (explicitPair) { - if (state.dump && CHAR_LINE_FEED$1 === state.dump.charCodeAt(0)) { - pairBuffer += '?'; - } else { - pairBuffer += '? '; + if (negative.length > 0) { + if (positive.length > 0) { + return entry => + positive.some(f => f(entry.basename)) && !negative.some(f => f(entry.basename)); } + return entry => !negative.some(f => f(entry.basename)); } + return entry => positive.some(f => f(entry.basename)); + } +}; - pairBuffer += state.dump; +class ReaddirpStream extends Readable { + static get defaultOptions() { + return { + root: '.', + /* eslint-disable no-unused-vars */ + fileFilter: (path) => true, + directoryFilter: (path) => true, + /* eslint-enable no-unused-vars */ + type: FILE_TYPE, + lstat: false, + depth: 2147483648, + alwaysStat: false + }; + } - if (explicitPair) { - pairBuffer += generateNextLine$1(state, level); - } + constructor(options = {}) { + super({ + objectMode: true, + autoDestroy: true, + highWaterMark: options.highWaterMark || 4096 + }); + const opts = { ...ReaddirpStream.defaultOptions, ...options }; + const { root, type } = opts; - if (!writeNode$1(state, level + 1, objectValue, true, explicitPair)) { - continue; // Skip this pair because of invalid value. - } + this._fileFilter = normalizeFilter(opts.fileFilter); + this._directoryFilter = normalizeFilter(opts.directoryFilter); - if (state.dump && CHAR_LINE_FEED$1 === state.dump.charCodeAt(0)) { - pairBuffer += ':'; + const statMethod = opts.lstat ? lstat$2 : stat$3; + // Use bigint stats if it's windows and stat() supports options (node 10+). + if (wantBigintFsStats) { + this._stat = path => statMethod(path, { bigint: true }); } else { - pairBuffer += ': '; + this._stat = statMethod; } - pairBuffer += state.dump; + this._maxDepth = opts.depth; + this._wantsDir = [DIR_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE].includes(type); + this._wantsFile = [FILE_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE].includes(type); + this._wantsEverything = type === EVERYTHING_TYPE; + this._root = sysPath$3.resolve(root); + this._isDirent = ('Dirent' in fs$9) && !opts.alwaysStat; + this._statsProp = this._isDirent ? 'dirent' : 'stats'; + this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent }; - // Both key and value are valid. - _result += pairBuffer; + // Launch stream with one parent, the root dir. + this.parents = [this._exploreDir(root, 1)]; + this.reading = false; + this.parent = undefined; } - state.tag = _tag; - state.dump = _result || '{}'; // Empty mapping if no valid pairs. -} - -function detectType$1(state, object, explicit) { - var _result, typeList, index, length, type, style; + async _read(batch) { + if (this.reading) return; + this.reading = true; - typeList = explicit ? state.explicitTypes : state.implicitTypes; + try { + while (!this.destroyed && batch > 0) { + const { path, depth, files = [] } = this.parent || {}; - for (index = 0, length = typeList.length; index < length; index += 1) { - type = typeList[index]; - - if ((type.instanceOf || type.predicate) && - (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && - (!type.predicate || type.predicate(object))) { - - state.tag = explicit ? type.tag : '?'; + if (files.length > 0) { + const slice = files.splice(0, batch).map(dirent => this._formatEntry(dirent, path)); + for (const entry of await Promise.all(slice)) { + if (this.destroyed) return; - if (type.represent) { - style = state.styleMap[type.tag] || type.defaultStyle; + const entryType = await this._getEntryType(entry); + if (entryType === 'directory' && this._directoryFilter(entry)) { + if (depth <= this._maxDepth) { + this.parents.push(this._exploreDir(entry.fullPath, depth + 1)); + } - if (_toString$3.call(type.represent) === '[object Function]') { - _result = type.represent(object, style); - } else if (_hasOwnProperty$4.call(type.represent, style)) { - _result = type.represent[style](object, style); + if (this._wantsDir) { + this.push(entry); + batch--; + } + } else if ((entryType === 'file' || this._includeAsFile(entry)) && this._fileFilter(entry)) { + if (this._wantsFile) { + this.push(entry); + batch--; + } + } + } } else { - throw new YAMLException$2('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + const parent = this.parents.pop(); + if (!parent) { + this.push(null); + break; + } + this.parent = await parent; + if (this.destroyed) return; } - - state.dump = _result; } - - return true; + } catch (error) { + this.destroy(error); + } finally { + this.reading = false; } } - return false; -} - -// Serializes `object` and writes it to global `result`. -// Returns true on success, or false on invalid object. -// -function writeNode$1(state, level, object, block, compact, iskey) { - state.tag = null; - state.dump = object; - - if (!detectType$1(state, object, false)) { - detectType$1(state, object, true); - } - - var type = _toString$3.call(state.dump); - - if (block) { - block = (state.flowLevel < 0 || state.flowLevel > level); + async _exploreDir(path, depth) { + let files; + try { + files = await readdir$1(path, this._rdOptions); + } catch (error) { + this._onError(error); + } + return { files, depth, path }; } - var objectOrArray = type === '[object Object]' || type === '[object Array]', - duplicateIndex, - duplicate; - - if (objectOrArray) { - duplicateIndex = state.duplicates.indexOf(object); - duplicate = duplicateIndex !== -1; + async _formatEntry(dirent, path) { + let entry; + try { + const basename = this._isDirent ? dirent.name : dirent; + const fullPath = sysPath$3.resolve(sysPath$3.join(path, basename)); + entry = { path: sysPath$3.relative(this._root, fullPath), fullPath, basename }; + entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath); + } catch (err) { + this._onError(err); + } + return entry; } - if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { - compact = false; + _onError(err) { + if (isNormalFlowError(err) && !this.destroyed) { + this.emit('warn', err); + } else { + this.destroy(err); + } } - if (duplicate && state.usedDuplicates[duplicateIndex]) { - state.dump = '*ref_' + duplicateIndex; - } else { - if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { - state.usedDuplicates[duplicateIndex] = true; + async _getEntryType(entry) { + // entry may be undefined, because a warning or an error were emitted + // and the statsProp is undefined + const stats = entry && entry[this._statsProp]; + if (!stats) { + return; } - if (type === '[object Object]') { - if (block && (Object.keys(state.dump).length !== 0)) { - writeBlockMapping$1(state, level, state.dump, compact); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; - } - } else { - writeFlowMapping$1(state, level, state.dump); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; - } - } - } else if (type === '[object Array]') { - var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level; - if (block && (state.dump.length !== 0)) { - writeBlockSequence$1(state, arrayLevel, state.dump, compact); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; + if (stats.isFile()) { + return 'file'; + } + if (stats.isDirectory()) { + return 'directory'; + } + if (stats && stats.isSymbolicLink()) { + const full = entry.fullPath; + try { + const entryRealPath = await realpath$2(full); + const entryRealPathStats = await lstat$2(entryRealPath); + if (entryRealPathStats.isFile()) { + return 'file'; } - } else { - writeFlowSequence$1(state, arrayLevel, state.dump); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + if (entryRealPathStats.isDirectory()) { + const len = entryRealPath.length; + if (full.startsWith(entryRealPath) && full.substr(len, 1) === sysPath$3.sep) { + const recursiveError = new Error( + `Circular symlink detected: "${full}" points to "${entryRealPath}"` + ); + recursiveError.code = RECURSIVE_ERROR_CODE; + return this._onError(recursiveError); + } + return 'directory'; } + } catch (error) { + this._onError(error); } - } else if (type === '[object String]') { - if (state.tag !== '?') { - writeScalar$1(state, state.dump, level, iskey); - } - } else { - if (state.skipInvalid) return false; - throw new YAMLException$2('unacceptable kind of an object to dump ' + type); - } - - if (state.tag !== null && state.tag !== '?') { - state.dump = '!<' + state.tag + '> ' + state.dump; } } - return true; -} - -function getDuplicateReferences$1(object, state) { - var objects = [], - duplicatesIndexes = [], - index, - length; - - inspectNode$1(object, objects, duplicatesIndexes); + _includeAsFile(entry) { + const stats = entry && entry[this._statsProp]; - for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { - state.duplicates.push(objects[duplicatesIndexes[index]]); + return stats && this._wantsEverything && !stats.isDirectory(); } - state.usedDuplicates = new Array(length); } -function inspectNode$1(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$1(object[index], objects, duplicatesIndexes); - } - } else { - objectKeyList = Object.keys(object); +/** + * @typedef {Object} ReaddirpArguments + * @property {Function=} fileFilter + * @property {Function=} directoryFilter + * @property {String=} type + * @property {Number=} depth + * @property {String=} root + * @property {Boolean=} lstat + * @property {Boolean=} bigint + */ - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - inspectNode$1(object[objectKeyList[index]], objects, duplicatesIndexes); - } - } - } +/** + * Main function which ends up calling readdirRec and reads all files and directories in given root recursively. + * @param {String} root Root directory + * @param {ReaddirpArguments=} options Options to specify root (start directory), filters and recursion depth + */ +const readdirp$1 = (root, options = {}) => { + let type = options.entryType || options.type; + if (type === 'both') type = FILE_DIR_TYPE; // backwards-compatibility + if (type) options.type = type; + if (!root) { + throw new Error('readdirp: root argument is required. Usage: readdirp(root, options)'); + } else if (typeof root !== 'string') { + throw new TypeError('readdirp: root argument must be a string. Usage: readdirp(root, options)'); + } else if (type && !ALL_TYPES.includes(type)) { + throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(', ')}`); } -} -function dump$2(input, options) { - options = options || {}; + options.root = root; + return new ReaddirpStream(options); +}; - var state = new State$2(options); +const readdirpPromise = (root, options = {}) => { + return new Promise((resolve, reject) => { + const files = []; + readdirp$1(root, options) + .on('data', entry => files.push(entry)) + .on('end', () => resolve(files)) + .on('error', error => reject(error)); + }); +}; - if (!state.noRefs) getDuplicateReferences$1(input, state); +readdirp$1.promise = readdirpPromise; +readdirp$1.ReaddirpStream = ReaddirpStream; +readdirp$1.default = readdirp$1; - if (writeNode$1(state, 0, input, true, true)) return state.dump + '\n'; +var readdirp_1 = readdirp$1; - return ''; -} +var anymatch$2 = {exports: {}}; -function safeDump$1(input, options) { - return dump$2(input, common$5.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); -} +/*! + * normalize-path + * + * Copyright (c) 2014-2018, Jon Schlinkert. + * Released under the MIT License. + */ -dumper$2.dump = dump$2; -dumper$2.safeDump = safeDump$1; +var normalizePath$2 = function(path, stripTrailing) { + if (typeof path !== 'string') { + throw new TypeError('expected path to be a string'); + } -var loader$1 = loader$2; -var dumper$1 = dumper$2; + if (path === '\\' || path === '/') return '/'; + var len = path.length; + if (len <= 1) return path; -function deprecated(name) { - return function () { - throw new Error('Function ' + name + ' is deprecated and cannot be used.'); - }; -} + // ensure that win32 namespaces has two leading slashes, so that the path is + // handled properly by the win32 version of path.parse() after being normalized + // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces + var prefix = ''; + if (len > 4 && path[3] === '\\') { + var ch = path[2]; + if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') { + path = path.slice(2); + prefix = '//'; + } + } + var segs = path.split(/[/\\]+/); + if (stripTrailing !== false && segs[segs.length - 1] === '') { + segs.pop(); + } + return prefix + segs.join('/'); +}; -jsYaml$2.Type = type$1; -jsYaml$2.Schema = schema$2; -jsYaml$2.FAILSAFE_SCHEMA = failsafe$1; -jsYaml$2.JSON_SCHEMA = json$3; -jsYaml$2.CORE_SCHEMA = core$4; -jsYaml$2.DEFAULT_SAFE_SCHEMA = default_safe; -jsYaml$2.DEFAULT_FULL_SCHEMA = default_full; -jsYaml$2.load = loader$1.load; -jsYaml$2.loadAll = loader$1.loadAll; -jsYaml$2.safeLoad = loader$1.safeLoad; -jsYaml$2.safeLoadAll = loader$1.safeLoadAll; -jsYaml$2.dump = dumper$1.dump; -jsYaml$2.safeDump = dumper$1.safeDump; -jsYaml$2.YAMLException = exception$1; +Object.defineProperty(anymatch$2.exports, "__esModule", { value: true }); -// Deprecated schema names from JS-YAML 2.0.x -jsYaml$2.MINIMAL_SCHEMA = failsafe$1; -jsYaml$2.SAFE_SCHEMA = default_safe; -jsYaml$2.DEFAULT_SCHEMA = default_full; +const picomatch = picomatch$2; +const normalizePath$1 = normalizePath$2; -// Deprecated functions from JS-YAML 1.x.x -jsYaml$2.scan = deprecated('scan'); -jsYaml$2.parse = deprecated('parse'); -jsYaml$2.compose = deprecated('compose'); -jsYaml$2.addConstructor = deprecated('addConstructor'); +/** + * @typedef {(testString: string) => boolean} AnymatchFn + * @typedef {string|RegExp|AnymatchFn} AnymatchPattern + * @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher + */ +const BANG$1 = '!'; +const DEFAULT_OPTIONS = {returnIndex: false}; +const arrify$1 = (item) => Array.isArray(item) ? item : [item]; -var yaml$1 = jsYaml$2; +/** + * @param {AnymatchPattern} matcher + * @param {object} options + * @returns {AnymatchFn} + */ +const createPattern = (matcher, options) => { + if (typeof matcher === 'function') { + return matcher; + } + if (typeof matcher === 'string') { + const glob = picomatch(matcher, options); + return (string) => matcher === string || glob(string); + } + if (matcher instanceof RegExp) { + return (string) => matcher.test(string); + } + return (string) => false; +}; +/** + * @param {Array} patterns + * @param {Array} negPatterns + * @param {String|Array} args + * @param {Boolean} returnIndex + * @returns {boolean|number} + */ +const matchPatterns = (patterns, negPatterns, args, returnIndex) => { + const isList = Array.isArray(args); + const _path = isList ? args[0] : args; + if (!isList && typeof _path !== 'string') { + throw new TypeError('anymatch: second argument must be a string: got ' + + Object.prototype.toString.call(_path)) + } + const path = normalizePath$1(_path); -var jsYaml$1 = yaml$1; + for (let index = 0; index < negPatterns.length; index++) { + const nglob = negPatterns[index]; + if (nglob(path)) { + return returnIndex ? -1 : false; + } + } -var isArrayish$2 = function isArrayish(obj) { - if (!obj) { - return false; - } + const applied = isList && [path].concat(args.slice(1)); + for (let index = 0; index < patterns.length; index++) { + const pattern = patterns[index]; + if (isList ? pattern(...applied) : pattern(path)) { + return returnIndex ? index : true; + } + } - return obj instanceof Array || Array.isArray(obj) || - (obj.length >= 0 && obj.splice instanceof Function); + return returnIndex ? -1 : false; }; -var util$4 = require$$0__default['default']; -var isArrayish$1 = isArrayish$2; - -var errorEx$1 = function errorEx(name, properties) { - if (!name || name.constructor !== String) { - properties = name || {}; - name = Error.name; - } +/** + * @param {AnymatchMatcher} matchers + * @param {Array|string} testString + * @param {object} options + * @returns {boolean|number|Function} + */ +const anymatch$1 = (matchers, testString, options = DEFAULT_OPTIONS) => { + if (matchers == null) { + throw new TypeError('anymatch: specify first argument'); + } + const opts = typeof options === 'boolean' ? {returnIndex: options} : options; + const returnIndex = opts.returnIndex || false; - var errorExError = function ErrorEXError(message) { - if (!this) { - return new ErrorEXError(message); - } + // Early cache for matchers. + const mtchers = arrify$1(matchers); + const negatedGlobs = mtchers + .filter(item => typeof item === 'string' && item.charAt(0) === BANG$1) + .map(item => item.slice(1)) + .map(item => picomatch(item, opts)); + const patterns = mtchers + .filter(item => typeof item !== 'string' || (typeof item === 'string' && item.charAt(0) !== BANG$1)) + .map(matcher => createPattern(matcher, opts)); - message = message instanceof Error - ? message.message - : (message || this.message); + if (testString == null) { + return (testString, ri = false) => { + const returnIndex = typeof ri === 'boolean' ? ri : false; + return matchPatterns(patterns, negatedGlobs, testString, returnIndex); + } + } - Error.call(this, message); - Error.captureStackTrace(this, errorExError); + return matchPatterns(patterns, negatedGlobs, testString, returnIndex); +}; - this.name = name; +anymatch$1.default = anymatch$1; +anymatch$2.exports = anymatch$1; - Object.defineProperty(this, 'message', { - configurable: true, - enumerable: false, - get: function () { - var newMessage = message.split(/\r?\n/g); +/*! + * is-extglob + * + * Copyright (c) 2014-2016, Jon Schlinkert. + * Licensed under the MIT License. + */ - for (var key in properties) { - if (!properties.hasOwnProperty(key)) { - continue; - } +var isExtglob$1 = function isExtglob(str) { + if (typeof str !== 'string' || str === '') { + return false; + } - var modifier = properties[key]; + var match; + while ((match = /(\\).|([@?!+*]\(.*\))/g.exec(str))) { + if (match[2]) return true; + str = str.slice(match.index + match[0].length); + } - if ('message' in modifier) { - newMessage = modifier.message(this[key], newMessage) || newMessage; - if (!isArrayish$1(newMessage)) { - newMessage = [newMessage]; - } - } - } + return false; +}; - return newMessage.join('\n'); - }, - set: function (v) { - message = v; - } - }); +/*! + * is-glob + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ - var overwrittenStack = null; +var isExtglob = isExtglob$1; +var chars$1 = { '{': '}', '(': ')', '[': ']'}; +var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; +var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/; - var stackDescriptor = Object.getOwnPropertyDescriptor(this, 'stack'); - var stackGetter = stackDescriptor.get; - var stackValue = stackDescriptor.value; - delete stackDescriptor.value; - delete stackDescriptor.writable; +var isGlob$2 = function isGlob(str, options) { + if (typeof str !== 'string' || str === '') { + return false; + } - stackDescriptor.set = function (newstack) { - overwrittenStack = newstack; - }; + if (isExtglob(str)) { + return true; + } - stackDescriptor.get = function () { - var stack = (overwrittenStack || ((stackGetter) - ? stackGetter.call(this) - : stackValue)).split(/\r?\n+/g); + var regex = strictRegex; + var match; - // starting in Node 7, the stack builder caches the message. - // just replace it. - if (!overwrittenStack) { - stack[0] = this.name + ': ' + this.message; - } + // optionally relax regex + if (options && options.strict === false) { + regex = relaxedRegex; + } - var lineCount = 1; - for (var key in properties) { - if (!properties.hasOwnProperty(key)) { - continue; - } + while ((match = regex.exec(str))) { + if (match[2]) return true; + var idx = match.index + match[0].length; - var modifier = properties[key]; + // if an open bracket/brace/paren is escaped, + // set the index to the next closing character + var open = match[1]; + var close = open ? chars$1[open] : null; + if (open && close) { + var n = str.indexOf(close, idx); + if (n !== -1) { + idx = n + 1; + } + } - if ('line' in modifier) { - var line = modifier.line(this[key]); - if (line) { - stack.splice(lineCount++, 0, ' ' + line); - } - } + str = str.slice(idx); + } + return false; +}; - if ('stack' in modifier) { - modifier.stack(this[key], stack); - } - } +var isGlob$1 = isGlob$2; +var pathPosixDirname = path__default['default'].posix.dirname; +var isWin32 = require$$0__default['default'].platform() === 'win32'; - return stack.join('\n'); - }; +var slash = '/'; +var backslash = /\\/g; +var enclosure = /[\{\[].*[\}\]]$/; +var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/; +var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g; - Object.defineProperty(this, 'stack', stackDescriptor); - }; +/** + * @param {string} str + * @param {Object} opts + * @param {boolean} [opts.flipBackslashes=true] + * @returns {string} + */ +var globParent$1 = function globParent(str, opts) { + var options = Object.assign({ flipBackslashes: true }, opts); - if (Object.setPrototypeOf) { - Object.setPrototypeOf(errorExError.prototype, Error.prototype); - Object.setPrototypeOf(errorExError, Error); - } else { - util$4.inherits(errorExError, Error); - } + // flip windows path separators + if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) { + str = str.replace(backslash, slash); + } - return errorExError; -}; + // special case for strings ending in enclosure containing path separator + if (enclosure.test(str)) { + str += slash; + } -errorEx$1.append = function (str, def) { - return { - message: function (v, message) { - v = v || def; + // preserves full path in case of trailing path separator + str += 'a'; - if (v) { - message[0] += ' ' + str.replace('%s', v.toString()); - } + // remove path parts that are globby + do { + str = pathPosixDirname(str); + } while (isGlob$1(str) || globby.test(str)); - return message; - } - }; + // remove escape chars and return result + return str.replace(escaped, '$1'); }; -errorEx$1.line = function (str, def) { - return { - line: function (v) { - v = v || def; +var utils$3 = {}; - if (v) { - return str.replace('%s', v.toString()); - } +(function (exports) { - return null; - } - }; +exports.isInteger = num => { + if (typeof num === 'number') { + return Number.isInteger(num); + } + if (typeof num === 'string' && num.trim() !== '') { + return Number.isInteger(Number(num)); + } + return false; }; -var errorEx_1 = errorEx$1; +/** + * Find a node of the given type + */ -const hexify = char => { - const h = char.charCodeAt(0).toString(16).toUpperCase(); - return '0x' + (h.length % 2 ? '0' : '') + h +exports.find = (node, type) => node.nodes.find(node => node.type === type); + +/** + * Find a node of the given type + */ + +exports.exceedsLimit = (min, max, step = 1, limit) => { + if (limit === false) return false; + if (!exports.isInteger(min) || !exports.isInteger(max)) return false; + return ((Number(max) - Number(min)) / Number(step)) >= limit; }; -const parseError = (e, txt, context) => { - if (!txt) { - return { - message: e.message + ' while parsing empty string', - position: 0, +/** + * Escape the given node with '\\' before node.value + */ + +exports.escapeNode = (block, n = 0, type) => { + let node = block.nodes[n]; + if (!node) return; + + if ((type && node.type === type) || node.type === 'open' || node.type === 'close') { + if (node.escaped !== true) { + node.value = '\\' + node.value; + node.escaped = true; } } - const badToken = e.message.match(/^Unexpected token (.) .*position\s+(\d+)/i); - const errIdx = badToken ? +badToken[2] - : e.message.match(/^Unexpected end of JSON.*/i) ? txt.length - 1 - : null; +}; - const msg = badToken ? e.message.replace(/^Unexpected token ./, `Unexpected token ${ - JSON.stringify(badToken[1]) - } (${hexify(badToken[1])})`) - : e.message; +/** + * Returns true if the given brace node should be enclosed in literal braces + */ - if (errIdx !== null && errIdx !== undefined) { - const start = errIdx <= context ? 0 - : errIdx - context; +exports.encloseBrace = node => { + if (node.type !== 'brace') return false; + if ((node.commas >> 0 + node.ranges >> 0) === 0) { + node.invalid = true; + return true; + } + return false; +}; - const end = errIdx + context >= txt.length ? txt.length - : errIdx + context; +/** + * Returns true if a brace node is invalid. + */ - const slice = (start === 0 ? '' : '...') + - txt.slice(start, end) + - (end === txt.length ? '' : '...'); +exports.isInvalidBrace = block => { + if (block.type !== 'brace') return false; + if (block.invalid === true || block.dollar) return true; + if ((block.commas >> 0 + block.ranges >> 0) === 0) { + block.invalid = true; + return true; + } + if (block.open !== true || block.close !== true) { + block.invalid = true; + return true; + } + return false; +}; - const near = txt === slice ? '' : 'near '; +/** + * Returns true if a node is an open or close node + */ - return { - message: msg + ` while parsing ${near}${JSON.stringify(slice)}`, - position: errIdx, - } - } else { - return { - message: msg + ` while parsing '${txt.slice(0, context * 2)}'`, - position: 0, - } +exports.isOpenOrClose = node => { + if (node.type === 'open' || node.type === 'close') { + return true; } + return node.open === true || node.close === true; }; -class JSONParseError extends SyntaxError { - constructor (er, txt, context, caller) { - context = context || 20; - const metadata = parseError(er, txt, context); - super(metadata.message); - Object.assign(this, metadata); - this.code = 'EJSONPARSE'; - this.systemError = er; - Error.captureStackTrace(this, caller || this.constructor); - } - get name () { return this.constructor.name } - set name (n) {} - get [Symbol.toStringTag] () { return this.constructor.name } -} +/** + * Reduce an array of text nodes. + */ -const kIndent = Symbol.for('indent'); -const kNewline = Symbol.for('newline'); -// only respect indentation if we got a line break, otherwise squash it -// things other than objects and arrays aren't indented, so ignore those -// Important: in both of these regexps, the $1 capture group is the newline -// or undefined, and the $2 capture group is the indent, or undefined. -const formatRE = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/; -const emptyRE = /^(?:\{\}|\[\])((?:\r?\n)+)?$/; +exports.reduce = nodes => nodes.reduce((acc, node) => { + if (node.type === 'text') acc.push(node.value); + if (node.type === 'range') node.type = 'text'; + return acc; +}, []); -const parseJson$1 = (txt, reviver, context) => { - const parseText = stripBOM(txt); - context = context || 20; - try { - // get the indentation so that we can save it back nicely - // if the file starts with {" then we have an indent of '', ie, none - // otherwise, pick the indentation of the next line after the first \n - // If the pattern doesn't match, then it means no indentation. - // JSON.stringify ignores symbols, so this is reasonably safe. - // if the string is '{}' or '[]', then use the default 2-space indent. - const [, newline = '\n', indent = ' '] = parseText.match(emptyRE) || - parseText.match(formatRE) || - [, '', '']; +/** + * Flatten an array + */ - const result = JSON.parse(parseText, reviver); - if (result && typeof result === 'object') { - result[kNewline] = newline; - result[kIndent] = indent; - } - return result - } catch (e) { - if (typeof txt !== 'string' && !Buffer.isBuffer(txt)) { - const isEmptyArray = Array.isArray(txt) && txt.length === 0; - throw Object.assign(new TypeError( - `Cannot parse ${isEmptyArray ? 'an empty array' : String(txt)}` - ), { - code: 'EJSONPARSE', - systemError: e, - }) +exports.flatten = (...args) => { + const result = []; + const flat = arr => { + for (let i = 0; i < arr.length; i++) { + let ele = arr[i]; + Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele); } - - throw new JSONParseError(e, parseText, context, parseJson$1) - } + return result; + }; + flat(args); + return result; }; +}(utils$3)); -// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) -// because the buffer-to-string conversion in `fs.readFileSync()` -// translates it to FEFF, the UTF-16 BOM. -const stripBOM = txt => String(txt).replace(/^\uFEFF/, ''); +const utils$2 = utils$3; -var jsonParseEvenBetterErrors = parseJson$1; -parseJson$1.JSONParseError = JSONParseError; +var stringify$6 = (ast, options = {}) => { + let stringify = (node, parent = {}) => { + let invalidBlock = options.escapeInvalid && utils$2.isInvalidBrace(parent); + let invalidNode = node.invalid === true && options.escapeInvalid === true; + let output = ''; -parseJson$1.noExceptions = (txt, reviver) => { - try { - return JSON.parse(stripBOM(txt), reviver) - } catch (e) {} -}; + if (node.value) { + if ((invalidBlock || invalidNode) && utils$2.isOpenOrClose(node)) { + return '\\' + node.value; + } + return node.value; + } -var LF = '\n'; -var CR = '\r'; -var LinesAndColumns$1 = (function () { - function LinesAndColumns(string) { - this.string = string; - var offsets = [0]; - for (var offset = 0; offset < string.length;) { - switch (string[offset]) { - case LF: - offset += LF.length; - offsets.push(offset); - break; - case CR: - offset += CR.length; - if (string[offset] === LF) { - offset += LF.length; - } - offsets.push(offset); - break; - default: - offset++; - break; - } - } - this.offsets = offsets; + if (node.value) { + return node.value; } - LinesAndColumns.prototype.locationForIndex = function (index) { - if (index < 0 || index > this.string.length) { - return null; - } - var line = 0; - var offsets = this.offsets; - while (offsets[line + 1] <= index) { - line++; - } - var column = index - offsets[line]; - return { line: line, column: column }; - }; - LinesAndColumns.prototype.indexForLocation = function (location) { - var line = location.line, column = location.column; - if (line < 0 || line >= this.offsets.length) { - return null; - } - if (column < 0 || column > this.lengthOfLine(line)) { - return null; - } - return this.offsets[line] + column; - }; - LinesAndColumns.prototype.lengthOfLine = function (line) { - var offset = this.offsets[line]; - var nextOffset = line === this.offsets.length - 1 ? this.string.length : this.offsets[line + 1]; - return nextOffset - offset; - }; - return LinesAndColumns; -}()); -var dist$2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - 'default': LinesAndColumns$1 -}); + if (node.nodes) { + for (let child of node.nodes) { + output += stringify(child); + } + } + return output; + }; -var require$$2 = /*@__PURE__*/getAugmentedNamespace(dist$2); + return stringify(ast); +}; -var lib$9 = {}; +/*! + * is-number + * + * Copyright (c) 2014-present, Jon Schlinkert. + * Released under the MIT License. + */ -var lib$8 = {}; +var isNumber$3 = function(num) { + if (typeof num === 'number') { + return num - num === 0; + } + if (typeof num === 'string' && num.trim() !== '') { + return Number.isFinite ? Number.isFinite(+num) : isFinite(+num); + } + return false; +}; -var jsTokens = {}; +/*! + * to-regex-range + * + * Copyright (c) 2015-present, Jon Schlinkert. + * Released under the MIT License. + */ -// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell -// License: MIT. (See LICENSE.) +const isNumber$2 = isNumber$3; -Object.defineProperty(jsTokens, "__esModule", { - value: true -}); +const toRegexRange$1 = (min, max, options) => { + if (isNumber$2(min) === false) { + throw new TypeError('toRegexRange: expected the first argument to be a number'); + } -// This regex comes from regex.coffee, and is inserted here by generate-index.js -// (run `npm run build`). -jsTokens.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g; + if (max === void 0 || min === max) { + return String(min); + } -jsTokens.matchToToken = function(match) { - var token = {type: "invalid", value: match[0], closed: undefined}; - if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4]); - else if (match[ 5]) token.type = "comment"; - else if (match[ 6]) token.type = "comment", token.closed = !!match[7]; - else if (match[ 8]) token.type = "regex"; - else if (match[ 9]) token.type = "number"; - else if (match[10]) token.type = "name"; - else if (match[11]) token.type = "punctuator"; - else if (match[12]) token.type = "whitespace"; - return token -}; + if (isNumber$2(max) === false) { + throw new TypeError('toRegexRange: expected the second argument to be a number.'); + } -var lib$7 = {}; + let opts = { relaxZeros: true, ...options }; + if (typeof opts.strictZeros === 'boolean') { + opts.relaxZeros = opts.strictZeros === false; + } -var identifier = {}; + let relax = String(opts.relaxZeros); + let shorthand = String(opts.shorthand); + let capture = String(opts.capture); + let wrap = String(opts.wrap); + let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap; -Object.defineProperty(identifier, "__esModule", { - value: true -}); -identifier.isIdentifierStart = isIdentifierStart; -identifier.isIdentifierChar = isIdentifierChar; -identifier.isIdentifierName = isIdentifierName; -let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\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\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\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\u0af9\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-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\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\u2118-\u211d\u2124\u2126\u2128\u212a-\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\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\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"; -let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; -const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); -const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); -nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; -const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938]; -const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; + if (toRegexRange$1.cache.hasOwnProperty(cacheKey)) { + return toRegexRange$1.cache[cacheKey].result; + } -function isInAstralSet(code, set) { - let pos = 0x10000; + let a = Math.min(min, max); + let b = Math.max(min, max); - for (let i = 0, length = set.length; i < length; i += 2) { - pos += set[i]; - if (pos > code) return false; - pos += set[i + 1]; - if (pos >= code) return true; + if (Math.abs(a - b) === 1) { + let result = min + '|' + max; + if (opts.capture) { + return `(${result})`; + } + if (opts.wrap === false) { + return result; + } + return `(?:${result})`; } - return false; -} + let isPadded = hasPadding(min) || hasPadding(max); + let state = { min, max, a, b }; + let positives = []; + let negatives = []; -function isIdentifierStart(code) { - if (code < 65) return code === 36; - if (code <= 90) return true; - if (code < 97) return code === 95; - if (code <= 122) return true; + if (isPadded) { + state.isPadded = isPadded; + state.maxLen = String(state.max).length; + } - if (code <= 0xffff) { - return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); + if (a < 0) { + let newMin = b < 0 ? Math.abs(b) : 1; + negatives = splitToPatterns(newMin, Math.abs(a), state, opts); + a = state.a = 0; } - return isInAstralSet(code, astralIdentifierStartCodes); -} + if (b >= 0) { + positives = splitToPatterns(a, b, state, opts); + } -function isIdentifierChar(code) { - if (code < 48) return code === 36; - if (code < 58) return true; - if (code < 65) return false; - if (code <= 90) return true; - if (code < 97) return code === 95; - if (code <= 122) return true; + state.negatives = negatives; + state.positives = positives; + state.result = collatePatterns(negatives, positives); - if (code <= 0xffff) { - return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); + if (opts.capture === true) { + state.result = `(${state.result})`; + } else if (opts.wrap !== false && (positives.length + negatives.length) > 1) { + state.result = `(?:${state.result})`; } - return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); -} + toRegexRange$1.cache[cacheKey] = state; + return state.result; +}; -function isIdentifierName(name) { - let isFirst = true; +function collatePatterns(neg, pos, options) { + let onlyNegative = filterPatterns(neg, pos, '-', false) || []; + let onlyPositive = filterPatterns(pos, neg, '', false) || []; + let intersected = filterPatterns(neg, pos, '-?', true) || []; + let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive); + return subpatterns.join('|'); +} - for (let i = 0; i < name.length; i++) { - let cp = name.charCodeAt(i); +function splitToRanges(min, max) { + let nines = 1; + let zeros = 1; - if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) { - const trail = name.charCodeAt(++i); + let stop = countNines(min, nines); + let stops = new Set([max]); - if ((trail & 0xfc00) === 0xdc00) { - cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff); - } - } + while (min <= stop && stop <= max) { + stops.add(stop); + nines += 1; + stop = countNines(min, nines); + } - if (isFirst) { - isFirst = false; + stop = countZeros(max + 1, zeros) - 1; - if (!isIdentifierStart(cp)) { - return false; - } - } else if (!isIdentifierChar(cp)) { - return false; - } + while (min < stop && stop <= max) { + stops.add(stop); + zeros += 1; + stop = countZeros(max + 1, zeros) - 1; } - return !isFirst; + stops = [...stops]; + stops.sort(compare$c); + return stops; } -var keyword = {}; +/** + * Convert a range to a regex pattern + * @param {Number} `start` + * @param {Number} `stop` + * @return {String} + */ -Object.defineProperty(keyword, "__esModule", { - value: true -}); -keyword.isReservedWord = isReservedWord; -keyword.isStrictReservedWord = isStrictReservedWord; -keyword.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord; -keyword.isStrictBindReservedWord = isStrictBindReservedWord; -keyword.isKeyword = isKeyword; -const reservedWords = { - keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"], - strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], - strictBind: ["eval", "arguments"] -}; -const keywords$1 = new Set(reservedWords.keyword); -const reservedWordsStrictSet = new Set(reservedWords.strict); -const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); - -function isReservedWord(word, inModule) { - return inModule && word === "await" || word === "enum"; -} - -function isStrictReservedWord(word, inModule) { - return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); -} +function rangeToPattern(start, stop, options) { + if (start === stop) { + return { pattern: start, count: [], digits: 0 }; + } -function isStrictBindOnlyReservedWord(word) { - return reservedWordsStrictBindSet.has(word); -} + let zipped = zip(start, stop); + let digits = zipped.length; + let pattern = ''; + let count = 0; -function isStrictBindReservedWord(word, inModule) { - return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); -} + for (let i = 0; i < digits; i++) { + let [startDigit, stopDigit] = zipped[i]; -function isKeyword(word) { - return keywords$1.has(word); -} + if (startDigit === stopDigit) { + pattern += startDigit; -(function (exports) { + } else if (startDigit !== '0' || stopDigit !== '9') { + pattern += toCharacterClass(startDigit, stopDigit); -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "isIdentifierName", { - enumerable: true, - get: function () { - return _identifier.isIdentifierName; - } -}); -Object.defineProperty(exports, "isIdentifierChar", { - enumerable: true, - get: function () { - return _identifier.isIdentifierChar; - } -}); -Object.defineProperty(exports, "isIdentifierStart", { - enumerable: true, - get: function () { - return _identifier.isIdentifierStart; - } -}); -Object.defineProperty(exports, "isReservedWord", { - enumerable: true, - get: function () { - return _keyword.isReservedWord; - } -}); -Object.defineProperty(exports, "isStrictBindOnlyReservedWord", { - enumerable: true, - get: function () { - return _keyword.isStrictBindOnlyReservedWord; - } -}); -Object.defineProperty(exports, "isStrictBindReservedWord", { - enumerable: true, - get: function () { - return _keyword.isStrictBindReservedWord; - } -}); -Object.defineProperty(exports, "isStrictReservedWord", { - enumerable: true, - get: function () { - return _keyword.isStrictReservedWord; - } -}); -Object.defineProperty(exports, "isKeyword", { - enumerable: true, - get: function () { - return _keyword.isKeyword; + } else { + count++; + } } -}); -var _identifier = identifier; + if (count) { + pattern += options.shorthand === true ? '\\d' : '[0-9]'; + } -var _keyword = keyword; -}(lib$7)); + return { pattern, count: [count], digits }; +} -var chalk$2 = {exports: {}}; +function splitToPatterns(min, max, tok, options) { + let ranges = splitToRanges(min, max); + let tokens = []; + let start = min; + let prev; -var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; + for (let i = 0; i < ranges.length; i++) { + let max = ranges[i]; + let obj = rangeToPattern(String(start), String(max), options); + let zeros = ''; -var escapeStringRegexp$3 = function (str) { - if (typeof str !== 'string') { - throw new TypeError('Expected a string'); - } + if (!tok.isPadded && prev && prev.pattern === obj.pattern) { + if (prev.count.length > 1) { + prev.count.pop(); + } - return str.replace(matchOperatorsRe, '\\$&'); -}; + prev.count.push(obj.count[0]); + prev.string = prev.pattern + toQuantifier(prev.count); + start = max + 1; + continue; + } -var ansiStyles$2 = {exports: {}}; + if (tok.isPadded) { + zeros = padZeros(max, tok, options); + } -var conversions$5 = {exports: {}}; + obj.string = zeros + obj.pattern + toQuantifier(obj.count); + tokens.push(obj); + start = max + 1; + prev = obj; + } -var colorName$1 = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] -}; + return tokens; +} -/* MIT license */ +function filterPatterns(arr, comparison, prefix, intersection, options) { + let result = []; -var cssKeywords$1 = colorName$1; + for (let ele of arr) { + let { string } = ele; -// NOTE: conversions should only return primitive values (i.e. arrays, or -// values that give correct `typeof` results). -// do not use box values types (i.e. Number(), String(), etc.) + // only push if _both_ are negative... + if (!intersection && !contains(comparison, 'string', string)) { + result.push(prefix + string); + } -var reverseKeywords$1 = {}; -for (var key$1 in cssKeywords$1) { - if (cssKeywords$1.hasOwnProperty(key$1)) { - reverseKeywords$1[cssKeywords$1[key$1]] = key$1; - } + // or _both_ are positive + if (intersection && contains(comparison, 'string', string)) { + result.push(prefix + string); + } + } + return result; } -var convert$6 = conversions$5.exports = { - rgb: {channels: 3, labels: 'rgb'}, - hsl: {channels: 3, labels: 'hsl'}, - hsv: {channels: 3, labels: 'hsv'}, - hwb: {channels: 3, labels: 'hwb'}, - cmyk: {channels: 4, labels: 'cmyk'}, - xyz: {channels: 3, labels: 'xyz'}, - lab: {channels: 3, labels: 'lab'}, - lch: {channels: 3, labels: 'lch'}, - hex: {channels: 1, labels: ['hex']}, - keyword: {channels: 1, labels: ['keyword']}, - ansi16: {channels: 1, labels: ['ansi16']}, - ansi256: {channels: 1, labels: ['ansi256']}, - hcg: {channels: 3, labels: ['h', 'c', 'g']}, - apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, - gray: {channels: 1, labels: ['gray']} -}; +/** + * Zip strings + */ -// hide .channels and .labels properties -for (var model in convert$6) { - if (convert$6.hasOwnProperty(model)) { - if (!('channels' in convert$6[model])) { - throw new Error('missing channels property: ' + model); - } +function zip(a, b) { + let arr = []; + for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]); + return arr; +} - if (!('labels' in convert$6[model])) { - throw new Error('missing channel labels property: ' + model); - } +function compare$c(a, b) { + return a > b ? 1 : b > a ? -1 : 0; +} - if (convert$6[model].labels.length !== convert$6[model].channels) { - throw new Error('channel and label counts mismatch: ' + model); - } +function contains(arr, key, val) { + return arr.some(ele => ele[key] === val); +} - var channels = convert$6[model].channels; - var labels$1 = convert$6[model].labels; - delete convert$6[model].channels; - delete convert$6[model].labels; - Object.defineProperty(convert$6[model], 'channels', {value: channels}); - Object.defineProperty(convert$6[model], 'labels', {value: labels$1}); - } +function countNines(min, len) { + return Number(String(min).slice(0, -len) + '9'.repeat(len)); } -convert$6.rgb.hsl = function (rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var delta = max - min; - var h; - var s; - var l; +function countZeros(integer, zeros) { + return integer - (integer % Math.pow(10, zeros)); +} - if (max === min) { - h = 0; - } else if (r === max) { - h = (g - b) / delta; - } else if (g === max) { - h = 2 + (b - r) / delta; - } else if (b === max) { - h = 4 + (r - g) / delta; - } +function toQuantifier(digits) { + let [start = 0, stop = ''] = digits; + if (stop || start > 1) { + return `{${start + (stop ? ',' + stop : '')}}`; + } + return ''; +} - h = Math.min(h * 60, 360); +function toCharacterClass(a, b, options) { + return `[${a}${(b - a === 1) ? '' : '-'}${b}]`; +} - if (h < 0) { - h += 360; - } +function hasPadding(str) { + return /^-?(0+)\d/.test(str); +} - l = (min + max) / 2; +function padZeros(value, tok, options) { + if (!tok.isPadded) { + return value; + } - if (max === min) { - s = 0; - } else if (l <= 0.5) { - s = delta / (max + min); - } else { - s = delta / (2 - max - min); - } + let diff = Math.abs(tok.maxLen - String(value).length); + let relax = options.relaxZeros !== false; - return [h, s * 100, l * 100]; -}; + switch (diff) { + case 0: + return ''; + case 1: + return relax ? '0?' : '0'; + case 2: + return relax ? '0{0,2}' : '00'; + default: { + return relax ? `0{0,${diff}}` : `0{${diff}}`; + } + } +} -convert$6.rgb.hsv = function (rgb) { - var rdif; - var gdif; - var bdif; - var h; - var s; +/** + * Cache + */ - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var v = Math.max(r, g, b); - var diff = v - Math.min(r, g, b); - var diffc = function (c) { - return (v - c) / 6 / diff + 1 / 2; - }; +toRegexRange$1.cache = {}; +toRegexRange$1.clearCache = () => (toRegexRange$1.cache = {}); - if (diff === 0) { - h = s = 0; - } else { - s = diff / v; - rdif = diffc(r); - gdif = diffc(g); - bdif = diffc(b); +/** + * Expose `toRegexRange` + */ - if (r === v) { - h = bdif - gdif; - } else if (g === v) { - h = (1 / 3) + rdif - bdif; - } else if (b === v) { - h = (2 / 3) + gdif - rdif; - } - if (h < 0) { - h += 1; - } else if (h > 1) { - h -= 1; - } - } +var toRegexRange_1 = toRegexRange$1; - return [ - h * 360, - s * 100, - v * 100 - ]; -}; +/*! + * fill-range + * + * Copyright (c) 2014-present, Jon Schlinkert. + * Licensed under the MIT License. + */ -convert$6.rgb.hwb = function (rgb) { - var r = rgb[0]; - var g = rgb[1]; - var b = rgb[2]; - var h = convert$6.rgb.hsl(rgb)[0]; - var w = 1 / 255 * Math.min(r, Math.min(g, b)); +const util$3 = require$$0__default$2['default']; +const toRegexRange = toRegexRange_1; - b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); +const isObject$2 = val => val !== null && typeof val === 'object' && !Array.isArray(val); - return [h, w * 100, b * 100]; +const transform$3 = toNumber => { + return value => toNumber === true ? Number(value) : String(value); }; -convert$6.rgb.cmyk = function (rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var c; - var m; - var y; - var k; +const isValidValue = value => { + return typeof value === 'number' || (typeof value === 'string' && value !== ''); +}; - k = Math.min(1 - r, 1 - g, 1 - b); - c = (1 - r - k) / (1 - k) || 0; - m = (1 - g - k) / (1 - k) || 0; - y = (1 - b - k) / (1 - k) || 0; +const isNumber$1 = num => Number.isInteger(+num); - return [c * 100, m * 100, y * 100, k * 100]; +const zeros = input => { + let value = `${input}`; + let index = -1; + if (value[0] === '-') value = value.slice(1); + if (value === '0') return false; + while (value[++index] === '0'); + return index > 0; }; -/** - * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance - * */ -function comparativeDistance$1(x, y) { - return ( - Math.pow(x[0] - y[0], 2) + - Math.pow(x[1] - y[1], 2) + - Math.pow(x[2] - y[2], 2) - ); -} +const stringify$5 = (start, end, options) => { + if (typeof start === 'string' || typeof end === 'string') { + return true; + } + return options.stringify === true; +}; -convert$6.rgb.keyword = function (rgb) { - var reversed = reverseKeywords$1[rgb]; - if (reversed) { - return reversed; - } +const pad = (input, maxLength, toNumber) => { + if (maxLength > 0) { + let dash = input[0] === '-' ? '-' : ''; + if (dash) input = input.slice(1); + input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0')); + } + if (toNumber === false) { + return String(input); + } + return input; +}; - var currentClosestDistance = Infinity; - var currentClosestKeyword; +const toMaxLen = (input, maxLength) => { + let negative = input[0] === '-' ? '-' : ''; + if (negative) { + input = input.slice(1); + maxLength--; + } + while (input.length < maxLength) input = '0' + input; + return negative ? ('-' + input) : input; +}; - for (var keyword in cssKeywords$1) { - if (cssKeywords$1.hasOwnProperty(keyword)) { - var value = cssKeywords$1[keyword]; +const toSequence = (parts, options) => { + parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); + parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); - // Compute comparative distance - var distance = comparativeDistance$1(rgb, value); + let prefix = options.capture ? '' : '?:'; + let positives = ''; + let negatives = ''; + let result; - // Check if its less, if so set as closest - if (distance < currentClosestDistance) { - currentClosestDistance = distance; - currentClosestKeyword = keyword; - } - } - } + if (parts.positives.length) { + positives = parts.positives.join('|'); + } - return currentClosestKeyword; -}; + if (parts.negatives.length) { + negatives = `-(${prefix}${parts.negatives.join('|')})`; + } -convert$6.keyword.rgb = function (keyword) { - return cssKeywords$1[keyword]; + if (positives && negatives) { + result = `${positives}|${negatives}`; + } else { + result = positives || negatives; + } + + if (options.wrap) { + return `(${prefix}${result})`; + } + + return result; }; -convert$6.rgb.xyz = function (rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; +const toRange = (a, b, isNumbers, options) => { + if (isNumbers) { + return toRegexRange(a, b, { wrap: false, ...options }); + } - // assume sRGB - r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); - g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); - b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); + let start = String.fromCharCode(a); + if (a === b) return start; - var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); - var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); - var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); + let stop = String.fromCharCode(b); + return `[${start}-${stop}]`; +}; - return [x * 100, y * 100, z * 100]; +const toRegex = (start, end, options) => { + if (Array.isArray(start)) { + let wrap = options.wrap === true; + let prefix = options.capture ? '' : '?:'; + return wrap ? `(${prefix}${start.join('|')})` : start.join('|'); + } + return toRegexRange(start, end, options); }; -convert$6.rgb.lab = function (rgb) { - var xyz = convert$6.rgb.xyz(rgb); - var x = xyz[0]; - var y = xyz[1]; - var z = xyz[2]; - var l; - var a; - var b; +const rangeError = (...args) => { + return new RangeError('Invalid range arguments: ' + util$3.inspect(...args)); +}; - x /= 95.047; - y /= 100; - z /= 108.883; +const invalidRange = (start, end, options) => { + if (options.strictRanges === true) throw rangeError([start, end]); + return []; +}; - x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); +const invalidStep = (step, options) => { + if (options.strictRanges === true) { + throw new TypeError(`Expected step "${step}" to be a number`); + } + return []; +}; - l = (116 * y) - 16; - a = 500 * (x - y); - b = 200 * (y - z); +const fillNumbers = (start, end, step = 1, options = {}) => { + let a = Number(start); + let b = Number(end); - return [l, a, b]; -}; + if (!Number.isInteger(a) || !Number.isInteger(b)) { + if (options.strictRanges === true) throw rangeError([start, end]); + return []; + } -convert$6.hsl.rgb = function (hsl) { - var h = hsl[0] / 360; - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var t1; - var t2; - var t3; - var rgb; - var val; + // fix negative zero + if (a === 0) a = 0; + if (b === 0) b = 0; - if (s === 0) { - val = l * 255; - return [val, val, val]; - } + let descending = a > b; + let startString = String(start); + let endString = String(end); + let stepString = String(step); + step = Math.max(Math.abs(step), 1); - if (l < 0.5) { - t2 = l * (1 + s); - } else { - t2 = l + s - l * s; - } + let padded = zeros(startString) || zeros(endString) || zeros(stepString); + let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0; + let toNumber = padded === false && stringify$5(start, end, options) === false; + let format = options.transform || transform$3(toNumber); - t1 = 2 * l - t2; + if (options.toRegex && step === 1) { + return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options); + } - rgb = [0, 0, 0]; - for (var i = 0; i < 3; i++) { - t3 = h + 1 / 3 * -(i - 1); - if (t3 < 0) { - t3++; - } - if (t3 > 1) { - t3--; - } + let parts = { negatives: [], positives: [] }; + let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num)); + let range = []; + let index = 0; - if (6 * t3 < 1) { - val = t1 + (t2 - t1) * 6 * t3; - } else if (2 * t3 < 1) { - val = t2; - } else if (3 * t3 < 2) { - val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; - } else { - val = t1; - } + while (descending ? a >= b : a <= b) { + if (options.toRegex === true && step > 1) { + push(a); + } else { + range.push(pad(format(a, index), maxLen, toNumber)); + } + a = descending ? a - step : a + step; + index++; + } - rgb[i] = val * 255; - } + if (options.toRegex === true) { + return step > 1 + ? toSequence(parts, options) + : toRegex(range, null, { wrap: false, ...options }); + } - return rgb; + return range; }; -convert$6.hsl.hsv = function (hsl) { - var h = hsl[0]; - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var smin = s; - var lmin = Math.max(l, 0.01); - var sv; - var v; +const fillLetters = (start, end, step = 1, options = {}) => { + if ((!isNumber$1(start) && start.length > 1) || (!isNumber$1(end) && end.length > 1)) { + return invalidRange(start, end, options); + } - l *= 2; - s *= (l <= 1) ? l : 2 - l; - smin *= lmin <= 1 ? lmin : 2 - lmin; - v = (l + s) / 2; - sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); - return [h, sv * 100, v * 100]; -}; + let format = options.transform || (val => String.fromCharCode(val)); + let a = `${start}`.charCodeAt(0); + let b = `${end}`.charCodeAt(0); -convert$6.hsv.rgb = function (hsv) { - var h = hsv[0] / 60; - var s = hsv[1] / 100; - var v = hsv[2] / 100; - var hi = Math.floor(h) % 6; + let descending = a > b; + let min = Math.min(a, b); + let max = Math.max(a, b); - var f = h - Math.floor(h); - var p = 255 * v * (1 - s); - var q = 255 * v * (1 - (s * f)); - var t = 255 * v * (1 - (s * (1 - f))); - v *= 255; + if (options.toRegex && step === 1) { + return toRange(min, max, false, options); + } - switch (hi) { - case 0: - return [v, t, p]; - case 1: - return [q, v, p]; - case 2: - return [p, v, t]; - case 3: - return [p, q, v]; - case 4: - return [t, p, v]; - case 5: - return [v, p, q]; - } -}; + let range = []; + let index = 0; -convert$6.hsv.hsl = function (hsv) { - var h = hsv[0]; - var s = hsv[1] / 100; - var v = hsv[2] / 100; - var vmin = Math.max(v, 0.01); - var lmin; - var sl; - var l; + while (descending ? a >= b : a <= b) { + range.push(format(a, index)); + a = descending ? a - step : a + step; + index++; + } - l = (2 - s) * v; - lmin = (2 - s) * vmin; - sl = s * vmin; - sl /= (lmin <= 1) ? lmin : 2 - lmin; - sl = sl || 0; - l /= 2; + if (options.toRegex === true) { + return toRegex(range, null, { wrap: false, options }); + } - return [h, sl * 100, l * 100]; + return range; }; -// http://dev.w3.org/csswg/css-color/#hwb-to-rgb -convert$6.hwb.rgb = function (hwb) { - var h = hwb[0] / 360; - var wh = hwb[1] / 100; - var bl = hwb[2] / 100; - var ratio = wh + bl; - var i; - var v; - var f; - var n; - - // wh + bl cant be > 1 - if (ratio > 1) { - wh /= ratio; - bl /= ratio; - } - - i = Math.floor(6 * h); - v = 1 - bl; - f = 6 * h - i; +const fill$2 = (start, end, step, options = {}) => { + if (end == null && isValidValue(start)) { + return [start]; + } - if ((i & 0x01) !== 0) { - f = 1 - f; - } + if (!isValidValue(start) || !isValidValue(end)) { + return invalidRange(start, end, options); + } - n = wh + f * (v - wh); // linear interpolation + if (typeof step === 'function') { + return fill$2(start, end, 1, { transform: step }); + } - var r; - var g; - var b; - switch (i) { - default: - case 6: - case 0: r = v; g = n; b = wh; break; - case 1: r = n; g = v; b = wh; break; - case 2: r = wh; g = v; b = n; break; - case 3: r = wh; g = n; b = v; break; - case 4: r = n; g = wh; b = v; break; - case 5: r = v; g = wh; b = n; break; - } + if (isObject$2(step)) { + return fill$2(start, end, 0, step); + } - return [r * 255, g * 255, b * 255]; -}; + let opts = { ...options }; + if (opts.capture === true) opts.wrap = true; + step = step || opts.step || 1; -convert$6.cmyk.rgb = function (cmyk) { - var c = cmyk[0] / 100; - var m = cmyk[1] / 100; - var y = cmyk[2] / 100; - var k = cmyk[3] / 100; - var r; - var g; - var b; + if (!isNumber$1(step)) { + if (step != null && !isObject$2(step)) return invalidStep(step, opts); + return fill$2(start, end, 1, step); + } - r = 1 - Math.min(1, c * (1 - k) + k); - g = 1 - Math.min(1, m * (1 - k) + k); - b = 1 - Math.min(1, y * (1 - k) + k); + if (isNumber$1(start) && isNumber$1(end)) { + return fillNumbers(start, end, step, opts); + } - return [r * 255, g * 255, b * 255]; + return fillLetters(start, end, Math.max(Math.abs(step), 1), opts); }; -convert$6.xyz.rgb = function (xyz) { - var x = xyz[0] / 100; - var y = xyz[1] / 100; - var z = xyz[2] / 100; - var r; - var g; - var b; +var fillRange = fill$2; - r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); - g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); - b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); +const fill$1 = fillRange; +const utils$1 = utils$3; - // assume sRGB - r = r > 0.0031308 - ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) - : r * 12.92; +const compile$1 = (ast, options = {}) => { + let walk = (node, parent = {}) => { + let invalidBlock = utils$1.isInvalidBrace(parent); + let invalidNode = node.invalid === true && options.escapeInvalid === true; + let invalid = invalidBlock === true || invalidNode === true; + let prefix = options.escapeInvalid === true ? '\\' : ''; + let output = ''; - g = g > 0.0031308 - ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) - : g * 12.92; + if (node.isOpen === true) { + return prefix + node.value; + } + if (node.isClose === true) { + return prefix + node.value; + } - b = b > 0.0031308 - ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) - : b * 12.92; + if (node.type === 'open') { + return invalid ? (prefix + node.value) : '('; + } - r = Math.min(Math.max(0, r), 1); - g = Math.min(Math.max(0, g), 1); - b = Math.min(Math.max(0, b), 1); + if (node.type === 'close') { + return invalid ? (prefix + node.value) : ')'; + } - return [r * 255, g * 255, b * 255]; -}; + if (node.type === 'comma') { + return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|'); + } -convert$6.xyz.lab = function (xyz) { - var x = xyz[0]; - var y = xyz[1]; - var z = xyz[2]; - var l; - var a; - var b; + if (node.value) { + return node.value; + } - x /= 95.047; - y /= 100; - z /= 108.883; + if (node.nodes && node.ranges > 0) { + let args = utils$1.reduce(node.nodes); + let range = fill$1(...args, { ...options, wrap: false, toRegex: true }); - x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); + if (range.length !== 0) { + return args.length > 1 && range.length > 1 ? `(${range})` : range; + } + } - l = (116 * y) - 16; - a = 500 * (x - y); - b = 200 * (y - z); + if (node.nodes) { + for (let child of node.nodes) { + output += walk(child, node); + } + } + return output; + }; - return [l, a, b]; + return walk(ast); }; -convert$6.lab.xyz = function (lab) { - var l = lab[0]; - var a = lab[1]; - var b = lab[2]; - var x; - var y; - var z; +var compile_1 = compile$1; - y = (l + 16) / 116; - x = a / 500 + y; - z = y - b / 200; +const fill = fillRange; +const stringify$4 = stringify$6; +const utils = utils$3; - var y2 = Math.pow(y, 3); - var x2 = Math.pow(x, 3); - var z2 = Math.pow(z, 3); - y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; - x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; - z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; +const append = (queue = '', stash = '', enclose = false) => { + let result = []; - x *= 95.047; - y *= 100; - z *= 108.883; + queue = [].concat(queue); + stash = [].concat(stash); - return [x, y, z]; + if (!stash.length) return queue; + if (!queue.length) { + return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash; + } + + for (let item of queue) { + if (Array.isArray(item)) { + for (let value of item) { + result.push(append(value, stash, enclose)); + } + } else { + for (let ele of stash) { + if (enclose === true && typeof ele === 'string') ele = `{${ele}}`; + result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele)); + } + } + } + return utils.flatten(result); }; -convert$6.lab.lch = function (lab) { - var l = lab[0]; - var a = lab[1]; - var b = lab[2]; - var hr; - var h; - var c; +const expand$4 = (ast, options = {}) => { + let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit; - hr = Math.atan2(b, a); - h = hr * 360 / 2 / Math.PI; + let walk = (node, parent = {}) => { + node.queue = []; - if (h < 0) { - h += 360; - } + let p = parent; + let q = parent.queue; - c = Math.sqrt(a * a + b * b); + while (p.type !== 'brace' && p.type !== 'root' && p.parent) { + p = p.parent; + q = p.queue; + } - return [l, c, h]; -}; + if (node.invalid || node.dollar) { + q.push(append(q.pop(), stringify$4(node, options))); + return; + } -convert$6.lch.lab = function (lch) { - var l = lch[0]; - var c = lch[1]; - var h = lch[2]; - var a; - var b; - var hr; + if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) { + q.push(append(q.pop(), ['{}'])); + return; + } - hr = h / 360 * 2 * Math.PI; - a = c * Math.cos(hr); - b = c * Math.sin(hr); + if (node.nodes && node.ranges > 0) { + let args = utils.reduce(node.nodes); - return [l, a, b]; -}; - -convert$6.rgb.ansi16 = function (args) { - var r = args[0]; - var g = args[1]; - var b = args[2]; - var value = 1 in arguments ? arguments[1] : convert$6.rgb.hsv(args)[2]; // hsv -> ansi16 optimization - - value = Math.round(value / 50); + if (utils.exceedsLimit(...args, options.step, rangeLimit)) { + throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.'); + } - if (value === 0) { - return 30; - } + let range = fill(...args, options); + if (range.length === 0) { + range = stringify$4(node, options); + } - var ansi = 30 - + ((Math.round(b / 255) << 2) - | (Math.round(g / 255) << 1) - | Math.round(r / 255)); + q.push(append(q.pop(), range)); + node.nodes = []; + return; + } - if (value === 2) { - ansi += 60; - } + let enclose = utils.encloseBrace(node); + let queue = node.queue; + let block = node; - return ansi; -}; + while (block.type !== 'brace' && block.type !== 'root' && block.parent) { + block = block.parent; + queue = block.queue; + } -convert$6.hsv.ansi16 = function (args) { - // optimization here; we already know the value and don't need to get - // it converted for us. - return convert$6.rgb.ansi16(convert$6.hsv.rgb(args), args[2]); -}; + for (let i = 0; i < node.nodes.length; i++) { + let child = node.nodes[i]; -convert$6.rgb.ansi256 = function (args) { - var r = args[0]; - var g = args[1]; - var b = args[2]; + if (child.type === 'comma' && node.type === 'brace') { + if (i === 1) queue.push(''); + queue.push(''); + continue; + } - // we use the extended greyscale palette here, with the exception of - // black and white. normal palette only has 4 greyscale shades. - if (r === g && g === b) { - if (r < 8) { - return 16; - } + if (child.type === 'close') { + q.push(append(q.pop(), queue, enclose)); + continue; + } - if (r > 248) { - return 231; - } + if (child.value && child.type !== 'open') { + queue.push(append(queue.pop(), child.value)); + continue; + } - return Math.round(((r - 8) / 247) * 24) + 232; - } + if (child.nodes) { + walk(child, node); + } + } - var ansi = 16 - + (36 * Math.round(r / 255 * 5)) - + (6 * Math.round(g / 255 * 5)) - + Math.round(b / 255 * 5); + return queue; + }; - return ansi; + return utils.flatten(walk(ast)); }; -convert$6.ansi16.rgb = function (args) { - var color = args % 10; +var expand_1 = expand$4; - // handle greyscale - if (color === 0 || color === 7) { - if (args > 50) { - color += 3.5; - } +var constants$2 = { + MAX_LENGTH: 1024 * 64, - color = color / 10.5 * 255; + // Digits + CHAR_0: '0', /* 0 */ + CHAR_9: '9', /* 9 */ - return [color, color, color]; - } + // Alphabet chars. + CHAR_UPPERCASE_A: 'A', /* A */ + CHAR_LOWERCASE_A: 'a', /* a */ + CHAR_UPPERCASE_Z: 'Z', /* Z */ + CHAR_LOWERCASE_Z: 'z', /* z */ - var mult = (~~(args > 50) + 1) * 0.5; - var r = ((color & 1) * mult) * 255; - var g = (((color >> 1) & 1) * mult) * 255; - var b = (((color >> 2) & 1) * mult) * 255; + CHAR_LEFT_PARENTHESES: '(', /* ( */ + CHAR_RIGHT_PARENTHESES: ')', /* ) */ - return [r, g, b]; -}; + CHAR_ASTERISK: '*', /* * */ -convert$6.ansi256.rgb = function (args) { - // handle greyscale - if (args >= 232) { - var c = (args - 232) * 10 + 8; - return [c, c, c]; - } + // Non-alphabetic chars. + CHAR_AMPERSAND: '&', /* & */ + CHAR_AT: '@', /* @ */ + CHAR_BACKSLASH: '\\', /* \ */ + CHAR_BACKTICK: '`', /* ` */ + CHAR_CARRIAGE_RETURN: '\r', /* \r */ + CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */ + CHAR_COLON: ':', /* : */ + CHAR_COMMA: ',', /* , */ + CHAR_DOLLAR: '$', /* . */ + CHAR_DOT: '.', /* . */ + CHAR_DOUBLE_QUOTE: '"', /* " */ + CHAR_EQUAL: '=', /* = */ + CHAR_EXCLAMATION_MARK: '!', /* ! */ + CHAR_FORM_FEED: '\f', /* \f */ + CHAR_FORWARD_SLASH: '/', /* / */ + CHAR_HASH: '#', /* # */ + CHAR_HYPHEN_MINUS: '-', /* - */ + CHAR_LEFT_ANGLE_BRACKET: '<', /* < */ + CHAR_LEFT_CURLY_BRACE: '{', /* { */ + CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */ + CHAR_LINE_FEED: '\n', /* \n */ + CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */ + CHAR_PERCENT: '%', /* % */ + CHAR_PLUS: '+', /* + */ + CHAR_QUESTION_MARK: '?', /* ? */ + CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */ + CHAR_RIGHT_CURLY_BRACE: '}', /* } */ + CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */ + CHAR_SEMICOLON: ';', /* ; */ + CHAR_SINGLE_QUOTE: '\'', /* ' */ + CHAR_SPACE: ' ', /* */ + CHAR_TAB: '\t', /* \t */ + CHAR_UNDERSCORE: '_', /* _ */ + CHAR_VERTICAL_LINE: '|', /* | */ + CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */ +}; - args -= 16; +const stringify$3 = stringify$6; - var rem; - var r = Math.floor(args / 36) / 5 * 255; - var g = Math.floor((rem = args % 36) / 6) / 5 * 255; - var b = (rem % 6) / 5 * 255; +/** + * Constants + */ - return [r, g, b]; -}; +const { + MAX_LENGTH: MAX_LENGTH$3, + CHAR_BACKSLASH, /* \ */ + CHAR_BACKTICK, /* ` */ + CHAR_COMMA: CHAR_COMMA$1, /* , */ + CHAR_DOT, /* . */ + CHAR_LEFT_PARENTHESES, /* ( */ + CHAR_RIGHT_PARENTHESES, /* ) */ + CHAR_LEFT_CURLY_BRACE, /* { */ + CHAR_RIGHT_CURLY_BRACE, /* } */ + CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$1, /* [ */ + CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$1, /* ] */ + CHAR_DOUBLE_QUOTE: CHAR_DOUBLE_QUOTE$1, /* " */ + CHAR_SINGLE_QUOTE: CHAR_SINGLE_QUOTE$1, /* ' */ + CHAR_NO_BREAK_SPACE, + CHAR_ZERO_WIDTH_NOBREAK_SPACE +} = constants$2; -convert$6.rgb.hex = function (args) { - var integer = ((Math.round(args[0]) & 0xFF) << 16) - + ((Math.round(args[1]) & 0xFF) << 8) - + (Math.round(args[2]) & 0xFF); +/** + * parse + */ - var string = integer.toString(16).toUpperCase(); - return '000000'.substring(string.length) + string; -}; +const parse$c = (input, options = {}) => { + if (typeof input !== 'string') { + throw new TypeError('Expected a string'); + } -convert$6.hex.rgb = function (args) { - var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); - if (!match) { - return [0, 0, 0]; - } + let opts = options || {}; + let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$3, opts.maxLength) : MAX_LENGTH$3; + if (input.length > max) { + throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`); + } - var colorString = match[0]; + let ast = { type: 'root', input, nodes: [] }; + let stack = [ast]; + let block = ast; + let prev = ast; + let brackets = 0; + let length = input.length; + let index = 0; + let depth = 0; + let value; - if (match[0].length === 3) { - colorString = colorString.split('').map(function (char) { - return char + char; - }).join(''); - } + /** + * Helpers + */ - var integer = parseInt(colorString, 16); - var r = (integer >> 16) & 0xFF; - var g = (integer >> 8) & 0xFF; - var b = integer & 0xFF; + const advance = () => input[index++]; + const push = node => { + if (node.type === 'text' && prev.type === 'dot') { + prev.type = 'text'; + } - return [r, g, b]; -}; + if (prev && prev.type === 'text' && node.type === 'text') { + prev.value += node.value; + return; + } -convert$6.rgb.hcg = function (rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var max = Math.max(Math.max(r, g), b); - var min = Math.min(Math.min(r, g), b); - var chroma = (max - min); - var grayscale; - var hue; + block.nodes.push(node); + node.parent = block; + node.prev = prev; + prev = node; + return node; + }; - if (chroma < 1) { - grayscale = min / (1 - chroma); - } else { - grayscale = 0; - } + push({ type: 'bos' }); - if (chroma <= 0) { - hue = 0; - } else - if (max === r) { - hue = ((g - b) / chroma) % 6; - } else - if (max === g) { - hue = 2 + (b - r) / chroma; - } else { - hue = 4 + (r - g) / chroma + 4; - } + while (index < length) { + block = stack[stack.length - 1]; + value = advance(); - hue /= 6; - hue %= 1; + /** + * Invalid chars + */ - return [hue * 360, chroma * 100, grayscale * 100]; -}; + if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) { + continue; + } -convert$6.hsl.hcg = function (hsl) { - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var c = 1; - var f = 0; + /** + * Escaped chars + */ - if (l < 0.5) { - c = 2.0 * s * l; - } else { - c = 2.0 * s * (1.0 - l); - } + if (value === CHAR_BACKSLASH) { + push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() }); + continue; + } - if (c < 1.0) { - f = (l - 0.5 * c) / (1.0 - c); - } + /** + * Right square bracket (literal): ']' + */ - return [hsl[0], c * 100, f * 100]; -}; + if (value === CHAR_RIGHT_SQUARE_BRACKET$1) { + push({ type: 'text', value: '\\' + value }); + continue; + } -convert$6.hsv.hcg = function (hsv) { - var s = hsv[1] / 100; - var v = hsv[2] / 100; + /** + * Left square bracket: '[' + */ - var c = s * v; - var f = 0; + if (value === CHAR_LEFT_SQUARE_BRACKET$1) { + brackets++; + let next; - if (c < 1.0) { - f = (v - c) / (1 - c); - } + while (index < length && (next = advance())) { + value += next; - return [hsv[0], c * 100, f * 100]; -}; + if (next === CHAR_LEFT_SQUARE_BRACKET$1) { + brackets++; + continue; + } -convert$6.hcg.rgb = function (hcg) { - var h = hcg[0] / 360; - var c = hcg[1] / 100; - var g = hcg[2] / 100; + if (next === CHAR_BACKSLASH) { + value += advance(); + continue; + } - if (c === 0.0) { - return [g * 255, g * 255, g * 255]; - } + if (next === CHAR_RIGHT_SQUARE_BRACKET$1) { + brackets--; - var pure = [0, 0, 0]; - var hi = (h % 1) * 6; - var v = hi % 1; - var w = 1 - v; - var mg = 0; + if (brackets === 0) { + break; + } + } + } - switch (Math.floor(hi)) { - case 0: - pure[0] = 1; pure[1] = v; pure[2] = 0; break; - case 1: - pure[0] = w; pure[1] = 1; pure[2] = 0; break; - case 2: - pure[0] = 0; pure[1] = 1; pure[2] = v; break; - case 3: - pure[0] = 0; pure[1] = w; pure[2] = 1; break; - case 4: - pure[0] = v; pure[1] = 0; pure[2] = 1; break; - default: - pure[0] = 1; pure[1] = 0; pure[2] = w; - } + push({ type: 'text', value }); + continue; + } - mg = (1.0 - c) * g; + /** + * Parentheses + */ - return [ - (c * pure[0] + mg) * 255, - (c * pure[1] + mg) * 255, - (c * pure[2] + mg) * 255 - ]; -}; + if (value === CHAR_LEFT_PARENTHESES) { + block = push({ type: 'paren', nodes: [] }); + stack.push(block); + push({ type: 'text', value }); + continue; + } -convert$6.hcg.hsv = function (hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; + if (value === CHAR_RIGHT_PARENTHESES) { + if (block.type !== 'paren') { + push({ type: 'text', value }); + continue; + } + block = stack.pop(); + push({ type: 'text', value }); + block = stack[stack.length - 1]; + continue; + } - var v = c + g * (1.0 - c); - var f = 0; + /** + * Quotes: '|"|` + */ - if (v > 0.0) { - f = c / v; - } + if (value === CHAR_DOUBLE_QUOTE$1 || value === CHAR_SINGLE_QUOTE$1 || value === CHAR_BACKTICK) { + let open = value; + let next; - return [hcg[0], f * 100, v * 100]; -}; + if (options.keepQuotes !== true) { + value = ''; + } -convert$6.hcg.hsl = function (hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; + while (index < length && (next = advance())) { + if (next === CHAR_BACKSLASH) { + value += next + advance(); + continue; + } - var l = g * (1.0 - c) + 0.5 * c; - var s = 0; + if (next === open) { + if (options.keepQuotes === true) value += next; + break; + } - if (l > 0.0 && l < 0.5) { - s = c / (2 * l); - } else - if (l >= 0.5 && l < 1.0) { - s = c / (2 * (1 - l)); - } + value += next; + } - return [hcg[0], s * 100, l * 100]; -}; + push({ type: 'text', value }); + continue; + } -convert$6.hcg.hwb = function (hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; - var v = c + g * (1.0 - c); - return [hcg[0], (v - c) * 100, (1 - v) * 100]; -}; + /** + * Left curly brace: '{' + */ -convert$6.hwb.hcg = function (hwb) { - var w = hwb[1] / 100; - var b = hwb[2] / 100; - var v = 1 - b; - var c = v - w; - var g = 0; + if (value === CHAR_LEFT_CURLY_BRACE) { + depth++; - if (c < 1) { - g = (v - c) / (1 - c); - } + let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true; + let brace = { + type: 'brace', + open: true, + close: false, + dollar, + depth, + commas: 0, + ranges: 0, + nodes: [] + }; - return [hwb[0], c * 100, g * 100]; -}; + block = push(brace); + stack.push(block); + push({ type: 'open', value }); + continue; + } -convert$6.apple.rgb = function (apple) { - return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; -}; + /** + * Right curly brace: '}' + */ -convert$6.rgb.apple = function (rgb) { - return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; -}; + if (value === CHAR_RIGHT_CURLY_BRACE) { + if (block.type !== 'brace') { + push({ type: 'text', value }); + continue; + } -convert$6.gray.rgb = function (args) { - return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; -}; + let type = 'close'; + block = stack.pop(); + block.close = true; -convert$6.gray.hsl = convert$6.gray.hsv = function (args) { - return [0, 0, args[0]]; -}; + push({ type, value }); + depth--; -convert$6.gray.hwb = function (gray) { - return [0, 100, gray[0]]; -}; + block = stack[stack.length - 1]; + continue; + } -convert$6.gray.cmyk = function (gray) { - return [0, 0, 0, gray[0]]; -}; + /** + * Comma: ',' + */ -convert$6.gray.lab = function (gray) { - return [gray[0], 0, 0]; -}; + if (value === CHAR_COMMA$1 && depth > 0) { + if (block.ranges > 0) { + block.ranges = 0; + let open = block.nodes.shift(); + block.nodes = [open, { type: 'text', value: stringify$3(block) }]; + } -convert$6.gray.hex = function (gray) { - var val = Math.round(gray[0] / 100 * 255) & 0xFF; - var integer = (val << 16) + (val << 8) + val; + push({ type: 'comma', value }); + block.commas++; + continue; + } - var string = integer.toString(16).toUpperCase(); - return '000000'.substring(string.length) + string; -}; - -convert$6.rgb.gray = function (rgb) { - var val = (rgb[0] + rgb[1] + rgb[2]) / 3; - return [val / 255 * 100]; -}; - -var conversions$4 = conversions$5.exports; - -/* - this function routes a model to all other models. - - all functions that are routed have a property `.conversion` attached - to the returned synthetic function. This property is an array - of strings, each with the steps in between the 'from' and 'to' - color models (inclusive). - - conversions that are not possible simply are not included. -*/ - -function buildGraph$1() { - var graph = {}; - // https://jsperf.com/object-keys-vs-for-in-with-closure/3 - var models = Object.keys(conversions$4); - - for (var len = models.length, i = 0; i < len; i++) { - graph[models[i]] = { - // http://jsperf.com/1-vs-infinity - // micro-opt, but this is simple. - distance: -1, - parent: null - }; - } - - return graph; -} - -// https://en.wikipedia.org/wiki/Breadth-first_search -function deriveBFS$1(fromModel) { - var graph = buildGraph$1(); - var queue = [fromModel]; // unshift -> queue -> pop + /** + * Dot: '.' + */ - graph[fromModel].distance = 0; + if (value === CHAR_DOT && depth > 0 && block.commas === 0) { + let siblings = block.nodes; - while (queue.length) { - var current = queue.pop(); - var adjacents = Object.keys(conversions$4[current]); + if (depth === 0 || siblings.length === 0) { + push({ type: 'text', value }); + continue; + } - for (var len = adjacents.length, i = 0; i < len; i++) { - var adjacent = adjacents[i]; - var node = graph[adjacent]; + if (prev.type === 'dot') { + block.range = []; + prev.value += value; + prev.type = 'range'; - if (node.distance === -1) { - node.distance = graph[current].distance + 1; - node.parent = current; - queue.unshift(adjacent); - } - } - } + if (block.nodes.length !== 3 && block.nodes.length !== 5) { + block.invalid = true; + block.ranges = 0; + prev.type = 'text'; + continue; + } - return graph; -} + block.ranges++; + block.args = []; + continue; + } -function link$2(from, to) { - return function (args) { - return to(from(args)); - }; -} + if (prev.type === 'range') { + siblings.pop(); -function wrapConversion$1(toModel, graph) { - var path = [graph[toModel].parent, toModel]; - var fn = conversions$4[graph[toModel].parent][toModel]; + let before = siblings[siblings.length - 1]; + before.value += prev.value + value; + prev = before; + block.ranges--; + continue; + } - var cur = graph[toModel].parent; - while (graph[cur].parent) { - path.unshift(graph[cur].parent); - fn = link$2(conversions$4[graph[cur].parent][cur], fn); - cur = graph[cur].parent; - } + push({ type: 'dot', value }); + continue; + } - fn.conversion = path; - return fn; -} + /** + * Text + */ -var route$3 = function (fromModel) { - var graph = deriveBFS$1(fromModel); - var conversion = {}; + push({ type: 'text', value }); + } - var models = Object.keys(graph); - for (var len = models.length, i = 0; i < len; i++) { - var toModel = models[i]; - var node = graph[toModel]; + // Mark imbalanced braces and brackets as invalid + do { + block = stack.pop(); - if (node.parent === null) { - // no possible conversion, or this node is the source model. - continue; - } + if (block.type !== 'root') { + block.nodes.forEach(node => { + if (!node.nodes) { + if (node.type === 'open') node.isOpen = true; + if (node.type === 'close') node.isClose = true; + if (!node.nodes) node.type = 'text'; + node.invalid = true; + } + }); - conversion[toModel] = wrapConversion$1(toModel, graph); - } + // get the location of the block on parent.nodes (block's siblings) + let parent = stack[stack.length - 1]; + let index = parent.nodes.indexOf(block); + // replace the (invalid) block with it's nodes + parent.nodes.splice(index, 1, ...block.nodes); + } + } while (stack.length > 0); - return conversion; + push({ type: 'eos' }); + return ast; }; -var conversions$3 = conversions$5.exports; -var route$2 = route$3; - -var convert$5 = {}; - -var models$4 = Object.keys(conversions$3); - -function wrapRaw$1(fn) { - var wrappedFn = function (args) { - if (args === undefined || args === null) { - return args; - } - - if (arguments.length > 1) { - args = Array.prototype.slice.call(arguments); - } - - return fn(args); - }; - - // preserve .conversion property if there is one - if ('conversion' in fn) { - wrappedFn.conversion = fn.conversion; - } - - return wrappedFn; -} - -function wrapRounded$1(fn) { - var wrappedFn = function (args) { - if (args === undefined || args === null) { - return args; - } - - if (arguments.length > 1) { - args = Array.prototype.slice.call(arguments); - } - - var result = fn(args); - - // we're assuming the result is an array here. - // see notice in conversions.js; don't use box types - // in conversion functions. - if (typeof result === 'object') { - for (var len = result.length, i = 0; i < len; i++) { - result[i] = Math.round(result[i]); - } - } - - return result; - }; - - // preserve .conversion property if there is one - if ('conversion' in fn) { - wrappedFn.conversion = fn.conversion; - } +var parse_1$1 = parse$c; - return wrappedFn; -} +const stringify$2 = stringify$6; +const compile = compile_1; +const expand$3 = expand_1; +const parse$b = parse_1$1; -models$4.forEach(function (fromModel) { - convert$5[fromModel] = {}; +/** + * Expand the given pattern or create a regex-compatible string. + * + * ```js + * const braces = require('braces'); + * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)'] + * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c'] + * ``` + * @param {String} `str` + * @param {Object} `options` + * @return {String} + * @api public + */ - Object.defineProperty(convert$5[fromModel], 'channels', {value: conversions$3[fromModel].channels}); - Object.defineProperty(convert$5[fromModel], 'labels', {value: conversions$3[fromModel].labels}); +const braces$1 = (input, options = {}) => { + let output = []; - var routes = route$2(fromModel); - var routeModels = Object.keys(routes); + if (Array.isArray(input)) { + for (let pattern of input) { + let result = braces$1.create(pattern, options); + if (Array.isArray(result)) { + output.push(...result); + } else { + output.push(result); + } + } + } else { + output = [].concat(braces$1.create(input, options)); + } - routeModels.forEach(function (toModel) { - var fn = routes[toModel]; + if (options && options.expand === true && options.nodupes === true) { + output = [...new Set(output)]; + } + return output; +}; - convert$5[fromModel][toModel] = wrapRounded$1(fn); - convert$5[fromModel][toModel].raw = wrapRaw$1(fn); - }); -}); +/** + * Parse the given `str` with the given `options`. + * + * ```js + * // braces.parse(pattern, [, options]); + * const ast = braces.parse('a/{b,c}/d'); + * console.log(ast); + * ``` + * @param {String} pattern Brace pattern to parse + * @param {Object} options + * @return {Object} Returns an AST + * @api public + */ -var colorConvert$1 = convert$5; +braces$1.parse = (input, options = {}) => parse$b(input, options); -(function (module) { -const colorConvert = colorConvert$1; +/** + * Creates a braces string from an AST, or an AST node. + * + * ```js + * const braces = require('braces'); + * let ast = braces.parse('foo/{a,b}/bar'); + * console.log(stringify(ast.nodes[2])); //=> '{a,b}' + * ``` + * @param {String} `input` Brace pattern or AST. + * @param {Object} `options` + * @return {Array} Returns an array of expanded values. + * @api public + */ -const wrapAnsi16 = (fn, offset) => function () { - const code = fn.apply(colorConvert, arguments); - return `\u001B[${code + offset}m`; +braces$1.stringify = (input, options = {}) => { + if (typeof input === 'string') { + return stringify$2(braces$1.parse(input, options), options); + } + return stringify$2(input, options); }; -const wrapAnsi256 = (fn, offset) => function () { - const code = fn.apply(colorConvert, arguments); - return `\u001B[${38 + offset};5;${code}m`; -}; +/** + * Compiles a brace pattern into a regex-compatible, optimized string. + * This method is called by the main [braces](#braces) function by default. + * + * ```js + * const braces = require('braces'); + * console.log(braces.compile('a/{b,c}/d')); + * //=> ['a/(b|c)/d'] + * ``` + * @param {String} `input` Brace pattern or AST. + * @param {Object} `options` + * @return {Array} Returns an array of expanded values. + * @api public + */ -const wrapAnsi16m = (fn, offset) => function () { - const rgb = fn.apply(colorConvert, arguments); - return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; +braces$1.compile = (input, options = {}) => { + if (typeof input === 'string') { + input = braces$1.parse(input, options); + } + return compile(input, options); }; -function assembleStyles() { - const codes = new Map(); - const styles = { - modifier: { - reset: [0, 0], - // 21 isn't widely supported and 22 does the same thing - bold: [1, 22], - dim: [2, 22], - italic: [3, 23], - underline: [4, 24], - inverse: [7, 27], - hidden: [8, 28], - strikethrough: [9, 29] - }, - color: { - black: [30, 39], - red: [31, 39], - green: [32, 39], - yellow: [33, 39], - blue: [34, 39], - magenta: [35, 39], - cyan: [36, 39], - white: [37, 39], - gray: [90, 39], - - // Bright color - redBright: [91, 39], - greenBright: [92, 39], - yellowBright: [93, 39], - blueBright: [94, 39], - magentaBright: [95, 39], - cyanBright: [96, 39], - whiteBright: [97, 39] - }, - bgColor: { - bgBlack: [40, 49], - bgRed: [41, 49], - bgGreen: [42, 49], - bgYellow: [43, 49], - bgBlue: [44, 49], - bgMagenta: [45, 49], - bgCyan: [46, 49], - bgWhite: [47, 49], - - // Bright color - bgBlackBright: [100, 49], - bgRedBright: [101, 49], - bgGreenBright: [102, 49], - bgYellowBright: [103, 49], - bgBlueBright: [104, 49], - bgMagentaBright: [105, 49], - bgCyanBright: [106, 49], - bgWhiteBright: [107, 49] - } - }; - - // Fix humans - styles.color.grey = styles.color.gray; - - for (const groupName of Object.keys(styles)) { - const group = styles[groupName]; - - for (const styleName of Object.keys(group)) { - const style = group[styleName]; - - styles[styleName] = { - open: `\u001B[${style[0]}m`, - close: `\u001B[${style[1]}m` - }; - - group[styleName] = styles[styleName]; - - codes.set(style[0], style[1]); - } - - Object.defineProperty(styles, groupName, { - value: group, - enumerable: false - }); - - Object.defineProperty(styles, 'codes', { - value: codes, - enumerable: false - }); - } - - const ansi2ansi = n => n; - const rgb2rgb = (r, g, b) => [r, g, b]; - - styles.color.close = '\u001B[39m'; - styles.bgColor.close = '\u001B[49m'; - - styles.color.ansi = { - ansi: wrapAnsi16(ansi2ansi, 0) - }; - styles.color.ansi256 = { - ansi256: wrapAnsi256(ansi2ansi, 0) - }; - styles.color.ansi16m = { - rgb: wrapAnsi16m(rgb2rgb, 0) - }; - - styles.bgColor.ansi = { - ansi: wrapAnsi16(ansi2ansi, 10) - }; - styles.bgColor.ansi256 = { - ansi256: wrapAnsi256(ansi2ansi, 10) - }; - styles.bgColor.ansi16m = { - rgb: wrapAnsi16m(rgb2rgb, 10) - }; - - for (let key of Object.keys(colorConvert)) { - if (typeof colorConvert[key] !== 'object') { - continue; - } - - const suite = colorConvert[key]; - - if (key === 'ansi16') { - key = 'ansi'; - } - - if ('ansi16' in suite) { - styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); - styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); - } +/** + * Expands a brace pattern into an array. This method is called by the + * main [braces](#braces) function when `options.expand` is true. Before + * using this method it's recommended that you read the [performance notes](#performance)) + * and advantages of using [.compile](#compile) instead. + * + * ```js + * const braces = require('braces'); + * console.log(braces.expand('a/{b,c}/d')); + * //=> ['a/b/d', 'a/c/d']; + * ``` + * @param {String} `pattern` Brace pattern + * @param {Object} `options` + * @return {Array} Returns an array of expanded values. + * @api public + */ - if ('ansi256' in suite) { - styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); - styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); - } +braces$1.expand = (input, options = {}) => { + if (typeof input === 'string') { + input = braces$1.parse(input, options); + } - if ('rgb' in suite) { - styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); - styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); - } - } + let result = expand$3(input, options); - return styles; -} + // filter out empty strings if specified + if (options.noempty === true) { + result = result.filter(Boolean); + } -// Make the export immutable -Object.defineProperty(module, 'exports', { - enumerable: true, - get: assembleStyles -}); -}(ansiStyles$2)); + // filter out duplicates if specified + if (options.nodupes === true) { + result = [...new Set(result)]; + } -var hasFlag$5 = (flag, argv) => { - argv = argv || process.argv; - const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); - const pos = argv.indexOf(prefix + flag); - const terminatorPos = argv.indexOf('--'); - return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); + return result; }; -const os$3 = require$$0__default$1['default']; -const hasFlag$4 = hasFlag$5; - -const env$2 = process.env; +/** + * Processes a brace pattern and returns either an expanded array + * (if `options.expand` is true), a highly optimized regex-compatible string. + * This method is called by the main [braces](#braces) function. + * + * ```js + * const braces = require('braces'); + * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}')) + * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)' + * ``` + * @param {String} `pattern` Brace pattern + * @param {Object} `options` + * @return {Array} Returns an array of expanded values. + * @api public + */ -let forceColor$2; -if (hasFlag$4('no-color') || - hasFlag$4('no-colors') || - hasFlag$4('color=false')) { - forceColor$2 = false; -} else if (hasFlag$4('color') || - hasFlag$4('colors') || - hasFlag$4('color=true') || - hasFlag$4('color=always')) { - forceColor$2 = true; -} -if ('FORCE_COLOR' in env$2) { - forceColor$2 = env$2.FORCE_COLOR.length === 0 || parseInt(env$2.FORCE_COLOR, 10) !== 0; -} +braces$1.create = (input, options = {}) => { + if (input === '' || input.length < 3) { + return [input]; + } -function translateLevel$2(level) { - if (level === 0) { - return false; - } + return options.expand !== true + ? braces$1.compile(input, options) + : braces$1.expand(input, options); +}; - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; -} +/** + * Expose "braces" + */ -function supportsColor$2(stream) { - if (forceColor$2 === false) { - return 0; - } +var braces_1 = braces$1; - if (hasFlag$4('color=16m') || - hasFlag$4('color=full') || - hasFlag$4('color=truecolor')) { - return 3; - } - - if (hasFlag$4('color=256')) { - return 2; - } +var require$$0$1 = [ + "3dm", + "3ds", + "3g2", + "3gp", + "7z", + "a", + "aac", + "adp", + "ai", + "aif", + "aiff", + "alz", + "ape", + "apk", + "appimage", + "ar", + "arj", + "asf", + "au", + "avi", + "bak", + "baml", + "bh", + "bin", + "bk", + "bmp", + "btif", + "bz2", + "bzip2", + "cab", + "caf", + "cgm", + "class", + "cmx", + "cpio", + "cr2", + "cur", + "dat", + "dcm", + "deb", + "dex", + "djvu", + "dll", + "dmg", + "dng", + "doc", + "docm", + "docx", + "dot", + "dotm", + "dra", + "DS_Store", + "dsk", + "dts", + "dtshd", + "dvb", + "dwg", + "dxf", + "ecelp4800", + "ecelp7470", + "ecelp9600", + "egg", + "eol", + "eot", + "epub", + "exe", + "f4v", + "fbs", + "fh", + "fla", + "flac", + "flatpak", + "fli", + "flv", + "fpx", + "fst", + "fvt", + "g3", + "gh", + "gif", + "graffle", + "gz", + "gzip", + "h261", + "h263", + "h264", + "icns", + "ico", + "ief", + "img", + "ipa", + "iso", + "jar", + "jpeg", + "jpg", + "jpgv", + "jpm", + "jxr", + "key", + "ktx", + "lha", + "lib", + "lvp", + "lz", + "lzh", + "lzma", + "lzo", + "m3u", + "m4a", + "m4v", + "mar", + "mdi", + "mht", + "mid", + "midi", + "mj2", + "mka", + "mkv", + "mmr", + "mng", + "mobi", + "mov", + "movie", + "mp3", + "mp4", + "mp4a", + "mpeg", + "mpg", + "mpga", + "mxu", + "nef", + "npx", + "numbers", + "nupkg", + "o", + "odp", + "ods", + "odt", + "oga", + "ogg", + "ogv", + "otf", + "ott", + "pages", + "pbm", + "pcx", + "pdb", + "pdf", + "pea", + "pgm", + "pic", + "png", + "pnm", + "pot", + "potm", + "potx", + "ppa", + "ppam", + "ppm", + "pps", + "ppsm", + "ppsx", + "ppt", + "pptm", + "pptx", + "psd", + "pya", + "pyc", + "pyo", + "pyv", + "qt", + "rar", + "ras", + "raw", + "resources", + "rgb", + "rip", + "rlc", + "rmf", + "rmvb", + "rpm", + "rtf", + "rz", + "s3m", + "s7z", + "scpt", + "sgi", + "shar", + "snap", + "sil", + "sketch", + "slk", + "smv", + "snk", + "so", + "stl", + "suo", + "sub", + "swf", + "tar", + "tbz", + "tbz2", + "tga", + "tgz", + "thmx", + "tif", + "tiff", + "tlz", + "ttc", + "ttf", + "txz", + "udf", + "uvh", + "uvi", + "uvm", + "uvp", + "uvs", + "uvu", + "viv", + "vob", + "war", + "wav", + "wax", + "wbmp", + "wdp", + "weba", + "webm", + "webp", + "whl", + "wim", + "wm", + "wma", + "wmv", + "wmx", + "woff", + "woff2", + "wrm", + "wvx", + "xbm", + "xif", + "xla", + "xlam", + "xls", + "xlsb", + "xlsm", + "xlsx", + "xlt", + "xltm", + "xltx", + "xm", + "xmind", + "xpi", + "xpm", + "xwd", + "xz", + "z", + "zip", + "zipx" +]; - if (stream && !stream.isTTY && forceColor$2 !== true) { - return 0; - } +var binaryExtensions$1 = require$$0$1; - const min = forceColor$2 ? 1 : 0; +const path$8 = path__default['default']; +const binaryExtensions = binaryExtensions$1; - if (process.platform === 'win32') { - // Node.js 7.5.0 is the first version of Node.js to include a patch to - // libuv that enables 256 color output on Windows. Anything earlier and it - // won't work. However, here we target Node.js 8 at minimum as it is an LTS - // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows - // release that supports 256 colors. Windows 10 build 14931 is the first release - // that supports 16m/TrueColor. - const osRelease = os$3.release().split('.'); - if ( - Number(process.versions.node.split('.')[0]) >= 8 && - Number(osRelease[0]) >= 10 && - Number(osRelease[2]) >= 10586 - ) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } +const extensions = new Set(binaryExtensions); - return 1; - } +var isBinaryPath$1 = filePath => extensions.has(path$8.extname(filePath).slice(1).toLowerCase()); - if ('CI' in env$2) { - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env$2) || env$2.CI_NAME === 'codeship') { - return 1; - } +var constants$1 = {}; - return min; - } +(function (exports) { - if ('TEAMCITY_VERSION' in env$2) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$2.TEAMCITY_VERSION) ? 1 : 0; - } +const {sep} = path__default['default']; +const {platform} = process; +const os = require$$0__default['default']; - if (env$2.COLORTERM === 'truecolor') { - return 3; - } +exports.EV_ALL = 'all'; +exports.EV_READY = 'ready'; +exports.EV_ADD = 'add'; +exports.EV_CHANGE = 'change'; +exports.EV_ADD_DIR = 'addDir'; +exports.EV_UNLINK = 'unlink'; +exports.EV_UNLINK_DIR = 'unlinkDir'; +exports.EV_RAW = 'raw'; +exports.EV_ERROR = 'error'; - if ('TERM_PROGRAM' in env$2) { - const version = parseInt((env$2.TERM_PROGRAM_VERSION || '').split('.')[0], 10); +exports.STR_DATA = 'data'; +exports.STR_END = 'end'; +exports.STR_CLOSE = 'close'; - switch (env$2.TERM_PROGRAM) { - case 'iTerm.app': - return version >= 3 ? 3 : 2; - case 'Apple_Terminal': - return 2; - // No default - } - } +exports.FSEVENT_CREATED = 'created'; +exports.FSEVENT_MODIFIED = 'modified'; +exports.FSEVENT_DELETED = 'deleted'; +exports.FSEVENT_MOVED = 'moved'; +exports.FSEVENT_CLONED = 'cloned'; +exports.FSEVENT_UNKNOWN = 'unknown'; +exports.FSEVENT_TYPE_FILE = 'file'; +exports.FSEVENT_TYPE_DIRECTORY = 'directory'; +exports.FSEVENT_TYPE_SYMLINK = 'symlink'; - if (/-256(color)?$/i.test(env$2.TERM)) { - return 2; - } +exports.KEY_LISTENERS = 'listeners'; +exports.KEY_ERR = 'errHandlers'; +exports.KEY_RAW = 'rawEmitters'; +exports.HANDLER_KEYS = [exports.KEY_LISTENERS, exports.KEY_ERR, exports.KEY_RAW]; - if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) { - return 1; - } +exports.DOT_SLASH = `.${sep}`; - if ('COLORTERM' in env$2) { - return 1; - } +exports.BACK_SLASH_RE = /\\/g; +exports.DOUBLE_SLASH_RE = /\/\//; +exports.SLASH_OR_BACK_SLASH_RE = /[/\\]/; +exports.DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/; +exports.REPLACER_RE = /^\.[/\\]/; - if (env$2.TERM === 'dumb') { - return min; - } +exports.SLASH = '/'; +exports.SLASH_SLASH = '//'; +exports.BRACE_START = '{'; +exports.BANG = '!'; +exports.ONE_DOT = '.'; +exports.TWO_DOTS = '..'; +exports.STAR = '*'; +exports.GLOBSTAR = '**'; +exports.ROOT_GLOBSTAR = '/**/*'; +exports.SLASH_GLOBSTAR = '/**'; +exports.DIR_SUFFIX = 'Dir'; +exports.ANYMATCH_OPTS = {dot: true}; +exports.STRING_TYPE = 'string'; +exports.FUNCTION_TYPE = 'function'; +exports.EMPTY_STR = ''; +exports.EMPTY_FN = () => {}; +exports.IDENTITY_FN = val => val; - return min; -} +exports.isWindows = platform === 'win32'; +exports.isMacos = platform === 'darwin'; +exports.isLinux = platform === 'linux'; +exports.isIBMi = os.type() === 'OS400'; +}(constants$1)); -function getSupportLevel$2(stream) { - const level = supportsColor$2(stream); - return translateLevel$2(level); -} +const fs$8 = require$$0__default$1['default']; +const sysPath$2 = path__default['default']; +const { promisify: promisify$2 } = require$$0__default$2['default']; +const isBinaryPath = isBinaryPath$1; +const { + isWindows: isWindows$3, + isLinux, + EMPTY_FN: EMPTY_FN$2, + EMPTY_STR: EMPTY_STR$1, + KEY_LISTENERS, + KEY_ERR, + KEY_RAW, + HANDLER_KEYS, + EV_CHANGE: EV_CHANGE$2, + EV_ADD: EV_ADD$2, + EV_ADD_DIR: EV_ADD_DIR$2, + EV_ERROR: EV_ERROR$2, + STR_DATA: STR_DATA$1, + STR_END: STR_END$2, + BRACE_START: BRACE_START$1, + STAR +} = constants$1; -var supportsColor_1$2 = { - supportsColor: getSupportLevel$2, - stdout: getSupportLevel$2(process.stdout), - stderr: getSupportLevel$2(process.stderr) -}; +const THROTTLE_MODE_WATCH = 'watch'; -const TEMPLATE_REGEX$1 = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; -const STYLE_REGEX$1 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; -const STRING_REGEX$1 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; -const ESCAPE_REGEX$1 = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi; +const open = promisify$2(fs$8.open); +const stat$2 = promisify$2(fs$8.stat); +const lstat$1 = promisify$2(fs$8.lstat); +const close = promisify$2(fs$8.close); +const fsrealpath = promisify$2(fs$8.realpath); -const ESCAPES$1 = new Map([ - ['n', '\n'], - ['r', '\r'], - ['t', '\t'], - ['b', '\b'], - ['f', '\f'], - ['v', '\v'], - ['0', '\0'], - ['\\', '\\'], - ['e', '\u001B'], - ['a', '\u0007'] -]); +const statMethods$1 = { lstat: lstat$1, stat: stat$2 }; -function unescape$1(c) { - if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) { - return String.fromCharCode(parseInt(c.slice(1), 16)); - } +// TODO: emit errors properly. Example: EMFILE on Macos. +const foreach = (val, fn) => { + if (val instanceof Set) { + val.forEach(fn); + } else { + fn(val); + } +}; - return ESCAPES$1.get(c) || c; -} +const addAndConvert = (main, prop, item) => { + let container = main[prop]; + if (!(container instanceof Set)) { + main[prop] = container = new Set([container]); + } + container.add(item); +}; -function parseArguments$1(name, args) { - const results = []; - const chunks = args.trim().split(/\s*,\s*/g); - let matches; +const clearItem = cont => key => { + const set = cont[key]; + if (set instanceof Set) { + set.clear(); + } else { + delete cont[key]; + } +}; - for (const chunk of chunks) { - if (!isNaN(chunk)) { - results.push(Number(chunk)); - } else if ((matches = chunk.match(STRING_REGEX$1))) { - results.push(matches[2].replace(ESCAPE_REGEX$1, (m, escape, chr) => escape ? unescape$1(escape) : chr)); - } else { - throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); - } - } +const delFromSet = (main, prop, item) => { + const container = main[prop]; + if (container instanceof Set) { + container.delete(item); + } else if (container === item) { + delete main[prop]; + } +}; - return results; -} +const isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val; -function parseStyle$1(style) { - STYLE_REGEX$1.lastIndex = 0; +/** + * @typedef {String} Path + */ - const results = []; - let matches; +// fs_watch helpers - while ((matches = STYLE_REGEX$1.exec(style)) !== null) { - const name = matches[1]; +// object to hold per-process fs_watch instances +// (may be shared across chokidar FSWatcher instances) - if (matches[2]) { - const args = parseArguments$1(name, matches[2]); - results.push([name].concat(args)); - } else { - results.push([name]); - } - } +/** + * @typedef {Object} FsWatchContainer + * @property {Set} listeners + * @property {Set} errHandlers + * @property {Set} rawEmitters + * @property {fs.FSWatcher=} watcher + * @property {Boolean=} watcherUnusable + */ - return results; -} +/** + * @type {Map} + */ +const FsWatchInstances = new Map(); -function buildStyle$1(chalk, styles) { - const enabled = {}; +/** + * Instantiates the fs_watch interface + * @param {String} path to be watched + * @param {Object} options to be passed to fs_watch + * @param {Function} listener main event handler + * @param {Function} errHandler emits info about errors + * @param {Function} emitRaw emits raw event data + * @returns {fs.FSWatcher} new fsevents instance + */ +function createFsWatchInstance(path, options, listener, errHandler, emitRaw) { + const handleEvent = (rawEvent, evPath) => { + listener(path); + emitRaw(rawEvent, evPath, {watchedPath: path}); - for (const layer of styles) { - for (const style of layer.styles) { - enabled[style[0]] = layer.inverse ? null : style.slice(1); - } - } - - let current = chalk; - for (const styleName of Object.keys(enabled)) { - if (Array.isArray(enabled[styleName])) { - if (!(styleName in current)) { - throw new Error(`Unknown Chalk style: ${styleName}`); - } - - if (enabled[styleName].length > 0) { - current = current[styleName].apply(current, enabled[styleName]); - } else { - current = current[styleName]; - } - } - } - - return current; + // emit based on events occurring for files from a directory's watcher in + // case the file's watcher misses it (and rely on throttling to de-dupe) + if (evPath && path !== evPath) { + fsWatchBroadcast( + sysPath$2.resolve(path, evPath), KEY_LISTENERS, sysPath$2.join(path, evPath) + ); + } + }; + try { + return fs$8.watch(path, options, handleEvent); + } catch (error) { + errHandler(error); + } } -var templates$1 = (chalk, tmp) => { - const styles = []; - const chunks = []; - let chunk = []; - - // eslint-disable-next-line max-params - tmp.replace(TEMPLATE_REGEX$1, (m, escapeChar, inverse, style, close, chr) => { - if (escapeChar) { - chunk.push(unescape$1(escapeChar)); - } else if (style) { - const str = chunk.join(''); - chunk = []; - chunks.push(styles.length === 0 ? str : buildStyle$1(chalk, styles)(str)); - styles.push({inverse, styles: parseStyle$1(style)}); - } else if (close) { - if (styles.length === 0) { - throw new Error('Found extraneous } in Chalk template literal'); - } - - chunks.push(buildStyle$1(chalk, styles)(chunk.join(''))); - chunk = []; - styles.pop(); - } else { - chunk.push(chr); - } - }); +/** + * Helper for passing fs_watch event data to a collection of listeners + * @param {Path} fullPath absolute path bound to fs_watch instance + * @param {String} type listener type + * @param {*=} val1 arguments to be passed to listeners + * @param {*=} val2 + * @param {*=} val3 + */ +const fsWatchBroadcast = (fullPath, type, val1, val2, val3) => { + const cont = FsWatchInstances.get(fullPath); + if (!cont) return; + foreach(cont[type], (listener) => { + listener(val1, val2, val3); + }); +}; - chunks.push(chunk.join('')); +/** + * Instantiates the fs_watch interface or binds listeners + * to an existing one covering the same file system entry + * @param {String} path + * @param {String} fullPath absolute path + * @param {Object} options to be passed to fs_watch + * @param {Object} handlers container for event listener functions + */ +const setFsWatchListener = (path, fullPath, options, handlers) => { + const {listener, errHandler, rawEmitter} = handlers; + let cont = FsWatchInstances.get(fullPath); - if (styles.length > 0) { - const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; - throw new Error(errMsg); - } + /** @type {fs.FSWatcher=} */ + let watcher; + if (!options.persistent) { + watcher = createFsWatchInstance( + path, options, listener, errHandler, rawEmitter + ); + return watcher.close.bind(watcher); + } + if (cont) { + addAndConvert(cont, KEY_LISTENERS, listener); + addAndConvert(cont, KEY_ERR, errHandler); + addAndConvert(cont, KEY_RAW, rawEmitter); + } else { + watcher = createFsWatchInstance( + path, + options, + fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), + errHandler, // no need to use broadcast here + fsWatchBroadcast.bind(null, fullPath, KEY_RAW) + ); + if (!watcher) return; + watcher.on(EV_ERROR$2, async (error) => { + const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR); + cont.watcherUnusable = true; // documented since Node 10.4.1 + // Workaround for https://github.com/joyent/node/issues/4337 + if (isWindows$3 && error.code === 'EPERM') { + try { + const fd = await open(path, 'r'); + await close(fd); + broadcastErr(error); + } catch (err) {} + } else { + broadcastErr(error); + } + }); + cont = { + listeners: listener, + errHandlers: errHandler, + rawEmitters: rawEmitter, + watcher + }; + FsWatchInstances.set(fullPath, cont); + } + // const index = cont.listeners.indexOf(listener); - return chunks.join(''); + // removes this instance's listeners and closes the underlying fs_watch + // instance if there are no more listeners left + return () => { + delFromSet(cont, KEY_LISTENERS, listener); + delFromSet(cont, KEY_ERR, errHandler); + delFromSet(cont, KEY_RAW, rawEmitter); + if (isEmptySet(cont.listeners)) { + // Check to protect against issue gh-730. + // if (cont.watcherUnusable) { + cont.watcher.close(); + // } + FsWatchInstances.delete(fullPath); + HANDLER_KEYS.forEach(clearItem(cont)); + cont.watcher = undefined; + Object.freeze(cont); + } + }; }; -(function (module) { -const escapeStringRegexp = escapeStringRegexp$3; -const ansiStyles = ansiStyles$2.exports; -const stdoutColor = supportsColor_1$2.stdout; +// fs_watchFile helpers -const template = templates$1; +// object to hold per-process fs_watchFile instances +// (may be shared across chokidar FSWatcher instances) +const FsWatchFileInstances = new Map(); -const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); +/** + * Instantiates the fs_watchFile interface or binds listeners + * to an existing one covering the same file system entry + * @param {String} path to be watched + * @param {String} fullPath absolute path + * @param {Object} options options to be passed to fs_watchFile + * @param {Object} handlers container for event listener functions + * @returns {Function} closer + */ +const setFsWatchFileListener = (path, fullPath, options, handlers) => { + const {listener, rawEmitter} = handlers; + let cont = FsWatchFileInstances.get(fullPath); -// `supportsColor.level` → `ansiStyles.color[name]` mapping -const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; + const copts = cont && cont.options; + if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) { + fs$8.unwatchFile(fullPath); + cont = undefined; + } -// `color-convert` models to exclude from the Chalk API due to conflicts and such -const skipModels = new Set(['gray']); + /* eslint-enable no-unused-vars, prefer-destructuring */ -const styles = Object.create(null); + if (cont) { + addAndConvert(cont, KEY_LISTENERS, listener); + addAndConvert(cont, KEY_RAW, rawEmitter); + } else { + // TODO + // listeners.add(listener); + // rawEmitters.add(rawEmitter); + cont = { + listeners: listener, + rawEmitters: rawEmitter, + options, + watcher: fs$8.watchFile(fullPath, options, (curr, prev) => { + foreach(cont.rawEmitters, (rawEmitter) => { + rawEmitter(EV_CHANGE$2, fullPath, {curr, prev}); + }); + const currmtime = curr.mtimeMs; + if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) { + foreach(cont.listeners, (listener) => listener(path, curr)); + } + }) + }; + FsWatchFileInstances.set(fullPath, cont); + } + // const index = cont.listeners.indexOf(listener); -function applyOptions(obj, options) { - options = options || {}; + // Removes this instance's listeners and closes the underlying fs_watchFile + // instance if there are no more listeners left. + return () => { + delFromSet(cont, KEY_LISTENERS, listener); + delFromSet(cont, KEY_RAW, rawEmitter); + if (isEmptySet(cont.listeners)) { + FsWatchFileInstances.delete(fullPath); + fs$8.unwatchFile(fullPath); + cont.options = cont.watcher = undefined; + Object.freeze(cont); + } + }; +}; - // Detect level if not set manually - const scLevel = stdoutColor ? stdoutColor.level : 0; - obj.level = options.level === undefined ? scLevel : options.level; - obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; +/** + * @mixin + */ +class NodeFsHandler$1 { + +/** + * @param {import("../index").FSWatcher} fsW + */ +constructor(fsW) { + this.fsw = fsW; + this._boundHandleError = (error) => fsW._handleError(error); } -function Chalk(options) { - // We check for this.template here since calling `chalk.constructor()` - // by itself will have a `this` of a previously constructed chalk object - if (!this || !(this instanceof Chalk) || this.template) { - const chalk = {}; - applyOptions(chalk, options); +/** + * Watch file for changes with fs_watchFile or fs_watch. + * @param {String} path to file or dir + * @param {Function} listener on fs change + * @returns {Function} closer for the watcher instance + */ +_watchWithNodeFs(path, listener) { + const opts = this.fsw.options; + const directory = sysPath$2.dirname(path); + const basename = sysPath$2.basename(path); + const parent = this.fsw._getWatchedDir(directory); + parent.add(basename); + const absolutePath = sysPath$2.resolve(path); + const options = {persistent: opts.persistent}; + if (!listener) listener = EMPTY_FN$2; - chalk.template = function () { - const args = [].slice.call(arguments); - return chalkTag.apply(null, [chalk.template].concat(args)); - }; + let closer; + if (opts.usePolling) { + options.interval = opts.enableBinaryInterval && isBinaryPath(basename) ? + opts.binaryInterval : opts.interval; + closer = setFsWatchFileListener(path, absolutePath, options, { + listener, + rawEmitter: this.fsw._emitRaw + }); + } else { + closer = setFsWatchListener(path, absolutePath, options, { + listener, + errHandler: this._boundHandleError, + rawEmitter: this.fsw._emitRaw + }); + } + return closer; +} - Object.setPrototypeOf(chalk, Chalk.prototype); - Object.setPrototypeOf(chalk.template, chalk); +/** + * Watch a file and emit add event if warranted. + * @param {Path} file Path + * @param {fs.Stats} stats result of fs_stat + * @param {Boolean} initialAdd was the file added at watch instantiation? + * @returns {Function} closer for the watcher instance + */ +_handleFile(file, stats, initialAdd) { + if (this.fsw.closed) { + return; + } + const dirname = sysPath$2.dirname(file); + const basename = sysPath$2.basename(file); + const parent = this.fsw._getWatchedDir(dirname); + // stats is always present + let prevStats = stats; - chalk.template.constructor = Chalk; + // if the file is already being watched, do nothing + if (parent.has(basename)) return; - return chalk.template; - } + const listener = async (path, newStats) => { + if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return; + if (!newStats || newStats.mtimeMs === 0) { + try { + const newStats = await stat$2(file); + if (this.fsw.closed) return; + // Check that change event was not fired because of changed only accessTime. + const at = newStats.atimeMs; + const mt = newStats.mtimeMs; + if (!at || at <= mt || mt !== prevStats.mtimeMs) { + this.fsw._emit(EV_CHANGE$2, file, newStats); + } + if (isLinux && prevStats.ino !== newStats.ino) { + this.fsw._closeFile(path); + prevStats = newStats; + this.fsw._addPathCloser(path, this._watchWithNodeFs(file, listener)); + } else { + prevStats = newStats; + } + } catch (error) { + // Fix issues where mtime is null but file is still present + this.fsw._remove(dirname, basename); + } + // add is about to be emitted if file not already tracked in parent + } else if (parent.has(basename)) { + // Check that change event was not fired because of changed only accessTime. + const at = newStats.atimeMs; + const mt = newStats.mtimeMs; + if (!at || at <= mt || mt !== prevStats.mtimeMs) { + this.fsw._emit(EV_CHANGE$2, file, newStats); + } + prevStats = newStats; + } + }; + // kick off the watcher + const closer = this._watchWithNodeFs(file, listener); - applyOptions(this, options); -} + // emit an add event if we're supposed to + if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) { + if (!this.fsw._throttle(EV_ADD$2, file, 0)) return; + this.fsw._emit(EV_ADD$2, file, stats); + } -// Use bright blue on Windows as the normal blue color is illegible -if (isSimpleWindowsTerm) { - ansiStyles.blue.open = '\u001B[94m'; + return closer; } -for (const key of Object.keys(ansiStyles)) { - ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); - - styles[key] = { - get() { - const codes = ansiStyles[key]; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); - } - }; -} +/** + * Handle symlinks encountered while reading a dir. + * @param {Object} entry returned by readdirp + * @param {String} directory path of dir being read + * @param {String} path of this item + * @param {String} item basename of this item + * @returns {Promise} true if no more processing is needed for this entry. + */ +async _handleSymlink(entry, directory, path, item) { + if (this.fsw.closed) { + return; + } + const full = entry.fullPath; + const dir = this.fsw._getWatchedDir(directory); -styles.visible = { - get() { - return build.call(this, this._styles || [], true, 'visible'); - } -}; + if (!this.fsw.options.followSymlinks) { + // watch symlink directly (don't follow) and detect changes + this.fsw._incrReadyCount(); + const linkPath = await fsrealpath(path); + if (this.fsw.closed) return; + if (dir.has(item)) { + if (this.fsw._symlinkPaths.get(full) !== linkPath) { + this.fsw._symlinkPaths.set(full, linkPath); + this.fsw._emit(EV_CHANGE$2, path, entry.stats); + } + } else { + dir.add(item); + this.fsw._symlinkPaths.set(full, linkPath); + this.fsw._emit(EV_ADD$2, path, entry.stats); + } + this.fsw._emitReady(); + return true; + } -ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g'); -for (const model of Object.keys(ansiStyles.color.ansi)) { - if (skipModels.has(model)) { - continue; - } + // don't follow the same symlink more than once + if (this.fsw._symlinkPaths.has(full)) { + return true; + } - styles[model] = { - get() { - const level = this.level; - return function () { - const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments); - const codes = { - open, - close: ansiStyles.color.close, - closeRe: ansiStyles.color.closeRe - }; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); - }; - } - }; + this.fsw._symlinkPaths.set(full, true); } -ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g'); -for (const model of Object.keys(ansiStyles.bgColor.ansi)) { - if (skipModels.has(model)) { - continue; - } +_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) { + // Normalize the directory name on Windows + directory = sysPath$2.join(directory, EMPTY_STR$1); - const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); - styles[bgModel] = { - get() { - const level = this.level; - return function () { - const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments); - const codes = { - open, - close: ansiStyles.bgColor.close, - closeRe: ansiStyles.bgColor.closeRe - }; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); - }; - } - }; -} + if (!wh.hasGlob) { + throttler = this.fsw._throttle('readdir', directory, 1000); + if (!throttler) return; + } -const proto = Object.defineProperties(() => {}, styles); + const previous = this.fsw._getWatchedDir(wh.path); + const current = new Set(); -function build(_styles, _empty, key) { - const builder = function () { - return applyStyle.apply(builder, arguments); - }; + let stream = this.fsw._readdirp(directory, { + fileFilter: entry => wh.filterPath(entry), + directoryFilter: entry => wh.filterDir(entry), + depth: 0 + }).on(STR_DATA$1, async (entry) => { + if (this.fsw.closed) { + stream = undefined; + return; + } + const item = entry.path; + let path = sysPath$2.join(directory, item); + current.add(item); - builder._styles = _styles; - builder._empty = _empty; + if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) { + return; + } - const self = this; + if (this.fsw.closed) { + stream = undefined; + return; + } + // Files that present in current directory snapshot + // but absent in previous are added to watch list and + // emit `add` event. + if (item === target || !target && !previous.has(item)) { + this.fsw._incrReadyCount(); - Object.defineProperty(builder, 'level', { - enumerable: true, - get() { - return self.level; - }, - set(level) { - self.level = level; - } - }); + // ensure relativeness of path is preserved in case of watcher reuse + path = sysPath$2.join(dir, sysPath$2.relative(dir, path)); - Object.defineProperty(builder, 'enabled', { - enumerable: true, - get() { - return self.enabled; - }, - set(enabled) { - self.enabled = enabled; - } - }); + this._addToNodeFs(path, initialAdd, wh, depth + 1); + } + }).on(EV_ERROR$2, this._boundHandleError); - // See below for fix regarding invisible grey/dim combination on Windows - builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; + return new Promise(resolve => + stream.once(STR_END$2, () => { + if (this.fsw.closed) { + stream = undefined; + return; + } + const wasThrottled = throttler ? throttler.clear() : false; - // `__proto__` is used because we must return a function, but there is - // no way to create a function with a different prototype - builder.__proto__ = proto; // eslint-disable-line no-proto + resolve(); - return builder; -} + // Files that absent in current directory snapshot + // but present in previous emit `remove` event + // and are removed from @watched[directory]. + previous.getChildren().filter((item) => { + return item !== directory && + !current.has(item) && + // in case of intersecting globs; + // a path may have been filtered out of this readdir, but + // shouldn't be removed because it matches a different glob + (!wh.hasGlob || wh.filterPath({ + fullPath: sysPath$2.resolve(directory, item) + })); + }).forEach((item) => { + this.fsw._remove(directory, item); + }); -function applyStyle() { - // Support varags, but simply cast to string in case there's only one arg - const args = arguments; - const argsLen = args.length; - let str = String(arguments[0]); - - if (argsLen === 0) { - return ''; - } - - if (argsLen > 1) { - // Don't slice `arguments`, it prevents V8 optimizations - for (let a = 1; a < argsLen; a++) { - str += ' ' + args[a]; - } - } - - if (!this.enabled || this.level <= 0 || !str) { - return this._empty ? '' : str; - } - - // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, - // see https://github.com/chalk/chalk/issues/58 - // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. - const originalDim = ansiStyles.dim.open; - if (isSimpleWindowsTerm && this.hasGrey) { - ansiStyles.dim.open = ''; - } - - for (const code of this._styles.slice().reverse()) { - // Replace any instances already present with a re-opening code - // otherwise only the part of the string until said closing code - // will be colored, and the rest will simply be 'plain'. - str = code.open + str.replace(code.closeRe, code.open) + code.close; - - // Close the styling before a linebreak and reopen - // after next line to fix a bleed issue on macOS - // https://github.com/chalk/chalk/pull/92 - str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); - } - - // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue - ansiStyles.dim.open = originalDim; - - return str; -} - -function chalkTag(chalk, strings) { - if (!Array.isArray(strings)) { - // If chalk() was called by itself or with a string, - // return the string itself as a string. - return [].slice.call(arguments, 1).join(' '); - } - - const args = [].slice.call(arguments, 2); - const parts = [strings.raw[0]]; - - for (let i = 1; i < strings.length; i++) { - parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); - parts.push(String(strings.raw[i])); - } + stream = undefined; - return template(chalk, parts.join('')); + // one more time for any missed in case changes came in extremely quickly + if (wasThrottled) this._handleRead(directory, false, wh, target, dir, depth, throttler); + }) + ); } -Object.defineProperties(Chalk.prototype, styles); - -module.exports = Chalk(); // eslint-disable-line new-cap -module.exports.supportsColor = stdoutColor; -module.exports.default = module.exports; // For TypeScript -}(chalk$2)); - -Object.defineProperty(lib$8, "__esModule", { - value: true -}); -lib$8.shouldHighlight = shouldHighlight; -lib$8.getChalk = getChalk; -lib$8.default = highlight; - -var _jsTokens = jsTokens; +/** + * Read directory to add / remove files from `@watched` list and re-read it on change. + * @param {String} dir fs path + * @param {fs.Stats} stats + * @param {Boolean} initialAdd + * @param {Number} depth relative to user-supplied path + * @param {String} target child path targeted for watch + * @param {Object} wh Common watch helpers for this path + * @param {String} realpath + * @returns {Promise} closer for the watcher instance. + */ +async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) { + const parentDir = this.fsw._getWatchedDir(sysPath$2.dirname(dir)); + const tracked = parentDir.has(sysPath$2.basename(dir)); + if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) { + if (!wh.hasGlob || wh.globFilter(dir)) this.fsw._emit(EV_ADD_DIR$2, dir, stats); + } -var _helperValidatorIdentifier = lib$7; + // ensure dir is tracked (harmless if redundant) + parentDir.add(sysPath$2.basename(dir)); + this.fsw._getWatchedDir(dir); + let throttler; + let closer; -var _chalk = chalk$2.exports; + const oDepth = this.fsw.options.depth; + if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) { + if (!target) { + await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler); + if (this.fsw.closed) return; + } -const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]); + closer = this._watchWithNodeFs(dir, (dirPath, stats) => { + // if current directory is removed, do nothing + if (stats && stats.mtimeMs === 0) return; -function getDefs$1(chalk) { - return { - keyword: chalk.cyan, - capitalized: chalk.yellow, - jsxIdentifier: chalk.yellow, - punctuator: chalk.yellow, - number: chalk.magenta, - string: chalk.green, - regex: chalk.magenta, - comment: chalk.grey, - invalid: chalk.white.bgRed.bold - }; + this._handleRead(dirPath, false, wh, target, dir, depth, throttler); + }); + } + return closer; } -const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/; -const BRACKET = /^[()[\]{}]$/; -let tokenize$3; -{ - const JSX_TAG = /^[a-z][\w-]*$/i; +/** + * Handle added file, directory, or glob pattern. + * Delegates call to _handleFile / _handleDir after checks. + * @param {String} path to file or ir + * @param {Boolean} initialAdd was the file added at watch instantiation? + * @param {Object} priorWh depth relative to user-supplied path + * @param {Number} depth Child path actually targeted for watch + * @param {String=} target Child path actually targeted for watch + * @returns {Promise} + */ +async _addToNodeFs(path, initialAdd, priorWh, depth, target) { + const ready = this.fsw._emitReady; + if (this.fsw._isIgnored(path) || this.fsw.closed) { + ready(); + return false; + } - const getTokenType = function (token, offset, text) { - if (token.type === "name") { - if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) { - return "keyword"; - } + const wh = this.fsw._getWatchHelpers(path, depth); + if (!wh.hasGlob && priorWh) { + wh.hasGlob = priorWh.hasGlob; + wh.globFilter = priorWh.globFilter; + wh.filterPath = entry => priorWh.filterPath(entry); + wh.filterDir = entry => priorWh.filterDir(entry); + } - if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == " colorize(str)).join("\n"); - } else { - highlighted += value; +if (fsevents) { + // TODO: real check + const mtch = process.version.match(/v(\d+)\.(\d+)/); + if (mtch && mtch[1] && mtch[2]) { + const maj = Number.parseInt(mtch[1], 10); + const min = Number.parseInt(mtch[2], 10); + if (maj === 8 && min < 16) { + fsevents = undefined; } } - - return highlighted; } -function shouldHighlight(options) { - return !!_chalk.supportsColor || options.forceColor; -} +const { + EV_ADD: EV_ADD$1, + EV_CHANGE: EV_CHANGE$1, + EV_ADD_DIR: EV_ADD_DIR$1, + EV_UNLINK: EV_UNLINK$1, + EV_ERROR: EV_ERROR$1, + STR_DATA, + STR_END: STR_END$1, + FSEVENT_CREATED, + FSEVENT_MODIFIED, + FSEVENT_DELETED, + FSEVENT_MOVED, + // FSEVENT_CLONED, + FSEVENT_UNKNOWN, + FSEVENT_TYPE_FILE, + FSEVENT_TYPE_DIRECTORY, + FSEVENT_TYPE_SYMLINK, -function getChalk(options) { - return options.forceColor ? new _chalk.constructor({ - enabled: true, - level: 1 - }) : _chalk; -} + ROOT_GLOBSTAR, + DIR_SUFFIX, + DOT_SLASH, + FUNCTION_TYPE: FUNCTION_TYPE$1, + EMPTY_FN: EMPTY_FN$1, + IDENTITY_FN +} = constants$1; -function highlight(code, options = {}) { - if (shouldHighlight(options)) { - const chalk = getChalk(options); - const defs = getDefs$1(chalk); - return highlightTokens(defs, code); - } else { - return code; - } -} +const Depth = (value) => isNaN(value) ? {} : {depth: value}; -Object.defineProperty(lib$9, "__esModule", { - value: true -}); -lib$9.codeFrameColumns = codeFrameColumns$1; -lib$9.default = _default$1; +const stat$1 = promisify$1(fs$7.stat); +const lstat = promisify$1(fs$7.lstat); +const realpath$1 = promisify$1(fs$7.realpath); -var _highlight = lib$8; +const statMethods = { stat: stat$1, lstat }; -let deprecationWarningShown = false; +/** + * @typedef {String} Path + */ -function getDefs(chalk) { - return { - gutter: chalk.grey, - marker: chalk.red.bold, - message: chalk.red.bold - }; -} +/** + * @typedef {Object} FsEventsWatchContainer + * @property {Set} listeners + * @property {Function} rawEmitter + * @property {{stop: Function}} watcher + */ -const NEWLINE = /\r\n|[\n\r\u2028\u2029]/; +// fsevents instance helper functions +/** + * Object to hold per-process fsevents instances (may be shared across chokidar FSWatcher instances) + * @type {Map} + */ +const FSEventsWatchers = new Map(); -function getMarkerLines(loc, source, opts) { - const startLoc = Object.assign({ - column: 0, - line: -1 - }, loc.start); - const endLoc = Object.assign({}, startLoc, loc.end); - const { - linesAbove = 2, - linesBelow = 3 - } = opts || {}; - const startLine = startLoc.line; - const startColumn = startLoc.column; - const endLine = endLoc.line; - const endColumn = endLoc.column; - let start = Math.max(startLine - (linesAbove + 1), 0); - let end = Math.min(source.length, endLine + linesBelow); +// Threshold of duplicate path prefixes at which to start +// consolidating going forward +const consolidateThreshhold = 10; - if (startLine === -1) { - start = 0; - } +const wrongEventFlags = new Set([ + 69888, 70400, 71424, 72704, 73472, 131328, 131840, 262912 +]); - if (endLine === -1) { - end = source.length; - } +/** + * Instantiates the fsevents interface + * @param {Path} path path to be watched + * @param {Function} callback called when fsevents is bound and ready + * @returns {{stop: Function}} new fsevents instance + */ +const createFSEventsInstance = (path, callback) => { + const stop = fsevents.watch(path, callback); + return {stop}; +}; - const lineDiff = endLine - startLine; - const markerLines = {}; +/** + * Instantiates the fsevents interface or binds listeners to an existing one covering + * the same file tree. + * @param {Path} path - to be watched + * @param {Path} realPath - real path for symlinks + * @param {Function} listener - called when fsevents emits events + * @param {Function} rawEmitter - passes data to listeners of the 'raw' event + * @returns {Function} closer + */ +function setFSEventsListener(path, realPath, listener, rawEmitter) { + let watchPath = sysPath$1.extname(realPath) ? sysPath$1.dirname(realPath) : realPath; - if (lineDiff) { - for (let i = 0; i <= lineDiff; i++) { - const lineNumber = i + startLine; + const parentPath = sysPath$1.dirname(watchPath); + let cont = FSEventsWatchers.get(watchPath); - if (!startColumn) { - markerLines[lineNumber] = true; - } else if (i === 0) { - const sourceLength = source[lineNumber - 1].length; - markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1]; - } else if (i === lineDiff) { - markerLines[lineNumber] = [0, endColumn]; - } else { - const sourceLength = source[lineNumber - i].length; - markerLines[lineNumber] = [0, sourceLength]; - } - } - } else { - if (startColumn === endColumn) { - if (startColumn) { - markerLines[startLine] = [startColumn, 0]; - } else { - markerLines[startLine] = true; - } - } else { - markerLines[startLine] = [startColumn, endColumn - startColumn]; - } + // If we've accumulated a substantial number of paths that + // could have been consolidated by watching one directory + // above the current one, create a watcher on the parent + // path instead, so that we do consolidate going forward. + if (couldConsolidate(parentPath)) { + watchPath = parentPath; } - return { - start, - end, - markerLines - }; -} - -function codeFrameColumns$1(rawLines, loc, opts = {}) { - const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts); - const chalk = (0, _highlight.getChalk)(opts); - const defs = getDefs(chalk); + const resolvedPath = sysPath$1.resolve(path); + const hasSymlink = resolvedPath !== realPath; - const maybeHighlight = (chalkFn, string) => { - return highlighted ? chalkFn(string) : string; + const filteredListener = (fullPath, flags, info) => { + if (hasSymlink) fullPath = fullPath.replace(realPath, resolvedPath); + if ( + fullPath === resolvedPath || + !fullPath.indexOf(resolvedPath + sysPath$1.sep) + ) listener(fullPath, flags, info); }; - const lines = rawLines.split(NEWLINE); - const { - start, - end, - markerLines - } = getMarkerLines(loc, lines, opts); - const hasColumns = loc.start && typeof loc.start.column === "number"; - const numberMaxWidth = String(end).length; - const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines; - let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => { - const number = start + 1 + index; - const paddedNumber = ` ${number}`.slice(-numberMaxWidth); - const gutter = ` ${paddedNumber} |`; - const hasMarker = markerLines[number]; - const lastMarkerLine = !markerLines[number + 1]; - - if (hasMarker) { - let markerLine = ""; - - if (Array.isArray(hasMarker)) { - const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " "); - const numberOfMarkers = hasMarker[1] || 1; - markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join(""); - - if (lastMarkerLine && opts.message) { - markerLine += " " + maybeHighlight(defs.message, opts.message); - } - } - - return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join(""); - } else { - return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`; + // check if there is already a watcher on a parent path + // modifies `watchPath` to the parent path when it finds a match + let watchedParent = false; + for (const watchedPath of FSEventsWatchers.keys()) { + if (realPath.indexOf(sysPath$1.resolve(watchedPath) + sysPath$1.sep) === 0) { + watchPath = watchedPath; + cont = FSEventsWatchers.get(watchPath); + watchedParent = true; + break; } - }).join("\n"); - - if (opts.message && !hasColumns) { - frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`; } - if (highlighted) { - return chalk.reset(frame); + if (cont || watchedParent) { + cont.listeners.add(filteredListener); } else { - return frame; - } -} - -function _default$1(rawLines, lineNumber, colNumber, opts = {}) { - if (!deprecationWarningShown) { - deprecationWarningShown = true; - const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`."; + cont = { + listeners: new Set([filteredListener]), + rawEmitter, + watcher: createFSEventsInstance(watchPath, (fullPath, flags) => { + if (!cont.listeners.size) return; + const info = fsevents.getInfo(fullPath, flags); + cont.listeners.forEach(list => { + list(fullPath, flags, info); + }); - if (process.emitWarning) { - process.emitWarning(message, "DeprecationWarning"); - } else { - const deprecationError = new Error(message); - deprecationError.name = "DeprecationWarning"; - console.warn(new Error(message)); - } + cont.rawEmitter(info.event, fullPath, info); + }) + }; + FSEventsWatchers.set(watchPath, cont); } - colNumber = Math.max(colNumber, 0); - const location = { - start: { - column: colNumber, - line: lineNumber + // removes this instance's listeners and closes the underlying fsevents + // instance if there are no more listeners left + return () => { + const lst = cont.listeners; + + lst.delete(filteredListener); + if (!lst.size) { + FSEventsWatchers.delete(watchPath); + if (cont.watcher) return cont.watcher.stop().then(() => { + cont.rawEmitter = cont.watcher = undefined; + Object.freeze(cont); + }); } }; - return codeFrameColumns$1(rawLines, location, opts); } -const errorEx = errorEx_1; -const fallback = jsonParseEvenBetterErrors; -const {default: LinesAndColumns} = require$$2; -const {codeFrameColumns} = lib$9; - -const JSONError = errorEx('JSONError', { - fileName: errorEx.append('in %s'), - codeFrame: errorEx.append('\n\n%s\n') -}); - -const parseJson = (string, reviver, filename) => { - if (typeof reviver === 'string') { - filename = reviver; - reviver = null; - } - - try { - try { - return JSON.parse(string, reviver); - } catch (error) { - fallback(string, reviver); - throw error; - } - } catch (error) { - error.message = error.message.replace(/\n/g, ''); - const indexMatch = error.message.match(/in JSON at position (\d+) while parsing/); +// Decide whether or not we should start a new higher-level +// parent watcher +const couldConsolidate = (path) => { + let count = 0; + for (const watchPath of FSEventsWatchers.keys()) { + if (watchPath.indexOf(path) === 0) { + count++; + if (count >= consolidateThreshhold) { + return true; + } + } + } - const jsonError = new JSONError(error); - if (filename) { - jsonError.fileName = filename; - } + return false; +}; - if (indexMatch && indexMatch.length > 0) { - const lines = new LinesAndColumns(string); - const index = Number(indexMatch[1]); - const location = lines.locationForIndex(index); +// returns boolean indicating whether fsevents can be used +const canUse = () => fsevents && FSEventsWatchers.size < 128; - const codeFrame = codeFrameColumns( - string, - {start: {line: location.line + 1, column: location.column + 1}}, - {highlightCode: true} - ); +// determines subdirectory traversal levels from root to path +const calcDepth = (path, root) => { + let i = 0; + while (!path.indexOf(root) && (path = sysPath$1.dirname(path)) !== root) i++; + return i; +}; - jsonError.codeFrame = codeFrame; - } +// returns boolean indicating whether the fsevents' event info has the same type +// as the one returned by fs.stat +const sameTypes = (info, stats) => ( + info.type === FSEVENT_TYPE_DIRECTORY && stats.isDirectory() || + info.type === FSEVENT_TYPE_SYMLINK && stats.isSymbolicLink() || + info.type === FSEVENT_TYPE_FILE && stats.isFile() +); - throw jsonError; - } -}; +/** + * @mixin + */ +class FsEventsHandler$1 { -parseJson.JSONError = JSONError; +/** + * @param {import('../index').FSWatcher} fsw + */ +constructor(fsw) { + this.fsw = fsw; +} +checkIgnored(path, stats) { + const ipaths = this.fsw._ignoredPaths; + if (this.fsw._isIgnored(path, stats)) { + ipaths.add(path); + if (stats && stats.isDirectory()) { + ipaths.add(path + ROOT_GLOBSTAR); + } + return true; + } -var parseJson_1 = parseJson; + ipaths.delete(path); + ipaths.delete(path + ROOT_GLOBSTAR); +} -var src = {exports: {}}; +addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) { + const event = watchedDir.has(item) ? EV_CHANGE$1 : EV_ADD$1; + this.handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts); +} -var browser = {exports: {}}; +async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts) { + try { + const stats = await stat$1(path); + if (this.fsw.closed) return; + if (sameTypes(info, stats)) { + this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } else { + this.handleEvent(EV_UNLINK$1, path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } catch (error) { + if (error.code === 'EACCES') { + this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } else { + this.handleEvent(EV_UNLINK$1, path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } +} -/** - * Helpers. - */ +handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts) { + if (this.fsw.closed || this.checkIgnored(path)) return; -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var w = d * 7; -var y = d * 365.25; + if (event === EV_UNLINK$1) { + const isDirectory = info.type === FSEVENT_TYPE_DIRECTORY; + // suppress unlink events on never before seen files + if (isDirectory || watchedDir.has(item)) { + this.fsw._remove(parent, item, isDirectory); + } + } else { + if (event === EV_ADD$1) { + // track new directories + if (info.type === FSEVENT_TYPE_DIRECTORY) this.fsw._getWatchedDir(path); -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} [options] - * @throws {Error} throw an error if val is not a non-empty string or a number - * @return {String|Number} - * @api public - */ + if (info.type === FSEVENT_TYPE_SYMLINK && opts.followSymlinks) { + // push symlinks back to the top of the stack to get handled + const curDepth = opts.depth === undefined ? + undefined : calcDepth(fullPath, realPath) + 1; + return this._addToFsEvents(path, false, true, curDepth); + } -var ms = function(val, options) { - options = options || {}; - var type = typeof val; - if (type === 'string' && val.length > 0) { - return parse$c(val); - } else if (type === 'number' && isFinite(val)) { - return options.long ? fmtLong(val) : fmtShort(val); + // track new paths + // (other than symlinks being followed, which will be tracked soon) + this.fsw._getWatchedDir(parent).add(item); + } + /** + * @type {'add'|'addDir'|'unlink'|'unlinkDir'} + */ + const eventName = info.type === FSEVENT_TYPE_DIRECTORY ? event + DIR_SUFFIX : event; + this.fsw._emit(eventName, path); + if (eventName === EV_ADD_DIR$1) this._addToFsEvents(path, false, true); } - throw new Error( - 'val is not a non-empty string or a valid number. val=' + - JSON.stringify(val) - ); -}; +} /** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ + * Handle symlinks encountered during directory scan + * @param {String} watchPath - file/dir path to be watched with fsevents + * @param {String} realPath - real path (in case of symlinks) + * @param {Function} transform - path transformer + * @param {Function} globFilter - path filter in case a glob pattern was provided + * @returns {Function} closer for the watcher instance +*/ +_watchWithFsEvents(watchPath, realPath, transform, globFilter) { + if (this.fsw.closed || this.fsw._isIgnored(watchPath)) return; + const opts = this.fsw.options; + const watchCallback = async (fullPath, flags, info) => { + if (this.fsw.closed) return; + if ( + opts.depth !== undefined && + calcDepth(fullPath, realPath) > opts.depth + ) return; + const path = transform(sysPath$1.join( + watchPath, sysPath$1.relative(watchPath, fullPath) + )); + if (globFilter && !globFilter(path)) return; + // ensure directories are tracked + const parent = sysPath$1.dirname(path); + const item = sysPath$1.basename(path); + const watchedDir = this.fsw._getWatchedDir( + info.type === FSEVENT_TYPE_DIRECTORY ? path : parent + ); -function parse$c(str) { - str = String(str); - if (str.length > 100) { - return; - } - var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( - str + // correct for wrong events emitted + if (wrongEventFlags.has(flags) || info.event === FSEVENT_UNKNOWN) { + if (typeof opts.ignored === FUNCTION_TYPE$1) { + let stats; + try { + stats = await stat$1(path); + } catch (error) {} + if (this.fsw.closed) return; + if (this.checkIgnored(path, stats)) return; + if (sameTypes(info, stats)) { + this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } else { + this.handleEvent(EV_UNLINK$1, path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } else { + this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } else { + switch (info.event) { + case FSEVENT_CREATED: + case FSEVENT_MODIFIED: + return this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); + case FSEVENT_DELETED: + case FSEVENT_MOVED: + return this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } + }; + + const closer = setFSEventsListener( + watchPath, + realPath, + watchCallback, + this.fsw._emitRaw ); - if (!match) { - return; - } - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'weeks': - case 'week': - case 'w': - return n * w; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - default: - return undefined; - } + + this.fsw._emitReady(); + return closer; } /** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private + * Handle symlinks encountered during directory scan + * @param {String} linkPath path to symlink + * @param {String} fullPath absolute path to the symlink + * @param {Function} transform pre-existing path transformer + * @param {Number} curDepth level of subdirectories traversed to where symlink is + * @returns {Promise} */ +async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) { + // don't follow the same symlink more than once + if (this.fsw.closed || this.fsw._symlinkPaths.has(fullPath)) return; -function fmtShort(ms) { - var msAbs = Math.abs(ms); - if (msAbs >= d) { - return Math.round(ms / d) + 'd'; - } - if (msAbs >= h) { - return Math.round(ms / h) + 'h'; - } - if (msAbs >= m) { - return Math.round(ms / m) + 'm'; - } - if (msAbs >= s) { - return Math.round(ms / s) + 's'; + this.fsw._symlinkPaths.set(fullPath, true); + this.fsw._incrReadyCount(); + + try { + const linkTarget = await realpath$1(linkPath); + if (this.fsw.closed) return; + if (this.fsw._isIgnored(linkTarget)) { + return this.fsw._emitReady(); + } + + this.fsw._incrReadyCount(); + + // add the linkTarget for watching with a wrapper for transform + // that causes emitted paths to incorporate the link's path + this._addToFsEvents(linkTarget || linkPath, (path) => { + let aliasedPath = linkPath; + if (linkTarget && linkTarget !== DOT_SLASH) { + aliasedPath = path.replace(linkTarget, linkPath); + } else if (path !== DOT_SLASH) { + aliasedPath = sysPath$1.join(linkPath, path); + } + return transform(aliasedPath); + }, false, curDepth); + } catch(error) { + if (this.fsw._handleError(error)) { + return this.fsw._emitReady(); + } } - return ms + 'ms'; } /** - * Long format for `ms`. * - * @param {Number} ms - * @return {String} - * @api private + * @param {Path} newPath + * @param {fs.Stats} stats */ +emitAdd(newPath, stats, processPath, opts, forceAdd) { + const pp = processPath(newPath); + const isDir = stats.isDirectory(); + const dirObj = this.fsw._getWatchedDir(sysPath$1.dirname(pp)); + const base = sysPath$1.basename(pp); -function fmtLong(ms) { - var msAbs = Math.abs(ms); - if (msAbs >= d) { - return plural$1(ms, msAbs, d, 'day'); - } - if (msAbs >= h) { - return plural$1(ms, msAbs, h, 'hour'); - } - if (msAbs >= m) { - return plural$1(ms, msAbs, m, 'minute'); - } - if (msAbs >= s) { - return plural$1(ms, msAbs, s, 'second'); + // ensure empty dirs get tracked + if (isDir) this.fsw._getWatchedDir(pp); + if (dirObj.has(base)) return; + dirObj.add(base); + + if (!opts.ignoreInitial || forceAdd === true) { + this.fsw._emit(isDir ? EV_ADD_DIR$1 : EV_ADD$1, pp, stats); } - return ms + ' ms'; } -/** - * Pluralization helper. - */ - -function plural$1(ms, msAbs, n, name) { - var isPlural = msAbs >= n * 1.5; - return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); +initWatch(realPath, path, wh, processPath) { + if (this.fsw.closed) return; + const closer = this._watchWithFsEvents( + wh.watchPath, + sysPath$1.resolve(realPath || wh.watchPath), + processPath, + wh.globFilter + ); + this.fsw._addPathCloser(path, closer); } /** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. + * Handle added path with fsevents + * @param {String} path file/dir path or glob pattern + * @param {Function|Boolean=} transform converts working path to what the user expects + * @param {Boolean=} forceAdd ensure add is emitted + * @param {Number=} priorDepth Level of subdirectories already traversed. + * @returns {Promise} */ +async _addToFsEvents(path, transform, forceAdd, priorDepth) { + if (this.fsw.closed) { + return; + } + const opts = this.fsw.options; + const processPath = typeof transform === FUNCTION_TYPE$1 ? transform : IDENTITY_FN; -function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = ms; - createDebug.destroy = destroy; - - Object.keys(env).forEach(key => { - createDebug[key] = env[key]; - }); + const wh = this.fsw._getWatchHelpers(path); - /** - * The currently active debug mode names, and names to skip. - */ + // evaluate what is at the path we're being asked to watch + try { + const stats = await statMethods[wh.statMethod](wh.watchPath); + if (this.fsw.closed) return; + if (this.fsw._isIgnored(wh.watchPath, stats)) { + throw null; + } + if (stats.isDirectory()) { + // emit addDir unless this is a glob parent + if (!wh.globFilter) this.emitAdd(processPath(path), stats, processPath, opts, forceAdd); - createDebug.names = []; - createDebug.skips = []; + // don't recurse further if it would exceed depth setting + if (priorDepth && priorDepth > opts.depth) return; - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - createDebug.formatters = {}; + // scan the contents of the dir + this.fsw._readdirp(wh.watchPath, { + fileFilter: entry => wh.filterPath(entry), + directoryFilter: entry => wh.filterDir(entry), + ...Depth(opts.depth - (priorDepth || 0)) + }).on(STR_DATA, (entry) => { + // need to check filterPath on dirs b/c filterDir is less restrictive + if (this.fsw.closed) { + return; + } + if (entry.stats.isDirectory() && !wh.filterPath(entry)) return; - /** - * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - function selectColor(namespace) { - let hash = 0; + const joinedPath = sysPath$1.join(wh.watchPath, entry.path); + const {fullPath} = entry; - for (let i = 0; i < namespace.length; i++) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } + if (wh.followSymlinks && entry.stats.isSymbolicLink()) { + // preserve the current depth here since it can't be derived from + // real paths past the symlink + const curDepth = opts.depth === undefined ? + undefined : calcDepth(joinedPath, sysPath$1.resolve(wh.watchPath)) + 1; - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; + this._handleFsEventsSymlink(joinedPath, fullPath, processPath, curDepth); + } else { + this.emitAdd(joinedPath, entry.stats, processPath, opts, forceAdd); + } + }).on(EV_ERROR$1, EMPTY_FN$1).on(STR_END$1, () => { + this.fsw._emitReady(); + }); + } else { + this.emitAdd(wh.watchPath, stats, processPath, opts, forceAdd); + this.fsw._emitReady(); + } + } catch (error) { + if (!error || this.fsw._handleError(error)) { + // TODO: Strange thing: "should not choke on an ignored watch path" will be failed without 2 ready calls -__- + this.fsw._emitReady(); + this.fsw._emitReady(); + } + } - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; - - function debug(...args) { - // Disabled? - if (!debug.enabled) { - return; - } + if (opts.persistent && forceAdd !== true) { + if (typeof transform === FUNCTION_TYPE$1) { + // realpath has already been resolved + this.initWatch(undefined, path, wh, processPath); + } else { + let realPath; + try { + realPath = await realpath$1(wh.watchPath); + } catch (e) {} + this.initWatch(realPath, path, wh, processPath); + } + } +} - const self = debug; +} - // Set `diff` timestamp - const curr = Number(new Date()); - const ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; +fseventsHandler.exports = FsEventsHandler$1; +fseventsHandler.exports.canUse = canUse; - args[0] = createDebug.coerce(args[0]); +const { EventEmitter } = require$$0__default$3['default']; +const fs$6 = require$$0__default$1['default']; +const sysPath = path__default['default']; +const { promisify } = require$$0__default$2['default']; +const readdirp = readdirp_1; +const anymatch = anymatch$2.exports.default; +const globParent = globParent$1; +const isGlob = isGlob$2; +const braces = braces_1; +const normalizePath = normalizePath$2; - if (typeof args[0] !== 'string') { - // Anything else let's inspect with %O - args.unshift('%O'); - } +const NodeFsHandler = nodefsHandler; +const FsEventsHandler = fseventsHandler.exports; +const { + EV_ALL, + EV_READY, + EV_ADD, + EV_CHANGE, + EV_UNLINK, + EV_ADD_DIR, + EV_UNLINK_DIR, + EV_RAW, + EV_ERROR, - // Apply any `formatters` transformations - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return '%'; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === 'function') { - const val = args[index]; - match = formatter.call(self, val); + STR_CLOSE, + STR_END, - // Now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); + BACK_SLASH_RE, + DOUBLE_SLASH_RE, + SLASH_OR_BACK_SLASH_RE, + DOT_RE, + REPLACER_RE, - // Apply env-specific formatting (colors, etc.) - createDebug.formatArgs.call(self, args); + SLASH: SLASH$1, + SLASH_SLASH, + BRACE_START, + BANG, + ONE_DOT, + TWO_DOTS, + GLOBSTAR: GLOBSTAR$1, + SLASH_GLOBSTAR, + ANYMATCH_OPTS, + STRING_TYPE, + FUNCTION_TYPE, + EMPTY_STR, + EMPTY_FN, - const logFn = self.log || createDebug.log; - logFn.apply(self, args); - } + isWindows: isWindows$2, + isMacos, + isIBMi +} = constants$1; - debug.namespace = namespace; - debug.useColors = createDebug.useColors(); - debug.color = createDebug.selectColor(namespace); - debug.extend = extend; - debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. +const stat = promisify(fs$6.stat); +const readdir = promisify(fs$6.readdir); - Object.defineProperty(debug, 'enabled', { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } +/** + * @typedef {String} Path + * @typedef {'all'|'add'|'addDir'|'change'|'unlink'|'unlinkDir'|'raw'|'error'|'ready'} EventName + * @typedef {'readdir'|'watch'|'add'|'remove'|'change'} ThrottleType + */ - return enabledCache; - }, - set: v => { - enableOverride = v; - } - }); +/** + * + * @typedef {Object} WatchHelpers + * @property {Boolean} followSymlinks + * @property {'stat'|'lstat'} statMethod + * @property {Path} path + * @property {Path} watchPath + * @property {Function} entryPath + * @property {Boolean} hasGlob + * @property {Object} globFilter + * @property {Function} filterPath + * @property {Function} filterDir + */ - // Env-specific initialization logic for debug instances - if (typeof createDebug.init === 'function') { - createDebug.init(debug); - } +const arrify = (value = []) => Array.isArray(value) ? value : [value]; +const flatten$1 = (list, result = []) => { + list.forEach(item => { + if (Array.isArray(item)) { + flatten$1(item, result); + } else { + result.push(item); + } + }); + return result; +}; - return debug; - } +const unifyPaths = (paths_) => { + /** + * @type {Array} + */ + const paths = flatten$1(arrify(paths_)); + if (!paths.every(p => typeof p === STRING_TYPE)) { + throw new TypeError(`Non-string provided as watch path: ${paths}`); + } + return paths.map(normalizePathToUnix); +}; - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } +// If SLASH_SLASH occurs at the beginning of path, it is not replaced +// because "//StoragePC/DrivePool/Movies" is a valid network path +const toUnix = (string) => { + let str = string.replace(BACK_SLASH_RE, SLASH$1); + let prepend = false; + if (str.startsWith(SLASH_SLASH)) { + prepend = true; + } + while (str.match(DOUBLE_SLASH_RE)) { + str = str.replace(DOUBLE_SLASH_RE, SLASH$1); + } + if (prepend) { + str = SLASH$1 + str; + } + return str; +}; - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; +// Our version of upath.normalize +// TODO: this is not equal to path-normalize module - investigate why +const normalizePathToUnix = (path) => toUnix(sysPath.normalize(toUnix(path))); - createDebug.names = []; - createDebug.skips = []; +const normalizeIgnored = (cwd = EMPTY_STR) => (path) => { + if (typeof path !== STRING_TYPE) return path; + return normalizePathToUnix(sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path)); +}; - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; +const getAbsolutePath = (path, cwd) => { + if (sysPath.isAbsolute(path)) { + return path; + } + if (path.startsWith(BANG)) { + return BANG + sysPath.join(cwd, path.slice(1)); + } + return sysPath.join(cwd, path); +}; - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; - } +const undef = (opts, key) => opts[key] === undefined; - namespaces = split[i].replace(/\*/g, '.*?'); +/** + * Directory entry. + * @property {Path} path + * @property {Set} items + */ +class DirEntry { + /** + * @param {Path} dir + * @param {Function} removeWatcher + */ + constructor(dir, removeWatcher) { + this.path = dir; + this._removeWatcher = removeWatcher; + /** @type {Set} */ + this.items = new Set(); + } - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - } + add(item) { + const {items} = this; + if (!items) return; + if (item !== ONE_DOT && item !== TWO_DOTS) items.add(item); + } - /** - * Disable debug output. - * - * @return {String} namespaces - * @api public - */ - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) - ].join(','); - createDebug.enable(''); - return namespaces; - } + async remove(item) { + const {items} = this; + if (!items) return; + items.delete(item); + if (items.size > 0) return; - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } + const dir = this.path; + try { + await readdir(dir); + } catch (err) { + if (this._removeWatcher) { + this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir)); + } + } + } - let i; - let len; + has(item) { + const {items} = this; + if (!items) return; + return items.has(item); + } - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } + /** + * @returns {Array} + */ + getChildren() { + const {items} = this; + if (!items) return; + return [...items.values()]; + } - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } + dispose() { + this.items.clear(); + delete this.path; + delete this._removeWatcher; + delete this.items; + Object.freeze(this); + } +} - return false; - } +const STAT_METHOD_F = 'stat'; +const STAT_METHOD_L = 'lstat'; +class WatchHelper { + constructor(path, watchPath, follow, fsw) { + this.fsw = fsw; + this.path = path = path.replace(REPLACER_RE, EMPTY_STR); + this.watchPath = watchPath; + this.fullWatchPath = sysPath.resolve(watchPath); + this.hasGlob = watchPath !== path; + /** @type {object|boolean} */ + if (path === EMPTY_STR) this.hasGlob = false; + this.globSymlink = this.hasGlob && follow ? undefined : false; + this.globFilter = this.hasGlob ? anymatch(path, undefined, ANYMATCH_OPTS) : false; + this.dirParts = this.getDirParts(path); + this.dirParts.forEach((parts) => { + if (parts.length > 1) parts.pop(); + }); + this.followSymlinks = follow; + this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L; + } - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } + checkGlobSymlink(entry) { + // only need to resolve once + // first entry should always have entry.parentDir === EMPTY_STR + if (this.globSymlink === undefined) { + this.globSymlink = entry.fullParentDir === this.fullWatchPath ? + false : {realPath: entry.fullParentDir, linkPath: this.fullWatchPath}; + } - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; - } + if (this.globSymlink) { + return entry.fullPath.replace(this.globSymlink.realPath, this.globSymlink.linkPath); + } - /** - * XXX DO NOT USE. This is a temporary stub function. - * XXX It WILL be removed in the next major release. - */ - function destroy() { - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } + return entry.fullPath; + } - createDebug.enable(createDebug.load()); + entryPath(entry) { + return sysPath.join(this.watchPath, + sysPath.relative(this.watchPath, this.checkGlobSymlink(entry)) + ); + } - return createDebug; -} + filterPath(entry) { + const {stats} = entry; + if (stats && stats.isSymbolicLink()) return this.filterDir(entry); + const resolvedPath = this.entryPath(entry); + const matchesGlob = this.hasGlob && typeof this.globFilter === FUNCTION_TYPE ? + this.globFilter(resolvedPath) : true; + return matchesGlob && + this.fsw._isntIgnored(resolvedPath, stats) && + this.fsw._hasReadPermissions(stats); + } -var common$4 = setup; + getDirParts(path) { + if (!this.hasGlob) return []; + const parts = []; + const expandedPath = path.includes(BRACE_START) ? braces.expand(path) : [path]; + expandedPath.forEach((path) => { + parts.push(sysPath.relative(this.watchPath, path).split(SLASH_OR_BACK_SLASH_RE)); + }); + return parts; + } -/* eslint-env browser */ + filterDir(entry) { + if (this.hasGlob) { + const entryParts = this.getDirParts(this.checkGlobSymlink(entry)); + let globstar = false; + this.unmatchedGlob = !this.dirParts.some((parts) => { + return parts.every((part, i) => { + if (part === GLOBSTAR$1) globstar = true; + return globstar || !entryParts[0][i] || anymatch(part, entryParts[0][i], ANYMATCH_OPTS); + }); + }); + } + return !this.unmatchedGlob && this.fsw._isntIgnored(this.entryPath(entry), entry.stats); + } +} -(function (module, exports) { /** - * This is the web browser implementation of `debug()`. + * Watches files & directories for changes. Emitted events: + * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error` + * + * new FSWatcher() + * .add(directories) + * .on('add', path => log('File', path, 'was added')) */ +class FSWatcher extends EventEmitter { +// Not indenting methods for history sake; for now. +constructor(_opts) { + super(); -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = localstorage(); -exports.destroy = (() => { - let warned = false; + const opts = {}; + if (_opts) Object.assign(opts, _opts); // for frozen objects - return () => { - if (!warned) { - warned = true; - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } - }; -})(); + /** @type {Map} */ + this._watched = new Map(); + /** @type {Map} */ + this._closers = new Map(); + /** @type {Set} */ + this._ignoredPaths = new Set(); -/** - * Colors. - */ + /** @type {Map} */ + this._throttled = new Map(); -exports.colors = [ - '#0000CC', - '#0000FF', - '#0033CC', - '#0033FF', - '#0066CC', - '#0066FF', - '#0099CC', - '#0099FF', - '#00CC00', - '#00CC33', - '#00CC66', - '#00CC99', - '#00CCCC', - '#00CCFF', - '#3300CC', - '#3300FF', - '#3333CC', - '#3333FF', - '#3366CC', - '#3366FF', - '#3399CC', - '#3399FF', - '#33CC00', - '#33CC33', - '#33CC66', - '#33CC99', - '#33CCCC', - '#33CCFF', - '#6600CC', - '#6600FF', - '#6633CC', - '#6633FF', - '#66CC00', - '#66CC33', - '#9900CC', - '#9900FF', - '#9933CC', - '#9933FF', - '#99CC00', - '#99CC33', - '#CC0000', - '#CC0033', - '#CC0066', - '#CC0099', - '#CC00CC', - '#CC00FF', - '#CC3300', - '#CC3333', - '#CC3366', - '#CC3399', - '#CC33CC', - '#CC33FF', - '#CC6600', - '#CC6633', - '#CC9900', - '#CC9933', - '#CCCC00', - '#CCCC33', - '#FF0000', - '#FF0033', - '#FF0066', - '#FF0099', - '#FF00CC', - '#FF00FF', - '#FF3300', - '#FF3333', - '#FF3366', - '#FF3399', - '#FF33CC', - '#FF33FF', - '#FF6600', - '#FF6633', - '#FF9900', - '#FF9933', - '#FFCC00', - '#FFCC33' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -// eslint-disable-next-line complexity -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } - - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } + /** @type {Map} */ + this._symlinkPaths = new Map(); - // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // Is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // Double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} + this._streams = new Set(); + this.closed = false; -/** - * Colorize log arguments if enabled. - * - * @api public - */ + // Set up default options. + if (undef(opts, 'persistent')) opts.persistent = true; + if (undef(opts, 'ignoreInitial')) opts.ignoreInitial = false; + if (undef(opts, 'ignorePermissionErrors')) opts.ignorePermissionErrors = false; + if (undef(opts, 'interval')) opts.interval = 100; + if (undef(opts, 'binaryInterval')) opts.binaryInterval = 300; + if (undef(opts, 'disableGlobbing')) opts.disableGlobbing = false; + opts.enableBinaryInterval = opts.binaryInterval !== opts.interval; -function formatArgs(args) { - args[0] = (this.useColors ? '%c' : '') + - this.namespace + - (this.useColors ? ' %c' : ' ') + - args[0] + - (this.useColors ? '%c ' : ' ') + - '+' + module.exports.humanize(this.diff); + // Enable fsevents on OS X when polling isn't explicitly enabled. + if (undef(opts, 'useFsEvents')) opts.useFsEvents = !opts.usePolling; - if (!this.useColors) { - return; - } + // If we can't use fsevents, ensure the options reflect it's disabled. + const canUseFsEvents = FsEventsHandler.canUse(); + if (!canUseFsEvents) opts.useFsEvents = false; - const c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); + // Use polling on Mac if not using fsevents. + // Other platforms use non-polling fs_watch. + if (undef(opts, 'usePolling') && !opts.useFsEvents) { + opts.usePolling = isMacos; + } - // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, match => { - if (match === '%%') { - return; - } - index++; - if (match === '%c') { - // We only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + // Always default to polling on IBM i because fs.watch() is not available on IBM i. + if(isIBMi) { + opts.usePolling = true; + } - args.splice(lastC, 0, c); -} + // Global override (useful for end-developers that need to force polling for all + // instances of chokidar, regardless of usage/dependency depth) + const envPoll = process.env.CHOKIDAR_USEPOLLING; + if (envPoll !== undefined) { + const envLower = envPoll.toLowerCase(); -/** - * Invokes `console.debug()` when available. - * No-op when `console.debug` is not a "function". - * If `console.debug` is not available, falls back - * to `console.log`. - * - * @api public - */ -exports.log = console.debug || console.log || (() => {}); + if (envLower === 'false' || envLower === '0') { + opts.usePolling = false; + } else if (envLower === 'true' || envLower === '1') { + opts.usePolling = true; + } else { + opts.usePolling = !!envLower; + } + } + const envInterval = process.env.CHOKIDAR_INTERVAL; + if (envInterval) { + opts.interval = Number.parseInt(envInterval, 10); + } -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ -function save(namespaces) { - try { - if (namespaces) { - exports.storage.setItem('debug', namespaces); - } else { - exports.storage.removeItem('debug'); - } - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + // Editor atomic write normalization enabled by default with fs.watch + if (undef(opts, 'atomic')) opts.atomic = !opts.usePolling && !opts.useFsEvents; + if (opts.atomic) this._pendingUnlinks = new Map(); -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ -function load() { - let r; - try { - r = exports.storage.getItem('debug'); - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } + if (undef(opts, 'followSymlinks')) opts.followSymlinks = true; - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } + if (undef(opts, 'awaitWriteFinish')) opts.awaitWriteFinish = false; + if (opts.awaitWriteFinish === true) opts.awaitWriteFinish = {}; + const awf = opts.awaitWriteFinish; + if (awf) { + if (!awf.stabilityThreshold) awf.stabilityThreshold = 2000; + if (!awf.pollInterval) awf.pollInterval = 100; + this._pendingWrites = new Map(); + } + if (opts.ignored) opts.ignored = arrify(opts.ignored); - return r; -} + let readyCalls = 0; + this._emitReady = () => { + readyCalls++; + if (readyCalls >= this._readyCount) { + this._emitReady = EMPTY_FN; + this._readyEmitted = true; + // use process.nextTick to allow time for listener to be bound + process.nextTick(() => this.emit(EV_READY)); + } + }; + this._emitRaw = (...args) => this.emit(EV_RAW, ...args); + this._readyEmitted = false; + this.options = opts; -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ + // Initialize with proper watcher. + if (opts.useFsEvents) { + this._fsEventsHandler = new FsEventsHandler(this); + } else { + this._nodeFsHandler = new NodeFsHandler(this); + } -function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } + // You’re frozen when your heart’s not open. + Object.freeze(opts); } -module.exports = common$4(exports); - -const {formatters} = module.exports; +// Public methods /** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + * Adds paths to be watched on an existing FSWatcher instance + * @param {Path|Array} paths_ + * @param {String=} _origAdd private; for handling non-existent paths to be watched + * @param {Boolean=} _internal private; indicates a non-user add + * @returns {FSWatcher} for chaining */ +add(paths_, _origAdd, _internal) { + const {cwd, disableGlobbing} = this.options; + this.closed = false; + let paths = unifyPaths(paths_); + if (cwd) { + paths = paths.map((path) => { + const absPath = getAbsolutePath(path, cwd); -formatters.j = function (v) { - try { - return JSON.stringify(v); - } catch (error) { - return '[UnexpectedJSONParseError]: ' + error.message; - } -}; -}(browser, browser.exports)); - -var node = {exports: {}}; - -var hasFlag$3 = (flag, argv = process.argv) => { - const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); - const position = argv.indexOf(prefix + flag); - const terminatorPosition = argv.indexOf('--'); - return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); -}; + // Check `path` instead of `absPath` because the cwd portion can't be a glob + if (disableGlobbing || !isGlob(path)) { + return absPath; + } + return normalizePath(absPath); + }); + } -const os$2 = require$$0__default$1['default']; -const tty = require$$1__default['default']; -const hasFlag$2 = hasFlag$3; + // set aside negated glob strings + paths = paths.filter((path) => { + if (path.startsWith(BANG)) { + this._ignoredPaths.add(path.slice(1)); + return false; + } -const {env: env$1} = process; + // if a path is being added that was previously ignored, stop ignoring it + this._ignoredPaths.delete(path); + this._ignoredPaths.delete(path + SLASH_GLOBSTAR); -let forceColor$1; -if (hasFlag$2('no-color') || - hasFlag$2('no-colors') || - hasFlag$2('color=false') || - hasFlag$2('color=never')) { - forceColor$1 = 0; -} else if (hasFlag$2('color') || - hasFlag$2('colors') || - hasFlag$2('color=true') || - hasFlag$2('color=always')) { - forceColor$1 = 1; -} + // reset the cached userIgnored anymatch fn + // to make ignoredPaths changes effective + this._userIgnored = undefined; -if ('FORCE_COLOR' in env$1) { - if (env$1.FORCE_COLOR === 'true') { - forceColor$1 = 1; - } else if (env$1.FORCE_COLOR === 'false') { - forceColor$1 = 0; - } else { - forceColor$1 = env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env$1.FORCE_COLOR, 10), 3); - } -} + return true; + }); -function translateLevel$1(level) { - if (level === 0) { - return false; - } + if (this.options.useFsEvents && this._fsEventsHandler) { + if (!this._readyCount) this._readyCount = paths.length; + if (this.options.persistent) this._readyCount *= 2; + paths.forEach((path) => this._fsEventsHandler._addToFsEvents(path)); + } else { + if (!this._readyCount) this._readyCount = 0; + this._readyCount += paths.length; + Promise.all( + paths.map(async path => { + const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, 0, 0, _origAdd); + if (res) this._emitReady(); + return res; + }) + ).then(results => { + if (this.closed) return; + results.filter(item => item).forEach(item => { + this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item)); + }); + }); + } - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; + return this; } -function supportsColor$1(haveStream, streamIsTTY) { - if (forceColor$1 === 0) { - return 0; - } - - if (hasFlag$2('color=16m') || - hasFlag$2('color=full') || - hasFlag$2('color=truecolor')) { - return 3; - } - - if (hasFlag$2('color=256')) { - return 2; - } - - if (haveStream && !streamIsTTY && forceColor$1 === undefined) { - return 0; - } - - const min = forceColor$1 || 0; - - if (env$1.TERM === 'dumb') { - return min; - } - - if (process.platform === 'win32') { - // Windows 10 build 10586 is the first Windows release that supports 256 colors. - // Windows 10 build 14931 is the first release that supports 16m/TrueColor. - const osRelease = os$2.release().split('.'); - if ( - Number(osRelease[0]) >= 10 && - Number(osRelease[2]) >= 10586 - ) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } - - return 1; - } - - if ('CI' in env$1) { - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') { - return 1; - } +/** + * Close watchers or start ignoring events from specified paths. + * @param {Path|Array} paths_ - string or array of strings, file/directory paths and/or globs + * @returns {FSWatcher} for chaining +*/ +unwatch(paths_) { + if (this.closed) return this; + const paths = unifyPaths(paths_); + const {cwd} = this.options; - return min; - } + paths.forEach((path) => { + // convert to absolute path unless relative path already matches + if (!sysPath.isAbsolute(path) && !this._closers.has(path)) { + if (cwd) path = sysPath.join(cwd, path); + path = sysPath.resolve(path); + } - if ('TEAMCITY_VERSION' in env$1) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0; - } + this._closePath(path); - if (env$1.COLORTERM === 'truecolor') { - return 3; - } + this._ignoredPaths.add(path); + if (this._watched.has(path)) { + this._ignoredPaths.add(path + SLASH_GLOBSTAR); + } - if ('TERM_PROGRAM' in env$1) { - const version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10); + // reset the cached userIgnored anymatch fn + // to make ignoredPaths changes effective + this._userIgnored = undefined; + }); - switch (env$1.TERM_PROGRAM) { - case 'iTerm.app': - return version >= 3 ? 3 : 2; - case 'Apple_Terminal': - return 2; - // No default - } - } + return this; +} - if (/-256(color)?$/i.test(env$1.TERM)) { - return 2; - } +/** + * Close watchers and remove all listeners from watched paths. + * @returns {Promise}. +*/ +close() { + if (this.closed) return this._closePromise; + this.closed = true; - if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) { - return 1; - } + // Memory management. + this.removeAllListeners(); + const closers = []; + this._closers.forEach(closerList => closerList.forEach(closer => { + const promise = closer(); + if (promise instanceof Promise) closers.push(promise); + })); + this._streams.forEach(stream => stream.destroy()); + this._userIgnored = undefined; + this._readyCount = 0; + this._readyEmitted = false; + this._watched.forEach(dirent => dirent.dispose()); + ['closers', 'watched', 'streams', 'symlinkPaths', 'throttled'].forEach(key => { + this[`_${key}`].clear(); + }); - if ('COLORTERM' in env$1) { - return 1; - } + this._closePromise = closers.length ? Promise.all(closers).then(() => undefined) : Promise.resolve(); + return this._closePromise; +} - return min; +/** + * Expose list of watched paths + * @returns {Object} for chaining +*/ +getWatched() { + const watchList = {}; + this._watched.forEach((entry, dir) => { + const key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir; + watchList[key || ONE_DOT] = entry.getChildren().sort(); + }); + return watchList; } -function getSupportLevel$1(stream) { - const level = supportsColor$1(stream, stream && stream.isTTY); - return translateLevel$1(level); +emitWithAll(event, args) { + this.emit(...args); + if (event !== EV_ERROR) this.emit(EV_ALL, ...args); } -var supportsColor_1$1 = { - supportsColor: getSupportLevel$1, - stdout: translateLevel$1(supportsColor$1(true, tty.isatty(1))), - stderr: translateLevel$1(supportsColor$1(true, tty.isatty(2))) -}; +// Common helpers +// -------------- /** - * Module dependencies. + * Normalize and emit events. + * Calling _emit DOES NOT MEAN emit() would be called! + * @param {EventName} event Type of event + * @param {Path} path File or directory path + * @param {*=} val1 arguments to be passed with event + * @param {*=} val2 + * @param {*=} val3 + * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag */ +async _emit(event, path, val1, val2, val3) { + if (this.closed) return; -(function (module, exports) { -const tty = require$$1__default['default']; -const util = require$$0__default['default']; + const opts = this.options; + if (isWindows$2) path = sysPath.normalize(path); + if (opts.cwd) path = sysPath.relative(opts.cwd, path); + /** @type Array */ + const args = [event, path]; + if (val3 !== undefined) args.push(val1, val2, val3); + else if (val2 !== undefined) args.push(val1, val2); + else if (val1 !== undefined) args.push(val1); -/** - * This is the Node.js implementation of `debug()`. - */ + const awf = opts.awaitWriteFinish; + let pw; + if (awf && (pw = this._pendingWrites.get(path))) { + pw.lastChange = new Date(); + return this; + } -exports.init = init; -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.destroy = util.deprecate( - () => {}, - 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' -); + if (opts.atomic) { + if (event === EV_UNLINK) { + this._pendingUnlinks.set(path, args); + setTimeout(() => { + this._pendingUnlinks.forEach((entry, path) => { + this.emit(...entry); + this.emit(EV_ALL, ...entry); + this._pendingUnlinks.delete(path); + }); + }, typeof opts.atomic === 'number' ? opts.atomic : 100); + return this; + } + if (event === EV_ADD && this._pendingUnlinks.has(path)) { + event = args[0] = EV_CHANGE; + this._pendingUnlinks.delete(path); + } + } -/** - * Colors. - */ + if (awf && (event === EV_ADD || event === EV_CHANGE) && this._readyEmitted) { + const awfEmit = (err, stats) => { + if (err) { + event = args[0] = EV_ERROR; + args[1] = err; + this.emitWithAll(event, args); + } else if (stats) { + // if stats doesn't exist the file must have been deleted + if (args.length > 2) { + args[2] = stats; + } else { + args.push(stats); + } + this.emitWithAll(event, args); + } + }; -exports.colors = [6, 2, 3, 4, 5, 1]; + this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit); + return this; + } -try { - // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) - // eslint-disable-next-line import/no-extraneous-dependencies - const supportsColor = supportsColor_1$1; + if (event === EV_CHANGE) { + const isThrottled = !this._throttle(EV_CHANGE, path, 50); + if (isThrottled) return this; + } - if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { - exports.colors = [ - 20, - 21, - 26, - 27, - 32, - 33, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 56, - 57, - 62, - 63, - 68, - 69, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 92, - 93, - 98, - 99, - 112, - 113, - 128, - 129, - 134, - 135, - 148, - 149, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 178, - 179, - 184, - 185, - 196, - 197, - 198, - 199, - 200, - 201, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 209, - 214, - 215, - 220, - 221 - ]; - } -} catch (error) { - // Swallow - we only care if `supports-color` is available; it doesn't have to be. + if (opts.alwaysStat && val1 === undefined && + (event === EV_ADD || event === EV_ADD_DIR || event === EV_CHANGE) + ) { + const fullPath = opts.cwd ? sysPath.join(opts.cwd, path) : path; + let stats; + try { + stats = await stat(fullPath); + } catch (err) {} + // Suppress event when fs_stat fails, to avoid sending undefined 'stat' + if (!stats || this.closed) return; + args.push(stats); + } + this.emitWithAll(event, args); + + return this; } /** - * Build up the default `inspectOpts` object from the environment variables. - * - * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js + * Common handler for errors + * @param {Error} error + * @returns {Error|Boolean} The error if defined, otherwise the value of the FSWatcher instance's `closed` flag */ +_handleError(error) { + const code = error && error.code; + if (error && code !== 'ENOENT' && code !== 'ENOTDIR' && + (!this.options.ignorePermissionErrors || (code !== 'EPERM' && code !== 'EACCES')) + ) { + this.emit(EV_ERROR, error); + } + return error || this.closed; +} -exports.inspectOpts = Object.keys(process.env).filter(key => { - return /^debug_/i.test(key); -}).reduce((obj, key) => { - // Camel-case - const prop = key - .substring(6) - .toLowerCase() - .replace(/_([a-z])/g, (_, k) => { - return k.toUpperCase(); - }); +/** + * Helper utility for throttling + * @param {ThrottleType} actionType type being throttled + * @param {Path} path being acted upon + * @param {Number} timeout duration of time to suppress duplicate actions + * @returns {Object|false} tracking object or false if action should be suppressed + */ +_throttle(actionType, path, timeout) { + if (!this._throttled.has(actionType)) { + this._throttled.set(actionType, new Map()); + } - // Coerce string value into JS value - let val = process.env[key]; - if (/^(yes|on|true|enabled)$/i.test(val)) { - val = true; - } else if (/^(no|off|false|disabled)$/i.test(val)) { - val = false; - } else if (val === 'null') { - val = null; - } else { - val = Number(val); - } + /** @type {Map} */ + const action = this._throttled.get(actionType); + /** @type {Object} */ + const actionPath = action.get(path); - obj[prop] = val; - return obj; -}, {}); + if (actionPath) { + actionPath.count++; + return false; + } -/** - * Is stdout a TTY? Colored output is enabled when `true`. - */ + let timeoutObject; + const clear = () => { + const item = action.get(path); + const count = item ? item.count : 0; + action.delete(path); + clearTimeout(timeoutObject); + if (item) clearTimeout(item.timeoutObject); + return count; + }; + timeoutObject = setTimeout(clear, timeout); + const thr = {timeoutObject, clear, count: 0}; + action.set(path, thr); + return thr; +} -function useColors() { - return 'colors' in exports.inspectOpts ? - Boolean(exports.inspectOpts.colors) : - tty.isatty(process.stderr.fd); +_incrReadyCount() { + return this._readyCount++; } /** - * Adds ANSI color escape codes if enabled. - * - * @api public + * Awaits write operation to finish. + * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback. + * @param {Path} path being acted upon + * @param {Number} threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished + * @param {EventName} event + * @param {Function} awfEmit Callback to be called when ready for event to be emitted. */ +_awaitWriteFinish(path, threshold, event, awfEmit) { + let timeoutHandler; -function formatArgs(args) { - const {namespace: name, useColors} = this; + let fullPath = path; + if (this.options.cwd && !sysPath.isAbsolute(path)) { + fullPath = sysPath.join(this.options.cwd, path); + } - if (useColors) { - const c = this.color; - const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c); - const prefix = ` ${colorCode};1m${name} \u001B[0m`; + const now = new Date(); - args[0] = prefix + args[0].split('\n').join('\n' + prefix); - args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m'); - } else { - args[0] = getDate() + name + ' ' + args[0]; - } -} + const awaitWriteFinish = (prevStat) => { + fs$6.stat(fullPath, (err, curStat) => { + if (err || !this._pendingWrites.has(path)) { + if (err && err.code !== 'ENOENT') awfEmit(err); + return; + } -function getDate() { - if (exports.inspectOpts.hideDate) { - return ''; - } - return new Date().toISOString() + ' '; -} + const now = Number(new Date()); -/** - * Invokes `util.format()` with the specified arguments and writes to stderr. - */ + if (prevStat && curStat.size !== prevStat.size) { + this._pendingWrites.get(path).lastChange = now; + } + const pw = this._pendingWrites.get(path); + const df = now - pw.lastChange; -function log(...args) { - return process.stderr.write(util.format(...args) + '\n'); -} + if (df >= threshold) { + this._pendingWrites.delete(path); + awfEmit(undefined, curStat); + } else { + timeoutHandler = setTimeout( + awaitWriteFinish, + this.options.awaitWriteFinish.pollInterval, + curStat + ); + } + }); + }; -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ -function save(namespaces) { - if (namespaces) { - process.env.DEBUG = namespaces; - } else { - // If you set a process.env field to null or undefined, it gets cast to the - // string 'null' or 'undefined'. Just delete instead. - delete process.env.DEBUG; - } + if (!this._pendingWrites.has(path)) { + this._pendingWrites.set(path, { + lastChange: now, + cancelWait: () => { + this._pendingWrites.delete(path); + clearTimeout(timeoutHandler); + return event; + } + }); + timeoutHandler = setTimeout( + awaitWriteFinish, + this.options.awaitWriteFinish.pollInterval + ); + } } -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - return process.env.DEBUG; +_getGlobIgnored() { + return [...this._ignoredPaths.values()]; } /** - * Init logic for `debug` instances. - * - * Create a new `inspectOpts` object in case `useColors` is set - * differently for a particular `debug` instance. + * Determines whether user has asked to ignore this path. + * @param {Path} path filepath or dir + * @param {fs.Stats=} stats result of fs.stat + * @returns {Boolean} */ +_isIgnored(path, stats) { + if (this.options.atomic && DOT_RE.test(path)) return true; + if (!this._userIgnored) { + const {cwd} = this.options; + const ign = this.options.ignored; -function init(debug) { - debug.inspectOpts = {}; + const ignored = ign && ign.map(normalizeIgnored(cwd)); + const paths = arrify(ignored) + .filter((path) => typeof path === STRING_TYPE && !isGlob(path)) + .map((path) => path + SLASH_GLOBSTAR); + const list = this._getGlobIgnored().map(normalizeIgnored(cwd)).concat(ignored, paths); + this._userIgnored = anymatch(list, undefined, ANYMATCH_OPTS); + } - const keys = Object.keys(exports.inspectOpts); - for (let i = 0; i < keys.length; i++) { - debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; - } + return this._userIgnored([path, stats]); } -module.exports = common$4(exports); - -const {formatters} = module.exports; +_isntIgnored(path, stat) { + return !this._isIgnored(path, stat); +} /** - * Map %o to `util.inspect()`, all on a single line. + * Provides a set of common helpers and properties relating to symlink and glob handling. + * @param {Path} path file, directory, or glob pattern being watched + * @param {Number=} depth at any depth > 0, this isn't a glob + * @returns {WatchHelper} object containing helpers for this path */ +_getWatchHelpers(path, depth) { + const watchPath = depth || this.options.disableGlobbing || !isGlob(path) ? path : globParent(path); + const follow = this.options.followSymlinks; -formatters.o = function (v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts) - .split('\n') - .map(str => str.trim()) - .join(' '); -}; + return new WatchHelper(path, watchPath, follow, this); +} + +// Directory helpers +// ----------------- /** - * Map %O to `util.inspect()`, allowing multiple lines if needed. + * Provides directory tracking objects + * @param {String} directory path of the directory + * @returns {DirEntry} the directory's tracking object */ +_getWatchedDir(directory) { + if (!this._boundRemove) this._boundRemove = this._remove.bind(this); + const dir = sysPath.resolve(directory); + if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove)); + return this._watched.get(dir); +} -formatters.O = function (v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts); -}; -}(node, node.exports)); +// File helpers +// ------------ /** - * Detect Electron renderer / nwjs process, which is node, but we should - * treat as a browser. - */ + * Check for read permissions. + * Based on this answer on SO: https://stackoverflow.com/a/11781404/1358405 + * @param {fs.Stats} stats - object, result of fs_stat + * @returns {Boolean} indicates whether the file can be read +*/ +_hasReadPermissions(stats) { + if (this.options.ignorePermissionErrors) return true; -if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { - src.exports = browser.exports; -} else { - src.exports = node.exports; + // stats.mode may be bigint + const md = stats && Number.parseInt(stats.mode, 10); + const st = md & 0o777; + const it = Number.parseInt(st.toString(8)[0], 10); + return Boolean(4 & it); } -var resolveFrom$1 = {exports: {}}; +/** + * Handles emitting unlink events for + * files and directories, and via recursion, for + * files and directories within directories that are unlinked + * @param {String} directory within which the following item is located + * @param {String} item base path of item/directory + * @returns {void} +*/ +_remove(directory, item, isDirectory) { + // if what is being deleted is a directory, get that directory's paths + // for recursive deleting and cleaning of watched object + // if it is not a directory, nestedDirectoryChildren will be empty array + const path = sysPath.join(directory, item); + const fullPath = sysPath.resolve(path); + isDirectory = isDirectory != null + ? isDirectory + : this._watched.has(path) || this._watched.has(fullPath); -const path$l = require$$0__default$2['default']; -const Module = require$$1__default$1['default']; -const fs$j = require$$0__default$3['default']; + // prevent duplicate handling in case of arriving here nearly simultaneously + // via multiple paths (such as _handleFile and _handleDir) + if (!this._throttle('remove', path, 100)) return; -const resolveFrom = (fromDirectory, moduleId, silent) => { - if (typeof fromDirectory !== 'string') { - throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof fromDirectory}\``); - } + // if the only watched file is removed, watch for its return + if (!isDirectory && !this.options.useFsEvents && this._watched.size === 1) { + this.add(directory, item, true); + } - if (typeof moduleId !== 'string') { - throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof moduleId}\``); - } + // This will create a new entry in the watched object in either case + // so we got to do the directory check beforehand + const wp = this._getWatchedDir(path); + const nestedDirectoryChildren = wp.getChildren(); - try { - fromDirectory = fs$j.realpathSync(fromDirectory); - } catch (error) { - if (error.code === 'ENOENT') { - fromDirectory = path$l.resolve(fromDirectory); - } else if (silent) { - return; - } else { - throw error; - } - } + // Recursively remove children directories / files. + nestedDirectoryChildren.forEach(nested => this._remove(path, nested)); - const fromFile = path$l.join(fromDirectory, 'noop.js'); + // Check if item was on the watched list and remove it + const parent = this._getWatchedDir(directory); + const wasTracked = parent.has(item); + parent.remove(item); - const resolveFileName = () => Module._resolveFilename(moduleId, { - id: fromFile, - filename: fromFile, - paths: Module._nodeModulePaths(fromDirectory) - }); + // Fixes issue #1042 -> Relative paths were detected and added as symlinks + // (https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L612), + // but never removed from the map in case the path was deleted. + // This leads to an incorrect state if the path was recreated: + // https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L553 + if (this._symlinkPaths.has(fullPath)) { + this._symlinkPaths.delete(fullPath); + } - if (silent) { - try { - return resolveFileName(); - } catch (error) { - return; - } - } + // If we wait for this file to be fully written, cancel the wait. + let relPath = path; + if (this.options.cwd) relPath = sysPath.relative(this.options.cwd, path); + if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) { + const event = this._pendingWrites.get(relPath).cancelWait(); + if (event === EV_ADD) return; + } - return resolveFileName(); -}; + // The Entry will either be a directory that just got removed + // or a bogus entry to a file, in either case we have to remove it + this._watched.delete(path); + this._watched.delete(fullPath); + const eventName = isDirectory ? EV_UNLINK_DIR : EV_UNLINK; + if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path); -resolveFrom$1.exports = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId); -resolveFrom$1.exports.silent = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId, true); + // Avoid conflicts if we later create another file with the same name + if (!this.options.useFsEvents) { + this._closePath(path); + } +} -var libnpmconfig = {}; +/** + * Closes all watchers for a path + * @param {Path} path + */ +_closePath(path) { + this._closeFile(path); + const dir = sysPath.dirname(path); + this._getWatchedDir(dir).remove(sysPath.basename(path)); +} -class FiggyPudding { - constructor (specs, opts, providers) { - this.__specs = specs || {}; - Object.keys(this.__specs).forEach(alias => { - if (typeof this.__specs[alias] === 'string') { - const key = this.__specs[alias]; - const realSpec = this.__specs[key]; - if (realSpec) { - const aliasArr = realSpec.aliases || []; - aliasArr.push(alias, key); - realSpec.aliases = [...(new Set(aliasArr))]; - this.__specs[alias] = realSpec; - } else { - throw new Error(`Alias refers to invalid key: ${key} -> ${alias}`) - } - } - }); - this.__opts = opts || {}; - this.__providers = reverse((providers).filter( - x => x != null && typeof x === 'object' - )); - this.__isFiggyPudding = true; - } - get (key) { - return pudGet(this, key, true) - } - get [Symbol.toStringTag] () { return 'FiggyPudding' } - forEach (fn, thisArg = this) { - for (let [key, value] of this.entries()) { - fn.call(thisArg, value, key, this); - } - } - toJSON () { - const obj = {}; - this.forEach((val, key) => { - obj[key] = val; - }); - return obj +/** + * Closes only file-specific watchers + * @param {Path} path + */ +_closeFile(path) { + const closers = this._closers.get(path); + if (!closers) return; + closers.forEach(closer => closer()); + this._closers.delete(path); +} + +/** + * + * @param {Path} path + * @param {Function} closer + */ +_addPathCloser(path, closer) { + if (!closer) return; + let list = this._closers.get(path); + if (!list) { + list = []; + this._closers.set(path, list); } - * entries (_matcher) { - for (let key of Object.keys(this.__specs)) { - yield [key, this.get(key)]; - } - const matcher = _matcher || this.__opts.other; - if (matcher) { - const seen = new Set(); - for (let p of this.__providers) { - const iter = p.entries ? p.entries(matcher) : entries(p); - for (let [key, val] of iter) { - if (matcher(key) && !seen.has(key)) { - seen.add(key); - yield [key, val]; - } - } - } + list.push(closer); +} + +_readdirp(root, opts) { + if (this.closed) return; + const options = {type: EV_ALL, alwaysStat: true, lstat: true, ...opts}; + let stream = readdirp(root, options); + this._streams.add(stream); + stream.once(STR_CLOSE, () => { + stream = undefined; + }); + stream.once(STR_END, () => { + if (stream) { + this._streams.delete(stream); + stream = undefined; } - } - * [Symbol.iterator] () { - for (let [key, value] of this.entries()) { - yield [key, value]; + }); + return stream; +} + +} + +// Export FSWatcher class +chokidar.FSWatcher = FSWatcher; + +/** + * Instantiates watcher with paths to be tracked. + * @param {String|Array} paths file/directory paths and/or globs + * @param {Object=} options chokidar opts + * @returns an instance of FSWatcher for chaining. + */ +const watch = (paths, options) => { + const watcher = new FSWatcher(options); + watcher.add(paths); + return watcher; +}; + +chokidar.watch = watch; + +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('vfile-message').VFileMessage} VFileMessage + * + * @typedef Statistics + * @property {number} fatal Fatal errors (`fatal: true`) + * @property {number} warn warning errors (`fatal: false`) + * @property {number} info informational messages (`fatal: null|undefined`) + * @property {number} nonfatal warning + info + * @property {number} total nonfatal + fatal + */ + +/** + * Get stats for a file, list of files, or list of messages. + * + * @param {Array.|VFile|VFileMessage} [value] + * @returns {Statistics} + */ +function statistics(value) { + var result = {true: 0, false: 0, null: 0}; + + if (value) { + if (Array.isArray(value)) { + list(value); + } else { + one(value); } } - * keys () { - for (let [key] of this.entries()) { - yield key; - } + + return { + fatal: result.true, + nonfatal: result.false + result.null, + warn: result.false, + info: result.null, + total: result.true + result.false + result.null } - * values () { - for (let [, value] of this.entries()) { - yield value; + + /** + * @param {Array.} value + * @returns {void} + */ + function list(value) { + var index = -1; + + while (++index < value.length) { + one(value[index]); } } - concat (...moreConfig) { - return new Proxy(new FiggyPudding( - this.__specs, - this.__opts, - reverse(this.__providers).concat(moreConfig) - ), proxyHandler) + + /** + * @param {VFile|VFileMessage} value + * @returns {void} + */ + function one(value) { + if ('messages' in value) return list(value.messages) + + result[ + value.fatal === undefined || value.fatal === null + ? null + : Boolean(value.fatal) + ]++; } } -try { - const util = require$$0__default['default']; - FiggyPudding.prototype[util.inspect.custom] = function (depth, opts) { - return ( - this[Symbol.toStringTag] + ' ' - ) + util.inspect(this.toJSON(), opts) - }; -} catch (e) {} -function BadKeyError (key) { - throw Object.assign(new Error( - `invalid config key requested: ${key}` - ), {code: 'EBADKEY'}) -} +/** + * @typedef {(error?: Error|null|undefined, ...output: any[]) => void} Callback + * @typedef {(...input: any[]) => any} Middleware + * + * @typedef {(...input: any[]) => void} Run Call all middleware. + * @typedef {(fn: Middleware) => Pipeline} Use Add `fn` (middleware) to the list. + * @typedef {{run: Run, use: Use}} Pipeline + */ -function pudGet (pud, key, validate) { - let spec = pud.__specs[key]; - if (validate && !spec && (!pud.__opts.other || !pud.__opts.other(key))) { - BadKeyError(key); - } else { - if (!spec) { spec = {}; } - let ret; - for (let p of pud.__providers) { - ret = tryGet(key, p); - if (ret === undefined && spec.aliases && spec.aliases.length) { - for (let alias of spec.aliases) { - if (alias === key) { continue } - ret = tryGet(alias, p); - if (ret !== undefined) { - break - } - } +/** + * Create new middleware. + * + * @returns {Pipeline} + */ +function trough() { + /** @type {Middleware[]} */ + const fns = []; + /** @type {Pipeline} */ + const pipeline = {run, use}; + + return pipeline + + /** @type {Run} */ + function run(...values) { + let middlewareIndex = -1; + /** @type {Callback} */ + const callback = values.pop(); + + if (typeof callback !== 'function') { + throw new TypeError('Expected function as last argument, not ' + callback) + } + + next(null, ...values); + + /** + * Run the next `fn`, or we’re done. + * + * @param {Error|null|undefined} error + * @param {any[]} output + */ + function next(error, ...output) { + const fn = fns[++middlewareIndex]; + let index = -1; + + if (error) { + callback(error); + return } - if (ret !== undefined) { - break + + // Copy non-nullish input into values. + while (++index < values.length) { + if (output[index] === null || output[index] === undefined) { + output[index] = values[index]; + } } - } - if (ret === undefined && spec.default !== undefined) { - if (typeof spec.default === 'function') { - return spec.default(pud) + + // Save the newly created `output` for the next call. + values = output; + + // Next or done. + if (fn) { + wrap(fn, next)(...output); } else { - return spec.default + callback(null, ...output); } - } else { - return ret } } -} -function tryGet (key, p) { - let ret; - if (p.__isFiggyPudding) { - ret = pudGet(p, key, false); - } else if (typeof p.get === 'function') { - ret = p.get(key); - } else { - ret = p[key]; + /** @type {Use} */ + function use(middelware) { + if (typeof middelware !== 'function') { + throw new TypeError( + 'Expected `middelware` to be a function, not ' + middelware + ) + } + + fns.push(middelware); + return pipeline } - return ret } -const proxyHandler = { - has (obj, prop) { - return prop in obj.__specs && pudGet(obj, prop, false) !== undefined - }, - ownKeys (obj) { - return Object.keys(obj.__specs) - }, - get (obj, prop) { - if ( - typeof prop === 'symbol' || - prop.slice(0, 2) === '__' || - prop in FiggyPudding.prototype - ) { - return obj[prop] +/** + * Wrap `middleware`. + * Can be sync or async; return a promise, receive a callback, or return new + * values and errors. + * + * @param {Middleware} middleware + * @param {Callback} callback + */ +function wrap(middleware, callback) { + /** @type {boolean} */ + let called; + + return wrapped + + /** + * Call `middleware`. + * @param {any[]} parameters + * @returns {void} + */ + function wrapped(...parameters) { + const fnExpectsCallback = middleware.length > parameters.length; + /** @type {any} */ + let result; + + if (fnExpectsCallback) { + parameters.push(done); } - return obj.get(prop) - }, - set (obj, prop, value) { - if ( - typeof prop === 'symbol' || - prop.slice(0, 2) === '__' - ) { - obj[prop] = value; - return true - } else { - throw new Error('figgyPudding options cannot be modified. Use .concat() instead.') + + try { + result = middleware(...parameters); + } catch (error) { + /** @type {Error} */ + const exception = error; + + // Well, this is quite the pickle. + // `middleware` received a callback and called it synchronously, but that + // threw an error. + // The only thing left to do is to throw the thing instead. + if (fnExpectsCallback && called) { + throw exception + } + + return done(exception) + } + + if (!fnExpectsCallback) { + if (result instanceof Promise) { + result.then(then, done); + } else if (result instanceof Error) { + done(result); + } else { + then(result); + } } - }, - deleteProperty () { - throw new Error('figgyPudding options cannot be deleted. Use .concat() and shadow them instead.') } -}; -var figgyPudding_1 = figgyPudding$1; -function figgyPudding$1 (specs, opts) { - function factory (...providers) { - return new Proxy(new FiggyPudding( - specs, - opts, - providers - ), proxyHandler) + /** + * Call `callback`, only once. + * @type {Callback} + */ + function done(error, ...output) { + if (!called) { + called = true; + callback(error, ...output); + } + } + + /** + * Call `done` with one value. + * + * @param {any} [value] + */ + function then(value) { + done(null, value); } - return factory } -function reverse (arr) { - const ret = []; - arr.forEach(x => ret.unshift(x)); - return ret +/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ +function isNothing(subject) { + return (typeof subject === 'undefined') || (subject === null); } -function entries (obj) { - return Object.keys(obj).map(k => [k, obj[k]]) + +function isObject$1(subject) { + return (typeof subject === 'object') && (subject !== null); } -var findUp$2 = {exports: {}}; -var locatePath$1 = {exports: {}}; +function toArray(sequence) { + if (Array.isArray(sequence)) return sequence; + else if (isNothing(sequence)) return []; -var pathExists$1 = {exports: {}}; + return [ sequence ]; +} -const fs$i = require$$0__default$3['default']; -pathExists$1.exports = fp => new Promise(resolve => { - fs$i.access(fp, err => { - resolve(!err); - }); -}); +function extend$2(target, source) { + var index, length, key, sourceKeys; -pathExists$1.exports.sync = fp => { - try { - fs$i.accessSync(fp); - return true; - } catch (err) { - return false; - } -}; + if (source) { + sourceKeys = Object.keys(source); -var pLimit$2 = {exports: {}}; + for (index = 0, length = sourceKeys.length; index < length; index += 1) { + key = sourceKeys[index]; + target[key] = source[key]; + } + } -var pTry$2 = {exports: {}}; + return target; +} -const pTry$1 = (fn, ...arguments_) => new Promise(resolve => { - resolve(fn(...arguments_)); -}); -pTry$2.exports = pTry$1; -// TODO: remove this in the next major version -pTry$2.exports.default = pTry$1; +function repeat$1(string, count) { + var result = '', cycle; -const pTry = pTry$2.exports; + for (cycle = 0; cycle < count; cycle += 1) { + result += string; + } -const pLimit$1 = concurrency => { - if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) { - return Promise.reject(new TypeError('Expected `concurrency` to be a number from 1 and up')); - } + return result; +} - const queue = []; - let activeCount = 0; - const next = () => { - activeCount--; +function isNegativeZero(number) { + return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); +} - if (queue.length > 0) { - queue.shift()(); - } - }; - const run = (fn, resolve, ...args) => { - activeCount++; +var isNothing_1 = isNothing; +var isObject_1 = isObject$1; +var toArray_1 = toArray; +var repeat_1 = repeat$1; +var isNegativeZero_1 = isNegativeZero; +var extend_1 = extend$2; - const result = pTry(fn, ...args); +var common$4 = { + isNothing: isNothing_1, + isObject: isObject_1, + toArray: toArray_1, + repeat: repeat_1, + isNegativeZero: isNegativeZero_1, + extend: extend_1 +}; - resolve(result); +// YAML error class. http://stackoverflow.com/questions/8458984 - result.then(next, next); - }; - const enqueue = (fn, resolve, ...args) => { - if (activeCount < concurrency) { - run(fn, resolve, ...args); - } else { - queue.push(run.bind(null, fn, resolve, ...args)); - } - }; +function formatError(exception, compact) { + var where = '', message = exception.reason || '(unknown reason)'; - const generator = (fn, ...args) => new Promise(resolve => enqueue(fn, resolve, ...args)); - Object.defineProperties(generator, { - activeCount: { - get: () => activeCount - }, - pendingCount: { - get: () => queue.length - }, - clearQueue: { - value: () => { - queue.length = 0; - } - } - }); + if (!exception.mark) return message; - return generator; -}; + if (exception.mark.name) { + where += 'in "' + exception.mark.name + '" '; + } -pLimit$2.exports = pLimit$1; -pLimit$2.exports.default = pLimit$1; + where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; -const pLimit = pLimit$2.exports; + if (!compact && exception.mark.snippet) { + where += '\n\n' + exception.mark.snippet; + } -class EndError extends Error { - constructor(value) { - super(); - this.value = value; - } + return message + ' ' + where; } -// The input can also be a promise, so we `Promise.resolve()` it -const testElement = (el, tester) => Promise.resolve(el).then(tester); -// The input can also be a promise, so we `Promise.all()` them both -const finder$1 = el => Promise.all(el).then(val => val[1] === true && Promise.reject(new EndError(val[0]))); +function YAMLException$1(reason, mark) { + // Super constructor + Error.call(this); -var pLocate$1 = (iterable, tester, opts) => { - opts = Object.assign({ - concurrency: Infinity, - preserveOrder: true - }, opts); + this.name = 'YAMLException'; + this.reason = reason; + this.mark = mark; + this.message = formatError(this, false); - const limit = pLimit(opts.concurrency); + // Include stack trace in error object + if (Error.captureStackTrace) { + // Chrome and NodeJS + Error.captureStackTrace(this, this.constructor); + } else { + // FF, IE 10+ and Safari 6+. Fallback for others + this.stack = (new Error()).stack || ''; + } +} - // Start all the promises concurrently with optional limit - const items = [...iterable].map(el => [el, limit(testElement, el, tester)]); - // Check the promises either serially or concurrently - const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity); +// Inherit from Error +YAMLException$1.prototype = Object.create(Error.prototype); +YAMLException$1.prototype.constructor = YAMLException$1; - return Promise.all(items.map(el => checkLimit(finder$1, el))) - .then(() => {}) - .catch(err => err instanceof EndError ? err.value : Promise.reject(err)); -}; -const path$k = require$$0__default$2['default']; -const pathExists = pathExists$1.exports; -const pLocate = pLocate$1; - -locatePath$1.exports = (iterable, options) => { - options = Object.assign({ - cwd: process.cwd() - }, options); - - return pLocate(iterable, el => pathExists(path$k.resolve(options.cwd, el)), options); +YAMLException$1.prototype.toString = function toString(compact) { + return this.name + ': ' + formatError(this, compact); }; -locatePath$1.exports.sync = (iterable, options) => { - options = Object.assign({ - cwd: process.cwd() - }, options); - for (const el of iterable) { - if (pathExists.sync(path$k.resolve(options.cwd, el))) { - return el; - } - } -}; +var exception = YAMLException$1; -const path$j = require$$0__default$2['default']; -const locatePath = locatePath$1.exports; +// get snippet for a single line, respecting maxLength +function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { + var head = ''; + var tail = ''; + var maxHalfLength = Math.floor(maxLineLength / 2) - 1; -findUp$2.exports = (filename, opts = {}) => { - const startDir = path$j.resolve(opts.cwd || ''); - const {root} = path$j.parse(startDir); + if (position - lineStart > maxHalfLength) { + head = ' ... '; + lineStart = position - maxHalfLength + head.length; + } - const filenames = [].concat(filename); + if (lineEnd - position > maxHalfLength) { + tail = ' ...'; + lineEnd = position + maxHalfLength - tail.length; + } - return new Promise(resolve => { - (function find(dir) { - locatePath(filenames, {cwd: dir}).then(file => { - if (file) { - resolve(path$j.join(dir, file)); - } else if (dir === root) { - resolve(null); - } else { - find(path$j.dirname(dir)); - } - }); - })(startDir); - }); -}; + return { + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, + pos: position - lineStart + head.length // relative position + }; +} -findUp$2.exports.sync = (filename, opts = {}) => { - let dir = path$j.resolve(opts.cwd || ''); - const {root} = path$j.parse(dir); - const filenames = [].concat(filename); +function padStart(string, max) { + return common$4.repeat(' ', max - string.length) + string; +} - // eslint-disable-next-line no-constant-condition - while (true) { - const file = locatePath.sync(filenames, {cwd: dir}); - if (file) { - return path$j.join(dir, file); - } +function makeSnippet(mark, options) { + options = Object.create(options || null); - if (dir === root) { - return null; - } + if (!mark.buffer) return null; - dir = path$j.dirname(dir); - } -}; + 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 ini$1 = {}; + var re = /\r?\n|\r|\0/g; + var lineStarts = [ 0 ]; + var lineEnds = []; + var match; + var foundLineNo = -1; -ini$1.parse = ini$1.decode = decode$2; + while ((match = re.exec(mark.buffer))) { + lineEnds.push(match.index); + lineStarts.push(match.index + match[0].length); -ini$1.stringify = ini$1.encode = encode$1; + if (mark.position <= match.index && foundLineNo < 0) { + foundLineNo = lineStarts.length - 2; + } + } -ini$1.safe = safe$8; -ini$1.unsafe = unsafe$1; + if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; -var eol$2 = typeof process !== 'undefined' && - process.platform === 'win32' ? '\r\n' : '\n'; + var result = '', i, line; + var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; + var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); -function encode$1 (obj, opt) { - var children = []; - var out = ''; + for (i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo - i], + lineEnds[foundLineNo - i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), + maxLineLength + ); + result = common$4.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n' + result; + } - if (typeof opt === 'string') { - opt = { - section: opt, - whitespace: false, - }; - } else { - opt = opt || {}; - opt.whitespace = opt.whitespace === true; + line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + result += common$4.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + result += common$4.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; + + for (i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo + i], + lineEnds[foundLineNo + i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), + maxLineLength + ); + result += common$4.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; } - var separator = opt.whitespace ? ' = ' : '='; + return result.replace(/\n$/, ''); +} - Object.keys(obj).forEach(function (k, _, __) { - var val = obj[k]; - if (val && Array.isArray(val)) { - val.forEach(function (item) { - out += safe$8(k + '[]') + separator + safe$8(item) + '\n'; - }); - } else if (val && typeof val === 'object') - children.push(k); - else - out += safe$8(k) + separator + safe$8(val) + eol$2; - }); - if (opt.section && out.length) - out = '[' + safe$8(opt.section) + ']' + eol$2 + out; +var snippet = makeSnippet; - children.forEach(function (k, _, __) { - var nk = dotSplit(k).join('\\.'); - var section = (opt.section ? opt.section + '.' : '') + nk; - var child = encode$1(obj[k], { - section: section, - whitespace: opt.whitespace, - }); - if (out.length && child.length) - out += eol$2; +var TYPE_CONSTRUCTOR_OPTIONS = [ + 'kind', + 'multi', + 'resolve', + 'construct', + 'instanceOf', + 'predicate', + 'represent', + 'representName', + 'defaultStyle', + 'styleAliases' +]; - out += child; - }); +var YAML_NODE_KINDS = [ + 'scalar', + 'sequence', + 'mapping' +]; - return out -} +function compileStyleAliases(map) { + var result = {}; -function dotSplit (str) { - return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002') - .replace(/\\\./g, '\u0001') - .split(/\./).map(function (part) { - return part.replace(/\1/g, '\\.') - .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001') - }) -} + if (map !== null) { + Object.keys(map).forEach(function (style) { + map[style].forEach(function (alias) { + result[String(alias)] = style; + }); + }); + } -function decode$2 (str) { - var out = {}; - var p = out; - var section = null; - // section |key = value - var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i; - var lines = str.split(/[\r\n]+/g); + return result; +} - lines.forEach(function (line, _, __) { - if (!line || line.match(/^\s*[;#]/)) - return - var match = line.match(re); - if (!match) - return - if (match[1] !== undefined) { - section = unsafe$1(match[1]); - if (section === '__proto__') { - // not allowed - // keep parsing the section, but don't attach it. - p = {}; - return - } - p = out[section] = out[section] || {}; - return - } - var key = unsafe$1(match[2]); - if (key === '__proto__') - return - var value = match[3] ? unsafe$1(match[4]) : true; - switch (value) { - case 'true': - case 'false': - case 'null': value = JSON.parse(value); - } +function Type$1(tag, options) { + options = options || {}; - // Convert keys with '[]' suffix to an array - if (key.length > 2 && key.slice(-2) === '[]') { - key = key.substring(0, key.length - 2); - if (key === '__proto__') - return - if (!p[key]) - p[key] = []; - else if (!Array.isArray(p[key])) - p[key] = [p[key]]; + Object.keys(options).forEach(function (name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); } - - // safeguard against resetting a previously defined - // array by accidentally forgetting the brackets - if (Array.isArray(p[key])) - p[key].push(value); - else - p[key] = value; }); - // {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}} - // use a filter to return the keys that have to be deleted. - Object.keys(out).filter(function (k, _, __) { - if (!out[k] || - typeof out[k] !== 'object' || - Array.isArray(out[k])) - return false + // TODO: Add tag format check. + this.options = options; // keep original options in case user wants to extend this type later + 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); - // see if the parent section is also an object. - // if so, add it to that, and mark this one for deletion - var parts = dotSplit(k); - var p = out; - var l = parts.pop(); - var nl = l.replace(/\\\./g, '.'); - parts.forEach(function (part, _, __) { - if (part === '__proto__') - return - if (!p[part] || typeof p[part] !== 'object') - p[part] = {}; - p = p[part]; - }); - if (p === out && nl === l) - return false + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} - p[nl] = out[k]; - return true - }).forEach(function (del, _, __) { - delete out[del]; - }); +var type$1 = Type$1; - return out -} +/*eslint-disable max-len*/ -function isQuoted (val) { - return (val.charAt(0) === '"' && val.slice(-1) === '"') || - (val.charAt(0) === "'" && val.slice(-1) === "'") -} -function safe$8 (val) { - return (typeof val !== 'string' || - val.match(/[=\r\n]/) || - val.match(/^\[/) || - (val.length > 1 && - isQuoted(val)) || - val !== val.trim()) - ? JSON.stringify(val) - : val.replace(/;/g, '\\;').replace(/#/g, '\\#') -} -function unsafe$1 (val, doUnesc) { - val = (val || '').trim(); - if (isQuoted(val)) { - // remove the single quotes before calling JSON.parse - if (val.charAt(0) === "'") - val = val.substr(1, val.length - 2); - try { - val = JSON.parse(val); - } catch (_) {} - } else { - // walk the val to find the first not-escaped ; character - var esc = false; - var unesc = ''; - for (var i = 0, l = val.length; i < l; i++) { - var c = val.charAt(i); - if (esc) { - if ('\\;#'.indexOf(c) !== -1) - unesc += c; - else - unesc += '\\' + c; - esc = false; - } else if (';#'.indexOf(c) !== -1) - break - else if (c === '\\') - esc = true; - else - unesc += c; - } - if (esc) - unesc += '\\'; +function compileList(schema, name) { + var result = []; - return unesc.trim() - } - return val -} + schema[name].forEach(function (currentType) { + var newIndex = result.length; -const fs$h = require$$0__default$3['default']; -const figgyPudding = figgyPudding_1; -const findUp$1 = findUp$2.exports; -const ini = ini$1; -const os$1 = require$$0__default$1['default']; -const path$i = require$$0__default$2['default']; + result.forEach(function (previousType, previousIndex) { + if (previousType.tag === currentType.tag && + previousType.kind === currentType.kind && + previousType.multi === currentType.multi) { -const NpmConfig = figgyPudding({}, { - // Open up the pudding object. - other () { return true } -}); + newIndex = previousIndex; + } + }); -const ConfigOpts = figgyPudding({ - cache: { default: path$i.join(os$1.homedir(), '.npm') }, - configNames: { default: ['npmrc', '.npmrc'] }, - envPrefix: { default: /^npm_config_/i }, - cwd: { default: () => process.cwd() }, - globalconfig: { - default: () => path$i.join(getGlobalPrefix(), 'etc', 'npmrc') - }, - userconfig: { default: path$i.join(os$1.homedir(), '.npmrc') } -}); + result[newIndex] = currentType; + }); -libnpmconfig.read = getNpmConfig; -function getNpmConfig (_opts, _builtin) { - const builtin = ConfigOpts(_builtin); - const env = {}; - for (let key of Object.keys(process.env)) { - if (!key.match(builtin.envPrefix)) continue - const newKey = key.toLowerCase() - .replace(builtin.envPrefix, '') - .replace(/(?!^)_/g, '-'); - env[newKey] = process.env[key]; - } - const cli = NpmConfig(_opts); - const userConfPath = ( - builtin.userconfig || - cli.userconfig || - env.userconfig - ); - const user = userConfPath && maybeReadIni(userConfPath); - const globalConfPath = ( - builtin.globalconfig || - cli.globalconfig || - env.globalconfig - ); - const global = globalConfPath && maybeReadIni(globalConfPath); - const projConfPath = findUp$1.sync(builtin.configNames, { cwd: builtin.cwd }); - let proj = {}; - if (projConfPath && projConfPath !== userConfPath) { - proj = maybeReadIni(projConfPath); - } - const newOpts = NpmConfig(builtin, global, user, proj, env, cli); - if (newOpts.cache) { - return newOpts.concat({ - cache: path$i.resolve( - ( - (cli.cache || env.cache) - ? builtin.cwd - : proj.cache - ? path$i.dirname(projConfPath) - : user.cache - ? path$i.dirname(userConfPath) - : global.cache - ? path$i.dirname(globalConfPath) - : path$i.dirname(userConfPath) - ), - newOpts.cache - ) - }) - } else { - return newOpts - } + return result; } -function maybeReadIni (f) { - let txt; - try { - txt = fs$h.readFileSync(f, 'utf8'); - } catch (err) { - if (err.code === 'ENOENT') { - return '' + +function compileMap(/* lists... */) { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + }, index, length; + + function collectType(type) { + if (type.multi) { + result.multi[type.kind].push(type); + result.multi['fallback'].push(type); } else { - throw err + result[type.kind][type.tag] = result['fallback'][type.tag] = type; } } - return ini.parse(txt) -} -function getGlobalPrefix () { - if (process.env.PREFIX) { - return process.env.PREFIX - } else if (process.platform === 'win32') { - // c:\node\node.exe --> prefix=c:\node\ - return path$i.dirname(process.execPath) - } else { - // /usr/local/bin/node --> prefix=/usr/local - let pref = path$i.dirname(path$i.dirname(process.execPath)); - // destdir only is respected on Unix - if (process.env.DESTDIR) { - pref = path$i.join(process.env.DESTDIR, pref); - } - return pref + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); } + return result; } -var fs$g = require$$0__default$3['default']; -var path$h = require$$0__default$2['default']; -var resolve = resolveFrom$1.exports.silent; -var readNpmConfig = libnpmconfig.read; - -var loadPlugin_1 = loadPlugin$1; -loadPlugin$1.resolve = resolvePlugin; - -var electron = process.versions.electron !== undefined; -var windows = process.platform === 'win32'; - -var argv = process.argv[1] || /* istanbul ignore next */ ''; -var nvm = process.env.NVM_BIN; -var appData = process.env.APPDATA; - -/* istanbul ignore next */ -var globalsLibrary = windows ? '' : 'lib'; - -var builtinNpmConfig; - -// The prefix config defaults to the location where node is installed. -// On Windows, this is in a place called `%AppData%`, which we have to -// pass to `libnpmconfig` explicitly: -/* istanbul ignore next */ -if (windows && appData) { - builtinNpmConfig = {prefix: path$h.join(appData, 'npm')}; -} - -var npmPrefix = readNpmConfig(null, builtinNpmConfig).prefix; -// If there is no prefix defined, use the defaults -// See: -/* istanbul ignore next */ -if (!npmPrefix) { - npmPrefix = windows - ? path$h.dirname(process.execPath) - : path$h.resolve(process.execPath, '../..'); +function Schema$1(definition) { + return this.extend(definition); } -var globally = electron || argv.indexOf(npmPrefix) === 0; -var globals = path$h.resolve(npmPrefix, globalsLibrary, 'node_modules'); -// If we’re in Electron, we’re running in a modified Node that cannot really -// install global node modules. -// To find the actual modules, the user has to set `prefix` somewhere in an -// `.npmrc` (which is picked up by `libnpmconfig`). -// Most people don’t do that, and some use NVM instead to manage different -// versions of Node. -// Luckily NVM leaks some environment variables that we can pick up on to try -// and detect the actual modules. -/* istanbul ignore next */ -if (electron && nvm && !fs$g.existsSync(globals)) { - globals = path$h.resolve(nvm, '..', globalsLibrary, 'node_modules'); -} +Schema$1.prototype.extend = function extend(definition) { + var implicit = []; + var explicit = []; -// Load the plugin found using `resolvePlugin`. -function loadPlugin$1(name, options) { - return commonjsRequire(resolvePlugin(name, options) || name) -} + if (definition instanceof type$1) { + // Schema.extend(type) + explicit.push(definition); -// Find a plugin. -// -// See also: -// -// -// -// Uses the standard node module loading strategy to find $name in each given -// `cwd` (and optionally the global `node_modules` directory). -// -// If a prefix is given and $name is not a path, `$prefix-$name` is also -// searched (preferring these over non-prefixed modules). -function resolvePlugin(name, options) { - var settings = options || {}; - var prefix = settings.prefix; - var cwd = settings.cwd; - var global = settings.global; - var filePath; - var sources; - var length; - var index; - var plugin; - var slash; - var scope = ''; + } else if (Array.isArray(definition)) { + // Schema.extend([ type1, type2, ... ]) + explicit = explicit.concat(definition); - if (global === null || global === undefined) { - global = globally; - } + } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { + // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) + if (definition.implicit) implicit = implicit.concat(definition.implicit); + if (definition.explicit) explicit = explicit.concat(definition.explicit); - if (cwd && typeof cwd === 'object') { - sources = cwd.concat(); } else { - sources = [cwd || process.cwd()]; + throw new exception('Schema.extend argument should be a Type, [ Type ], ' + + 'or a schema definition ({ implicit: [...], explicit: [...] })'); } - // Non-path. - if (name.charAt(0) !== '.') { - if (global) { - sources.push(globals); + 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.'); } - // Unprefix module. - if (prefix) { - prefix = prefix.charAt(prefix.length - 1) === '-' ? prefix : prefix + '-'; + 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.'); + } - // Scope? - if (name.charAt(0) === '@') { - slash = name.indexOf('/'); + 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.'); + } + }); - // Let’s keep the algorithm simple. - // No need to care if this is a “valid” scope (I think?). - // But we do check for the slash. - if (slash !== -1) { - scope = name.slice(0, slash + 1); - name = name.slice(slash + 1); - } - } - - if (name.slice(0, prefix.length) !== prefix) { - plugin = scope + prefix + name; - } - - name = scope + name; + 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.'); } - } - - length = sources.length; - index = -1; - - while (++index < length) { - cwd = sources[index]; - filePath = (plugin && resolve(cwd, plugin)) || resolve(cwd, name); + }); - if (filePath) { - return filePath - } - } + var result = Object.create(Schema$1.prototype); - return null -} + result.implicit = (this.implicit || []).concat(implicit); + result.explicit = (this.explicit || []).concat(explicit); -var isPlainObj = value => { - if (Object.prototype.toString.call(value) !== '[object Object]') { - return false; - } + result.compiledImplicit = compileList(result, 'implicit'); + result.compiledExplicit = compileList(result, 'explicit'); + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); - const prototype = Object.getPrototypeOf(value); - return prototype === null || prototype === Object.prototype; + return result; }; -var format$1 = {exports: {}}; - -(function (module) { -(function() { - - //// Export the API - var namespace; - - // CommonJS / Node module - { - namespace = module.exports = format; - } - - namespace.format = format; - namespace.vsprintf = vsprintf; - if (typeof console !== 'undefined' && typeof console.log === 'function') { - namespace.printf = printf; - } +var schema$1 = Schema$1; - function printf(/* ... */) { - console.log(format.apply(null, arguments)); - } +var str = new type$1('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } +}); - function vsprintf(fmt, replacements) { - return format.apply(null, [fmt].concat(replacements)); - } +var seq = new type$1('tag:yaml.org,2002:seq', { + kind: 'sequence', + construct: function (data) { return data !== null ? data : []; } +}); - function format(fmt) { - var argIndex = 1 // skip initial format argument - , args = [].slice.call(arguments) - , i = 0 - , n = fmt.length - , result = '' - , c - , escaped = false - , arg - , tmp - , leadingZero = false - , precision - , nextArg = function() { return args[argIndex++]; } - , slurpNumber = function() { - var digits = ''; - while (/\d/.test(fmt[i])) { - digits += fmt[i++]; - c = fmt[i]; - } - return digits.length > 0 ? parseInt(digits) : null; - } - ; - for (; i < n; ++i) { - c = fmt[i]; - if (escaped) { - escaped = false; - if (c == '.') { - leadingZero = false; - c = fmt[++i]; - } - else if (c == '0' && fmt[i + 1] == '.') { - leadingZero = true; - i += 2; - c = fmt[i]; - } - else { - leadingZero = true; - } - precision = slurpNumber(); - switch (c) { - case 'b': // number in binary - result += parseInt(nextArg(), 10).toString(2); - break; - case 'c': // character - arg = nextArg(); - if (typeof arg === 'string' || arg instanceof String) - result += arg; - else - result += String.fromCharCode(parseInt(arg, 10)); - break; - case 'd': // number in decimal - result += parseInt(nextArg(), 10); - break; - case 'f': // floating point number - tmp = String(parseFloat(nextArg()).toFixed(precision || 6)); - result += leadingZero ? tmp : tmp.replace(/^0/, ''); - break; - case 'j': // JSON - result += JSON.stringify(nextArg()); - break; - case 'o': // number in octal - result += '0' + parseInt(nextArg(), 10).toString(8); - break; - case 's': // string - result += nextArg(); - break; - case 'x': // lowercase hexadecimal - result += '0x' + parseInt(nextArg(), 10).toString(16); - break; - case 'X': // uppercase hexadecimal - result += '0x' + parseInt(nextArg(), 10).toString(16).toUpperCase(); - break; - default: - result += c; - break; - } - } else if (c === '%') { - escaped = true; - } else { - result += c; - } - } - return result; - } +var map$3 = new type$1('tag:yaml.org,2002:map', { + kind: 'mapping', + construct: function (data) { return data !== null ? data : {}; } +}); -}()); -}(format$1)); +var failsafe = new schema$1({ + explicit: [ + str, + seq, + map$3 + ] +}); -var formatter = format$1.exports; +function resolveYamlNull(data) { + if (data === null) return true; -var fault$3 = create$2(Error); + var max = data.length; -var fault_1 = fault$3; + return (max === 1 && data === '~') || + (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); +} -fault$3.eval = create$2(EvalError); -fault$3.range = create$2(RangeError); -fault$3.reference = create$2(ReferenceError); -fault$3.syntax = create$2(SyntaxError); -fault$3.type = create$2(TypeError); -fault$3.uri = create$2(URIError); +function constructYamlNull() { + return null; +} -fault$3.create = create$2; +function isNull(object) { + return object === null; +} -// Create a new `EConstructor`, with the formatted `format` as a first argument. -function create$2(EConstructor) { - FormattedError.displayName = EConstructor.displayName || EConstructor.name; +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' +}); - return FormattedError +function resolveYamlBoolean(data) { + if (data === null) return false; - function FormattedError(format) { - if (format) { - format = formatter.apply(null, arguments); - } + var max = data.length; - return new EConstructor(format) - } + return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || + (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); } -var fs$f = require$$0__default$3['default']; -var path$g = require$$0__default$2['default']; -var fault$2 = fault_1; -var debug$d = src.exports('unified-engine:find-up'); -var wrap$1 = wrap_1; - -var findUp = FindUp$2; +function constructYamlBoolean(data) { + return data === 'true' || + data === 'True' || + data === 'TRUE'; +} -FindUp$2.prototype.load = load$4; +function isBoolean(object) { + return Object.prototype.toString.call(object) === '[object Boolean]'; +} -function FindUp$2(options) { - var self = this; +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' +}); - self.cache = {}; - self.cwd = options.cwd; - self.detect = options.detect; - self.names = options.names; - self.create = options.create; +function isHexCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || + ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || + ((0x61/* a */ <= c) && (c <= 0x66/* f */)); +} - if (options.filePath) { - self.givenFilePath = path$g.resolve(options.cwd, options.filePath); - } +function isOctCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); } -function load$4(filePath, callback) { - var self = this; - var givenFile = self.givenFile; - var parent; +function isDecCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); +} - if (self.givenFilePath) { - if (givenFile) { - apply(callback, givenFile); - } else { - givenFile = [callback]; - self.givenFile = givenFile; - debug$d('Checking given file `%s`', self.givenFilePath); - fs$f.readFile(self.givenFilePath, loadGiven); - } +function resolveYamlInteger(data) { + if (data === null) return false; - return - } + var max = data.length, + index = 0, + hasDigits = false, + ch; - if (!self.detect) { - return callback() - } + if (!max) return false; - filePath = path$g.resolve(self.cwd, filePath); - parent = path$g.dirname(filePath); + ch = data[index]; - if (parent in self.cache) { - apply(callback, self.cache[parent]); - } else { - self.cache[parent] = [callback]; - find(parent); + // sign + if (ch === '-' || ch === '+') { + ch = data[++index]; } - function loadGiven(error, buf) { - var cbs = self.givenFile; - var result; + if (ch === '0') { + // 0 + if (index + 1 === max) return true; + ch = data[++index]; - if (error) { - result = fault$2( - 'Cannot read given file `%s`\n%s', - path$g.relative(self.cwd, self.givenFilePath), - error.stack - ); - result.code = 'ENOENT'; - result.path = error.path; - result.syscall = error.syscall; - loaded(result); - } else { - wrap$1(self.create, onparse)(buf, self.givenFilePath); - } + // base 2, base 8, base 16 - function onparse(error, result) { - if (error) { - debug$d(error.message); - loaded( - fault$2( - 'Cannot parse given file `%s`\n%s', - path$g.relative(self.cwd, self.givenFilePath), - error.stack - ) - ); - } else { - debug$d('Read given file `%s`', self.givenFilePath); - loaded(result); - } - } + if (ch === 'b') { + // base 2 + index++; - function loaded(result) { - givenFile = result; - self.givenFile = result; - applyAll(cbs, result); + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch !== '0' && ch !== '1') return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; } - } - - function find(directory) { - var index = -1; - - next(); - function next() { - var parent; - // Try to read the next file. - // We do not use `readdir` because on huge directories, that could be - // *very* slow. - if (++index < self.names.length) { - fs$f.readFile(path$g.join(directory, self.names[index]), done); - } else { - parent = path$g.dirname(directory); + if (ch === 'x') { + // base 16 + index++; - if (directory === parent) { - debug$d('No files found for `%s`', filePath); - found(); - } else if (parent in self.cache) { - apply(found, self.cache[parent]); - } else { - self.cache[parent] = [found]; - find(parent); - } + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isHexCode(data.charCodeAt(index))) return false; + hasDigits = true; } + return hasDigits && ch !== '_'; } - function done(error, buf) { - var fp = path$g.join(directory, self.names[index]); - - /* istanbul ignore if - Hard to test. */ - if (error) { - if (error.code === 'ENOENT') { - return next() - } - - debug$d(error.message); - return found( - fault$2( - 'Cannot read file `%s`\n%s', - path$g.relative(self.cwd, fp), - error.message - ) - ) - } - wrap$1(self.create, onparse)(buf, fp); + if (ch === 'o') { + // base 8 + index++; - function onparse(error, result) { - if (error) { - found( - fault$2( - 'Cannot parse file `%s`\n%s', - path$g.relative(self.cwd, fp), - error.message - ) - ); - } else if (result) { - debug$d('Read file `%s`', fp); - found(null, result); - } else { - next(); - } + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isOctCode(data.charCodeAt(index))) return false; + hasDigits = true; } - } - - function found(error, result) { - var cbs = self.cache[directory]; - self.cache[directory] = error || result; - applyAll(cbs, error || result); + return hasDigits && ch !== '_'; } } - function applyAll(cbs, result) { - var index = cbs.length; + // base 10 (except 0) - while (index--) { - apply(cbs[index], result); - } - } + // value should not start with `_`; + if (ch === '_') return false; - function apply(cb, result) { - if ( - result !== null && - typeof result === 'object' && - typeof result[0] === 'function' - ) { - result.push(cb); - } else if (result instanceof Error) { - cb(result); - } else { - cb(null, result); + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isDecCode(data.charCodeAt(index))) { + return false; } + hasDigits = true; } -} - -var path$f = require$$0__default$2['default']; -var yaml = jsYaml$1; -var json$2 = parseJson_1; -var debug$c = src.exports('unified-engine:configuration'); -var loadPlugin = loadPlugin_1; -var plain$1 = isPlainObj; -var fault$1 = fault_1; -var FindUp$1 = findUp; -var configuration = Config; - -var own$f = {}.hasOwnProperty; - -var loaders = { - '.json': loadJson, - '.cjs': loadScriptOrModule, - '.mjs': loadScriptOrModule, - '.js': loadScriptOrModule, - '.yaml': loadYaml, - '.yml': loadYaml -}; + // Should have digits and should not end with `_` + if (!hasDigits || ch === '_') return false; -var defaultLoader = loadJson; + return true; +} -Config.prototype.load = load$3; +function constructYamlInteger(data) { + var value = data, sign = 1, ch; -function Config(options) { - var names = []; + if (value.indexOf('_') !== -1) { + value = value.replace(/_/g, ''); + } - this.cwd = options.cwd; - this.packageField = options.packageField; - this.pluginPrefix = options.pluginPrefix; - this.configTransform = options.configTransform; - this.defaultConfig = options.defaultConfig; + ch = value[0]; - if (options.rcName) { - names.push( - options.rcName, - options.rcName + '.js', - options.rcName + '.yml', - options.rcName + '.yaml' - ); - debug$c('Looking for `%s` configuration files', names); + if (ch === '-' || ch === '+') { + if (ch === '-') sign = -1; + value = value.slice(1); + ch = value[0]; } - if (options.packageField) { - names.push('package.json'); - debug$c( - 'Looking for `%s` fields in `package.json` files', - options.packageField - ); - } + if (value === '0') return 0; - this.given = {settings: options.settings, plugins: options.plugins}; - this.create = create$1.bind(this); + 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); + } - this.findUp = new FindUp$1({ - filePath: options.rcPath, - cwd: options.cwd, - detect: options.detectConfig, - names: names, - create: this.create - }); + return sign * parseInt(value, 10); } -function load$3(filePath, callback) { - var self = this; - - self.findUp.load(filePath || path$f.resolve(this.cwd, 'stdin.js'), done); - - function done(error, file) { - if (error || file) { - return callback(error, file) - } - - self.create().then(function (result) { - callback(null, result); - }, callback); - } +function isInteger(object) { + return (Object.prototype.toString.call(object)) === '[object Number]' && + (object % 1 === 0 && !common$4.isNegativeZero(object)); } -async function create$1(buf, filePath) { - var self = this; - var fn = (filePath && loaders[path$f.extname(filePath)]) || defaultLoader; - var options = {prefix: self.pluginPrefix, cwd: self.cwd}; - var result = {settings: {}, plugins: []}; - var contents; - - if (filePath) { - contents = await fn.apply(self, arguments); +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); }, + /* eslint-disable max-len */ + 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' ] } +}); - if (self.configTransform && contents !== undefined) { - contents = self.configTransform(contents, filePath); - } +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + + // .2e4, .2 + // special case, seems not from spec + '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + + // .inf + '|[-+]?\\.(?:inf|Inf|INF)' + + // .nan + '|\\.(?:nan|NaN|NAN))$'); - // Exit if we did find a `package.json`, but it does not have configuration. - if ( - buf && - contents === undefined && - path$f.basename(filePath) === 'package.json' - ) { - return - } +function resolveYamlFloat(data) { + if (data === null) return false; - if (contents === undefined) { - if (self.defaultConfig) { - await merge$1( - result, - self.defaultConfig, - Object.assign({}, options, {root: self.cwd}) - ); - } - } else { - await merge$1( - result, - contents, - Object.assign({}, options, {root: path$f.dirname(filePath)}) - ); + if (!YAML_FLOAT_PATTERN.test(data) || + // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === '_') { + return false; } - await merge$1(result, self.given, Object.assign({}, options, {root: self.cwd})); - - return result -} - -function loadScriptOrModule(_, filePath) { - return loadFromAbsolutePath(filePath, this.cwd) + return true; } -function loadYaml(buf, filePath) { - return yaml.safeLoad(buf, {filename: path$f.basename(filePath)}) -} +function constructYamlFloat(data) { + var value, sign; -function loadJson(buf, filePath) { - var result = json$2(buf, filePath); + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; - if (path$f.basename(filePath) === 'package.json') { - result = result[this.packageField]; + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); } - return result -} + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; -async function merge$1(target, raw, options) { - if (typeof raw === 'object' && raw !== null) { - await addPreset(raw); - } else { - throw new Error('Expected preset, not `' + raw + '`') + } else if (value === '.nan') { + return NaN; } + return sign * parseFloat(value, 10); +} - return target - - async function addPreset(result) { - var plugins = result.plugins; - - if (plugins === null || plugins === undefined) ; else if (typeof plugins === 'object' && plugins !== null) { - await ('length' in plugins ? addEach(plugins) : addIn(plugins)); - } else { - throw new Error( - 'Expected a list or object of plugins, not `' + plugins + '`' - ) - } - - target.settings = Object.assign({}, target.settings, result.settings); - } - async function addEach(result) { - var index = -1; - var value; +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; - while (++index < result.length) { - value = result[index]; +function representYamlFloat(object, style) { + var res; - // Keep order sequential instead of parallel. - // eslint-disable-next-line no-await-in-loop - await (value !== null && typeof value === 'object' && 'length' in value - ? use.apply(null, value) - : use(value)); + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; } - } - - async function addIn(result) { - var key; - - for (key in result) { - // Keep order sequential instead of parallel. - // eslint-disable-next-line no-await-in-loop - await use(key, result[key]); + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; } - } - - async function use(usable, value) { - if (typeof usable === 'string') { - await addModule(usable, value); - } else if (typeof usable === 'function') { - addPlugin(usable, value); - } else { - await merge$1(target, usable, options); + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; } + } else if (common$4.isNegativeZero(object)) { + return '-0.0'; } - async function addModule(id, value) { - var fp = loadPlugin.resolve(id, {cwd: options.root, prefix: options.prefix}); - var result; + res = object.toString(10); - if (fp) { - result = await loadFromAbsolutePath(fp, options.root); + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack - try { - if (typeof result === 'function') { - addPlugin(result, value); - } else { - await merge$1( - target, - result, - Object.assign({}, options, {root: path$f.dirname(fp)}) - ); - } - } catch (_) { - throw fault$1( - 'Error: Expected preset or plugin, not %s, at `%s`', - result, - path$f.relative(options.root, fp) - ) - } - } else { - fp = path$f.relative(options.cwd, path$f.resolve(options.root, id)); - addPlugin( - failingModule(fp, new Error('Could not find module `' + id + '`')), - value - ); - } - } + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; +} - function addPlugin(result, value) { - var entry = find$2(target.plugins, result); +function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common$4.isNegativeZero(object)); +} - if (entry) { - reconfigure(entry, value); - } else { - target.plugins.push([result, value]); - } - } -} +var float = new type$1('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' +}); -function reconfigure(entry, value) { - if (plain$1(entry[1]) && plain$1(value)) { - value = Object.assign({}, entry[1], value); - } +var json = failsafe.extend({ + implicit: [ + _null, + bool, + int, + float + ] +}); - entry[1] = value; -} +var core = json; -function find$2(entries, plugin) { - var index = -1; +var YAML_DATE_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9])' + // [2] month + '-([0-9][0-9])$'); // [3] day - while (++index < entries.length) { - if (entries[index][0] === plugin) { - return entries[index] - } - } +var YAML_TIMESTAMP_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9]?)' + // [2] month + '-([0-9][0-9]?)' + // [3] day + '(?:[Tt]|[ \\t]+)' + // ... + '([0-9][0-9]?)' + // [4] hour + ':([0-9][0-9])' + // [5] minute + ':([0-9][0-9])' + // [6] second + '(?:\\.([0-9]*))?' + // [7] fraction + '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour + '(?::([0-9][0-9]))?))?$'); // [11] tz_minute + +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 failingModule(id, error) { - var cache = failingModule.cache || (failingModule.cache = {}); - var submodule = own$f.call(cache, id) ? cache[id] : (cache[id] = fail); - return submodule - function fail() { - throw error +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'); + + // match: [1] year [2] month [3] day + + year = +(match[1]); + month = +(match[2]) - 1; // JS month starts with 0 + day = +(match[3]); + + if (!match[4]) { // no hour + return new Date(Date.UTC(year, month, day)); } -} -async function loadFromAbsolutePath(fp, base) { - var ext = path$f.extname(fp); - var result; + // match: [4] hour [5] minute [6] second [7] fraction - /* istanbul ignore next - To do next major: Tests don’t run on Node 10 */ - if (ext !== '.mjs') { - try { - result = commonjsRequire(fp); - } catch (error) { - if (ext !== '.cjs' && error.code === 'ERR_REQUIRE_ESM') { - ext = '.mjs'; - } else { - throw fault$1( - 'Cannot parse script `%s`\n%s', - path$f.relative(base, fp), - error.stack - ) - } - } + hour = +(match[4]); + minute = +(match[5]); + second = +(match[6]); - if (result && typeof result === 'object' && result.__esModule) { - result = result.default; + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { // milli-seconds + fraction += '0'; } + fraction = +fraction; } - /* istanbul ignore next - To do next major: Tests don’t run on Node 10 */ - if (ext === '.mjs') { - result = (await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(fp)); })).default; - } + // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute - return result -} + if (match[9]) { + tz_hour = +(match[10]); + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds + if (match[9] === '-') delta = -delta; + } -var Configuration = configuration; + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); -var configure_1$2 = configure$6; + if (delta) date.setTime(date.getTime() - delta); -function configure$6(context, settings) { - context.configuration = new Configuration(settings); + return date; } -// A simple implementation of make-array -function makeArray (subject) { - return Array.isArray(subject) - ? subject - : [subject] +function representYamlTimestamp(object /*, style*/) { + return object.toISOString(); } -const EMPTY = ''; -const SPACE = ' '; -const ESCAPE = '\\'; -const REGEX_TEST_BLANK_LINE = /^\s+$/; -const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; -const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; -const REGEX_SPLITALL_CRLF = /\r?\n/g; -// /foo, -// ./foo, -// ../foo, -// . -// .. -const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; - -const SLASH$1 = '/'; -const KEY_IGNORE = typeof Symbol !== 'undefined' - ? Symbol.for('node-ignore') - /* istanbul ignore next */ - : 'node-ignore'; +var timestamp = new type$1('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); -const define = (object, key, value) => - Object.defineProperty(object, key, {value}); +function resolveYamlMerge(data) { + return data === '<<' || data === null; +} -const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; +var merge$1 = new type$1('tag:yaml.org,2002:merge', { + kind: 'scalar', + resolve: resolveYamlMerge +}); -// Sanitize the range of a regular expression -// The cases are complicated, see test cases for details -const sanitizeRange = range => range.replace( - REGEX_REGEXP_RANGE, - (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) - ? match - // Invalid range (out of order) which is ok for gitignore rules but - // fatal for JavaScript regular expression, so eliminate it. - : EMPTY -); +/*eslint-disable no-bitwise*/ -// See fixtures #59 -const cleanRangeBackSlash = slashes => { - const {length} = slashes; - return slashes.slice(0, length - length % 2) -}; -// > If the pattern ends with a slash, -// > it is removed for the purpose of the following description, -// > but it would only find a match with a directory. -// > In other words, foo/ will match a directory foo and paths underneath it, -// > but will not match a regular file or a symbolic link foo -// > (this is consistent with the way how pathspec works in general in Git). -// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' -// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call -// you could use option `mark: true` with `glob` -// '`foo/`' should not continue with the '`..`' -const REPLACERS = [ - // > Trailing spaces are ignored unless they are quoted with backslash ("\") - [ - // (a\ ) -> (a ) - // (a ) -> (a) - // (a \ ) -> (a ) - /\\?\s+$/, - match => match.indexOf('\\') === 0 - ? SPACE - : EMPTY - ], - // replace (\ ) with ' ' - [ - /\\\s/g, - () => SPACE - ], +// [ 64, 65, 66 ] -> [ padding, CR, LF ] +var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; - // Escape metacharacters - // which is written down by users but means special for regular expressions. - // > There are 12 characters with special meanings: - // > - the backslash \, - // > - the caret ^, - // > - the dollar sign $, - // > - the period or dot ., - // > - the vertical bar or pipe symbol |, - // > - the question mark ?, - // > - the asterisk or star *, - // > - the plus sign +, - // > - the opening parenthesis (, - // > - the closing parenthesis ), - // > - and the opening square bracket [, - // > - the opening curly brace {, - // > These special characters are often called "metacharacters". - [ - /[\\$.|*+(){^]/g, - match => `\\${match}` - ], +function resolveYamlBinary(data) { + if (data === null) return false; - [ - // > a question mark (?) matches a single character - /(?!\\)\?/g, - () => '[^/]' - ], + var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; - // leading slash - [ + // Convert one by one. + for (idx = 0; idx < max; idx++) { + code = map.indexOf(data.charAt(idx)); - // > A leading slash matches the beginning of the pathname. - // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". - // A leading slash matches the beginning of the pathname - /^\//, - () => '^' - ], + // Skip CR/LF + if (code > 64) continue; - // replace special metacharacter slash after the leading slash - [ - /\//g, - () => '\\/' - ], + // Fail on illegal characters + if (code < 0) return false; - [ - // > A leading "**" followed by a slash means match in all directories. - // > For example, "**/foo" matches file or directory "foo" anywhere, - // > the same as pattern "foo". - // > "**/foo/bar" matches file or directory "bar" anywhere that is directly - // > under directory "foo". - // Notice that the '*'s have been replaced as '\\*' - /^\^*\\\*\\\*\\\//, + bitlen += 6; + } - // '**/foo' <-> 'foo' - () => '^(?:.*\\/)?' - ], + // If there are any bits left, source was corrupted + return (bitlen % 8) === 0; +} - // starting - [ - // there will be no leading '/' - // (which has been replaced by section "leading slash") - // If starts with '**', adding a '^' to the regular expression also works - /^(?=[^^])/, - function startingReplacer () { - // If has a slash `/` at the beginning or middle - return !/\/(?!$)/.test(this) - // > Prior to 2.22.1 - // > If the pattern does not contain a slash /, - // > Git treats it as a shell glob pattern - // Actually, if there is only a trailing slash, - // git also treats it as a shell glob pattern +function constructYamlBinary(data) { + var idx, tailbits, + input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan + max = input.length, + map = BASE64_MAP, + bits = 0, + result = []; - // After 2.22.1 (compatible but clearer) - // > If there is a separator at the beginning or middle (or both) - // > of the pattern, then the pattern is relative to the directory - // > level of the particular .gitignore file itself. - // > Otherwise the pattern may also match at any level below - // > the .gitignore level. - ? '(?:^|\\/)' + // Collect by 6*4 bits (3 bytes) - // > Otherwise, Git treats the pattern as a shell glob suitable for - // > consumption by fnmatch(3) - : '^' + for (idx = 0; idx < max; idx++) { + if ((idx % 4 === 0) && idx) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); } - ], - // two globstars - [ - // Use lookahead assertions so that we could match more than one `'/**'` - /\\\/\\\*\\\*(?=\\\/|$)/g, + bits = (bits << 6) | map.indexOf(input.charAt(idx)); + } - // Zero, one or several directories - // should not use '*', or it will be replaced by the next replacer + // Dump tail - // Check if it is not the last `'/**'` - (_, index, str) => index + 6 < str.length + tailbits = (max % 4) * 6; - // case: /**/ - // > A slash followed by two consecutive asterisks then a slash matches - // > zero or more directories. - // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. - // '/**/' - ? '(?:\\/[^\\/]+)*' + if (tailbits === 0) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } else if (tailbits === 18) { + result.push((bits >> 10) & 0xFF); + result.push((bits >> 2) & 0xFF); + } else if (tailbits === 12) { + result.push((bits >> 4) & 0xFF); + } - // case: /** - // > A trailing `"/**"` matches everything inside. + return new Uint8Array(result); +} - // #21: everything inside but it should not include the current folder - : '\\/.+' - ], +function representYamlBinary(object /*, style*/) { + var result = '', bits = 0, idx, tail, + max = object.length, + map = BASE64_MAP; - // intermediate wildcards - [ - // Never replace escaped '*' - // ignore rule '\*' will match the path '*' + // Convert every three bytes to 4 ASCII characters. - // 'abc.*/' -> go - // 'abc.*' -> skip this rule - /(^|[^\\]+)\\\*(?=.+)/g, + for (idx = 0; idx < max; idx++) { + if ((idx % 3 === 0) && idx) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } - // '*.js' matches '.js' - // '*.js' doesn't match 'abc' - (_, p1) => `${p1}[^\\/]*` - ], + bits = (bits << 8) + object[idx]; + } - [ - // unescape, revert step 3 except for back slash - // For example, if a user escape a '\\*', - // after step 3, the result will be '\\\\\\*' - /\\\\\\(?=[$.|*+(){^])/g, - () => ESCAPE - ], + // Dump tail - [ - // '\\\\' -> '\\' - /\\\\/g, - () => ESCAPE - ], + tail = max % 3; - [ - // > The range notation, e.g. [a-zA-Z], - // > can be used to match one of the characters in a range. + if (tail === 0) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } else if (tail === 2) { + result += map[(bits >> 10) & 0x3F]; + result += map[(bits >> 4) & 0x3F]; + result += map[(bits << 2) & 0x3F]; + result += map[64]; + } else if (tail === 1) { + result += map[(bits >> 2) & 0x3F]; + result += map[(bits << 4) & 0x3F]; + result += map[64]; + result += map[64]; + } - // `\` is escaped by step 3 - /(\\)?\[([^\]/]*?)(\\*)($|\])/g, - (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE - // '\\[bar]' -> '\\\\[bar\\]' - ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` - : close === ']' - ? endEscape.length % 2 === 0 - // A normal case, and it is a range notation - // '[bar]' - // '[bar\\\\]' - ? `[${sanitizeRange(range)}${endEscape}]` - // Invalid range notaton - // '[bar\\]' -> '[bar\\\\]' - : '[]' - : '[]' - ], + return result; +} - // ending - [ - // 'js' will not match 'js.' - // 'ab' will not match 'abc' - /(?:[^*])$/, +function isBinary(obj) { + return Object.prototype.toString.call(obj) === '[object Uint8Array]'; +} - // WTF! - // https://git-scm.com/docs/gitignore - // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) - // which re-fixes #24, #38 +var binary = new type$1('tag:yaml.org,2002:binary', { + kind: 'scalar', + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); - // > If there is a separator at the end of the pattern then the pattern - // > will only match directories, otherwise the pattern can match both - // > files and directories. +var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; +var _toString$2 = Object.prototype.toString; - // 'js*' will not match 'a.js' - // 'js/' will not match 'a.js' - // 'js' will match 'a.js' and 'a.js/' - match => /\/$/.test(match) - // foo/ will not match 'foo' - ? `${match}$` - // foo matches 'foo' and 'foo/' - : `${match}(?=$|\\/$)` - ], +function resolveYamlOmap(data) { + if (data === null) return true; - // trailing wildcard - [ - /(\^|\\\/)?\\\*$/, - (_, p1) => { - const prefix = p1 - // '\^': - // '/*' does not match EMPTY - // '/*' does not match everything + var objectKeys = [], index, length, pair, pairKey, pairHasKey, + object = data; - // '\\\/': - // 'abc/*' does not match 'abc/' - ? `${p1}[^/]+` + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; - // 'a*' matches 'a' - // 'a*' matches 'aa' - : '[^/]*'; + if (_toString$2.call(pair) !== '[object Object]') return false; - return `${prefix}(?=$|\\/$)` + for (pairKey in pair) { + if (_hasOwnProperty$3.call(pair, pairKey)) { + if (!pairHasKey) pairHasKey = true; + else return false; + } } - ], -]; -// A simple cache, because an ignore rule only has only one certain meaning -const regexCache = Object.create(null); + if (!pairHasKey) return false; -// @param {pattern} -const makeRegex = (pattern, negative, ignorecase) => { - const r = regexCache[pattern]; - if (r) { - return r + if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); + else return false; } - // const replacers = negative - // ? NEGATIVE_REPLACERS - // : POSITIVE_REPLACERS + return true; +} - const source = REPLACERS.reduce( - (prev, current) => prev.replace(current[0], current[1].bind(pattern)), - pattern - ); +function constructYamlOmap(data) { + return data !== null ? data : []; +} - return regexCache[pattern] = ignorecase - ? new RegExp(source, 'i') - : new RegExp(source) -}; +var omap = new type$1('tag:yaml.org,2002:omap', { + kind: 'sequence', + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); -const isString = subject => typeof subject === 'string'; +var _toString$1 = Object.prototype.toString; -// > A blank line matches no files, so it can serve as a separator for readability. -const checkPattern = pattern => pattern - && isString(pattern) - && !REGEX_TEST_BLANK_LINE.test(pattern) +function resolveYamlPairs(data) { + if (data === null) return true; - // > A line starting with # serves as a comment. - && pattern.indexOf('#') !== 0; + var index, length, pair, keys, result, + object = data; -const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF); + result = new Array(object.length); -class IgnoreRule { - constructor ( - origin, - pattern, - negative, - regex - ) { - this.origin = origin; - this.pattern = pattern; - this.negative = negative; - this.regex = regex; - } -} + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; -const createRule = (pattern, ignorecase) => { - const origin = pattern; - let negative = false; + if (_toString$1.call(pair) !== '[object Object]') return false; - // > An optional prefix "!" which negates the pattern; - if (pattern.indexOf('!') === 0) { - negative = true; - pattern = pattern.substr(1); + keys = Object.keys(pair); + + if (keys.length !== 1) return false; + + result[index] = [ keys[0], pair[keys[0]] ]; } - pattern = pattern - // > Put a backslash ("\") in front of the first "!" for patterns that - // > begin with a literal "!", for example, `"\!important!.txt"`. - .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') - // > Put a backslash ("\") in front of the first hash for patterns that - // > begin with a hash. - .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#'); + return true; +} - const regex = makeRegex(pattern, negative, ignorecase); +function constructYamlPairs(data) { + if (data === null) return []; - return new IgnoreRule( - origin, - pattern, - negative, - regex - ) -}; + var index, length, pair, keys, result, + object = data; -const throwError$1 = (message, Ctor) => { - throw new Ctor(message) -}; + result = new Array(object.length); -const checkPath = (path, originalPath, doThrow) => { - if (!isString(path)) { - return doThrow( - `path must be a string, but got \`${originalPath}\``, - TypeError - ) - } + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; - // We don't know if we should ignore EMPTY, so throw - if (!path) { - return doThrow(`path must not be empty`, TypeError) - } + keys = Object.keys(pair); - // Check if it is a relative path - if (checkPath.isNotRelative(path)) { - const r = '`path.relative()`d'; - return doThrow( - `path should be a ${r} string, but got "${originalPath}"`, - RangeError - ) + result[index] = [ keys[0], pair[keys[0]] ]; } - return true -}; - -const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path); + return result; +} -checkPath.isNotRelative = isNotRelative; -checkPath.convert = p => p; +var pairs = new type$1('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); -class Ignore$2 { - constructor ({ - ignorecase = true - } = {}) { - this._rules = []; - this._ignorecase = ignorecase; - define(this, KEY_IGNORE, true); - this._initCache(); - } +var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; - _initCache () { - this._ignoreCache = Object.create(null); - this._testCache = Object.create(null); - } +function resolveYamlSet(data) { + if (data === null) return true; - _addPattern (pattern) { - // #32 - if (pattern && pattern[KEY_IGNORE]) { - this._rules = this._rules.concat(pattern._rules); - this._added = true; - return - } + var key, object = data; - if (checkPattern(pattern)) { - const rule = createRule(pattern, this._ignorecase); - this._added = true; - this._rules.push(rule); + for (key in object) { + if (_hasOwnProperty$2.call(object, key)) { + if (object[key] !== null) return false; } } - // @param {Array | string | Ignore} pattern - add (pattern) { - this._added = false; + return true; +} - makeArray( - isString(pattern) - ? splitPattern(pattern) - : pattern - ).forEach(this._addPattern, this); +function constructYamlSet(data) { + return data !== null ? data : {}; +} - // Some rules have just added to the ignore, - // making the behavior changed. - if (this._added) { - this._initCache(); - } +var set = new type$1('tag:yaml.org,2002:set', { + kind: 'mapping', + resolve: resolveYamlSet, + construct: constructYamlSet +}); - return this - } +var _default$1 = core.extend({ + implicit: [ + timestamp, + merge$1 + ], + explicit: [ + binary, + omap, + pairs, + set + ] +}); - // legacy - addPattern (pattern) { - return this.add(pattern) - } +/*eslint-disable max-len,no-use-before-define*/ - // | ignored : unignored - // negative | 0:0 | 0:1 | 1:0 | 1:1 - // -------- | ------- | ------- | ------- | -------- - // 0 | TEST | TEST | SKIP | X - // 1 | TESTIF | SKIP | TEST | X - // - SKIP: always skip - // - TEST: always test - // - TESTIF: only test if checkUnignored - // - X: that never happen - // @param {boolean} whether should check if the path is unignored, - // setting `checkUnignored` to `false` could reduce additional - // path matching. - // @returns {TestResult} true if a file is ignored - _testOne (path, checkUnignored) { - let ignored = false; - let unignored = false; - this._rules.forEach(rule => { - const {negative} = rule; - if ( - unignored === negative && ignored !== unignored - || negative && !ignored && !unignored && !checkUnignored - ) { - return - } - const matched = rule.regex.test(path); - if (matched) { - ignored = !negative; - unignored = negative; - } - }); +var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; - return { - ignored, - unignored - } - } - // @returns {TestResult} - _test (originalPath, cache, checkUnignored, slices) { - const path = originalPath - // Supports nullable path - && checkPath.convert(originalPath); +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; - checkPath(path, originalPath, throwError$1); - return this._t(path, cache, checkUnignored, slices) - } +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; - _t (path, cache, checkUnignored, slices) { - if (path in cache) { - return cache[path] - } - if (!slices) { - // path/to/a.js - // ['path', 'to', 'a.js'] - slices = path.split(SLASH$1); - } +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; - slices.pop(); - // If the path has no parent directory, just test it - if (!slices.length) { - return cache[path] = this._testOne(path, checkUnignored) - } +function _class(obj) { return Object.prototype.toString.call(obj); } - const parent = this._t( - slices.join(SLASH$1) + SLASH$1, - cache, - checkUnignored, - slices - ); +function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); +} - // If the path contains a parent directory, check the parent first - return cache[path] = parent.ignored - // > It is not possible to re-include a file if a parent directory of - // > that file is excluded. - ? parent - : this._testOne(path, checkUnignored) - } +function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); +} - ignores (path) { - return this._test(path, this._ignoreCache, false).ignored - } +function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); +} - createFilter () { - return path => !this.ignores(path) - } +function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; +} - filter (paths) { - return makeArray(paths).filter(this.createFilter()) +function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; } - // @returns {TestResult} - test (path) { - return this._test(path, this._testCache, true) + /*eslint-disable no-bitwise*/ + lc = c | 0x20; + + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; } + + return -1; +} + +function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; } -const factory$5 = options => new Ignore$2(options); +function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } -const returnFalse = () => false; + return -1; +} -const isPathValid = path => - checkPath(path && checkPath.convert(path), path, returnFalse); +function simpleEscapeSequence(c) { + /* eslint-disable indent */ + return (c === 0x30/* 0 */) ? '\x00' : + (c === 0x61/* a */) ? '\x07' : + (c === 0x62/* b */) ? '\x08' : + (c === 0x74/* t */) ? '\x09' : + (c === 0x09/* Tab */) ? '\x09' : + (c === 0x6E/* n */) ? '\x0A' : + (c === 0x76/* v */) ? '\x0B' : + (c === 0x66/* f */) ? '\x0C' : + (c === 0x72/* r */) ? '\x0D' : + (c === 0x65/* e */) ? '\x1B' : + (c === 0x20/* Space */) ? ' ' : + (c === 0x22/* " */) ? '\x22' : + (c === 0x2F/* / */) ? '/' : + (c === 0x5C/* \ */) ? '\x5C' : + (c === 0x4E/* N */) ? '\x85' : + (c === 0x5F/* _ */) ? '\xA0' : + (c === 0x4C/* L */) ? '\u2028' : + (c === 0x50/* P */) ? '\u2029' : ''; +} -factory$5.isPathValid = isPathValid; +function charFromCodepoint(c) { + if (c <= 0xFFFF) { + return String.fromCharCode(c); + } + // Encode UTF-16 surrogate pair + // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF + return String.fromCharCode( + ((c - 0x010000) >> 10) + 0xD800, + ((c - 0x010000) & 0x03FF) + 0xDC00 + ); +} -// Fixes typescript -factory$5.default = factory$5; +var simpleEscapeCheck = new Array(256); // integer, for fast access +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); +} -var ignore$2 = factory$5; -// Windows -// -------------------------------------------------------------- -/* istanbul ignore if */ -if ( - // Detect `process` so that it can run in browsers. - typeof process !== 'undefined' - && ( - process.env && process.env.IGNORE_TEST_WIN32 - || process.platform === 'win32' - ) -) { - /* eslint no-control-regex: "off" */ - const makePosix = str => /^\\\\\?\\/.test(str) - || /["<>|\u0000-\u001F]+/u.test(str) - ? str - : str.replace(/\\/g, '/'); +function State$1(input, options) { + this.input = input; - checkPath.convert = makePosix; + this.filename = options['filename'] || null; + this.schema = options['schema'] || _default$1; + this.onWarning = options['onWarning'] || null; + // (Hidden) Remove? makes the loader to expect YAML 1.1 documents + // if such documents have no explicit %YAML directive + this.legacy = options['legacy'] || false; - // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/' - // 'd:\\foo' - const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; - checkPath.isNotRelative = path => - REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) - || isNotRelative(path); -} + this.json = options['json'] || false; + this.listener = options['listener'] || null; + + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; -var path$e = require$$0__default$2['default']; -var gitignore$1 = ignore$2; -var FindUp = findUp; + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; -var ignore$1 = Ignore$1; + // position of first leading tab in the current line, + // used to make sure there are no tabs in the indentation + this.firstTabInLine = -1; -Ignore$1.prototype.check = check$5; + this.documents = []; -function Ignore$1(options) { - this.cwd = options.cwd; - this.ignorePathResolveFrom = options.ignorePathResolveFrom; + /* + this.version; + this.checkLineBreaks; + this.tagMap; + this.anchorMap; + this.tag; + this.anchor; + this.kind; + this.result;*/ - this.findUp = new FindUp({ - filePath: options.ignorePath, - cwd: options.cwd, - detect: options.detectIgnore, - names: options.ignoreName ? [options.ignoreName] : [], - create: create - }); } -function check$5(filePath, callback) { - var self = this; - self.findUp.load(filePath, done); +function generateError(state, message) { + var mark = { + name: state.filename, + buffer: state.input.slice(0, -1), // omit trailing \0 + position: state.position, + line: state.line, + column: state.position - state.lineStart + }; - function done(error, ignore) { - var normal; + mark.snippet = snippet(mark); - if (error) { - callback(error); - } else if (ignore) { - normal = path$e.relative( - path$e.resolve( - self.cwd, - self.ignorePathResolveFrom === 'cwd' ? '.' : ignore.filePath - ), - path$e.resolve(self.cwd, filePath) - ); + return new exception(message, mark); +} - if ( - normal === '' || - normal === '..' || - normal.charAt(0) === path$e.sep || - normal.slice(0, 3) === '..' + path$e.sep - ) { - callback(null, false); - } else { - callback(null, ignore.ignores(normal)); - } - } else { - callback(null, false); - } - } +function throwError$1(state, message) { + throw generateError(state, message); } -function create(buf, filePath) { - var ignore = gitignore$1().add(String(buf)); - ignore.filePath = path$e.dirname(filePath); - return ignore +function throwWarning(state, message) { + if (state.onWarning) { + state.onWarning.call(null, generateError(state, message)); + } } -var old$1 = {}; -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. +var directiveHandlers = { -var pathModule = require$$0__default$2['default']; -var isWindows$2 = process.platform === 'win32'; -var fs$e = require$$0__default$3['default']; + YAML: function handleYamlDirective(state, name, args) { -// JavaScript implementation of realpath, ported from node pre-v6 + var match, major, minor; -var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); + if (state.version !== null) { + throwError$1(state, 'duplication of %YAML directive'); + } -function rethrow() { - // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and - // is fairly slow to generate. - var callback; - if (DEBUG) { - var backtrace = new Error; - callback = debugCallback; - } else - callback = missingCallback; + if (args.length !== 1) { + throwError$1(state, 'YAML directive accepts exactly one argument'); + } - return callback; + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); - function debugCallback(err) { - if (err) { - backtrace.message = err.message; - err = backtrace; - missingCallback(err); + if (match === null) { + throwError$1(state, 'ill-formed argument of the YAML directive'); } - } - function missingCallback(err) { - if (err) { - if (process.throwDeprecation) - throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs - else if (!process.noDeprecation) { - var msg = 'fs: missing callback ' + (err.stack || err.message); - if (process.traceDeprecation) - console.trace(msg); - else - console.error(msg); - } + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + + if (major !== 1) { + throwError$1(state, 'unacceptable YAML version of the document'); } - } -} -function maybeCallback(cb) { - return typeof cb === 'function' ? cb : rethrow(); -} + state.version = args[0]; + state.checkLineBreaks = (minor < 2); -pathModule.normalize; + if (minor !== 1 && minor !== 2) { + throwWarning(state, 'unsupported YAML version of the document'); + } + }, -// Regexp that finds the next partion of a (partial) path -// result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] -if (isWindows$2) { - var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; -} else { - var nextPartRe = /(.*?)(?:[\/]+|$)/g; -} + TAG: function handleTagDirective(state, name, args) { -// Regex to find the device root, including trailing slash. E.g. 'c:\\'. -if (isWindows$2) { - var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; -} else { - var splitRootRe = /^[\/]*/; -} + var handle, prefix; -old$1.realpathSync = function realpathSync(p, cache) { - // make p is absolute - p = pathModule.resolve(p); + if (args.length !== 2) { + throwError$1(state, 'TAG directive accepts exactly two arguments'); + } - if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { - return cache[p]; - } + handle = args[0]; + prefix = args[1]; - var original = p, - seenLinks = {}, - knownHard = {}; - - // current character position in p - var pos; - // the partial path so far, including a trailing slash if any - var current; - // the partial path without a trailing slash (except when pointing at a root) - var base; - // the partial path scanned in the previous round, with slash - var previous; + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError$1(state, 'ill-formed tag handle (first argument) of the TAG directive'); + } - start(); + if (_hasOwnProperty$1.call(state.tagMap, handle)) { + throwError$1(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } - function start() { - // Skip over roots - var m = splitRootRe.exec(p); - pos = m[0].length; - current = m[0]; - base = m[0]; - previous = ''; + if (!PATTERN_TAG_URI.test(prefix)) { + throwError$1(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + } - // On windows, check that the root exists. On unix there is no need. - if (isWindows$2 && !knownHard[base]) { - fs$e.lstatSync(base); - knownHard[base] = true; + try { + prefix = decodeURIComponent(prefix); + } catch (err) { + throwError$1(state, 'tag prefix is malformed: ' + prefix); } + + state.tagMap[handle] = prefix; } +}; - // walk down the path, swapping out linked pathparts for their real - // values - // NB: p.length changes. - while (pos < p.length) { - // find the next part - nextPartRe.lastIndex = pos; - var result = nextPartRe.exec(p); - previous = current; - current += result[0]; - base = previous + result[1]; - pos = nextPartRe.lastIndex; - // continue if not a symlink - if (knownHard[base] || (cache && cache[base] === base)) { - continue; - } +function captureSegment(state, start, end, checkJson) { + var _position, _length, _character, _result; - var resolvedLink; - if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { - // some known symbolic link. no need to stat again. - resolvedLink = cache[base]; - } else { - var stat = fs$e.lstatSync(base); - if (!stat.isSymbolicLink()) { - knownHard[base] = true; - if (cache) cache[base] = base; - continue; - } + if (start < end) { + _result = state.input.slice(start, end); - // read the link if it wasn't read before - // dev/ino always return 0 on windows, so skip the check. - var linkTarget = null; - if (!isWindows$2) { - var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); - if (seenLinks.hasOwnProperty(id)) { - linkTarget = seenLinks[id]; + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 0x09 || + (0x20 <= _character && _character <= 0x10FFFF))) { + throwError$1(state, 'expected valid JSON character'); } } - if (linkTarget === null) { - fs$e.statSync(base); - linkTarget = fs$e.readlinkSync(base); - } - resolvedLink = pathModule.resolve(previous, linkTarget); - // track this, if given a cache. - if (cache) cache[base] = resolvedLink; - if (!isWindows$2) seenLinks[id] = linkTarget; + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError$1(state, 'the stream contains non-printable characters'); } - // resolve the link, then start over - p = pathModule.resolve(resolvedLink, p.slice(pos)); - start(); + state.result += _result; } +} - if (cache) cache[original] = p; +function mergeMappings(state, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; - return p; -}; + if (!common$4.isObject(source)) { + throwError$1(state, 'cannot merge mappings; the provided source object is unacceptable'); + } + sourceKeys = Object.keys(source); -old$1.realpath = function realpath(p, cache, cb) { - if (typeof cb !== 'function') { - cb = maybeCallback(cache); - cache = null; + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + + if (!_hasOwnProperty$1.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } } +} - // make p is absolute - p = pathModule.resolve(p); +function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, + startLine, startLineStart, startPos) { - if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { - return process.nextTick(cb.bind(null, null, cache[p])); + var index, quantity; + + // The output is a plain object here, so keys can only be strings. + // We need to convert keyNode to a string, but doing so can hang the process + // (deeply nested arrays that explode exponentially using aliases). + 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$1(state, 'nested arrays are not supported inside keys'); + } + + if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { + keyNode[index] = '[object Object]'; + } + } } - var original = p, - seenLinks = {}, - knownHard = {}; + // Avoid code execution in load() via toString property + // (still use its own toString for arrays, timestamps, + // and whatever user schema extensions happen to have @@toStringTag) + if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { + keyNode = '[object Object]'; + } - // current character position in p - var pos; - // the partial path so far, including a trailing slash if any - var current; - // the partial path without a trailing slash (except when pointing at a root) - var base; - // the partial path scanned in the previous round, with slash - var previous; - start(); + keyNode = String(keyNode); - function start() { - // Skip over roots - var m = splitRootRe.exec(p); - pos = m[0].length; - current = m[0]; - base = m[0]; - previous = ''; + if (_result === null) { + _result = {}; + } - // On windows, check that the root exists. On unix there is no need. - if (isWindows$2 && !knownHard[base]) { - fs$e.lstat(base, function(err) { - if (err) return cb(err); - knownHard[base] = true; - LOOP(); + 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$1(state, 'duplicated mapping key'); + } + + // used for this specific key only because Object.defineProperty is slow + if (keyNode === '__proto__') { + Object.defineProperty(_result, keyNode, { + configurable: true, + enumerable: true, + writable: true, + value: valueNode }); } else { - process.nextTick(LOOP); + _result[keyNode] = valueNode; } + delete overridableKeys[keyNode]; } - // walk down the path, swapping out linked pathparts for their real - // values - function LOOP() { - // stop if scanned past end of path - if (pos >= p.length) { - if (cache) cache[original] = p; - return cb(null, p); - } + return _result; +} - // find the next part - nextPartRe.lastIndex = pos; - var result = nextPartRe.exec(p); - previous = current; - current += result[0]; - base = previous + result[1]; - pos = nextPartRe.lastIndex; +function readLineBreak(state) { + var ch; - // continue if not a symlink - if (knownHard[base] || (cache && cache[base] === base)) { - return process.nextTick(LOOP); - } + ch = state.input.charCodeAt(state.position); - if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { - // known symbolic link. no need to stat again. - return gotResolvedLink(cache[base]); + if (ch === 0x0A/* LF */) { + state.position++; + } else if (ch === 0x0D/* CR */) { + state.position++; + if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { + state.position++; } - - return fs$e.lstat(base, gotStat); + } else { + throwError$1(state, 'a line break is expected'); } - function gotStat(err, stat) { - if (err) return cb(err); + state.line += 1; + state.lineStart = state.position; + state.firstTabInLine = -1; +} - // if not a symlink, skip to the next path part - if (!stat.isSymbolicLink()) { - knownHard[base] = true; - if (cache) cache[base] = base; - return process.nextTick(LOOP); - } +function skipSeparationSpace(state, allowComments, checkIndent) { + var lineBreaks = 0, + ch = state.input.charCodeAt(state.position); - // stat & read the link if not read before - // call gotTarget as soon as the link target is known - // dev/ino always return 0 on windows, so skip the check. - if (!isWindows$2) { - var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); - if (seenLinks.hasOwnProperty(id)) { - return gotTarget(null, seenLinks[id], base); + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { + state.firstTabInLine = state.position; } + ch = state.input.charCodeAt(++state.position); } - fs$e.stat(base, function(err) { - if (err) return cb(err); - fs$e.readlink(base, function(err, target) { - if (!isWindows$2) seenLinks[id] = target; - gotTarget(err, target); - }); - }); - } + if (allowComments && ch === 0x23/* # */) { + do { + ch = state.input.charCodeAt(++state.position); + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } - function gotTarget(err, target, base) { - if (err) return cb(err); + if (is_EOL(ch)) { + readLineBreak(state); - var resolvedLink = pathModule.resolve(previous, target); - if (cache) cache[base] = resolvedLink; - gotResolvedLink(resolvedLink); - } + ch = state.input.charCodeAt(state.position); + lineBreaks++; + state.lineIndent = 0; - function gotResolvedLink(resolvedLink) { - // resolve the link, then start over - p = pathModule.resolve(resolvedLink, p.slice(pos)); - start(); + while (ch === 0x20/* Space */) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + } else { + break; + } } -}; -var fs_realpath = realpath$2; -realpath$2.realpath = realpath$2; -realpath$2.sync = realpathSync; -realpath$2.realpathSync = realpathSync; -realpath$2.monkeypatch = monkeypatch; -realpath$2.unmonkeypatch = unmonkeypatch; + if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { + throwWarning(state, 'deficient indentation'); + } -var fs$d = require$$0__default$3['default']; -var origRealpath = fs$d.realpath; -var origRealpathSync = fs$d.realpathSync; + return lineBreaks; +} -var version$2 = process.version; -var ok$2 = /^v[0-5]\./.test(version$2); -var old = old$1; +function testDocumentSeparator(state) { + var _position = state.position, + ch; -function newError (er) { - return er && er.syscall === 'realpath' && ( - er.code === 'ELOOP' || - er.code === 'ENOMEM' || - er.code === 'ENAMETOOLONG' - ) -} + ch = state.input.charCodeAt(_position); -function realpath$2 (p, cache, cb) { - if (ok$2) { - return origRealpath(p, cache, cb) - } + // Condition state.position === state.lineStart is tested + // in parent on each call, for efficiency. No needs to test here again. + if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && + ch === state.input.charCodeAt(_position + 1) && + ch === state.input.charCodeAt(_position + 2)) { - if (typeof cache === 'function') { - cb = cache; - cache = null; - } - origRealpath(p, cache, function (er, result) { - if (newError(er)) { - old.realpath(p, cache, cb); - } else { - cb(er, result); - } - }); -} + _position += 3; -function realpathSync (p, cache) { - if (ok$2) { - return origRealpathSync(p, cache) - } + ch = state.input.charCodeAt(_position); - try { - return origRealpathSync(p, cache) - } catch (er) { - if (newError(er)) { - return old.realpathSync(p, cache) - } else { - throw er + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; } } -} -function monkeypatch () { - fs$d.realpath = realpath$2; - fs$d.realpathSync = realpathSync; + return false; } -function unmonkeypatch () { - fs$d.realpath = origRealpath; - fs$d.realpathSync = origRealpathSync; +function writeFoldedLines(state, count) { + if (count === 1) { + state.result += ' '; + } else if (count > 1) { + state.result += common$4.repeat('\n', count - 1); + } } -var concatMap$1 = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray$1(x)) res.push.apply(res, x); - else res.push(x); - } - return res; -}; -var isArray$1 = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; +function readPlainScalar(state, nodeIndent, withinFlowCollection) { + var preceding, + following, + captureStart, + captureEnd, + hasPendingContent, + _line, + _lineStart, + _lineIndent, + _kind = state.kind, + _result = state.result, + ch; -var balancedMatch = balanced$1; -function balanced$1(a, b, str) { - if (a instanceof RegExp) a = maybeMatch(a, str); - if (b instanceof RegExp) b = maybeMatch(b, str); + ch = state.input.charCodeAt(state.position); - var r = range$3(a, b, str); + if (is_WS_OR_EOL(ch) || + is_FLOW_INDICATOR(ch) || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || + ch === 0x60/* ` */) { + return false; + } - return r && { - start: r[0], - end: r[1], - pre: str.slice(0, r[0]), - body: str.slice(r[0] + a.length, r[1]), - post: str.slice(r[1] + b.length) - }; -} + if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { + following = state.input.charCodeAt(state.position + 1); -function maybeMatch(reg, str) { - var m = str.match(reg); - return m ? m[0] : null; -} + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } -balanced$1.range = range$3; -function range$3(a, b, str) { - var begs, beg, left, right, result; - var ai = str.indexOf(a); - var bi = str.indexOf(b, ai + 1); - var i = ai; + state.kind = 'scalar'; + state.result = ''; + captureStart = captureEnd = state.position; + hasPendingContent = false; - if (ai >= 0 && bi > 0) { - if(a===b) { - return [ai, bi]; - } - begs = []; - left = str.length; + while (ch !== 0) { + if (ch === 0x3A/* : */) { + following = state.input.charCodeAt(state.position + 1); - while (i >= 0 && !result) { - if (i == ai) { - begs.push(i); - ai = str.indexOf(a, i + 1); - } else if (begs.length == 1) { - result = [ begs.pop(), bi ]; - } else { - beg = begs.pop(); - if (beg < left) { - left = beg; - right = bi; - } + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } - bi = str.indexOf(b, i + 1); + } else if (ch === 0x23/* # */) { + preceding = state.input.charCodeAt(state.position - 1); + + if (is_WS_OR_EOL(preceding)) { + break; } - i = ai < bi && ai >= 0 ? ai : bi; - } + } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || + withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; - if (begs.length) { - result = [ left, right ]; + } 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; + } } - } - return result; -} + if (hasPendingContent) { + captureSegment(state, captureStart, captureEnd, false); + writeFoldedLines(state, state.line - _line); + captureStart = captureEnd = state.position; + hasPendingContent = false; + } -var concatMap = concatMap$1; -var balanced = balancedMatch; + if (!is_WHITE_SPACE(ch)) { + captureEnd = state.position + 1; + } -var braceExpansion = expandTop; + ch = state.input.charCodeAt(++state.position); + } -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; + captureSegment(state, captureStart, captureEnd, false); -function numeric$1(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); -} + if (state.result) { + return true; + } -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); + state.kind = _kind; + state.result = _result; + return false; } -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); -} +function readSingleQuotedScalar(state, nodeIndent) { + var ch, + captureStart, captureEnd; + ch = state.input.charCodeAt(state.position); -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); + if (ch !== 0x27/* ' */) { + return false; + } - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x27/* ' */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); - parts.push.apply(parts, p); + if (ch === 0x27/* ' */) { + captureStart = state.position; + state.position++; + captureEnd = state.position; + } else { + return true; + } - return parts; -} + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; -function expandTop(str) { - if (!str) - return []; + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError$1(state, 'unexpected end of the document within a single quoted scalar'); - // I don't know why Bash 4.3 does this, but it does. - // Anything starting with {} will have the first two bytes preserved - // but *only* at the top level, so {},a}b will not expand to anything, - // but a{},b}c will be expanded to [a}c,abc]. - // One could argue that this is a bug in Bash, but since the goal of - // this module is to match Bash's rules, we escape a leading {} - if (str.substr(0, 2) === '{}') { - str = '\\{\\}' + str.substr(2); + } else { + state.position++; + captureEnd = state.position; + } } - return expand$4(escapeBraces(str), true).map(unescapeBraces); + throwError$1(state, 'unexpected end of the stream within a single quoted scalar'); } -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} +function readDoubleQuotedScalar(state, nodeIndent) { + var captureStart, + captureEnd, + hexLength, + hexResult, + tmp, + ch; -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} + ch = state.input.charCodeAt(state.position); -function expand$4(str, isTop) { - var expansions = []; + if (ch !== 0x22/* " */) { + return false; + } - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = m.body.indexOf(',') >= 0; - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*\}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand$4(str); - } - return [str]; - } + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x22/* " */) { + captureSegment(state, captureStart, state.position, true); + state.position++; + return true; - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand$4(n[0], false).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand$4(m.post, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } + } else if (ch === 0x5C/* \ */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. + if (is_EOL(ch)) { + skipSeparationSpace(state, false, nodeIndent); - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand$4(m.post, false) - : ['']; + // TODO: rework to inline fn with no type cast? + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state.result += simpleEscapeMap[ch]; + state.position++; - var N; + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; - if (isSequence) { - var x = numeric$1(n[0]); - var y = numeric$1(n[1]); - var width = Math.max(n[0].length, n[1].length); - var incr = n.length == 3 - ? Math.abs(numeric$1(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); + for (; hexLength > 0; hexLength--) { + ch = state.input.charCodeAt(++state.position); - N = []; + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; + } else { + throwError$1(state, 'expected hexadecimal character'); } } + + state.result += charFromCodepoint(hexResult); + + state.position++; + + } else { + throwError$1(state, 'unknown escape sequence'); } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand$4(el, false) }); - } - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); + 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$1(state, 'unexpected end of the document within a double quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; } } - return expansions; + throwError$1(state, 'unexpected end of the stream within a double quoted scalar'); } -var minimatch_1 = minimatch$3; -minimatch$3.Minimatch = Minimatch$1; +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; -var path$d = { sep: '/' }; -try { - path$d = require$$0__default$2['default']; -} catch (er) {} + ch = state.input.charCodeAt(state.position); -var GLOBSTAR$1 = minimatch$3.GLOBSTAR = Minimatch$1.GLOBSTAR = {}; -var expand$3 = braceExpansion; + if (ch === 0x5B/* [ */) { + terminator = 0x5D;/* ] */ + isMapping = false; + _result = []; + } else if (ch === 0x7B/* { */) { + terminator = 0x7D;/* } */ + isMapping = true; + _result = {}; + } else { + return false; + } -var plTypes = { - '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, - '?': { open: '(?:', close: ')?' }, - '+': { open: '(?:', close: ')+' }, - '*': { open: '(?:', close: ')*' }, - '@': { open: '(?:', close: ')' } -}; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } -// any single thing other than / -// don't need to escape / when using new RegExp() -var qmark = '[^/]'; + ch = state.input.charCodeAt(++state.position); -// * => any number of characters -var star$3 = qmark + '*?'; + while (ch !== 0) { + skipSeparationSpace(state, true, nodeIndent); -// ** when dots are allowed. Anything goes, except .. and . -// not (^ or / followed by one or two dots followed by $ or /), -// followed by anything, any number of times. -var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; + ch = state.input.charCodeAt(state.position); -// not a ^ or / followed by a dot, -// followed by anything, any number of times. -var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; + 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$1(state, 'missed comma between flow collection entries'); + } else if (ch === 0x2C/* , */) { + // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 + throwError$1(state, "expected the node content, but found ','"); + } -// characters that need to be escaped in RegExp. -var reSpecials = charSet('().*{}+?[]^$\\!'); + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; -// "abc" -> { a:true, b:true, c:true } -function charSet (s) { - return s.split('').reduce(function (set, c) { - set[c] = true; - return set - }, {}) -} + if (ch === 0x3F/* ? */) { + following = state.input.charCodeAt(state.position + 1); -// normalizes slashes. -var slashSplit = /\/+/; + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state.position++; + skipSeparationSpace(state, true, nodeIndent); + } + } -minimatch$3.filter = filter; -function filter (pattern, options) { - options = options || {}; - return function (p, i, list) { - return minimatch$3(p, pattern, options) - } -} + _line = state.line; // Save the current 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); -function ext (a, b) { - a = a || {}; - b = b || {}; - var t = {}; - Object.keys(b).forEach(function (k) { - t[k] = b[k]; - }); - Object.keys(a).forEach(function (k) { - t[k] = a[k]; - }); - return t -} + ch = state.input.charCodeAt(state.position); -minimatch$3.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch$3 + if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { + isPair = true; + ch = state.input.charCodeAt(++state.position); + skipSeparationSpace(state, true, nodeIndent); + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state.result; + } - var orig = minimatch$3; + 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); + } - var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) - }; + skipSeparationSpace(state, true, nodeIndent); - m.Minimatch = function Minimatch (pattern, options) { - return new orig.Minimatch(pattern, ext(def, options)) - }; + ch = state.input.charCodeAt(state.position); - return m -}; + if (ch === 0x2C/* , */) { + readNext = true; + ch = state.input.charCodeAt(++state.position); + } else { + readNext = false; + } + } -Minimatch$1.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch$1 - return minimatch$3.defaults(def).Minimatch -}; + throwError$1(state, 'unexpected end of the stream within a flow collection'); +} -function minimatch$3 (p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } +function readBlockScalar(state, nodeIndent) { + var captureStart, + folding, + chomping = CHOMPING_CLIP, + didReadContent = false, + detectedIndent = false, + textIndent = nodeIndent, + emptyLines = 0, + atMoreIndented = false, + tmp, + ch; - if (!options) options = {}; + ch = state.input.charCodeAt(state.position); - // shortcut: comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { - return false + if (ch === 0x7C/* | */) { + folding = false; + } else if (ch === 0x3E/* > */) { + folding = true; + } else { + return false; } - // "" only matches "" - if (pattern.trim() === '') return p === '' + state.kind = 'scalar'; + state.result = ''; - return new Minimatch$1(pattern, options).match(p) -} + while (ch !== 0) { + ch = state.input.charCodeAt(++state.position); -function Minimatch$1 (pattern, options) { - if (!(this instanceof Minimatch$1)) { - return new Minimatch$1(pattern, options) - } + if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { + if (CHOMPING_CLIP === chomping) { + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError$1(state, 'repeat of a chomping mode identifier'); + } - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError$1(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$1(state, 'repeat of an indentation width identifier'); + } + + } else { + break; + } } - if (!options) options = {}; - pattern = pattern.trim(); + if (is_WHITE_SPACE(ch)) { + do { ch = state.input.charCodeAt(++state.position); } + while (is_WHITE_SPACE(ch)); - // windows support: need to use /, not \ - if (path$d.sep !== '/') { - pattern = pattern.split(path$d.sep).join('/'); + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (!is_EOL(ch) && (ch !== 0)); + } } - this.options = options; - this.set = []; - this.pattern = pattern; - this.regexp = null; - this.negate = false; - this.comment = false; - this.empty = false; + while (ch !== 0) { + readLineBreak(state); + state.lineIndent = 0; - // make the set of regexps etc. - this.make(); -} + ch = state.input.charCodeAt(state.position); -Minimatch$1.prototype.debug = function () {}; + while ((!detectedIndent || state.lineIndent < textIndent) && + (ch === 0x20/* Space */)) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } -Minimatch$1.prototype.make = make; -function make () { - // don't do it more than once. - if (this._made) return + if (!detectedIndent && state.lineIndent > textIndent) { + textIndent = state.lineIndent; + } - var pattern = this.pattern; - var options = this.options; + if (is_EOL(ch)) { + emptyLines++; + continue; + } - // empty patterns and comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { - this.comment = true; - return - } - if (!pattern) { - this.empty = true; - return - } + // End of the scalar. + if (state.lineIndent < textIndent) { - // step 1: figure out negation, etc. - this.parseNegate(); + // Perform the chomping. + if (chomping === CHOMPING_KEEP) { + state.result += common$4.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { // i.e. only if the scalar is not empty. + state.result += '\n'; + } + } - // step 2: expand braces - var set = this.globSet = this.braceExpand(); + // Break this `while` cycle and go to the funciton's epilogue. + break; + } - if (options.debug) this.debug = console.error; + // Folded style: use fancy rules to handle line breaks. + if (folding) { - this.debug(this.pattern, set); + // Lines starting with white space characters (more-indented lines) are not folded. + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + // except for the first content line (cf. Example 8.1) + state.result += common$4.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - // step 3: now we have a set, so turn each one into a series of path-portion - // matching patterns. - // These will be regexps, except in the case of "**", which is - // set to the GLOBSTAR object for globstar behavior, - // and will not contain any / characters - set = this.globParts = set.map(function (s) { - return s.split(slashSplit) - }); + // End of more-indented block. + } else if (atMoreIndented) { + atMoreIndented = false; + state.result += common$4.repeat('\n', emptyLines + 1); - this.debug(this.pattern, set); + // Just one line break - perceive as the same line. + } else if (emptyLines === 0) { + if (didReadContent) { // i.e. only if we have already read some scalar content. + state.result += ' '; + } - // glob --> regexps - set = set.map(function (s, si, set) { - return s.map(this.parse, this) - }, this); + // Several line breaks - perceive as different lines. + } else { + state.result += common$4.repeat('\n', emptyLines); + } - this.debug(this.pattern, set); + // Literal style: just add exact number of line breaks between content lines. + } else { + // Keep all line breaks except the header line break. + state.result += common$4.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } - // filter out everything that didn't compile properly. - set = set.filter(function (s) { - return s.indexOf(false) === -1 - }); + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state.position; - this.debug(this.pattern, set); + while (!is_EOL(ch) && (ch !== 0)) { + ch = state.input.charCodeAt(++state.position); + } - this.set = set; + captureSegment(state, captureStart, state.position, false); + } + + return true; } -Minimatch$1.prototype.parseNegate = parseNegate; -function parseNegate () { - var pattern = this.pattern; - var negate = false; - var options = this.options; - var negateOffset = 0; +function readBlockSequence(state, nodeIndent) { + var _line, + _tag = state.tag, + _anchor = state.anchor, + _result = [], + following, + detected = false, + ch; - if (options.nonegate) return + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; - for (var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === '!' - ; i++) { - negate = !negate; - negateOffset++; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; } - if (negateOffset) this.pattern = pattern.substr(negateOffset); - this.negate = negate; -} + ch = state.input.charCodeAt(state.position); -// Brace expansion: -// a{b,c}d -> abd acd -// a{b,}c -> abc ac -// a{0..3}d -> a0d a1d a2d a3d -// a{b,c{d,e}f}g -> abg acdfg acefg -// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg -// -// Invalid sets are not expanded. -// a{2..}b -> a{2..}b -// a{b}c -> a{b}c -minimatch$3.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) -}; + while (ch !== 0) { + if (state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError$1(state, 'tab characters must not be used in indentation'); + } -Minimatch$1.prototype.braceExpand = braceExpand; + if (ch !== 0x2D/* - */) { + break; + } -function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch$1) { - options = this.options; - } else { - options = {}; + following = state.input.charCodeAt(state.position + 1); + + if (!is_WS_OR_EOL(following)) { + break; } - } - pattern = typeof pattern === 'undefined' - ? this.pattern : pattern; + detected = true; + state.position++; - if (typeof pattern === 'undefined') { - throw new TypeError('undefined pattern') - } + if (skipSeparationSpace(state, true, -1)) { + if (state.lineIndent <= nodeIndent) { + _result.push(null); + ch = state.input.charCodeAt(state.position); + continue; + } + } - if (options.nobrace || - !pattern.match(/\{.*\}/)) { - // shortcut. no need to expand. - return [pattern] - } + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state.result); + skipSeparationSpace(state, true, -1); - return expand$3(pattern) -} + ch = state.input.charCodeAt(state.position); -// parse a component of the expanded set. -// At this point, no pattern may contain "/" in it -// so we're going to return a 2d array, where each entry is the full -// pattern, split on '/', and then turned into a regular expression. -// A regexp is made at the end which joins each array with an -// escaped /, and another full one which joins each regexp with |. -// -// Following the lead of Bash 4.1, note that "**" only has special meaning -// when it is the *only* thing in a path portion. Otherwise, any series -// of * is equivalent to a single *. Globstar behavior is enabled by -// default, and can be disabled by setting options.noglobstar. -Minimatch$1.prototype.parse = parse$b; -var SUBPARSE = {}; -function parse$b (pattern, isSub) { - if (pattern.length > 1024 * 64) { - throw new TypeError('pattern is too long') + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError$1(state, 'bad indentation of a sequence entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } } - var options = this.options; + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'sequence'; + state.result = _result; + return true; + } + return false; +} - // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR$1 - if (pattern === '') return '' +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; - var re = ''; - var hasMagic = !!options.nocase; - var escaping = false; - // ? => one single character - var patternListStack = []; - var negativeLists = []; - var stateChar; - var inClass = false; - var reClassStart = -1; - var classStart = -1; - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - var patternStart = pattern.charAt(0) === '.' ? '' // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' - : '(?!\\.)'; - var self = this; + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; - function clearStateChar () { - if (stateChar) { - // we had some state-tracking character - // that wasn't consumed by this pass. - switch (stateChar) { - case '*': - re += star$3; - hasMagic = true; - break - case '?': - re += qmark; - hasMagic = true; - break - default: - re += '\\' + stateChar; - break - } - self.debug('clearStateChar %j %j', stateChar, re); - stateChar = false; - } + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; } - for (var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i++) { - this.debug('%s\t%s %s %j', pattern, i, re, c); + ch = state.input.charCodeAt(state.position); - // skip over any that are escaped. - if (escaping && reSpecials[c]) { - re += '\\' + c; - escaping = false; - continue + while (ch !== 0) { + if (!atExplicitKey && state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError$1(state, 'tab characters must not be used in indentation'); } - switch (c) { - case '/': - // completely not allowed, even escaped. - // Should already be path-split by now. - return false - - case '\\': - clearStateChar(); - escaping = true; - continue - - // the various stateChar values - // for the "extglob" stuff. - case '?': - case '*': - case '+': - case '@': - case '!': - this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); - - // all of those are literals inside a class, except that - // the glob [!a] means [^a] in regexp - if (inClass) { - this.debug(' in class'); - if (c === '!' && i === classStart + 1) c = '^'; - re += c; - continue - } + following = state.input.charCodeAt(state.position + 1); + _line = state.line; // Save the current line. - // if we already have a stateChar, then it means - // that there was something like ** or +? in there. - // Handle the stateChar, then proceed with this one. - self.debug('call clearStateChar %j', stateChar); - clearStateChar(); - stateChar = c; - // if extglob is disabled, then +(asdf|foo) isn't a thing. - // just clear the statechar *now*, rather than even diving into - // the patternList stuff. - if (options.noext) clearStateChar(); - continue + // + // Explicit notation case. There are two separate blocks: + // first for the key (denoted by "?") and second for the value (denoted by ":") + // + if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { - case '(': - if (inClass) { - re += '('; - continue + if (ch === 0x3F/* ? */) { + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; } - if (!stateChar) { - re += '\\('; - continue - } + detected = true; + atExplicitKey = true; + allowCompact = true; - patternListStack.push({ - type: stateChar, - start: i - 1, - reStart: re.length, - open: plTypes[stateChar].open, - close: plTypes[stateChar].close - }); - // negation is (?:(?!js)[^/]*) - re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; - this.debug('plType %j %j', stateChar, re); - stateChar = false; - continue + } else if (atExplicitKey) { + // i.e. 0x3A/* : */ === character after the explicit key. + atExplicitKey = false; + allowCompact = true; - case ')': - if (inClass || !patternListStack.length) { - re += '\\)'; - continue - } + } else { + throwError$1(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + } - clearStateChar(); - hasMagic = true; - var pl = patternListStack.pop(); - // negation is (?:(?!js)[^/]*) - // The others are (?:) - re += pl.close; - if (pl.type === '!') { - negativeLists.push(pl); - } - pl.reEnd = re.length; - continue + state.position += 1; + ch = following; - case '|': - if (inClass || !patternListStack.length || escaping) { - re += '\\|'; - escaping = false; - continue - } + // + // Implicit notation case. Flow-style node as the key first, then ":", and the value. + // + } else { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; - clearStateChar(); - re += '|'; - continue + if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + // Neither implicit nor explicit notation. + // Reading is done. Go to the epilogue. + break; + } - // these are mostly the same in regexp and glob - case '[': - // swallow any state-tracking char before the [ - clearStateChar(); + if (state.line === _line) { + ch = state.input.charCodeAt(state.position); - if (inClass) { - re += '\\' + c; - continue + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); } - inClass = true; - classStart = i; - reClassStart = re.length; - re += c; - continue + if (ch === 0x3A/* : */) { + ch = state.input.charCodeAt(++state.position); - case ']': - // a right bracket shall lose its special - // meaning and represent itself in - // a bracket expression if it occurs - // first in the list. -- POSIX.2 2.8.3.2 - if (i === classStart + 1 || !inClass) { - re += '\\' + c; - escaping = false; - continue - } + if (!is_WS_OR_EOL(ch)) { + throwError$1(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + } - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i); - try { - RegExp('[' + cs + ']'); - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE); - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'; - hasMagic = hasMagic || sp[1]; - inClass = false; - continue + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; } - } - // finish up the class. - hasMagic = true; - inClass = false; - re += c; - continue + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state.tag; + keyNode = state.result; - default: - // swallow any state char that wasn't consumed - clearStateChar(); + } else if (detected) { + throwError$1(state, 'can not read an implicit mapping pair; a colon is missed'); - if (escaping) { - // no need - escaping = false; - } else if (reSpecials[c] - && !(c === '^' && inClass)) { - re += '\\'; + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. } - re += c; + } else if (detected) { + throwError$1(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); - } // switch - } // for + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + } - // handle the case where we left a class open. - // "[abc" is valid, equivalent to "\[abc" - if (inClass) { - // split where the last [ was, and escape it - // this is a huge pita. We now have to re-walk - // the contents of the would-be class to re-translate - // any characters that were passed through as-is - cs = pattern.substr(classStart + 1); - sp = this.parse(cs, SUBPARSE); - re = re.substr(0, reClassStart) + '\\[' + sp[0]; - hasMagic = hasMagic || sp[1]; - } + // + // Common reading code for both explicit and implicit notations. + // + if (state.line === _line || state.lineIndent > nodeIndent) { + if (atExplicitKey) { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + } - // handle the case where we had a +( thing at the *end* - // of the pattern. - // each pattern list stack adds 3 chars, and we need to go through - // and escape any | chars that were passed through as-is for the regexp. - // Go through and escape them, taking care not to double-escape any - // | chars that were already escaped. - for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + pl.open.length); - this.debug('setting tail', re, pl); - // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - // the | isn't already escaped, so escape it. - $2 = '\\'; + if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state.result; + } else { + valueNode = state.result; + } } - // need to escape all those slashes *again*, without escaping the - // one that we need for escaping the | character. As it works out, - // escaping an even number of slashes can be done by simply repeating - // it exactly after itself. That's why this trick works. - // - // I am sorry that you have to see this. - return $1 + $1 + $2 + '|' - }); + if (!atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } - this.debug('tail=%j\n %s', tail, tail, pl, re); - var t = pl.type === '*' ? star$3 - : pl.type === '?' ? qmark - : '\\' + pl.type; + skipSeparationSpace(state, true, -1); + ch = state.input.charCodeAt(state.position); + } - hasMagic = true; - re = re.slice(0, pl.reStart) + t + '\\(' + tail; + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError$1(state, 'bad indentation of a mapping entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } } - // handle trailing things that only matter at the very end. - clearStateChar(); - if (escaping) { - // trailing \\ - re += '\\\\'; + // + // Epilogue. + // + + // Special case: last mapping's node contains only the key in explicit notation. + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); } - // only need to apply the nodot start if the re starts with - // something that could conceivably capture a dot - var addPatternStart = false; - switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true; + // Expose the resulting mapping. + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'mapping'; + state.result = _result; } - // Hack to work around lack of negative lookbehind in JS - // A pattern like: *.!(x).!(y|z) needs to ensure that a name - // like 'a.xyz.yz' doesn't match. So, the first negative - // lookahead, has to look ALL the way ahead, to the end of - // the pattern. - for (var n = negativeLists.length - 1; n > -1; n--) { - var nl = negativeLists[n]; - - var nlBefore = re.slice(0, nl.reStart); - var nlFirst = re.slice(nl.reStart, nl.reEnd - 8); - var nlLast = re.slice(nl.reEnd - 8, nl.reEnd); - var nlAfter = re.slice(nl.reEnd); + return detected; +} - nlLast += nlAfter; +function readTagProperty(state) { + var _position, + isVerbatim = false, + isNamed = false, + tagHandle, + tagName, + ch; - // Handle nested stuff like *(*.js|!(*.json)), where open parens - // mean that we should *not* include the ) in the bit that is considered - // "after" the negated section. - var openParensBefore = nlBefore.split('(').length - 1; - var cleanAfter = nlAfter; - for (i = 0; i < openParensBefore; i++) { - cleanAfter = cleanAfter.replace(/\)[+*?]?/, ''); - } - nlAfter = cleanAfter; + ch = state.input.charCodeAt(state.position); - var dollar = ''; - if (nlAfter === '' && isSub !== SUBPARSE) { - dollar = '$'; - } - var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast; - re = newRe; - } + if (ch !== 0x21/* ! */) return false; - // if the re is not "" at this point, then we need to make sure - // it doesn't match against an empty path part. - // Otherwise a/* will match a/, which it should not. - if (re !== '' && hasMagic) { - re = '(?=.)' + re; + if (state.tag !== null) { + throwError$1(state, 'duplication of a tag property'); } - if (addPatternStart) { - re = patternStart + re; - } + ch = state.input.charCodeAt(++state.position); - // parsing just a piece of a larger pattern. - if (isSub === SUBPARSE) { - return [re, hasMagic] - } + if (ch === 0x3C/* < */) { + isVerbatim = true; + ch = state.input.charCodeAt(++state.position); - // skip the regexp for non-magical patterns - // unescape anything in it, though, so that it'll be - // an exact match against a file etc. - if (!hasMagic) { - return globUnescape(pattern) - } + } else if (ch === 0x21/* ! */) { + isNamed = true; + tagHandle = '!!'; + ch = state.input.charCodeAt(++state.position); - var flags = options.nocase ? 'i' : ''; - try { - var regExp = new RegExp('^' + re + '$', flags); - } catch (er) { - // If it was an invalid regular expression, then it can't match - // anything. This trick looks for a character after the end of - // the string, which is of course impossible, except in multi-line - // mode, but it's not a /m regex. - return new RegExp('$.') + } else { + tagHandle = '!'; } - regExp._glob = pattern; - regExp._src = re; + _position = state.position; - return regExp -} + if (isVerbatim) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && ch !== 0x3E/* > */); -minimatch$3.makeRe = function (pattern, options) { - return new Minimatch$1(pattern, options || {}).makeRe() -}; + if (state.position < state.length) { + tagName = state.input.slice(_position, state.position); + ch = state.input.charCodeAt(++state.position); + } else { + throwError$1(state, 'unexpected end of the stream within a verbatim tag'); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { -Minimatch$1.prototype.makeRe = makeRe; -function makeRe () { - if (this.regexp || this.regexp === false) return this.regexp + if (ch === 0x21/* ! */) { + if (!isNamed) { + tagHandle = state.input.slice(_position - 1, state.position + 1); - // at this point, this.set is a 2d array of partial - // pattern strings, or "**". - // - // It's better to use .match(). This function shouldn't - // be used, really, but it's pretty convenient sometimes, - // when you just want to work with a regex. - var set = this.set; + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError$1(state, 'named tag handle cannot contain such characters'); + } - if (!set.length) { - this.regexp = false; - return this.regexp - } - var options = this.options; + isNamed = true; + _position = state.position + 1; + } else { + throwError$1(state, 'tag suffix cannot contain exclamation marks'); + } + } - var twoStar = options.noglobstar ? star$3 - : options.dot ? twoStarDot - : twoStarNoDot; - var flags = options.nocase ? 'i' : ''; + ch = state.input.charCodeAt(++state.position); + } - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return (p === GLOBSTAR$1) ? twoStar - : (typeof p === 'string') ? regExpEscape(p) - : p._src - }).join('\\\/') - }).join('|'); + tagName = state.input.slice(_position, state.position); - // must match entire pattern - // ending in a * or ** will make it less strict. - re = '^(?:' + re + ')$'; + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError$1(state, 'tag suffix cannot contain flow indicator characters'); + } + } - // can match anything, as long as it's not this. - if (this.negate) re = '^(?!' + re + ').*$'; + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError$1(state, 'tag name cannot contain such characters: ' + tagName); + } try { - this.regexp = new RegExp(re, flags); - } catch (ex) { - this.regexp = false; + tagName = decodeURIComponent(tagName); + } catch (err) { + throwError$1(state, 'tag name is malformed: ' + tagName); } - return this.regexp -} -minimatch$3.match = function (list, pattern, options) { - options = options || {}; - var mm = new Minimatch$1(pattern, options); - list = list.filter(function (f) { - return mm.match(f) - }); - if (mm.options.nonull && !list.length) { - list.push(pattern); - } - return list -}; + if (isVerbatim) { + state.tag = tagName; -Minimatch$1.prototype.match = match; -function match (f, partial) { - this.debug('match', f, this.pattern); - // short-circuit in the case of busted things. - // comments, etc. - if (this.comment) return false - if (this.empty) return f === '' + } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { + state.tag = state.tagMap[tagHandle] + tagName; - if (f === '/' && partial) return true + } else if (tagHandle === '!') { + state.tag = '!' + tagName; - var options = this.options; + } else if (tagHandle === '!!') { + state.tag = 'tag:yaml.org,2002:' + tagName; - // windows: need to use /, not \ - if (path$d.sep !== '/') { - f = f.split(path$d.sep).join('/'); + } else { + throwError$1(state, 'undeclared tag handle "' + tagHandle + '"'); } - // treat the test path as a set of pathparts. - f = f.split(slashSplit); - this.debug(this.pattern, 'split', f); + return true; +} - // just ONE of the pattern sets in this.set needs to match - // in order for it to be valid. If negating, then just one - // match means that we have failed. - // Either way, return on the first hit. +function readAnchorProperty(state) { + var _position, + ch; - var set = this.set; - this.debug(this.pattern, 'set', set); + ch = state.input.charCodeAt(state.position); - // Find the basename of the path by looking for the last non-empty segment - var filename; - var i; - for (i = f.length - 1; i >= 0; i--) { - filename = f[i]; - if (filename) break + if (ch !== 0x26/* & */) return false; + + if (state.anchor !== null) { + throwError$1(state, 'duplication of an anchor property'); } - for (i = 0; i < set.length; i++) { - var pattern = set[i]; - var file = f; - if (options.matchBase && pattern.length === 1) { - file = [filename]; - } - var hit = this.matchOne(file, pattern, partial); - if (hit) { - if (options.flipNegate) return true - return !this.negate - } + 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); } - // didn't get any hits. this is success if it's a negative - // pattern, failure otherwise. - if (options.flipNegate) return false - return this.negate + if (state.position === _position) { + throwError$1(state, 'name of an anchor node must contain at least one character'); + } + + state.anchor = state.input.slice(_position, state.position); + return true; } -// set partial to true to test if, for example, -// "/a/b" matches the start of "/*/b/*/d" -// Partial means, if you run out of file before you run -// out of pattern, then that's fine, as long as all -// the parts match. -Minimatch$1.prototype.matchOne = function (file, pattern, partial) { - var options = this.options; +function readAlias(state) { + var _position, alias, + ch; - this.debug('matchOne', - { 'this': this, file: file, pattern: pattern }); + ch = state.input.charCodeAt(state.position); - this.debug('matchOne', file.length, pattern.length); + if (ch !== 0x2A/* * */) return false; - for (var fi = 0, - pi = 0, - fl = file.length, - pl = pattern.length - ; (fi < fl) && (pi < pl) - ; fi++, pi++) { - this.debug('matchOne loop'); - var p = pattern[pi]; - var f = file[fi]; + ch = state.input.charCodeAt(++state.position); + _position = state.position; - this.debug(pattern, p, f); + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } - // should be impossible. - // some invalid regexp stuff in the set. - if (p === false) return false + if (state.position === _position) { + throwError$1(state, 'name of an alias node must contain at least one character'); + } - if (p === GLOBSTAR$1) { - this.debug('GLOBSTAR', [pattern, p, f]); + alias = state.input.slice(_position, state.position); - // "**" - // a/**/b/**/c would match the following: - // a/b/x/y/z/c - // a/x/y/z/b/c - // a/b/x/b/x/c - // a/b/c - // To do this, take the rest of the pattern after - // the **, and see if it would match the file remainder. - // If so, return success. - // If not, the ** "swallows" a segment, and try again. - // This is recursively awful. - // - // a/**/b/**/c matching a/b/x/y/z/c - // - a matches a - // - doublestar - // - matchOne(b/x/y/z/c, b/**/c) - // - b matches b - // - doublestar - // - matchOne(x/y/z/c, c) -> no - // - matchOne(y/z/c, c) -> no - // - matchOne(z/c, c) -> no - // - matchOne(c, c) yes, hit - var fr = fi; - var pr = pi + 1; - if (pr === pl) { - this.debug('** at the end'); - // a ** at the end will just swallow the rest. - // We have found a match. - // however, it will not swallow /.x, unless - // options.dot is set. - // . and .. are *never* matched by **, for explosively - // exponential reasons. - for (; fi < fl; fi++) { - if (file[fi] === '.' || file[fi] === '..' || - (!options.dot && file[fi].charAt(0) === '.')) return false - } - return true - } + if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { + throwError$1(state, 'unidentified alias "' + alias + '"'); + } - // ok, let's see if we can swallow whatever we can. - while (fr < fl) { - var swallowee = file[fr]; + state.result = state.anchorMap[alias]; + skipSeparationSpace(state, true, -1); + return true; +} - this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); +function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, + allowBlockScalars, + allowBlockCollections, + indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this>> no match, partial?', file, fr, pattern, pr); - if (fr === fl) return true + 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; } - return false } + } - // something other than ** - // non-magic patterns just have to match exactly - // patterns with magic have been turned into regexps. - var hit; - if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase(); + 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 { - hit = f === p; + allowBlockCollections = false; } - this.debug('string match', p, f, hit); - } else { - hit = f.match(p); - this.debug('pattern match', p, f, hit); } + } - if (!hit) return false + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; } - // Note: ending in / means that we'll get a final "" - // at the end of the pattern. This can only match a - // corresponding "" at the end of the file. - // If the file ends in /, then it can only match a - // a pattern that ends in /, unless the pattern just - // doesn't have any more for it. But, a/b/ should *not* - // match "a/b/*", even though "" matches against the - // [^/]*? pattern, except in partial mode, where it might - // simply not be reached yet. - // However, a/b/ should still satisfy a/* + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } - // now either we fell off the end of the pattern, or we're done. - if (fi === fl && pi === pl) { - // ran out of pattern and filename at the same time. - // an exact hit! - return true - } else if (fi === fl) { - // ran out of file, but still had pattern left. - // this is ok if we're doing the match as part of - // a glob fs traversal. - return partial - } else if (pi === pl) { - // ran out of pattern, still have file left. - // this is only acceptable if we're on the very last - // empty segment of a file with a trailing slash. - // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === ''); - return emptyFileEnd - } + blockIndent = state.position - state.lineStart; - // should be unreachable. - throw new Error('wtf?') -}; + 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; -// replace stuff like \* with * -function globUnescape (s) { - return s.replace(/\\(.)/g, '$1') -} + } else if (readAlias(state)) { + hasContent = true; -function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') -} + if (state.tag !== null || state.anchor !== null) { + throwError$1(state, 'alias node should not have any properties'); + } -var inherits$3 = {exports: {}}; + } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; -var inherits_browser = {exports: {}}; + if (state.tag === null) { + state.tag = '?'; + } + } -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - inherits_browser.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; } - }); - } - }; -} else { - // old school shim for old browsers - inherits_browser.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; + } + } else if (indentStatus === 0) { + // Special case: block sequences are allowed to have same indentation level as the parent. + // http://www.yaml.org/spec/1.2/spec.html#id2799784 + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); } - }; -} + } -try { - var util$3 = require$$0__default['default']; - /* istanbul ignore next */ - if (typeof util$3.inherits !== 'function') throw ''; - inherits$3.exports = util$3.inherits; -} catch (e) { - /* istanbul ignore next */ - inherits$3.exports = inherits_browser.exports; -} + if (state.tag === null) { + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } -var pathIsAbsolute = {exports: {}}; - -function posix(path) { - return path.charAt(0) === '/'; -} - -function win32(path) { - // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 - var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; - var result = splitDeviceRe.exec(path); - var device = result[1] || ''; - var isUnc = Boolean(device && device.charAt(1) !== ':'); + } else if (state.tag === '?') { + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only automatically assigned to plain scalars. + // + // We only need to check kind conformity in case user explicitly assigns '?' + // tag, for example like this: "! [0]" + // + if (state.result !== null && state.kind !== 'scalar') { + throwError$1(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + } - // UNC paths are always absolute - return Boolean(result[2] || isUnc); -} + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type = state.implicitTypes[typeIndex]; -pathIsAbsolute.exports = process.platform === 'win32' ? win32 : posix; -pathIsAbsolute.exports.posix = posix; -pathIsAbsolute.exports.win32 = win32; + if (type.resolve(state.result)) { // `state.result` updated in resolver if matched + state.result = type.construct(state.result); + state.tag = type.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 = state.typeMap[state.kind || 'fallback'][state.tag]; + } else { + // looking for multi type + type = null; + typeList = state.typeMap.multi[state.kind || 'fallback']; -var common$3 = {}; + for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { + type = typeList[typeIndex]; + break; + } + } + } -common$3.setopts = setopts$2; -common$3.ownProp = ownProp$2; -common$3.makeAbs = makeAbs; -common$3.finish = finish; -common$3.mark = mark; -common$3.isIgnored = isIgnored$2; -common$3.childrenIgnored = childrenIgnored$2; + if (!type) { + throwError$1(state, 'unknown tag !<' + state.tag + '>'); + } -function ownProp$2 (obj, field) { - return Object.prototype.hasOwnProperty.call(obj, field) -} + if (state.result !== null && type.kind !== state.kind) { + throwError$1(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + } -var path$c = require$$0__default$2['default']; -var minimatch$2 = minimatch_1; -var isAbsolute$2 = pathIsAbsolute.exports; -var Minimatch = minimatch$2.Minimatch; + if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched + throwError$1(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + } else { + state.result = type.construct(state.result, state.tag); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } -function alphasort (a, b) { - return a.localeCompare(b, 'en') + if (state.listener !== null) { + state.listener('close', state); + } + return state.tag !== null || state.anchor !== null || hasContent; } -function setupIgnores (self, options) { - self.ignore = options.ignore || []; +function readDocument(state) { + var documentStart = state.position, + _position, + directiveName, + directiveArgs, + hasDirectives = false, + ch; - if (!Array.isArray(self.ignore)) - self.ignore = [self.ignore]; + state.version = null; + state.checkLineBreaks = state.legacy; + state.tagMap = Object.create(null); + state.anchorMap = Object.create(null); - if (self.ignore.length) { - self.ignore = self.ignore.map(ignoreMap); - } -} + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + skipSeparationSpace(state, true, -1); -// ignore patterns are always in dot:true mode. -function ignoreMap (pattern) { - var gmatcher = null; - if (pattern.slice(-3) === '/**') { - var gpattern = pattern.replace(/(\/\*\*)+$/, ''); - gmatcher = new Minimatch(gpattern, { dot: true }); - } + ch = state.input.charCodeAt(state.position); - return { - matcher: new Minimatch(pattern, { dot: true }), - gmatcher: gmatcher - } -} + if (state.lineIndent > 0 || ch !== 0x25/* % */) { + break; + } -function setopts$2 (self, pattern, options) { - if (!options) - options = {}; + hasDirectives = true; + ch = state.input.charCodeAt(++state.position); + _position = state.position; - // base-matching: just use globstar for that. - if (options.matchBase && -1 === pattern.indexOf("/")) { - if (options.noglobstar) { - throw new Error("base matching requires globstar") + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); } - pattern = "**/" + pattern; - } - self.silent = !!options.silent; - self.pattern = pattern; - self.strict = options.strict !== false; - self.realpath = !!options.realpath; - self.realpathCache = options.realpathCache || Object.create(null); - self.follow = !!options.follow; - self.dot = !!options.dot; - self.mark = !!options.mark; - self.nodir = !!options.nodir; - if (self.nodir) - self.mark = true; - self.sync = !!options.sync; - self.nounique = !!options.nounique; - self.nonull = !!options.nonull; - self.nosort = !!options.nosort; - self.nocase = !!options.nocase; - self.stat = !!options.stat; - self.noprocess = !!options.noprocess; - self.absolute = !!options.absolute; + directiveName = state.input.slice(_position, state.position); + directiveArgs = []; - self.maxLength = options.maxLength || Infinity; - self.cache = options.cache || Object.create(null); - self.statCache = options.statCache || Object.create(null); - self.symlinks = options.symlinks || Object.create(null); + if (directiveName.length < 1) { + throwError$1(state, 'directive name must not be less than one character in length'); + } - setupIgnores(self, options); + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } - self.changedCwd = false; - var cwd = process.cwd(); - if (!ownProp$2(options, "cwd")) - self.cwd = cwd; - else { - self.cwd = path$c.resolve(options.cwd); - self.changedCwd = self.cwd !== cwd; - } + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && !is_EOL(ch)); + break; + } - self.root = options.root || path$c.resolve(self.cwd, "/"); - self.root = path$c.resolve(self.root); - if (process.platform === "win32") - self.root = self.root.replace(/\\/g, "/"); + if (is_EOL(ch)) break; - // TODO: is an absolute `cwd` supposed to be resolved against `root`? - // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') - self.cwdAbs = isAbsolute$2(self.cwd) ? self.cwd : makeAbs(self, self.cwd); - if (process.platform === "win32") - self.cwdAbs = self.cwdAbs.replace(/\\/g, "/"); - self.nomount = !!options.nomount; + _position = state.position; - // disable comments and negation in Minimatch. - // Note that they are not supported in Glob itself anyway. - options.nonegate = true; - options.nocomment = true; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } - self.minimatch = new Minimatch(pattern, options); - self.options = self.minimatch.options; -} + directiveArgs.push(state.input.slice(_position, state.position)); + } -function finish (self) { - var nou = self.nounique; - var all = nou ? [] : Object.create(null); + if (ch !== 0) readLineBreak(state); - for (var i = 0, l = self.matches.length; i < l; i ++) { - var matches = self.matches[i]; - if (!matches || Object.keys(matches).length === 0) { - if (self.nonull) { - // do like the shell, and spit out the literal glob - var literal = self.minimatch.globSet[i]; - if (nou) - all.push(literal); - else - all[literal] = true; - } + if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state, directiveName, directiveArgs); } else { - // had matches - var m = Object.keys(matches); - if (nou) - all.push.apply(all, m); - else - m.forEach(function (m) { - all[m] = true; - }); + throwWarning(state, 'unknown document directive "' + directiveName + '"'); } } - if (!nou) - all = Object.keys(all); + skipSeparationSpace(state, true, -1); - if (!self.nosort) - all = all.sort(alphasort); + if (state.lineIndent === 0 && + state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { + state.position += 3; + skipSeparationSpace(state, true, -1); - // at *some* point we statted all of these - if (self.mark) { - for (var i = 0; i < all.length; i++) { - all[i] = self._mark(all[i]); - } - if (self.nodir) { - all = all.filter(function (e) { - var notDir = !(/\/$/.test(e)); - var c = self.cache[e] || self.cache[makeAbs(self, e)]; - if (notDir && c) - notDir = c !== 'DIR' && !Array.isArray(c); - return notDir - }); - } + } else if (hasDirectives) { + throwError$1(state, 'directives end mark is expected'); } - if (self.ignore.length) - all = all.filter(function(m) { - return !isIgnored$2(self, m) - }); + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state, true, -1); - self.found = all; -} + 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'); + } -function mark (self, p) { - var abs = makeAbs(self, p); - var c = self.cache[abs]; - var m = p; - if (c) { - var isDir = c === 'DIR' || Array.isArray(c); - var slash = p.slice(-1) === '/'; + state.documents.push(state.result); - if (isDir && !slash) - m += '/'; - else if (!isDir && slash) - m = m.slice(0, -1); + if (state.position === state.lineStart && testDocumentSeparator(state)) { - if (m !== p) { - var mabs = makeAbs(self, m); - self.statCache[mabs] = self.statCache[abs]; - self.cache[mabs] = self.cache[abs]; + if (state.input.charCodeAt(state.position) === 0x2E/* . */) { + state.position += 3; + skipSeparationSpace(state, true, -1); } + return; } - return m -} - -// lotta situps... -function makeAbs (self, f) { - var abs = f; - if (f.charAt(0) === '/') { - abs = path$c.join(self.root, f); - } else if (isAbsolute$2(f) || f === '') { - abs = f; - } else if (self.changedCwd) { - abs = path$c.resolve(self.cwd, f); + if (state.position < (state.length - 1)) { + throwError$1(state, 'end of the stream or a document separator is expected'); } else { - abs = path$c.resolve(f); + return; } - - if (process.platform === 'win32') - abs = abs.replace(/\\/g, '/'); - - return abs -} - - -// Return true, if pattern ends with globstar '**', for the accompanying parent directory. -// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents -function isIgnored$2 (self, path) { - if (!self.ignore.length) - return false - - return self.ignore.some(function(item) { - return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) - }) -} - -function childrenIgnored$2 (self, path) { - if (!self.ignore.length) - return false - - return self.ignore.some(function(item) { - return !!(item.gmatcher && item.gmatcher.match(path)) - }) } -var sync$3 = globSync$1; -globSync$1.GlobSync = GlobSync$1; -var fs$c = require$$0__default$3['default']; -var rp$1 = fs_realpath; -var minimatch$1 = minimatch_1; -var path$b = require$$0__default$2['default']; -var assert$1 = require$$5__default['default']; -var isAbsolute$1 = pathIsAbsolute.exports; -var common$2 = common$3; -var setopts$1 = common$2.setopts; -var ownProp$1 = common$2.ownProp; -var childrenIgnored$1 = common$2.childrenIgnored; -var isIgnored$1 = common$2.isIgnored; +function loadDocuments(input, options) { + input = String(input); + options = options || {}; -function globSync$1 (pattern, options) { - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') + if (input.length !== 0) { - return new GlobSync$1(pattern, options).found -} + // Add tailing `\n` if not exists + if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && + input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { + input += '\n'; + } -function GlobSync$1 (pattern, options) { - if (!pattern) - throw new Error('must provide pattern') + // Strip BOM + if (input.charCodeAt(0) === 0xFEFF) { + input = input.slice(1); + } + } - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') + var state = new State$1(input, options); - if (!(this instanceof GlobSync$1)) - return new GlobSync$1(pattern, options) + var nullpos = input.indexOf('\0'); - setopts$1(this, pattern, options); + if (nullpos !== -1) { + state.position = nullpos; + throwError$1(state, 'null byte is not allowed in input'); + } - if (this.noprocess) - return this + // Use 0 as string terminator. That significantly simplifies bounds check. + state.input += '\0'; - var n = this.minimatch.set.length; - this.matches = new Array(n); - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false); + while (state.input.charCodeAt(state.position) === 0x20/* Space */) { + state.lineIndent += 1; + state.position += 1; } - this._finish(); -} -GlobSync$1.prototype._finish = function () { - assert$1(this instanceof GlobSync$1); - if (this.realpath) { - var self = this; - this.matches.forEach(function (matchset, index) { - var set = self.matches[index] = Object.create(null); - for (var p in matchset) { - try { - p = self._makeAbs(p); - var real = rp$1.realpathSync(p, self.realpathCache); - set[real] = true; - } catch (er) { - if (er.syscall === 'stat') - set[self._makeAbs(p)] = true; - else - throw er - } - } - }); + while (state.position < (state.length - 1)) { + readDocument(state); } - common$2.finish(this); -}; + return state.documents; +} -GlobSync$1.prototype._process = function (pattern, index, inGlobStar) { - assert$1(this instanceof GlobSync$1); - // Get the first [n] parts of pattern that are all strings. - var n = 0; - while (typeof pattern[n] === 'string') { - n ++; +function loadAll$1(input, iterator, options) { + if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { + options = iterator; + iterator = null; } - // now n is the index of the first one that is *not* a string. - // See if there's anything else - var prefix; - switch (n) { - // if not, then this is rather simple - case pattern.length: - this._processSimple(pattern.join('/'), index); - return - - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null; - break + var documents = loadDocuments(input, options); - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's 'absolute' like /foo/bar, - // or 'relative' like '../baz' - prefix = pattern.slice(0, n).join('/'); - break + if (typeof iterator !== 'function') { + return documents; } - var remain = pattern.slice(n); - - // get the list of entries. - var read; - if (prefix === null) - read = '.'; - else if (isAbsolute$1(prefix) || isAbsolute$1(pattern.join('/'))) { - if (!prefix || !isAbsolute$1(prefix)) - prefix = '/' + prefix; - read = prefix; - } else - read = prefix; + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} - var abs = this._makeAbs(read); - //if ignored, skip processing - if (childrenIgnored$1(this, read)) - return +function load$1(input, options) { + var documents = loadDocuments(input, options); - var isGlobStar = remain[0] === minimatch$1.GLOBSTAR; - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar); - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar); -}; + if (documents.length === 0) { + /*eslint-disable no-undefined*/ + return undefined; + } else if (documents.length === 1) { + return documents[0]; + } + throw new exception('expected a single document in the stream, but found more'); +} -GlobSync$1.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { - var entries = this._readdir(abs, inGlobStar); +var loadAll_1 = loadAll$1; +var load_1 = load$1; - // if the abs isn't a dir, then nothing can match! - if (!entries) - return +var loader = { + loadAll: loadAll_1, + load: load_1 +}; - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = remain[0]; - var negate = !!this.minimatch.negate; - var rawGlob = pn._glob; - var dotOk = this.dot || rawGlob.charAt(0) === '.'; +/*eslint-disable no-use-before-define*/ - var matchedEntries = []; - for (var i = 0; i < entries.length; i++) { - var e = entries[i]; - if (e.charAt(0) !== '.' || dotOk) { - var m; - if (negate && !prefix) { - m = !e.match(pn); - } else { - m = e.match(pn); - } - if (m) - matchedEntries.push(e); - } - } - var len = matchedEntries.length; - // If there are no matched entries, then nothing matches. - if (len === 0) - return - // if this is the last remaining pattern bit, then no need for - // an additional stat *unless* the user has specified mark or - // stat explicitly. We know they exist, since readdir returned - // them. - if (remain.length === 1 && !this.mark && !this.stat) { - if (!this.matches[index]) - this.matches[index] = Object.create(null); - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i]; - if (prefix) { - if (prefix.slice(-1) !== '/') - e = prefix + '/' + e; - else - e = prefix + e; - } +var _toString = Object.prototype.toString; +var _hasOwnProperty = Object.prototype.hasOwnProperty; - if (e.charAt(0) === '/' && !this.nomount) { - e = path$b.join(this.root, e); - } - this._emitMatch(index, e); - } - // This was the last one, and no stats were needed - return - } - - // now test all matched entries as stand-ins for that part - // of the pattern. - remain.shift(); - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i]; - var newPattern; - if (prefix) - newPattern = [prefix, e]; - else - newPattern = [e]; - this._process(newPattern.concat(remain), index, inGlobStar); - } -}; - - -GlobSync$1.prototype._emitMatch = function (index, e) { - if (isIgnored$1(this, e)) - return - - var abs = this._makeAbs(e); +var CHAR_BOM = 0xFEFF; +var CHAR_TAB = 0x09; /* Tab */ +var CHAR_LINE_FEED = 0x0A; /* LF */ +var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ +var CHAR_SPACE = 0x20; /* Space */ +var CHAR_EXCLAMATION = 0x21; /* ! */ +var CHAR_DOUBLE_QUOTE = 0x22; /* " */ +var CHAR_SHARP = 0x23; /* # */ +var CHAR_PERCENT = 0x25; /* % */ +var CHAR_AMPERSAND = 0x26; /* & */ +var CHAR_SINGLE_QUOTE = 0x27; /* ' */ +var CHAR_ASTERISK = 0x2A; /* * */ +var CHAR_COMMA = 0x2C; /* , */ +var CHAR_MINUS = 0x2D; /* - */ +var CHAR_COLON = 0x3A; /* : */ +var CHAR_EQUALS = 0x3D; /* = */ +var CHAR_GREATER_THAN = 0x3E; /* > */ +var CHAR_QUESTION = 0x3F; /* ? */ +var CHAR_COMMERCIAL_AT = 0x40; /* @ */ +var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ +var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ +var CHAR_GRAVE_ACCENT = 0x60; /* ` */ +var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ +var CHAR_VERTICAL_LINE = 0x7C; /* | */ +var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ - if (this.mark) - e = this._mark(e); +var ESCAPE_SEQUENCES = {}; - if (this.absolute) { - e = abs; - } +ESCAPE_SEQUENCES[0x00] = '\\0'; +ESCAPE_SEQUENCES[0x07] = '\\a'; +ESCAPE_SEQUENCES[0x08] = '\\b'; +ESCAPE_SEQUENCES[0x09] = '\\t'; +ESCAPE_SEQUENCES[0x0A] = '\\n'; +ESCAPE_SEQUENCES[0x0B] = '\\v'; +ESCAPE_SEQUENCES[0x0C] = '\\f'; +ESCAPE_SEQUENCES[0x0D] = '\\r'; +ESCAPE_SEQUENCES[0x1B] = '\\e'; +ESCAPE_SEQUENCES[0x22] = '\\"'; +ESCAPE_SEQUENCES[0x5C] = '\\\\'; +ESCAPE_SEQUENCES[0x85] = '\\N'; +ESCAPE_SEQUENCES[0xA0] = '\\_'; +ESCAPE_SEQUENCES[0x2028] = '\\L'; +ESCAPE_SEQUENCES[0x2029] = '\\P'; - if (this.matches[index][e]) - return +var DEPRECATED_BOOLEANS_SYNTAX = [ + 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', + 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' +]; - if (this.nodir) { - var c = this.cache[abs]; - if (c === 'DIR' || Array.isArray(c)) - return - } +var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; - this.matches[index][e] = true; +function compileStyleMap(schema, map) { + var result, keys, index, length, tag, style, type; - if (this.stat) - this._stat(e); -}; + if (map === null) return {}; + result = {}; + keys = Object.keys(map); -GlobSync$1.prototype._readdirInGlobStar = function (abs) { - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false) + for (index = 0, length = keys.length; index < length; index += 1) { + tag = keys[index]; + style = String(map[tag]); - var entries; - var lstat; - try { - lstat = fs$c.lstatSync(abs); - } catch (er) { - if (er.code === 'ENOENT') { - // lstat failed, doesn't exist - return null + if (tag.slice(0, 2) === '!!') { + tag = 'tag:yaml.org,2002:' + tag.slice(2); } - } - - var isSym = lstat && lstat.isSymbolicLink(); - this.symlinks[abs] = isSym; - - // If it's not a symlink or a dir, then it's definitely a regular file. - // don't bother doing a readdir in that case. - if (!isSym && lstat && !lstat.isDirectory()) - this.cache[abs] = 'FILE'; - else - entries = this._readdir(abs, false); + type = schema.compiledTypeMap['fallback'][tag]; - return entries -}; + if (type && _hasOwnProperty.call(type.styleAliases, style)) { + style = type.styleAliases[style]; + } -GlobSync$1.prototype._readdir = function (abs, inGlobStar) { + result[tag] = style; + } - if (inGlobStar && !ownProp$1(this.symlinks, abs)) - return this._readdirInGlobStar(abs) + return result; +} - if (ownProp$1(this.cache, abs)) { - var c = this.cache[abs]; - if (!c || c === 'FILE') - return null +function encodeHex(character) { + var string, handle, length; - if (Array.isArray(c)) - return c - } + string = character.toString(16).toUpperCase(); - try { - return this._readdirEntries(abs, fs$c.readdirSync(abs)) - } catch (er) { - this._readdirError(abs, er); - return null + if (character <= 0xFF) { + handle = 'x'; + length = 2; + } else if (character <= 0xFFFF) { + handle = 'u'; + length = 4; + } else if (character <= 0xFFFFFFFF) { + handle = 'U'; + length = 8; + } else { + throw new exception('code point within a string may not be greater than 0xFFFFFFFF'); } -}; -GlobSync$1.prototype._readdirEntries = function (abs, entries) { - // if we haven't asked to stat everything, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. - if (!this.mark && !this.stat) { - for (var i = 0; i < entries.length; i ++) { - var e = entries[i]; - if (abs === '/') - e = abs + e; - else - e = abs + '/' + e; - this.cache[e] = true; - } - } + return '\\' + handle + common$4.repeat('0', length - string.length) + string; +} - this.cache[abs] = entries; - // mark and cache dir-ness - return entries -}; +var QUOTING_TYPE_SINGLE = 1, + QUOTING_TYPE_DOUBLE = 2; -GlobSync$1.prototype._readdirError = function (f, er) { - // handle errors, and cache the information - switch (er.code) { - case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 - case 'ENOTDIR': // totally normal. means it *does* exist. - var abs = this._makeAbs(f); - this.cache[abs] = 'FILE'; - if (abs === this.cwdAbs) { - var error = new Error(er.code + ' invalid cwd ' + this.cwd); - error.path = this.cwd; - error.code = er.code; - throw error - } - break +function State(options) { + this.schema = options['schema'] || _default$1; + this.indent = Math.max(1, (options['indent'] || 2)); + this.noArrayIndent = options['noArrayIndent'] || false; + this.skipInvalid = options['skipInvalid'] || false; + this.flowLevel = (common$4.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; - case 'ENOENT': // not terribly unusual - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false; - break + this.implicitTypes = this.schema.compiledImplicit; + this.explicitTypes = this.schema.compiledExplicit; - default: // some unusual error. Treat as failure. - this.cache[this._makeAbs(f)] = false; - if (this.strict) - throw er - if (!this.silent) - console.error('glob error', er); - break - } -}; + this.tag = null; + this.result = ''; -GlobSync$1.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { + this.duplicates = []; + this.usedDuplicates = null; +} - var entries = this._readdir(abs, inGlobStar); +// Indents every line in a string. Empty lines (\n only) are not indented. +function indentString(string, spaces) { + var ind = common$4.repeat(' ', spaces), + position = 0, + next = -1, + result = '', + line, + length = string.length; - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return + 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; + } - // test without the globstar, and with every child both below - // and replacing the globstar. - var remainWithoutGlobStar = remain.slice(1); - var gspref = prefix ? [ prefix ] : []; - var noGlobStar = gspref.concat(remainWithoutGlobStar); + if (line.length && line !== '\n') result += ind; - // the noGlobStar pattern exits the inGlobStar state - this._process(noGlobStar, index, false); + result += line; + } - var len = entries.length; - var isSym = this.symlinks[abs]; + return result; +} - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return +function generateNextLine(state, level) { + return '\n' + common$4.repeat(' ', state.indent * level); +} - for (var i = 0; i < len; i++) { - var e = entries[i]; - if (e.charAt(0) === '.' && !this.dot) - continue +function testImplicitResolving(state, str) { + var index, length, type; - // these two cases enter the inGlobStar state - var instead = gspref.concat(entries[i], remainWithoutGlobStar); - this._process(instead, index, true); + for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { + type = state.implicitTypes[index]; - var below = gspref.concat(entries[i], remain); - this._process(below, index, true); + if (type.resolve(str)) { + return true; + } } -}; -GlobSync$1.prototype._processSimple = function (prefix, index) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var exists = this._stat(prefix); + return false; +} - if (!this.matches[index]) - this.matches[index] = Object.create(null); +// [33] s-white ::= s-space | s-tab +function isWhitespace(c) { + return c === CHAR_SPACE || c === CHAR_TAB; +} - // If it doesn't exist, then just mark the lack of results - if (!exists) - return +// Returns true if the character can be printed without escaping. +// From YAML 1.2: "any allowed characters known to be non-printable +// should also be escaped. [However,] This isn’t mandatory" +// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. +function isPrintable(c) { + return (0x00020 <= c && c <= 0x00007E) + || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) + || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) + || (0x10000 <= c && c <= 0x10FFFF); +} - if (prefix && isAbsolute$1(prefix) && !this.nomount) { - var trail = /[\/\\]$/.test(prefix); - if (prefix.charAt(0) === '/') { - prefix = path$b.join(this.root, prefix); - } else { - prefix = path$b.resolve(this.root, prefix); - if (trail) - prefix += '/'; - } - } +// [34] ns-char ::= nb-char - s-white +// [27] nb-char ::= c-printable - b-char - c-byte-order-mark +// [26] b-char ::= b-line-feed | b-carriage-return +// Including s-white (for some reason, examples doesn't match specs in this aspect) +// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark +function isNsCharOrWhitespace(c) { + return isPrintable(c) + && c !== CHAR_BOM + // - b-char + && c !== CHAR_CARRIAGE_RETURN + && c !== CHAR_LINE_FEED; +} - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/'); +// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out +// c = flow-in ⇒ ns-plain-safe-in +// c = block-key ⇒ ns-plain-safe-out +// c = flow-key ⇒ ns-plain-safe-in +// [128] ns-plain-safe-out ::= ns-char +// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator +// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) +// | ( /* An ns-char preceding */ “#” ) +// | ( “:” /* Followed by an ns-plain-safe(c) */ ) +function isPlainSafe(c, prev, inblock) { + var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); + var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); + return ( + // ns-plain-safe + inblock ? // c = flow-in + cIsNsCharOrWhitespace + : cIsNsCharOrWhitespace + // - c-flow-indicator + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + ) + // ns-plain-char + && c !== CHAR_SHARP // false on '#' + && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' + || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' + || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' +} - // Mark this as a match - this._emitMatch(index, prefix); -}; +// Simplified test for values allowed as the first character in plain style. +function isPlainSafeFirst(c) { + // Uses a subset of ns-char - c-indicator + // where ns-char = nb-char - s-white. + // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part + return isPrintable(c) && c !== CHAR_BOM + && !isWhitespace(c) // - s-white + // - (c-indicator ::= + // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” + && 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; +} -// Returns either 'DIR', 'FILE', or false -GlobSync$1.prototype._stat = function (f) { - var abs = this._makeAbs(f); - var needDir = f.slice(-1) === '/'; +// Simplified test for values allowed as the last character in plain style. +function isPlainSafeLast(c) { + // just not whitespace or colon, it will be checked to be plain character later + return !isWhitespace(c) && c !== CHAR_COLON; +} - if (f.length > this.maxLength) - return false +// Same as 'string'.codePointAt(pos), but works in older browsers. +function codePointAt(string, pos) { + var first = string.charCodeAt(pos), second; + if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { + second = string.charCodeAt(pos + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; +} - if (!this.stat && ownProp$1(this.cache, abs)) { - var c = this.cache[abs]; +// Determines whether block indentation indicator is required. +function needIndentIndicator(string) { + var leadingSpaceRe = /^\n* /; + return leadingSpaceRe.test(string); +} - if (Array.isArray(c)) - c = 'DIR'; +var STYLE_PLAIN = 1, + STYLE_SINGLE = 2, + STYLE_LITERAL = 3, + STYLE_FOLDED = 4, + STYLE_DOUBLE = 5; - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return c +// Determines which scalar styles are possible and returns the preferred style. +// lineWidth = -1 => no limit. +// Pre-conditions: str.length > 0. +// Post-conditions: +// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. +// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). +// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). +function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, + testAmbiguousType, quotingType, forceQuotes, inblock) { - if (needDir && c === 'FILE') - return false + var i; + var char = 0; + var prevChar = null; + var hasLineBreak = false; + var hasFoldableLine = false; // only checked if shouldTrackWidth + var shouldTrackWidth = lineWidth !== -1; + var previousLineBreak = -1; // count the first line correctly + var plain = isPlainSafeFirst(codePointAt(string, 0)) + && isPlainSafeLast(codePointAt(string, string.length - 1)); - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } - var stat = this.statCache[abs]; - if (!stat) { - var lstat; - try { - lstat = fs$c.lstatSync(abs); - } catch (er) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false; - return false + if (singleLineOnly || forceQuotes) { + // Case: no block styles. + // Check for disallowed characters to rule out plain and single. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (!isPrintable(char)) { + return STYLE_DOUBLE; } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; } - - if (lstat && lstat.isSymbolicLink()) { - try { - stat = fs$c.statSync(abs); - } catch (er) { - stat = lstat; + } else { + // Case: block styles permitted. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (char === CHAR_LINE_FEED) { + hasLineBreak = true; + // Check if any line can be folded. + if (shouldTrackWidth) { + hasFoldableLine = hasFoldableLine || + // Foldable line = too long, and not more-indented. + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' '); + previousLineBreak = i; + } + } else if (!isPrintable(char)) { + return STYLE_DOUBLE; } - } else { - stat = lstat; + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; } + // in case the end is missing a \n + hasFoldableLine = hasFoldableLine || (shouldTrackWidth && + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' ')); } - - this.statCache[abs] = stat; - - var c = true; - if (stat) - c = stat.isDirectory() ? 'DIR' : 'FILE'; - - this.cache[abs] = this.cache[abs] || c; - - if (needDir && c === 'FILE') - return false - - return c -}; - -GlobSync$1.prototype._mark = function (p) { - return common$2.mark(this, p) -}; - -GlobSync$1.prototype._makeAbs = function (f) { - return common$2.makeAbs(this, f) -}; - -// Returns a wrapper function that returns a wrapped callback -// The wrapper function should do some stuff, and return a -// presumably different callback function. -// This makes sure that own properties are retained, so that -// decorations and such are not lost along the way. -var wrappy_1 = wrappy$2; -function wrappy$2 (fn, cb) { - if (fn && cb) return wrappy$2(fn)(cb) - - if (typeof fn !== 'function') - throw new TypeError('need wrapper function') - - Object.keys(fn).forEach(function (k) { - wrapper[k] = fn[k]; - }); - - return wrapper - - function wrapper() { - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - var ret = fn.apply(this, args); - var cb = args[args.length-1]; - if (typeof ret === 'function' && ret !== cb) { - Object.keys(cb).forEach(function (k) { - ret[k] = cb[k]; - }); + // Although every style can represent \n without escaping, prefer block styles + // for multiline, since they're more readable and they don't add empty lines. + // Also prefer folding a super-long line. + if (!hasLineBreak && !hasFoldableLine) { + // Strings interpretable as another type have to be quoted; + // e.g. the string 'true' vs. the boolean true. + if (plain && !forceQuotes && !testAmbiguousType(string)) { + return STYLE_PLAIN; } - return ret + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; + } + // Edge case: block indentation indicator can only have one digit. + if (indentPerLevel > 9 && needIndentIndicator(string)) { + return STYLE_DOUBLE; + } + // At this point we know block styles are valid. + // Prefer literal style unless we want to fold. + if (!forceQuotes) { + return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; } -var once$3 = {exports: {}}; - -var wrappy$1 = wrappy_1; -once$3.exports = wrappy$1(once$2); -once$3.exports.strict = wrappy$1(onceStrict); +// Note: line breaking/folding is implemented for only the folded style. +// NB. We drop the last trailing newline (if any) of a returned block scalar +// since the dumper adds its own newline. This always works: +// • No ending newline => unaffected; already using strip "-" chomping. +// • Ending newline => removed then restored. +// Importantly, this keeps the "+" chomp indicator from gaining an extra line. +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 + "'"); + } + } -once$2.proto = once$2(function () { - Object.defineProperty(Function.prototype, 'once', { - value: function () { - return once$2(this) - }, - configurable: true - }); + var indent = state.indent * Math.max(1, level); // no 0-indent scalars + // As indentation gets deeper, let the width decrease monotonically + // to the lower bound min(state.lineWidth, 40). + // Note that this implies + // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. + // state.lineWidth > 40 + state.indent: width decreases until the lower bound. + // This behaves better than a constant minimum width which disallows narrower options, + // or an indent threshold which causes the width to suddenly increase. + var lineWidth = state.lineWidth === -1 + ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); - Object.defineProperty(Function.prototype, 'onceStrict', { - value: function () { - return onceStrict(this) - }, - configurable: true - }); -}); + // Without knowing if keys are implicit/explicit, assume implicit for safety. + var singleLineOnly = iskey + // No block styles in flow mode. + || (state.flowLevel > -1 && level >= state.flowLevel); + function testAmbiguity(string) { + return testImplicitResolving(state, string); + } -function once$2 (fn) { - var f = function () { - if (f.called) return f.value - f.called = true; - return f.value = fn.apply(this, arguments) - }; - f.called = false; - return f -} + switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, + testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { -function onceStrict (fn) { - var f = function () { - if (f.called) - throw new Error(f.onceError) - f.called = true; - return f.value = fn.apply(this, arguments) - }; - var name = fn.name || 'Function wrapped with `once`'; - f.onceError = name + " shouldn't be called more than once"; - f.called = false; - return f + 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'); + } + }()); } -var wrappy = wrappy_1; -var reqs = Object.create(null); -var once$1 = once$3.exports; +// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. +function blockHeader(string, indentPerLevel) { + var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; -var inflight_1 = wrappy(inflight$1); + // note the special case: the string '\n' counts as a "trailing" empty line. + var clip = string[string.length - 1] === '\n'; + var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); + var chomp = keep ? '+' : (clip ? '' : '-'); -function inflight$1 (key, cb) { - if (reqs[key]) { - reqs[key].push(cb); - return null - } else { - reqs[key] = [cb]; - return makeres(key) - } + return indentIndicator + chomp + '\n'; } -function makeres (key) { - return once$1(function RES () { - var cbs = reqs[key]; - var len = cbs.length; - var args = slice$2(arguments); - - // XXX It's somewhat ambiguous whether a new callback added in this - // pass should be queued for later execution if something in the - // list of callbacks throws, or if it should just be discarded. - // However, it's such an edge case that it hardly matters, and either - // choice is likely as surprising as the other. - // As it happens, we do go ahead and schedule it for later execution. - try { - for (var i = 0; i < len; i++) { - cbs[i].apply(null, args); - } - } finally { - if (cbs.length > len) { - // added more in the interim. - // de-zalgo, just in case, but don't call again. - cbs.splice(0, len); - process.nextTick(function () { - RES.apply(null, args); - }); - } else { - delete reqs[key]; - } - } - }) +// (See the note for writeScalar.) +function dropEndingNewline(string) { + return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; } -function slice$2 (args) { - var length = args.length; - var array = []; +// Note: a long line without a suitable break point will exceed the width limit. +// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. +function foldString(string, width) { + // In folded style, $k$ consecutive newlines output as $k+1$ newlines— + // unless they're before or after a more-indented line, or at the very + // beginning or end, in which case $k$ maps to $k$. + // Therefore, parse each chunk as newline(s) followed by a content line. + var lineRe = /(\n+)([^\n]*)/g; - for (var i = 0; i < length; i++) array[i] = args[i]; - return array -} + // first line (possibly an empty line) + var result = (function () { + var nextLF = string.indexOf('\n'); + nextLF = nextLF !== -1 ? nextLF : string.length; + lineRe.lastIndex = nextLF; + return foldLine(string.slice(0, nextLF), width); + }()); + // If we haven't reached the first content line yet, don't add an extra \n. + var prevMoreIndented = string[0] === '\n' || string[0] === ' '; + var moreIndented; -// Approach: -// -// 1. Get the minimatch set -// 2. For each pattern in the set, PROCESS(pattern, false) -// 3. Store matches per-set, then uniq them -// -// PROCESS(pattern, inGlobStar) -// Get the first [n] items from pattern that are all strings -// Join these together. This is PREFIX. -// If there is no more remaining, then stat(PREFIX) and -// add to matches if it succeeds. END. -// -// If inGlobStar and PREFIX is symlink and points to dir -// set ENTRIES = [] -// else readdir(PREFIX) as ENTRIES -// If fail, END -// -// with ENTRIES -// If pattern[n] is GLOBSTAR -// // handle the case where the globstar match is empty -// // by pruning it out, and testing the resulting pattern -// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) -// // handle other cases. -// for ENTRY in ENTRIES (not dotfiles) -// // attach globstar + tail onto the entry -// // Mark that this entry is a globstar match -// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) -// -// else // not globstar -// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) -// Test ENTRY against pattern[n] -// If fails, continue -// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) -// -// Caveat: -// Cache all stats and readdirs results to minimize syscall. Since all -// we ever care about is existence and directory-ness, we can just keep -// `true` for files, and [children,...] for directories, or `false` for -// things that don't exist. + // rest of the lines + 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; + } -var glob_1 = glob$1; + return result; +} -var fs$b = require$$0__default$3['default']; -var rp = fs_realpath; -var minimatch = minimatch_1; -var inherits$2 = inherits$3.exports; -var EE = require$$0__default$4['default'].EventEmitter; -var path$a = require$$0__default$2['default']; -var assert = require$$5__default['default']; -var isAbsolute = pathIsAbsolute.exports; -var globSync = sync$3; -var common$1 = common$3; -var setopts = common$1.setopts; -var ownProp = common$1.ownProp; -var inflight = inflight_1; -var childrenIgnored = common$1.childrenIgnored; -var isIgnored = common$1.isIgnored; +// Greedy line breaking. +// Picks the longest line under the limit each time, +// otherwise settles for the shortest line over the limit. +// NB. More-indented lines *cannot* be folded, as that would add an extra \n. +function foldLine(line, width) { + if (line === '' || line[0] === ' ') return line; -var once = once$3.exports; + // Since a more-indented line adds a \n, breaks can't be followed by a space. + var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. + var match; + // start is an inclusive index. end, curr, and next are exclusive. + var start = 0, end, curr = 0, next = 0; + var result = ''; -function glob$1 (pattern, options, cb) { - if (typeof options === 'function') cb = options, options = {}; - if (!options) options = {}; + // Invariants: 0 <= start <= length-1. + // 0 <= curr <= next <= max(0, length-2). curr - start <= width. + // Inside the loop: + // A match implies length >= 2, so curr and next are <= length-2. + while ((match = breakRe.exec(line))) { + next = match.index; + // maintain invariant: curr - start <= width + if (next - start > width) { + end = (curr > start) ? curr : next; // derive end <= length-2 + result += '\n' + line.slice(start, end); + // skip the space that was output as \n + start = end + 1; // derive start <= length-1 + } + curr = next; + } - if (options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return globSync(pattern, options) + // By the invariants, start <= length-1, so there is something left over. + // It is either the whole string or a part starting from non-whitespace. + result += '\n'; + // Insert a break if the remainder is too long and there is a break available. + if (line.length - start > width && curr > start) { + result += line.slice(start, curr) + '\n' + line.slice(curr + 1); + } else { + result += line.slice(start); } - return new Glob(pattern, options, cb) + return result.slice(1); // drop extra \n joiner } -glob$1.sync = globSync; -var GlobSync = glob$1.GlobSync = globSync.GlobSync; +// Escapes a double-quoted string. +function escapeString(string) { + var result = ''; + var char = 0; + var escapeSeq; -// old api surface -glob$1.glob = glob$1; + for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + escapeSeq = ESCAPE_SEQUENCES[char]; -function extend$3 (origin, add) { - if (add === null || typeof add !== 'object') { - return origin + if (!escapeSeq && isPrintable(char)) { + result += string[i]; + if (char >= 0x10000) result += string[i + 1]; + } else { + result += escapeSeq || encodeHex(char); + } } - var keys = Object.keys(add); - var i = keys.length; - while (i--) { - origin[keys[i]] = add[keys[i]]; - } - return origin + return result; } -glob$1.hasMagic = function (pattern, options_) { - var options = extend$3({}, options_); - options.noprocess = true; +function writeFlowSequence(state, level, object) { + var _result = '', + _tag = state.tag, + index, + length, + value; - var g = new Glob(pattern, options); - var set = g.minimatch.set; + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; - if (!pattern) - return false + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } - if (set.length > 1) - return true + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level, value, false, false) || + (typeof value === 'undefined' && + writeNode(state, level, null, false, false))) { - for (var j = 0; j < set[0].length; j++) { - if (typeof set[0][j] !== 'string') - return true + if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); + _result += state.dump; + } } - return false -}; + state.tag = _tag; + state.dump = '[' + _result + ']'; +} -glob$1.Glob = Glob; -inherits$2(Glob, EE); -function Glob (pattern, options, cb) { - if (typeof options === 'function') { - cb = options; - options = null; - } +function writeBlockSequence(state, level, object, compact) { + var _result = '', + _tag = state.tag, + index, + length, + value; - if (options && options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return new GlobSync(pattern, options) - } + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; - if (!(this instanceof Glob)) - return new Glob(pattern, options, cb) + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } - setopts(this, pattern, options); - this._didRealPath = false; + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level + 1, value, true, true, false, true) || + (typeof value === 'undefined' && + writeNode(state, level + 1, null, true, true, false, true))) { - // process each pattern in the minimatch set - var n = this.minimatch.set.length; + if (!compact || _result !== '') { + _result += generateNextLine(state, level); + } - // The matches are stored as {: true,...} so that - // duplicates are automagically pruned. - // Later, we do an Object.keys() on these. - // Keep them as a list so we can fill in when nonull is set. - this.matches = new Array(n); + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + _result += '-'; + } else { + _result += '- '; + } - if (typeof cb === 'function') { - cb = once(cb); - this.on('error', cb); - this.on('end', function (matches) { - cb(null, matches); - }); + _result += state.dump; + } } - var self = this; - this._processing = 0; + state.tag = _tag; + state.dump = _result || '[]'; // Empty sequence if no valid values. +} - this._emitQueue = []; - this._processQueue = []; - this.paused = false; +function writeFlowMapping(state, level, object) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + pairBuffer; - if (this.noprocess) - return this + for (index = 0, length = objectKeyList.length; index < length; index += 1) { - if (n === 0) - return done() + pairBuffer = ''; + if (_result !== '') pairBuffer += ', '; - var sync = true; - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false, done); - } - sync = false; + if (state.condenseFlow) pairBuffer += '"'; - function done () { - --self._processing; - if (self._processing <= 0) { - if (sync) { - process.nextTick(function () { - self._finish(); - }); - } else { - self._finish(); - } + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); } - } -} -Glob.prototype._finish = function () { - assert(this instanceof Glob); - if (this.aborted) - return + if (!writeNode(state, level, objectKey, false, false)) { + continue; // Skip this pair because of invalid key; + } - if (this.realpath && !this._didRealpath) - return this._realpath() + if (state.dump.length > 1024) pairBuffer += '? '; - common$1.finish(this); - this.emit('end', this.found); -}; + pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); -Glob.prototype._realpath = function () { - if (this._didRealpath) - return + if (!writeNode(state, level, objectValue, false, false)) { + continue; // Skip this pair because of invalid value. + } - this._didRealpath = true; + pairBuffer += state.dump; - var n = this.matches.length; - if (n === 0) - return this._finish() - - var self = this; - for (var i = 0; i < this.matches.length; i++) - this._realpathSet(i, next); - - function next () { - if (--n === 0) - self._finish(); + // Both key and value are valid. + _result += pairBuffer; } -}; -Glob.prototype._realpathSet = function (index, cb) { - var matchset = this.matches[index]; - if (!matchset) - return cb() + state.tag = _tag; + state.dump = '{' + _result + '}'; +} - var found = Object.keys(matchset); - var self = this; - var n = found.length; +function writeBlockMapping(state, level, object, compact) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + explicitPair, + pairBuffer; - if (n === 0) - return cb() + // Allow sorting keys so that the output file is deterministic + if (state.sortKeys === true) { + // Default sorting + objectKeyList.sort(); + } else if (typeof state.sortKeys === 'function') { + // Custom sort function + objectKeyList.sort(state.sortKeys); + } else if (state.sortKeys) { + // Something is wrong + throw new exception('sortKeys must be a boolean or a function'); + } - var set = this.matches[index] = Object.create(null); - found.forEach(function (p, i) { - // If there's a problem with the stat, then it means that - // one or more of the links in the realpath couldn't be - // resolved. just return the abs value in that case. - p = self._makeAbs(p); - rp.realpath(p, self.realpathCache, function (er, real) { - if (!er) - set[real] = true; - else if (er.syscall === 'stat') - set[p] = true; - else - self.emit('error', er); // srsly wtf right here + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = ''; - if (--n === 0) { - self.matches[index] = set; - cb(); - } - }); - }); -}; + if (!compact || _result !== '') { + pairBuffer += generateNextLine(state, level); + } -Glob.prototype._mark = function (p) { - return common$1.mark(this, p) -}; + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; -Glob.prototype._makeAbs = function (f) { - return common$1.makeAbs(this, f) -}; + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } -Glob.prototype.abort = function () { - this.aborted = true; - this.emit('abort'); -}; + if (!writeNode(state, level + 1, objectKey, true, true, true)) { + continue; // Skip this pair because of invalid key. + } -Glob.prototype.pause = function () { - if (!this.paused) { - this.paused = true; - this.emit('pause'); - } -}; + explicitPair = (state.tag !== null && state.tag !== '?') || + (state.dump && state.dump.length > 1024); -Glob.prototype.resume = function () { - if (this.paused) { - this.emit('resume'); - this.paused = false; - if (this._emitQueue.length) { - var eq = this._emitQueue.slice(0); - this._emitQueue.length = 0; - for (var i = 0; i < eq.length; i ++) { - var e = eq[i]; - this._emitMatch(e[0], e[1]); - } - } - if (this._processQueue.length) { - var pq = this._processQueue.slice(0); - this._processQueue.length = 0; - for (var i = 0; i < pq.length; i ++) { - var p = pq[i]; - this._processing--; - this._process(p[0], p[1], p[2], p[3]); + if (explicitPair) { + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += '?'; + } else { + pairBuffer += '? '; } } - } -}; - -Glob.prototype._process = function (pattern, index, inGlobStar, cb) { - assert(this instanceof Glob); - assert(typeof cb === 'function'); - - if (this.aborted) - return - this._processing++; - if (this.paused) { - this._processQueue.push([pattern, index, inGlobStar, cb]); - return - } + pairBuffer += state.dump; - //console.error('PROCESS %d', this._processing, pattern) + if (explicitPair) { + pairBuffer += generateNextLine(state, level); + } - // Get the first [n] parts of pattern that are all strings. - var n = 0; - while (typeof pattern[n] === 'string') { - n ++; - } - // now n is the index of the first one that is *not* a string. + if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { + continue; // Skip this pair because of invalid value. + } - // see if there's anything else - var prefix; - switch (n) { - // if not, then this is rather simple - case pattern.length: - this._processSimple(pattern.join('/'), index, cb); - return + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += ':'; + } else { + pairBuffer += ': '; + } - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null; - break + pairBuffer += state.dump; - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's 'absolute' like /foo/bar, - // or 'relative' like '../baz' - prefix = pattern.slice(0, n).join('/'); - break + // Both key and value are valid. + _result += pairBuffer; } - var remain = pattern.slice(n); - - // get the list of entries. - var read; - if (prefix === null) - read = '.'; - else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { - if (!prefix || !isAbsolute(prefix)) - prefix = '/' + prefix; - read = prefix; - } else - read = prefix; + state.tag = _tag; + state.dump = _result || '{}'; // Empty mapping if no valid pairs. +} - var abs = this._makeAbs(read); +function detectType(state, object, explicit) { + var _result, typeList, index, length, type, style; - //if ignored, skip _processing - if (childrenIgnored(this, read)) - return cb() + typeList = explicit ? state.explicitTypes : state.implicitTypes; - var isGlobStar = remain[0] === minimatch.GLOBSTAR; - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb); - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb); -}; + for (index = 0, length = typeList.length; index < length; index += 1) { + type = typeList[index]; -Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { - var self = this; - this._readdir(abs, inGlobStar, function (er, entries) { - return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) - }); -}; + if ((type.instanceOf || type.predicate) && + (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && + (!type.predicate || type.predicate(object))) { -Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + if (explicit) { + if (type.multi && type.representName) { + state.tag = type.representName(object); + } else { + state.tag = type.tag; + } + } else { + state.tag = '?'; + } - // if the abs isn't a dir, then nothing can match! - if (!entries) - return cb() + if (type.represent) { + style = state.styleMap[type.tag] || type.defaultStyle; - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = remain[0]; - var negate = !!this.minimatch.negate; - var rawGlob = pn._glob; - var dotOk = this.dot || rawGlob.charAt(0) === '.'; + if (_toString.call(type.represent) === '[object Function]') { + _result = type.represent(object, style); + } else if (_hasOwnProperty.call(type.represent, style)) { + _result = type.represent[style](object, style); + } else { + throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + } - var matchedEntries = []; - for (var i = 0; i < entries.length; i++) { - var e = entries[i]; - if (e.charAt(0) !== '.' || dotOk) { - var m; - if (negate && !prefix) { - m = !e.match(pn); - } else { - m = e.match(pn); + state.dump = _result; } - if (m) - matchedEntries.push(e); + + return true; } } - //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) + return false; +} - var len = matchedEntries.length; - // If there are no matched entries, then nothing matches. - if (len === 0) - return cb() +// Serializes `object` and writes it to global `result`. +// Returns true on success, or false on invalid object. +// +function writeNode(state, level, object, block, compact, iskey, isblockseq) { + state.tag = null; + state.dump = object; - // if this is the last remaining pattern bit, then no need for - // an additional stat *unless* the user has specified mark or - // stat explicitly. We know they exist, since readdir returned - // them. + if (!detectType(state, object, false)) { + detectType(state, object, true); + } - if (remain.length === 1 && !this.mark && !this.stat) { - if (!this.matches[index]) - this.matches[index] = Object.create(null); + var type = _toString.call(state.dump); + var inblock = block; + var tagStr; - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i]; - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e; - else - e = prefix + e; - } + if (block) { + block = (state.flowLevel < 0 || state.flowLevel > level); + } - if (e.charAt(0) === '/' && !this.nomount) { - e = path$a.join(this.root, e); - } - this._emitMatch(index, e); - } - // This was the last one, and no stats were needed - return cb() + var objectOrArray = type === '[object Object]' || type === '[object Array]', + duplicateIndex, + duplicate; + + if (objectOrArray) { + duplicateIndex = state.duplicates.indexOf(object); + duplicate = duplicateIndex !== -1; } - // now test all matched entries as stand-ins for that part - // of the pattern. - remain.shift(); - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i]; - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e; - else - e = prefix + e; - } - this._process([e].concat(remain), index, inGlobStar, cb); + if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { + compact = false; } - cb(); -}; -Glob.prototype._emitMatch = function (index, e) { - if (this.aborted) - return + if (duplicate && state.usedDuplicates[duplicateIndex]) { + state.dump = '*ref_' + duplicateIndex; + } else { + if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { + state.usedDuplicates[duplicateIndex] = true; + } + if (type === '[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 === '[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 === '[object String]') { + if (state.tag !== '?') { + writeScalar(state, state.dump, level, iskey, inblock); + } + } else if (type === '[object Undefined]') { + return false; + } else { + if (state.skipInvalid) return false; + throw new exception('unacceptable kind of an object to dump ' + type); + } - if (isIgnored(this, e)) - return + if (state.tag !== null && state.tag !== '?') { + // Need to encode all characters except those allowed by the spec: + // + // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ + // [36] ns-hex-digit ::= ns-dec-digit + // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ + // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ + // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” + // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” + // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” + // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” + // + // Also need to encode '!' because it has special meaning (end of tag prefix). + // + tagStr = encodeURI( + state.tag[0] === '!' ? state.tag.slice(1) : state.tag + ).replace(/!/g, '%21'); - if (this.paused) { - this._emitQueue.push([index, e]); - return - } + if (state.tag[0] === '!') { + tagStr = '!' + tagStr; + } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { + tagStr = '!!' + tagStr.slice(18); + } else { + tagStr = '!<' + tagStr + '>'; + } - var abs = isAbsolute(e) ? e : this._makeAbs(e); + state.dump = tagStr + ' ' + state.dump; + } + } - if (this.mark) - e = this._mark(e); + return true; +} - if (this.absolute) - e = abs; +function getDuplicateReferences(object, state) { + var objects = [], + duplicatesIndexes = [], + index, + length; - if (this.matches[index][e]) - return + inspectNode(object, objects, duplicatesIndexes); - if (this.nodir) { - var c = this.cache[abs]; - if (c === 'DIR' || Array.isArray(c)) - return + for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { + state.duplicates.push(objects[duplicatesIndexes[index]]); } + state.usedDuplicates = new Array(length); +} - this.matches[index][e] = true; - - var st = this.statCache[abs]; - if (st) - this.emit('stat', e, st); +function inspectNode(object, objects, duplicatesIndexes) { + var objectKeyList, + index, + length; - this.emit('match', e); -}; + 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); -Glob.prototype._readdirInGlobStar = function (abs, cb) { - if (this.aborted) - return + if (Array.isArray(object)) { + for (index = 0, length = object.length; index < length; index += 1) { + inspectNode(object[index], objects, duplicatesIndexes); + } + } else { + objectKeyList = Object.keys(object); - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false, cb) + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + } + } + } + } +} - var lstatkey = 'lstat\0' + abs; - var self = this; - var lstatcb = inflight(lstatkey, lstatcb_); +function dump$1(input, options) { + options = options || {}; - if (lstatcb) - fs$b.lstat(abs, lstatcb); + var state = new State(options); - function lstatcb_ (er, lstat) { - if (er && er.code === 'ENOENT') - return cb() + if (!state.noRefs) getDuplicateReferences(input, state); - var isSym = lstat && lstat.isSymbolicLink(); - self.symlinks[abs] = isSym; + var value = input; - // If it's not a symlink or a dir, then it's definitely a regular file. - // don't bother doing a readdir in that case. - if (!isSym && lstat && !lstat.isDirectory()) { - self.cache[abs] = 'FILE'; - cb(); - } else - self._readdir(abs, false, cb); + if (state.replacer) { + value = state.replacer.call({ '': value }, '', value); } -}; - -Glob.prototype._readdir = function (abs, inGlobStar, cb) { - if (this.aborted) - return - cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb); - if (!cb) - return + if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; - //console.error('RD %j %j', +inGlobStar, abs) - if (inGlobStar && !ownProp(this.symlinks, abs)) - return this._readdirInGlobStar(abs, cb) + return ''; +} - if (ownProp(this.cache, abs)) { - var c = this.cache[abs]; - if (!c || c === 'FILE') - return cb() +var dump_1 = dump$1; - if (Array.isArray(c)) - return cb(null, c) - } - fs$b.readdir(abs, readdirCb(this, abs, cb)); +var dumper = { + dump: dump_1 }; -function readdirCb (self, abs, cb) { - return function (er, entries) { - if (er) - self._readdirError(abs, er, cb); - else - self._readdirEntries(abs, entries, cb); - } +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.'); + }; } -Glob.prototype._readdirEntries = function (abs, entries, cb) { - if (this.aborted) - return - // if we haven't asked to stat everything, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. - if (!this.mark && !this.stat) { - for (var i = 0; i < entries.length; i ++) { - var e = entries[i]; - if (abs === '/') - e = abs + e; - else - e = abs + '/' + e; - this.cache[e] = true; - } - } +var Type = type$1; +var Schema = schema$1; +var FAILSAFE_SCHEMA = failsafe; +var JSON_SCHEMA = json; +var CORE_SCHEMA = core; +var DEFAULT_SCHEMA = _default$1; +var load = loader.load; +var loadAll = loader.loadAll; +var dump = dumper.dump; +var YAMLException = exception; - this.cache[abs] = entries; - return cb(null, entries) +// Re-export all types in case user wants to create custom schema +var types$1 = { + binary: binary, + float: float, + map: map$3, + null: _null, + pairs: pairs, + set: set, + timestamp: timestamp, + bool: bool, + int: int, + merge: merge$1, + omap: omap, + seq: seq, + str: str }; -Glob.prototype._readdirError = function (f, er, cb) { - if (this.aborted) - return - - // handle errors, and cache the information - switch (er.code) { - case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 - case 'ENOTDIR': // totally normal. means it *does* exist. - var abs = this._makeAbs(f); - this.cache[abs] = 'FILE'; - if (abs === this.cwdAbs) { - var error = new Error(er.code + ' invalid cwd ' + this.cwd); - error.path = this.cwd; - error.code = er.code; - this.emit('error', error); - this.abort(); - } - break - - case 'ENOENT': // not terribly unusual - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false; - break - - default: // some unusual error. Treat as failure. - this.cache[this._makeAbs(f)] = false; - if (this.strict) { - this.emit('error', er); - // If the error is handled, then we abort - // if not, we threw out of here - this.abort(); - } - if (!this.silent) - console.error('glob error', er); - break - } - - return cb() -}; +// Removed functions from JS-YAML 3.0.x +var safeLoad = renamed('safeLoad', 'load'); +var safeLoadAll = renamed('safeLoadAll', 'loadAll'); +var safeDump = renamed('safeDump', 'dump'); -Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { - var self = this; - this._readdir(abs, inGlobStar, function (er, entries) { - self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb); - }); +var jsYaml = { + Type: Type, + Schema: Schema, + FAILSAFE_SCHEMA: FAILSAFE_SCHEMA, + JSON_SCHEMA: JSON_SCHEMA, + CORE_SCHEMA: CORE_SCHEMA, + DEFAULT_SCHEMA: DEFAULT_SCHEMA, + load: load, + loadAll: loadAll, + dump: dump, + YAMLException: YAMLException, + types: types$1, + safeLoad: safeLoad, + safeLoadAll: safeLoadAll, + safeDump: safeDump }; +var isArrayish$2 = function isArrayish(obj) { + if (!obj) { + return false; + } -Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - //console.error('pgs2', prefix, remain[0], entries) - - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return cb() + return obj instanceof Array || Array.isArray(obj) || + (obj.length >= 0 && obj.splice instanceof Function); +}; - // test without the globstar, and with every child both below - // and replacing the globstar. - var remainWithoutGlobStar = remain.slice(1); - var gspref = prefix ? [ prefix ] : []; - var noGlobStar = gspref.concat(remainWithoutGlobStar); +var util$2 = require$$0__default$2['default']; +var isArrayish$1 = isArrayish$2; - // the noGlobStar pattern exits the inGlobStar state - this._process(noGlobStar, index, false, cb); +var errorEx$1 = function errorEx(name, properties) { + if (!name || name.constructor !== String) { + properties = name || {}; + name = Error.name; + } - var isSym = this.symlinks[abs]; - var len = entries.length; + var errorExError = function ErrorEXError(message) { + if (!this) { + return new ErrorEXError(message); + } - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return cb() + message = message instanceof Error + ? message.message + : (message || this.message); - for (var i = 0; i < len; i++) { - var e = entries[i]; - if (e.charAt(0) === '.' && !this.dot) - continue + Error.call(this, message); + Error.captureStackTrace(this, errorExError); - // these two cases enter the inGlobStar state - var instead = gspref.concat(entries[i], remainWithoutGlobStar); - this._process(instead, index, true, cb); + this.name = name; - var below = gspref.concat(entries[i], remain); - this._process(below, index, true, cb); - } + Object.defineProperty(this, 'message', { + configurable: true, + enumerable: false, + get: function () { + var newMessage = message.split(/\r?\n/g); - cb(); -}; + for (var key in properties) { + if (!properties.hasOwnProperty(key)) { + continue; + } -Glob.prototype._processSimple = function (prefix, index, cb) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var self = this; - this._stat(prefix, function (er, exists) { - self._processSimple2(prefix, index, er, exists, cb); - }); -}; -Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { + var modifier = properties[key]; - //console.error('ps2', prefix, exists) + if ('message' in modifier) { + newMessage = modifier.message(this[key], newMessage) || newMessage; + if (!isArrayish$1(newMessage)) { + newMessage = [newMessage]; + } + } + } - if (!this.matches[index]) - this.matches[index] = Object.create(null); + return newMessage.join('\n'); + }, + set: function (v) { + message = v; + } + }); - // If it doesn't exist, then just mark the lack of results - if (!exists) - return cb() + var overwrittenStack = null; - if (prefix && isAbsolute(prefix) && !this.nomount) { - var trail = /[\/\\]$/.test(prefix); - if (prefix.charAt(0) === '/') { - prefix = path$a.join(this.root, prefix); - } else { - prefix = path$a.resolve(this.root, prefix); - if (trail) - prefix += '/'; - } - } + var stackDescriptor = Object.getOwnPropertyDescriptor(this, 'stack'); + var stackGetter = stackDescriptor.get; + var stackValue = stackDescriptor.value; + delete stackDescriptor.value; + delete stackDescriptor.writable; - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/'); + stackDescriptor.set = function (newstack) { + overwrittenStack = newstack; + }; - // Mark this as a match - this._emitMatch(index, prefix); - cb(); -}; + stackDescriptor.get = function () { + var stack = (overwrittenStack || ((stackGetter) + ? stackGetter.call(this) + : stackValue)).split(/\r?\n+/g); -// Returns either 'DIR', 'FILE', or false -Glob.prototype._stat = function (f, cb) { - var abs = this._makeAbs(f); - var needDir = f.slice(-1) === '/'; + // starting in Node 7, the stack builder caches the message. + // just replace it. + if (!overwrittenStack) { + stack[0] = this.name + ': ' + this.message; + } - if (f.length > this.maxLength) - return cb() + var lineCount = 1; + for (var key in properties) { + if (!properties.hasOwnProperty(key)) { + continue; + } - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs]; + var modifier = properties[key]; - if (Array.isArray(c)) - c = 'DIR'; + if ('line' in modifier) { + var line = modifier.line(this[key]); + if (line) { + stack.splice(lineCount++, 0, ' ' + line); + } + } - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return cb(null, c) + if ('stack' in modifier) { + modifier.stack(this[key], stack); + } + } - if (needDir && c === 'FILE') - return cb() + return stack.join('\n'); + }; - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } - var stat = this.statCache[abs]; - if (stat !== undefined) { - if (stat === false) - return cb(null, stat) - else { - var type = stat.isDirectory() ? 'DIR' : 'FILE'; - if (needDir && type === 'FILE') - return cb() - else - return cb(null, type, stat) - } - } + Object.defineProperty(this, 'stack', stackDescriptor); + }; - var self = this; - var statcb = inflight('stat\0' + abs, lstatcb_); - if (statcb) - fs$b.lstat(abs, statcb); + if (Object.setPrototypeOf) { + Object.setPrototypeOf(errorExError.prototype, Error.prototype); + Object.setPrototypeOf(errorExError, Error); + } else { + util$2.inherits(errorExError, Error); + } - function lstatcb_ (er, lstat) { - if (lstat && lstat.isSymbolicLink()) { - // If it's a symlink, then treat it as the target, unless - // the target does not exist, then treat it as a file. - return fs$b.stat(abs, function (er, stat) { - if (er) - self._stat2(f, abs, null, lstat, cb); - else - self._stat2(f, abs, er, stat, cb); - }) - } else { - self._stat2(f, abs, er, lstat, cb); - } - } + return errorExError; }; -Glob.prototype._stat2 = function (f, abs, er, stat, cb) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false; - return cb() - } +errorEx$1.append = function (str, def) { + return { + message: function (v, message) { + v = v || def; - var needDir = f.slice(-1) === '/'; - this.statCache[abs] = stat; + if (v) { + message[0] += ' ' + str.replace('%s', v.toString()); + } - if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) - return cb(null, false, stat) + return message; + } + }; +}; - var c = true; - if (stat) - c = stat.isDirectory() ? 'DIR' : 'FILE'; - this.cache[abs] = this.cache[abs] || c; +errorEx$1.line = function (str, def) { + return { + line: function (v) { + v = v || def; - if (needDir && c === 'FILE') - return cb() + if (v) { + return str.replace('%s', v.toString()); + } - return cb(null, c, stat) + return null; + } + }; }; -/*! - * Determine if an object is a Buffer - * - * @author Feross Aboukhadijeh - * @license MIT - */ +var errorEx_1 = errorEx$1; -var isBuffer = function isBuffer (obj) { - return obj != null && obj.constructor != null && - typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +const hexify = char => { + const h = char.charCodeAt(0).toString(16).toUpperCase(); + return '0x' + (h.length % 2 ? '0' : '') + h }; -var own$e = {}.hasOwnProperty; - -var unistUtilStringifyPosition = stringify$e; - -function stringify$e(value) { - // Nothing. - if (!value || typeof value !== 'object') { - return '' - } - - // Node. - if (own$e.call(value, 'position') || own$e.call(value, 'type')) { - return position$4(value.position) - } - - // Position. - if (own$e.call(value, 'start') || own$e.call(value, 'end')) { - return position$4(value) - } - - // Point. - if (own$e.call(value, 'line') || own$e.call(value, 'column')) { - return point$3(value) - } - - // ? - return '' -} - -function point$3(point) { - if (!point || typeof point !== 'object') { - point = {}; - } - - return index$2(point.line) + ':' + index$2(point.column) -} - -function position$4(pos) { - if (!pos || typeof pos !== 'object') { - pos = {}; +const parseError = (e, txt, context) => { + if (!txt) { + return { + message: e.message + ' while parsing empty string', + position: 0, + } } + const badToken = e.message.match(/^Unexpected token (.) .*position\s+(\d+)/i); + const errIdx = badToken ? +badToken[2] + : e.message.match(/^Unexpected end of JSON.*/i) ? txt.length - 1 + : null; - return point$3(pos.start) + '-' + point$3(pos.end) -} - -function index$2(value) { - return value && typeof value === 'number' ? value : 1 -} - -var stringify$d = unistUtilStringifyPosition; - -var vfileMessage$1 = VMessage$3; - -// Inherit from `Error#`. -function VMessagePrototype$1() {} -VMessagePrototype$1.prototype = Error.prototype; -VMessage$3.prototype = new VMessagePrototype$1(); - -// Message properties. -var proto$2 = VMessage$3.prototype; - -proto$2.file = ''; -proto$2.name = ''; -proto$2.reason = ''; -proto$2.message = ''; -proto$2.stack = ''; -proto$2.fatal = null; -proto$2.column = null; -proto$2.line = null; - -// Construct a new VMessage. -// -// Note: We cannot invoke `Error` on the created context, as that adds readonly -// `line` and `column` attributes on Safari 9, thus throwing and failing the -// data. -function VMessage$3(reason, position, origin) { - var parts; - var range; - var location; + const msg = badToken ? e.message.replace(/^Unexpected token ./, `Unexpected token ${ + JSON.stringify(badToken[1]) + } (${hexify(badToken[1])})`) + : e.message; - if (typeof position === 'string') { - origin = position; - position = null; - } + if (errIdx !== null && errIdx !== undefined) { + const start = errIdx <= context ? 0 + : errIdx - context; - parts = parseOrigin$1(origin); - range = stringify$d(position) || '1:1'; + const end = errIdx + context >= txt.length ? txt.length + : errIdx + context; - location = { - start: {line: null, column: null}, - end: {line: null, column: null} - }; + const slice = (start === 0 ? '' : '...') + + txt.slice(start, end) + + (end === txt.length ? '' : '...'); - // Node. - if (position && position.position) { - position = position.position; - } + const near = txt === slice ? '' : 'near '; - if (position) { - // Position. - if (position.start) { - location = position; - position = position.start; - } else { - // Point. - location.start = position; + return { + message: msg + ` while parsing ${near}${JSON.stringify(slice)}`, + position: errIdx, + } + } else { + return { + message: msg + ` while parsing '${txt.slice(0, context * 2)}'`, + position: 0, } } +}; - if (reason.stack) { - this.stack = reason.stack; - reason = reason.message; +class JSONParseError extends SyntaxError { + constructor (er, txt, context, caller) { + context = context || 20; + const metadata = parseError(er, txt, context); + super(metadata.message); + Object.assign(this, metadata); + this.code = 'EJSONPARSE'; + this.systemError = er; + Error.captureStackTrace(this, caller || this.constructor); } - - this.message = reason; - this.name = range; - this.reason = reason; - this.line = position ? position.line : null; - this.column = position ? position.column : null; - this.location = location; - this.source = parts[0]; - this.ruleId = parts[1]; + get name () { return this.constructor.name } + set name (n) {} + get [Symbol.toStringTag] () { return this.constructor.name } } -function parseOrigin$1(origin) { - var result = [null, null]; - var index; +const kIndent = Symbol.for('indent'); +const kNewline = Symbol.for('newline'); +// only respect indentation if we got a line break, otherwise squash it +// things other than objects and arrays aren't indented, so ignore those +// Important: in both of these regexps, the $1 capture group is the newline +// or undefined, and the $2 capture group is the indent, or undefined. +const formatRE = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/; +const emptyRE = /^(?:\{\}|\[\])((?:\r?\n)+)?$/; - if (typeof origin === 'string') { - index = origin.indexOf(':'); +const parseJson$1 = (txt, reviver, context) => { + const parseText = stripBOM(txt); + context = context || 20; + try { + // get the indentation so that we can save it back nicely + // if the file starts with {" then we have an indent of '', ie, none + // otherwise, pick the indentation of the next line after the first \n + // If the pattern doesn't match, then it means no indentation. + // JSON.stringify ignores symbols, so this is reasonably safe. + // if the string is '{}' or '[]', then use the default 2-space indent. + const [, newline = '\n', indent = ' '] = parseText.match(emptyRE) || + parseText.match(formatRE) || + [, '', '']; - if (index === -1) { - result[1] = origin; - } else { - result[0] = origin.slice(0, index); - result[1] = origin.slice(index + 1); + const result = JSON.parse(parseText, reviver); + if (result && typeof result === 'object') { + result[kNewline] = newline; + result[kIndent] = indent; + } + return result + } catch (e) { + if (typeof txt !== 'string' && !Buffer.isBuffer(txt)) { + const isEmptyArray = Array.isArray(txt) && txt.length === 0; + throw Object.assign(new TypeError( + `Cannot parse ${isEmptyArray ? 'an empty array' : String(txt)}` + ), { + code: 'EJSONPARSE', + systemError: e, + }) } - } - - return result -} - -var minpath$1 = require$$0__default$2['default']; - -var minproc$1 = process; - -var p$1 = minpath$1; -var proc$2 = minproc$1; -var buffer$5 = isBuffer; - -var core$3 = VFile$3; - -var own$d = {}.hasOwnProperty; - -// Order of setting (least specific to most), we need this because otherwise -// `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a -// stem can be set. -var order$4 = ['history', 'path', 'basename', 'stem', 'extname', 'dirname']; -VFile$3.prototype.toString = toString$9; + throw new JSONParseError(e, parseText, context, parseJson$1) + } +}; -// Access full path (`~/index.min.js`). -Object.defineProperty(VFile$3.prototype, 'path', {get: getPath$1, set: setPath$1}); +// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) +// because the buffer-to-string conversion in `fs.readFileSync()` +// translates it to FEFF, the UTF-16 BOM. +const stripBOM = txt => String(txt).replace(/^\uFEFF/, ''); -// Access parent path (`~`). -Object.defineProperty(VFile$3.prototype, 'dirname', { - get: getDirname$1, - set: setDirname$1 -}); +var jsonParseEvenBetterErrors = parseJson$1; +parseJson$1.JSONParseError = JSONParseError; -// Access basename (`index.min.js`). -Object.defineProperty(VFile$3.prototype, 'basename', { - get: getBasename$1, - set: setBasename$1 -}); +parseJson$1.noExceptions = (txt, reviver) => { + try { + return JSON.parse(stripBOM(txt), reviver) + } catch (e) {} +}; -// Access extname (`.js`). -Object.defineProperty(VFile$3.prototype, 'extname', { - get: getExtname$1, - set: setExtname$1 +var LF = '\n'; +var CR = '\r'; +var LinesAndColumns$1 = (function () { + function LinesAndColumns(string) { + this.string = string; + var offsets = [0]; + for (var offset = 0; offset < string.length;) { + switch (string[offset]) { + case LF: + offset += LF.length; + offsets.push(offset); + break; + case CR: + offset += CR.length; + if (string[offset] === LF) { + offset += LF.length; + } + offsets.push(offset); + break; + default: + offset++; + break; + } + } + this.offsets = offsets; + } + LinesAndColumns.prototype.locationForIndex = function (index) { + if (index < 0 || index > this.string.length) { + return null; + } + var line = 0; + var offsets = this.offsets; + while (offsets[line + 1] <= index) { + line++; + } + var column = index - offsets[line]; + return { line: line, column: column }; + }; + LinesAndColumns.prototype.indexForLocation = function (location) { + var line = location.line, column = location.column; + if (line < 0 || line >= this.offsets.length) { + return null; + } + if (column < 0 || column > this.lengthOfLine(line)) { + return null; + } + return this.offsets[line] + column; + }; + LinesAndColumns.prototype.lengthOfLine = function (line) { + var offset = this.offsets[line]; + var nextOffset = line === this.offsets.length - 1 ? this.string.length : this.offsets[line + 1]; + return nextOffset - offset; + }; + return LinesAndColumns; +}()); + +var dist = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': LinesAndColumns$1 }); -// Access stem (`index.min`). -Object.defineProperty(VFile$3.prototype, 'stem', {get: getStem$1, set: setStem$1}); +var require$$2 = /*@__PURE__*/getAugmentedNamespace(dist); -// Construct a new file. -function VFile$3(options) { - var prop; - var index; +var lib$4 = {}; - if (!options) { - options = {}; - } else if (typeof options === 'string' || buffer$5(options)) { - options = {contents: options}; - } else if ('message' in options && 'messages' in options) { - return options - } +var lib$3 = {}; - if (!(this instanceof VFile$3)) { - return new VFile$3(options) - } +var jsTokens = {}; - this.data = {}; - this.messages = []; - this.history = []; - this.cwd = proc$2.cwd(); +// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell +// License: MIT. (See LICENSE.) - // Set path related properties in the correct order. - index = -1; +Object.defineProperty(jsTokens, "__esModule", { + value: true +}); - while (++index < order$4.length) { - prop = order$4[index]; +// This regex comes from regex.coffee, and is inserted here by generate-index.js +// (run `npm run build`). +jsTokens.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g; - if (own$d.call(options, prop)) { - this[prop] = options[prop]; - } - } +jsTokens.matchToToken = function(match) { + var token = {type: "invalid", value: match[0], closed: undefined}; + if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4]); + else if (match[ 5]) token.type = "comment"; + else if (match[ 6]) token.type = "comment", token.closed = !!match[7]; + else if (match[ 8]) token.type = "regex"; + else if (match[ 9]) token.type = "number"; + else if (match[10]) token.type = "name"; + else if (match[11]) token.type = "punctuator"; + else if (match[12]) token.type = "whitespace"; + return token +}; - // Set non-path related properties. - for (prop in options) { - if (order$4.indexOf(prop) < 0) { - this[prop] = options[prop]; - } +var lib$2 = {}; + +var identifier = {}; + +Object.defineProperty(identifier, "__esModule", { + value: true +}); +identifier.isIdentifierStart = isIdentifierStart; +identifier.isIdentifierChar = isIdentifierChar; +identifier.isIdentifierName = isIdentifierName; +let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\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\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\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\u0af9\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-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\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\u2118-\u211d\u2124\u2126\u2128\u212a-\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\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\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"; +let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; +const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); +const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); +nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; +const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938]; +const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; + +function isInAstralSet(code, set) { + let pos = 0x10000; + + for (let i = 0, length = set.length; i < length; i += 2) { + pos += set[i]; + if (pos > code) return false; + pos += set[i + 1]; + if (pos >= code) return true; } -} -function getPath$1() { - return this.history[this.history.length - 1] + return false; } -function setPath$1(path) { - assertNonEmpty$1(path, 'path'); +function isIdentifierStart(code) { + if (code < 65) return code === 36; + if (code <= 90) return true; + if (code < 97) return code === 95; + if (code <= 122) return true; - if (this.path !== path) { - this.history.push(path); + if (code <= 0xffff) { + return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); } -} -function getDirname$1() { - return typeof this.path === 'string' ? p$1.dirname(this.path) : undefined + return isInAstralSet(code, astralIdentifierStartCodes); } -function setDirname$1(dirname) { - assertPath$1(this.path, 'dirname'); - this.path = p$1.join(dirname || '', this.basename); -} +function isIdentifierChar(code) { + if (code < 48) return code === 36; + if (code < 58) return true; + if (code < 65) return false; + if (code <= 90) return true; + if (code < 97) return code === 95; + if (code <= 122) return true; -function getBasename$1() { - return typeof this.path === 'string' ? p$1.basename(this.path) : undefined -} + if (code <= 0xffff) { + return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); + } -function setBasename$1(basename) { - assertNonEmpty$1(basename, 'basename'); - assertPart$1(basename, 'basename'); - this.path = p$1.join(this.dirname || '', basename); + return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); } -function getExtname$1() { - return typeof this.path === 'string' ? p$1.extname(this.path) : undefined -} +function isIdentifierName(name) { + let isFirst = true; + + for (let i = 0; i < name.length; i++) { + let cp = name.charCodeAt(i); -function setExtname$1(extname) { - assertPart$1(extname, 'extname'); - assertPath$1(this.path, 'extname'); + if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) { + const trail = name.charCodeAt(++i); - if (extname) { - if (extname.charCodeAt(0) !== 46 /* `.` */) { - throw new Error('`extname` must start with `.`') + if ((trail & 0xfc00) === 0xdc00) { + cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff); + } } - if (extname.indexOf('.', 1) > -1) { - throw new Error('`extname` cannot contain multiple dots') + if (isFirst) { + isFirst = false; + + if (!isIdentifierStart(cp)) { + return false; + } + } else if (!isIdentifierChar(cp)) { + return false; } } - this.path = p$1.join(this.dirname, this.stem + (extname || '')); + return !isFirst; } -function getStem$1() { - return typeof this.path === 'string' - ? p$1.basename(this.path, this.extname) - : undefined -} +var keyword = {}; -function setStem$1(stem) { - assertNonEmpty$1(stem, 'stem'); - assertPart$1(stem, 'stem'); - this.path = p$1.join(this.dirname || '', stem + (this.extname || '')); -} +Object.defineProperty(keyword, "__esModule", { + value: true +}); +keyword.isReservedWord = isReservedWord; +keyword.isStrictReservedWord = isStrictReservedWord; +keyword.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord; +keyword.isStrictBindReservedWord = isStrictBindReservedWord; +keyword.isKeyword = isKeyword; +const reservedWords = { + keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"], + strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], + strictBind: ["eval", "arguments"] +}; +const keywords$1 = new Set(reservedWords.keyword); +const reservedWordsStrictSet = new Set(reservedWords.strict); +const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); -// Get the value of the file. -function toString$9(encoding) { - return (this.contents || '').toString(encoding) +function isReservedWord(word, inModule) { + return inModule && word === "await" || word === "enum"; } -// Assert that `part` is not a path (i.e., does not contain `p.sep`). -function assertPart$1(part, name) { - if (part && part.indexOf(p$1.sep) > -1) { - throw new Error( - '`' + name + '` cannot be a path: did not expect `' + p$1.sep + '`' - ) - } +function isStrictReservedWord(word, inModule) { + return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); } -// Assert that `part` is not empty. -function assertNonEmpty$1(part, name) { - if (!part) { - throw new Error('`' + name + '` cannot be empty') - } +function isStrictBindOnlyReservedWord(word) { + return reservedWordsStrictBindSet.has(word); } -// Assert `path` exists. -function assertPath$1(path, name) { - if (!path) { - throw new Error('Setting `' + name + '` requires `path` to be set too') - } +function isStrictBindReservedWord(word, inModule) { + return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); } -var VMessage$2 = vfileMessage$1; -var VFile$2 = core$3; - -var lib$6 = VFile$2; - -VFile$2.prototype.message = message$1; -VFile$2.prototype.info = info$1; -VFile$2.prototype.fail = fail$2; +function isKeyword(word) { + return keywords$1.has(word); +} -// Create a message with `reason` at `position`. -// When an error is passed in as `reason`, copies the stack. -function message$1(reason, position, origin) { - var message = new VMessage$2(reason, position, origin); +(function (exports) { - if (this.path) { - message.name = this.path + ':' + message.name; - message.file = this.path; +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "isIdentifierName", { + enumerable: true, + get: function () { + return _identifier.isIdentifierName; } +}); +Object.defineProperty(exports, "isIdentifierChar", { + enumerable: true, + get: function () { + return _identifier.isIdentifierChar; + } +}); +Object.defineProperty(exports, "isIdentifierStart", { + enumerable: true, + get: function () { + return _identifier.isIdentifierStart; + } +}); +Object.defineProperty(exports, "isReservedWord", { + enumerable: true, + get: function () { + return _keyword.isReservedWord; + } +}); +Object.defineProperty(exports, "isStrictBindOnlyReservedWord", { + enumerable: true, + get: function () { + return _keyword.isStrictBindOnlyReservedWord; + } +}); +Object.defineProperty(exports, "isStrictBindReservedWord", { + enumerable: true, + get: function () { + return _keyword.isStrictBindReservedWord; + } +}); +Object.defineProperty(exports, "isStrictReservedWord", { + enumerable: true, + get: function () { + return _keyword.isStrictReservedWord; + } +}); +Object.defineProperty(exports, "isKeyword", { + enumerable: true, + get: function () { + return _keyword.isKeyword; + } +}); - message.fatal = false; - - this.messages.push(message); +var _identifier = identifier; - return message -} +var _keyword = keyword; +}(lib$2)); -// Fail: creates a vmessage, associates it with the file, and throws it. -function fail$2() { - var message = this.message.apply(this, arguments); +var chalk = {exports: {}}; - message.fatal = true; +var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; - throw message -} +var escapeStringRegexp$1 = function (str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } -// Info: creates a vmessage, associates it with the file, and marks the fatality -// as null. -function info$1() { - var message = this.message.apply(this, arguments); + return str.replace(matchOperatorsRe, '\\$&'); +}; - message.fatal = null; +var ansiStyles = {exports: {}}; - return message -} +var conversions$2 = {exports: {}}; -var vfile$9 = lib$6; +var colorName = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; -var buffer$4 = isBuffer; -var vfile$8 = vfile$9; +/* MIT license */ -var core$2 = toVFile; +var cssKeywords = colorName; -// Create a virtual file from a description. If `options` is a string or a -// buffer, it’s used as the path. In all other cases, the options are passed -// through to `vfile()`. -function toVFile(options) { - if (typeof options === 'string' || buffer$4(options)) { - options = {path: String(options)}; - } +// NOTE: conversions should only return primitive values (i.e. arrays, or +// values that give correct `typeof` results). +// do not use box values types (i.e. Number(), String(), etc.) - return vfile$8(options) +var reverseKeywords = {}; +for (var key$1 in cssKeywords) { + if (cssKeywords.hasOwnProperty(key$1)) { + reverseKeywords[cssKeywords[key$1]] = key$1; + } } -var sync$2 = {}; +var convert$2 = conversions$2.exports = { + rgb: {channels: 3, labels: 'rgb'}, + hsl: {channels: 3, labels: 'hsl'}, + hsv: {channels: 3, labels: 'hsv'}, + hwb: {channels: 3, labels: 'hwb'}, + cmyk: {channels: 4, labels: 'cmyk'}, + xyz: {channels: 3, labels: 'xyz'}, + lab: {channels: 3, labels: 'lab'}, + lch: {channels: 3, labels: 'lch'}, + hex: {channels: 1, labels: ['hex']}, + keyword: {channels: 1, labels: ['keyword']}, + ansi16: {channels: 1, labels: ['ansi16']}, + ansi256: {channels: 1, labels: ['ansi256']}, + hcg: {channels: 3, labels: ['h', 'c', 'g']}, + apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, + gray: {channels: 1, labels: ['gray']} +}; -var fs$a = require$$0__default$3['default']; -var path$9 = require$$0__default$2['default']; -var vfile$7 = core$2; +// hide .channels and .labels properties +for (var model in convert$2) { + if (convert$2.hasOwnProperty(model)) { + if (!('channels' in convert$2[model])) { + throw new Error('missing channels property: ' + model); + } -sync$2.read = readSync; -sync$2.write = writeSync; + if (!('labels' in convert$2[model])) { + throw new Error('missing channel labels property: ' + model); + } -// Create a virtual file and read it in, synchronously. -function readSync(description, options) { - var file = vfile$7(description); - file.contents = fs$a.readFileSync(path$9.resolve(file.cwd, file.path), options); - return file -} + if (convert$2[model].labels.length !== convert$2[model].channels) { + throw new Error('channel and label counts mismatch: ' + model); + } -// Create a virtual file and write it out, synchronously. -function writeSync(description, options) { - var file = vfile$7(description); - fs$a.writeFileSync( - path$9.resolve(file.cwd, file.path), - file.contents || '', - options - ); - return file + var channels = convert$2[model].channels; + var labels$1 = convert$2[model].labels; + delete convert$2[model].channels; + delete convert$2[model].labels; + Object.defineProperty(convert$2[model], 'channels', {value: channels}); + Object.defineProperty(convert$2[model], 'labels', {value: labels$1}); + } } -var async$1 = {}; - -var fs$9 = require$$0__default$3['default']; -var path$8 = require$$0__default$2['default']; -var vfile$6 = core$2; +convert$2.rgb.hsl = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var delta = max - min; + var h; + var s; + var l; -async$1.read = read$3; -async$1.write = write; + if (max === min) { + h = 0; + } else if (r === max) { + h = (g - b) / delta; + } else if (g === max) { + h = 2 + (b - r) / delta; + } else if (b === max) { + h = 4 + (r - g) / delta; + } -// Create a virtual file and read it in, asynchronously. -function read$3(description, options, callback) { - var file = vfile$6(description); + h = Math.min(h * 60, 360); - if (!callback && typeof options === 'function') { - callback = options; - options = null; - } + if (h < 0) { + h += 360; + } - if (!callback) { - return new Promise(executor) - } + l = (min + max) / 2; - executor(resolve, callback); + if (max === min) { + s = 0; + } else if (l <= 0.5) { + s = delta / (max + min); + } else { + s = delta / (2 - max - min); + } - function resolve(result) { - callback(null, result); - } + return [h, s * 100, l * 100]; +}; - function executor(resolve, reject) { - var fp; +convert$2.rgb.hsv = function (rgb) { + var rdif; + var gdif; + var bdif; + var h; + var s; - try { - fp = path$8.resolve(file.cwd, file.path); - } catch (error) { - return reject(error) - } + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var v = Math.max(r, g, b); + var diff = v - Math.min(r, g, b); + var diffc = function (c) { + return (v - c) / 6 / diff + 1 / 2; + }; - fs$9.readFile(fp, options, done); + if (diff === 0) { + h = s = 0; + } else { + s = diff / v; + rdif = diffc(r); + gdif = diffc(g); + bdif = diffc(b); - function done(error, res) { - if (error) { - reject(error); - } else { - file.contents = res; - resolve(file); - } - } - } -} - -// Create a virtual file and write it out, asynchronously. -function write(description, options, callback) { - var file = vfile$6(description); + if (r === v) { + h = bdif - gdif; + } else if (g === v) { + h = (1 / 3) + rdif - bdif; + } else if (b === v) { + h = (2 / 3) + gdif - rdif; + } + if (h < 0) { + h += 1; + } else if (h > 1) { + h -= 1; + } + } - // Weird, right? Otherwise `fs` doesn’t accept it. - if (!callback && typeof options === 'function') { - callback = options; - options = undefined; - } + return [ + h * 360, + s * 100, + v * 100 + ]; +}; - if (!callback) { - return new Promise(executor) - } +convert$2.rgb.hwb = function (rgb) { + var r = rgb[0]; + var g = rgb[1]; + var b = rgb[2]; + var h = convert$2.rgb.hsl(rgb)[0]; + var w = 1 / 255 * Math.min(r, Math.min(g, b)); - executor(resolve, callback); + b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); - function resolve(result) { - callback(null, result); - } + return [h, w * 100, b * 100]; +}; - function executor(resolve, reject) { - var fp; +convert$2.rgb.cmyk = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var c; + var m; + var y; + var k; - try { - fp = path$8.resolve(file.cwd, file.path); - } catch (error) { - return reject(error) - } + k = Math.min(1 - r, 1 - g, 1 - b); + c = (1 - r - k) / (1 - k) || 0; + m = (1 - g - k) / (1 - k) || 0; + y = (1 - b - k) / (1 - k) || 0; - fs$9.writeFile(fp, file.contents || '', options, done); + return [c * 100, m * 100, y * 100, k * 100]; +}; - function done(error) { - if (error) { - reject(error); - } else { - resolve(file); - } - } - } +/** + * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance + * */ +function comparativeDistance(x, y) { + return ( + Math.pow(x[0] - y[0], 2) + + Math.pow(x[1] - y[1], 2) + + Math.pow(x[2] - y[2], 2) + ); } -var vfile$5 = core$2; -var sync$1 = sync$2; -var async = async$1; - -var fs$8 = vfile$5; +convert$2.rgb.keyword = function (rgb) { + var reversed = reverseKeywords[rgb]; + if (reversed) { + return reversed; + } -vfile$5.read = async.read; -vfile$5.readSync = sync$1.read; -vfile$5.write = async.write; -vfile$5.writeSync = sync$1.write; + var currentClosestDistance = Infinity; + var currentClosestKeyword; -var toVfile = fs$8; + for (var keyword in cssKeywords) { + if (cssKeywords.hasOwnProperty(keyword)) { + var value = cssKeywords[keyword]; -var path$7 = require$$0__default$2['default']; -var fs$7 = require$$0__default$3['default']; -var gitignore = ignore$2; -var glob = glob_1; -var vfile$4 = toVfile; + // Compute comparative distance + var distance = comparativeDistance(rgb, value); -var finder = find$1; + // Check if its less, if so set as closest + if (distance < currentClosestDistance) { + currentClosestDistance = distance; + currentClosestKeyword = keyword; + } + } + } -// Search `patterns`, a mix of globs, paths, and files. -function find$1(input, options, callback) { - expand$2(input, options, done); + return currentClosestKeyword; +}; - function done(error, result) { - /* istanbul ignore if - glob errors are unusual. - * other errors are on the vfile results. */ - if (error) { - callback(error); - } else { - callback(null, {oneFileMode: oneFileMode(result), files: result.output}); - } - } -} +convert$2.keyword.rgb = function (keyword) { + return cssKeywords[keyword]; +}; -// Expand the given glob patterns, search given and found directories, and map -// to vfiles. -function expand$2(input, options, next) { - var paths = []; - var actual = 0; - var expected = 0; - var failed; +convert$2.rgb.xyz = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; - input.forEach(each); + // assume sRGB + r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); + g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); + b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); - if (!expected) { - search$1(paths, options, done); - } + var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); + var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); + var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); - function each(file) { - if (typeof file === 'string') { - if (glob.hasMagic(file)) { - expected++; - glob(file, {cwd: options.cwd}, one); - } else { - // `relative` to make the paths canonical. - file = - path$7.relative(options.cwd, path$7.resolve(options.cwd, file)) || '.'; - paths.push(file); - } - } else { - file.cwd = options.cwd; - file.path = path$7.relative(options.cwd, file.path); - file.history = [file.path]; - paths.push(file); - } - } + return [x * 100, y * 100, z * 100]; +}; - function one(error, files) { - /* istanbul ignore if - Glob errors are unusual. */ - if (failed) { - return - } +convert$2.rgb.lab = function (rgb) { + var xyz = convert$2.rgb.xyz(rgb); + var x = xyz[0]; + var y = xyz[1]; + var z = xyz[2]; + var l; + var a; + var b; - /* istanbul ignore if - Glob errors are unusual. */ - if (error) { - failed = true; - done(error); - } else { - actual++; - paths = paths.concat(files); + x /= 95.047; + y /= 100; + z /= 108.883; - if (actual === expected) { - search$1(paths, options, done); - } - } - } + x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); - function done(error, files) { - /* istanbul ignore if - `search` currently does not give errors. */ - if (error) { - next(error); - } else { - next(null, {input: paths, output: files}); - } - } -} + l = (116 * y) - 16; + a = 500 * (x - y); + b = 200 * (y - z); -// Search `paths`. -function search$1(input, options, next) { - var extraIgnore = gitignore().add(options.ignorePatterns); - var files = []; - var expected = 0; - var actual = 0; + return [l, a, b]; +}; - input.forEach(each); +convert$2.hsl.rgb = function (hsl) { + var h = hsl[0] / 360; + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var t1; + var t2; + var t3; + var rgb; + var val; - if (!expected) { - next(null, files); - } + if (s === 0) { + val = l * 255; + return [val, val, val]; + } - return each + if (l < 0.5) { + t2 = l * (1 + s); + } else { + t2 = l + s - l * s; + } - function each(file) { - var ext = typeof file === 'string' ? path$7.extname(file) : file.extname; - var part; + t1 = 2 * l - t2; - // Normalise globs. - if (typeof file === 'string') { - file = file.split('/').join(path$7.sep); - } + rgb = [0, 0, 0]; + for (var i = 0; i < 3; i++) { + t3 = h + 1 / 3 * -(i - 1); + if (t3 < 0) { + t3++; + } + if (t3 > 1) { + t3--; + } - part = base(file); + if (6 * t3 < 1) { + val = t1 + (t2 - t1) * 6 * t3; + } else if (2 * t3 < 1) { + val = t2; + } else if (3 * t3 < 2) { + val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; + } else { + val = t1; + } - if (options.nested && (part.charAt(0) === '.' || part === 'node_modules')) { - return - } + rgb[i] = val * 255; + } - expected++; + return rgb; +}; - statAndIgnore( - file, - Object.assign({}, options, {extraIgnore: extraIgnore}), - handle - ); +convert$2.hsl.hsv = function (hsl) { + var h = hsl[0]; + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var smin = s; + var lmin = Math.max(l, 0.01); + var sv; + var v; - function handle(error, result) { - var ignored = result && result.ignored; - var dir = result && result.stats && result.stats.isDirectory(); + l *= 2; + s *= (l <= 1) ? l : 2 - l; + smin *= lmin <= 1 ? lmin : 2 - lmin; + v = (l + s) / 2; + sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); - if (ignored && (options.nested || options.silentlyIgnore)) { - return one(null, []) - } + return [h, sv * 100, v * 100]; +}; - if (!ignored && dir) { - return fs$7.readdir(path$7.resolve(options.cwd, filePath(file)), directory) - } +convert$2.hsv.rgb = function (hsv) { + var h = hsv[0] / 60; + var s = hsv[1] / 100; + var v = hsv[2] / 100; + var hi = Math.floor(h) % 6; - if ( - !dir && - options.nested && - options.extensions.length > 0 && - options.extensions.indexOf(ext) === -1 - ) { - return one(null, []) - } + var f = h - Math.floor(h); + var p = 255 * v * (1 - s); + var q = 255 * v * (1 - (s * f)); + var t = 255 * v * (1 - (s * (1 - f))); + v *= 255; - file = vfile$4(file); - file.cwd = options.cwd; + switch (hi) { + case 0: + return [v, t, p]; + case 1: + return [q, v, p]; + case 2: + return [p, v, t]; + case 3: + return [p, q, v]; + case 4: + return [t, p, v]; + case 5: + return [v, p, q]; + } +}; - if (ignored) { - try { - file.fail('Cannot process specified file: it’s ignored'); - } catch (_) {} - } +convert$2.hsv.hsl = function (hsv) { + var h = hsv[0]; + var s = hsv[1] / 100; + var v = hsv[2] / 100; + var vmin = Math.max(v, 0.01); + var lmin; + var sl; + var l; - if (error && error.code === 'ENOENT') { - try { - file.fail( - error.syscall === 'stat' ? 'No such file or directory' : error - ); - } catch (_) {} - } + l = (2 - s) * v; + lmin = (2 - s) * vmin; + sl = s * vmin; + sl /= (lmin <= 1) ? lmin : 2 - lmin; + sl = sl || 0; + l /= 2; - one(null, [file]); - } + return [h, sl * 100, l * 100]; +}; - function directory(error, basenames) { - var file; +// http://dev.w3.org/csswg/css-color/#hwb-to-rgb +convert$2.hwb.rgb = function (hwb) { + var h = hwb[0] / 360; + var wh = hwb[1] / 100; + var bl = hwb[2] / 100; + var ratio = wh + bl; + var i; + var v; + var f; + var n; - /* istanbul ignore if - Should not happen often: the directory is `stat`ed - * first, which was ok, but reading it is not. */ - if (error) { - file = vfile$4(filePath(file)); - file.cwd = options.cwd; + // wh + bl cant be > 1 + if (ratio > 1) { + wh /= ratio; + bl /= ratio; + } - try { - file.fail('Cannot read directory'); - } catch (_) {} + i = Math.floor(6 * h); + v = 1 - bl; + f = 6 * h - i; - one(null, [file]); - } else { - search$1( - basenames.map(concat), - Object.assign({}, options, {nested: true}), - one - ); - } - } + if ((i & 0x01) !== 0) { + f = 1 - f; + } - // Error is never given. Always given `results`. - function one(_, results) { - /* istanbul ignore else - Always given. */ - if (results) { - files = files.concat(results); - } + n = wh + f * (v - wh); // linear interpolation - actual++; + var r; + var g; + var b; + switch (i) { + default: + case 6: + case 0: r = v; g = n; b = wh; break; + case 1: r = n; g = v; b = wh; break; + case 2: r = wh; g = v; b = n; break; + case 3: r = wh; g = n; b = v; break; + case 4: r = n; g = wh; b = v; break; + case 5: r = v; g = wh; b = n; break; + } - if (actual === expected) { - next(null, files); - } - } + return [r * 255, g * 255, b * 255]; +}; - function concat(value) { - return path$7.join(filePath(file), value) - } - } -} +convert$2.cmyk.rgb = function (cmyk) { + var c = cmyk[0] / 100; + var m = cmyk[1] / 100; + var y = cmyk[2] / 100; + var k = cmyk[3] / 100; + var r; + var g; + var b; -function statAndIgnore(file, options, callback) { - var fp = path$7.resolve(options.cwd, filePath(file)); - var normal = path$7.relative(options.cwd, fp); - var expected = 1; - var actual = 0; - var stats; - var ignored; + r = 1 - Math.min(1, c * (1 - k) + k); + g = 1 - Math.min(1, m * (1 - k) + k); + b = 1 - Math.min(1, y * (1 - k) + k); - if (!file.contents) { - expected++; - fs$7.stat(fp, handleStat); - } + return [r * 255, g * 255, b * 255]; +}; - options.ignore.check(fp, handleIgnore); +convert$2.xyz.rgb = function (xyz) { + var x = xyz[0] / 100; + var y = xyz[1] / 100; + var z = xyz[2] / 100; + var r; + var g; + var b; - function handleStat(error, value) { - stats = value; - one(error); - } + r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); + g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); + b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); - function handleIgnore(error, value) { - ignored = value; - one(error); - } + // assume sRGB + r = r > 0.0031308 + ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) + : r * 12.92; - function one(error) { - actual++; + g = g > 0.0031308 + ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) + : g * 12.92; - if (error) { - callback(error); - actual = -1; - } else if (actual === expected) { - callback(null, { - stats: stats, - ignored: - ignored || - (normal === '' || - normal === '..' || - normal.charAt(0) === path$7.sep || - normal.slice(0, 3) === '..' + path$7.sep - ? false - : options.extraIgnore.ignores(normal)) - }); - } - } -} + b = b > 0.0031308 + ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) + : b * 12.92; -function base(file) { - return typeof file === 'string' ? path$7.basename(file) : file.basename -} + r = Math.min(Math.max(0, r), 1); + g = Math.min(Math.max(0, g), 1); + b = Math.min(Math.max(0, b), 1); -function filePath(file) { - return typeof file === 'string' ? file : file.path -} + return [r * 255, g * 255, b * 255]; +}; -function oneFileMode(result) { - return ( - result.output.length === 1 && - result.input.length === 1 && - result.output[0].path === result.input[0] - ) -} +convert$2.xyz.lab = function (xyz) { + var x = xyz[0]; + var y = xyz[1]; + var z = xyz[2]; + var l; + var a; + var b; -var Ignore = ignore$1; -var find = finder; + x /= 95.047; + y /= 100; + z /= 108.883; -var fileSystem_1$1 = fileSystem$3; + x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); -// Find files from the file-system. -function fileSystem$3(context, settings, next) { - if (context.files.length === 0) { - next(); - } else { - find( - context.files, - { - cwd: settings.cwd, - extensions: settings.extensions, - silentlyIgnore: settings.silentlyIgnore, - ignorePatterns: settings.ignorePatterns, - ignore: new Ignore({ - cwd: settings.cwd, - detectIgnore: settings.detectIgnore, - ignoreName: settings.ignoreName, - ignorePath: settings.ignorePath, - ignorePathResolveFrom: settings.ignorePathResolveFrom - }) - }, - onfound - ); - } + l = (116 * y) - 16; + a = 500 * (x - y); + b = 200 * (y - z); - function onfound(error, result) { - var output = result.files; + return [l, a, b]; +}; - // Sort alphabetically. - // Everything is unique so we do not care about cases where left and right - // are equal. - output.sort(sortAlphabetically); +convert$2.lab.xyz = function (lab) { + var l = lab[0]; + var a = lab[1]; + var b = lab[2]; + var x; + var y; + var z; - // Mark as given. - // This allows outputting files, which can be pretty dangerous, so it’s - // “hidden”. - output.forEach(markAsGiven); + y = (l + 16) / 116; + x = a / 500 + y; + z = y - b / 200; - context.files = output; + var y2 = Math.pow(y, 3); + var x2 = Math.pow(x, 3); + var z2 = Math.pow(z, 3); + y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; + x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; + z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; - // If `out` was not set, detect it based on whether one file was given. - if (settings.out === null || settings.out === undefined) { - settings.out = result.oneFileMode; - } + x *= 95.047; + y *= 100; + z *= 108.883; - next(error); - } + return [x, y, z]; +}; - function markAsGiven(file) { - file.data.unifiedEngineGiven = true; - } +convert$2.lab.lch = function (lab) { + var l = lab[0]; + var a = lab[1]; + var b = lab[2]; + var hr; + var h; + var c; - function sortAlphabetically(left, right) { - return left.path < right.path ? -1 : 1 - } -} + hr = Math.atan2(b, a); + h = hr * 360 / 2 / Math.PI; -/* eslint-disable node/no-deprecated-api */ + if (h < 0) { + h += 360; + } -var toString$8 = Object.prototype.toString; + c = Math.sqrt(a * a + b * b); -var isModern = ( - typeof Buffer !== 'undefined' && - typeof Buffer.alloc === 'function' && - typeof Buffer.allocUnsafe === 'function' && - typeof Buffer.from === 'function' -); + return [l, c, h]; +}; -function isArrayBuffer (input) { - return toString$8.call(input).slice(8, -1) === 'ArrayBuffer' -} +convert$2.lch.lab = function (lch) { + var l = lch[0]; + var c = lch[1]; + var h = lch[2]; + var a; + var b; + var hr; -function fromArrayBuffer (obj, byteOffset, length) { - byteOffset >>>= 0; + hr = h / 360 * 2 * Math.PI; + a = c * Math.cos(hr); + b = c * Math.sin(hr); - var maxLength = obj.byteLength - byteOffset; + return [l, a, b]; +}; - if (maxLength < 0) { - throw new RangeError("'offset' is out of bounds") - } +convert$2.rgb.ansi16 = function (args) { + var r = args[0]; + var g = args[1]; + var b = args[2]; + var value = 1 in arguments ? arguments[1] : convert$2.rgb.hsv(args)[2]; // hsv -> ansi16 optimization - if (length === undefined) { - length = maxLength; - } else { - length >>>= 0; + value = Math.round(value / 50); - if (length > maxLength) { - throw new RangeError("'length' is out of bounds") - } - } + if (value === 0) { + return 30; + } - return isModern - ? Buffer.from(obj.slice(byteOffset, byteOffset + length)) - : new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length))) -} + var ansi = 30 + + ((Math.round(b / 255) << 2) + | (Math.round(g / 255) << 1) + | Math.round(r / 255)); -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8'; - } + if (value === 2) { + ansi += 60; + } - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('"encoding" must be a valid string encoding') - } + return ansi; +}; - return isModern - ? Buffer.from(string, encoding) - : new Buffer(string, encoding) -} +convert$2.hsv.ansi16 = function (args) { + // optimization here; we already know the value and don't need to get + // it converted for us. + return convert$2.rgb.ansi16(convert$2.hsv.rgb(args), args[2]); +}; -function bufferFrom$1 (value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') - } +convert$2.rgb.ansi256 = function (args) { + var r = args[0]; + var g = args[1]; + var b = args[2]; - if (isArrayBuffer(value)) { - return fromArrayBuffer(value, encodingOrOffset, length) - } + // we use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r === g && g === b) { + if (r < 8) { + return 16; + } - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } + if (r > 248) { + return 231; + } - return isModern - ? Buffer.from(value) - : new Buffer(value) -} + return Math.round(((r - 8) / 247) * 24) + 232; + } -var bufferFrom_1 = bufferFrom$1; + var ansi = 16 + + (36 * Math.round(r / 255 * 5)) + + (6 * Math.round(g / 255 * 5)) + + Math.round(b / 255 * 5); -var typedarray = {}; + return ansi; +}; -(function (exports) { -var undefined$1 = (void 0); // Paranoia +convert$2.ansi16.rgb = function (args) { + var color = args % 10; -// Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to -// create, and consume so much memory, that the browser appears frozen. -var MAX_ARRAY_LENGTH = 1e5; + // handle greyscale + if (color === 0 || color === 7) { + if (args > 50) { + color += 3.5; + } -// Approximations of internal ECMAScript conversion functions -var ECMAScript = (function() { - // Stash a copy in case other scripts modify these - var opts = Object.prototype.toString, - ophop = Object.prototype.hasOwnProperty; + color = color / 10.5 * 255; - return { - // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues: - Class: function(v) { return opts.call(v).replace(/^\[object *|\]$/g, ''); }, - HasProperty: function(o, p) { return p in o; }, - HasOwnProperty: function(o, p) { return ophop.call(o, p); }, - IsCallable: function(o) { return typeof o === 'function'; }, - ToInt32: function(v) { return v >> 0; }, - ToUint32: function(v) { return v >>> 0; } - }; -}()); + return [color, color, color]; + } -// Snapshot intrinsics -var LN2 = Math.LN2, - abs = Math.abs, - floor = Math.floor, - log = Math.log, - min = Math.min, - pow = Math.pow, - round = Math.round; + var mult = (~~(args > 50) + 1) * 0.5; + var r = ((color & 1) * mult) * 255; + var g = (((color >> 1) & 1) * mult) * 255; + var b = (((color >> 2) & 1) * mult) * 255; -// ES5: lock down object properties -function configureProperties(obj) { - if (getOwnPropNames && defineProp) { - var props = getOwnPropNames(obj), i; - for (i = 0; i < props.length; i += 1) { - defineProp(obj, props[i], { - value: obj[props[i]], - writable: false, - enumerable: false, - configurable: false - }); - } - } -} + return [r, g, b]; +}; -// emulate ES5 getter/setter API using legacy APIs -// http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx -// (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but -// note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless) -var defineProp; -if (Object.defineProperty && (function() { - try { - Object.defineProperty({}, 'x', {}); - return true; - } catch (e) { - return false; - } - })()) { - defineProp = Object.defineProperty; -} else { - defineProp = function(o, p, desc) { - if (!o === Object(o)) throw new TypeError("Object.defineProperty called on non-object"); - if (ECMAScript.HasProperty(desc, 'get') && Object.prototype.__defineGetter__) { Object.prototype.__defineGetter__.call(o, p, desc.get); } - if (ECMAScript.HasProperty(desc, 'set') && Object.prototype.__defineSetter__) { Object.prototype.__defineSetter__.call(o, p, desc.set); } - if (ECMAScript.HasProperty(desc, 'value')) { o[p] = desc.value; } - return o; - }; -} +convert$2.ansi256.rgb = function (args) { + // handle greyscale + if (args >= 232) { + var c = (args - 232) * 10 + 8; + return [c, c, c]; + } -var getOwnPropNames = Object.getOwnPropertyNames || function (o) { - if (o !== Object(o)) throw new TypeError("Object.getOwnPropertyNames called on non-object"); - var props = [], p; - for (p in o) { - if (ECMAScript.HasOwnProperty(o, p)) { - props.push(p); - } - } - return props; + args -= 16; + + var rem; + var r = Math.floor(args / 36) / 5 * 255; + var g = Math.floor((rem = args % 36) / 6) / 5 * 255; + var b = (rem % 6) / 5 * 255; + + return [r, g, b]; }; -// ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value) -// for index in 0 ... obj.length -function makeArrayAccessors(obj) { - if (!defineProp) { return; } +convert$2.rgb.hex = function (args) { + var integer = ((Math.round(args[0]) & 0xFF) << 16) + + ((Math.round(args[1]) & 0xFF) << 8) + + (Math.round(args[2]) & 0xFF); - if (obj.length > MAX_ARRAY_LENGTH) throw new RangeError("Array too large for polyfill"); + var string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; - function makeArrayAccessor(index) { - defineProp(obj, index, { - 'get': function() { return obj._getter(index); }, - 'set': function(v) { obj._setter(index, v); }, - enumerable: true, - configurable: false - }); - } +convert$2.hex.rgb = function (args) { + var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); + if (!match) { + return [0, 0, 0]; + } - var i; - for (i = 0; i < obj.length; i += 1) { - makeArrayAccessor(i); - } -} + var colorString = match[0]; -// Internal conversion functions: -// pack() - take a number (interpreted as Type), output a byte array -// unpack() - take a byte array, output a Type-like number + if (match[0].length === 3) { + colorString = colorString.split('').map(function (char) { + return char + char; + }).join(''); + } -function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; } -function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; } + var integer = parseInt(colorString, 16); + var r = (integer >> 16) & 0xFF; + var g = (integer >> 8) & 0xFF; + var b = integer & 0xFF; -function packI8(n) { return [n & 0xff]; } -function unpackI8(bytes) { return as_signed(bytes[0], 8); } + return [r, g, b]; +}; -function packU8(n) { return [n & 0xff]; } -function unpackU8(bytes) { return as_unsigned(bytes[0], 8); } +convert$2.rgb.hcg = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var max = Math.max(Math.max(r, g), b); + var min = Math.min(Math.min(r, g), b); + var chroma = (max - min); + var grayscale; + var hue; -function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; } + if (chroma < 1) { + grayscale = min / (1 - chroma); + } else { + grayscale = 0; + } -function packI16(n) { return [(n >> 8) & 0xff, n & 0xff]; } -function unpackI16(bytes) { return as_signed(bytes[0] << 8 | bytes[1], 16); } + if (chroma <= 0) { + hue = 0; + } else + if (max === r) { + hue = ((g - b) / chroma) % 6; + } else + if (max === g) { + hue = 2 + (b - r) / chroma; + } else { + hue = 4 + (r - g) / chroma + 4; + } -function packU16(n) { return [(n >> 8) & 0xff, n & 0xff]; } -function unpackU16(bytes) { return as_unsigned(bytes[0] << 8 | bytes[1], 16); } + hue /= 6; + hue %= 1; -function packI32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } -function unpackI32(bytes) { return as_signed(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } + return [hue * 360, chroma * 100, grayscale * 100]; +}; -function packU32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } -function unpackU32(bytes) { return as_unsigned(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } +convert$2.hsl.hcg = function (hsl) { + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var c = 1; + var f = 0; -function packIEEE754(v, ebits, fbits) { + if (l < 0.5) { + c = 2.0 * s * l; + } else { + c = 2.0 * s * (1.0 - l); + } - var bias = (1 << (ebits - 1)) - 1, - s, e, f, i, bits, str, bytes; + if (c < 1.0) { + f = (l - 0.5 * c) / (1.0 - c); + } - function roundToEven(n) { - var w = floor(n), f = n - w; - if (f < 0.5) - return w; - if (f > 0.5) - return w + 1; - return w % 2 ? w + 1 : w; - } + return [hsl[0], c * 100, f * 100]; +}; - // Compute sign, exponent, fraction - if (v !== v) { - // NaN - // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping - e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0; - } else if (v === Infinity || v === -Infinity) { - e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0; - } else if (v === 0) { - e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0; - } else { - s = v < 0; - v = abs(v); +convert$2.hsv.hcg = function (hsv) { + var s = hsv[1] / 100; + var v = hsv[2] / 100; - if (v >= pow(2, 1 - bias)) { - e = min(floor(log(v) / LN2), 1023); - f = roundToEven(v / pow(2, e) * pow(2, fbits)); - if (f / pow(2, fbits) >= 2) { - e = e + 1; - f = 1; - } - if (e > bias) { - // Overflow - e = (1 << ebits) - 1; - f = 0; - } else { - // Normalized - e = e + bias; - f = f - pow(2, fbits); - } - } else { - // Denormalized - e = 0; - f = roundToEven(v / pow(2, 1 - bias - fbits)); - } - } + var c = s * v; + var f = 0; - // Pack sign, exponent, fraction - bits = []; - for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); } - for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); } - bits.push(s ? 1 : 0); - bits.reverse(); - str = bits.join(''); + if (c < 1.0) { + f = (v - c) / (1 - c); + } - // Bits to bytes - bytes = []; - while (str.length) { - bytes.push(parseInt(str.substring(0, 8), 2)); - str = str.substring(8); - } - return bytes; -} + return [hsv[0], c * 100, f * 100]; +}; -function unpackIEEE754(bytes, ebits, fbits) { +convert$2.hcg.rgb = function (hcg) { + var h = hcg[0] / 360; + var c = hcg[1] / 100; + var g = hcg[2] / 100; - // Bytes to bits - var bits = [], i, j, b, str, - bias, s, e, f; + if (c === 0.0) { + return [g * 255, g * 255, g * 255]; + } - for (i = bytes.length; i; i -= 1) { - b = bytes[i - 1]; - for (j = 8; j; j -= 1) { - bits.push(b % 2 ? 1 : 0); b = b >> 1; - } - } - bits.reverse(); - str = bits.join(''); + var pure = [0, 0, 0]; + var hi = (h % 1) * 6; + var v = hi % 1; + var w = 1 - v; + var mg = 0; - // Unpack sign, exponent, fraction - bias = (1 << (ebits - 1)) - 1; - s = parseInt(str.substring(0, 1), 2) ? -1 : 1; - e = parseInt(str.substring(1, 1 + ebits), 2); - f = parseInt(str.substring(1 + ebits), 2); + switch (Math.floor(hi)) { + case 0: + pure[0] = 1; pure[1] = v; pure[2] = 0; break; + case 1: + pure[0] = w; pure[1] = 1; pure[2] = 0; break; + case 2: + pure[0] = 0; pure[1] = 1; pure[2] = v; break; + case 3: + pure[0] = 0; pure[1] = w; pure[2] = 1; break; + case 4: + pure[0] = v; pure[1] = 0; pure[2] = 1; break; + default: + pure[0] = 1; pure[1] = 0; pure[2] = w; + } - // Produce number - if (e === (1 << ebits) - 1) { - return f !== 0 ? NaN : s * Infinity; - } else if (e > 0) { - // Normalized - return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); - } else if (f !== 0) { - // Denormalized - return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); - } else { - return s < 0 ? -0 : 0; - } -} + mg = (1.0 - c) * g; -function unpackF64(b) { return unpackIEEE754(b, 11, 52); } -function packF64(v) { return packIEEE754(v, 11, 52); } -function unpackF32(b) { return unpackIEEE754(b, 8, 23); } -function packF32(v) { return packIEEE754(v, 8, 23); } + return [ + (c * pure[0] + mg) * 255, + (c * pure[1] + mg) * 255, + (c * pure[2] + mg) * 255 + ]; +}; +convert$2.hcg.hsv = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; -// -// 3 The ArrayBuffer Type -// + var v = c + g * (1.0 - c); + var f = 0; -(function() { + if (v > 0.0) { + f = c / v; + } - /** @constructor */ - var ArrayBuffer = function ArrayBuffer(length) { - length = ECMAScript.ToInt32(length); - if (length < 0) throw new RangeError('ArrayBuffer size is not a small enough positive integer'); + return [hcg[0], f * 100, v * 100]; +}; - this.byteLength = length; - this._bytes = []; - this._bytes.length = length; +convert$2.hcg.hsl = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; - var i; - for (i = 0; i < this.byteLength; i += 1) { - this._bytes[i] = 0; - } + var l = g * (1.0 - c) + 0.5 * c; + var s = 0; - configureProperties(this); - }; + if (l > 0.0 && l < 0.5) { + s = c / (2 * l); + } else + if (l >= 0.5 && l < 1.0) { + s = c / (2 * (1 - l)); + } - exports.ArrayBuffer = exports.ArrayBuffer || ArrayBuffer; + return [hcg[0], s * 100, l * 100]; +}; - // - // 4 The ArrayBufferView Type - // +convert$2.hcg.hwb = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; + var v = c + g * (1.0 - c); + return [hcg[0], (v - c) * 100, (1 - v) * 100]; +}; - // NOTE: this constructor is not exported - /** @constructor */ - var ArrayBufferView = function ArrayBufferView() { - //this.buffer = null; - //this.byteOffset = 0; - //this.byteLength = 0; - }; +convert$2.hwb.hcg = function (hwb) { + var w = hwb[1] / 100; + var b = hwb[2] / 100; + var v = 1 - b; + var c = v - w; + var g = 0; - // - // 5 The Typed Array View Types - // + if (c < 1) { + g = (v - c) / (1 - c); + } - function makeConstructor(bytesPerElement, pack, unpack) { - // Each TypedArray type requires a distinct constructor instance with - // identical logic, which this produces. + return [hwb[0], c * 100, g * 100]; +}; - var ctor; - ctor = function(buffer, byteOffset, length) { - var array, sequence, i, s; +convert$2.apple.rgb = function (apple) { + return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; +}; - if (!arguments.length || typeof arguments[0] === 'number') { - // Constructor(unsigned long length) - this.length = ECMAScript.ToInt32(arguments[0]); - if (length < 0) throw new RangeError('ArrayBufferView size is not a small enough positive integer'); +convert$2.rgb.apple = function (rgb) { + return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; +}; - this.byteLength = this.length * this.BYTES_PER_ELEMENT; - this.buffer = new ArrayBuffer(this.byteLength); - this.byteOffset = 0; - } else if (typeof arguments[0] === 'object' && arguments[0].constructor === ctor) { - // Constructor(TypedArray array) - array = arguments[0]; +convert$2.gray.rgb = function (args) { + return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; +}; - this.length = array.length; - this.byteLength = this.length * this.BYTES_PER_ELEMENT; - this.buffer = new ArrayBuffer(this.byteLength); - this.byteOffset = 0; +convert$2.gray.hsl = convert$2.gray.hsv = function (args) { + return [0, 0, args[0]]; +}; - for (i = 0; i < this.length; i += 1) { - this._setter(i, array._getter(i)); - } - } else if (typeof arguments[0] === 'object' && - !(arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { - // Constructor(sequence array) - sequence = arguments[0]; +convert$2.gray.hwb = function (gray) { + return [0, 100, gray[0]]; +}; - this.length = ECMAScript.ToUint32(sequence.length); - this.byteLength = this.length * this.BYTES_PER_ELEMENT; - this.buffer = new ArrayBuffer(this.byteLength); - this.byteOffset = 0; - - for (i = 0; i < this.length; i += 1) { - s = sequence[i]; - this._setter(i, Number(s)); - } - } else if (typeof arguments[0] === 'object' && - (arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { - // Constructor(ArrayBuffer buffer, - // optional unsigned long byteOffset, optional unsigned long length) - this.buffer = buffer; +convert$2.gray.cmyk = function (gray) { + return [0, 0, 0, gray[0]]; +}; - this.byteOffset = ECMAScript.ToUint32(byteOffset); - if (this.byteOffset > this.buffer.byteLength) { - throw new RangeError("byteOffset out of range"); - } +convert$2.gray.lab = function (gray) { + return [gray[0], 0, 0]; +}; - if (this.byteOffset % this.BYTES_PER_ELEMENT) { - // The given byteOffset must be a multiple of the element - // size of the specific type, otherwise an exception is raised. - throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size."); - } +convert$2.gray.hex = function (gray) { + var val = Math.round(gray[0] / 100 * 255) & 0xFF; + var integer = (val << 16) + (val << 8) + val; - if (arguments.length < 3) { - this.byteLength = this.buffer.byteLength - this.byteOffset; + var string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; - if (this.byteLength % this.BYTES_PER_ELEMENT) { - throw new RangeError("length of buffer minus byteOffset not a multiple of the element size"); - } - this.length = this.byteLength / this.BYTES_PER_ELEMENT; - } else { - this.length = ECMAScript.ToUint32(length); - this.byteLength = this.length * this.BYTES_PER_ELEMENT; - } +convert$2.rgb.gray = function (rgb) { + var val = (rgb[0] + rgb[1] + rgb[2]) / 3; + return [val / 255 * 100]; +}; - if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { - throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); - } - } else { - throw new TypeError("Unexpected argument type(s)"); - } +var conversions$1 = conversions$2.exports; - this.constructor = ctor; +/* + this function routes a model to all other models. - configureProperties(this); - makeArrayAccessors(this); - }; + all functions that are routed have a property `.conversion` attached + to the returned synthetic function. This property is an array + of strings, each with the steps in between the 'from' and 'to' + color models (inclusive). - ctor.prototype = new ArrayBufferView(); - ctor.prototype.BYTES_PER_ELEMENT = bytesPerElement; - ctor.prototype._pack = pack; - ctor.prototype._unpack = unpack; - ctor.BYTES_PER_ELEMENT = bytesPerElement; + conversions that are not possible simply are not included. +*/ - // getter type (unsigned long index); - ctor.prototype._getter = function(index) { - if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); +function buildGraph() { + var graph = {}; + // https://jsperf.com/object-keys-vs-for-in-with-closure/3 + var models = Object.keys(conversions$1); - index = ECMAScript.ToUint32(index); - if (index >= this.length) { - return undefined$1; - } + for (var len = models.length, i = 0; i < len; i++) { + graph[models[i]] = { + // http://jsperf.com/1-vs-infinity + // micro-opt, but this is simple. + distance: -1, + parent: null + }; + } - var bytes = [], i, o; - for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; - i < this.BYTES_PER_ELEMENT; - i += 1, o += 1) { - bytes.push(this.buffer._bytes[o]); - } - return this._unpack(bytes); - }; + return graph; +} - // NONSTANDARD: convenience alias for getter: type get(unsigned long index); - ctor.prototype.get = ctor.prototype._getter; +// https://en.wikipedia.org/wiki/Breadth-first_search +function deriveBFS(fromModel) { + var graph = buildGraph(); + var queue = [fromModel]; // unshift -> queue -> pop - // setter void (unsigned long index, type value); - ctor.prototype._setter = function(index, value) { - if (arguments.length < 2) throw new SyntaxError("Not enough arguments"); + graph[fromModel].distance = 0; - index = ECMAScript.ToUint32(index); - if (index >= this.length) { - return undefined$1; - } + while (queue.length) { + var current = queue.pop(); + var adjacents = Object.keys(conversions$1[current]); - var bytes = this._pack(value), i, o; - for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; - i < this.BYTES_PER_ELEMENT; - i += 1, o += 1) { - this.buffer._bytes[o] = bytes[i]; - } - }; + for (var len = adjacents.length, i = 0; i < len; i++) { + var adjacent = adjacents[i]; + var node = graph[adjacent]; - // void set(TypedArray array, optional unsigned long offset); - // void set(sequence array, optional unsigned long offset); - ctor.prototype.set = function(index, value) { - if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); - var array, sequence, offset, len, - i, s, d, - byteOffset, byteLength, tmp; + if (node.distance === -1) { + node.distance = graph[current].distance + 1; + node.parent = current; + queue.unshift(adjacent); + } + } + } - if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) { - // void set(TypedArray array, optional unsigned long offset); - array = arguments[0]; - offset = ECMAScript.ToUint32(arguments[1]); + return graph; +} - if (offset + array.length > this.length) { - throw new RangeError("Offset plus length of array is out of range"); - } +function link$1(from, to) { + return function (args) { + return to(from(args)); + }; +} - byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT; - byteLength = array.length * this.BYTES_PER_ELEMENT; +function wrapConversion(toModel, graph) { + var path = [graph[toModel].parent, toModel]; + var fn = conversions$1[graph[toModel].parent][toModel]; - if (array.buffer === this.buffer) { - tmp = []; - for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) { - tmp[i] = array.buffer._bytes[s]; - } - for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) { - this.buffer._bytes[d] = tmp[i]; - } - } else { - for (i = 0, s = array.byteOffset, d = byteOffset; - i < byteLength; i += 1, s += 1, d += 1) { - this.buffer._bytes[d] = array.buffer._bytes[s]; - } - } - } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') { - // void set(sequence array, optional unsigned long offset); - sequence = arguments[0]; - len = ECMAScript.ToUint32(sequence.length); - offset = ECMAScript.ToUint32(arguments[1]); + var cur = graph[toModel].parent; + while (graph[cur].parent) { + path.unshift(graph[cur].parent); + fn = link$1(conversions$1[graph[cur].parent][cur], fn); + cur = graph[cur].parent; + } - if (offset + len > this.length) { - throw new RangeError("Offset plus length of array is out of range"); - } + fn.conversion = path; + return fn; +} - for (i = 0; i < len; i += 1) { - s = sequence[i]; - this._setter(offset + i, Number(s)); - } - } else { - throw new TypeError("Unexpected argument type(s)"); - } - }; +var route$1 = function (fromModel) { + var graph = deriveBFS(fromModel); + var conversion = {}; - // TypedArray subarray(long begin, optional long end); - ctor.prototype.subarray = function(start, end) { - function clamp(v, min, max) { return v < min ? min : v > max ? max : v; } + var models = Object.keys(graph); + for (var len = models.length, i = 0; i < len; i++) { + var toModel = models[i]; + var node = graph[toModel]; - start = ECMAScript.ToInt32(start); - end = ECMAScript.ToInt32(end); + if (node.parent === null) { + // no possible conversion, or this node is the source model. + continue; + } - if (arguments.length < 1) { start = 0; } - if (arguments.length < 2) { end = this.length; } + conversion[toModel] = wrapConversion(toModel, graph); + } - if (start < 0) { start = this.length + start; } - if (end < 0) { end = this.length + end; } + return conversion; +}; - start = clamp(start, 0, this.length); - end = clamp(end, 0, this.length); +var conversions = conversions$2.exports; +var route = route$1; - var len = end - start; - if (len < 0) { - len = 0; - } +var convert$1 = {}; - return new this.constructor( - this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len); - }; +var models = Object.keys(conversions); - return ctor; - } +function wrapRaw(fn) { + var wrappedFn = function (args) { + if (args === undefined || args === null) { + return args; + } - var Int8Array = makeConstructor(1, packI8, unpackI8); - var Uint8Array = makeConstructor(1, packU8, unpackU8); - var Uint8ClampedArray = makeConstructor(1, packU8Clamped, unpackU8); - var Int16Array = makeConstructor(2, packI16, unpackI16); - var Uint16Array = makeConstructor(2, packU16, unpackU16); - var Int32Array = makeConstructor(4, packI32, unpackI32); - var Uint32Array = makeConstructor(4, packU32, unpackU32); - var Float32Array = makeConstructor(4, packF32, unpackF32); - var Float64Array = makeConstructor(8, packF64, unpackF64); + if (arguments.length > 1) { + args = Array.prototype.slice.call(arguments); + } - exports.Int8Array = exports.Int8Array || Int8Array; - exports.Uint8Array = exports.Uint8Array || Uint8Array; - exports.Uint8ClampedArray = exports.Uint8ClampedArray || Uint8ClampedArray; - exports.Int16Array = exports.Int16Array || Int16Array; - exports.Uint16Array = exports.Uint16Array || Uint16Array; - exports.Int32Array = exports.Int32Array || Int32Array; - exports.Uint32Array = exports.Uint32Array || Uint32Array; - exports.Float32Array = exports.Float32Array || Float32Array; - exports.Float64Array = exports.Float64Array || Float64Array; -}()); + return fn(args); + }; -// -// 6 The DataView View Type -// + // preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } -(function() { - function r(array, index) { - return ECMAScript.IsCallable(array.get) ? array.get(index) : array[index]; - } + return wrappedFn; +} - var IS_BIG_ENDIAN = (function() { - var u16array = new(exports.Uint16Array)([0x1234]), - u8array = new(exports.Uint8Array)(u16array.buffer); - return r(u8array, 0) === 0x12; - }()); +function wrapRounded(fn) { + var wrappedFn = function (args) { + if (args === undefined || args === null) { + return args; + } - // Constructor(ArrayBuffer buffer, - // optional unsigned long byteOffset, - // optional unsigned long byteLength) - /** @constructor */ - var DataView = function DataView(buffer, byteOffset, byteLength) { - if (arguments.length === 0) { - buffer = new exports.ArrayBuffer(0); - } else if (!(buffer instanceof exports.ArrayBuffer || ECMAScript.Class(buffer) === 'ArrayBuffer')) { - throw new TypeError("TypeError"); - } + if (arguments.length > 1) { + args = Array.prototype.slice.call(arguments); + } - this.buffer = buffer || new exports.ArrayBuffer(0); + var result = fn(args); - this.byteOffset = ECMAScript.ToUint32(byteOffset); - if (this.byteOffset > this.buffer.byteLength) { - throw new RangeError("byteOffset out of range"); - } + // we're assuming the result is an array here. + // see notice in conversions.js; don't use box types + // in conversion functions. + if (typeof result === 'object') { + for (var len = result.length, i = 0; i < len; i++) { + result[i] = Math.round(result[i]); + } + } - if (arguments.length < 3) { - this.byteLength = this.buffer.byteLength - this.byteOffset; - } else { - this.byteLength = ECMAScript.ToUint32(byteLength); - } + return result; + }; - if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { - throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); - } + // preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } - configureProperties(this); - }; + return wrappedFn; +} - function makeGetter(arrayType) { - return function(byteOffset, littleEndian) { +models.forEach(function (fromModel) { + convert$1[fromModel] = {}; - byteOffset = ECMAScript.ToUint32(byteOffset); + Object.defineProperty(convert$1[fromModel], 'channels', {value: conversions[fromModel].channels}); + Object.defineProperty(convert$1[fromModel], 'labels', {value: conversions[fromModel].labels}); - if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { - throw new RangeError("Array index out of range"); - } - byteOffset += this.byteOffset; + var routes = route(fromModel); + var routeModels = Object.keys(routes); - var uint8Array = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT), - bytes = [], i; - for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { - bytes.push(r(uint8Array, i)); - } + routeModels.forEach(function (toModel) { + var fn = routes[toModel]; - if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { - bytes.reverse(); - } + convert$1[fromModel][toModel] = wrapRounded(fn); + convert$1[fromModel][toModel].raw = wrapRaw(fn); + }); +}); - return r(new arrayType(new exports.Uint8Array(bytes).buffer), 0); - }; - } +var colorConvert = convert$1; - DataView.prototype.getUint8 = makeGetter(exports.Uint8Array); - DataView.prototype.getInt8 = makeGetter(exports.Int8Array); - DataView.prototype.getUint16 = makeGetter(exports.Uint16Array); - DataView.prototype.getInt16 = makeGetter(exports.Int16Array); - DataView.prototype.getUint32 = makeGetter(exports.Uint32Array); - DataView.prototype.getInt32 = makeGetter(exports.Int32Array); - DataView.prototype.getFloat32 = makeGetter(exports.Float32Array); - DataView.prototype.getFloat64 = makeGetter(exports.Float64Array); +(function (module) { +const colorConvert$1 = colorConvert; - function makeSetter(arrayType) { - return function(byteOffset, value, littleEndian) { +const wrapAnsi16 = (fn, offset) => function () { + const code = fn.apply(colorConvert$1, arguments); + return `\u001B[${code + offset}m`; +}; - byteOffset = ECMAScript.ToUint32(byteOffset); - if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { - throw new RangeError("Array index out of range"); - } +const wrapAnsi256 = (fn, offset) => function () { + const code = fn.apply(colorConvert$1, arguments); + return `\u001B[${38 + offset};5;${code}m`; +}; - // Get bytes - var typeArray = new arrayType([value]), - byteArray = new exports.Uint8Array(typeArray.buffer), - bytes = [], i, byteView; +const wrapAnsi16m = (fn, offset) => function () { + const rgb = fn.apply(colorConvert$1, arguments); + return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; +}; - for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { - bytes.push(r(byteArray, i)); - } +function assembleStyles() { + const codes = new Map(); + const styles = { + modifier: { + reset: [0, 0], + // 21 isn't widely supported and 22 does the same thing + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + color: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + gray: [90, 39], - // Flip if necessary - if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { - bytes.reverse(); - } + // Bright color + redBright: [91, 39], + greenBright: [92, 39], + yellowBright: [93, 39], + blueBright: [94, 39], + magentaBright: [95, 39], + cyanBright: [96, 39], + whiteBright: [97, 39] + }, + bgColor: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], - // Write them - byteView = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT); - byteView.set(bytes); - }; - } + // Bright color + bgBlackBright: [100, 49], + bgRedBright: [101, 49], + bgGreenBright: [102, 49], + bgYellowBright: [103, 49], + bgBlueBright: [104, 49], + bgMagentaBright: [105, 49], + bgCyanBright: [106, 49], + bgWhiteBright: [107, 49] + } + }; - DataView.prototype.setUint8 = makeSetter(exports.Uint8Array); - DataView.prototype.setInt8 = makeSetter(exports.Int8Array); - DataView.prototype.setUint16 = makeSetter(exports.Uint16Array); - DataView.prototype.setInt16 = makeSetter(exports.Int16Array); - DataView.prototype.setUint32 = makeSetter(exports.Uint32Array); - DataView.prototype.setInt32 = makeSetter(exports.Int32Array); - DataView.prototype.setFloat32 = makeSetter(exports.Float32Array); - DataView.prototype.setFloat64 = makeSetter(exports.Float64Array); + // Fix humans + styles.color.grey = styles.color.gray; - exports.DataView = exports.DataView || DataView; + for (const groupName of Object.keys(styles)) { + const group = styles[groupName]; -}()); -}(typedarray)); + for (const styleName of Object.keys(group)) { + const style = group[styleName]; -var Writable = require$$0__default$5['default'].Writable; -var inherits$1 = inherits$3.exports; -var bufferFrom = bufferFrom_1; + styles[styleName] = { + open: `\u001B[${style[0]}m`, + close: `\u001B[${style[1]}m` + }; -if (typeof Uint8Array === 'undefined') { - var U8 = typedarray.Uint8Array; -} else { - var U8 = Uint8Array; -} + group[styleName] = styles[styleName]; -function ConcatStream(opts, cb) { - if (!(this instanceof ConcatStream)) return new ConcatStream(opts, cb) + codes.set(style[0], style[1]); + } - if (typeof opts === 'function') { - cb = opts; - opts = {}; - } - if (!opts) opts = {}; + Object.defineProperty(styles, groupName, { + value: group, + enumerable: false + }); - var encoding = opts.encoding; - var shouldInferEncoding = false; + Object.defineProperty(styles, 'codes', { + value: codes, + enumerable: false + }); + } - if (!encoding) { - shouldInferEncoding = true; - } else { - encoding = String(encoding).toLowerCase(); - if (encoding === 'u8' || encoding === 'uint8') { - encoding = 'uint8array'; - } - } + const ansi2ansi = n => n; + const rgb2rgb = (r, g, b) => [r, g, b]; - Writable.call(this, { objectMode: true }); + styles.color.close = '\u001B[39m'; + styles.bgColor.close = '\u001B[49m'; - this.encoding = encoding; - this.shouldInferEncoding = shouldInferEncoding; + styles.color.ansi = { + ansi: wrapAnsi16(ansi2ansi, 0) + }; + styles.color.ansi256 = { + ansi256: wrapAnsi256(ansi2ansi, 0) + }; + styles.color.ansi16m = { + rgb: wrapAnsi16m(rgb2rgb, 0) + }; - if (cb) this.on('finish', function () { cb(this.getBody()); }); - this.body = []; -} - -var concatStream = ConcatStream; -inherits$1(ConcatStream, Writable); - -ConcatStream.prototype._write = function(chunk, enc, next) { - this.body.push(chunk); - next(); -}; - -ConcatStream.prototype.inferEncoding = function (buff) { - var firstBuffer = buff === undefined ? this.body[0] : buff; - if (Buffer.isBuffer(firstBuffer)) return 'buffer' - if (typeof Uint8Array !== 'undefined' && firstBuffer instanceof Uint8Array) return 'uint8array' - if (Array.isArray(firstBuffer)) return 'array' - if (typeof firstBuffer === 'string') return 'string' - if (Object.prototype.toString.call(firstBuffer) === "[object Object]") return 'object' - return 'buffer' -}; + styles.bgColor.ansi = { + ansi: wrapAnsi16(ansi2ansi, 10) + }; + styles.bgColor.ansi256 = { + ansi256: wrapAnsi256(ansi2ansi, 10) + }; + styles.bgColor.ansi16m = { + rgb: wrapAnsi16m(rgb2rgb, 10) + }; -ConcatStream.prototype.getBody = function () { - if (!this.encoding && this.body.length === 0) return [] - if (this.shouldInferEncoding) this.encoding = this.inferEncoding(); - if (this.encoding === 'array') return arrayConcat(this.body) - if (this.encoding === 'string') return stringConcat(this.body) - if (this.encoding === 'buffer') return bufferConcat(this.body) - if (this.encoding === 'uint8array') return u8Concat(this.body) - return this.body -}; + for (let key of Object.keys(colorConvert$1)) { + if (typeof colorConvert$1[key] !== 'object') { + continue; + } -function isArrayish (arr) { - return /Array\]$/.test(Object.prototype.toString.call(arr)) -} + const suite = colorConvert$1[key]; -function isBufferish (p) { - return typeof p === 'string' || isArrayish(p) || (p && typeof p.subarray === 'function') -} + if (key === 'ansi16') { + key = 'ansi'; + } -function stringConcat (parts) { - var strings = []; - for (var i = 0; i < parts.length; i++) { - var p = parts[i]; - if (typeof p === 'string') { - strings.push(p); - } else if (Buffer.isBuffer(p)) { - strings.push(p); - } else if (isBufferish(p)) { - strings.push(bufferFrom(p)); - } else { - strings.push(bufferFrom(String(p))); - } - } - if (Buffer.isBuffer(parts[0])) { - strings = Buffer.concat(strings); - strings = strings.toString('utf8'); - } else { - strings = strings.join(''); - } - return strings -} + if ('ansi16' in suite) { + styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); + styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); + } -function bufferConcat (parts) { - var bufs = []; - for (var i = 0; i < parts.length; i++) { - var p = parts[i]; - if (Buffer.isBuffer(p)) { - bufs.push(p); - } else if (isBufferish(p)) { - bufs.push(bufferFrom(p)); - } else { - bufs.push(bufferFrom(String(p))); - } - } - return Buffer.concat(bufs) -} + if ('ansi256' in suite) { + styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); + styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); + } -function arrayConcat (parts) { - var res = []; - for (var i = 0; i < parts.length; i++) { - res.push.apply(res, parts[i]); - } - return res -} + if ('rgb' in suite) { + styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); + styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); + } + } -function u8Concat (parts) { - var len = 0; - for (var i = 0; i < parts.length; i++) { - if (typeof parts[i] === 'string') { - parts[i] = bufferFrom(parts[i]); - } - len += parts[i].length; - } - var u8 = new U8(len); - for (var i = 0, offset = 0; i < parts.length; i++) { - var part = parts[i]; - for (var j = 0; j < part.length; j++) { - u8[offset++] = part[j]; - } - } - return u8 + return styles; } -var debug$b = src.exports('unified-engine:file-set-pipeline:stdin'); -var vfile$3 = toVfile; -var concat = concatStream; +// Make the export immutable +Object.defineProperty(module, 'exports', { + enumerable: true, + get: assembleStyles +}); +}(ansiStyles)); -var stdin_1 = stdin$1; +var hasFlag$2 = (flag, argv) => { + argv = argv || process.argv; + const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); + const pos = argv.indexOf(prefix + flag); + const terminatorPos = argv.indexOf('--'); + return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); +}; -function stdin$1(context, settings, next) { - var error; +const os$1 = require$$0__default['default']; +const hasFlag$1 = hasFlag$2; - if (settings.files && settings.files.length > 0) { - debug$b('Ignoring `streamIn`'); +const env$1 = process.env; - if (settings.filePath) { - error = new Error( - 'Do not pass both `--file-path` and real files.\nDid you mean to pass stdin instead of files?' - ); - } +let forceColor; +if (hasFlag$1('no-color') || + hasFlag$1('no-colors') || + hasFlag$1('color=false')) { + forceColor = false; +} else if (hasFlag$1('color') || + hasFlag$1('colors') || + hasFlag$1('color=true') || + hasFlag$1('color=always')) { + forceColor = true; +} +if ('FORCE_COLOR' in env$1) { + forceColor = env$1.FORCE_COLOR.length === 0 || parseInt(env$1.FORCE_COLOR, 10) !== 0; +} - next(error); +function translateLevel$1(level) { + if (level === 0) { + return false; + } - return - } + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; +} - if (settings.streamIn.isTTY) { - debug$b('Cannot read from `tty` stream'); - next(new Error('No input')); +function supportsColor$1(stream) { + if (forceColor === false) { + return 0; + } - return - } + if (hasFlag$1('color=16m') || + hasFlag$1('color=full') || + hasFlag$1('color=truecolor')) { + return 3; + } - debug$b('Reading from `streamIn`'); + if (hasFlag$1('color=256')) { + return 2; + } - settings.streamIn.pipe(concat({encoding: 'string'}, read)); + if (stream && !stream.isTTY && forceColor !== true) { + return 0; + } - function read(value) { - var file = vfile$3(settings.filePath || undefined); + const min = forceColor ? 1 : 0; - debug$b('Read from `streamIn`'); + if (process.platform === 'win32') { + // Node.js 7.5.0 is the first version of Node.js to include a patch to + // libuv that enables 256 color output on Windows. Anything earlier and it + // won't work. However, here we target Node.js 8 at minimum as it is an LTS + // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows + // release that supports 256 colors. Windows 10 build 14931 is the first release + // that supports 16m/TrueColor. + const osRelease = os$1.release().split('.'); + if ( + Number(process.versions.node.split('.')[0]) >= 8 && + Number(osRelease[0]) >= 10 && + Number(osRelease[2]) >= 10586 + ) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } - file.cwd = settings.cwd; - file.contents = value; - file.data.unifiedEngineGiven = true; - file.data.unifiedEngineStreamIn = true; + return 1; + } - context.files = [file]; + if ('CI' in env$1) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') { + return 1; + } - // If `out` was not set, set `out`. - settings.out = - settings.out === null || settings.out === undefined ? true : settings.out; + return min; + } - next(); - } -} + if ('TEAMCITY_VERSION' in env$1) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0; + } -var events = require$$0__default$4['default']; -var inherits = require$$0__default['default'].inherits; -var trough$3 = trough_1; -var vfile$2 = toVfile; + if (env$1.COLORTERM === 'truecolor') { + return 3; + } -var fileSet = FileSet$1; + if ('TERM_PROGRAM' in env$1) { + const version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10); -// FileSet constructor. -function FileSet$1() { - var self = this; + switch (env$1.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Apple_Terminal': + return 2; + // No default + } + } - self.files = []; - self.origins = []; + if (/-256(color)?$/i.test(env$1.TERM)) { + return 2; + } - self.expected = 0; - self.actual = 0; + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) { + return 1; + } - self.pipeline = trough$3(); - self.plugins = []; + if ('COLORTERM' in env$1) { + return 1; + } - events.init.call(self); + if (env$1.TERM === 'dumb') { + return min; + } - self.on('one', one$1.bind(self)); + return min; } -// Events. -inherits(FileSet$1, events.EventEmitter); - -// Expose methods. -FileSet$1.prototype.valueOf = valueOf; -FileSet$1.prototype.use = use; -FileSet$1.prototype.add = add; - -// Create an array representation of `fileSet`. -function valueOf() { - return this.files +function getSupportLevel(stream) { + const level = supportsColor$1(stream); + return translateLevel$1(level); } -// Attach middleware to the pipeline on `fileSet`. -function use(plugin) { - var self = this; - var pipeline = self.pipeline; - var duplicate = false; - - if (plugin && plugin.pluginId) { - duplicate = self.plugins.some(matches); - } +var supportsColor_1 = { + supportsColor: getSupportLevel, + stdout: getSupportLevel(process.stdout), + stderr: getSupportLevel(process.stderr) +}; - if (!duplicate && self.plugins.indexOf(plugin) !== -1) { - duplicate = true; - } +const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; +const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; +const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; +const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi; - if (!duplicate) { - self.plugins.push(plugin); - pipeline.use(plugin); - } +const ESCAPES = new Map([ + ['n', '\n'], + ['r', '\r'], + ['t', '\t'], + ['b', '\b'], + ['f', '\f'], + ['v', '\v'], + ['0', '\0'], + ['\\', '\\'], + ['e', '\u001B'], + ['a', '\u0007'] +]); - return self +function unescape(c) { + if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) { + return String.fromCharCode(parseInt(c.slice(1), 16)); + } - function matches(fn) { - return fn.pluginId === plugin.pluginId - } + return ESCAPES.get(c) || c; } -// Add a file to be processed. -// Ignores duplicate files (based on the `filePath` at time of addition). -// Only runs `file-pipeline` on files which have not `failed` before addition. -function add(file) { - var self = this; +function parseArguments(name, args) { + const results = []; + const chunks = args.trim().split(/\s*,\s*/g); + let matches; - if (typeof file === 'string') { - file = vfile$2(file); - } + for (const chunk of chunks) { + if (!isNaN(chunk)) { + results.push(Number(chunk)); + } else if ((matches = chunk.match(STRING_REGEX))) { + results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr)); + } else { + throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); + } + } - // Prevent files from being added multiple times. - if (self.origins.indexOf(file.history[0]) !== -1) { - return self - } + return results; +} - self.origins.push(file.history[0]); +function parseStyle(style) { + STYLE_REGEX.lastIndex = 0; - // Add. - self.valueOf().push(file); - self.expected++; + const results = []; + let matches; - // Force an asynchronous operation. - // This ensures that files which fall through the file pipeline immediately - // (such as, when already fatally failed) still queue up correctly. - setImmediate(add); + while ((matches = STYLE_REGEX.exec(style)) !== null) { + const name = matches[1]; - return self + if (matches[2]) { + const args = parseArguments(name, matches[2]); + results.push([name].concat(args)); + } else { + results.push([name]); + } + } - function add() { - self.emit('add', file); - } + return results; } -// Utility invoked when a single file has completed it's pipeline, triggering -// `done` when all files are complete. -function one$1() { - var self = this; +function buildStyle(chalk, styles) { + const enabled = {}; - self.actual++; + for (const layer of styles) { + for (const style of layer.styles) { + enabled[style[0]] = layer.inverse ? null : style.slice(1); + } + } - if (self.actual >= self.expected) { - self.emit('done'); - } -} + let current = chalk; + for (const styleName of Object.keys(enabled)) { + if (Array.isArray(enabled[styleName])) { + if (!(styleName in current)) { + throw new Error(`Unknown Chalk style: ${styleName}`); + } -var fs$6 = require$$0__default$3['default']; -var path$6 = require$$0__default$2['default']; -var debug$a = src.exports('unified-engine:file-pipeline:read'); -var stats$7 = vfileStatistics; + if (enabled[styleName].length > 0) { + current = current[styleName].apply(current, enabled[styleName]); + } else { + current = current[styleName]; + } + } + } -var read_1 = read$2; + return current; +} -// Fill a file with its contents when not already filled. -function read$2(context, file, fileSet, next) { - var filePath = file.path; +var templates = (chalk, tmp) => { + const styles = []; + const chunks = []; + let chunk = []; - if (file.contents || file.data.unifiedEngineStreamIn) { - debug$a('Not reading file `%s` with contents', filePath); - next(); - } else if (stats$7(file).fatal) { - debug$a('Not reading failed file `%s`', filePath); - next(); - } else { - filePath = path$6.resolve(context.cwd, filePath); + // eslint-disable-next-line max-params + tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => { + if (escapeChar) { + chunk.push(unescape(escapeChar)); + } else if (style) { + const str = chunk.join(''); + chunk = []; + chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str)); + styles.push({inverse, styles: parseStyle(style)}); + } else if (close) { + if (styles.length === 0) { + throw new Error('Found extraneous } in Chalk template literal'); + } - debug$a('Reading `%s` in `%s`', filePath, 'utf8'); - fs$6.readFile(filePath, 'utf8', onread); - } + chunks.push(buildStyle(chalk, styles)(chunk.join(''))); + chunk = []; + styles.pop(); + } else { + chunk.push(chr); + } + }); - function onread(error, contents) { - debug$a('Read `%s` (error: %s)', filePath, error); + chunks.push(chunk.join('')); - file.contents = contents || ''; + if (styles.length > 0) { + const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; + throw new Error(errMsg); + } - next(error); - } -} + return chunks.join(''); +}; -/** - * Has own property. - * - * @type {Function} - */ +(function (module) { +const escapeStringRegexp = escapeStringRegexp$1; +const ansiStyles$1 = ansiStyles.exports; +const stdoutColor = supportsColor_1.stdout; -var has = Object.prototype.hasOwnProperty; +const template = templates; -/** - * To string. - * - * @type {Function} - */ +const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); -var toString$7 = Object.prototype.toString; +// `supportsColor.level` → `ansiStyles.color[name]` mapping +const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; -/** - * Test whether a value is "empty". - * - * @param {Mixed} val - * @return {Boolean} - */ +// `color-convert` models to exclude from the Chalk API due to conflicts and such +const skipModels = new Set(['gray']); -function isEmpty$1(val) { - // Null and Undefined... - if (val == null) return true +const styles = Object.create(null); - // Booleans... - if ('boolean' == typeof val) return false +function applyOptions(obj, options) { + options = options || {}; - // Numbers... - if ('number' == typeof val) return val === 0 + // Detect level if not set manually + const scLevel = stdoutColor ? stdoutColor.level : 0; + obj.level = options.level === undefined ? scLevel : options.level; + obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; +} - // Strings... - if ('string' == typeof val) return val.length === 0 +function Chalk(options) { + // We check for this.template here since calling `chalk.constructor()` + // by itself will have a `this` of a previously constructed chalk object + if (!this || !(this instanceof Chalk) || this.template) { + const chalk = {}; + applyOptions(chalk, options); - // Functions... - if ('function' == typeof val) return val.length === 0 + chalk.template = function () { + const args = [].slice.call(arguments); + return chalkTag.apply(null, [chalk.template].concat(args)); + }; - // Arrays... - if (Array.isArray(val)) return val.length === 0 + Object.setPrototypeOf(chalk, Chalk.prototype); + Object.setPrototypeOf(chalk.template, chalk); - // Errors... - if (val instanceof Error) return val.message === '' + chalk.template.constructor = Chalk; - // Objects... - if (val.toString == toString$7) { - switch (val.toString()) { + return chalk.template; + } - // Maps, Sets, Files and Errors... - case '[object File]': - case '[object Map]': - case '[object Set]': { - return val.size === 0 - } + applyOptions(this, options); +} - // Plain objects... - case '[object Object]': { - for (var key in val) { - if (has.call(val, key)) return false - } +// Use bright blue on Windows as the normal blue color is illegible +if (isSimpleWindowsTerm) { + ansiStyles$1.blue.open = '\u001B[94m'; +} - return true - } - } - } +for (const key of Object.keys(ansiStyles$1)) { + ansiStyles$1[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles$1[key].close), 'g'); - // Anything else... - return false + styles[key] = { + get() { + const codes = ansiStyles$1[key]; + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); + } + }; } -/** - * Export `isEmpty`. - * - * @type {Function} - */ +styles.visible = { + get() { + return build.call(this, this._styles || [], true, 'visible'); + } +}; -var lib$5 = isEmpty$1; +ansiStyles$1.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles$1.color.close), 'g'); +for (const model of Object.keys(ansiStyles$1.color.ansi)) { + if (skipModels.has(model)) { + continue; + } -var debug$9 = src.exports('unified-engine:file-pipeline:configure'); -var stats$6 = vfileStatistics; -var empty$3 = lib$5; + styles[model] = { + get() { + const level = this.level; + return function () { + const open = ansiStyles$1.color[levelMapping[level]][model].apply(null, arguments); + const codes = { + open, + close: ansiStyles$1.color.close, + closeRe: ansiStyles$1.color.closeRe + }; + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); + }; + } + }; +} -var configure_1$1 = configure$5; +ansiStyles$1.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles$1.bgColor.close), 'g'); +for (const model of Object.keys(ansiStyles$1.bgColor.ansi)) { + if (skipModels.has(model)) { + continue; + } -// Collect configuration for a file based on the context. -function configure$5(context, file, fileSet, next) { - if (stats$6(file).fatal) { - return next() - } + const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); + styles[bgModel] = { + get() { + const level = this.level; + return function () { + const open = ansiStyles$1.bgColor[levelMapping[level]][model].apply(null, arguments); + const codes = { + open, + close: ansiStyles$1.bgColor.close, + closeRe: ansiStyles$1.bgColor.closeRe + }; + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); + }; + } + }; +} - context.configuration.load(file.path, handleConfiguration); +const proto = Object.defineProperties(() => {}, styles); - function handleConfiguration(error, configuration) { - var index = -1; - var plugin; - var options; +function build(_styles, _empty, key) { + const builder = function () { + return applyStyle.apply(builder, arguments); + }; - if (error) { - return next(error) - } + builder._styles = _styles; + builder._empty = _empty; - // Store configuration on the context object. - debug$9('Using settings `%j`', configuration.settings); - context.processor.data('settings', configuration.settings); + const self = this; - debug$9('Using `%d` plugins', configuration.plugins.length); + Object.defineProperty(builder, 'level', { + enumerable: true, + get() { + return self.level; + }, + set(level) { + self.level = level; + } + }); - while (++index < configuration.plugins.length) { - plugin = configuration.plugins[index][0]; - options = configuration.plugins[index][1]; + Object.defineProperty(builder, 'enabled', { + enumerable: true, + get() { + return self.enabled; + }, + set(enabled) { + self.enabled = enabled; + } + }); - if (options === false) { - continue - } - - // Allow for default arguments in es2020. - if (options === null || (typeof options === 'object' && empty$3(options))) { - options = undefined; - } - - debug$9( - 'Using plugin `%s`, with options `%j`', - plugin.displayName || plugin.name || 'function', - options - ); + // See below for fix regarding invisible grey/dim combination on Windows + builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; - try { - context.processor.use(plugin, options, fileSet); - } catch (error_) { - /* istanbul ignore next - Should not happen anymore! */ - return next(error_) - } - } + // `__proto__` is used because we must return a function, but there is + // no way to create a function with a different prototype + builder.__proto__ = proto; // eslint-disable-line no-proto - next(); - } + return builder; } -var debug$8 = src.exports('unified-engine:file-pipeline:parse'); -var stats$5 = vfileStatistics; -var json$1 = parseJson_1; - -var parse_1$4 = parse$a; - -// Fill a file with a tree. -function parse$a(context, file) { - var message; - - if (stats$5(file).fatal) { - return - } +function applyStyle() { + // Support varags, but simply cast to string in case there's only one arg + const args = arguments; + const argsLen = args.length; + let str = String(arguments[0]); - if (context.treeIn) { - debug$8('Not parsing already parsed document'); + if (argsLen === 0) { + return ''; + } - try { - context.tree = json$1(file.toString()); - } catch (error) { - message = file.message( - new Error('Cannot read file as JSON\n' + error.message) - ); - message.fatal = true; - } + if (argsLen > 1) { + // Don't slice `arguments`, it prevents V8 optimizations + for (let a = 1; a < argsLen; a++) { + str += ' ' + args[a]; + } + } - // Add the preferred extension to ensure the file, when serialized, is - // correctly recognised. - // Only add it if there is a path — not if the file is for example stdin. - if (file.path) { - file.extname = context.extensions[0]; - } + if (!this.enabled || this.level <= 0 || !str) { + return this._empty ? '' : str; + } - file.contents = ''; + // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, + // see https://github.com/chalk/chalk/issues/58 + // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. + const originalDim = ansiStyles$1.dim.open; + if (isSimpleWindowsTerm && this.hasGrey) { + ansiStyles$1.dim.open = ''; + } - return - } + for (const code of this._styles.slice().reverse()) { + // Replace any instances already present with a re-opening code + // otherwise only the part of the string until said closing code + // will be colored, and the rest will simply be 'plain'. + str = code.open + str.replace(code.closeRe, code.open) + code.close; - debug$8('Parsing `%s`', file.path); + // Close the styling before a linebreak and reopen + // after next line to fix a bleed issue on macOS + // https://github.com/chalk/chalk/pull/92 + str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); + } - context.tree = context.processor.parse(file); + // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue + ansiStyles$1.dim.open = originalDim; - debug$8('Parsed document'); + return str; } -var debug$7 = src.exports('unified-engine:file-pipeline:transform'); -var stats$4 = vfileStatistics; +function chalkTag(chalk, strings) { + if (!Array.isArray(strings)) { + // If chalk() was called by itself or with a string, + // return the string itself as a string. + return [].slice.call(arguments, 1).join(' '); + } -var transform_1$1 = transform$5; + const args = [].slice.call(arguments, 2); + const parts = [strings.raw[0]]; -// Transform the tree associated with a file with configured plugins. -function transform$5(context, file, fileSet, next) { - if (stats$4(file).fatal) { - next(); - } else { - debug$7('Transforming document `%s`', file.path); - context.processor.run(context.tree, file, onrun); - } + for (let i = 1; i < strings.length; i++) { + parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); + parts.push(String(strings.raw[i])); + } - function onrun(error, node) { - debug$7('Transformed document (error: %s)', error); - context.tree = node; - next(error); - } + return template(chalk, parts.join('')); } -var debug$6 = src.exports('unified-engine:file-pipeline:queue'); -var stats$3 = vfileStatistics; +Object.defineProperties(Chalk.prototype, styles); -var queue_1 = queue$1; +module.exports = Chalk(); // eslint-disable-line new-cap +module.exports.supportsColor = stdoutColor; +module.exports.default = module.exports; // For TypeScript +}(chalk)); -// Queue all files which came this far. -// When the last file gets here, run the file-set pipeline and flush the queue. -function queue$1(context, file, fileSet, next) { - var origin = file.history[0]; - var map = fileSet.complete; - var complete = true; +Object.defineProperty(lib$3, "__esModule", { + value: true +}); +lib$3.shouldHighlight = shouldHighlight; +lib$3.getChalk = getChalk; +lib$3.default = highlight; - if (!map) { - map = {}; - fileSet.complete = map; - } +var _jsTokens = jsTokens; - debug$6('Queueing `%s`', origin); +var _helperValidatorIdentifier = lib$2; - map[origin] = next; +var _chalk = chalk.exports; - fileSet.valueOf().forEach(each); +const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]); - if (!complete) { - debug$6('Not flushing: some files cannot be flushed'); - return - } +function getDefs$1(chalk) { + return { + keyword: chalk.cyan, + capitalized: chalk.yellow, + jsxIdentifier: chalk.yellow, + punctuator: chalk.yellow, + number: chalk.magenta, + string: chalk.green, + regex: chalk.magenta, + comment: chalk.grey, + invalid: chalk.white.bgRed.bold + }; +} - fileSet.complete = {}; +const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/; +const BRACKET = /^[()[\]{}]$/; +let tokenize; +{ + const JSX_TAG = /^[a-z][\w-]*$/i; - fileSet.pipeline.run(fileSet, done); + const getTokenType = function (token, offset, text) { + if (token.type === "name") { + if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) { + return "keyword"; + } - function each(file) { - var key = file.history[0]; + if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == " colorize(str)).join("\n"); } else { - result.push(formatNesting(pad + '├─ ') + inspect$2(node, pad + '│ ')); + highlighted += value; } } - return result.join('\n') + return highlighted; } -// Colored nesting formatter. -function formatNesting(value) { - return dim(value) +function shouldHighlight(options) { + return !!_chalk.supportsColor || options.forceColor; } -// Compile a single position. -function compile$2(pos) { - var values = []; +function getChalk(options) { + return options.forceColor ? new _chalk.constructor({ + enabled: true, + level: 1 + }) : _chalk; +} - if (!pos) { - return null +function highlight(code, options = {}) { + if (shouldHighlight(options)) { + const chalk = getChalk(options); + const defs = getDefs$1(chalk); + return highlightTokens(defs, code); + } else { + return code; } +} + +Object.defineProperty(lib$4, "__esModule", { + value: true +}); +lib$4.codeFrameColumns = codeFrameColumns$1; +lib$4.default = _default; - values = [[pos.line || 1, pos.column || 1].join(':')]; +var _highlight = lib$3; - if ('offset' in pos) { - values.push(String(pos.offset || 0)); - } +let deprecationWarningShown = false; - return values +function getDefs(chalk) { + return { + gutter: chalk.grey, + marker: chalk.red.bold, + message: chalk.red.bold + }; } -// Compile a location. -function stringify$c(start, end) { - var values = []; - var positions = []; - var offsets = []; +const NEWLINE = /\r\n|[\n\r\u2028\u2029]/; - add(start); - add(end); +function getMarkerLines(loc, source, opts) { + const startLoc = Object.assign({ + column: 0, + line: -1 + }, loc.start); + const endLoc = Object.assign({}, startLoc, loc.end); + const { + linesAbove = 2, + linesBelow = 3 + } = opts || {}; + const startLine = startLoc.line; + const startColumn = startLoc.column; + const endLine = endLoc.line; + const endColumn = endLoc.column; + let start = Math.max(startLine - (linesAbove + 1), 0); + let end = Math.min(source.length, endLine + linesBelow); - if (positions.length !== 0) { - values.push(positions.join('-')); + if (startLine === -1) { + start = 0; } - if (offsets.length !== 0) { - values.push(offsets.join('-')); + if (endLine === -1) { + end = source.length; } - return values.join(', ') - - // Add a position. - function add(position) { - var tuple = compile$2(position); + const lineDiff = endLine - startLine; + const markerLines = {}; - if (tuple) { - positions.push(tuple[0]); + if (lineDiff) { + for (let i = 0; i <= lineDiff; i++) { + const lineNumber = i + startLine; - if (tuple[1]) { - offsets.push(tuple[1]); + if (!startColumn) { + markerLines[lineNumber] = true; + } else if (i === 0) { + const sourceLength = source[lineNumber - 1].length; + markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1]; + } else if (i === lineDiff) { + markerLines[lineNumber] = [0, endColumn]; + } else { + const sourceLength = source[lineNumber - i].length; + markerLines[lineNumber] = [0, sourceLength]; } } - } -} - -// Colored node formatter. -function formatNode(node) { - var log = node.type; - var location = node.position || {}; - var position = stringify$c(location.start, location.end); - var key; - var values = []; - var value; - - if (node.children) { - log += dim('[') + yellow(node.children.length) + dim(']'); - } else if (typeof node.value === 'string') { - log += dim(': ') + green(JSON.stringify(node.value)); - } - - if (position) { - log += ' (' + position + ')'; - } - - for (key in node) { - value = node[key]; - - if ( - ignore.indexOf(key) !== -1 || - value === null || - value === undefined || - (typeof value === 'object' && isEmpty(value)) - ) { - continue + } else { + if (startColumn === endColumn) { + if (startColumn) { + markerLines[startLine] = [startColumn, 0]; + } else { + markerLines[startLine] = true; + } + } else { + markerLines[startLine] = [startColumn, endColumn - startColumn]; } - - values.push('[' + key + '=' + JSON.stringify(value) + ']'); } - if (values.length !== 0) { - log += ' ' + values.join(''); - } - - return log -} - -// Remove ANSI colour from `value`. -function stripColor(value) { - return value.replace(colorExpression, '') -} - -// Factory to wrap values in ANSI colours. -function ansiColor(open, close) { - return color - - function color(value) { - return '\u001B[' + open + 'm' + value + '\u001B[' + close + 'm' - } + return { + start, + end, + markerLines + }; } -var debug$5 = src.exports('unified-engine:file-pipeline:stringify'); -var buffer$3 = isBuffer; -var stats$2 = vfileStatistics; -var inspect$1 = unistUtilInspect; - -var stringify_1 = stringify$b; +function codeFrameColumns$1(rawLines, loc, opts = {}) { + const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts); + const chalk = (0, _highlight.getChalk)(opts); + const defs = getDefs(chalk); -// Stringify a tree. -function stringify$b(context, file) { - var value; + const maybeHighlight = (chalkFn, string) => { + return highlighted ? chalkFn(string) : string; + }; - if (stats$2(file).fatal) { - debug$5('Not compiling failed document'); - return - } + const lines = rawLines.split(NEWLINE); + const { + start, + end, + markerLines + } = getMarkerLines(loc, lines, opts); + const hasColumns = loc.start && typeof loc.start.column === "number"; + const numberMaxWidth = String(end).length; + const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines; + let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => { + const number = start + 1 + index; + const paddedNumber = ` ${number}`.slice(-numberMaxWidth); + const gutter = ` ${paddedNumber} |`; + const hasMarker = markerLines[number]; + const lastMarkerLine = !markerLines[number + 1]; - if (!context.output && !context.out && !context.alwaysStringify) { - debug$5('Not compiling document without output settings'); - return - } + if (hasMarker) { + let markerLine = ""; - debug$5('Compiling `%s`', file.path); + if (Array.isArray(hasMarker)) { + const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " "); + const numberOfMarkers = hasMarker[1] || 1; + markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join(""); - if (context.inspect) { - // Add a `txt` extension if there is a path. - if (file.path) { - file.extname = '.txt'; - } + if (lastMarkerLine && opts.message) { + markerLine += " " + maybeHighlight(defs.message, opts.message); + } + } - value = inspect$1[context.color ? 'color' : 'noColor'](context.tree) + '\n'; - } else if (context.treeOut) { - // Add a `json` extension to ensure the file is correctly seen as JSON. - // Only add it if there is a path — not if the file is for example stdin. - if (file.path) { - file.extname = '.json'; + return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join(""); + } else { + return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`; } + }).join("\n"); - // Add the line feed to create a valid UNIX file. - value = JSON.stringify(context.tree, null, 2) + '\n'; - } else { - value = context.processor.stringify(context.tree, file); + if (opts.message && !hasColumns) { + frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`; } - if (value === undefined || value === null) ; else if (typeof value === 'string' || buffer$3(value)) { - file.contents = value; + if (highlighted) { + return chalk.reset(frame); } else { - file.result = value; + return frame; } - - debug$5('Serialized document'); } -var fs$5 = require$$0__default$3['default']; -var path$5 = require$$0__default$2['default']; -var debug$4 = src.exports('unified-engine:file-pipeline:copy'); - -var copy_1 = copy$4; - -// Move a file. -function copy$4(context, file, fileSet, next) { - var output = context.output; - var outpath = output; - var currentPath = file.path; - - if (typeof outpath !== 'string') { - debug$4('Not copying'); - return next() - } - - outpath = path$5.resolve(context.cwd, outpath); - - debug$4('Copying `%s`', currentPath); - - fs$5.stat(outpath, onstatfile); - - function onstatfile(error, stats) { - if (error) { - if ( - error.code !== 'ENOENT' || - output.charAt(output.length - 1) === path$5.sep - ) { - return next( - new Error('Cannot read output directory. Error:\n' + error.message) - ) - } - - fs$5.stat(path$5.dirname(outpath), onstatparent); - } else { - done(stats.isDirectory()); - } - } +function _default(rawLines, lineNumber, colNumber, opts = {}) { + if (!deprecationWarningShown) { + deprecationWarningShown = true; + const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`."; - // This is either given an error, or the parent exists which is a directory, - // but we should keep the basename of the given file. - function onstatparent(error) { - if (error) { - next(new Error('Cannot read parent directory. Error:\n' + error.message)); + if (process.emitWarning) { + process.emitWarning(message, "DeprecationWarning"); } else { - done(false); + const deprecationError = new Error(message); + deprecationError.name = "DeprecationWarning"; + console.warn(new Error(message)); } } - function done(directory) { - if (!directory && fileSet.expected > 1) { - return next( - new Error('Cannot write multiple files to single output: ' + outpath) - ) + colNumber = Math.max(colNumber, 0); + const location = { + start: { + column: colNumber, + line: lineNumber } - - file[directory ? 'dirname' : 'path'] = path$5.relative(file.cwd, outpath); - - debug$4('Copying document from %s to %s', currentPath, file.path); - - next(); - } -} - -var debug$3 = src.exports('unified-engine:file-pipeline:stdout'); -var stats$1 = vfileStatistics; - -var stdout_1 = stdout$1; - -// Write a virtual file to `streamOut`. -// Ignored when `output` is given, more than one file was processed, or `out` -// is false. -function stdout$1(context, file, fileSet, next) { - if (!file.data.unifiedEngineGiven) { - debug$3('Ignoring programmatically added file'); - next(); - } else if (stats$1(file).fatal || context.output || !context.out) { - debug$3('Ignoring writing to `streamOut`'); - next(); - } else { - debug$3('Writing document to `streamOut`'); - context.streamOut.write(file.toString(), next); - } + }; + return codeFrameColumns$1(rawLines, location, opts); } -var fs$4 = require$$0__default$3['default']; -var path$4 = require$$0__default$2['default']; -var debug$2 = src.exports('unified-engine:file-pipeline:file-system'); -var stats = vfileStatistics; +const errorEx = errorEx_1; +const fallback = jsonParseEvenBetterErrors; +const {default: LinesAndColumns} = require$$2; +const {codeFrameColumns} = lib$4; -var fileSystem_1 = fileSystem$2; +const JSONError = errorEx('JSONError', { + fileName: errorEx.append('in %s'), + codeFrame: errorEx.append('\n\n%s\n') +}); -// Write a virtual file to the file-system. -// Ignored when `output` is not given. -function fileSystem$2(context, file, fileSet, next) { - var destinationPath; +const parseJson = (string, reviver, filename) => { + if (typeof reviver === 'string') { + filename = reviver; + reviver = null; + } - if (!context.output) { - debug$2('Ignoring writing to file-system'); - return next() - } + try { + try { + return JSON.parse(string, reviver); + } catch (error) { + fallback(string, reviver); + throw error; + } + } catch (error) { + error.message = error.message.replace(/\n/g, ''); + const indexMatch = error.message.match(/in JSON at position (\d+) while parsing/); - if (!file.data.unifiedEngineGiven) { - debug$2('Ignoring programmatically added file'); - return next() - } + const jsonError = new JSONError(error); + if (filename) { + jsonError.fileName = filename; + } - destinationPath = file.path; + if (indexMatch && indexMatch.length > 0) { + const lines = new LinesAndColumns(string); + const index = Number(indexMatch[1]); + const location = lines.locationForIndex(index); - if (!destinationPath) { - debug$2('Cannot write file without a `destinationPath`'); - return next(new Error('Cannot write file without an output path')) - } + const codeFrame = codeFrameColumns( + string, + {start: {line: location.line + 1, column: location.column + 1}}, + {highlightCode: true} + ); - if (stats(file).fatal) { - debug$2('Cannot write file with a fatal error'); - return next() - } + jsonError.codeFrame = codeFrame; + } - destinationPath = path$4.resolve(context.cwd, destinationPath); - debug$2('Writing document to `%s`', destinationPath); + throw jsonError; + } +}; - file.stored = true; +parseJson.JSONError = JSONError; - fs$4.writeFile(destinationPath, file.toString(), next); -} +var parseJson_1 = parseJson; -var trough$2 = trough_1; -var read$1 = read_1; -var configure$4 = configure_1$1; -var parse$9 = parse_1$4; -var transform$4 = transform_1$1; -var queue = queue_1; -var stringify$a = stringify_1; -var copy$3 = copy_1; -var stdout = stdout_1; -var fileSystem$1 = fileSystem_1; +var src = {exports: {}}; -// This pipeline ensures each of the pipes always runs: even if the read pipe -// fails, queue and write run. -var filePipeline$1 = trough$2() - .use(chunk(trough$2().use(read$1).use(configure$4).use(parse$9).use(transform$4))) - .use(chunk(trough$2().use(queue))) - .use(chunk(trough$2().use(stringify$a).use(copy$3).use(stdout).use(fileSystem$1))); - -// Factory to run a pipe. -// Wraps a pipe to trigger an error on the `file` in `context`, but still call -// `next`. -function chunk(pipe) { - return run +var browser = {exports: {}}; - // Run the bound bound pipe and handles any errors. - function run(context, file, fileSet, next) { - pipe.run(context, file, fileSet, one); +/** + * Helpers. + */ - function one(error) { - var messages = file.messages; - var index; +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var w = d * 7; +var y = d * 365.25; - if (error) { - index = messages.indexOf(error); +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ - if (index === -1) { - error = file.message(error); - index = messages.length - 1; - } +var ms = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === 'string' && val.length > 0) { + return parse$a(val); + } else if (type === 'number' && isFinite(val)) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); +}; - messages[index].fatal = true; - } +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ - next(); - } +function parse$a(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'weeks': + case 'week': + case 'w': + return n * w; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; } } -var FileSet = fileSet; -var filePipeline = filePipeline$1; - -var transform_1 = transform$3; - -// Transform all files. -function transform$3(context, settings, next) { - var fileSet = new FileSet(); - - context.fileSet = fileSet; - - fileSet.on('add', add).on('done', next); +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ - if (context.files.length === 0) { - next(); - } else { - context.files.forEach(fileSet.add, fileSet); +function fmtShort(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return Math.round(ms / d) + 'd'; } - - function add(file) { - filePipeline.run( - { - configuration: context.configuration, - processor: settings.processor(), - cwd: settings.cwd, - extensions: settings.extensions, - pluginPrefix: settings.pluginPrefix, - treeIn: settings.treeIn, - treeOut: settings.treeOut, - inspect: settings.inspect, - color: settings.color, - out: settings.out, - output: settings.output, - streamOut: settings.streamOut, - alwaysStringify: settings.alwaysStringify - }, - file, - fileSet, - done - ); - - function done(error) { - /* istanbul ignore next - Does not occur as all failures in `filePipeLine` - * are failed on each file. - * Still, just to ensure things work in the future, we add an extra - * check. */ - if (error) { - error = file.message(error); - error.fatal = true; - } - - fileSet.emit('one', file); - } + if (msAbs >= h) { + return Math.round(ms / h) + 'h'; + } + if (msAbs >= m) { + return Math.round(ms / m) + 'm'; + } + if (msAbs >= s) { + return Math.round(ms / s) + 's'; } + return ms + 'ms'; } -var hasFlag$1 = (flag, argv) => { - argv = argv || process.argv; - const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); - const pos = argv.indexOf(prefix + flag); - const terminatorPos = argv.indexOf('--'); - return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); -}; - -const os = require$$0__default$1['default']; -const hasFlag = hasFlag$1; - -const {env} = process; +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ -let forceColor; -if (hasFlag('no-color') || - hasFlag('no-colors') || - hasFlag('color=false') || - hasFlag('color=never')) { - forceColor = 0; -} else if (hasFlag('color') || - hasFlag('colors') || - hasFlag('color=true') || - hasFlag('color=always')) { - forceColor = 1; -} -if ('FORCE_COLOR' in env) { - if (env.FORCE_COLOR === true || env.FORCE_COLOR === 'true') { - forceColor = 1; - } else if (env.FORCE_COLOR === false || env.FORCE_COLOR === 'false') { - forceColor = 0; - } else { - forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3); - } +function fmtLong(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return plural$1(ms, msAbs, d, 'day'); + } + if (msAbs >= h) { + return plural$1(ms, msAbs, h, 'hour'); + } + if (msAbs >= m) { + return plural$1(ms, msAbs, m, 'minute'); + } + if (msAbs >= s) { + return plural$1(ms, msAbs, s, 'second'); + } + return ms + ' ms'; } -function translateLevel(level) { - if (level === 0) { - return false; - } +/** + * Pluralization helper. + */ - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; +function plural$1(ms, msAbs, n, name) { + var isPlural = msAbs >= n * 1.5; + return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -function supportsColor(stream) { - if (forceColor === 0) { - return 0; - } - - if (hasFlag('color=16m') || - hasFlag('color=full') || - hasFlag('color=truecolor')) { - return 3; - } +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ - if (hasFlag('color=256')) { - return 2; - } +function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = ms; + createDebug.destroy = destroy; - if (stream && !stream.isTTY && forceColor === undefined) { - return 0; - } + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); - const min = forceColor || 0; + /** + * The currently active debug mode names, and names to skip. + */ - if (env.TERM === 'dumb') { - return min; - } + createDebug.names = []; + createDebug.skips = []; - if (process.platform === 'win32') { - // Node.js 7.5.0 is the first version of Node.js to include a patch to - // libuv that enables 256 color output on Windows. Anything earlier and it - // won't work. However, here we target Node.js 8 at minimum as it is an LTS - // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows - // release that supports 256 colors. Windows 10 build 14931 is the first release - // that supports 16m/TrueColor. - const osRelease = os.release().split('.'); - if ( - Number(process.versions.node.split('.')[0]) >= 8 && - Number(osRelease[0]) >= 10 && - Number(osRelease[2]) >= 10586 - ) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; - return 1; - } + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; - if ('CI' in env) { - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') { - return 1; + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer } - return min; - } - - if ('TEAMCITY_VERSION' in env) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; - } - - if (env.COLORTERM === 'truecolor') { - return 3; + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; } + createDebug.selectColor = selectColor; - if ('TERM_PROGRAM' in env) { - const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); - - switch (env.TERM_PROGRAM) { - case 'iTerm.app': - return version >= 3 ? 3 : 2; - case 'Apple_Terminal': - return 2; - // No default - } - } + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; - if (/-256(color)?$/i.test(env.TERM)) { - return 2; - } + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } - if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { - return 1; - } + const self = debug; - if ('COLORTERM' in env) { - return 1; - } + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; - return min; -} + args[0] = createDebug.coerce(args[0]); -function getSupportLevel(stream) { - const level = supportsColor(stream); - return translateLevel(level); -} + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } -var supportsColor_1 = { - supportsColor: getSupportLevel, - stdout: getSupportLevel(process.stdout), - stderr: getSupportLevel(process.stderr) -}; + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return '%'; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); -var stringWidth$1 = {exports: {}}; + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); -var ansiRegex$1 = ({onlyFirst = false} = {}) => { - const pattern = [ - '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', - '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' - ].join('|'); + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); - return new RegExp(pattern, onlyFirst ? undefined : 'g'); -}; + const logFn = self.log || createDebug.log; + logFn.apply(self, args); + } -const ansiRegex = ansiRegex$1; + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. -var stripAnsi$1 = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string; + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } -var isFullwidthCodePoint$2 = {exports: {}}; + return enabledCache; + }, + set: v => { + enableOverride = v; + } + }); -/* eslint-disable yoda */ + // Env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } -const isFullwidthCodePoint$1 = codePoint => { - if (Number.isNaN(codePoint)) { - return false; + return debug; } - // Code points are derived from: - // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt - if ( - codePoint >= 0x1100 && ( - codePoint <= 0x115F || // Hangul Jamo - codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET - codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - (0x3250 <= codePoint && codePoint <= 0x4DBF) || - // CJK Unified Ideographs .. Yi Radicals - (0x4E00 <= codePoint && codePoint <= 0xA4C6) || - // Hangul Jamo Extended-A - (0xA960 <= codePoint && codePoint <= 0xA97C) || - // Hangul Syllables - (0xAC00 <= codePoint && codePoint <= 0xD7A3) || - // CJK Compatibility Ideographs - (0xF900 <= codePoint && codePoint <= 0xFAFF) || - // Vertical Forms - (0xFE10 <= codePoint && codePoint <= 0xFE19) || - // CJK Compatibility Forms .. Small Form Variants - (0xFE30 <= codePoint && codePoint <= 0xFE6B) || - // Halfwidth and Fullwidth Forms - (0xFF01 <= codePoint && codePoint <= 0xFF60) || - (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || - // Kana Supplement - (0x1B000 <= codePoint && codePoint <= 0x1B001) || - // Enclosed Ideographic Supplement - (0x1F200 <= codePoint && codePoint <= 0x1F251) || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - (0x20000 <= codePoint && codePoint <= 0x3FFFD) - ) - ) { - return true; + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; } - return false; -}; - -isFullwidthCodePoint$2.exports = isFullwidthCodePoint$1; -isFullwidthCodePoint$2.exports.default = isFullwidthCodePoint$1; + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; -var emojiRegex$1 = function () { - // https://mths.be/emoji - return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g; -}; + createDebug.names = []; + createDebug.skips = []; -const stripAnsi = stripAnsi$1; -const isFullwidthCodePoint = isFullwidthCodePoint$2.exports; -const emojiRegex = emojiRegex$1; + let i; + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + const len = split.length; -const stringWidth = string => { - if (typeof string !== 'string' || string.length === 0) { - return 0; - } + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue; + } - string = stripAnsi(string); + namespaces = split[i].replace(/\*/g, '.*?'); - if (string.length === 0) { - return 0; + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } } - string = string.replace(emojiRegex(), ' '); + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ].join(','); + createDebug.enable(''); + return namespaces; + } - let width = 0; + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } - for (let i = 0; i < string.length; i++) { - const code = string.codePointAt(i); + let i; + let len; - // Ignore control characters - if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { - continue; + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } } - // Ignore combining characters - if (code >= 0x300 && code <= 0x36F) { - continue; + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } } - // Surrogates - if (code > 0xFFFF) { - i++; + return false; + } + + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp.toString() + .substring(2, regexp.toString().length - 2) + .replace(/\.\*\?$/, '*'); + } + + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; } + return val; + } - width += isFullwidthCodePoint(code) ? 2 : 1; + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); } - return width; -}; + createDebug.enable(createDebug.load()); -stringWidth$1.exports = stringWidth; -// TODO: remove this in the next major version -stringWidth$1.exports.default = stringWidth; + return createDebug; +} -/*! - * repeat-string - * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT License. - */ +var common$3 = setup; -/** - * Results cache +/* eslint-env browser */ + +(function (module, exports) { +/** + * This is the web browser implementation of `debug()`. */ -var res = ''; -var cache; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = localstorage(); +exports.destroy = (() => { + let warned = false; + + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; +})(); /** - * Expose `repeat` + * Colors. */ -var repeatString = repeat$7; +exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' +]; /** - * Repeat the given `string` the specified `number` - * of times. - * - * **Example:** - * - * ```js - * var repeat = require('repeat-string'); - * repeat('A', 5); - * //=> AAAAA - * ``` + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. * - * @param {String} `string` The string to repeat - * @param {Number} `number` The number of times to repeat the string - * @return {String} Repeated string - * @api public + * TODO: add a `localStorage` variable to explicitly enable/disable colors */ -function repeat$7(str, num) { - if (typeof str !== 'string') { - throw new TypeError('expected a string'); - } +// eslint-disable-next-line complexity +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; + } - // cover common, quick use cases - if (num === 1) return str; - if (num === 2) return str + str; + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } - var max = str.length * num; - if (cache !== str || typeof cache === 'undefined') { - cache = str; - res = ''; - } else if (res.length >= max) { - return res.substr(0, max); - } + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} - while (max > res.length && num > 1) { - if (num & 1) { - res += str; - } +/** + * Colorize log arguments if enabled. + * + * @api public + */ - num >>= 1; - str += str; - } +function formatArgs(args) { + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); - res += str; - res = res.substr(0, max); - return res; -} + if (!this.useColors) { + return; + } -var vfileSort = sort$1; + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); -var severities = { - true: 2, - false: 1, - null: 0, - undefined: 0 -}; + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); -function sort$1(file) { - file.messages.sort(comparator); - return file + args.splice(lastC, 0, c); } -function comparator(a, b) { - return ( - check$4(a, b, 'line') || - check$4(a, b, 'column') || - severities[b.fatal] - severities[a.fatal] || - compare$3(a, b, 'source') || - compare$3(a, b, 'ruleId') || - compare$3(a, b, 'reason') || - 0 - ) -} +/** + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. + * + * @api public + */ +exports.log = console.debug || console.log || (() => {}); -function check$4(a, b, property) { - return (a[property] || 0) - (b[property] || 0) +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ +function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } -function compare$3(a, b, property) { - return (a[property] || '').localeCompare(b[property] || '') +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ +function load() { + let r; + try { + r = exports.storage.getItem('debug'); + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; } -var supported = supportsColor_1.stderr.hasBasic; -var width = stringWidth$1.exports; -var stringify$9 = unistUtilStringifyPosition; -var repeat$6 = repeatString; -var statistics$1 = vfileStatistics; -var sort = vfileSort; +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } +} -var vfileReporter = reporter$1; +module.exports = common$3(exports); -var push$1 = [].push; +const {formatters} = module.exports; -// `log-symbols` without chalk: -/* istanbul ignore next - Windows. */ -var chars$1 = - process.platform === 'win32' - ? {error: '×', warning: '‼'} - : {error: '✖', warning: '⚠'}; +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ -var labels = { - true: 'error', - false: 'warning', - null: 'info', - undefined: 'info' +formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } }; +}(browser, browser.exports)); -// Report a file’s messages. -function reporter$1(files, options) { - var settings = options || {}; - var one; +var node = {exports: {}}; - if (!files) { - return '' - } +/** + * Module dependencies. + */ - // Error. - if ('name' in files && 'message' in files) { - return String(files.stack || files) - } +(function (module, exports) { +const tty = tty__default['default']; +const util = require$$0__default$2['default']; - // One file. - if (!('length' in files)) { - one = true; - files = [files]; - } +/** + * This is the Node.js implementation of `debug()`. + */ - return format(transform$2(files, settings), one, settings) -} +exports.init = init; +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.destroy = util.deprecate( + () => {}, + 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' +); -function transform$2(files, options) { - var index = -1; - var rows = []; - var all = []; - var sizes = {}; - var messages; - var offset; - var message; - var messageRows; - var row; - var key; +/** + * Colors. + */ - while (++index < files.length) { - messages = sort({messages: files[index].messages.concat()}).messages; - messageRows = []; - offset = -1; +exports.colors = [6, 2, 3, 4, 5, 1]; - while (++offset < messages.length) { - message = messages[offset]; +try { + // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) + // eslint-disable-next-line import/no-extraneous-dependencies + const supportsColor = supportsColor_1$1; - if (!options.silent || message.fatal) { - all.push(message); + if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { + exports.colors = [ + 20, + 21, + 26, + 27, + 32, + 33, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 56, + 57, + 62, + 63, + 68, + 69, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 92, + 93, + 98, + 99, + 112, + 113, + 128, + 129, + 134, + 135, + 148, + 149, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 178, + 179, + 184, + 185, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 214, + 215, + 220, + 221 + ]; + } +} catch (error) { + // Swallow - we only care if `supports-color` is available; it doesn't have to be. +} - row = { - location: stringify$9( - message.location.end.line && message.location.end.column - ? message.location - : message.location.start - ), - label: labels[message.fatal], - reason: - (message.stack || message.message) + - (options.verbose && message.note ? '\n' + message.note : ''), - ruleId: message.ruleId || '', - source: message.source || '' - }; +/** + * Build up the default `inspectOpts` object from the environment variables. + * + * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js + */ - for (key in row) { - sizes[key] = Math.max(size$1(row[key]), sizes[key] || 0); - } +exports.inspectOpts = Object.keys(process.env).filter(key => { + return /^debug_/i.test(key); +}).reduce((obj, key) => { + // Camel-case + const prop = key + .substring(6) + .toLowerCase() + .replace(/_([a-z])/g, (_, k) => { + return k.toUpperCase(); + }); - messageRows.push(row); - } - } + // Coerce string value into JS value + let val = process.env[key]; + if (/^(yes|on|true|enabled)$/i.test(val)) { + val = true; + } else if (/^(no|off|false|disabled)$/i.test(val)) { + val = false; + } else if (val === 'null') { + val = null; + } else { + val = Number(val); + } - if ((!options.quiet && !options.silent) || messageRows.length) { - rows.push({type: 'file', file: files[index], stats: statistics$1(messages)}); - push$1.apply(rows, messageRows); - } - } + obj[prop] = val; + return obj; +}, {}); + +/** + * Is stdout a TTY? Colored output is enabled when `true`. + */ - return {rows: rows, stats: statistics$1(all), sizes: sizes} +function useColors() { + return 'colors' in exports.inspectOpts ? + Boolean(exports.inspectOpts.colors) : + tty.isatty(process.stderr.fd); } -function format(map, one, options) { - var enabled = options.color == null ? supported : options.color; - var lines = []; - var index = -1; - var stats; - var row; - var line; - var reason; - var rest; - var match; +/** + * Adds ANSI color escape codes if enabled. + * + * @api public + */ - while (++index < map.rows.length) { - row = map.rows[index]; +function formatArgs(args) { + const {namespace: name, useColors} = this; - if (row.type === 'file') { - stats = row.stats; - line = row.file.history[0] || options.defaultName || ''; + if (useColors) { + const c = this.color; + const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c); + const prefix = ` ${colorCode};1m${name} \u001B[0m`; - line = - one && !options.defaultName && !row.file.history[0] - ? '' - : (enabled - ? '\x1b[4m' /* Underline. */ + - (stats.fatal - ? '\x1b[31m' /* Red. */ - : stats.total - ? '\x1b[33m' /* Yellow. */ - : '\x1b[32m') /* Green. */ + - line + - '\x1b[39m\x1b[24m' - : line) + - (row.file.stored && row.file.path !== row.file.history[0] - ? ' > ' + row.file.path - : ''); + args[0] = prefix + args[0].split('\n').join('\n' + prefix); + args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m'); + } else { + args[0] = getDate() + name + ' ' + args[0]; + } +} - if (!stats.total) { - line = - (line ? line + ': ' : '') + - (row.file.stored - ? enabled - ? '\x1b[33mwritten\x1b[39m' /* Yellow. */ - : 'written' - : 'no issues found'); - } +function getDate() { + if (exports.inspectOpts.hideDate) { + return ''; + } + return new Date().toISOString() + ' '; +} - if (line) { - if (index && map.rows[index - 1].type !== 'file') { - lines.push(''); - } +/** + * Invokes `util.format()` with the specified arguments and writes to stderr. + */ - lines.push(line); - } - } else { - reason = row.reason; - match = /\r?\n|\r/.exec(reason); +function log(...args) { + return process.stderr.write(util.format(...args) + '\n'); +} - if (match) { - rest = reason.slice(match.index); - reason = reason.slice(0, match.index); - } else { - rest = ''; - } +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ +function save(namespaces) { + if (namespaces) { + process.env.DEBUG = namespaces; + } else { + // If you set a process.env field to null or undefined, it gets cast to the + // string 'null' or 'undefined'. Just delete instead. + delete process.env.DEBUG; + } +} - lines.push( - ( - ' ' + - repeat$6(' ', map.sizes.location - size$1(row.location)) + - row.location + - ' ' + - (enabled - ? (row.label === 'error' - ? '\x1b[31m' /* Red. */ - : '\x1b[33m') /* Yellow. */ + - row.label + - '\x1b[39m' - : row.label) + - repeat$6(' ', map.sizes.label - size$1(row.label)) + - ' ' + - reason + - repeat$6(' ', map.sizes.reason - size$1(reason)) + - ' ' + - row.ruleId + - repeat$6(' ', map.sizes.ruleId - size$1(row.ruleId)) + - ' ' + - (row.source || '') - ).replace(/ +$/, '') + rest - ); - } - } +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ - stats = map.stats; +function load() { + return process.env.DEBUG; +} - if (stats.fatal || stats.warn) { - line = ''; +/** + * Init logic for `debug` instances. + * + * Create a new `inspectOpts` object in case `useColors` is set + * differently for a particular `debug` instance. + */ - if (stats.fatal) { - line = - (enabled - ? '\x1b[31m' /* Red. */ + chars$1.error + '\x1b[39m' - : chars$1.error) + - ' ' + - stats.fatal + - ' ' + - (labels.true + (stats.fatal === 1 ? '' : 's')); - } +function init(debug) { + debug.inspectOpts = {}; - if (stats.warn) { - line = - (line ? line + ', ' : '') + - (enabled - ? '\x1b[33m' /* Yellow. */ + chars$1.warning + '\x1b[39m' - : chars$1.warning) + - ' ' + - stats.warn + - ' ' + - (labels.false + (stats.warn === 1 ? '' : 's')); - } + const keys = Object.keys(exports.inspectOpts); + for (let i = 0; i < keys.length; i++) { + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; + } +} - if (stats.total !== stats.fatal && stats.total !== stats.warn) { - line = stats.total + ' messages (' + line + ')'; - } +module.exports = common$3(exports); - lines.push('', line); - } +const {formatters} = module.exports; - return lines.join('\n') -} +/** + * Map %o to `util.inspect()`, all on a single line. + */ -// Get the length of `value`, ignoring ANSI sequences. -function size$1(value) { - var match = /\r?\n|\r/.exec(value); - return width(match ? value.slice(0, match.index) : value) +formatters.o = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts) + .split('\n') + .map(str => str.trim()) + .join(' '); +}; + +/** + * Map %O to `util.inspect()`, allowing multiple lines if needed. + */ + +formatters.O = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts); +}; +}(node, node.exports)); + +/** + * Detect Electron renderer / nwjs process, which is node, but we should + * treat as a browser. + */ + +if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { + src.exports = browser.exports; +} else { + src.exports = node.exports; } -var load$2 = loadPlugin_1; -var report = vfileReporter; +var createDebug = src.exports; -var log_1 = log$1; +var re$6 = {exports: {}}; -function log$1(context, settings, next) { - var reporter = settings.reporter || report; - var diagnostics; +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +const SEMVER_SPEC_VERSION = '2.0.0'; - if (typeof reporter === 'string') { - try { - reporter = load$2(reporter, {cwd: settings.cwd, prefix: 'vfile-reporter'}); - } catch (_) { - next(new Error('Could not find reporter `' + reporter + '`')); - return - } - } +const MAX_LENGTH$2 = 256; +const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991; - diagnostics = reporter( - context.files.filter(given), - Object.assign({}, settings.reporterOptions, { - quiet: settings.quiet, - silent: settings.silent, - color: settings.color - }) - ); +// Max safe segment length for coercion. +const MAX_SAFE_COMPONENT_LENGTH = 16; - if (diagnostics) { - if (diagnostics.charAt(diagnostics.length - 1) !== '\n') { - diagnostics += '\n'; - } +var constants = { + SEMVER_SPEC_VERSION, + MAX_LENGTH: MAX_LENGTH$2, + MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1, + MAX_SAFE_COMPONENT_LENGTH +}; - settings.streamError.write(diagnostics, next); - } else { - next(); - } -} +const debug$f = ( + typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG) +) ? (...args) => console.error('SEMVER', ...args) + : () => {}; -function given(file) { - return file.data.unifiedEngineGiven -} +var debug_1 = debug$f; -var trough$1 = trough_1; -var configure$3 = configure_1$2; -var fileSystem = fileSystem_1$1; -var stdin = stdin_1; -var transform$1 = transform_1; -var log = log_1; +(function (module, exports) { +const { MAX_SAFE_COMPONENT_LENGTH } = constants; +const debug = debug_1; +exports = module.exports = {}; -var fileSetPipeline$1 = trough$1() - .use(configure$3) - .use(fileSystem) - .use(stdin) - .use(transform$1) - .use(log); +// The actual regexps go on exports.re +const re = exports.re = []; +const src = exports.src = []; +const t = exports.t = {}; +let R = 0; -var PassThrough = require$$0__default$5['default'].PassThrough; -var statistics = vfileStatistics; -var fileSetPipeline = fileSetPipeline$1; +const createToken = (name, value, isGlobal) => { + const index = R++; + debug(index, value); + t[name] = index; + src[index] = value; + re[index] = new RegExp(value, isGlobal ? 'g' : undefined); +}; -var lib$4 = run; +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. -// Run the file set pipeline once. -// `callback` is invoked with a fatal error, or with a status code (`0` on -// success, `1` on failure). -function run(options, callback) { - var settings = {}; - var stdin = new PassThrough(); - var tree; - var detectConfig; - var hasConfig; - var detectIgnore; - var hasIgnore; +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. - try { - stdin = process.stdin; - } catch (_) { - // Obscure bug in Node (seen on Windows). - // See: , - // . - } +createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*'); +createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); - if (!callback) { - throw new Error('Missing `callback`') - } +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. - if (!options || !options.processor) { - return next(new Error('Missing `processor`')) - } +createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); - // Processor. - settings.processor = options.processor; +// ## Main Version +// Three dot-separated numeric identifiers. - // Path to run as. - settings.cwd = options.cwd || process.cwd(); +createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})`); - // Input. - settings.files = options.files || []; - settings.extensions = (options.extensions || []).map(extension$2); +createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); - settings.filePath = options.filePath || null; - settings.streamIn = options.streamIn || stdin; +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. - // Output. - settings.streamOut = options.streamOut || process.stdout; - settings.streamError = options.streamError || process.stderr; - settings.alwaysStringify = options.alwaysStringify; - settings.output = options.output; - settings.out = options.out; +createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] +}|${src[t.NONNUMERICIDENTIFIER]})`); - // Null overwrites config settings, `undefined` does not. - if (settings.output === null || settings.output === undefined) { - settings.output = undefined; - } +createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] +}|${src[t.NONNUMERICIDENTIFIER]})`); - if (settings.output && settings.out) { - return next(new Error('Cannot accept both `output` and `out`')) - } +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. - // Process phase management. - tree = options.tree || false; +createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] +}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); - settings.treeIn = options.treeIn; - settings.treeOut = options.treeOut; - settings.inspect = options.inspect; +createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] +}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); - if (settings.treeIn === null || settings.treeIn === undefined) { - settings.treeIn = tree; - } +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. - if (settings.treeOut === null || settings.treeOut === undefined) { - settings.treeOut = tree; - } +createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); - // Configuration. - detectConfig = options.detectConfig; - hasConfig = Boolean(options.rcName || options.packageField); +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. - if (detectConfig && !hasConfig) { - return next( - new Error('Missing `rcName` or `packageField` with `detectConfig`') - ) - } +createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] +}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); - settings.detectConfig = - detectConfig === null || detectConfig === undefined - ? hasConfig - : detectConfig; - settings.rcName = options.rcName || null; - settings.rcPath = options.rcPath || null; - settings.packageField = options.packageField || null; - settings.settings = options.settings || {}; - settings.configTransform = options.configTransform; - settings.defaultConfig = options.defaultConfig; +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. - // Ignore. - detectIgnore = options.detectIgnore; - hasIgnore = Boolean(options.ignoreName); +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. - settings.detectIgnore = - detectIgnore === null || detectIgnore === undefined - ? hasIgnore - : detectIgnore; - settings.ignoreName = options.ignoreName || null; - settings.ignorePath = options.ignorePath || null; - settings.ignorePathResolveFrom = options.ignorePathResolveFrom || 'dir'; - settings.ignorePatterns = options.ignorePatterns || []; - settings.silentlyIgnore = Boolean(options.silentlyIgnore); +createToken('FULLPLAIN', `v?${src[t.MAINVERSION] +}${src[t.PRERELEASE]}?${ + src[t.BUILD]}?`); - if (detectIgnore && !hasIgnore) { - return next(new Error('Missing `ignoreName` with `detectIgnore`')) +createToken('FULL', `^${src[t.FULLPLAIN]}$`); + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] +}${src[t.PRERELEASELOOSE]}?${ + src[t.BUILD]}?`); + +createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`); + +createToken('GTLT', '((?:<|>)?=?)'); + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); +createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); + +createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:${src[t.PRERELEASE]})?${ + src[t.BUILD]}?` + + `)?)?`); + +createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:${src[t.PRERELEASELOOSE]})?${ + src[t.BUILD]}?` + + `)?)?`); + +createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); +createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); + +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +createToken('COERCE', `${'(^|[^\\d])' + + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:$|[^\\d])`); +createToken('COERCERTL', src[t.COERCE], true); + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +createToken('LONETILDE', '(?:~>?)'); + +createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true); +exports.tildeTrimReplace = '$1~'; + +createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); +createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +createToken('LONECARET', '(?:\\^)'); + +createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true); +exports.caretTrimReplace = '$1^'; + +createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); +createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); +createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] +}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); +exports.comparatorTrimReplace = '$1$2$3'; + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAIN]})` + + `\\s*$`); + +createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAINLOOSE]})` + + `\\s*$`); + +// Star ranges basically just allow anything at all. +createToken('STAR', '(<|>)?=?\\s*\\*'); +// >=0.0.0 is like a star +createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$'); +createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$'); +}(re$6, re$6.exports)); + +// parse out just the options we care about so we always get a consistent +// obj with keys in a consistent order. +const opts = ['includePrerelease', 'loose', 'rtl']; +const parseOptions$4 = options => + !options ? {} + : typeof options !== 'object' ? { loose: true } + : opts.filter(k => options[k]).reduce((options, k) => { + options[k] = true; + return options + }, {}); +var parseOptions_1 = parseOptions$4; + +const numeric$1 = /^[0-9]+$/; +const compareIdentifiers$1 = (a, b) => { + const anum = numeric$1.test(a); + const bnum = numeric$1.test(b); + + if (anum && bnum) { + a = +a; + b = +b; } - // Plugins. - settings.pluginPrefix = options.pluginPrefix || null; - settings.plugins = options.plugins || {}; + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +}; - // Reporting. - settings.reporter = options.reporter || null; - settings.reporterOptions = options.reporterOptions || null; - settings.color = options.color || false; - settings.silent = options.silent || false; - settings.quiet = options.quiet || false; - settings.frail = options.frail || false; +const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a); - // Process. - fileSetPipeline.run({files: options.files || []}, settings, next); +var identifiers = { + compareIdentifiers: compareIdentifiers$1, + rcompareIdentifiers +}; - function next(error, context) { - var stats = statistics((context || {}).files); - var failed = Boolean( - settings.frail ? stats.fatal || stats.warn : stats.fatal - ); +const debug$e = debug_1; +const { MAX_LENGTH: MAX_LENGTH$1, MAX_SAFE_INTEGER } = constants; +const { re: re$5, t: t$4 } = re$6.exports; - if (error) { - callback(error); - } else { - callback(null, failed ? 1 : 0, context); +const parseOptions$3 = parseOptions_1; +const { compareIdentifiers } = identifiers; +class SemVer$e { + constructor (version, options) { + options = parseOptions$3(options); + + if (version instanceof SemVer$e) { + if (version.loose === !!options.loose && + version.includePrerelease === !!options.includePrerelease) { + return version + } else { + version = version.version; + } + } else if (typeof version !== 'string') { + throw new TypeError(`Invalid Version: ${version}`) } - } -} -function extension$2(ext) { - return ext.charAt(0) === '.' ? ext : '.' + ext -} + if (version.length > MAX_LENGTH$1) { + throw new TypeError( + `version is longer than ${MAX_LENGTH$1} characters` + ) + } -var ansiStyles$1 = {exports: {}}; + debug$e('SemVer', version, options); + this.options = options; + this.loose = !!options.loose; + // this isn't actually relevant for versions, but keep it so that we + // don't run into trouble passing this.options around. + this.includePrerelease = !!options.includePrerelease; -var colorName = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] -}; + const m = version.trim().match(options.loose ? re$5[t$4.LOOSE] : re$5[t$4.FULL]); -/* MIT license */ + if (!m) { + throw new TypeError(`Invalid Version: ${version}`) + } -/* eslint-disable no-mixed-operators */ -const cssKeywords = colorName; + this.raw = version; -// NOTE: conversions should only return primitive values (i.e. arrays, or -// values that give correct `typeof` results). -// do not use box values types (i.e. Number(), String(), etc.) + // these are actually numbers + this.major = +m[1]; + this.minor = +m[2]; + this.patch = +m[3]; -const reverseKeywords = {}; -for (const key of Object.keys(cssKeywords)) { - reverseKeywords[cssKeywords[key]] = key; -} + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } -const convert$4 = { - rgb: {channels: 3, labels: 'rgb'}, - hsl: {channels: 3, labels: 'hsl'}, - hsv: {channels: 3, labels: 'hsv'}, - hwb: {channels: 3, labels: 'hwb'}, - cmyk: {channels: 4, labels: 'cmyk'}, - xyz: {channels: 3, labels: 'xyz'}, - lab: {channels: 3, labels: 'lab'}, - lch: {channels: 3, labels: 'lch'}, - hex: {channels: 1, labels: ['hex']}, - keyword: {channels: 1, labels: ['keyword']}, - ansi16: {channels: 1, labels: ['ansi16']}, - ansi256: {channels: 1, labels: ['ansi256']}, - hcg: {channels: 3, labels: ['h', 'c', 'g']}, - apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, - gray: {channels: 1, labels: ['gray']} -}; + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } -var conversions$2 = convert$4; + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } -// Hide .channels and .labels properties -for (const model of Object.keys(convert$4)) { - if (!('channels' in convert$4[model])) { - throw new Error('missing channels property: ' + model); - } + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = []; + } else { + this.prerelease = m[4].split('.').map((id) => { + if (/^[0-9]+$/.test(id)) { + const num = +id; + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }); + } - if (!('labels' in convert$4[model])) { - throw new Error('missing channel labels property: ' + model); - } + this.build = m[5] ? m[5].split('.') : []; + this.format(); + } - if (convert$4[model].labels.length !== convert$4[model].channels) { - throw new Error('channel and label counts mismatch: ' + model); - } + format () { + this.version = `${this.major}.${this.minor}.${this.patch}`; + if (this.prerelease.length) { + this.version += `-${this.prerelease.join('.')}`; + } + return this.version + } - const {channels, labels} = convert$4[model]; - delete convert$4[model].channels; - delete convert$4[model].labels; - Object.defineProperty(convert$4[model], 'channels', {value: channels}); - Object.defineProperty(convert$4[model], 'labels', {value: labels}); -} + toString () { + return this.version + } -convert$4.rgb.hsl = function (rgb) { - const r = rgb[0] / 255; - const g = rgb[1] / 255; - const b = rgb[2] / 255; - const min = Math.min(r, g, b); - const max = Math.max(r, g, b); - const delta = max - min; - let h; - let s; + compare (other) { + debug$e('SemVer.compare', this.version, this.options, other); + if (!(other instanceof SemVer$e)) { + if (typeof other === 'string' && other === this.version) { + return 0 + } + other = new SemVer$e(other, this.options); + } - if (max === min) { - h = 0; - } else if (r === max) { - h = (g - b) / delta; - } else if (g === max) { - h = 2 + (b - r) / delta; - } else if (b === max) { - h = 4 + (r - g) / delta; - } + if (other.version === this.version) { + return 0 + } - h = Math.min(h * 60, 360); + return this.compareMain(other) || this.comparePre(other) + } - if (h < 0) { - h += 360; - } + compareMain (other) { + if (!(other instanceof SemVer$e)) { + other = new SemVer$e(other, this.options); + } - const l = (min + max) / 2; + return ( + compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) + ) + } - if (max === min) { - s = 0; - } else if (l <= 0.5) { - s = delta / (max + min); - } else { - s = delta / (2 - max - min); - } + comparePre (other) { + if (!(other instanceof SemVer$e)) { + other = new SemVer$e(other, this.options); + } - return [h, s * 100, l * 100]; -}; + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } -convert$4.rgb.hsv = function (rgb) { - let rdif; - let gdif; - let bdif; - let h; - let s; + let i = 0; + do { + const a = this.prerelease[i]; + const b = other.prerelease[i]; + debug$e('prerelease compare', i, a, b); + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } - const r = rgb[0] / 255; - const g = rgb[1] / 255; - const b = rgb[2] / 255; - const v = Math.max(r, g, b); - const diff = v - Math.min(r, g, b); - const diffc = function (c) { - return (v - c) / 6 / diff + 1 / 2; - }; + compareBuild (other) { + if (!(other instanceof SemVer$e)) { + other = new SemVer$e(other, this.options); + } - if (diff === 0) { - h = 0; - s = 0; - } else { - s = diff / v; - rdif = diffc(r); - gdif = diffc(g); - bdif = diffc(b); + let i = 0; + do { + const a = this.build[i]; + const b = other.build[i]; + debug$e('prerelease compare', i, a, b); + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } - if (r === v) { - h = bdif - gdif; - } else if (g === v) { - h = (1 / 3) + rdif - bdif; - } else if (b === v) { - h = (2 / 3) + gdif - rdif; - } + // preminor will bump the version up to the next minor release, and immediately + // down to pre-release. premajor and prepatch work the same way. + inc (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0; + this.patch = 0; + this.minor = 0; + this.major++; + this.inc('pre', identifier); + break + case 'preminor': + this.prerelease.length = 0; + this.patch = 0; + this.minor++; + this.inc('pre', identifier); + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0; + this.inc('patch', identifier); + this.inc('pre', identifier); + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier); + } + this.inc('pre', identifier); + break - if (h < 0) { - h += 1; - } else if (h > 1) { - h -= 1; - } - } + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if ( + this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0 + ) { + this.major++; + } + this.minor = 0; + this.patch = 0; + this.prerelease = []; + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++; + } + this.patch = 0; + this.prerelease = []; + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++; + } + this.prerelease = []; + break + // This probably shouldn't be used publicly. + // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. + case 'pre': + if (this.prerelease.length === 0) { + this.prerelease = [0]; + } else { + let i = this.prerelease.length; + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++; + i = -2; + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0); + } + } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0]; + } + } else { + this.prerelease = [identifier, 0]; + } + } + break - return [ - h * 360, - s * 100, - v * 100 - ]; -}; + default: + throw new Error(`invalid increment argument: ${release}`) + } + this.format(); + this.raw = this.version; + return this + } +} -convert$4.rgb.hwb = function (rgb) { - const r = rgb[0]; - const g = rgb[1]; - let b = rgb[2]; - const h = convert$4.rgb.hsl(rgb)[0]; - const w = 1 / 255 * Math.min(r, Math.min(g, b)); +var semver$2 = SemVer$e; - b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); +const {MAX_LENGTH} = constants; +const { re: re$4, t: t$3 } = re$6.exports; +const SemVer$d = semver$2; - return [h, w * 100, b * 100]; -}; +const parseOptions$2 = parseOptions_1; +const parse$9 = (version, options) => { + options = parseOptions$2(options); -convert$4.rgb.cmyk = function (rgb) { - const r = rgb[0] / 255; - const g = rgb[1] / 255; - const b = rgb[2] / 255; + if (version instanceof SemVer$d) { + return version + } - const k = Math.min(1 - r, 1 - g, 1 - b); - const c = (1 - r - k) / (1 - k) || 0; - const m = (1 - g - k) / (1 - k) || 0; - const y = (1 - b - k) / (1 - k) || 0; + if (typeof version !== 'string') { + return null + } - return [c * 100, m * 100, y * 100, k * 100]; + if (version.length > MAX_LENGTH) { + return null + } + + const r = options.loose ? re$4[t$3.LOOSE] : re$4[t$3.FULL]; + if (!r.test(version)) { + return null + } + + try { + return new SemVer$d(version, options) + } catch (er) { + return null + } }; -function comparativeDistance(x, y) { - /* - See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance - */ - return ( - ((x[0] - y[0]) ** 2) + - ((x[1] - y[1]) ** 2) + - ((x[2] - y[2]) ** 2) - ); -} +var parse_1 = parse$9; -convert$4.rgb.keyword = function (rgb) { - const reversed = reverseKeywords[rgb]; - if (reversed) { - return reversed; - } +const parse$8 = parse_1; +const valid$1 = (version, options) => { + const v = parse$8(version, options); + return v ? v.version : null +}; +var valid_1 = valid$1; - let currentClosestDistance = Infinity; - let currentClosestKeyword; +const parse$7 = parse_1; +const clean = (version, options) => { + const s = parse$7(version.trim().replace(/^[=v]+/, ''), options); + return s ? s.version : null +}; +var clean_1 = clean; - for (const keyword of Object.keys(cssKeywords)) { - const value = cssKeywords[keyword]; +const SemVer$c = semver$2; - // Compute comparative distance - const distance = comparativeDistance(rgb, value); - - // Check if its less, if so set as closest - if (distance < currentClosestDistance) { - currentClosestDistance = distance; - currentClosestKeyword = keyword; - } - } +const inc = (version, release, options, identifier) => { + if (typeof (options) === 'string') { + identifier = options; + options = undefined; + } - return currentClosestKeyword; + try { + return new SemVer$c(version, options).inc(release, identifier).version + } catch (er) { + return null + } }; +var inc_1 = inc; -convert$4.keyword.rgb = function (keyword) { - return cssKeywords[keyword]; -}; +const SemVer$b = semver$2; +const compare$b = (a, b, loose) => + new SemVer$b(a, loose).compare(new SemVer$b(b, loose)); -convert$4.rgb.xyz = function (rgb) { - let r = rgb[0] / 255; - let g = rgb[1] / 255; - let b = rgb[2] / 255; +var compare_1 = compare$b; - // Assume sRGB - r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92); - g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92); - b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92); +const compare$a = compare_1; +const eq$2 = (a, b, loose) => compare$a(a, b, loose) === 0; +var eq_1 = eq$2; - const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); - const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); - const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); +const parse$6 = parse_1; +const eq$1 = eq_1; - return [x * 100, y * 100, z * 100]; +const diff = (version1, version2) => { + if (eq$1(version1, version2)) { + return null + } else { + const v1 = parse$6(version1); + const v2 = parse$6(version2); + const hasPre = v1.prerelease.length || v2.prerelease.length; + const prefix = hasPre ? 'pre' : ''; + const defaultResult = hasPre ? 'prerelease' : ''; + for (const key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } + } + } + return defaultResult // may be undefined + } }; +var diff_1 = diff; -convert$4.rgb.lab = function (rgb) { - const xyz = convert$4.rgb.xyz(rgb); - let x = xyz[0]; - let y = xyz[1]; - let z = xyz[2]; - - x /= 95.047; - y /= 100; - z /= 108.883; +const SemVer$a = semver$2; +const major = (a, loose) => new SemVer$a(a, loose).major; +var major_1 = major; - x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); +const SemVer$9 = semver$2; +const minor = (a, loose) => new SemVer$9(a, loose).minor; +var minor_1 = minor; - const l = (116 * y) - 16; - const a = 500 * (x - y); - const b = 200 * (y - z); +const SemVer$8 = semver$2; +const patch = (a, loose) => new SemVer$8(a, loose).patch; +var patch_1 = patch; - return [l, a, b]; +const parse$5 = parse_1; +const prerelease = (version, options) => { + const parsed = parse$5(version, options); + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null }; +var prerelease_1 = prerelease; -convert$4.hsl.rgb = function (hsl) { - const h = hsl[0] / 360; - const s = hsl[1] / 100; - const l = hsl[2] / 100; - let t2; - let t3; - let val; +const compare$9 = compare_1; +const rcompare = (a, b, loose) => compare$9(b, a, loose); +var rcompare_1 = rcompare; - if (s === 0) { - val = l * 255; - return [val, val, val]; - } +const compare$8 = compare_1; +const compareLoose = (a, b) => compare$8(a, b, true); +var compareLoose_1 = compareLoose; - if (l < 0.5) { - t2 = l * (1 + s); - } else { - t2 = l + s - l * s; - } +const SemVer$7 = semver$2; +const compareBuild$2 = (a, b, loose) => { + const versionA = new SemVer$7(a, loose); + const versionB = new SemVer$7(b, loose); + return versionA.compare(versionB) || versionA.compareBuild(versionB) +}; +var compareBuild_1 = compareBuild$2; - const t1 = 2 * l - t2; +const compareBuild$1 = compareBuild_1; +const sort$1 = (list, loose) => list.sort((a, b) => compareBuild$1(a, b, loose)); +var sort_1 = sort$1; - const rgb = [0, 0, 0]; - for (let i = 0; i < 3; i++) { - t3 = h + 1 / 3 * -(i - 1); - if (t3 < 0) { - t3++; - } +const compareBuild = compareBuild_1; +const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)); +var rsort_1 = rsort; - if (t3 > 1) { - t3--; - } +const compare$7 = compare_1; +const gt$3 = (a, b, loose) => compare$7(a, b, loose) > 0; +var gt_1 = gt$3; - if (6 * t3 < 1) { - val = t1 + (t2 - t1) * 6 * t3; - } else if (2 * t3 < 1) { - val = t2; - } else if (3 * t3 < 2) { - val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; - } else { - val = t1; - } +const compare$6 = compare_1; +const lt$2 = (a, b, loose) => compare$6(a, b, loose) < 0; +var lt_1 = lt$2; - rgb[i] = val * 255; - } +const compare$5 = compare_1; +const neq$1 = (a, b, loose) => compare$5(a, b, loose) !== 0; +var neq_1 = neq$1; - return rgb; -}; +const compare$4 = compare_1; +const gte$3 = (a, b, loose) => compare$4(a, b, loose) >= 0; +var gte_1 = gte$3; -convert$4.hsl.hsv = function (hsl) { - const h = hsl[0]; - let s = hsl[1] / 100; - let l = hsl[2] / 100; - let smin = s; - const lmin = Math.max(l, 0.01); +const compare$3 = compare_1; +const lte$3 = (a, b, loose) => compare$3(a, b, loose) <= 0; +var lte_1 = lte$3; - l *= 2; - s *= (l <= 1) ? l : 2 - l; - smin *= lmin <= 1 ? lmin : 2 - lmin; - const v = (l + s) / 2; - const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); +const eq = eq_1; +const neq = neq_1; +const gt$2 = gt_1; +const gte$2 = gte_1; +const lt$1 = lt_1; +const lte$2 = lte_1; - return [h, sv * 100, v * 100]; -}; +const cmp$1 = (a, op, b, loose) => { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version; + if (typeof b === 'object') + b = b.version; + return a === b -convert$4.hsv.rgb = function (hsv) { - const h = hsv[0] / 60; - const s = hsv[1] / 100; - let v = hsv[2] / 100; - const hi = Math.floor(h) % 6; + case '!==': + if (typeof a === 'object') + a = a.version; + if (typeof b === 'object') + b = b.version; + return a !== b - const f = h - Math.floor(h); - const p = 255 * v * (1 - s); - const q = 255 * v * (1 - (s * f)); - const t = 255 * v * (1 - (s * (1 - f))); - v *= 255; + case '': + case '=': + case '==': + return eq(a, b, loose) - switch (hi) { - case 0: - return [v, t, p]; - case 1: - return [q, v, p]; - case 2: - return [p, v, t]; - case 3: - return [p, q, v]; - case 4: - return [t, p, v]; - case 5: - return [v, p, q]; - } -}; + case '!=': + return neq(a, b, loose) -convert$4.hsv.hsl = function (hsv) { - const h = hsv[0]; - const s = hsv[1] / 100; - const v = hsv[2] / 100; - const vmin = Math.max(v, 0.01); - let sl; - let l; + case '>': + return gt$2(a, b, loose) - l = (2 - s) * v; - const lmin = (2 - s) * vmin; - sl = s * vmin; - sl /= (lmin <= 1) ? lmin : 2 - lmin; - sl = sl || 0; - l /= 2; + case '>=': + return gte$2(a, b, loose) - return [h, sl * 100, l * 100]; -}; + case '<': + return lt$1(a, b, loose) + + case '<=': + return lte$2(a, b, loose) -// http://dev.w3.org/csswg/css-color/#hwb-to-rgb -convert$4.hwb.rgb = function (hwb) { - const h = hwb[0] / 360; - let wh = hwb[1] / 100; - let bl = hwb[2] / 100; - const ratio = wh + bl; - let f; + default: + throw new TypeError(`Invalid operator: ${op}`) + } +}; +var cmp_1 = cmp$1; - // Wh + bl cant be > 1 - if (ratio > 1) { - wh /= ratio; - bl /= ratio; - } +const SemVer$6 = semver$2; +const parse$4 = parse_1; +const {re: re$3, t: t$2} = re$6.exports; - const i = Math.floor(6 * h); - const v = 1 - bl; - f = 6 * h - i; +const coerce$I = (version, options) => { + if (version instanceof SemVer$6) { + return version + } - if ((i & 0x01) !== 0) { - f = 1 - f; - } + if (typeof version === 'number') { + version = String(version); + } - const n = wh + f * (v - wh); // Linear interpolation + if (typeof version !== 'string') { + return null + } - let r; - let g; - let b; - /* eslint-disable max-statements-per-line,no-multi-spaces */ - switch (i) { - default: - case 6: - case 0: r = v; g = n; b = wh; break; - case 1: r = n; g = v; b = wh; break; - case 2: r = wh; g = v; b = n; break; - case 3: r = wh; g = n; b = v; break; - case 4: r = n; g = wh; b = v; break; - case 5: r = v; g = wh; b = n; break; - } - /* eslint-enable max-statements-per-line,no-multi-spaces */ + options = options || {}; - return [r * 255, g * 255, b * 255]; -}; + let match = null; + if (!options.rtl) { + match = version.match(re$3[t$2.COERCE]); + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + let next; + while ((next = re$3[t$2.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if (!match || + next.index + next[0].length !== match.index + match[0].length) { + match = next; + } + re$3[t$2.COERCERTL].lastIndex = next.index + next[1].length + next[2].length; + } + // leave it in a clean state + re$3[t$2.COERCERTL].lastIndex = -1; + } -convert$4.cmyk.rgb = function (cmyk) { - const c = cmyk[0] / 100; - const m = cmyk[1] / 100; - const y = cmyk[2] / 100; - const k = cmyk[3] / 100; + if (match === null) + return null - const r = 1 - Math.min(1, c * (1 - k) + k); - const g = 1 - Math.min(1, m * (1 - k) + k); - const b = 1 - Math.min(1, y * (1 - k) + k); + return parse$4(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) +}; +var coerce_1 = coerce$I; - return [r * 255, g * 255, b * 255]; +var iterator = function (Yallist) { + Yallist.prototype[Symbol.iterator] = function* () { + for (let walker = this.head; walker; walker = walker.next) { + yield walker.value; + } + }; }; -convert$4.xyz.rgb = function (xyz) { - const x = xyz[0] / 100; - const y = xyz[1] / 100; - const z = xyz[2] / 100; - let r; - let g; - let b; +var yallist = Yallist$1; - r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); - g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); - b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); +Yallist$1.Node = Node; +Yallist$1.create = Yallist$1; - // Assume sRGB - r = r > 0.0031308 - ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055) - : r * 12.92; +function Yallist$1 (list) { + var self = this; + if (!(self instanceof Yallist$1)) { + self = new Yallist$1(); + } - g = g > 0.0031308 - ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055) - : g * 12.92; + self.tail = null; + self.head = null; + self.length = 0; - b = b > 0.0031308 - ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055) - : b * 12.92; + if (list && typeof list.forEach === 'function') { + list.forEach(function (item) { + self.push(item); + }); + } else if (arguments.length > 0) { + for (var i = 0, l = arguments.length; i < l; i++) { + self.push(arguments[i]); + } + } - r = Math.min(Math.max(0, r), 1); - g = Math.min(Math.max(0, g), 1); - b = Math.min(Math.max(0, b), 1); + return self +} - return [r * 255, g * 255, b * 255]; -}; +Yallist$1.prototype.removeNode = function (node) { + if (node.list !== this) { + throw new Error('removing node which does not belong to this list') + } -convert$4.xyz.lab = function (xyz) { - let x = xyz[0]; - let y = xyz[1]; - let z = xyz[2]; + var next = node.next; + var prev = node.prev; - x /= 95.047; - y /= 100; - z /= 108.883; + if (next) { + next.prev = prev; + } - x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); + if (prev) { + prev.next = next; + } - const l = (116 * y) - 16; - const a = 500 * (x - y); - const b = 200 * (y - z); + if (node === this.head) { + this.head = next; + } + if (node === this.tail) { + this.tail = prev; + } - return [l, a, b]; -}; + node.list.length--; + node.next = null; + node.prev = null; + node.list = null; -convert$4.lab.xyz = function (lab) { - const l = lab[0]; - const a = lab[1]; - const b = lab[2]; - let x; - let y; - let z; + return next +}; - y = (l + 16) / 116; - x = a / 500 + y; - z = y - b / 200; +Yallist$1.prototype.unshiftNode = function (node) { + if (node === this.head) { + return + } - const y2 = y ** 3; - const x2 = x ** 3; - const z2 = z ** 3; - y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; - x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; - z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; + if (node.list) { + node.list.removeNode(node); + } - x *= 95.047; - y *= 100; - z *= 108.883; + var head = this.head; + node.list = this; + node.next = head; + if (head) { + head.prev = node; + } - return [x, y, z]; + this.head = node; + if (!this.tail) { + this.tail = node; + } + this.length++; }; -convert$4.lab.lch = function (lab) { - const l = lab[0]; - const a = lab[1]; - const b = lab[2]; - let h; - - const hr = Math.atan2(b, a); - h = hr * 360 / 2 / Math.PI; +Yallist$1.prototype.pushNode = function (node) { + if (node === this.tail) { + return + } - if (h < 0) { - h += 360; - } + if (node.list) { + node.list.removeNode(node); + } - const c = Math.sqrt(a * a + b * b); + var tail = this.tail; + node.list = this; + node.prev = tail; + if (tail) { + tail.next = node; + } - return [l, c, h]; + this.tail = node; + if (!this.head) { + this.head = node; + } + this.length++; }; -convert$4.lch.lab = function (lch) { - const l = lch[0]; - const c = lch[1]; - const h = lch[2]; - - const hr = h / 360 * 2 * Math.PI; - const a = c * Math.cos(hr); - const b = c * Math.sin(hr); +Yallist$1.prototype.push = function () { + for (var i = 0, l = arguments.length; i < l; i++) { + push$2(this, arguments[i]); + } + return this.length +}; - return [l, a, b]; +Yallist$1.prototype.unshift = function () { + for (var i = 0, l = arguments.length; i < l; i++) { + unshift(this, arguments[i]); + } + return this.length }; -convert$4.rgb.ansi16 = function (args, saturation = null) { - const [r, g, b] = args; - let value = saturation === null ? convert$4.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization +Yallist$1.prototype.pop = function () { + if (!this.tail) { + return undefined + } - value = Math.round(value / 50); + var res = this.tail.value; + this.tail = this.tail.prev; + if (this.tail) { + this.tail.next = null; + } else { + this.head = null; + } + this.length--; + return res +}; - if (value === 0) { - return 30; - } +Yallist$1.prototype.shift = function () { + if (!this.head) { + return undefined + } - let ansi = 30 - + ((Math.round(b / 255) << 2) - | (Math.round(g / 255) << 1) - | Math.round(r / 255)); + var res = this.head.value; + this.head = this.head.next; + if (this.head) { + this.head.prev = null; + } else { + this.tail = null; + } + this.length--; + return res +}; - if (value === 2) { - ansi += 60; - } +Yallist$1.prototype.forEach = function (fn, thisp) { + thisp = thisp || this; + for (var walker = this.head, i = 0; walker !== null; i++) { + fn.call(thisp, walker.value, i, this); + walker = walker.next; + } +}; - return ansi; +Yallist$1.prototype.forEachReverse = function (fn, thisp) { + thisp = thisp || this; + for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { + fn.call(thisp, walker.value, i, this); + walker = walker.prev; + } }; -convert$4.hsv.ansi16 = function (args) { - // Optimization here; we already know the value and don't need to get - // it converted for us. - return convert$4.rgb.ansi16(convert$4.hsv.rgb(args), args[2]); +Yallist$1.prototype.get = function (n) { + for (var i = 0, walker = this.head; walker !== null && i < n; i++) { + // abort out of the list early if we hit a cycle + walker = walker.next; + } + if (i === n && walker !== null) { + return walker.value + } }; -convert$4.rgb.ansi256 = function (args) { - const r = args[0]; - const g = args[1]; - const b = args[2]; +Yallist$1.prototype.getReverse = function (n) { + for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { + // abort out of the list early if we hit a cycle + walker = walker.prev; + } + if (i === n && walker !== null) { + return walker.value + } +}; - // We use the extended greyscale palette here, with the exception of - // black and white. normal palette only has 4 greyscale shades. - if (r === g && g === b) { - if (r < 8) { - return 16; - } +Yallist$1.prototype.map = function (fn, thisp) { + thisp = thisp || this; + var res = new Yallist$1(); + for (var walker = this.head; walker !== null;) { + res.push(fn.call(thisp, walker.value, this)); + walker = walker.next; + } + return res +}; - if (r > 248) { - return 231; - } +Yallist$1.prototype.mapReverse = function (fn, thisp) { + thisp = thisp || this; + var res = new Yallist$1(); + for (var walker = this.tail; walker !== null;) { + res.push(fn.call(thisp, walker.value, this)); + walker = walker.prev; + } + return res +}; - return Math.round(((r - 8) / 247) * 24) + 232; - } +Yallist$1.prototype.reduce = function (fn, initial) { + var acc; + var walker = this.head; + if (arguments.length > 1) { + acc = initial; + } else if (this.head) { + walker = this.head.next; + acc = this.head.value; + } else { + throw new TypeError('Reduce of empty list with no initial value') + } - const ansi = 16 - + (36 * Math.round(r / 255 * 5)) - + (6 * Math.round(g / 255 * 5)) - + Math.round(b / 255 * 5); + for (var i = 0; walker !== null; i++) { + acc = fn(acc, walker.value, i); + walker = walker.next; + } - return ansi; + return acc }; -convert$4.ansi16.rgb = function (args) { - let color = args % 10; +Yallist$1.prototype.reduceReverse = function (fn, initial) { + var acc; + var walker = this.tail; + if (arguments.length > 1) { + acc = initial; + } else if (this.tail) { + walker = this.tail.prev; + acc = this.tail.value; + } else { + throw new TypeError('Reduce of empty list with no initial value') + } - // Handle greyscale - if (color === 0 || color === 7) { - if (args > 50) { - color += 3.5; - } + for (var i = this.length - 1; walker !== null; i--) { + acc = fn(acc, walker.value, i); + walker = walker.prev; + } - color = color / 10.5 * 255; + return acc +}; - return [color, color, color]; - } +Yallist$1.prototype.toArray = function () { + var arr = new Array(this.length); + for (var i = 0, walker = this.head; walker !== null; i++) { + arr[i] = walker.value; + walker = walker.next; + } + return arr +}; - const mult = (~~(args > 50) + 1) * 0.5; - const r = ((color & 1) * mult) * 255; - const g = (((color >> 1) & 1) * mult) * 255; - const b = (((color >> 2) & 1) * mult) * 255; +Yallist$1.prototype.toArrayReverse = function () { + var arr = new Array(this.length); + for (var i = 0, walker = this.tail; walker !== null; i++) { + arr[i] = walker.value; + walker = walker.prev; + } + return arr +}; - return [r, g, b]; +Yallist$1.prototype.slice = function (from, to) { + to = to || this.length; + if (to < 0) { + to += this.length; + } + from = from || 0; + if (from < 0) { + from += this.length; + } + var ret = new Yallist$1(); + if (to < from || to < 0) { + return ret + } + if (from < 0) { + from = 0; + } + if (to > this.length) { + to = this.length; + } + for (var i = 0, walker = this.head; walker !== null && i < from; i++) { + walker = walker.next; + } + for (; walker !== null && i < to; i++, walker = walker.next) { + ret.push(walker.value); + } + return ret }; -convert$4.ansi256.rgb = function (args) { - // Handle greyscale - if (args >= 232) { - const c = (args - 232) * 10 + 8; - return [c, c, c]; - } +Yallist$1.prototype.sliceReverse = function (from, to) { + to = to || this.length; + if (to < 0) { + to += this.length; + } + from = from || 0; + if (from < 0) { + from += this.length; + } + var ret = new Yallist$1(); + if (to < from || to < 0) { + return ret + } + if (from < 0) { + from = 0; + } + if (to > this.length) { + to = this.length; + } + for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { + walker = walker.prev; + } + for (; walker !== null && i > from; i--, walker = walker.prev) { + ret.push(walker.value); + } + return ret +}; - args -= 16; +Yallist$1.prototype.splice = function (start, deleteCount, ...nodes) { + if (start > this.length) { + start = this.length - 1; + } + if (start < 0) { + start = this.length + start; + } - let rem; - const r = Math.floor(args / 36) / 5 * 255; - const g = Math.floor((rem = args % 36) / 6) / 5 * 255; - const b = (rem % 6) / 5 * 255; + for (var i = 0, walker = this.head; walker !== null && i < start; i++) { + walker = walker.next; + } - return [r, g, b]; -}; + var ret = []; + for (var i = 0; walker && i < deleteCount; i++) { + ret.push(walker.value); + walker = this.removeNode(walker); + } + if (walker === null) { + walker = this.tail; + } -convert$4.rgb.hex = function (args) { - const integer = ((Math.round(args[0]) & 0xFF) << 16) - + ((Math.round(args[1]) & 0xFF) << 8) - + (Math.round(args[2]) & 0xFF); + if (walker !== this.head && walker !== this.tail) { + walker = walker.prev; + } - const string = integer.toString(16).toUpperCase(); - return '000000'.substring(string.length) + string; + for (var i = 0; i < nodes.length; i++) { + walker = insert(this, walker, nodes[i]); + } + return ret; }; -convert$4.hex.rgb = function (args) { - const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); - if (!match) { - return [0, 0, 0]; - } +Yallist$1.prototype.reverse = function () { + var head = this.head; + var tail = this.tail; + for (var walker = head; walker !== null; walker = walker.prev) { + var p = walker.prev; + walker.prev = walker.next; + walker.next = p; + } + this.head = tail; + this.tail = head; + return this +}; - let colorString = match[0]; +function insert (self, node, value) { + var inserted = node === self.head ? + new Node(value, null, node, self) : + new Node(value, node, node.next, self); - if (match[0].length === 3) { - colorString = colorString.split('').map(char => { - return char + char; - }).join(''); - } + if (inserted.next === null) { + self.tail = inserted; + } + if (inserted.prev === null) { + self.head = inserted; + } - const integer = parseInt(colorString, 16); - const r = (integer >> 16) & 0xFF; - const g = (integer >> 8) & 0xFF; - const b = integer & 0xFF; + self.length++; - return [r, g, b]; -}; + return inserted +} -convert$4.rgb.hcg = function (rgb) { - const r = rgb[0] / 255; - const g = rgb[1] / 255; - const b = rgb[2] / 255; - const max = Math.max(Math.max(r, g), b); - const min = Math.min(Math.min(r, g), b); - const chroma = (max - min); - let grayscale; - let hue; +function push$2 (self, item) { + self.tail = new Node(item, self.tail, null, self); + if (!self.head) { + self.head = self.tail; + } + self.length++; +} - if (chroma < 1) { - grayscale = min / (1 - chroma); - } else { - grayscale = 0; - } +function unshift (self, item) { + self.head = new Node(item, null, self.head, self); + if (!self.tail) { + self.tail = self.head; + } + self.length++; +} - if (chroma <= 0) { - hue = 0; - } else - if (max === r) { - hue = ((g - b) / chroma) % 6; - } else - if (max === g) { - hue = 2 + (b - r) / chroma; - } else { - hue = 4 + (r - g) / chroma; - } +function Node (value, prev, next, list) { + if (!(this instanceof Node)) { + return new Node(value, prev, next, list) + } - hue /= 6; - hue %= 1; + this.list = list; + this.value = value; - return [hue * 360, chroma * 100, grayscale * 100]; -}; + if (prev) { + prev.next = this; + this.prev = prev; + } else { + this.prev = null; + } -convert$4.hsl.hcg = function (hsl) { - const s = hsl[1] / 100; - const l = hsl[2] / 100; + if (next) { + next.prev = this; + this.next = next; + } else { + this.next = null; + } +} - const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l)); +try { + // add if support for Symbol.iterator is present + iterator(Yallist$1); +} catch (er) {} - let f = 0; - if (c < 1.0) { - f = (l - 0.5 * c) / (1.0 - c); - } +// A linked list to keep track of recently-used-ness +const Yallist = yallist; + +const MAX = Symbol('max'); +const LENGTH = Symbol('length'); +const LENGTH_CALCULATOR = Symbol('lengthCalculator'); +const ALLOW_STALE = Symbol('allowStale'); +const MAX_AGE = Symbol('maxAge'); +const DISPOSE = Symbol('dispose'); +const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet'); +const LRU_LIST = Symbol('lruList'); +const CACHE = Symbol('cache'); +const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet'); + +const naiveLength = () => 1; + +// lruList is a yallist where the head is the youngest +// item, and the tail is the oldest. the list contains the Hit +// objects as the entries. +// Each Hit object has a reference to its Yallist.Node. This +// never changes. +// +// cache is a Map (or PseudoMap) that matches the keys to +// the Yallist.Node object. +class LRUCache { + constructor (options) { + if (typeof options === 'number') + options = { max: options }; + + if (!options) + options = {}; - return [hsl[0], c * 100, f * 100]; -}; + if (options.max && (typeof options.max !== 'number' || options.max < 0)) + throw new TypeError('max must be a non-negative number') + // Kind of weird to have a default max of Infinity, but oh well. + this[MAX] = options.max || Infinity; -convert$4.hsv.hcg = function (hsv) { - const s = hsv[1] / 100; - const v = hsv[2] / 100; + const lc = options.length || naiveLength; + this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc; + this[ALLOW_STALE] = options.stale || false; + if (options.maxAge && typeof options.maxAge !== 'number') + throw new TypeError('maxAge must be a number') + this[MAX_AGE] = options.maxAge || 0; + this[DISPOSE] = options.dispose; + this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false; + this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false; + this.reset(); + } - const c = s * v; - let f = 0; + // resize the cache when the max changes. + set max (mL) { + if (typeof mL !== 'number' || mL < 0) + throw new TypeError('max must be a non-negative number') - if (c < 1.0) { - f = (v - c) / (1 - c); - } + this[MAX] = mL || Infinity; + trim(this); + } + get max () { + return this[MAX] + } - return [hsv[0], c * 100, f * 100]; -}; + set allowStale (allowStale) { + this[ALLOW_STALE] = !!allowStale; + } + get allowStale () { + return this[ALLOW_STALE] + } -convert$4.hcg.rgb = function (hcg) { - const h = hcg[0] / 360; - const c = hcg[1] / 100; - const g = hcg[2] / 100; + set maxAge (mA) { + if (typeof mA !== 'number') + throw new TypeError('maxAge must be a non-negative number') - if (c === 0.0) { - return [g * 255, g * 255, g * 255]; - } + this[MAX_AGE] = mA; + trim(this); + } + get maxAge () { + return this[MAX_AGE] + } - const pure = [0, 0, 0]; - const hi = (h % 1) * 6; - const v = hi % 1; - const w = 1 - v; - let mg = 0; + // resize the cache when the lengthCalculator changes. + set lengthCalculator (lC) { + if (typeof lC !== 'function') + lC = naiveLength; - /* eslint-disable max-statements-per-line */ - switch (Math.floor(hi)) { - case 0: - pure[0] = 1; pure[1] = v; pure[2] = 0; break; - case 1: - pure[0] = w; pure[1] = 1; pure[2] = 0; break; - case 2: - pure[0] = 0; pure[1] = 1; pure[2] = v; break; - case 3: - pure[0] = 0; pure[1] = w; pure[2] = 1; break; - case 4: - pure[0] = v; pure[1] = 0; pure[2] = 1; break; - default: - pure[0] = 1; pure[1] = 0; pure[2] = w; - } - /* eslint-enable max-statements-per-line */ + if (lC !== this[LENGTH_CALCULATOR]) { + this[LENGTH_CALCULATOR] = lC; + this[LENGTH] = 0; + this[LRU_LIST].forEach(hit => { + hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key); + this[LENGTH] += hit.length; + }); + } + trim(this); + } + get lengthCalculator () { return this[LENGTH_CALCULATOR] } - mg = (1.0 - c) * g; + get length () { return this[LENGTH] } + get itemCount () { return this[LRU_LIST].length } - return [ - (c * pure[0] + mg) * 255, - (c * pure[1] + mg) * 255, - (c * pure[2] + mg) * 255 - ]; -}; + rforEach (fn, thisp) { + thisp = thisp || this; + for (let walker = this[LRU_LIST].tail; walker !== null;) { + const prev = walker.prev; + forEachStep(this, fn, walker, thisp); + walker = prev; + } + } -convert$4.hcg.hsv = function (hcg) { - const c = hcg[1] / 100; - const g = hcg[2] / 100; + forEach (fn, thisp) { + thisp = thisp || this; + for (let walker = this[LRU_LIST].head; walker !== null;) { + const next = walker.next; + forEachStep(this, fn, walker, thisp); + walker = next; + } + } - const v = c + g * (1.0 - c); - let f = 0; + keys () { + return this[LRU_LIST].toArray().map(k => k.key) + } - if (v > 0.0) { - f = c / v; - } + values () { + return this[LRU_LIST].toArray().map(k => k.value) + } - return [hcg[0], f * 100, v * 100]; -}; + reset () { + if (this[DISPOSE] && + this[LRU_LIST] && + this[LRU_LIST].length) { + this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)); + } -convert$4.hcg.hsl = function (hcg) { - const c = hcg[1] / 100; - const g = hcg[2] / 100; + this[CACHE] = new Map(); // hash of items by key + this[LRU_LIST] = new Yallist(); // list of items in order of use recency + this[LENGTH] = 0; // length of items in the list + } - const l = g * (1.0 - c) + 0.5 * c; - let s = 0; + dump () { + return this[LRU_LIST].map(hit => + isStale(this, hit) ? false : { + k: hit.key, + v: hit.value, + e: hit.now + (hit.maxAge || 0) + }).toArray().filter(h => h) + } - if (l > 0.0 && l < 0.5) { - s = c / (2 * l); - } else - if (l >= 0.5 && l < 1.0) { - s = c / (2 * (1 - l)); - } + dumpLru () { + return this[LRU_LIST] + } - return [hcg[0], s * 100, l * 100]; -}; + set (key, value, maxAge) { + maxAge = maxAge || this[MAX_AGE]; -convert$4.hcg.hwb = function (hcg) { - const c = hcg[1] / 100; - const g = hcg[2] / 100; - const v = c + g * (1.0 - c); - return [hcg[0], (v - c) * 100, (1 - v) * 100]; -}; + if (maxAge && typeof maxAge !== 'number') + throw new TypeError('maxAge must be a number') -convert$4.hwb.hcg = function (hwb) { - const w = hwb[1] / 100; - const b = hwb[2] / 100; - const v = 1 - b; - const c = v - w; - let g = 0; + const now = maxAge ? Date.now() : 0; + const len = this[LENGTH_CALCULATOR](value, key); - if (c < 1) { - g = (v - c) / (1 - c); - } + if (this[CACHE].has(key)) { + if (len > this[MAX]) { + del(this, this[CACHE].get(key)); + return false + } - return [hwb[0], c * 100, g * 100]; -}; + const node = this[CACHE].get(key); + const item = node.value; -convert$4.apple.rgb = function (apple) { - return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; -}; + // dispose of the old one before overwriting + // split out into 2 ifs for better coverage tracking + if (this[DISPOSE]) { + if (!this[NO_DISPOSE_ON_SET]) + this[DISPOSE](key, item.value); + } -convert$4.rgb.apple = function (rgb) { - return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; -}; + item.now = now; + item.maxAge = maxAge; + item.value = value; + this[LENGTH] += len - item.length; + item.length = len; + this.get(key); + trim(this); + return true + } -convert$4.gray.rgb = function (args) { - return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; -}; + const hit = new Entry(key, value, len, now, maxAge); -convert$4.gray.hsl = function (args) { - return [0, 0, args[0]]; -}; + // oversized objects fall out of cache automatically. + if (hit.length > this[MAX]) { + if (this[DISPOSE]) + this[DISPOSE](key, value); -convert$4.gray.hsv = convert$4.gray.hsl; + return false + } -convert$4.gray.hwb = function (gray) { - return [0, 100, gray[0]]; + this[LENGTH] += hit.length; + this[LRU_LIST].unshift(hit); + this[CACHE].set(key, this[LRU_LIST].head); + trim(this); + return true + } + + has (key) { + if (!this[CACHE].has(key)) return false + const hit = this[CACHE].get(key).value; + return !isStale(this, hit) + } + + get (key) { + return get(this, key, true) + } + + peek (key) { + return get(this, key, false) + } + + pop () { + const node = this[LRU_LIST].tail; + if (!node) + return null + + del(this, node); + return node.value + } + + del (key) { + del(this, this[CACHE].get(key)); + } + + load (arr) { + // reset the cache + this.reset(); + + const now = Date.now(); + // A previous serialized cache has the most recent items first + for (let l = arr.length - 1; l >= 0; l--) { + const hit = arr[l]; + const expiresAt = hit.e || 0; + if (expiresAt === 0) + // the item was created without expiration in a non aged cache + this.set(hit.k, hit.v); + else { + const maxAge = expiresAt - now; + // dont add already expired items + if (maxAge > 0) { + this.set(hit.k, hit.v, maxAge); + } + } + } + } + + prune () { + this[CACHE].forEach((value, key) => get(this, key, false)); + } +} + +const get = (self, key, doUse) => { + const node = self[CACHE].get(key); + if (node) { + const hit = node.value; + if (isStale(self, hit)) { + del(self, node); + if (!self[ALLOW_STALE]) + return undefined + } else { + if (doUse) { + if (self[UPDATE_AGE_ON_GET]) + node.value.now = Date.now(); + self[LRU_LIST].unshiftNode(node); + } + } + return hit.value + } }; -convert$4.gray.cmyk = function (gray) { - return [0, 0, 0, gray[0]]; +const isStale = (self, hit) => { + if (!hit || (!hit.maxAge && !self[MAX_AGE])) + return false + + const diff = Date.now() - hit.now; + return hit.maxAge ? diff > hit.maxAge + : self[MAX_AGE] && (diff > self[MAX_AGE]) }; -convert$4.gray.lab = function (gray) { - return [gray[0], 0, 0]; +const trim = self => { + if (self[LENGTH] > self[MAX]) { + for (let walker = self[LRU_LIST].tail; + self[LENGTH] > self[MAX] && walker !== null;) { + // We know that we're about to delete this one, and also + // what the next least recently used key will be, so just + // go ahead and set it now. + const prev = walker.prev; + del(self, walker); + walker = prev; + } + } }; -convert$4.gray.hex = function (gray) { - const val = Math.round(gray[0] / 100 * 255) & 0xFF; - const integer = (val << 16) + (val << 8) + val; +const del = (self, node) => { + if (node) { + const hit = node.value; + if (self[DISPOSE]) + self[DISPOSE](hit.key, hit.value); - const string = integer.toString(16).toUpperCase(); - return '000000'.substring(string.length) + string; + self[LENGTH] -= hit.length; + self[CACHE].delete(hit.key); + self[LRU_LIST].removeNode(node); + } }; -convert$4.rgb.gray = function (rgb) { - const val = (rgb[0] + rgb[1] + rgb[2]) / 3; - return [val / 255 * 100]; +class Entry { + constructor (key, value, length, now, maxAge) { + this.key = key; + this.value = value; + this.length = length; + this.now = now; + this.maxAge = maxAge || 0; + } +} + +const forEachStep = (self, fn, node, thisp) => { + let hit = node.value; + if (isStale(self, hit)) { + del(self, node); + if (!self[ALLOW_STALE]) + hit = undefined; + } + if (hit) + fn.call(thisp, hit.value, hit.key, self); }; -const conversions$1 = conversions$2; +var lruCache = LRUCache; -/* - This function routes a model to all other models. +// hoisted class for cyclic dependency +class Range$a { + constructor (range, options) { + options = parseOptions$1(options); - all functions that are routed have a property `.conversion` attached - to the returned synthetic function. This property is an array - of strings, each with the steps in between the 'from' and 'to' - color models (inclusive). + if (range instanceof Range$a) { + if ( + range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease + ) { + return range + } else { + return new Range$a(range.raw, options) + } + } - conversions that are not possible simply are not included. -*/ + if (range instanceof Comparator$2) { + // just put it in the set and return + this.raw = range.value; + this.set = [[range]]; + this.format(); + return this + } -function buildGraph() { - const graph = {}; - // https://jsperf.com/object-keys-vs-for-in-with-closure/3 - const models = Object.keys(conversions$1); + this.options = options; + this.loose = !!options.loose; + this.includePrerelease = !!options.includePrerelease; - for (let len = models.length, i = 0; i < len; i++) { - graph[models[i]] = { - // http://jsperf.com/1-vs-infinity - // micro-opt, but this is simple. - distance: -1, - parent: null - }; - } + // First, split based on boolean or || + this.raw = range; + this.set = range + .split(/\s*\|\|\s*/) + // map the range to a 2d array of comparators + .map(range => this.parseRange(range.trim())) + // throw out any comparator lists that are empty + // this generally means that it was not a valid range, which is allowed + // in loose mode, but will still throw if the WHOLE range is invalid. + .filter(c => c.length); + + if (!this.set.length) { + throw new TypeError(`Invalid SemVer Range: ${range}`) + } + + // if we have any that are not the null set, throw out null sets. + if (this.set.length > 1) { + // keep the first one, in case they're all null sets + const first = this.set[0]; + this.set = this.set.filter(c => !isNullSet(c[0])); + if (this.set.length === 0) + this.set = [first]; + else if (this.set.length > 1) { + // if we have any that are *, then the range is just * + for (const c of this.set) { + if (c.length === 1 && isAny(c[0])) { + this.set = [c]; + break + } + } + } + } - return graph; -} + this.format(); + } -// https://en.wikipedia.org/wiki/Breadth-first_search -function deriveBFS(fromModel) { - const graph = buildGraph(); - const queue = [fromModel]; // Unshift -> queue -> pop + format () { + this.range = this.set + .map((comps) => { + return comps.join(' ').trim() + }) + .join('||') + .trim(); + return this.range + } - graph[fromModel].distance = 0; + toString () { + return this.range + } + + parseRange (range) { + range = range.trim(); + + // memoize range parsing for performance. + // this is a very hot path, and fully deterministic. + const memoOpts = Object.keys(this.options).join(','); + const memoKey = `parseRange:${memoOpts}:${range}`; + const cached = cache$1.get(memoKey); + if (cached) + return cached + + const loose = this.options.loose; + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + const hr = loose ? re$2[t$1.HYPHENRANGELOOSE] : re$2[t$1.HYPHENRANGE]; + range = range.replace(hr, hyphenReplace(this.options.includePrerelease)); + debug$d('hyphen replace', range); + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re$2[t$1.COMPARATORTRIM], comparatorTrimReplace); + debug$d('comparator trim', range, re$2[t$1.COMPARATORTRIM]); + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re$2[t$1.TILDETRIM], tildeTrimReplace); + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re$2[t$1.CARETTRIM], caretTrimReplace); + + // normalize spaces + range = range.split(/\s+/).join(' '); + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + const compRe = loose ? re$2[t$1.COMPARATORLOOSE] : re$2[t$1.COMPARATOR]; + const rangeList = range + .split(' ') + .map(comp => parseComparator(comp, this.options)) + .join(' ') + .split(/\s+/) + // >=0.0.0 is equivalent to * + .map(comp => replaceGTE0(comp, this.options)) + // in loose mode, throw out any that are not valid comparators + .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) + .map(comp => new Comparator$2(comp, this.options)); + + // if any comparators are the null set, then replace with JUST null set + // if more than one comparator, remove any * comparators + // also, don't include the same comparator more than once + rangeList.length; + const rangeMap = new Map(); + for (const comp of rangeList) { + if (isNullSet(comp)) + return [comp] + rangeMap.set(comp.value, comp); + } + if (rangeMap.size > 1 && rangeMap.has('')) + rangeMap.delete(''); + + const result = [...rangeMap.values()]; + cache$1.set(memoKey, result); + return result + } - while (queue.length) { - const current = queue.pop(); - const adjacents = Object.keys(conversions$1[current]); + intersects (range, options) { + if (!(range instanceof Range$a)) { + throw new TypeError('a Range is required') + } - for (let len = adjacents.length, i = 0; i < len; i++) { - const adjacent = adjacents[i]; - const node = graph[adjacent]; + return this.set.some((thisComparators) => { + return ( + isSatisfiable(thisComparators, options) && + range.set.some((rangeComparators) => { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every((thisComparator) => { + return rangeComparators.every((rangeComparator) => { + return thisComparator.intersects(rangeComparator, options) + }) + }) + ) + }) + ) + }) + } - if (node.distance === -1) { - node.distance = graph[current].distance + 1; - node.parent = current; - queue.unshift(adjacent); - } - } - } + // if ANY of the sets match ALL of its comparators, then pass + test (version) { + if (!version) { + return false + } - return graph; -} + if (typeof version === 'string') { + try { + version = new SemVer$5(version, this.options); + } catch (er) { + return false + } + } -function link$1(from, to) { - return function (args) { - return to(from(args)); - }; + for (let i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false + } } +var range$1 = Range$a; -function wrapConversion(toModel, graph) { - const path = [graph[toModel].parent, toModel]; - let fn = conversions$1[graph[toModel].parent][toModel]; +const LRU = lruCache; +const cache$1 = new LRU({ max: 1000 }); - let cur = graph[toModel].parent; - while (graph[cur].parent) { - path.unshift(graph[cur].parent); - fn = link$1(conversions$1[graph[cur].parent][cur], fn); - cur = graph[cur].parent; - } +const parseOptions$1 = parseOptions_1; +const Comparator$2 = comparator$1; +const debug$d = debug_1; +const SemVer$5 = semver$2; +const { + re: re$2, + t: t$1, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace +} = re$6.exports; + +const isNullSet = c => c.value === '<0.0.0-0'; +const isAny = c => c.value === ''; + +// take a set of comparators and determine whether there +// exists a version which can satisfy it +const isSatisfiable = (comparators, options) => { + let result = true; + const remainingComparators = comparators.slice(); + let testComparator = remainingComparators.pop(); + + while (result && remainingComparators.length) { + result = remainingComparators.every((otherComparator) => { + return testComparator.intersects(otherComparator, options) + }); - fn.conversion = path; - return fn; -} + testComparator = remainingComparators.pop(); + } -var route$1 = function (fromModel) { - const graph = deriveBFS(fromModel); - const conversion = {}; + return result +}; - const models = Object.keys(graph); - for (let len = models.length, i = 0; i < len; i++) { - const toModel = models[i]; - const node = graph[toModel]; +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +const parseComparator = (comp, options) => { + debug$d('comp', comp, options); + comp = replaceCarets(comp, options); + debug$d('caret', comp); + comp = replaceTildes(comp, options); + debug$d('tildes', comp); + comp = replaceXRanges(comp, options); + debug$d('xrange', comp); + comp = replaceStars(comp, options); + debug$d('stars', comp); + return comp +}; + +const isX = id => !id || id.toLowerCase() === 'x' || id === '*'; + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 +const replaceTildes = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { + return replaceTilde(comp, options) + }).join(' '); + +const replaceTilde = (comp, options) => { + const r = options.loose ? re$2[t$1.TILDELOOSE] : re$2[t$1.TILDE]; + return comp.replace(r, (_, M, m, p, pr) => { + debug$d('tilde', comp, _, M, m, p, pr); + let ret; - if (node.parent === null) { - // No possible conversion, or this node is the source model. - continue; - } + if (isX(M)) { + ret = ''; + } else if (isX(m)) { + ret = `>=${M}.0.0 <${+M + 1}.0.0-0`; + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0-0 + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`; + } else if (pr) { + debug$d('replaceTilde pr', pr); + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0`; + } else { + // ~1.2.3 == >=1.2.3 <1.3.0-0 + ret = `>=${M}.${m}.${p + } <${M}.${+m + 1}.0-0`; + } - conversion[toModel] = wrapConversion(toModel, graph); - } + debug$d('tilde return', ret); + return ret + }) +}; - return conversion; +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 +// ^1.2.3 --> >=1.2.3 <2.0.0-0 +// ^1.2.0 --> >=1.2.0 <2.0.0-0 +const replaceCarets = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { + return replaceCaret(comp, options) + }).join(' '); + +const replaceCaret = (comp, options) => { + debug$d('caret', comp, options); + const r = options.loose ? re$2[t$1.CARETLOOSE] : re$2[t$1.CARET]; + const z = options.includePrerelease ? '-0' : ''; + return comp.replace(r, (_, M, m, p, pr) => { + debug$d('caret', comp, _, M, m, p, pr); + let ret; + + if (isX(M)) { + ret = ''; + } else if (isX(m)) { + ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`; + } else if (isX(p)) { + if (M === '0') { + ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`; + } else { + ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`; + } + } else if (pr) { + debug$d('replaceCaret pr', pr); + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${m}.${+p + 1}-0`; + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0`; + } + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${+M + 1}.0.0-0`; + } + } else { + debug$d('no pr'); + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p + }${z} <${M}.${m}.${+p + 1}-0`; + } else { + ret = `>=${M}.${m}.${p + }${z} <${M}.${+m + 1}.0-0`; + } + } else { + ret = `>=${M}.${m}.${p + } <${+M + 1}.0.0-0`; + } + } + + debug$d('caret return', ret); + return ret + }) }; -const conversions = conversions$2; -const route = route$1; +const replaceXRanges = (comp, options) => { + debug$d('replaceXRanges', comp, options); + return comp.split(/\s+/).map((comp) => { + return replaceXRange(comp, options) + }).join(' ') +}; -const convert$3 = {}; +const replaceXRange = (comp, options) => { + comp = comp.trim(); + const r = options.loose ? re$2[t$1.XRANGELOOSE] : re$2[t$1.XRANGE]; + return comp.replace(r, (ret, gtlt, M, m, p, pr) => { + debug$d('xRange', comp, ret, gtlt, M, m, p, pr); + const xM = isX(M); + const xm = xM || isX(m); + const xp = xm || isX(p); + const anyX = xp; -const models$3 = Object.keys(conversions); + if (gtlt === '=' && anyX) { + gtlt = ''; + } -function wrapRaw(fn) { - const wrappedFn = function (...args) { - const arg0 = args[0]; - if (arg0 === undefined || arg0 === null) { - return arg0; - } + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : ''; - if (arg0.length > 1) { - args = arg0; - } + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0'; + } else { + // nothing is forbidden + ret = '*'; + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0; + } + p = 0; + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + gtlt = '>='; + if (xm) { + M = +M + 1; + m = 0; + p = 0; + } else { + m = +m + 1; + p = 0; + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<'; + if (xm) { + M = +M + 1; + } else { + m = +m + 1; + } + } - return fn(args); - }; + if (gtlt === '<') + pr = '-0'; - // Preserve .conversion property if there is one - if ('conversion' in fn) { - wrappedFn.conversion = fn.conversion; - } + ret = `${gtlt + M}.${m}.${p}${pr}`; + } else if (xm) { + ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`; + } else if (xp) { + ret = `>=${M}.${m}.0${pr + } <${M}.${+m + 1}.0-0`; + } - return wrappedFn; -} + debug$d('xRange return', ret); -function wrapRounded(fn) { - const wrappedFn = function (...args) { - const arg0 = args[0]; + return ret + }) +}; - if (arg0 === undefined || arg0 === null) { - return arg0; - } +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +const replaceStars = (comp, options) => { + debug$d('replaceStars', comp, options); + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re$2[t$1.STAR], '') +}; + +const replaceGTE0 = (comp, options) => { + debug$d('replaceGTE0', comp, options); + return comp.trim() + .replace(re$2[options.includePrerelease ? t$1.GTE0PRE : t$1.GTE0], '') +}; + +// This function is passed to string.replace(re[t.HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0-0 +const hyphenReplace = incPr => ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) => { + if (isX(fM)) { + from = ''; + } else if (isX(fm)) { + from = `>=${fM}.0.0${incPr ? '-0' : ''}`; + } else if (isX(fp)) { + from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`; + } else if (fpr) { + from = `>=${from}`; + } else { + from = `>=${from}${incPr ? '-0' : ''}`; + } + + if (isX(tM)) { + to = ''; + } else if (isX(tm)) { + to = `<${+tM + 1}.0.0-0`; + } else if (isX(tp)) { + to = `<${tM}.${+tm + 1}.0-0`; + } else if (tpr) { + to = `<=${tM}.${tm}.${tp}-${tpr}`; + } else if (incPr) { + to = `<${tM}.${tm}.${+tp + 1}-0`; + } else { + to = `<=${to}`; + } - if (arg0.length > 1) { - args = arg0; - } + return (`${from} ${to}`).trim() +}; - const result = fn(args); +const testSet = (set, version, options) => { + for (let i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } - // We're assuming the result is an array here. - // see notice in conversions.js; don't use box types - // in conversion functions. - if (typeof result === 'object') { - for (let len = result.length, i = 0; i < len; i++) { - result[i] = Math.round(result[i]); - } - } + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (let i = 0; i < set.length; i++) { + debug$d(set[i].semver); + if (set[i].semver === Comparator$2.ANY) { + continue + } - return result; - }; + if (set[i].semver.prerelease.length > 0) { + const allowed = set[i].semver; + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } - // Preserve .conversion property if there is one - if ('conversion' in fn) { - wrappedFn.conversion = fn.conversion; - } + // Version has a -pre, but it's not one of the ones we like. + return false + } - return wrappedFn; -} + return true +}; -models$3.forEach(fromModel => { - convert$3[fromModel] = {}; +const ANY$2 = Symbol('SemVer ANY'); +// hoisted class for cyclic dependency +class Comparator$1 { + static get ANY () { + return ANY$2 + } + constructor (comp, options) { + options = parseOptions(options); - Object.defineProperty(convert$3[fromModel], 'channels', {value: conversions[fromModel].channels}); - Object.defineProperty(convert$3[fromModel], 'labels', {value: conversions[fromModel].labels}); + if (comp instanceof Comparator$1) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value; + } + } - const routes = route(fromModel); - const routeModels = Object.keys(routes); + debug$c('comparator', comp, options); + this.options = options; + this.loose = !!options.loose; + this.parse(comp); - routeModels.forEach(toModel => { - const fn = routes[toModel]; + if (this.semver === ANY$2) { + this.value = ''; + } else { + this.value = this.operator + this.semver.version; + } - convert$3[fromModel][toModel] = wrapRounded(fn); - convert$3[fromModel][toModel].raw = wrapRaw(fn); - }); -}); + debug$c('comp', this); + } -var colorConvert = convert$3; + parse (comp) { + const r = this.options.loose ? re$1[t.COMPARATORLOOSE] : re$1[t.COMPARATOR]; + const m = comp.match(r); -(function (module) { + if (!m) { + throw new TypeError(`Invalid comparator: ${comp}`) + } -const wrapAnsi16 = (fn, offset) => (...args) => { - const code = fn(...args); - return `\u001B[${code + offset}m`; -}; + this.operator = m[1] !== undefined ? m[1] : ''; + if (this.operator === '=') { + this.operator = ''; + } -const wrapAnsi256 = (fn, offset) => (...args) => { - const code = fn(...args); - return `\u001B[${38 + offset};5;${code}m`; -}; + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY$2; + } else { + this.semver = new SemVer$4(m[2], this.options.loose); + } + } -const wrapAnsi16m = (fn, offset) => (...args) => { - const rgb = fn(...args); - return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; -}; + toString () { + return this.value + } -const ansi2ansi = n => n; -const rgb2rgb = (r, g, b) => [r, g, b]; + test (version) { + debug$c('Comparator.test', version, this.options.loose); -const setLazyProperty = (object, property, get) => { - Object.defineProperty(object, property, { - get: () => { - const value = get(); + if (this.semver === ANY$2 || version === ANY$2) { + return true + } - Object.defineProperty(object, property, { - value, - enumerable: true, - configurable: true - }); + if (typeof version === 'string') { + try { + version = new SemVer$4(version, this.options); + } catch (er) { + return false + } + } - return value; - }, - enumerable: true, - configurable: true - }); + return cmp(version, this.operator, this.semver, this.options) + } + + intersects (comp, options) { + if (!(comp instanceof Comparator$1)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + }; + } + + if (this.operator === '') { + if (this.value === '') { + return true + } + return new Range$9(comp.value, options).test(this.value) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + return new Range$9(this.value, options).test(comp.semver) + } + + const sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>'); + const sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<'); + const sameSemVer = this.semver.version === comp.semver.version; + const differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<='); + const oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<'); + const oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>'); + + return ( + sameDirectionIncreasing || + sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || + oppositeDirectionsGreaterThan + ) + } +} + +var comparator$1 = Comparator$1; + +const parseOptions = parseOptions_1; +const {re: re$1, t} = re$6.exports; +const cmp = cmp_1; +const debug$c = debug_1; +const SemVer$4 = semver$2; +const Range$9 = range$1; + +const Range$8 = range$1; +const satisfies$3 = (version, range, options) => { + try { + range = new Range$8(range, options); + } catch (er) { + return false + } + return range.test(version) }; +var satisfies_1 = satisfies$3; -/** @type {typeof import('color-convert')} */ -let colorConvert$1; -const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => { - if (colorConvert$1 === undefined) { - colorConvert$1 = colorConvert; - } +const Range$7 = range$1; - const offset = isBackground ? 10 : 0; - const styles = {}; +// Mostly just for testing and legacy API reasons +const toComparators = (range, options) => + new Range$7(range, options).set + .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')); - for (const [sourceSpace, suite] of Object.entries(colorConvert$1)) { - const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace; - if (sourceSpace === targetSpace) { - styles[name] = wrap(identity, offset); - } else if (typeof suite === 'object') { - styles[name] = wrap(suite[targetSpace], offset); - } - } +var toComparators_1 = toComparators; - return styles; +const SemVer$3 = semver$2; +const Range$6 = range$1; + +const maxSatisfying = (versions, range, options) => { + let max = null; + let maxSV = null; + let rangeObj = null; + try { + rangeObj = new Range$6(range, options); + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v; + maxSV = new SemVer$3(max, options); + } + } + }); + return max }; +var maxSatisfying_1 = maxSatisfying; -function assembleStyles() { - const codes = new Map(); - const styles = { - modifier: { - reset: [0, 0], - // 21 isn't widely supported and 22 does the same thing - bold: [1, 22], - dim: [2, 22], - italic: [3, 23], - underline: [4, 24], - inverse: [7, 27], - hidden: [8, 28], - strikethrough: [9, 29] - }, - color: { - black: [30, 39], - red: [31, 39], - green: [32, 39], - yellow: [33, 39], - blue: [34, 39], - magenta: [35, 39], - cyan: [36, 39], - white: [37, 39], +const SemVer$2 = semver$2; +const Range$5 = range$1; +const minSatisfying = (versions, range, options) => { + let min = null; + let minSV = null; + let rangeObj = null; + try { + rangeObj = new Range$5(range, options); + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v; + minSV = new SemVer$2(min, options); + } + } + }); + return min +}; +var minSatisfying_1 = minSatisfying; - // Bright color - blackBright: [90, 39], - redBright: [91, 39], - greenBright: [92, 39], - yellowBright: [93, 39], - blueBright: [94, 39], - magentaBright: [95, 39], - cyanBright: [96, 39], - whiteBright: [97, 39] - }, - bgColor: { - bgBlack: [40, 49], - bgRed: [41, 49], - bgGreen: [42, 49], - bgYellow: [43, 49], - bgBlue: [44, 49], - bgMagenta: [45, 49], - bgCyan: [46, 49], - bgWhite: [47, 49], +const SemVer$1 = semver$2; +const Range$4 = range$1; +const gt$1 = gt_1; - // Bright color - bgBlackBright: [100, 49], - bgRedBright: [101, 49], - bgGreenBright: [102, 49], - bgYellowBright: [103, 49], - bgBlueBright: [104, 49], - bgMagentaBright: [105, 49], - bgCyanBright: [106, 49], - bgWhiteBright: [107, 49] - } - }; +const minVersion = (range, loose) => { + range = new Range$4(range, loose); - // Alias bright black as gray (and grey) - styles.color.gray = styles.color.blackBright; - styles.bgColor.bgGray = styles.bgColor.bgBlackBright; - styles.color.grey = styles.color.blackBright; - styles.bgColor.bgGrey = styles.bgColor.bgBlackBright; + let minver = new SemVer$1('0.0.0'); + if (range.test(minver)) { + return minver + } - for (const [groupName, group] of Object.entries(styles)) { - for (const [styleName, style] of Object.entries(group)) { - styles[styleName] = { - open: `\u001B[${style[0]}m`, - close: `\u001B[${style[1]}m` - }; + minver = new SemVer$1('0.0.0-0'); + if (range.test(minver)) { + return minver + } - group[styleName] = styles[styleName]; + minver = null; + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i]; - codes.set(style[0], style[1]); - } + let setMin = null; + comparators.forEach((comparator) => { + // Clone to avoid manipulating the comparator's semver object. + const compver = new SemVer$1(comparator.semver.version); + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++; + } else { + compver.prerelease.push(0); + } + compver.raw = compver.format(); + /* fallthrough */ + case '': + case '>=': + if (!setMin || gt$1(compver, setMin)) { + setMin = compver; + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error(`Unexpected operation: ${comparator.operator}`) + } + }); + if (setMin && (!minver || gt$1(minver, setMin))) + minver = setMin; + } - Object.defineProperty(styles, groupName, { - value: group, - enumerable: false - }); - } + if (minver && range.test(minver)) { + return minver + } - Object.defineProperty(styles, 'codes', { - value: codes, - enumerable: false - }); + return null +}; +var minVersion_1 = minVersion; - styles.color.close = '\u001B[39m'; - styles.bgColor.close = '\u001B[49m'; +const Range$3 = range$1; +const validRange = (range, options) => { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range$3(range, options).range || '*' + } catch (er) { + return null + } +}; +var valid = validRange; + +const SemVer = semver$2; +const Comparator = comparator$1; +const {ANY: ANY$1} = Comparator; +const Range$2 = range$1; +const satisfies$2 = satisfies_1; +const gt = gt_1; +const lt = lt_1; +const lte$1 = lte_1; +const gte$1 = gte_1; + +const outside$2 = (version, range, hilo, options) => { + version = new SemVer(version, options); + range = new Range$2(range, options); + + let gtfn, ltefn, ltfn, comp, ecomp; + switch (hilo) { + case '>': + gtfn = gt; + ltefn = lte$1; + ltfn = lt; + comp = '>'; + ecomp = '>='; + break + case '<': + gtfn = lt; + ltefn = gte$1; + ltfn = gt; + comp = '<'; + ecomp = '<='; + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } - setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false)); - setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false)); - setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false)); - setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true)); - setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true)); - setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true)); + // If it satisfies the range it is not outside + if (satisfies$2(version, range, options)) { + return false + } - return styles; -} + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. -// Make the export immutable -Object.defineProperty(module, 'exports', { - enumerable: true, - get: assembleStyles -}); -}(ansiStyles$1)); + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i]; -const stringReplaceAll$1 = (string, substring, replacer) => { - let index = string.indexOf(substring); - if (index === -1) { - return string; - } + let high = null; + let low = null; - const substringLength = substring.length; - let endIndex = 0; - let returnValue = ''; - do { - returnValue += string.substr(endIndex, index - endIndex) + substring + replacer; - endIndex = index + substringLength; - index = string.indexOf(substring, endIndex); - } while (index !== -1); + comparators.forEach((comparator) => { + if (comparator.semver === ANY$1) { + comparator = new Comparator('>=0.0.0'); + } + high = high || comparator; + low = low || comparator; + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator; + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator; + } + }); - returnValue += string.substr(endIndex); - return returnValue; -}; + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } -const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => { - let endIndex = 0; - let returnValue = ''; - do { - const gotCR = string[index - 1] === '\r'; - returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix; - endIndex = index + 1; - index = string.indexOf('\n', endIndex); - } while (index !== -1); + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false + } + } + return true +}; - returnValue += string.substr(endIndex); - return returnValue; +var outside_1 = outside$2; + +// Determine if version is greater than all the versions possible in the range. +const outside$1 = outside_1; +const gtr = (version, range, options) => outside$1(version, range, '>', options); +var gtr_1 = gtr; + +const outside = outside_1; +// Determine if version is less than all the versions possible in the range +const ltr = (version, range, options) => outside(version, range, '<', options); +var ltr_1 = ltr; + +const Range$1 = range$1; +const intersects = (r1, r2, options) => { + r1 = new Range$1(r1, options); + r2 = new Range$1(r2, options); + return r1.intersects(r2) +}; +var intersects_1 = intersects; + +// given a set of versions and a range, create a "simplified" range +// that includes the same versions that the original range does +// If the original range is shorter than the simplified one, return that. +const satisfies$1 = satisfies_1; +const compare$2 = compare_1; +var simplify = (versions, range, options) => { + const set = []; + let min = null; + let prev = null; + const v = versions.sort((a, b) => compare$2(a, b, options)); + for (const version of v) { + const included = satisfies$1(version, range, options); + if (included) { + prev = version; + if (!min) + min = version; + } else { + if (prev) { + set.push([min, prev]); + } + prev = null; + min = null; + } + } + if (min) + set.push([min, null]); + + const ranges = []; + for (const [min, max] of set) { + if (min === max) + ranges.push(min); + else if (!max && min === v[0]) + ranges.push('*'); + else if (!max) + ranges.push(`>=${min}`); + else if (min === v[0]) + ranges.push(`<=${max}`); + else + ranges.push(`${min} - ${max}`); + } + const simplified = ranges.join(' || '); + const original = typeof range.raw === 'string' ? range.raw : String(range); + return simplified.length < original.length ? simplified : range }; -var util$2 = { - stringReplaceAll: stringReplaceAll$1, - stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1 +const Range = range$1; +const { ANY } = comparator$1; +const satisfies = satisfies_1; +const compare$1 = compare_1; + +// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: +// - Every simple range `r1, r2, ...` is a subset of some `R1, R2, ...` +// +// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: +// - If c is only the ANY comparator +// - If C is only the ANY comparator, return true +// - Else return false +// - Let EQ be the set of = comparators in c +// - If EQ is more than one, return true (null set) +// - Let GT be the highest > or >= comparator in c +// - Let LT be the lowest < or <= comparator in c +// - If GT and LT, and GT.semver > LT.semver, return true (null set) +// - If EQ +// - If GT, and EQ does not satisfy GT, return true (null set) +// - If LT, and EQ does not satisfy LT, return true (null set) +// - If EQ satisfies every C, return true +// - Else return false +// - If GT +// - If GT.semver is lower than any > or >= comp in C, return false +// - If GT is >=, and GT.semver does not satisfy every C, return false +// - If LT +// - If LT.semver is greater than any < or <= comp in C, return false +// - If LT is <=, and LT.semver does not satisfy every C, return false +// - If any C is a = range, and GT or LT are set, return false +// - Else return true + +const subset = (sub, dom, options) => { + if (sub === dom) + return true + + sub = new Range(sub, options); + dom = new Range(dom, options); + let sawNonNull = false; + + OUTER: for (const simpleSub of sub.set) { + for (const simpleDom of dom.set) { + const isSub = simpleSubset(simpleSub, simpleDom, options); + sawNonNull = sawNonNull || isSub !== null; + if (isSub) + continue OUTER + } + // the null set is a subset of everything, but null simple ranges in + // a complex range should be ignored. so if we saw a non-null range, + // then we know this isn't a subset, but if EVERY simple range was null, + // then it is a subset. + if (sawNonNull) + return false + } + return true }; -const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; -const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; -const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; -const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi; +const simpleSubset = (sub, dom, options) => { + if (sub === dom) + return true -const ESCAPES = new Map([ - ['n', '\n'], - ['r', '\r'], - ['t', '\t'], - ['b', '\b'], - ['f', '\f'], - ['v', '\v'], - ['0', '\0'], - ['\\', '\\'], - ['e', '\u001B'], - ['a', '\u0007'] -]); + if (sub.length === 1 && sub[0].semver === ANY) + return dom.length === 1 && dom[0].semver === ANY -function unescape(c) { - const u = c[0] === 'u'; - const bracket = c[1] === '{'; + const eqSet = new Set(); + let gt, lt; + for (const c of sub) { + if (c.operator === '>' || c.operator === '>=') + gt = higherGT(gt, c, options); + else if (c.operator === '<' || c.operator === '<=') + lt = lowerLT(lt, c, options); + else + eqSet.add(c.semver); + } - if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) { - return String.fromCharCode(parseInt(c.slice(1), 16)); - } + if (eqSet.size > 1) + return null - if (u && bracket) { - return String.fromCodePoint(parseInt(c.slice(2, -1), 16)); - } + let gtltComp; + if (gt && lt) { + gtltComp = compare$1(gt.semver, lt.semver, options); + if (gtltComp > 0) + return null + else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + return null + } - return ESCAPES.get(c) || c; -} + // will iterate one or zero times + for (const eq of eqSet) { + if (gt && !satisfies(eq, String(gt), options)) + return null -function parseArguments(name, arguments_) { - const results = []; - const chunks = arguments_.trim().split(/\s*,\s*/g); - let matches; + if (lt && !satisfies(eq, String(lt), options)) + return null - for (const chunk of chunks) { - const number = Number(chunk); - if (!Number.isNaN(number)) { - results.push(number); - } else if ((matches = chunk.match(STRING_REGEX))) { - results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character)); - } else { - throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); - } - } + for (const c of dom) { + if (!satisfies(eq, String(c), options)) + return false + } - return results; -} + return true + } -function parseStyle(style) { - STYLE_REGEX.lastIndex = 0; + let higher, lower; + let hasDomLT, hasDomGT; + for (const c of dom) { + hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='; + hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='; + if (gt) { + if (c.operator === '>' || c.operator === '>=') { + higher = higherGT(gt, c, options); + if (higher === c && higher !== gt) + return false + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + return false + } + if (lt) { + if (c.operator === '<' || c.operator === '<=') { + lower = lowerLT(lt, c, options); + if (lower === c && lower !== lt) + return false + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + return false + } + if (!c.operator && (lt || gt) && gtltComp !== 0) + return false + } - const results = []; - let matches; + // if there was a < or >, and nothing in the dom, then must be false + // UNLESS it was limited by another range in the other direction. + // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 + if (gt && hasDomLT && !lt && gtltComp !== 0) + return false - while ((matches = STYLE_REGEX.exec(style)) !== null) { - const name = matches[1]; + if (lt && hasDomGT && !gt && gtltComp !== 0) + return false - if (matches[2]) { - const args = parseArguments(name, matches[2]); - results.push([name].concat(args)); - } else { - results.push([name]); - } - } + return true +}; - return results; -} +// >=1.2.3 is lower than >1.2.3 +const higherGT = (a, b, options) => { + if (!a) + return b + const comp = compare$1(a.semver, b.semver, options); + return comp > 0 ? a + : comp < 0 ? b + : b.operator === '>' && a.operator === '>=' ? b + : a +}; + +// <=1.2.3 is higher than <1.2.3 +const lowerLT = (a, b, options) => { + if (!a) + return b + const comp = compare$1(a.semver, b.semver, options); + return comp < 0 ? a + : comp > 0 ? b + : b.operator === '<' && a.operator === '<=' ? b + : a +}; + +var subset_1 = subset; + +// just pre-load all the stuff that index.js lazily exports +const internalRe = re$6.exports; +var semver$1 = { + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + SemVer: semver$2, + compareIdentifiers: identifiers.compareIdentifiers, + rcompareIdentifiers: identifiers.rcompareIdentifiers, + parse: parse_1, + valid: valid_1, + clean: clean_1, + inc: inc_1, + diff: diff_1, + major: major_1, + minor: minor_1, + patch: patch_1, + prerelease: prerelease_1, + compare: compare_1, + rcompare: rcompare_1, + compareLoose: compareLoose_1, + compareBuild: compareBuild_1, + sort: sort_1, + rsort: rsort_1, + gt: gt_1, + lt: lt_1, + eq: eq_1, + neq: neq_1, + gte: gte_1, + lte: lte_1, + cmp: cmp_1, + coerce: coerce_1, + Comparator: comparator$1, + Range: range$1, + satisfies: satisfies_1, + toComparators: toComparators_1, + maxSatisfying: maxSatisfying_1, + minSatisfying: minSatisfying_1, + minVersion: minVersion_1, + validRange: valid, + outside: outside_1, + gtr: gtr_1, + ltr: ltr_1, + intersects: intersects_1, + simplifyRange: simplify, + subset: subset_1, +}; + +var semver = semver$1; + +var builtins = function ({ + version = process.version, + experimental = false +} = {}) { + var coreModules = [ + 'assert', + 'buffer', + 'child_process', + 'cluster', + 'console', + 'constants', + 'crypto', + 'dgram', + 'dns', + 'domain', + 'events', + 'fs', + 'http', + 'https', + 'module', + 'net', + 'os', + 'path', + 'punycode', + 'querystring', + 'readline', + 'repl', + 'stream', + 'string_decoder', + 'sys', + 'timers', + 'tls', + 'tty', + 'url', + 'util', + 'vm', + 'zlib' + ]; + + if (semver.lt(version, '6.0.0')) coreModules.push('freelist'); + if (semver.gte(version, '1.0.0')) coreModules.push('v8'); + if (semver.gte(version, '1.1.0')) coreModules.push('process'); + if (semver.gte(version, '8.0.0')) coreModules.push('inspector'); + if (semver.gte(version, '8.1.0')) coreModules.push('async_hooks'); + if (semver.gte(version, '8.4.0')) coreModules.push('http2'); + if (semver.gte(version, '8.5.0')) coreModules.push('perf_hooks'); + if (semver.gte(version, '10.0.0')) coreModules.push('trace_events'); -function buildStyle(chalk, styles) { - const enabled = {}; + if ( + semver.gte(version, '10.5.0') && + (experimental || semver.gte(version, '12.0.0')) + ) { + coreModules.push('worker_threads'); + } + if (semver.gte(version, '12.16.0') && experimental) { + coreModules.push('wasi'); + } + + return coreModules +}; - for (const layer of styles) { - for (const style of layer.styles) { - enabled[style[0]] = layer.inverse ? null : style.slice(1); - } - } +// Manually “tree shaken” from: - let current = chalk; - for (const [styleName, styles] of Object.entries(enabled)) { - if (!Array.isArray(styles)) { - continue; - } +const reader = {read: read$3}; +var packageJsonReader = reader; - if (!(styleName in current)) { - throw new Error(`Unknown Chalk style: ${styleName}`); - } +/** + * @param {string} jsonPath + * @returns {{string: string}} + */ +function read$3(jsonPath) { + return find$1(path__default['default'].dirname(jsonPath)) +} - current = styles.length > 0 ? current[styleName](...styles) : current[styleName]; - } +/** + * @param {string} dir + * @returns {{string: string}} + */ +function find$1(dir) { + try { + const string = require$$0__default$1['default'].readFileSync( + path__default['default'].toNamespacedPath(path__default['default'].join(dir, 'package.json')), + 'utf8' + ); + return {string} + } catch (error) { + if (error.code === 'ENOENT') { + const parent = path__default['default'].dirname(dir); + if (dir !== parent) return find$1(parent) + return {string: undefined} + // Throw all other errors. + /* c8 ignore next 4 */ + } - return current; + throw error + } } -var templates = (chalk, temporary) => { - const styles = []; - const chunks = []; - let chunk = []; +// Manually “tree shaken” from: - // eslint-disable-next-line max-params - temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => { - if (escapeCharacter) { - chunk.push(unescape(escapeCharacter)); - } else if (style) { - const string = chunk.join(''); - chunk = []; - chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string)); - styles.push({inverse, styles: parseStyle(style)}); - } else if (close) { - if (styles.length === 0) { - throw new Error('Found extraneous } in Chalk template literal'); - } +const isWindows$1 = process.platform === 'win32'; - chunks.push(buildStyle(chalk, styles)(chunk.join(''))); - chunk = []; - styles.pop(); - } else { - chunk.push(character); - } - }); +const own$e = {}.hasOwnProperty; - chunks.push(chunk.join('')); +const codes = {}; - if (styles.length > 0) { - const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; - throw new Error(errMsg); - } +/** + * @typedef {(...args: unknown[]) => string} MessageFunction + */ - return chunks.join(''); -}; +/** @type {Map} */ +const messages = new Map(); +const nodeInternalPrefix = '__node_internal_'; +/** @type {number} */ +let userStackTraceLimit; -const ansiStyles = ansiStyles$1.exports; -const {stdout: stdoutColor, stderr: stderrColor} = supportsColor_1$1; -const { - stringReplaceAll, - stringEncaseCRLFWithFirstIndex -} = util$2; +codes.ERR_INVALID_MODULE_SPECIFIER = createError( + 'ERR_INVALID_MODULE_SPECIFIER', + /** + * @param {string} request + * @param {string} reason + * @param {string} [base] + */ + (request, reason, base = undefined) => { + return `Invalid module "${request}" ${reason}${ + base ? ` imported from ${base}` : '' + }` + }, + TypeError +); -// `supportsColor.level` → `ansiStyles.color[name]` mapping -const levelMapping = [ - 'ansi', - 'ansi', - 'ansi256', - 'ansi16m' -]; +codes.ERR_INVALID_PACKAGE_CONFIG = createError( + 'ERR_INVALID_PACKAGE_CONFIG', + /** + * @param {string} path + * @param {string} [base] + * @param {string} [message] + */ + (path, base, message) => { + return `Invalid package config ${path}${ + base ? ` while importing ${base}` : '' + }${message ? `. ${message}` : ''}` + }, + Error +); -const styles = Object.create(null); +codes.ERR_INVALID_PACKAGE_TARGET = createError( + 'ERR_INVALID_PACKAGE_TARGET', + /** + * @param {string} pkgPath + * @param {string} key + * @param {unknown} target + * @param {boolean} [isImport=false] + * @param {string} [base] + */ + (pkgPath, key, target, isImport = false, base = undefined) => { + const relError = + typeof target === 'string' && + !isImport && + target.length > 0 && + !target.startsWith('./'); + if (key === '.') { + assert__default['default'](isImport === false); + return ( + `Invalid "exports" main target ${JSON.stringify(target)} defined ` + + `in the package config ${pkgPath}package.json${ + base ? ` imported from ${base}` : '' + }${relError ? '; targets must start with "./"' : ''}` + ) + } -const applyOptions = (object, options = {}) => { - if (options.level > 3 || options.level < 0) { - throw new Error('The `level` option should be an integer from 0 to 3'); - } + return `Invalid "${ + isImport ? 'imports' : 'exports' + }" target ${JSON.stringify( + target + )} defined for '${key}' in the package config ${pkgPath}package.json${ + base ? ` imported from ${base}` : '' + }${relError ? '; targets must start with "./"' : ''}` + }, + Error +); - // Detect level if not set manually - const colorLevel = stdoutColor ? stdoutColor.level : 0; - object.level = options.level === undefined ? colorLevel : options.level; -}; +codes.ERR_MODULE_NOT_FOUND = createError( + 'ERR_MODULE_NOT_FOUND', + /** + * @param {string} path + * @param {string} base + * @param {string} [type] + */ + (path, base, type = 'package') => { + return `Cannot find ${type} '${path}' imported from ${base}` + }, + Error +); -class ChalkClass { - constructor(options) { - return chalkFactory(options); - } -} +codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError( + 'ERR_PACKAGE_IMPORT_NOT_DEFINED', + /** + * @param {string} specifier + * @param {string} packagePath + * @param {string} base + */ + (specifier, packagePath, base) => { + return `Package import specifier "${specifier}" is not defined${ + packagePath ? ` in package ${packagePath}package.json` : '' + } imported from ${base}` + }, + TypeError +); -const chalkFactory = options => { - const chalk = {}; - applyOptions(chalk, options); +codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError( + 'ERR_PACKAGE_PATH_NOT_EXPORTED', + /** + * @param {string} pkgPath + * @param {string} subpath + * @param {string} [base] + */ + (pkgPath, subpath, base = undefined) => { + if (subpath === '.') + return `No "exports" main defined in ${pkgPath}package.json${ + base ? ` imported from ${base}` : '' + }` + return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${ + base ? ` imported from ${base}` : '' + }` + }, + Error +); - chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_); +codes.ERR_UNSUPPORTED_DIR_IMPORT = createError( + 'ERR_UNSUPPORTED_DIR_IMPORT', + "Directory import '%s' is not supported " + + 'resolving ES modules imported from %s', + Error +); - Object.setPrototypeOf(chalk, Chalk.prototype); - Object.setPrototypeOf(chalk.template, chalk); +codes.ERR_UNKNOWN_FILE_EXTENSION = createError( + 'ERR_UNKNOWN_FILE_EXTENSION', + 'Unknown file extension "%s" for %s', + TypeError +); - chalk.template.constructor = () => { - throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.'); - }; +codes.ERR_INVALID_ARG_VALUE = createError( + 'ERR_INVALID_ARG_VALUE', + /** + * @param {string} name + * @param {unknown} value + * @param {string} [reason='is invalid'] + */ + (name, value, reason = 'is invalid') => { + let inspected = require$$0$4.inspect(value); - chalk.template.Instance = ChalkClass; + if (inspected.length > 128) { + inspected = `${inspected.slice(0, 128)}...`; + } - return chalk.template; -}; + const type = name.includes('.') ? 'property' : 'argument'; -function Chalk(options) { - return chalkFactory(options); + return `The ${type} '${name}' ${reason}. Received ${inspected}` + }, + TypeError + // Note: extra classes have been shaken out. + // , RangeError +); + +codes.ERR_UNSUPPORTED_ESM_URL_SCHEME = createError( + 'ERR_UNSUPPORTED_ESM_URL_SCHEME', + /** + * @param {URL} url + */ + (url) => { + let message = + 'Only file and data URLs are supported by the default ESM loader'; + + if (isWindows$1 && url.protocol.length === 2) { + message += '. On Windows, absolute paths must be valid file:// URLs'; + } + + message += `. Received protocol '${url.protocol}'`; + return message + }, + Error +); + +/** + * Utility function for registering the error codes. Only used here. Exported + * *only* to allow for testing. + * @param {string} sym + * @param {MessageFunction|string} value + * @param {ErrorConstructor} def + * @returns {new (...args: unknown[]) => Error} + */ +function createError(sym, value, def) { + // Special case for SystemError that formats the error message differently + // The SystemErrors only have SystemError as their base classes. + messages.set(sym, value); + + return makeNodeErrorWithCode(def, sym) } -for (const [styleName, style] of Object.entries(ansiStyles)) { - styles[styleName] = { - get() { - const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty); - Object.defineProperty(this, styleName, {value: builder}); - return builder; - } - }; +/** + * @param {ErrorConstructor} Base + * @param {string} key + * @returns {ErrorConstructor} + */ +function makeNodeErrorWithCode(Base, key) { + // @ts-expect-error It’s a Node error. + return NodeError + /** + * @param {unknown[]} args + */ + function NodeError(...args) { + const limit = Error.stackTraceLimit; + if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0; + const error = new Base(); + // Reset the limit and setting the name property. + if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit; + const message = getMessage(key, args, error); + Object.defineProperty(error, 'message', { + value: message, + enumerable: false, + writable: true, + configurable: true + }); + Object.defineProperty(error, 'toString', { + /** @this {Error} */ + value() { + return `${this.name} [${key}]: ${this.message}` + }, + enumerable: false, + writable: true, + configurable: true + }); + addCodeToName(error, Base.name, key); + // @ts-expect-error It’s a Node error. + error.code = key; + return error + } } -styles.visible = { - get() { - const builder = createBuilder(this, this._styler, true); - Object.defineProperty(this, 'visible', {value: builder}); - return builder; - } -}; +const addCodeToName = hideStackFrames( + /** + * @param {Error} error + * @param {string} name + * @param {string} code + * @returns {void} + */ + function (error, name, code) { + // Set the stack + error = captureLargerStackTrace(error); + // Add the error code to the name to include it in the stack trace. + error.name = `${name} [${code}]`; + // Access the stack to generate the error message including the error code + // from the name. + error.stack; // eslint-disable-line no-unused-expressions + // Reset the name to the actual name. + if (name === 'SystemError') { + Object.defineProperty(error, 'name', { + value: name, + enumerable: false, + writable: true, + configurable: true + }); + } else { + delete error.name; + } + } +); -const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256']; +/** + * @returns {boolean} + */ +function isErrorStackTraceLimitWritable() { + const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit'); + if (desc === undefined) { + return Object.isExtensible(Error) + } -for (const model of usedModels) { - styles[model] = { - get() { - const {level} = this; - return function (...arguments_) { - const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler); - return createBuilder(this, styler, this._isEmpty); - }; - } - }; + return own$e.call(desc, 'writable') ? desc.writable : desc.set !== undefined } -for (const model of usedModels) { - const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); - styles[bgModel] = { - get() { - const {level} = this; - return function (...arguments_) { - const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler); - return createBuilder(this, styler, this._isEmpty); - }; - } - }; +/** + * This function removes unnecessary frames from Node.js core errors. + * @template {(...args: unknown[]) => unknown} T + * @type {(fn: T) => T} + */ +function hideStackFrames(fn) { + // We rename the functions that will be hidden to cut off the stacktrace + // at the outermost one + const hidden = nodeInternalPrefix + fn.name; + Object.defineProperty(fn, 'name', {value: hidden}); + return fn } -const proto$1 = Object.defineProperties(() => {}, { - ...styles, - level: { - enumerable: true, - get() { - return this._generator.level; - }, - set(level) { - this._generator.level = level; - } - } -}); +const captureLargerStackTrace = hideStackFrames( + /** + * @param {Error} error + * @returns {Error} + */ + function (error) { + const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable(); + if (stackTraceLimitIsWritable) { + userStackTraceLimit = Error.stackTraceLimit; + Error.stackTraceLimit = Number.POSITIVE_INFINITY; + } -const createStyler = (open, close, parent) => { - let openAll; - let closeAll; - if (parent === undefined) { - openAll = open; - closeAll = close; - } else { - openAll = parent.openAll + open; - closeAll = close + parent.closeAll; - } + Error.captureStackTrace(error); - return { - open, - close, - openAll, - closeAll, - parent - }; -}; + // Reset the limit + if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit; -const createBuilder = (self, _styler, _isEmpty) => { - const builder = (...arguments_) => { - // Single argument is hot path, implicit coercion is faster than anything - // eslint-disable-next-line no-implicit-coercion - return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' ')); - }; + return error + } +); - // `__proto__` is used because we must return a function, but there is - // no way to create a function with a different prototype - builder.__proto__ = proto$1; // eslint-disable-line no-proto +/** + * @param {string} key + * @param {unknown[]} args + * @param {Error} self + * @returns {string} + */ +function getMessage(key, args, self) { + const message = messages.get(key); - builder._generator = self; - builder._styler = _styler; - builder._isEmpty = _isEmpty; + if (typeof message === 'function') { + assert__default['default']( + message.length <= args.length, // Default options do not count. + `Code: ${key}; The provided arguments length (${args.length}) does not ` + + `match the required ones (${message.length}).` + ); + return Reflect.apply(message, self, args) + } - return builder; + const expectedLength = (message.match(/%[dfijoOs]/g) || []).length; + assert__default['default']( + expectedLength === args.length, + `Code: ${key}; The provided arguments length (${args.length}) does not ` + + `match the required ones (${expectedLength}).` + ); + if (args.length === 0) return message + + args.unshift(message); + return Reflect.apply(require$$0$4.format, null, args) +} + +// Manually “tree shaken” from: + +const {ERR_UNKNOWN_FILE_EXTENSION} = codes; + +const extensionFormatMap = { + __proto__: null, + '.cjs': 'commonjs', + '.js': 'module', + '.mjs': 'module' }; -const applyStyle = (self, string) => { - if (self.level <= 0 || !string) { - return self._isEmpty ? '' : string; - } - - let styler = self._styler; +/** + * @param {string} url + * @returns {{format: string|null}} + */ +function defaultGetFormat(url$1) { + if (url$1.startsWith('node:')) { + return {format: 'builtin'} + } - if (styler === undefined) { - return string; - } + const parsed = new url.URL(url$1); - const {openAll, closeAll} = styler; - if (string.indexOf('\u001B') !== -1) { - while (styler !== undefined) { - // Replace any instances already present with a re-opening code - // otherwise only the part of the string until said closing code - // will be colored, and the rest will simply be 'plain'. - string = stringReplaceAll(string, styler.close, styler.open); + if (parsed.protocol === 'data:') { + const {1: mime} = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec( + parsed.pathname + ) || [null, null]; + const format = mime === 'text/javascript' ? 'module' : null; + return {format} + } - styler = styler.parent; - } - } + if (parsed.protocol === 'file:') { + const ext = path__default['default'].extname(parsed.pathname); + /** @type {string} */ + let format; + if (ext === '.js') { + format = getPackageType(parsed.href) === 'module' ? 'module' : 'commonjs'; + } else { + format = extensionFormatMap[ext]; + } - // We can move both next actions out of loop, because remaining actions in loop won't have - // any/visible effect on parts we add here. Close the styling before a linebreak and reopen - // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92 - const lfIndex = string.indexOf('\n'); - if (lfIndex !== -1) { - string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); - } + if (!format) { + throw new ERR_UNKNOWN_FILE_EXTENSION(ext, url.fileURLToPath(url$1)) + } - return openAll + string + closeAll; -}; + return {format: format || null} + } -let template; -const chalkTag = (chalk, ...strings) => { - const [firstString] = strings; + return {format: null} +} - if (!Array.isArray(firstString)) { - // If chalk() was called by itself or with a string, - // return the string itself as a string. - return strings.join(' '); - } +// Manually “tree shaken” from: - const arguments_ = strings.slice(1); - const parts = [firstString.raw[0]]; +const listOfBuiltins = builtins(); - for (let i = 1; i < firstString.length; i++) { - parts.push( - String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), - String(firstString.raw[i]) - ); - } +const { + ERR_INVALID_MODULE_SPECIFIER, + ERR_INVALID_PACKAGE_CONFIG, + ERR_INVALID_PACKAGE_TARGET, + ERR_MODULE_NOT_FOUND, + ERR_PACKAGE_IMPORT_NOT_DEFINED, + ERR_PACKAGE_PATH_NOT_EXPORTED, + ERR_UNSUPPORTED_DIR_IMPORT, + ERR_UNSUPPORTED_ESM_URL_SCHEME, + ERR_INVALID_ARG_VALUE +} = codes; + +const own$d = {}.hasOwnProperty; + +const DEFAULT_CONDITIONS = Object.freeze(['node', 'import']); +const DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS); + +const invalidSegmentRegEx = /(^|\\|\/)(\.\.?|node_modules)(\\|\/|$)/; +const patternRegEx = /\*/g; +const encodedSepRegEx = /%2f|%2c/i; +/** @type {Set} */ +const emittedPackageWarnings = new Set(); +/** @type {Map} */ +const packageJsonCache = new Map(); + +/** + * @param {string} match + * @param {URL} pjsonUrl + * @param {boolean} isExports + * @param {URL} base + * @returns {void} + */ +function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) { + const pjsonPath = url.fileURLToPath(pjsonUrl); + + if (emittedPackageWarnings.has(pjsonPath + '|' + match)) return + emittedPackageWarnings.add(pjsonPath + '|' + match); + process.emitWarning( + `Use of deprecated folder mapping "${match}" in the ${ + isExports ? '"exports"' : '"imports"' + } field module resolution of the package at ${pjsonPath}${ + base ? ` imported from ${url.fileURLToPath(base)}` : '' + }.\n` + + `Update this package.json to use a subpath pattern like "${match}*".`, + 'DeprecationWarning', + 'DEP0148' + ); +} - if (template === undefined) { - template = templates; - } +/** + * @param {URL} url + * @param {URL} packageJsonUrl + * @param {URL} base + * @param {unknown} [main] + * @returns {void} + */ +function emitLegacyIndexDeprecation(url$1, packageJsonUrl, base, main) { + const {format} = defaultGetFormat(url$1.href); + if (format !== 'module') return + const path = url.fileURLToPath(url$1.href); + const pkgPath = url.fileURLToPath(new url.URL('.', packageJsonUrl)); + const basePath = url.fileURLToPath(base); + if (main) + process.emitWarning( + `Package ${pkgPath} has a "main" field set to ${JSON.stringify(main)}, ` + + `excluding the full filename and extension to the resolved file at "${path.slice( + pkgPath.length + )}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is` + + 'deprecated for ES modules.', + 'DeprecationWarning', + 'DEP0151' + ); + else + process.emitWarning( + `No "main" or "exports" field defined in the package.json for ${pkgPath} resolving the main entry point "${path.slice( + pkgPath.length + )}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, + 'DeprecationWarning', + 'DEP0151' + ); +} - return template(chalk, parts.join('')); -}; +/** + * @param {string[]} [conditions] + * @returns {Set} + */ +function getConditionsSet(conditions) { + if (conditions !== undefined && conditions !== DEFAULT_CONDITIONS) { + if (!Array.isArray(conditions)) { + throw new ERR_INVALID_ARG_VALUE( + 'conditions', + conditions, + 'expected an array' + ) + } -Object.defineProperties(Chalk.prototype, styles); + return new Set(conditions) + } -const chalk$1 = Chalk(); // eslint-disable-line new-cap -chalk$1.supportsColor = stdoutColor; -chalk$1.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap -chalk$1.stderr.supportsColor = stderrColor; + return DEFAULT_CONDITIONS_SET +} -// For TypeScript -chalk$1.Level = { - None: 0, - Basic: 1, - Ansi256: 2, - TrueColor: 3, - 0: 'None', - 1: 'Basic', - 2: 'Ansi256', - 3: 'TrueColor' -}; +/** + * @param {string} path + * @returns {Stats} + */ +function tryStatSync(path) { + // Note: from Node 15 onwards we can use `throwIfNoEntry: false` instead. + try { + return require$$0$3.statSync(path) + } catch { + return new require$$0$3.Stats() + } +} -var source$1 = chalk$1; +/** + * @param {string} path + * @param {string|URL} specifier Note: `specifier` is actually optional, not base. + * @param {URL} [base] + * @returns {PackageConfig} + */ +function getPackageConfig(path, specifier, base) { + const existing = packageJsonCache.get(path); + if (existing !== undefined) { + return existing + } + + const source = packageJsonReader.read(path).string; + + if (source === undefined) { + /** @type {PackageConfig} */ + const packageConfig = { + pjsonPath: path, + exists: false, + main: undefined, + name: undefined, + type: 'none', + exports: undefined, + imports: undefined + }; + packageJsonCache.set(path, packageConfig); + return packageConfig + } -var chokidar$1 = {}; + /** @type {Object.} */ + let packageJson; + try { + packageJson = JSON.parse(source); + } catch (error) { + throw new ERR_INVALID_PACKAGE_CONFIG( + path, + (base ? `"${specifier}" from ` : '') + url.fileURLToPath(base || specifier), + error.message + ) + } -var utils$7 = {}; + const {exports, imports, main, name, type} = packageJson; -const path$3 = require$$0__default$2['default']; -const WIN_SLASH = '\\\\/'; -const WIN_NO_SLASH = `[^${WIN_SLASH}]`; + /** @type {PackageConfig} */ + const packageConfig = { + pjsonPath: path, + exists: true, + main: typeof main === 'string' ? main : undefined, + name: typeof name === 'string' ? name : undefined, + type: type === 'module' || type === 'commonjs' ? type : 'none', + // @ts-expect-error Assume `Object.`. + exports, + // @ts-expect-error Assume `Object.`. + imports: imports && typeof imports === 'object' ? imports : undefined + }; + packageJsonCache.set(path, packageConfig); + return packageConfig +} /** - * Posix glob regex + * @param {URL|string} resolved + * @returns {PackageConfig} */ +function getPackageScopeConfig(resolved) { + let packageJsonUrl = new url.URL('./package.json', resolved); -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 NO_DOT = `(?!${DOT_LITERAL})`; -const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`; -const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`; -const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`; -const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`; -const STAR$1 = `${QMARK}*?`; + while (true) { + const packageJsonPath = packageJsonUrl.pathname; -const POSIX_CHARS = { - DOT_LITERAL, - PLUS_LITERAL, - QMARK_LITERAL, - SLASH_LITERAL, - ONE_CHAR, - QMARK, - END_ANCHOR, - DOTS_SLASH, - NO_DOT, - NO_DOTS, - NO_DOT_SLASH, - NO_DOTS_SLASH, - QMARK_NO_DOT, - STAR: STAR$1, - START_ANCHOR -}; + if (packageJsonPath.endsWith('node_modules/package.json')) break + + const packageConfig = getPackageConfig( + url.fileURLToPath(packageJsonUrl), + resolved + ); + if (packageConfig.exists) return packageConfig + + const lastPackageJsonUrl = packageJsonUrl; + packageJsonUrl = new url.URL('../package.json', packageJsonUrl); + + // Terminates at root where ../package.json equals ../../package.json + // (can't just check "/package.json" for Windows support). + if (packageJsonUrl.pathname === lastPackageJsonUrl.pathname) break + } + + const packageJsonPath = url.fileURLToPath(packageJsonUrl); + /** @type {PackageConfig} */ + const packageConfig = { + pjsonPath: packageJsonPath, + exists: false, + main: undefined, + name: undefined, + type: 'none', + exports: undefined, + imports: undefined + }; + packageJsonCache.set(packageJsonPath, packageConfig); + return packageConfig +} /** - * Windows glob regex + * Legacy CommonJS main resolution: + * 1. let M = pkg_url + (json main field) + * 2. TRY(M, M.js, M.json, M.node) + * 3. TRY(M/index.js, M/index.json, M/index.node) + * 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node) + * 5. NOT_FOUND + * + * @param {URL} url + * @returns {boolean} */ +function fileExists(url$1) { + return tryStatSync(url.fileURLToPath(url$1)).isFile() +} + +/** + * @param {URL} packageJsonUrl + * @param {PackageConfig} packageConfig + * @param {URL} base + * @returns {URL} + */ +function legacyMainResolve(packageJsonUrl, packageConfig, base) { + /** @type {URL} */ + let guess; + if (packageConfig.main !== undefined) { + guess = new url.URL(`./${packageConfig.main}`, packageJsonUrl); + // Note: fs check redundances will be handled by Descriptor cache here. + if (fileExists(guess)) return guess + + const tries = [ + `./${packageConfig.main}.js`, + `./${packageConfig.main}.json`, + `./${packageConfig.main}.node`, + `./${packageConfig.main}/index.js`, + `./${packageConfig.main}/index.json`, + `./${packageConfig.main}/index.node` + ]; + let i = -1; + + while (++i < tries.length) { + guess = new url.URL(tries[i], packageJsonUrl); + if (fileExists(guess)) break + guess = undefined; + } + + if (guess) { + emitLegacyIndexDeprecation( + guess, + packageJsonUrl, + base, + packageConfig.main + ); + return guess + } + // Fallthrough. + } -const WINDOWS_CHARS = { - ...POSIX_CHARS, + const tries = ['./index.js', './index.json', './index.node']; + let i = -1; - 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}]|$)` -}; + while (++i < tries.length) { + guess = new url.URL(tries[i], packageJsonUrl); + if (fileExists(guess)) break + guess = undefined; + } + + if (guess) { + emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main); + return guess + } + + // Not found. + throw new ERR_MODULE_NOT_FOUND( + url.fileURLToPath(new url.URL('.', packageJsonUrl)), + url.fileURLToPath(base) + ) +} /** - * POSIX Bracket Regex + * @param {URL} resolved + * @param {URL} base + * @returns {URL} */ +function finalizeResolution(resolved, base) { + if (encodedSepRegEx.test(resolved.pathname)) + throw new ERR_INVALID_MODULE_SPECIFIER( + resolved.pathname, + 'must not include encoded "/" or "\\" characters', + url.fileURLToPath(base) + ) -const POSIX_REGEX_SOURCE$1 = { - 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' -}; + const path = url.fileURLToPath(resolved); -var constants$5 = { - MAX_LENGTH: 1024 * 64, - POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1, + const stats = tryStatSync(path.endsWith('/') ? path.slice(-1) : path); - // regular expressions - 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, + if (stats.isDirectory()) { + const error = new ERR_UNSUPPORTED_DIR_IMPORT(path, url.fileURLToPath(base)); + // @ts-expect-error Add this for `import.meta.resolve`. + error.url = String(resolved); + throw error + } - // Replace globs with equivalent patterns to reduce parsing time. - REPLACEMENTS: { - '***': '*', - '**/**': '**', - '**/**/**': '**' - }, + if (!stats.isFile()) { + throw new ERR_MODULE_NOT_FOUND( + path || resolved.pathname, + base && url.fileURLToPath(base), + 'module' + ) + } - // Digits - CHAR_0: 48, /* 0 */ - CHAR_9: 57, /* 9 */ + return resolved +} - // Alphabet chars. - CHAR_UPPERCASE_A: 65, /* A */ - CHAR_LOWERCASE_A: 97, /* a */ - CHAR_UPPERCASE_Z: 90, /* Z */ - CHAR_LOWERCASE_Z: 122, /* z */ +/** + * @param {string} specifier + * @param {URL?} packageJsonUrl + * @param {URL} base + * @returns {never} + */ +function throwImportNotDefined(specifier, packageJsonUrl, base) { + throw new ERR_PACKAGE_IMPORT_NOT_DEFINED( + specifier, + packageJsonUrl && url.fileURLToPath(new url.URL('.', packageJsonUrl)), + url.fileURLToPath(base) + ) +} - CHAR_LEFT_PARENTHESES: 40, /* ( */ - CHAR_RIGHT_PARENTHESES: 41, /* ) */ +/** + * @param {string} subpath + * @param {URL} packageJsonUrl + * @param {URL} base + * @returns {never} + */ +function throwExportsNotFound(subpath, packageJsonUrl, base) { + throw new ERR_PACKAGE_PATH_NOT_EXPORTED( + url.fileURLToPath(new url.URL('.', packageJsonUrl)), + subpath, + base && url.fileURLToPath(base) + ) +} - CHAR_ASTERISK: 42, /* * */ +/** + * @param {string} subpath + * @param {URL} packageJsonUrl + * @param {boolean} internal + * @param {URL} [base] + * @returns {never} + */ +function throwInvalidSubpath(subpath, packageJsonUrl, internal, base) { + const reason = `request is not a valid subpath for the "${ + internal ? 'imports' : 'exports' + }" resolution of ${url.fileURLToPath(packageJsonUrl)}`; - // Non-alphabetic chars. - CHAR_AMPERSAND: 38, /* & */ - CHAR_AT: 64, /* @ */ - CHAR_BACKWARD_SLASH: 92, /* \ */ - CHAR_CARRIAGE_RETURN: 13, /* \r */ - 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, /* \f */ - 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, /* \n */ - CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */ - 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, /* \t */ - CHAR_UNDERSCORE: 95, /* _ */ - CHAR_VERTICAL_LINE: 124, /* | */ - CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */ + throw new ERR_INVALID_MODULE_SPECIFIER( + subpath, + reason, + base && url.fileURLToPath(base) + ) +} - SEP: path$3.sep, +/** + * @param {string} subpath + * @param {unknown} target + * @param {URL} packageJsonUrl + * @param {boolean} internal + * @param {URL} [base] + * @returns {never} + */ +function throwInvalidPackageTarget( + subpath, + target, + packageJsonUrl, + internal, + base +) { + target = + typeof target === 'object' && target !== null + ? JSON.stringify(target, null, '') + : `${target}`; + + throw new ERR_INVALID_PACKAGE_TARGET( + url.fileURLToPath(new url.URL('.', packageJsonUrl)), + subpath, + target, + internal, + base && url.fileURLToPath(base) + ) +} - /** - * Create EXTGLOB_CHARS - */ +/** + * @param {string} target + * @param {string} subpath + * @param {string} match + * @param {URL} packageJsonUrl + * @param {URL} base + * @param {boolean} pattern + * @param {boolean} internal + * @param {Set} conditions + * @returns {URL} + */ +function resolvePackageTargetString( + target, + subpath, + match, + packageJsonUrl, + base, + pattern, + internal, + conditions +) { + if (subpath !== '' && !pattern && target[target.length - 1] !== '/') + throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base); - 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: ')' } - }; - }, + if (!target.startsWith('./')) { + if (internal && !target.startsWith('../') && !target.startsWith('/')) { + let isURL = false; - /** - * Create GLOB_CHARS - */ + try { + new url.URL(target); + isURL = true; + } catch {} - globChars(win32) { - return win32 === true ? WINDOWS_CHARS : POSIX_CHARS; + if (!isURL) { + const exportTarget = pattern + ? target.replace(patternRegEx, subpath) + : target + subpath; + + return packageResolve(exportTarget, packageJsonUrl, conditions) + } + } + + throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base); } -}; -(function (exports) { + if (invalidSegmentRegEx.test(target.slice(2))) + throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base); -const path = require$$0__default$2['default']; -const win32 = process.platform === 'win32'; -const { - REGEX_BACKSLASH, - REGEX_REMOVE_BACKSLASH, - REGEX_SPECIAL_CHARS, - REGEX_SPECIAL_CHARS_GLOBAL -} = constants$5; + const resolved = new url.URL(target, packageJsonUrl); + const resolvedPath = resolved.pathname; + const packagePath = new url.URL('.', packageJsonUrl).pathname; -exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); -exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str); -exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str); -exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1'); -exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/'); + if (!resolvedPath.startsWith(packagePath)) + throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base); -exports.removeBackslashes = str => { - return str.replace(REGEX_REMOVE_BACKSLASH, match => { - return match === '\\' ? '' : match; - }); -}; + if (subpath === '') return resolved -exports.supportsLookbehinds = () => { - const segs = process.version.slice(1).split('.').map(Number); - if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) { - return true; - } - return false; -}; + if (invalidSegmentRegEx.test(subpath)) + throwInvalidSubpath(match + subpath, packageJsonUrl, internal, base); -exports.isWindows = options => { - if (options && typeof options.windows === 'boolean') { - return options.windows; + if (pattern) return new url.URL(resolved.href.replace(patternRegEx, subpath)) + return new url.URL(subpath, resolved) +} + +/** + * @param {string} key + * @returns {boolean} + */ +function isArrayIndex(key) { + const keyNumber = Number(key); + if (`${keyNumber}` !== key) return false + return keyNumber >= 0 && keyNumber < 0xffff_ffff +} + +/** + * @param {URL} packageJsonUrl + * @param {unknown} target + * @param {string} subpath + * @param {string} packageSubpath + * @param {URL} base + * @param {boolean} pattern + * @param {boolean} internal + * @param {Set} conditions + * @returns {URL} + */ +function resolvePackageTarget( + packageJsonUrl, + target, + subpath, + packageSubpath, + base, + pattern, + internal, + conditions +) { + if (typeof target === 'string') { + return resolvePackageTargetString( + target, + subpath, + packageSubpath, + packageJsonUrl, + base, + pattern, + internal, + conditions + ) } - return win32 === true || path.sep === '\\'; -}; -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)}`; -}; + if (Array.isArray(target)) { + /** @type {unknown[]} */ + const targetList = target; + if (targetList.length === 0) return null -exports.removePrefix = (input, state = {}) => { - let output = input; - if (output.startsWith('./')) { - output = output.slice(2); - state.prefix = './'; - } - return output; -}; + /** @type {Error} */ + let lastException; + let i = -1; -exports.wrapOutput = (input, state = {}, options = {}) => { - const prepend = options.contains ? '' : '^'; - const append = options.contains ? '' : '$'; + while (++i < targetList.length) { + const targetItem = targetList[i]; + /** @type {URL} */ + let resolved; + try { + resolved = resolvePackageTarget( + packageJsonUrl, + targetItem, + subpath, + packageSubpath, + base, + pattern, + internal, + conditions + ); + } catch (error) { + lastException = error; + if (error.code === 'ERR_INVALID_PACKAGE_TARGET') continue + throw error + } - let output = `${prepend}(?:${input})${append}`; - if (state.negated === true) { - output = `(?:^(?!${output}).*$)`; - } - return output; -}; -}(utils$7)); + if (resolved === undefined) continue -const utils$6 = utils$7; -const { - CHAR_ASTERISK: CHAR_ASTERISK$1, /* * */ - CHAR_AT, /* @ */ - CHAR_BACKWARD_SLASH, /* \ */ - CHAR_COMMA: CHAR_COMMA$2, /* , */ - CHAR_DOT: CHAR_DOT$1, /* . */ - CHAR_EXCLAMATION_MARK, /* ! */ - CHAR_FORWARD_SLASH, /* / */ - CHAR_LEFT_CURLY_BRACE: CHAR_LEFT_CURLY_BRACE$1, /* { */ - CHAR_LEFT_PARENTHESES: CHAR_LEFT_PARENTHESES$1, /* ( */ - CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$2, /* [ */ - CHAR_PLUS, /* + */ - CHAR_QUESTION_MARK, /* ? */ - CHAR_RIGHT_CURLY_BRACE: CHAR_RIGHT_CURLY_BRACE$1, /* } */ - CHAR_RIGHT_PARENTHESES: CHAR_RIGHT_PARENTHESES$1, /* ) */ - CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$2 /* ] */ -} = constants$5; + if (resolved === null) { + lastException = null; + continue + } -const isPathSeparator = code => { - return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH; -}; + return resolved + } -const depth = token => { - if (token.isPrefix !== true) { - token.depth = token.isGlobstar ? Infinity : 1; + if (lastException === undefined || lastException === null) { + // @ts-expect-error The diff between `undefined` and `null` seems to be + // intentional + return lastException + } + + throw lastException } -}; -/** - * 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 - */ + if (typeof target === 'object' && target !== null) { + const keys = Object.getOwnPropertyNames(target); + let i = -1; -const scan$1 = (input, options) => { - const opts = options || {}; + while (++i < keys.length) { + const key = keys[i]; + if (isArrayIndex(key)) { + throw new ERR_INVALID_PACKAGE_CONFIG( + url.fileURLToPath(packageJsonUrl), + base, + '"exports" cannot contain numeric property keys.' + ) + } + } - const length = input.length - 1; - const scanToEnd = opts.parts === true || opts.scanToEnd === true; - const slashes = []; - const tokens = []; - const parts = []; + i = -1; - let str = input; - let index = -1; - let start = 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 }; + while (++i < keys.length) { + const key = keys[i]; + if (key === 'default' || (conditions && conditions.has(key))) { + /** @type {unknown} */ + const conditionalTarget = target[key]; + const resolved = resolvePackageTarget( + packageJsonUrl, + conditionalTarget, + subpath, + packageSubpath, + base, + pattern, + internal, + conditions + ); + if (resolved === undefined) continue + return resolved + } + } - const eos = () => index >= length; - const peek = () => str.charCodeAt(index + 1); - const advance = () => { - prev = code; - return str.charCodeAt(++index); - }; + return undefined + } - while (index < length) { - code = advance(); - let next; + if (target === null) { + return null + } - if (code === CHAR_BACKWARD_SLASH) { - backslashes = token.backslashes = true; - code = advance(); + throwInvalidPackageTarget( + packageSubpath, + target, + packageJsonUrl, + internal, + base + ); +} - if (code === CHAR_LEFT_CURLY_BRACE$1) { - braceEscaped = true; - } - continue; +/** + * @param {unknown} exports + * @param {URL} packageJsonUrl + * @param {URL} base + * @returns {boolean} + */ +function isConditionalExportsMainSugar(exports, packageJsonUrl, base) { + if (typeof exports === 'string' || Array.isArray(exports)) return true + if (typeof exports !== 'object' || exports === null) return false + + const keys = Object.getOwnPropertyNames(exports); + let isConditionalSugar = false; + let i = 0; + let j = -1; + while (++j < keys.length) { + const key = keys[j]; + const curIsConditionalSugar = key === '' || key[0] !== '.'; + if (i++ === 0) { + isConditionalSugar = curIsConditionalSugar; + } else if (isConditionalSugar !== curIsConditionalSugar) { + throw new ERR_INVALID_PACKAGE_CONFIG( + url.fileURLToPath(packageJsonUrl), + base, + '"exports" cannot contain some keys starting with \'.\' and some not.' + + ' The exports object must either be an object of package subpath keys' + + ' or an object of main entry condition name keys only.' + ) } + } - if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE$1) { - braces++; + return isConditionalSugar +} - while (eos() !== true && (code = advance())) { - if (code === CHAR_BACKWARD_SLASH) { - backslashes = token.backslashes = true; - advance(); - continue; - } +/** + * @param {URL} packageJsonUrl + * @param {string} packageSubpath + * @param {Object.} packageConfig + * @param {URL} base + * @param {Set} conditions + * @returns {ResolveObject} + */ +function packageExportsResolve( + packageJsonUrl, + packageSubpath, + packageConfig, + base, + conditions +) { + let exports = packageConfig.exports; + if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) + exports = {'.': exports}; + + if (own$d.call(exports, packageSubpath)) { + const target = exports[packageSubpath]; + const resolved = resolvePackageTarget( + packageJsonUrl, + target, + '', + packageSubpath, + base, + false, + false, + conditions + ); + if (resolved === null || resolved === undefined) + throwExportsNotFound(packageSubpath, packageJsonUrl, base); + return {resolved, exact: true} + } - if (code === CHAR_LEFT_CURLY_BRACE$1) { - braces++; - continue; - } + let bestMatch = ''; + const keys = Object.getOwnPropertyNames(exports); + let i = -1; - if (braceEscaped !== true && code === CHAR_DOT$1 && (code = advance()) === CHAR_DOT$1) { - isBrace = token.isBrace = true; - isGlob = token.isGlob = true; - finished = true; + while (++i < keys.length) { + const key = keys[i]; + if ( + key[key.length - 1] === '*' && + packageSubpath.startsWith(key.slice(0, -1)) && + packageSubpath.length >= key.length && + key.length > bestMatch.length + ) { + bestMatch = key; + } else if ( + key[key.length - 1] === '/' && + packageSubpath.startsWith(key) && + key.length > bestMatch.length + ) { + bestMatch = key; + } + } + + if (bestMatch) { + const target = exports[bestMatch]; + const pattern = bestMatch[bestMatch.length - 1] === '*'; + const subpath = packageSubpath.slice(bestMatch.length - (pattern ? 1 : 0)); + const resolved = resolvePackageTarget( + packageJsonUrl, + target, + subpath, + bestMatch, + base, + pattern, + false, + conditions + ); + if (resolved === null || resolved === undefined) + throwExportsNotFound(packageSubpath, packageJsonUrl, base); + if (!pattern) + emitFolderMapDeprecation(bestMatch, packageJsonUrl, true, base); + return {resolved, exact: pattern} + } - if (scanToEnd === true) { - continue; - } + throwExportsNotFound(packageSubpath, packageJsonUrl, base); +} - break; - } +/** + * @param {string} name + * @param {URL} base + * @param {Set} [conditions] + * @returns {ResolveObject} + */ +function packageImportsResolve(name, base, conditions) { + if (name === '#' || name.startsWith('#/')) { + const reason = 'is not a valid internal imports specifier name'; + throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, url.fileURLToPath(base)) + } + + /** @type {URL} */ + let packageJsonUrl; + + const packageConfig = getPackageScopeConfig(base); + + if (packageConfig.exists) { + packageJsonUrl = url.pathToFileURL(packageConfig.pjsonPath); + const imports = packageConfig.imports; + if (imports) { + if (own$d.call(imports, name)) { + const resolved = resolvePackageTarget( + packageJsonUrl, + imports[name], + '', + name, + base, + false, + true, + conditions + ); + if (resolved !== null) return {resolved, exact: true} + } else { + let bestMatch = ''; + const keys = Object.getOwnPropertyNames(imports); + let i = -1; - if (braceEscaped !== true && code === CHAR_COMMA$2) { - isBrace = token.isBrace = true; - isGlob = token.isGlob = true; - finished = true; + while (++i < keys.length) { + const key = keys[i]; - if (scanToEnd === true) { - continue; + if ( + key[key.length - 1] === '*' && + name.startsWith(key.slice(0, -1)) && + name.length >= key.length && + key.length > bestMatch.length + ) { + bestMatch = key; + } else if ( + key[key.length - 1] === '/' && + name.startsWith(key) && + key.length > bestMatch.length + ) { + bestMatch = key; } - - break; } - if (code === CHAR_RIGHT_CURLY_BRACE$1) { - braces--; - - if (braces === 0) { - braceEscaped = false; - isBrace = token.isBrace = true; - finished = true; - break; + if (bestMatch) { + const target = imports[bestMatch]; + const pattern = bestMatch[bestMatch.length - 1] === '*'; + const subpath = name.slice(bestMatch.length - (pattern ? 1 : 0)); + const resolved = resolvePackageTarget( + packageJsonUrl, + target, + subpath, + bestMatch, + base, + pattern, + true, + conditions + ); + if (resolved !== null) { + if (!pattern) + emitFolderMapDeprecation(bestMatch, packageJsonUrl, false, base); + return {resolved, exact: pattern} } } } - - if (scanToEnd === true) { - continue; - } - - break; } + } - if (code === CHAR_FORWARD_SLASH) { - slashes.push(index); - tokens.push(token); - token = { value: '', depth: 0, isGlob: false }; + throwImportNotDefined(name, packageJsonUrl, base); +} - if (finished === true) continue; - if (prev === CHAR_DOT$1 && index === (start + 1)) { - start += 2; - continue; - } +/** + * @param {string} url + * @returns {PackageType} + */ +function getPackageType(url) { + const packageConfig = getPackageScopeConfig(url); + return packageConfig.type +} - lastIndex = index + 1; - continue; +/** + * @param {string} specifier + * @param {URL} base + */ +function parsePackageName(specifier, base) { + let separatorIndex = specifier.indexOf('/'); + let validPackageName = true; + let isScoped = false; + if (specifier[0] === '@') { + isScoped = true; + if (separatorIndex === -1 || specifier.length === 0) { + validPackageName = false; + } else { + separatorIndex = specifier.indexOf('/', separatorIndex + 1); } + } - if (opts.noext !== true) { - const isExtglobChar = code === CHAR_PLUS - || code === CHAR_AT - || code === CHAR_ASTERISK$1 - || code === CHAR_QUESTION_MARK - || code === CHAR_EXCLAMATION_MARK; + const packageName = + separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex); - if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES$1) { - isGlob = token.isGlob = true; - isExtglob = token.isExtglob = true; - finished = true; - if (code === CHAR_EXCLAMATION_MARK && index === start) { - negatedExtglob = true; - } + // Package name cannot have leading . and cannot have percent-encoding or + // separators. + let i = -1; + while (++i < packageName.length) { + if (packageName[i] === '%' || packageName[i] === '\\') { + validPackageName = false; + break + } + } - if (scanToEnd === true) { - while (eos() !== true && (code = advance())) { - if (code === CHAR_BACKWARD_SLASH) { - backslashes = token.backslashes = true; - code = advance(); - continue; - } + if (!validPackageName) { + throw new ERR_INVALID_MODULE_SPECIFIER( + specifier, + 'is not a valid package name', + url.fileURLToPath(base) + ) + } - if (code === CHAR_RIGHT_PARENTHESES$1) { - isGlob = token.isGlob = true; - finished = true; - break; - } - } - continue; - } - break; - } - } + const packageSubpath = + '.' + (separatorIndex === -1 ? '' : specifier.slice(separatorIndex)); - if (code === CHAR_ASTERISK$1) { - if (prev === CHAR_ASTERISK$1) isGlobstar = token.isGlobstar = true; - isGlob = token.isGlob = true; - finished = true; + return {packageName, packageSubpath, isScoped} +} - if (scanToEnd === true) { - continue; - } - break; - } +/** + * @param {string} specifier + * @param {URL} base + * @param {Set} conditions + * @returns {URL} + */ +function packageResolve(specifier, base, conditions) { + const {packageName, packageSubpath, isScoped} = parsePackageName( + specifier, + base + ); - if (code === CHAR_QUESTION_MARK) { - isGlob = token.isGlob = true; - finished = true; + // ResolveSelf + const packageConfig = getPackageScopeConfig(base); - if (scanToEnd === true) { - continue; - } - break; + // Can’t test. + /* c8 ignore next 16 */ + if (packageConfig.exists) { + const packageJsonUrl = url.pathToFileURL(packageConfig.pjsonPath); + if ( + packageConfig.name === packageName && + packageConfig.exports !== undefined && + packageConfig.exports !== null + ) { + return packageExportsResolve( + packageJsonUrl, + packageSubpath, + packageConfig, + base, + conditions + ).resolved } + } - if (code === CHAR_LEFT_SQUARE_BRACKET$2) { - while (eos() !== true && (next = advance())) { - if (next === CHAR_BACKWARD_SLASH) { - backslashes = token.backslashes = true; - advance(); - continue; - } + let packageJsonUrl = new url.URL( + './node_modules/' + packageName + '/package.json', + base + ); + let packageJsonPath = url.fileURLToPath(packageJsonUrl); + /** @type {string} */ + let lastPath; + do { + const stat = tryStatSync(packageJsonPath.slice(0, -13)); + if (!stat.isDirectory()) { + lastPath = packageJsonPath; + packageJsonUrl = new url.URL( + (isScoped ? '../../../../node_modules/' : '../../../node_modules/') + + packageName + + '/package.json', + packageJsonUrl + ); + packageJsonPath = url.fileURLToPath(packageJsonUrl); + continue + } - if (next === CHAR_RIGHT_SQUARE_BRACKET$2) { - isBracket = token.isBracket = true; - isGlob = token.isGlob = true; - finished = true; - break; - } - } + // Package match. + const packageConfig = getPackageConfig(packageJsonPath, specifier, base); + if (packageConfig.exports !== undefined && packageConfig.exports !== null) + return packageExportsResolve( + packageJsonUrl, + packageSubpath, + packageConfig, + base, + conditions + ).resolved + if (packageSubpath === '.') + return legacyMainResolve(packageJsonUrl, packageConfig, base) + return new url.URL(packageSubpath, packageJsonUrl) + // Cross-platform root check. + } while (packageJsonPath.length !== lastPath.length) - if (scanToEnd === true) { - continue; - } + throw new ERR_MODULE_NOT_FOUND(packageName, url.fileURLToPath(base)) +} - break; +/** + * @param {string} specifier + * @returns {boolean} + */ +function isRelativeSpecifier(specifier) { + if (specifier[0] === '.') { + if (specifier.length === 1 || specifier[1] === '/') return true + if ( + specifier[1] === '.' && + (specifier.length === 2 || specifier[2] === '/') + ) { + return true } + } - if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) { - negated = token.negated = true; - start++; - continue; - } + return false +} - if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES$1) { - isGlob = token.isGlob = true; +/** + * @param {string} specifier + * @returns {boolean} + */ +function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) { + if (specifier === '') return false + if (specifier[0] === '/') return true + return isRelativeSpecifier(specifier) +} - if (scanToEnd === true) { - while (eos() !== true && (code = advance())) { - if (code === CHAR_LEFT_PARENTHESES$1) { - backslashes = token.backslashes = true; - code = advance(); - continue; - } +/** + * The “Resolver Algorithm Specification” as detailed in the Node docs (which is + * sync and slightly lower-level than `resolve`). + * + * + * + * @param {string} specifier + * @param {URL} base + * @param {Set} [conditions] + * @returns {URL} + */ +function moduleResolve(specifier, base, conditions) { + // Order swapped from spec for minor perf gain. + // Ok since relative URLs cannot parse as URLs. + /** @type {URL} */ + let resolved; - if (code === CHAR_RIGHT_PARENTHESES$1) { - finished = true; - break; - } - } - continue; - } - break; + if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) { + resolved = new url.URL(specifier, base); + } else if (specifier[0] === '#') { +({resolved} = packageImportsResolve(specifier, base, conditions)); + } else { + try { + resolved = new url.URL(specifier); + } catch { + resolved = packageResolve(specifier, base, conditions); } + } - if (isGlob === true) { - finished = true; + return finalizeResolution(resolved, base) +} - if (scanToEnd === true) { - continue; - } +/** + * @param {string} specifier + * @param {{parentURL?: string, conditions?: string[]}} context + * @returns {{url: string}} + */ +function defaultResolve(specifier, context = {}) { + const {parentURL} = context; + /** @type {URL} */ + let parsed; - break; + try { + parsed = new url.URL(specifier); + if (parsed.protocol === 'data:') { + return {url: specifier} } + } catch {} + + if (parsed && parsed.protocol === 'node:') return {url: specifier} + if (parsed && parsed.protocol !== 'file:' && parsed.protocol !== 'data:') + throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed) + + if (listOfBuiltins.includes(specifier)) { + return {url: 'node:' + specifier} } - if (opts.noext === true) { - isExtglob = false; - isGlob = false; + if (parentURL.startsWith('data:')) { + // This is gonna blow up, we want the error + new url.URL(specifier, parentURL); } - let base = str; - let prefix = ''; - let glob = ''; + const conditions = getConditionsSet(context.conditions); + let url$1 = moduleResolve(specifier, new url.URL(parentURL), conditions); - if (start > 0) { - prefix = str.slice(0, start); - str = str.slice(start); - lastIndex -= start; - } + const urlPath = url.fileURLToPath(url$1); + const real = require$$0$3.realpathSync(urlPath); + const old = url$1; + url$1 = url.pathToFileURL(real + (urlPath.endsWith(path__default['default'].sep) ? '/' : '')); + url$1.search = old.search; + url$1.hash = old.hash; - if (base && isGlob === true && lastIndex > 0) { - base = str.slice(0, lastIndex); - glob = str.slice(lastIndex); - } else if (isGlob === true) { - base = ''; - glob = str; - } else { - base = str; + return {url: `${url$1}`} +} + +/** + * Provides a module-relative resolution function scoped to each module, + * returning the URL string. + * `import.meta.resolve` also accepts a second argument which is the parent + * module from which to resolve from. + * + * This function is asynchronous because the ES module resolver in Node.js is + * allowed to be asynchronous. + * + * @param {string} specifier The module specifier to resolve relative to parent. + * @param {string} parent The absolute parent module URL to resolve from. + * You should pass `import.meta.url` or something else + * @returns {Promise} + */ +async function resolve(specifier, parent) { + if (!parent) { + throw new Error( + 'Please pass `parent`: `import-meta-resolve` cannot ponyfill that' + ) } - if (base && base !== '' && base !== '/' && base !== str) { - if (isPathSeparator(base.charCodeAt(base.length - 1))) { - base = base.slice(0, -1); - } + try { + return defaultResolve(specifier, {parentURL: parent}).url + } catch (error) { + return error.code === 'ERR_UNSUPPORTED_DIR_IMPORT' + ? error.url + : Promise.reject(error) } +} - if (opts.unescape === true) { - if (glob) glob = utils$6.removeBackslashes(glob); +var libnpmconfig = {}; - if (base && backslashes === true) { - base = utils$6.removeBackslashes(base); +class FiggyPudding { + constructor (specs, opts, providers) { + this.__specs = specs || {}; + Object.keys(this.__specs).forEach(alias => { + if (typeof this.__specs[alias] === 'string') { + const key = this.__specs[alias]; + const realSpec = this.__specs[key]; + if (realSpec) { + const aliasArr = realSpec.aliases || []; + aliasArr.push(alias, key); + realSpec.aliases = [...(new Set(aliasArr))]; + this.__specs[alias] = realSpec; + } else { + throw new Error(`Alias refers to invalid key: ${key} -> ${alias}`) + } + } + }); + this.__opts = opts || {}; + this.__providers = reverse((providers).filter( + x => x != null && typeof x === 'object' + )); + this.__isFiggyPudding = true; + } + get (key) { + return pudGet(this, key, true) + } + get [Symbol.toStringTag] () { return 'FiggyPudding' } + forEach (fn, thisArg = this) { + for (let [key, value] of this.entries()) { + fn.call(thisArg, value, key, this); } } - - const state = { - prefix, - input, - start, - base, - glob, - isBrace, - isBracket, - isGlob, - isExtglob, - isGlobstar, - negated, - negatedExtglob - }; - - if (opts.tokens === true) { - state.maxDepth = 0; - if (!isPathSeparator(code)) { - tokens.push(token); + toJSON () { + const obj = {}; + this.forEach((val, key) => { + obj[key] = val; + }); + return obj + } + * entries (_matcher) { + for (let key of Object.keys(this.__specs)) { + yield [key, this.get(key)]; + } + const matcher = _matcher || this.__opts.other; + if (matcher) { + const seen = new Set(); + for (let p of this.__providers) { + const iter = p.entries ? p.entries(matcher) : entries(p); + for (let [key, val] of iter) { + if (matcher(key) && !seen.has(key)) { + seen.add(key); + yield [key, val]; + } + } + } + } + } + * [Symbol.iterator] () { + for (let [key, value] of this.entries()) { + yield [key, value]; } - state.tokens = tokens; } + * keys () { + for (let [key] of this.entries()) { + yield key; + } + } + * values () { + for (let [, value] of this.entries()) { + yield value; + } + } + concat (...moreConfig) { + return new Proxy(new FiggyPudding( + this.__specs, + this.__opts, + reverse(this.__providers).concat(moreConfig) + ), proxyHandler) + } +} +try { + const util = require$$0__default$2['default']; + FiggyPudding.prototype[util.inspect.custom] = function (depth, opts) { + return ( + this[Symbol.toStringTag] + ' ' + ) + util.inspect(this.toJSON(), opts) + }; +} catch (e) {} - if (opts.parts === true || opts.tokens === true) { - let prevIndex; +function BadKeyError (key) { + throw Object.assign(new Error( + `invalid config key requested: ${key}` + ), {code: 'EBADKEY'}) +} - for (let idx = 0; idx < slashes.length; idx++) { - const n = prevIndex ? prevIndex + 1 : start; - const i = slashes[idx]; - const value = input.slice(n, i); - if (opts.tokens) { - if (idx === 0 && start !== 0) { - tokens[idx].isPrefix = true; - tokens[idx].value = prefix; - } else { - tokens[idx].value = value; +function pudGet (pud, key, validate) { + let spec = pud.__specs[key]; + if (validate && !spec && (!pud.__opts.other || !pud.__opts.other(key))) { + BadKeyError(key); + } else { + if (!spec) { spec = {}; } + let ret; + for (let p of pud.__providers) { + ret = tryGet(key, p); + if (ret === undefined && spec.aliases && spec.aliases.length) { + for (let alias of spec.aliases) { + if (alias === key) { continue } + ret = tryGet(alias, p); + if (ret !== undefined) { + break + } } - depth(tokens[idx]); - state.maxDepth += tokens[idx].depth; } - if (idx !== 0 || value !== '') { - parts.push(value); + if (ret !== undefined) { + break } - prevIndex = i; } - - 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; + if (ret === undefined && spec.default !== undefined) { + if (typeof spec.default === 'function') { + return spec.default(pud) + } else { + return spec.default } + } else { + return ret } + } +} - state.slashes = slashes; - state.parts = parts; +function tryGet (key, p) { + let ret; + if (p.__isFiggyPudding) { + ret = pudGet(p, key, false); + } else if (typeof p.get === 'function') { + ret = p.get(key); + } else { + ret = p[key]; } + return ret +} - return state; +const proxyHandler = { + has (obj, prop) { + return prop in obj.__specs && pudGet(obj, prop, false) !== undefined + }, + ownKeys (obj) { + return Object.keys(obj.__specs) + }, + get (obj, prop) { + if ( + typeof prop === 'symbol' || + prop.slice(0, 2) === '__' || + prop in FiggyPudding.prototype + ) { + return obj[prop] + } + return obj.get(prop) + }, + set (obj, prop, value) { + if ( + typeof prop === 'symbol' || + prop.slice(0, 2) === '__' + ) { + obj[prop] = value; + return true + } else { + throw new Error('figgyPudding options cannot be modified. Use .concat() instead.') + } + }, + deleteProperty () { + throw new Error('figgyPudding options cannot be deleted. Use .concat() and shadow them instead.') + } }; -var scan_1 = scan$1; +var figgyPudding_1 = figgyPudding$1; +function figgyPudding$1 (specs, opts) { + function factory (...providers) { + return new Proxy(new FiggyPudding( + specs, + opts, + providers + ), proxyHandler) + } + return factory +} -const constants$4 = constants$5; -const utils$5 = utils$7; +function reverse (arr) { + const ret = []; + arr.forEach(x => ret.unshift(x)); + return ret +} -/** - * Constants - */ +function entries (obj) { + return Object.keys(obj).map(k => [k, obj[k]]) +} -const { - MAX_LENGTH: MAX_LENGTH$4, - POSIX_REGEX_SOURCE, - REGEX_NON_SPECIAL_CHARS, - REGEX_SPECIAL_CHARS_BACKREF, - REPLACEMENTS -} = constants$4; +var findUp$1 = {exports: {}}; -/** - * Helpers - */ +var locatePath$1 = {exports: {}}; -const expandRange = (args, options) => { - if (typeof options.expandRange === 'function') { - return options.expandRange(...args, options); - } +var pathExists$1 = {exports: {}}; - args.sort(); - const value = `[${args.join('-')}]`; +const fs$5 = require$$0__default$1['default']; - try { - /* eslint-disable-next-line no-new */ - new RegExp(value); - } catch (ex) { - return args.map(v => utils$5.escapeRegex(v)).join('..'); - } +pathExists$1.exports = fp => new Promise(resolve => { + fs$5.access(fp, err => { + resolve(!err); + }); +}); - return value; +pathExists$1.exports.sync = fp => { + try { + fs$5.accessSync(fp); + return true; + } catch (err) { + return false; + } }; -/** - * Create the message for a syntax error - */ +var pLimit$2 = {exports: {}}; -const syntaxError$1 = (type, char) => { - return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`; -}; +var pTry$2 = {exports: {}}; -/** - * Parse the given input string. - * @param {String} input - * @param {Object} options - * @return {Object} - */ +const pTry$1 = (fn, ...arguments_) => new Promise(resolve => { + resolve(fn(...arguments_)); +}); -const parse$8 = (input, options) => { - if (typeof input !== 'string') { - throw new TypeError('Expected a string'); - } +pTry$2.exports = pTry$1; +// TODO: remove this in the next major version +pTry$2.exports.default = pTry$1; - input = REPLACEMENTS[input] || input; +const pTry = pTry$2.exports; - const opts = { ...options }; - const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$4, opts.maxLength) : MAX_LENGTH$4; +const pLimit$1 = concurrency => { + if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) { + return Promise.reject(new TypeError('Expected `concurrency` to be a number from 1 and up')); + } - let len = input.length; - if (len > max) { - throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); - } + const queue = []; + let activeCount = 0; - const bos = { type: 'bos', value: '', output: opts.prepend || '' }; - const tokens = [bos]; - - const capture = opts.capture ? '' : '?:'; - const win32 = utils$5.isWindows(options); - - // create constants based on platform, for windows or posix - const PLATFORM_CHARS = constants$4.globChars(win32); - const EXTGLOB_CHARS = constants$4.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 => { - return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; - }; + const next = () => { + activeCount--; - const nodot = opts.dot ? '' : NO_DOT; - const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT; - let star = opts.bash === true ? globstar(opts) : STAR; + if (queue.length > 0) { + queue.shift()(); + } + }; - if (opts.capture) { - star = `(${star})`; - } + const run = (fn, resolve, ...args) => { + activeCount++; - // minimatch options support - if (typeof opts.noext === 'boolean') { - opts.noextglob = opts.noext; - } + const result = pTry(fn, ...args); - 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 - }; + resolve(result); - input = utils$5.removePrefix(input, state); - len = input.length; + result.then(next, next); + }; - const extglobs = []; - const braces = []; - const stack = []; - let prev = bos; - let value; + const enqueue = (fn, resolve, ...args) => { + if (activeCount < concurrency) { + run(fn, resolve, ...args); + } else { + queue.push(run.bind(null, fn, resolve, ...args)); + } + }; - /** - * Tokenizing helpers - */ + const generator = (fn, ...args) => new Promise(resolve => enqueue(fn, resolve, ...args)); + Object.defineProperties(generator, { + activeCount: { + get: () => activeCount + }, + pendingCount: { + get: () => queue.length + }, + clearQueue: { + value: () => { + queue.length = 0; + } + } + }); - 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 = '', num = 0) => { - state.consumed += value; - state.index += num; - }; + return generator; +}; - const append = token => { - state.output += token.output != null ? token.output : token.value; - consume(token.value); - }; +pLimit$2.exports = pLimit$1; +pLimit$2.exports.default = pLimit$1; - const negate = () => { - let count = 1; +const pLimit = pLimit$2.exports; - while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) { - advance(); - state.start++; - count++; - } +class EndError extends Error { + constructor(value) { + super(); + this.value = value; + } +} - if (count % 2 === 0) { - return false; - } +// The input can also be a promise, so we `Promise.resolve()` it +const testElement = (el, tester) => Promise.resolve(el).then(tester); - state.negated = true; - state.start++; - return true; - }; +// The input can also be a promise, so we `Promise.all()` them both +const finder$1 = el => Promise.all(el).then(val => val[1] === true && Promise.reject(new EndError(val[0]))); - const increment = type => { - state[type]++; - stack.push(type); - }; +var pLocate$1 = (iterable, tester, opts) => { + opts = Object.assign({ + concurrency: Infinity, + preserveOrder: true + }, opts); - const decrement = type => { - state[type]--; - stack.pop(); - }; + const limit = pLimit(opts.concurrency); - /** - * 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. - */ + // Start all the promises concurrently with optional limit + const items = [...iterable].map(el => [el, limit(testElement, el, tester)]); - 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')); + // Check the promises either serially or concurrently + const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity); - 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; - } - } + return Promise.all(items.map(el => checkLimit(finder$1, el))) + .then(() => {}) + .catch(err => err instanceof EndError ? err.value : Promise.reject(err)); +}; - if (extglobs.length && tok.type !== 'paren') { - extglobs[extglobs.length - 1].inner += tok.value; - } +const path$7 = path__default['default']; +const pathExists = pathExists$1.exports; +const pLocate = pLocate$1; - if (tok.value || tok.output) append(tok); - if (prev && prev.type === 'text' && tok.type === 'text') { - prev.value += tok.value; - prev.output = (prev.output || '') + tok.value; - return; - } +locatePath$1.exports = (iterable, options) => { + options = Object.assign({ + cwd: process.cwd() + }, options); - tok.prev = prev; - tokens.push(tok); - prev = tok; - }; + return pLocate(iterable, el => pathExists(path$7.resolve(options.cwd, el)), options); +}; - const extglobOpen = (type, value) => { - const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' }; +locatePath$1.exports.sync = (iterable, options) => { + options = Object.assign({ + cwd: process.cwd() + }, options); - token.prev = prev; - token.parens = state.parens; - token.output = state.output; - const output = (opts.capture ? '(' : '') + token.open; + for (const el of iterable) { + if (pathExists.sync(path$7.resolve(options.cwd, el))) { + return el; + } + } +}; - increment('parens'); - push({ type, value, output: state.output ? '' : ONE_CHAR }); - push({ type: 'paren', extglob: true, value: advance(), output }); - extglobs.push(token); - }; +const path$6 = path__default['default']; +const locatePath = locatePath$1.exports; - const extglobClose = token => { - let output = token.close + (opts.capture ? ')' : ''); - let rest; +findUp$1.exports = (filename, opts = {}) => { + const startDir = path$6.resolve(opts.cwd || ''); + const {root} = path$6.parse(startDir); - if (token.type === 'negate') { - let extglobStar = star; + const filenames = [].concat(filename); - if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { - extglobStar = globstar(opts); - } + return new Promise(resolve => { + (function find(dir) { + locatePath(filenames, {cwd: dir}).then(file => { + if (file) { + resolve(path$6.join(dir, file)); + } else if (dir === root) { + resolve(null); + } else { + find(path$6.dirname(dir)); + } + }); + })(startDir); + }); +}; - if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { - output = token.close = `)$))${extglobStar}`; - } +findUp$1.exports.sync = (filename, opts = {}) => { + let dir = path$6.resolve(opts.cwd || ''); + const {root} = path$6.parse(dir); - if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) { - output = token.close = `)${rest})${extglobStar})`; - } + const filenames = [].concat(filename); - if (token.prev.type === 'bos') { - state.negatedExtglob = true; - } - } + // eslint-disable-next-line no-constant-condition + while (true) { + const file = locatePath.sync(filenames, {cwd: dir}); - push({ type: 'paren', extglob: true, value, output }); - decrement('parens'); - }; + if (file) { + return path$6.join(dir, file); + } - /** - * Fast paths - */ + if (dir === root) { + return null; + } - if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { - let backslashes = false; + dir = path$6.dirname(dir); + } +}; - let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { - if (first === '\\') { - backslashes = true; - return m; - } +var ini$1 = {}; - 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); - } +ini$1.parse = ini$1.decode = decode; - if (first === '.') { - return DOT_LITERAL.repeat(chars.length); - } +ini$1.stringify = ini$1.encode = encode$1; - if (first === '*') { - if (esc) { - return esc + first + (rest ? star : ''); - } - return star; - } - return esc ? m : `\\${m}`; - }); +ini$1.safe = safe$1; +ini$1.unsafe = unsafe$1; - if (backslashes === true) { - if (opts.unescape === true) { - output = output.replace(/\\/g, ''); - } else { - output = output.replace(/\\+/g, m => { - return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : ''); - }); - } - } +var eol$1 = typeof process !== 'undefined' && + process.platform === 'win32' ? '\r\n' : '\n'; - if (output === input && opts.contains === true) { - state.output = input; - return state; - } +function encode$1 (obj, opt) { + var children = []; + var out = ''; - state.output = utils$5.wrapOutput(output, state, options); - return state; + if (typeof opt === 'string') { + opt = { + section: opt, + whitespace: false, + }; + } else { + opt = opt || {}; + opt.whitespace = opt.whitespace === true; } - /** - * Tokenize input until we reach end-of-string - */ - - while (!eos()) { - value = advance(); - - if (value === '\u0000') { - continue; - } - - /** - * Escaped characters - */ + var separator = opt.whitespace ? ' = ' : '='; - if (value === '\\') { - const next = peek(); + Object.keys(obj).forEach(function (k, _, __) { + var val = obj[k]; + if (val && Array.isArray(val)) { + val.forEach(function (item) { + out += safe$1(k + '[]') + separator + safe$1(item) + '\n'; + }); + } else if (val && typeof val === 'object') + children.push(k); + else + out += safe$1(k) + separator + safe$1(val) + eol$1; + }); - if (next === '/' && opts.bash !== true) { - continue; - } + if (opt.section && out.length) + out = '[' + safe$1(opt.section) + ']' + eol$1 + out; - if (next === '.' || next === ';') { - continue; - } + children.forEach(function (k, _, __) { + var nk = dotSplit(k).join('\\.'); + var section = (opt.section ? opt.section + '.' : '') + nk; + var child = encode$1(obj[k], { + section: section, + whitespace: opt.whitespace, + }); + if (out.length && child.length) + out += eol$1; - if (!next) { - value += '\\'; - push({ type: 'text', value }); - continue; - } + out += child; + }); - // collapse slashes to reduce potential for exploits - const match = /^\\+/.exec(remaining()); - let slashes = 0; + return out +} - if (match && match[0].length > 2) { - slashes = match[0].length; - state.index += slashes; - if (slashes % 2 !== 0) { - value += '\\'; - } - } +function dotSplit (str) { + return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002') + .replace(/\\\./g, '\u0001') + .split(/\./).map(function (part) { + return part.replace(/\1/g, '\\.') + .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001') + }) +} - if (opts.unescape === true) { - value = advance(); - } else { - value += advance(); - } +function decode (str) { + var out = {}; + var p = out; + var section = null; + // section |key = value + var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i; + var lines = str.split(/[\r\n]+/g); - if (state.brackets === 0) { - push({ type: 'text', value }); - continue; + lines.forEach(function (line, _, __) { + if (!line || line.match(/^\s*[;#]/)) + return + var match = line.match(re); + if (!match) + return + if (match[1] !== undefined) { + section = unsafe$1(match[1]); + if (section === '__proto__') { + // not allowed + // keep parsing the section, but don't attach it. + p = {}; + return } + p = out[section] = out[section] || {}; + return + } + var key = unsafe$1(match[2]); + if (key === '__proto__') + return + var value = match[3] ? unsafe$1(match[4]) : true; + switch (value) { + case 'true': + case 'false': + case 'null': value = JSON.parse(value); } - /** - * If we're inside a regex character class, continue - * until we reach the closing bracket. - */ + // Convert keys with '[]' suffix to an array + if (key.length > 2 && key.slice(-2) === '[]') { + key = key.substring(0, key.length - 2); + if (key === '__proto__') + return + if (!p[key]) + p[key] = []; + else if (!Array.isArray(p[key])) + p[key] = [p[key]]; + } - 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; + // safeguard against resetting a previously defined + // array by accidentally forgetting the brackets + if (Array.isArray(p[key])) + p[key].push(value); + else + p[key] = value; + }); - if (inner.includes(':')) { - const idx = prev.value.lastIndexOf('['); - const pre = prev.value.slice(0, idx); - const rest = prev.value.slice(idx + 2); - const posix = POSIX_REGEX_SOURCE[rest]; - if (posix) { - prev.value = pre + posix; - state.backtrack = true; - advance(); + // {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}} + // use a filter to return the keys that have to be deleted. + Object.keys(out).filter(function (k, _, __) { + if (!out[k] || + typeof out[k] !== 'object' || + Array.isArray(out[k])) + return false - if (!bos.output && tokens.indexOf(prev) === 1) { - bos.output = ONE_CHAR; - } - continue; - } - } - } - } + // see if the parent section is also an object. + // if so, add it to that, and mark this one for deletion + var parts = dotSplit(k); + var p = out; + var l = parts.pop(); + var nl = l.replace(/\\\./g, '.'); + parts.forEach(function (part, _, __) { + if (part === '__proto__') + return + if (!p[part] || typeof p[part] !== 'object') + p[part] = {}; + p = p[part]; + }); + if (p === out && nl === l) + return false - if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) { - value = `\\${value}`; - } + p[nl] = out[k]; + return true + }).forEach(function (del, _, __) { + delete out[del]; + }); - if (value === ']' && (prev.value === '[' || prev.value === '[^')) { - value = `\\${value}`; - } + return out +} - if (opts.posix === true && value === '!' && prev.value === '[') { - value = '^'; - } +function isQuoted (val) { + return (val.charAt(0) === '"' && val.slice(-1) === '"') || + (val.charAt(0) === "'" && val.slice(-1) === "'") +} - 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$5.escapeRegex(value); - prev.value += value; - append({ value }); - continue; - } - - /** - * Double quotes - */ +function safe$1 (val) { + return (typeof val !== 'string' || + val.match(/[=\r\n]/) || + val.match(/^\[/) || + (val.length > 1 && + isQuoted(val)) || + val !== val.trim()) + ? JSON.stringify(val) + : val.replace(/;/g, '\\;').replace(/#/g, '\\#') +} - if (value === '"') { - state.quotes = state.quotes === 1 ? 0 : 1; - if (opts.keepQuotes === true) { - push({ type: 'text', value }); - } - continue; - } +function unsafe$1 (val, doUnesc) { + val = (val || '').trim(); + if (isQuoted(val)) { + // remove the single quotes before calling JSON.parse + if (val.charAt(0) === "'") + val = val.substr(1, val.length - 2); - /** - * Parentheses - */ + try { + val = JSON.parse(val); + } catch (_) {} + } else { + // walk the val to find the first not-escaped ; character + var esc = false; + var unesc = ''; + for (var i = 0, l = val.length; i < l; i++) { + var c = val.charAt(i); + if (esc) { + if ('\\;#'.indexOf(c) !== -1) + unesc += c; + else + unesc += '\\' + c; - if (value === '(') { - increment('parens'); - push({ type: 'paren', value }); - continue; + esc = false; + } else if (';#'.indexOf(c) !== -1) + break + else if (c === '\\') + esc = true; + else + unesc += c; } + if (esc) + unesc += '\\'; - if (value === ')') { - if (state.parens === 0 && opts.strictBrackets === true) { - throw new SyntaxError(syntaxError$1('opening', '(')); - } - - const extglob = extglobs[extglobs.length - 1]; - if (extglob && state.parens === extglob.parens + 1) { - extglobClose(extglobs.pop()); - continue; - } + return unesc.trim() + } + return val +} - push({ type: 'paren', value, output: state.parens ? ')' : '\\)' }); - decrement('parens'); - continue; - } +const fs$4 = require$$0__default$1['default']; +const figgyPudding = figgyPudding_1; +const findUp = findUp$1.exports; +const ini = ini$1; +const os = require$$0__default['default']; +const path$5 = path__default['default']; - /** - * Square brackets - */ +const NpmConfig = figgyPudding({}, { + // Open up the pudding object. + other () { return true } +}); - if (value === '[') { - if (opts.nobracket === true || !remaining().includes(']')) { - if (opts.nobracket !== true && opts.strictBrackets === true) { - throw new SyntaxError(syntaxError$1('closing', ']')); - } +const ConfigOpts = figgyPudding({ + cache: { default: path$5.join(os.homedir(), '.npm') }, + configNames: { default: ['npmrc', '.npmrc'] }, + envPrefix: { default: /^npm_config_/i }, + cwd: { default: () => process.cwd() }, + globalconfig: { + default: () => path$5.join(getGlobalPrefix(), 'etc', 'npmrc') + }, + userconfig: { default: path$5.join(os.homedir(), '.npmrc') } +}); - value = `\\${value}`; - } else { - increment('brackets'); - } +libnpmconfig.read = getNpmConfig; +function getNpmConfig (_opts, _builtin) { + const builtin = ConfigOpts(_builtin); + const env = {}; + for (let key of Object.keys(process.env)) { + if (!key.match(builtin.envPrefix)) continue + const newKey = key.toLowerCase() + .replace(builtin.envPrefix, '') + .replace(/(?!^)_/g, '-'); + env[newKey] = process.env[key]; + } + const cli = NpmConfig(_opts); + const userConfPath = ( + builtin.userconfig || + cli.userconfig || + env.userconfig + ); + const user = userConfPath && maybeReadIni(userConfPath); + const globalConfPath = ( + builtin.globalconfig || + cli.globalconfig || + env.globalconfig + ); + const global = globalConfPath && maybeReadIni(globalConfPath); + const projConfPath = findUp.sync(builtin.configNames, { cwd: builtin.cwd }); + let proj = {}; + if (projConfPath && projConfPath !== userConfPath) { + proj = maybeReadIni(projConfPath); + } + const newOpts = NpmConfig(builtin, global, user, proj, env, cli); + if (newOpts.cache) { + return newOpts.concat({ + cache: path$5.resolve( + ( + (cli.cache || env.cache) + ? builtin.cwd + : proj.cache + ? path$5.dirname(projConfPath) + : user.cache + ? path$5.dirname(userConfPath) + : global.cache + ? path$5.dirname(globalConfPath) + : path$5.dirname(userConfPath) + ), + newOpts.cache + ) + }) + } else { + return newOpts + } +} - push({ type: 'bracket', value }); - continue; +function maybeReadIni (f) { + let txt; + try { + txt = fs$4.readFileSync(f, 'utf8'); + } catch (err) { + if (err.code === 'ENOENT') { + return '' + } else { + throw err } + } + return ini.parse(txt) +} - if (value === ']') { - if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) { - push({ type: 'text', value, output: `\\${value}` }); - continue; - } +function getGlobalPrefix () { + if (process.env.PREFIX) { + return process.env.PREFIX + } else if (process.platform === 'win32') { + // c:\node\node.exe --> prefix=c:\node\ + return path$5.dirname(process.execPath) + } else { + // /usr/local/bin/node --> prefix=/usr/local + let pref = path$5.dirname(path$5.dirname(process.execPath)); + // destdir only is respected on Unix + if (process.env.DESTDIR) { + pref = path$5.join(process.env.DESTDIR, pref); + } + return pref + } +} - if (state.brackets === 0) { - if (opts.strictBrackets === true) { - throw new SyntaxError(syntaxError$1('opening', '[')); - } +/** + * @typedef ResolveOptions + * @property {string} [prefix] + * @property {string|string[]} [cwd] + * @property {boolean} [global] + */ - push({ type: 'text', value, output: `\\${value}` }); - continue; - } +const electron = process.versions.electron !== undefined; +const windows = process.platform === 'win32'; - decrement('brackets'); +const argv = process.argv[1] || /* c8 ignore next */ ''; +const nvm = process.env.NVM_BIN; +const appData = process.env.APPDATA; - const prevValue = prev.value.slice(1); - if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { - value = `/${value}`; - } +/* c8 ignore next */ +const globalsLibrary = windows ? '' : 'lib'; - prev.value += value; - append({ value }); +/** @type {{prefix?: string}} */ +let builtinNpmConfig; - // when literal brackets are explicitly disabled - // assume we should match with a regex character class - if (opts.literalBrackets === false || utils$5.hasRegexChars(prevValue)) { - continue; - } +// The prefix config defaults to the location where node is installed. +// On Windows, this is in a place called `%AppData%`, which we have to +// pass to `libnpmconfig` explicitly: +/* c8 ignore next 4 */ +if (windows && appData) { + builtinNpmConfig = {prefix: path__default['default'].join(appData, 'npm')}; +} - const escaped = utils$5.escapeRegex(prev.value); - state.output = state.output.slice(0, -prev.value.length); +/** + * Note: `libnpmconfig` uses `figgy-pudding` which is slated for archival. + * Either `libnpmconfig` will switch to an alternative or we’ll have to. + * @type {string} + */ +let npmPrefix = libnpmconfig.read(null, builtinNpmConfig).prefix; - // when literal brackets are explicitly enabled - // assume we should escape the brackets to match literal characters - if (opts.literalBrackets === true) { - state.output += escaped; - prev.value = escaped; - continue; - } +// If there is no prefix defined, use the defaults +// See: +/* c8 ignore next 5 */ +if (!npmPrefix) { + npmPrefix = windows + ? path__default['default'].dirname(process.execPath) + : path__default['default'].resolve(process.execPath, '../..'); +} - // when the user specifies nothing, try to match both - prev.value = `(${capture}${escaped}|${prev.value})`; - state.output += prev.value; - continue; - } +const globalsDefault = electron || argv.indexOf(npmPrefix) === 0; +let globalDir = path__default['default'].resolve(npmPrefix, globalsLibrary, 'node_modules'); - /** - * Braces - */ +// If we’re in Electron, we’re running in a modified Node that cannot really +// install global node modules. +// To find the actual modules, the user has to set `prefix` somewhere in an +// `.npmrc` (which is picked up by `libnpmconfig`). +// Most people don’t do that, and some use NVM instead to manage different +// versions of Node. +// Luckily NVM leaks some environment variables that we can pick up on to try +// and detect the actual modules. +/* c8 ignore next 3 */ +if (electron && nvm && !require$$0__default$1['default'].existsSync(globalDir)) { + globalDir = path__default['default'].resolve(nvm, '..', globalsLibrary, 'node_modules'); +} - if (value === '{' && opts.nobrace !== true) { - increment('braces'); +/** + * Load the plugin found using `resolvePlugin`. + * + * @param {string} name The name to import. + * @param {LoadOptions} [options] + * @returns {Promise} + */ +async function loadPlugin(name, options = {}) { + const {key = 'default', ...rest} = options; + const fp = await resolvePlugin(name, rest); + /** @type {Object.} */ + // Bug with coverage on Node@12. + /* c8 ignore next 3 */ + const mod = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(url.pathToFileURL(fp).href)); }); + return key === false ? mod : mod[key] +} - const open = { - type: 'brace', - value, - output: '(', - outputIndex: state.output.length, - tokensIndex: state.tokens.length - }; +/** + * Find a plugin. + * + * See also: + * * https://docs.npmjs.com/files/folders#node-modules + * * https://github.com/sindresorhus/resolve-from + * + * Uses the standard node module loading strategy to find `$name` in each given + * `cwd` (and optionally the global `node_modules` directory). + * + * If a prefix is given and `$name` is not a path, `$prefix-$name` is also + * searched (preferring these over non-prefixed modules). + * + * @param {string} name + * @param {ResolveOptions} [options] + * @returns {Promise.} + */ +async function resolvePlugin(name, options = {}) { + const prefix = options.prefix + ? options.prefix + + (options.prefix.charAt(options.prefix.length - 1) === '-' ? '' : '-') + : undefined; + const cwd = options.cwd; + const globals = + options.global === undefined || options.global === null + ? globalsDefault + : options.global; + const sources = Array.isArray(cwd) ? cwd.concat() : [cwd || process.cwd()]; + /** @type {string} */ + let plugin; + /** @type {Error} */ + let lastError; - braces.push(open); - push(open); - continue; + // Non-path. + if (name.charAt(0) !== '.') { + if (globals) { + sources.push(globalDir); } - if (value === '}') { - const brace = braces[braces.length - 1]; - - if (opts.nobrace === true || !brace) { - push({ type: 'text', value, output: value }); - continue; - } - - let output = ')'; + let scope = ''; - if (brace.dots === true) { - const arr = tokens.slice(); - const range = []; + // Unprefix module. + if (prefix) { + // Scope? + if (name.charAt(0) === '@') { + const slash = name.indexOf('/'); - for (let i = arr.length - 1; i >= 0; i--) { - tokens.pop(); - if (arr[i].type === 'brace') { - break; - } - if (arr[i].type !== 'dots') { - range.unshift(arr[i].value); - } + // Let’s keep the algorithm simple. + // No need to care if this is a “valid” scope (I think?). + // But we do check for the slash. + if (slash !== -1) { + scope = name.slice(0, slash + 1); + name = name.slice(slash + 1); } - - 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); - } + if (name.slice(0, prefix.length) !== prefix) { + plugin = scope + prefix + name; } - push({ type: 'brace', value, output }); - decrement('braces'); - braces.pop(); - continue; + name = scope + name; } + } - /** - * Pipes - */ - - if (value === '|') { - if (extglobs.length > 0) { - extglobs[extglobs.length - 1].conditions++; - } - push({ type: 'text', value }); - continue; - } + let index = -1; + /** @type {string} */ + let fp; - /** - * Commas - */ + while (++index < sources.length) { + fp = plugin && (await attempt(sources[index], plugin)); + if (fp) return fp - if (value === ',') { - let output = value; + fp = await attempt(sources[index], name); + if (fp) return fp + } - const brace = braces[braces.length - 1]; - if (brace && stack[stack.length - 1] === 'braces') { - brace.comma = true; - output = '|'; - } + // There’s always an error. + // Bug with coverage on Node@12. + /* c8 ignore next 8 */ + throw lastError - push({ type: 'comma', value, output }); - continue; + /** + * @param {string} base + * @param {string} name + * @returns {Promise} + */ + async function attempt(base, name) { + try { + // `import-meta-resolve` resolves from files, whereas `load-plugin` works + // on folders, which is why we add a `/` at the end. + return url.fileURLToPath( + await resolve(name, url.pathToFileURL(base).href + '/') + ) + // Bug with coverage on Node@12. + /* c8 ignore next 1 */ + } catch (error) { + lastError = error; } + } +} - /** - * Slashes - */ +function isPlainObject$1(value) { + if (Object.prototype.toString.call(value) !== '[object Object]') { + return false; + } - if (value === '/') { - // if the beginning of the glob is "./", advance the start - // to the current index, and don't add the "./" characters - // to the state. This greatly simplifies lookbehinds when - // checking for BOS characters like "!" and "." (not "./") - if (prev.type === 'dot' && state.index === state.start + 1) { - state.start = state.index + 1; - state.consumed = ''; - state.output = ''; - tokens.pop(); - prev = bos; // reset "prev" to the first token - continue; - } + const prototype = Object.getPrototypeOf(value); + return prototype === null || prototype === Object.prototype; +} - push({ type: 'slash', value, output: SLASH_LITERAL }); - continue; - } +var format$1 = {exports: {}}; - /** - * Dots - */ +(function (module) { +(function() { - 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; - } + //// Export the API + var namespace; - if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') { - push({ type: 'text', value, output: DOT_LITERAL }); - continue; - } + // CommonJS / Node module + { + namespace = module.exports = format; + } - push({ type: 'dot', value, output: DOT_LITERAL }); - continue; - } + namespace.format = format; + namespace.vsprintf = vsprintf; - /** - * Question marks - */ + if (typeof console !== 'undefined' && typeof console.log === 'function') { + namespace.printf = printf; + } - if (value === '?') { - const isGroup = prev && prev.value === '('; - if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { - extglobOpen('qmark', value); - continue; - } + function printf(/* ... */) { + console.log(format.apply(null, arguments)); + } - if (prev && prev.type === 'paren') { - const next = peek(); - let output = value; + function vsprintf(fmt, replacements) { + return format.apply(null, [fmt].concat(replacements)); + } - if (next === '<' && !utils$5.supportsLookbehinds()) { - throw new Error('Node.js v10 or higher is required for regex lookbehinds'); + function format(fmt) { + var argIndex = 1 // skip initial format argument + , args = [].slice.call(arguments) + , i = 0 + , n = fmt.length + , result = '' + , c + , escaped = false + , arg + , tmp + , leadingZero = false + , precision + , nextArg = function() { return args[argIndex++]; } + , slurpNumber = function() { + var digits = ''; + while (/\d/.test(fmt[i])) { + digits += fmt[i++]; + c = fmt[i]; + } + return digits.length > 0 ? parseInt(digits) : null; } - - if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) { - output = `\\${value}`; + ; + for (; i < n; ++i) { + c = fmt[i]; + if (escaped) { + escaped = false; + if (c == '.') { + leadingZero = false; + c = fmt[++i]; } - - 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; + else if (c == '0' && fmt[i + 1] == '.') { + leadingZero = true; + i += 2; + c = fmt[i]; } + else { + leadingZero = true; + } + precision = slurpNumber(); + switch (c) { + case 'b': // number in binary + result += parseInt(nextArg(), 10).toString(2); + break; + case 'c': // character + arg = nextArg(); + if (typeof arg === 'string' || arg instanceof String) + result += arg; + else + result += String.fromCharCode(parseInt(arg, 10)); + break; + case 'd': // number in decimal + result += parseInt(nextArg(), 10); + break; + case 'f': // floating point number + tmp = String(parseFloat(nextArg()).toFixed(precision || 6)); + result += leadingZero ? tmp : tmp.replace(/^0/, ''); + break; + case 'j': // JSON + result += JSON.stringify(nextArg()); + break; + case 'o': // number in octal + result += '0' + parseInt(nextArg(), 10).toString(8); + break; + case 's': // string + result += nextArg(); + break; + case 'x': // lowercase hexadecimal + result += '0x' + parseInt(nextArg(), 10).toString(16); + break; + case 'X': // uppercase hexadecimal + result += '0x' + parseInt(nextArg(), 10).toString(16).toUpperCase(); + break; + default: + result += c; + break; + } + } else if (c === '%') { + escaped = true; + } else { + result += c; } - - 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; } + return result; + } - /** - * Plain text - */ +}()); +}(format$1)); - if (value === '@') { - if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { - push({ type: 'at', extglob: true, value, output: '' }); - continue; - } +var formatter = format$1.exports; - push({ type: 'text', value }); - continue; - } +// @ts-ignore - /** - * Plain text - */ +var fault = Object.assign(create$1(Error), { + eval: create$1(EvalError), + range: create$1(RangeError), + reference: create$1(ReferenceError), + syntax: create$1(SyntaxError), + type: create$1(TypeError), + uri: create$1(URIError) +}); - if (value !== '*') { - if (value === '$' || value === '^') { - value = `\\${value}`; - } +/** + * Create a new `EConstructor`, with the formatted `format` as a first argument. + * + * @template {Error} Fault + * @template {new (reason: string) => Fault} Class + * @param {Class} Constructor + */ +function create$1(Constructor) { + /** @type {string} */ + // @ts-ignore + FormattedError.displayName = Constructor.displayName || Constructor.name; - const match = REGEX_NON_SPECIAL_CHARS.exec(remaining()); - if (match) { - value += match[0]; - state.index += match[0].length; - } + return FormattedError - push({ type: 'text', value }); - continue; - } + /** + * @param {string} [format] + * @param {...unknown} values + * @returns {Fault} + */ + function FormattedError(format, ...values) { + /** @type {string} */ + var reason = format ? formatter(format, ...values) : format; + return new Constructor(reason) + } +} - /** - * Stars - */ +const debug$b = createDebug('unified-engine:find-up'); - 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; - } +/** + * @template Value + */ +class FindUp { + /** + * @callback Create + * @param {Buffer} buf + * @param {string} filePath + * @returns {Promise|Value|undefined} + */ - let rest = remaining(); - if (opts.noextglob !== true && /^\([^?]/.test(rest)) { - extglobOpen('star', value); - continue; - } + /** + * @callback Callback + * @param {Error|null} error + * @param {Value} [result] + * @returns {void} + */ - if (prev.type === 'star') { - if (opts.noglobstar === true) { - consume(value); - continue; - } + /** + * @typedef Options + * @property {string} cwd + * @property {string|undefined} filePath + * @property {boolean|undefined} [detect] + * @property {string[]} names + * @property {Create} create + */ - 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'); + /** + * @param {Options} options + */ + constructor(options) { + /** @type {Record} */ + this.cache = {}; + /** @type {string} */ + this.cwd = options.cwd; + /** @type {boolean|undefined} */ + this.detect = options.detect; + /** @type {string[]} */ + this.names = options.names; + /** @type {Create} */ + this.create = options.create; - if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) { - push({ type: 'star', value, output: '' }); - continue; - } + /** @type {string|undefined} */ + this.givenFilePath = options.filePath + ? path__default$1['default'].resolve(options.cwd, options.filePath) + : undefined; - 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; - } + /* eslint-disable no-unused-expressions */ + /** @type {Error|Value|Callback[]|undefined} */ + this.givenFile; + /* eslint-enable no-unused-expressions */ + } - // strip consecutive `/**/` - while (rest.slice(0, 3) === '/**') { - const after = input[state.index + 4]; - if (after && after !== '/') { - break; - } - rest = rest.slice(3); - consume('/**', 3); - } + /** + * @param {string} filePath + * @param {Callback} callback + */ + load(filePath, callback) { + const self = this; + const givenFile = this.givenFile; + const {givenFilePath} = this; + + if (givenFilePath) { + if (givenFile) { + apply(callback, givenFile); + } else { + const cbs = [callback]; + this.givenFile = cbs; + debug$b('Checking given file `%s`', givenFilePath); + fs__default['default'].readFile(givenFilePath, (error, buf) => { + if (error) { + /** @type {NodeJS.ErrnoException} */ + const result = fault( + 'Cannot read given file `%s`\n%s', + path__default$1['default'].relative(this.cwd, givenFilePath), + error.stack + ); + result.code = 'ENOENT'; + result.path = error.path; + result.syscall = error.syscall; + loaded(result); + } else { + wrap(this.create, (error, /** @type {Value} */ result) => { + if (error) { + debug$b(error.message); + loaded( + fault( + 'Cannot parse given file `%s`\n%s', + path__default$1['default'].relative(this.cwd, givenFilePath), + error.stack + ) + ); + } else { + debug$b('Read given file `%s`', givenFilePath); + loaded(result); + } + })(buf, givenFilePath); + } - 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; + /** @param {Error|Value} result */ + function loaded(result) { + self.givenFile = result; + applyAll(cbs, result); + } + }); } - 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}`; + return + } - 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 (!this.detect) { + return callback(null) + } - if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { - const end = rest[1] !== void 0 ? '|$' : ''; + filePath = path__default$1['default'].resolve(this.cwd, filePath); + const parent = path__default$1['default'].dirname(filePath); - state.output = state.output.slice(0, -(prior.output + prev.output).length); - prior.output = `(?:${prior.output}`; + if (parent in this.cache) { + apply(callback, this.cache[parent]); + } else { + this.cache[parent] = [callback]; + find(parent); + } - prev.type = 'globstar'; - prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; - prev.value += value; + /** + * @param {string} directory + */ + function find(directory) { + let index = -1; - state.output += prior.output + prev.output; - state.globstar = true; + next(); - consume(value + advance()); + function next() { + // Try to read the next file. + // We do not use `readdir` because on huge directories, that could be + // *very* slow. + if (++index < self.names.length) { + fs__default['default'].readFile(path__default$1['default'].join(directory, self.names[index]), done); + } else { + const parent = path__default$1['default'].dirname(directory); - push({ type: 'slash', value: '/', output: '' }); - continue; + if (directory === parent) { + debug$b('No files found for `%s`', filePath); + found(null); + } else if (parent in self.cache) { + apply(found, self.cache[parent]); + } else { + self.cache[parent] = [found]; + find(parent); + } + } } - 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; - } + /** + * @param {NodeJS.ErrnoException|null} error + * @param {Buffer} [buf] + * @returns {void} + */ + function done(error, buf) { + const fp = path__default$1['default'].join(directory, self.names[index]); - // remove single star from output - state.output = state.output.slice(0, -prev.output.length); + if (error) { + // Hard to test. + /* c8 ignore next 13 */ + if (error.code === 'ENOENT') { + return next() + } - // reset previous token to globstar - prev.type = 'globstar'; - prev.output = globstar(opts); - prev.value += value; + debug$b(error.message); + return found( + fault( + 'Cannot read file `%s`\n%s', + path__default$1['default'].relative(self.cwd, fp), + error.message + ) + ) + } - // reset output with globstar - state.output += prev.output; - state.globstar = true; - consume(value); - continue; + wrap(self.create, (error, /** @type {Value} */ result) => { + if (error) { + found( + fault( + 'Cannot parse file `%s`\n%s', + path__default$1['default'].relative(self.cwd, fp), + error.message + ) + ); + } else if (result) { + debug$b('Read file `%s`', fp); + found(null, result); + } else { + next(); + } + })(buf, fp); + } + + /** + * @param {Error|null} error + * @param {Value} [result] + * @returns {void} + */ + function found(error, result) { + /** @type {Callback[]} */ + // @ts-expect-error: always a list if found. + const cbs = self.cache[directory]; + self.cache[directory] = error || result; + applyAll(cbs, error || result); + } } - const token = { type: 'star', value, output: star }; + /** + * @param {Callback[]} cbs + * @param {Value|Error|undefined} result + */ + function applyAll(cbs, result) { + let index = cbs.length; - if (opts.bash === true) { - token.output = '.*?'; - if (prev.type === 'bos' || prev.type === 'slash') { - token.output = nodot + token.output; + while (index--) { + apply(cbs[index], result); } - push(token); - continue; } - if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { - token.output = value; - push(token); - continue; + /** + * @param {Callback} cb + * @param {Value|Error|Callback[]|undefined} result + */ + function apply(cb, result) { + if (Array.isArray(result)) { + result.push(cb); + } else if (result instanceof Error) { + cb(result); + } else { + cb(null, result); + } } + } +} - 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; +/** + * @typedef {import('unified').Plugin} Plugin + * @typedef {import('unified').PluginTuple} PluginTuple + * @typedef {import('unified').PluggableList} PluggableList + * + * @typedef {Record} Settings + * + * @typedef {Record} PluginIdObject + * @typedef {Array} PluginIdList + * + * @typedef Preset + * @property {Settings} [settings] + * @property {PluggableList|PluginIdObject|PluginIdList|undefined} [plugins] + * + * @typedef Config + * @property {Settings} [settings] + * @property {Array} [plugins] + * + * @callback ConfigTransform + * @param {any} config + * @param {string} filePath + * @returns {Preset} + * + * @callback Loader + * @param {Buffer} buf + * @param {string} filePath + * @returns {Promise} + * + * @callback Callback + * @param {Error|null} error + * @param {Config} [result] + * @returns {void} + */ - } else if (opts.dot === true) { - state.output += NO_DOTS_SLASH; - prev.output += NO_DOTS_SLASH; +const debug$a = createDebug('unified-engine:configuration'); - } else { - state.output += nodot; - prev.output += nodot; - } +const own$c = {}.hasOwnProperty; - if (peek() !== '*') { - state.output += ONE_CHAR; - prev.output += ONE_CHAR; - } +/** @type {Record} */ +const loaders = { + '.json': loadJson, + '.cjs': loadScriptOrModule, + '.mjs': loadScriptOrModule, + '.js': loadScriptOrModule, + '.yaml': loadYaml, + '.yml': loadYaml +}; + +const defaultLoader = loadJson; + +/** + * @typedef Options + * @property {string} cwd + * @property {string} [packageField] + * @property {string} [pluginPrefix] + * @property {string} [rcName] + * @property {string} [rcPath] + * @property {boolean} [detectConfig] + * @property {ConfigTransform} [configTransform] + * @property {Preset} [defaultConfig] + * @property {Preset['settings']} [settings] + * @property {Preset['plugins']} [plugins] + */ + +class Configuration { + /** + * @param {Options} options + */ + constructor(options) { + /** @type {string[]} */ + const names = []; + + /** @type {string} */ + this.cwd = options.cwd; + /** @type {string|undefined} */ + this.packageField = options.packageField; + /** @type {string|undefined} */ + this.pluginPrefix = options.pluginPrefix; + /** @type {ConfigTransform|undefined} */ + this.configTransform = options.configTransform; + /** @type {Preset|undefined} */ + this.defaultConfig = options.defaultConfig; + + if (options.rcName) { + names.push( + options.rcName, + options.rcName + '.js', + options.rcName + '.yml', + options.rcName + '.yaml' + ); + debug$a('Looking for `%s` configuration files', names); } - push(token); - } + if (options.packageField) { + names.push('package.json'); + debug$a( + 'Looking for `%s` fields in `package.json` files', + options.packageField + ); + } - while (state.brackets > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ']')); - state.output = utils$5.escapeLast(state.output, '['); - decrement('brackets'); - } + /** @type {Preset} */ + this.given = {settings: options.settings, plugins: options.plugins}; + this.create = this.create.bind(this); - while (state.parens > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ')')); - state.output = utils$5.escapeLast(state.output, '('); - decrement('parens'); + /** @type {FindUp} */ + this.findUp = new FindUp({ + cwd: options.cwd, + filePath: options.rcPath, + detect: options.detectConfig, + names, + create: this.create + }); } - while (state.braces > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', '}')); - state.output = utils$5.escapeLast(state.output, '{'); - decrement('braces'); - } + /** + * @param {string} filePath + * @param {Callback} callback + * @returns {void} + */ + load(filePath, callback) { + this.findUp.load( + filePath || path__default$1['default'].resolve(this.cwd, 'stdin.js'), + (error, file) => { + if (error || file) { + return callback(error, file) + } - if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { - push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); + this.create(undefined, undefined).then((result) => { + callback(null, result); + }, callback); + } + ); } - // rebuild the output if we had to backtrack at any point - if (state.backtrack === true) { - state.output = ''; + /** + * @param {Buffer|undefined} buf + * @param {string|undefined} filePath + * @returns {Promise} + */ + async create(buf, filePath) { + const options = {prefix: this.pluginPrefix, cwd: this.cwd}; + const result = {settings: {}, plugins: []}; + const extname = filePath ? path__default$1['default'].extname(filePath) : undefined; + const loader = + extname && extname in loaders ? loaders[extname] : defaultLoader; + /** @type {Preset|undefined} */ + let value; - for (const token of state.tokens) { - state.output += token.output != null ? token.output : token.value; + if (filePath && buf) { + value = await loader.call(this, buf, filePath); - if (token.suffix) { - state.output += token.suffix; + if (this.configTransform && value !== undefined) { + value = this.configTransform(value, filePath); } } - } - return state; -}; + // Exit if we did find a `package.json`, but it does not have configuration. + if ( + filePath && + value === undefined && + path__default$1['default'].basename(filePath) === 'package.json' + ) { + return + } -/** - * 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. - */ + if (value === undefined) { + if (this.defaultConfig) { + await merge( + result, + this.defaultConfig, + Object.assign({}, options, {root: this.cwd}) + ); + } + } else { + await merge( + result, + value, + // @ts-expect-error: `value` can only exist if w/ `filePath`. + Object.assign({}, options, {root: path__default$1['default'].dirname(filePath)}) + ); + } -parse$8.fastpaths = (input, options) => { - const opts = { ...options }; - const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$4, opts.maxLength) : MAX_LENGTH$4; - const len = input.length; - if (len > max) { - throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); + await merge( + result, + this.given, + Object.assign({}, options, {root: this.cwd}) + ); + + // C8 bug on Node@12 + /* c8 ignore next 2 */ + return result } +} - input = REPLACEMENTS[input] || input; - const win32 = utils$5.isWindows(options); +/** @type {Loader} */ +async function loadScriptOrModule(_, filePath) { + // C8 bug on Node@12 + /* c8 ignore next 4 */ + // @ts-expect-error: Assume it matches config. + // type-coverage:ignore-next-line + return loadFromAbsolutePath(filePath, this.cwd) +} - // create constants based on platform, for windows or posix - const { - DOT_LITERAL, - SLASH_LITERAL, - ONE_CHAR, - DOTS_SLASH, - NO_DOT, - NO_DOTS, - NO_DOTS_SLASH, - STAR, - START_ANCHOR - } = constants$4.globChars(win32); +/** @type {Loader} */ +async function loadYaml(buf, filePath) { + // C8 bug on Node@12 + /* c8 ignore next 4 */ + // @ts-expect-error: Assume it matches config. + return jsYaml.load(String(buf), {filename: path__default$1['default'].basename(filePath)}) +} - 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; +/** @type {Loader} */ +async function loadJson(buf, filePath) { + /** @type {Record} */ + const result = parseJson_1(String(buf), filePath); - if (opts.capture) { - star = `(${star})`; + // C8 bug on Node@12 + /* c8 ignore next 8 */ + // @ts-expect-error: Assume it matches config. + return path__default$1['default'].basename(filePath) === 'package.json' + ? // @ts-expect-error: `this` is the configuration context, TS doesn’t like + // `this` on callbacks. + // type-coverage:ignore-next-line + result[this.packageField] + : result +} + +/** + * @param {Required} target + * @param {Preset} raw + * @param {{root: string, prefix: string|undefined}} options + * @returns {Promise} + */ +async function merge(target, raw, options) { + if (typeof raw === 'object' && raw !== null) { + await addPreset(raw); + } else { + throw new Error('Expected preset, not `' + raw + '`') } - const globstar = opts => { - if (opts.noglobstar === true) return star; - return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; - }; + // C8 bug on Node@12 + /* c8 ignore next 6 */ + return target - const create = str => { - switch (str) { - case '*': - return `${nodot}${ONE_CHAR}${star}`; + /** + * @param {Preset} result + */ + async function addPreset(result) { + const plugins = result.plugins; - case '.*': - return `${DOT_LITERAL}${ONE_CHAR}${star}`; + if (plugins === null || plugins === undefined) ; else if (typeof plugins === 'object' && plugins !== null) { + await (Array.isArray(plugins) ? addEach(plugins) : addIn(plugins)); + } else { + throw new Error( + 'Expected a list or object of plugins, not `' + plugins + '`' + ) + } - case '*.*': - return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; + target.settings = Object.assign({}, target.settings, result.settings); + // C8 bug on Node@12 + /* c8 ignore next 6 */ + } - case '*/*': - return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`; + /** + * @param {PluginIdList|PluggableList} result + */ + async function addEach(result) { + let index = -1; - case '**': - return nodot + globstar(opts); + while (++index < result.length) { + const value = result[index]; - case '**/*': - return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`; + // Keep order sequential instead of parallel. + /* eslint-disable no-await-in-loop */ + // @ts-expect-error: Spreading is fine. + // type-coverage:ignore-next-line + await (Array.isArray(value) ? use(...value) : use(value, undefined)); + /* eslint-enable no-await-in-loop */ + } + // C8 bug on Node@12 + /* c8 ignore next 6 */ + } - case '**/*.*': - return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; + /** + * @param {PluginIdObject} result + */ + async function addIn(result) { + /** @type {string} */ + let key; - case '**/.*': - return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`; + for (key in result) { + if (own$c.call(result, key)) { + // Keep order sequential instead of parallel. + // eslint-disable-next-line no-await-in-loop + await use(key, result[key]); + } + } + // C8 bug on Node@12 + /* c8 ignore next 7 */ + } - default: { - const match = /^(.*?)\.(\w+)$/.exec(str); - if (!match) return; + /** + * @param {string|Plugin|Preset} usable + * @param {Settings|null|undefined} value + */ + async function use(usable, value) { + if (typeof usable === 'string') { + await addModule(usable, value); + } else if (typeof usable === 'function') { + addPlugin(usable, value); + } else { + await merge(target, usable, options); + } + // C8 bug on Node@12 + /* c8 ignore next 7 */ + } - const source = create(match[1]); - if (!source) return; + /** + * @param {string} id + * @param {Settings|null|undefined} value + */ + async function addModule(id, value) { + /** @type {string} */ + let fp; - return source + DOT_LITERAL + match[2]; - } + try { + fp = await resolvePlugin(id, { + cwd: options.root, + prefix: options.prefix + }); + } catch (error) { + addPlugin(() => { + throw fault('Could not find module `%s`\n%s', id, error.stack) + }, value); + return } - }; - const output = utils$5.removePrefix(input, state); - let source = create(output); + const result = await loadFromAbsolutePath(fp, options.root); - if (source && opts.strictSlashes !== true) { - source += `${SLASH_LITERAL}?`; + try { + if (typeof result === 'function') { + addPlugin(result, value); + } else { + await merge( + target, + result, + Object.assign({}, options, {root: path__default$1['default'].dirname(fp)}) + ); + } + } catch { + throw fault( + 'Error: Expected preset or plugin, not %s, at `%s`', + result, + path__default$1['default'].relative(options.root, fp) + ) + } + // C8 bug on Node@12 + /* c8 ignore next 8 */ } - return source; -}; + /** + * @param {Plugin} plugin + * @param {Settings|null|undefined} value + * @returns {void} + */ + function addPlugin(plugin, value) { + const entry = find(target.plugins, plugin); -var parse_1$3 = parse$8; + if (value === null) { + value = undefined; + } -const path$2 = require$$0__default$2['default']; -const scan = scan_1; -const parse$7 = parse_1$3; -const utils$4 = utils$7; -const constants$3 = constants$5; -const isObject$3 = val => val && typeof val === 'object' && !Array.isArray(val); + if (entry) { + reconfigure(entry, value); + } else { + target.plugins.push([plugin, value]); + } + } +} /** - * 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 + * @param {PluginTuple} entry + * @param {Settings|undefined} value + * @returns {void} */ - -const picomatch$3 = (glob, options, returnState = false) => { - if (Array.isArray(glob)) { - const fns = glob.map(input => picomatch$3(input, options, returnState)); - const arrayMatcher = str => { - for (const isMatch of fns) { - const state = isMatch(str); - if (state) return state; - } - return false; - }; - return arrayMatcher; - } - - const isState = isObject$3(glob) && glob.tokens && glob.input; - - if (glob === '' || (typeof glob !== 'string' && !isState)) { - throw new TypeError('Expected pattern to be a non-empty string'); - } - - const opts = options || {}; - const posix = utils$4.isWindows(options); - const regex = isState - ? picomatch$3.compileRe(glob, options) - : picomatch$3.makeRe(glob, 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$3(opts.ignore, ignoreOpts, returnState); +function reconfigure(entry, value) { + if (isPlainObject$1(entry[1]) && isPlainObject$1(value)) { + value = Object.assign({}, entry[1], value); } - const matcher = (input, returnObject = false) => { - const { isMatch, match, output } = picomatch$3.test(input, regex, options, { glob, posix }); - const result = { glob, state, regex, posix, input, output, match, isMatch }; + entry[1] = value; +} - if (typeof opts.onResult === 'function') { - opts.onResult(result); - } +/** + * @param {Array} entries + * @param {Plugin} plugin + * @returns {PluginTuple|undefined} + */ +function find(entries, plugin) { + let index = -1; - if (isMatch === false) { - result.isMatch = false; - return returnObject ? result : false; + while (++index < entries.length) { + const entry = entries[index]; + if (entry[0] === plugin) { + return entry } + } +} - if (isIgnored(input)) { - if (typeof opts.onIgnore === 'function') { - opts.onIgnore(result); - } - result.isMatch = false; - return returnObject ? result : false; - } +/** + * @param {string} fp + * @param {string} base + * @returns {Promise} + */ +async function loadFromAbsolutePath(fp, base) { + try { + /** @type {{default?: unknown}} */ + const result = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(node_url.pathToFileURL(fp).href)); }); - if (typeof opts.onMatch === 'function') { - opts.onMatch(result); + if (!('default' in result)) { + throw new Error( + 'Expected a plugin or preset exported as the default export' + ) } - return returnObject ? result : true; - }; - if (returnState) { - matcher.state = state; + // @ts-expect-error: assume plugin/preset. + return result.default + // C8 bug on Node@12 + /* c8 ignore next 4 */ + } catch (error) { + throw fault('Cannot import `%s`\n%s', path__default$1['default'].relative(base, fp), error.stack) } - - 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 + * @typedef {import('./index.js').Settings} Settings */ -picomatch$3.test = (input, regex, options, { glob, posix } = {}) => { - if (typeof input !== 'string') { - throw new TypeError('Expected input to be a string'); - } +/** + * @param {Context} context + * @param {Settings} settings + */ +function configure$3(context, settings) { + context.configuration = new Configuration(settings); +} - if (input === '') { - return { isMatch: false, output: '' }; - } +// A simple implementation of make-array +function makeArray (subject) { + return Array.isArray(subject) + ? subject + : [subject] +} - const opts = options || {}; - const format = opts.format || (posix ? utils$4.toPosixSlashes : null); - let match = input === glob; - let output = (match && format) ? format(input) : input; +const EMPTY = ''; +const SPACE = ' '; +const ESCAPE = '\\'; +const REGEX_TEST_BLANK_LINE = /^\s+$/; +const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; +const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; +const REGEX_SPLITALL_CRLF = /\r?\n/g; +// /foo, +// ./foo, +// ../foo, +// . +// .. +const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; - if (match === false) { - output = format ? format(input) : input; - match = output === glob; - } +const SLASH = '/'; +const KEY_IGNORE = typeof Symbol !== 'undefined' + ? Symbol.for('node-ignore') + /* istanbul ignore next */ + : 'node-ignore'; - if (match === false || opts.capture === true) { - if (opts.matchBase === true || opts.basename === true) { - match = picomatch$3.matchBase(input, regex, options, posix); - } else { - match = regex.exec(output); - } - } +const define = (object, key, value) => + Object.defineProperty(object, key, {value}); - return { isMatch: Boolean(match), match, output }; -}; +const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; -/** - * 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 - */ +// Sanitize the range of a regular expression +// The cases are complicated, see test cases for details +const sanitizeRange = range => range.replace( + REGEX_REGEXP_RANGE, + (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) + ? match + // Invalid range (out of order) which is ok for gitignore rules but + // fatal for JavaScript regular expression, so eliminate it. + : EMPTY +); -picomatch$3.matchBase = (input, glob, options, posix = utils$4.isWindows(options)) => { - const regex = glob instanceof RegExp ? glob : picomatch$3.makeRe(glob, options); - return regex.test(path$2.basename(input)); +// See fixtures #59 +const cleanRangeBackSlash = slashes => { + const {length} = slashes; + return slashes.slice(0, length - length % 2) }; -/** - * 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 - */ +// > If the pattern ends with a slash, +// > it is removed for the purpose of the following description, +// > but it would only find a match with a directory. +// > In other words, foo/ will match a directory foo and paths underneath it, +// > but will not match a regular file or a symbolic link foo +// > (this is consistent with the way how pathspec works in general in Git). +// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' +// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call +// you could use option `mark: true` with `glob` -picomatch$3.isMatch = (str, patterns, options) => picomatch$3(patterns, options)(str); +// '`foo/`' should not continue with the '`..`' +const REPLACERS = [ -/** - * 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 - */ + // > Trailing spaces are ignored unless they are quoted with backslash ("\") + [ + // (a\ ) -> (a ) + // (a ) -> (a) + // (a \ ) -> (a ) + /\\?\s+$/, + match => match.indexOf('\\') === 0 + ? SPACE + : EMPTY + ], -picomatch$3.parse = (pattern, options) => { - if (Array.isArray(pattern)) return pattern.map(p => picomatch$3.parse(p, options)); - return parse$7(pattern, { ...options, fastpaths: false }); -}; + // replace (\ ) with ' ' + [ + /\\\s/g, + () => SPACE + ], -/** - * 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 - */ + // Escape metacharacters + // which is written down by users but means special for regular expressions. -picomatch$3.scan = (input, options) => scan(input, options); + // > There are 12 characters with special meanings: + // > - the backslash \, + // > - the caret ^, + // > - the dollar sign $, + // > - the period or dot ., + // > - the vertical bar or pipe symbol |, + // > - the question mark ?, + // > - the asterisk or star *, + // > - the plus sign +, + // > - the opening parenthesis (, + // > - the closing parenthesis ), + // > - and the opening square bracket [, + // > - the opening curly brace {, + // > These special characters are often called "metacharacters". + [ + /[\\$.|*+(){^]/g, + match => `\\${match}` + ], -/** - * 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 - */ + [ + // > a question mark (?) matches a single character + /(?!\\)\?/g, + () => '[^/]' + ], -picomatch$3.compileRe = (state, options, returnOutput = false, returnState = false) => { - if (returnOutput === true) { - return state.output; - } + // leading slash + [ - const opts = options || {}; - const prepend = opts.contains ? '' : '^'; - const append = opts.contains ? '' : '$'; + // > A leading slash matches the beginning of the pathname. + // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". + // A leading slash matches the beginning of the pathname + /^\//, + () => '^' + ], - let source = `${prepend}(?:${state.output})${append}`; - if (state && state.negated === true) { - source = `^(?!${source}).*$`; - } + // replace special metacharacter slash after the leading slash + [ + /\//g, + () => '\\/' + ], - const regex = picomatch$3.toRegex(source, options); - if (returnState === true) { - regex.state = state; - } + [ + // > A leading "**" followed by a slash means match in all directories. + // > For example, "**/foo" matches file or directory "foo" anywhere, + // > the same as pattern "foo". + // > "**/foo/bar" matches file or directory "bar" anywhere that is directly + // > under directory "foo". + // Notice that the '*'s have been replaced as '\\*' + /^\^*\\\*\\\*\\\//, - return regex; -}; + // '**/foo' <-> 'foo' + () => '^(?:.*\\/)?' + ], -/** - * 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 - */ + // starting + [ + // there will be no leading '/' + // (which has been replaced by section "leading slash") + // If starts with '**', adding a '^' to the regular expression also works + /^(?=[^^])/, + function startingReplacer () { + // If has a slash `/` at the beginning or middle + return !/\/(?!$)/.test(this) + // > Prior to 2.22.1 + // > If the pattern does not contain a slash /, + // > Git treats it as a shell glob pattern + // Actually, if there is only a trailing slash, + // git also treats it as a shell glob pattern -picomatch$3.makeRe = (input, options = {}, returnOutput = false, returnState = false) => { - if (!input || typeof input !== 'string') { - throw new TypeError('Expected a non-empty string'); - } + // After 2.22.1 (compatible but clearer) + // > If there is a separator at the beginning or middle (or both) + // > of the pattern, then the pattern is relative to the directory + // > level of the particular .gitignore file itself. + // > Otherwise the pattern may also match at any level below + // > the .gitignore level. + ? '(?:^|\\/)' - let parsed = { negated: false, fastpaths: true }; + // > Otherwise, Git treats the pattern as a shell glob suitable for + // > consumption by fnmatch(3) + : '^' + } + ], - if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) { - parsed.output = parse$7.fastpaths(input, options); - } + // two globstars + [ + // Use lookahead assertions so that we could match more than one `'/**'` + /\\\/\\\*\\\*(?=\\\/|$)/g, - if (!parsed.output) { - parsed = parse$7(input, options); - } + // Zero, one or several directories + // should not use '*', or it will be replaced by the next replacer - return picomatch$3.compileRe(parsed, options, returnOutput, returnState); -}; + // Check if it is not the last `'/**'` + (_, index, str) => index + 6 < str.length -/** - * 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 - */ + // case: /**/ + // > A slash followed by two consecutive asterisks then a slash matches + // > zero or more directories. + // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. + // '/**/' + ? '(?:\\/[^\\/]+)*' -picomatch$3.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 /$^/; - } -}; + // case: /** + // > A trailing `"/**"` matches everything inside. -/** - * Picomatch constants. - * @return {Object} - */ + // #21: everything inside but it should not include the current folder + : '\\/.+' + ], -picomatch$3.constants = constants$3; + // intermediate wildcards + [ + // Never replace escaped '*' + // ignore rule '\*' will match the path '*' -/** - * Expose "picomatch" - */ + // 'abc.*/' -> go + // 'abc.*' -> skip this rule + /(^|[^\\]+)\\\*(?=.+)/g, -var picomatch_1 = picomatch$3; + // '*.js' matches '.js' + // '*.js' doesn't match 'abc' + (_, p1) => `${p1}[^\\/]*` + ], -var picomatch$2 = picomatch_1; + [ + // unescape, revert step 3 except for back slash + // For example, if a user escape a '\\*', + // after step 3, the result will be '\\\\\\*' + /\\\\\\(?=[$.|*+(){^])/g, + () => ESCAPE + ], -const fs$3 = require$$0__default$3['default']; -const { Readable } = require$$0__default$5['default']; -const sysPath$3 = require$$0__default$2['default']; -const { promisify: promisify$3 } = require$$0__default['default']; -const picomatch$1 = picomatch$2; + [ + // '\\\\' -> '\\' + /\\\\/g, + () => ESCAPE + ], -const readdir$1 = promisify$3(fs$3.readdir); -const stat$3 = promisify$3(fs$3.stat); -const lstat$2 = promisify$3(fs$3.lstat); -const realpath$1 = promisify$3(fs$3.realpath); + [ + // > The range notation, e.g. [a-zA-Z], + // > can be used to match one of the characters in a range. -/** - * @typedef {Object} EntryInfo - * @property {String} path - * @property {String} fullPath - * @property {fs.Stats=} stats - * @property {fs.Dirent=} dirent - * @property {String} basename - */ + // `\` is escaped by step 3 + /(\\)?\[([^\]/]*?)(\\*)($|\])/g, + (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE + // '\\[bar]' -> '\\\\[bar\\]' + ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` + : close === ']' + ? endEscape.length % 2 === 0 + // A normal case, and it is a range notation + // '[bar]' + // '[bar\\\\]' + ? `[${sanitizeRange(range)}${endEscape}]` + // Invalid range notaton + // '[bar\\]' -> '[bar\\\\]' + : '[]' + : '[]' + ], -const BANG$2 = '!'; -const RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR'; -const NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP', RECURSIVE_ERROR_CODE]); -const FILE_TYPE = 'files'; -const DIR_TYPE = 'directories'; -const FILE_DIR_TYPE = 'files_directories'; -const EVERYTHING_TYPE = 'all'; -const ALL_TYPES = [FILE_TYPE, DIR_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE]; - -const isNormalFlowError = error => NORMAL_FLOW_ERRORS.has(error.code); -const [maj, min] = process.versions.node.split('.').slice(0, 2).map(n => Number.parseInt(n, 10)); -const wantBigintFsStats = process.platform === 'win32' && (maj > 10 || (maj === 10 && min >= 5)); - -const normalizeFilter = filter => { - if (filter === undefined) return; - if (typeof filter === 'function') return filter; + // ending + [ + // 'js' will not match 'js.' + // 'ab' will not match 'abc' + /(?:[^*])$/, - if (typeof filter === 'string') { - const glob = picomatch$1(filter.trim()); - return entry => glob(entry.basename); - } + // WTF! + // https://git-scm.com/docs/gitignore + // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) + // which re-fixes #24, #38 - if (Array.isArray(filter)) { - const positive = []; - const negative = []; - for (const item of filter) { - const trimmed = item.trim(); - if (trimmed.charAt(0) === BANG$2) { - negative.push(picomatch$1(trimmed.slice(1))); - } else { - positive.push(picomatch$1(trimmed)); - } - } + // > If there is a separator at the end of the pattern then the pattern + // > will only match directories, otherwise the pattern can match both + // > files and directories. - if (negative.length > 0) { - if (positive.length > 0) { - return entry => - positive.some(f => f(entry.basename)) && !negative.some(f => f(entry.basename)); - } - return entry => !negative.some(f => f(entry.basename)); - } - return entry => positive.some(f => f(entry.basename)); - } -}; + // 'js*' will not match 'a.js' + // 'js/' will not match 'a.js' + // 'js' will match 'a.js' and 'a.js/' + match => /\/$/.test(match) + // foo/ will not match 'foo' + ? `${match}$` + // foo matches 'foo' and 'foo/' + : `${match}(?=$|\\/$)` + ], -class ReaddirpStream extends Readable { - static get defaultOptions() { - return { - root: '.', - /* eslint-disable no-unused-vars */ - fileFilter: (path) => true, - directoryFilter: (path) => true, - /* eslint-enable no-unused-vars */ - type: FILE_TYPE, - lstat: false, - depth: 2147483648, - alwaysStat: false - }; - } + // trailing wildcard + [ + /(\^|\\\/)?\\\*$/, + (_, p1) => { + const prefix = p1 + // '\^': + // '/*' does not match EMPTY + // '/*' does not match everything - constructor(options = {}) { - super({ - objectMode: true, - autoDestroy: true, - highWaterMark: options.highWaterMark || 4096 - }); - const opts = { ...ReaddirpStream.defaultOptions, ...options }; - const { root, type } = opts; + // '\\\/': + // 'abc/*' does not match 'abc/' + ? `${p1}[^/]+` - this._fileFilter = normalizeFilter(opts.fileFilter); - this._directoryFilter = normalizeFilter(opts.directoryFilter); + // 'a*' matches 'a' + // 'a*' matches 'aa' + : '[^/]*'; - const statMethod = opts.lstat ? lstat$2 : stat$3; - // Use bigint stats if it's windows and stat() supports options (node 10+). - if (wantBigintFsStats) { - this._stat = path => statMethod(path, { bigint: true }); - } else { - this._stat = statMethod; + return `${prefix}(?=$|\\/$)` } + ], +]; - this._maxDepth = opts.depth; - this._wantsDir = [DIR_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE].includes(type); - this._wantsFile = [FILE_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE].includes(type); - this._wantsEverything = type === EVERYTHING_TYPE; - this._root = sysPath$3.resolve(root); - this._isDirent = ('Dirent' in fs$3) && !opts.alwaysStat; - this._statsProp = this._isDirent ? 'dirent' : 'stats'; - this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent }; +// A simple cache, because an ignore rule only has only one certain meaning +const regexCache = Object.create(null); - // Launch stream with one parent, the root dir. - this.parents = [this._exploreDir(root, 1)]; - this.reading = false; - this.parent = undefined; +// @param {pattern} +const makeRegex = (pattern, negative, ignorecase) => { + const r = regexCache[pattern]; + if (r) { + return r } - async _read(batch) { - if (this.reading) return; - this.reading = true; - - try { - while (!this.destroyed && batch > 0) { - const { path, depth, files = [] } = this.parent || {}; + // const replacers = negative + // ? NEGATIVE_REPLACERS + // : POSITIVE_REPLACERS - if (files.length > 0) { - const slice = files.splice(0, batch).map(dirent => this._formatEntry(dirent, path)); - for (const entry of await Promise.all(slice)) { - if (this.destroyed) return; + const source = REPLACERS.reduce( + (prev, current) => prev.replace(current[0], current[1].bind(pattern)), + pattern + ); - const entryType = await this._getEntryType(entry); - if (entryType === 'directory' && this._directoryFilter(entry)) { - if (depth <= this._maxDepth) { - this.parents.push(this._exploreDir(entry.fullPath, depth + 1)); - } + return regexCache[pattern] = ignorecase + ? new RegExp(source, 'i') + : new RegExp(source) +}; - if (this._wantsDir) { - this.push(entry); - batch--; - } - } else if ((entryType === 'file' || this._includeAsFile(entry)) && this._fileFilter(entry)) { - if (this._wantsFile) { - this.push(entry); - batch--; - } - } - } - } else { - const parent = this.parents.pop(); - if (!parent) { - this.push(null); - break; - } - this.parent = await parent; - if (this.destroyed) return; - } - } - } catch (error) { - this.destroy(error); - } finally { - this.reading = false; - } - } +const isString = subject => typeof subject === 'string'; - async _exploreDir(path, depth) { - let files; - try { - files = await readdir$1(path, this._rdOptions); - } catch (error) { - this._onError(error); - } - return { files, depth, path }; - } +// > A blank line matches no files, so it can serve as a separator for readability. +const checkPattern = pattern => pattern + && isString(pattern) + && !REGEX_TEST_BLANK_LINE.test(pattern) - async _formatEntry(dirent, path) { - let entry; - try { - const basename = this._isDirent ? dirent.name : dirent; - const fullPath = sysPath$3.resolve(sysPath$3.join(path, basename)); - entry = { path: sysPath$3.relative(this._root, fullPath), fullPath, basename }; - entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath); - } catch (err) { - this._onError(err); - } - return entry; - } + // > A line starting with # serves as a comment. + && pattern.indexOf('#') !== 0; - _onError(err) { - if (isNormalFlowError(err) && !this.destroyed) { - this.emit('warn', err); - } else { - this.destroy(err); - } - } +const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF); - async _getEntryType(entry) { - // entry may be undefined, because a warning or an error were emitted - // and the statsProp is undefined - const stats = entry && entry[this._statsProp]; - if (!stats) { - return; - } - if (stats.isFile()) { - return 'file'; - } - if (stats.isDirectory()) { - return 'directory'; - } - if (stats && stats.isSymbolicLink()) { - const full = entry.fullPath; - try { - const entryRealPath = await realpath$1(full); - const entryRealPathStats = await lstat$2(entryRealPath); - if (entryRealPathStats.isFile()) { - return 'file'; - } - if (entryRealPathStats.isDirectory()) { - const len = entryRealPath.length; - if (full.startsWith(entryRealPath) && full.substr(len, 1) === sysPath$3.sep) { - const recursiveError = new Error( - `Circular symlink detected: "${full}" points to "${entryRealPath}"` - ); - recursiveError.code = RECURSIVE_ERROR_CODE; - return this._onError(recursiveError); - } - return 'directory'; - } - } catch (error) { - this._onError(error); - } - } +class IgnoreRule { + constructor ( + origin, + pattern, + negative, + regex + ) { + this.origin = origin; + this.pattern = pattern; + this.negative = negative; + this.regex = regex; } +} - _includeAsFile(entry) { - const stats = entry && entry[this._statsProp]; +const createRule = (pattern, ignorecase) => { + const origin = pattern; + let negative = false; - return stats && this._wantsEverything && !stats.isDirectory(); + // > An optional prefix "!" which negates the pattern; + if (pattern.indexOf('!') === 0) { + negative = true; + pattern = pattern.substr(1); } -} -/** - * @typedef {Object} ReaddirpArguments - * @property {Function=} fileFilter - * @property {Function=} directoryFilter - * @property {String=} type - * @property {Number=} depth - * @property {String=} root - * @property {Boolean=} lstat - * @property {Boolean=} bigint - */ + pattern = pattern + // > Put a backslash ("\") in front of the first "!" for patterns that + // > begin with a literal "!", for example, `"\!important!.txt"`. + .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') + // > Put a backslash ("\") in front of the first hash for patterns that + // > begin with a hash. + .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#'); -/** - * Main function which ends up calling readdirRec and reads all files and directories in given root recursively. - * @param {String} root Root directory - * @param {ReaddirpArguments=} options Options to specify root (start directory), filters and recursion depth - */ -const readdirp$1 = (root, options = {}) => { - let type = options.entryType || options.type; - if (type === 'both') type = FILE_DIR_TYPE; // backwards-compatibility - if (type) options.type = type; - if (!root) { - throw new Error('readdirp: root argument is required. Usage: readdirp(root, options)'); - } else if (typeof root !== 'string') { - throw new TypeError('readdirp: root argument must be a string. Usage: readdirp(root, options)'); - } else if (type && !ALL_TYPES.includes(type)) { - throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(', ')}`); - } + const regex = makeRegex(pattern, negative, ignorecase); - options.root = root; - return new ReaddirpStream(options); + return new IgnoreRule( + origin, + pattern, + negative, + regex + ) }; -const readdirpPromise = (root, options = {}) => { - return new Promise((resolve, reject) => { - const files = []; - readdirp$1(root, options) - .on('data', entry => files.push(entry)) - .on('end', () => resolve(files)) - .on('error', error => reject(error)); - }); +const throwError = (message, Ctor) => { + throw new Ctor(message) }; -readdirp$1.promise = readdirpPromise; -readdirp$1.ReaddirpStream = ReaddirpStream; -readdirp$1.default = readdirp$1; - -var readdirp_1 = readdirp$1; - -var anymatch$2 = {exports: {}}; - -/*! - * normalize-path - * - * Copyright (c) 2014-2018, Jon Schlinkert. - * Released under the MIT License. - */ - -var normalizePath$2 = function(path, stripTrailing) { - if (typeof path !== 'string') { - throw new TypeError('expected path to be a string'); +const checkPath = (path, originalPath, doThrow) => { + if (!isString(path)) { + return doThrow( + `path must be a string, but got \`${originalPath}\``, + TypeError + ) } - if (path === '\\' || path === '/') return '/'; - - var len = path.length; - if (len <= 1) return path; - - // ensure that win32 namespaces has two leading slashes, so that the path is - // handled properly by the win32 version of path.parse() after being normalized - // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces - var prefix = ''; - if (len > 4 && path[3] === '\\') { - var ch = path[2]; - if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') { - path = path.slice(2); - prefix = '//'; - } + // We don't know if we should ignore EMPTY, so throw + if (!path) { + return doThrow(`path must not be empty`, TypeError) } - var segs = path.split(/[/\\]+/); - if (stripTrailing !== false && segs[segs.length - 1] === '') { - segs.pop(); + // Check if it is a relative path + if (checkPath.isNotRelative(path)) { + const r = '`path.relative()`d'; + return doThrow( + `path should be a ${r} string, but got "${originalPath}"`, + RangeError + ) } - return prefix + segs.join('/'); -}; -Object.defineProperty(anymatch$2.exports, "__esModule", { value: true }); + return true +}; -const picomatch = picomatch$2; -const normalizePath$1 = normalizePath$2; +const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path); -/** - * @typedef {(testString: string) => boolean} AnymatchFn - * @typedef {string|RegExp|AnymatchFn} AnymatchPattern - * @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher - */ -const BANG$1 = '!'; -const DEFAULT_OPTIONS = {returnIndex: false}; -const arrify$1 = (item) => Array.isArray(item) ? item : [item]; +checkPath.isNotRelative = isNotRelative; +checkPath.convert = p => p; -/** - * @param {AnymatchPattern} matcher - * @param {object} options - * @returns {AnymatchFn} - */ -const createPattern = (matcher, options) => { - if (typeof matcher === 'function') { - return matcher; - } - if (typeof matcher === 'string') { - const glob = picomatch(matcher, options); - return (string) => matcher === string || glob(string); - } - if (matcher instanceof RegExp) { - return (string) => matcher.test(string); +class Ignore$1 { + constructor ({ + ignorecase = true + } = {}) { + this._rules = []; + this._ignorecase = ignorecase; + define(this, KEY_IGNORE, true); + this._initCache(); } - return (string) => false; -}; -/** - * @param {Array} patterns - * @param {Array} negPatterns - * @param {String|Array} args - * @param {Boolean} returnIndex - * @returns {boolean|number} - */ -const matchPatterns = (patterns, negPatterns, args, returnIndex) => { - const isList = Array.isArray(args); - const _path = isList ? args[0] : args; - if (!isList && typeof _path !== 'string') { - throw new TypeError('anymatch: second argument must be a string: got ' + - Object.prototype.toString.call(_path)) + _initCache () { + this._ignoreCache = Object.create(null); + this._testCache = Object.create(null); } - const path = normalizePath$1(_path); - for (let index = 0; index < negPatterns.length; index++) { - const nglob = negPatterns[index]; - if (nglob(path)) { - return returnIndex ? -1 : false; + _addPattern (pattern) { + // #32 + if (pattern && pattern[KEY_IGNORE]) { + this._rules = this._rules.concat(pattern._rules); + this._added = true; + return } - } - const applied = isList && [path].concat(args.slice(1)); - for (let index = 0; index < patterns.length; index++) { - const pattern = patterns[index]; - if (isList ? pattern(...applied) : pattern(path)) { - return returnIndex ? index : true; + if (checkPattern(pattern)) { + const rule = createRule(pattern, this._ignorecase); + this._added = true; + this._rules.push(rule); } } - return returnIndex ? -1 : false; -}; - -/** - * @param {AnymatchMatcher} matchers - * @param {Array|string} testString - * @param {object} options - * @returns {boolean|number|Function} - */ -const anymatch$1 = (matchers, testString, options = DEFAULT_OPTIONS) => { - if (matchers == null) { - throw new TypeError('anymatch: specify first argument'); - } - const opts = typeof options === 'boolean' ? {returnIndex: options} : options; - const returnIndex = opts.returnIndex || false; + // @param {Array | string | Ignore} pattern + add (pattern) { + this._added = false; - // Early cache for matchers. - const mtchers = arrify$1(matchers); - const negatedGlobs = mtchers - .filter(item => typeof item === 'string' && item.charAt(0) === BANG$1) - .map(item => item.slice(1)) - .map(item => picomatch(item, opts)); - const patterns = mtchers - .filter(item => typeof item !== 'string' || (typeof item === 'string' && item.charAt(0) !== BANG$1)) - .map(matcher => createPattern(matcher, opts)); + makeArray( + isString(pattern) + ? splitPattern(pattern) + : pattern + ).forEach(this._addPattern, this); - if (testString == null) { - return (testString, ri = false) => { - const returnIndex = typeof ri === 'boolean' ? ri : false; - return matchPatterns(patterns, negatedGlobs, testString, returnIndex); + // Some rules have just added to the ignore, + // making the behavior changed. + if (this._added) { + this._initCache(); } + + return this } - return matchPatterns(patterns, negatedGlobs, testString, returnIndex); -}; + // legacy + addPattern (pattern) { + return this.add(pattern) + } -anymatch$1.default = anymatch$1; -anymatch$2.exports = anymatch$1; + // | ignored : unignored + // negative | 0:0 | 0:1 | 1:0 | 1:1 + // -------- | ------- | ------- | ------- | -------- + // 0 | TEST | TEST | SKIP | X + // 1 | TESTIF | SKIP | TEST | X -/*! - * is-extglob - * - * Copyright (c) 2014-2016, Jon Schlinkert. - * Licensed under the MIT License. - */ + // - SKIP: always skip + // - TEST: always test + // - TESTIF: only test if checkUnignored + // - X: that never happen -var isExtglob$1 = function isExtglob(str) { - if (typeof str !== 'string' || str === '') { - return false; - } + // @param {boolean} whether should check if the path is unignored, + // setting `checkUnignored` to `false` could reduce additional + // path matching. - var match; - while ((match = /(\\).|([@?!+*]\(.*\))/g.exec(str))) { - if (match[2]) return true; - str = str.slice(match.index + match[0].length); - } + // @returns {TestResult} true if a file is ignored + _testOne (path, checkUnignored) { + let ignored = false; + let unignored = false; - return false; -}; + this._rules.forEach(rule => { + const {negative} = rule; + if ( + unignored === negative && ignored !== unignored + || negative && !ignored && !unignored && !checkUnignored + ) { + return + } -/*! - * is-glob - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ + const matched = rule.regex.test(path); -var isExtglob = isExtglob$1; -var chars = { '{': '}', '(': ')', '[': ']'}; -var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; -var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/; + if (matched) { + ignored = !negative; + unignored = negative; + } + }); -var isGlob$2 = function isGlob(str, options) { - if (typeof str !== 'string' || str === '') { - return false; + return { + ignored, + unignored + } } - if (isExtglob(str)) { - return true; - } + // @returns {TestResult} + _test (originalPath, cache, checkUnignored, slices) { + const path = originalPath + // Supports nullable path + && checkPath.convert(originalPath); - var regex = strictRegex; - var match; + checkPath(path, originalPath, throwError); - // optionally relax regex - if (options && options.strict === false) { - regex = relaxedRegex; + return this._t(path, cache, checkUnignored, slices) } - while ((match = regex.exec(str))) { - if (match[2]) return true; - var idx = match.index + match[0].length; - - // if an open bracket/brace/paren is escaped, - // set the index to the next closing character - var open = match[1]; - var close = open ? chars[open] : null; - if (open && close) { - var n = str.indexOf(close, idx); - if (n !== -1) { - idx = n + 1; - } + _t (path, cache, checkUnignored, slices) { + if (path in cache) { + return cache[path] } - str = str.slice(idx); - } - return false; -}; + if (!slices) { + // path/to/a.js + // ['path', 'to', 'a.js'] + slices = path.split(SLASH); + } -var isGlob$1 = isGlob$2; -var pathPosixDirname = require$$0__default$2['default'].posix.dirname; -var isWin32 = require$$0__default$1['default'].platform() === 'win32'; + slices.pop(); -var slash = '/'; -var backslash = /\\/g; -var enclosure = /[\{\[].*[\}\]]$/; -var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/; -var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g; + // If the path has no parent directory, just test it + if (!slices.length) { + return cache[path] = this._testOne(path, checkUnignored) + } -/** - * @param {string} str - * @param {Object} opts - * @param {boolean} [opts.flipBackslashes=true] - * @returns {string} - */ -var globParent$1 = function globParent(str, opts) { - var options = Object.assign({ flipBackslashes: true }, opts); + const parent = this._t( + slices.join(SLASH) + SLASH, + cache, + checkUnignored, + slices + ); - // flip windows path separators - if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) { - str = str.replace(backslash, slash); + // If the path contains a parent directory, check the parent first + return cache[path] = parent.ignored + // > It is not possible to re-include a file if a parent directory of + // > that file is excluded. + ? parent + : this._testOne(path, checkUnignored) } - // special case for strings ending in enclosure containing path separator - if (enclosure.test(str)) { - str += slash; + ignores (path) { + return this._test(path, this._ignoreCache, false).ignored } - // preserves full path in case of trailing path separator - str += 'a'; - - // remove path parts that are globby - do { - str = pathPosixDirname(str); - } while (isGlob$1(str) || globby.test(str)); - - // remove escape chars and return result - return str.replace(escaped, '$1'); -}; - -var utils$3 = {}; - -(function (exports) { + createFilter () { + return path => !this.ignores(path) + } -exports.isInteger = num => { - if (typeof num === 'number') { - return Number.isInteger(num); + filter (paths) { + return makeArray(paths).filter(this.createFilter()) } - if (typeof num === 'string' && num.trim() !== '') { - return Number.isInteger(Number(num)); + + // @returns {TestResult} + test (path) { + return this._test(path, this._testCache, true) } - return false; -}; +} -/** - * Find a node of the given type - */ +const factory$1 = options => new Ignore$1(options); -exports.find = (node, type) => node.nodes.find(node => node.type === type); +const returnFalse = () => false; -/** - * Find a node of the given type - */ +const isPathValid = path => + checkPath(path && checkPath.convert(path), path, returnFalse); -exports.exceedsLimit = (min, max, step = 1, limit) => { - if (limit === false) return false; - if (!exports.isInteger(min) || !exports.isInteger(max)) return false; - return ((Number(max) - Number(min)) / Number(step)) >= limit; -}; +factory$1.isPathValid = isPathValid; -/** - * Escape the given node with '\\' before node.value - */ +// Fixes typescript +factory$1.default = factory$1; -exports.escapeNode = (block, n = 0, type) => { - let node = block.nodes[n]; - if (!node) return; +var ignore = factory$1; - if ((type && node.type === type) || node.type === 'open' || node.type === 'close') { - if (node.escaped !== true) { - node.value = '\\' + node.value; - node.escaped = true; - } - } -}; +// Windows +// -------------------------------------------------------------- +/* istanbul ignore if */ +if ( + // Detect `process` so that it can run in browsers. + typeof process !== 'undefined' + && ( + process.env && process.env.IGNORE_TEST_WIN32 + || process.platform === 'win32' + ) +) { + /* eslint no-control-regex: "off" */ + const makePosix = str => /^\\\\\?\\/.test(str) + || /["<>|\u0000-\u001F]+/u.test(str) + ? str + : str.replace(/\\/g, '/'); -/** - * Returns true if the given brace node should be enclosed in literal braces - */ + checkPath.convert = makePosix; -exports.encloseBrace = node => { - if (node.type !== 'brace') return false; - if ((node.commas >> 0 + node.ranges >> 0) === 0) { - node.invalid = true; - return true; - } - return false; -}; + // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/' + // 'd:\\foo' + const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; + checkPath.isNotRelative = path => + REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) + || isNotRelative(path); +} /** - * Returns true if a brace node is invalid. + * @typedef {import('ignore').Ignore & {filePath: string}} IgnoreConfig + * + * @typedef {'cwd'|'dir'} ResolveFrom + * + * @typedef Options + * @property {string} cwd + * @property {boolean|undefined} detectIgnore + * @property {string|undefined} ignoreName + * @property {string|undefined} ignorePath + * @property {ResolveFrom|undefined} ignorePathResolveFrom + * + * @callback Callback + * @param {Error|null} error + * @param {boolean|undefined} [result] */ -exports.isInvalidBrace = block => { - if (block.type !== 'brace') return false; - if (block.invalid === true || block.dollar) return true; - if ((block.commas >> 0 + block.ranges >> 0) === 0) { - block.invalid = true; - return true; - } - if (block.open !== true || block.close !== true) { - block.invalid = true; - return true; +class Ignore { + /** + * @param {Options} options + */ + constructor(options) { + /** @type {string} */ + this.cwd = options.cwd; + /** @type {ResolveFrom|undefined} */ + this.ignorePathResolveFrom = options.ignorePathResolveFrom; + + /** @type {FindUp} */ + this.findUp = new FindUp({ + cwd: options.cwd, + filePath: options.ignorePath, + detect: options.detectIgnore, + names: options.ignoreName ? [options.ignoreName] : [], + create + }); } - return false; -}; -/** - * Returns true if a node is an open or close node - */ + /** + * @param {string} filePath + * @param {Callback} callback + */ + check(filePath, callback) { + this.findUp.load(filePath, (error, ignoreSet) => { + if (error) { + callback(error); + } else if (ignoreSet) { + const normal = path__default$1['default'].relative( + path__default$1['default'].resolve( + this.cwd, + this.ignorePathResolveFrom === 'cwd' ? '.' : ignoreSet.filePath + ), + path__default$1['default'].resolve(this.cwd, filePath) + ); -exports.isOpenOrClose = node => { - if (node.type === 'open' || node.type === 'close') { - return true; + if ( + normal === '' || + normal === '..' || + normal.charAt(0) === path__default$1['default'].sep || + normal.slice(0, 3) === '..' + path__default$1['default'].sep + ) { + callback(null, false); + } else { + callback(null, ignoreSet.ignores(normal)); + } + } else { + callback(null, false); + } + }); } - return node.open === true || node.close === true; -}; +} /** - * Reduce an array of text nodes. + * @param {Buffer} buf + * @param {string} filePath + * @returns {IgnoreConfig} */ +function create(buf, filePath) { + /** @type {IgnoreConfig} */ + return Object.assign(ignore().add(String(buf)), { + filePath: path__default$1['default'].dirname(filePath) + }) +} -exports.reduce = nodes => nodes.reduce((acc, node) => { - if (node.type === 'text') acc.push(node.value); - if (node.type === 'range') node.type = 'text'; - return acc; -}, []); +var old$1 = {}; -/** - * Flatten an array - */ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -exports.flatten = (...args) => { - const result = []; - const flat = arr => { - for (let i = 0; i < arr.length; i++) { - let ele = arr[i]; - Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele); - } - return result; - }; - flat(args); - return result; -}; -}(utils$3)); +var pathModule = path__default['default']; +var isWindows = process.platform === 'win32'; +var fs$3 = require$$0__default$1['default']; -const utils$2 = utils$3; +// JavaScript implementation of realpath, ported from node pre-v6 -var stringify$8 = (ast, options = {}) => { - let stringify = (node, parent = {}) => { - let invalidBlock = options.escapeInvalid && utils$2.isInvalidBrace(parent); - let invalidNode = node.invalid === true && options.escapeInvalid === true; - let output = ''; +var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); - if (node.value) { - if ((invalidBlock || invalidNode) && utils$2.isOpenOrClose(node)) { - return '\\' + node.value; - } - return node.value; - } +function rethrow() { + // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and + // is fairly slow to generate. + var callback; + if (DEBUG) { + var backtrace = new Error; + callback = debugCallback; + } else + callback = missingCallback; - if (node.value) { - return node.value; + return callback; + + function debugCallback(err) { + if (err) { + backtrace.message = err.message; + err = backtrace; + missingCallback(err); } + } - if (node.nodes) { - for (let child of node.nodes) { - output += stringify(child); + function missingCallback(err) { + if (err) { + if (process.throwDeprecation) + throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs + else if (!process.noDeprecation) { + var msg = 'fs: missing callback ' + (err.stack || err.message); + if (process.traceDeprecation) + console.trace(msg); + else + console.error(msg); } } - return output; - }; + } +} - return stringify(ast); -}; +function maybeCallback(cb) { + return typeof cb === 'function' ? cb : rethrow(); +} -/*! - * is-number - * - * Copyright (c) 2014-present, Jon Schlinkert. - * Released under the MIT License. - */ +pathModule.normalize; -var isNumber$3 = function(num) { - if (typeof num === 'number') { - return num - num === 0; - } - if (typeof num === 'string' && num.trim() !== '') { - return Number.isFinite ? Number.isFinite(+num) : isFinite(+num); - } - return false; -}; +// Regexp that finds the next partion of a (partial) path +// result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] +if (isWindows) { + var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; +} else { + var nextPartRe = /(.*?)(?:[\/]+|$)/g; +} -/*! - * to-regex-range - * - * Copyright (c) 2015-present, Jon Schlinkert. - * Released under the MIT License. - */ +// Regex to find the device root, including trailing slash. E.g. 'c:\\'. +if (isWindows) { + var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; +} else { + var splitRootRe = /^[\/]*/; +} -const isNumber$2 = isNumber$3; +old$1.realpathSync = function realpathSync(p, cache) { + // make p is absolute + p = pathModule.resolve(p); -const toRegexRange$1 = (min, max, options) => { - if (isNumber$2(min) === false) { - throw new TypeError('toRegexRange: expected the first argument to be a number'); + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return cache[p]; } - if (max === void 0 || min === max) { - return String(min); - } + var original = p, + seenLinks = {}, + knownHard = {}; - if (isNumber$2(max) === false) { - throw new TypeError('toRegexRange: expected the second argument to be a number.'); - } + // current character position in p + var pos; + // the partial path so far, including a trailing slash if any + var current; + // the partial path without a trailing slash (except when pointing at a root) + var base; + // the partial path scanned in the previous round, with slash + var previous; - let opts = { relaxZeros: true, ...options }; - if (typeof opts.strictZeros === 'boolean') { - opts.relaxZeros = opts.strictZeros === false; - } + start(); - let relax = String(opts.relaxZeros); - let shorthand = String(opts.shorthand); - let capture = String(opts.capture); - let wrap = String(opts.wrap); - let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap; + function start() { + // Skip over roots + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; - if (toRegexRange$1.cache.hasOwnProperty(cacheKey)) { - return toRegexRange$1.cache[cacheKey].result; + // On windows, check that the root exists. On unix there is no need. + if (isWindows && !knownHard[base]) { + fs$3.lstatSync(base); + knownHard[base] = true; + } } - let a = Math.min(min, max); - let b = Math.max(min, max); + // walk down the path, swapping out linked pathparts for their real + // values + // NB: p.length changes. + while (pos < p.length) { + // find the next part + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; - if (Math.abs(a - b) === 1) { - let result = min + '|' + max; - if (opts.capture) { - return `(${result})`; - } - if (opts.wrap === false) { - return result; + // continue if not a symlink + if (knownHard[base] || (cache && cache[base] === base)) { + continue; } - return `(?:${result})`; - } - let isPadded = hasPadding(min) || hasPadding(max); - let state = { min, max, a, b }; - let positives = []; - let negatives = []; + var resolvedLink; + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + // some known symbolic link. no need to stat again. + resolvedLink = cache[base]; + } else { + var stat = fs$3.lstatSync(base); + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + continue; + } - if (isPadded) { - state.isPadded = isPadded; - state.maxLen = String(state.max).length; + // read the link if it wasn't read before + // dev/ino always return 0 on windows, so skip the check. + var linkTarget = null; + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + if (seenLinks.hasOwnProperty(id)) { + linkTarget = seenLinks[id]; + } + } + if (linkTarget === null) { + fs$3.statSync(base); + linkTarget = fs$3.readlinkSync(base); + } + resolvedLink = pathModule.resolve(previous, linkTarget); + // track this, if given a cache. + if (cache) cache[base] = resolvedLink; + if (!isWindows) seenLinks[id] = linkTarget; + } + + // resolve the link, then start over + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); } - if (a < 0) { - let newMin = b < 0 ? Math.abs(b) : 1; - negatives = splitToPatterns(newMin, Math.abs(a), state, opts); - a = state.a = 0; - } + if (cache) cache[original] = p; - if (b >= 0) { - positives = splitToPatterns(a, b, state, opts); + return p; +}; + + +old$1.realpath = function realpath(p, cache, cb) { + if (typeof cb !== 'function') { + cb = maybeCallback(cache); + cache = null; } - state.negatives = negatives; - state.positives = positives; - state.result = collatePatterns(negatives, positives); + // make p is absolute + p = pathModule.resolve(p); - if (opts.capture === true) { - state.result = `(${state.result})`; - } else if (opts.wrap !== false && (positives.length + negatives.length) > 1) { - state.result = `(?:${state.result})`; + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return process.nextTick(cb.bind(null, null, cache[p])); } - toRegexRange$1.cache[cacheKey] = state; - return state.result; -}; + var original = p, + seenLinks = {}, + knownHard = {}; -function collatePatterns(neg, pos, options) { - let onlyNegative = filterPatterns(neg, pos, '-', false) || []; - let onlyPositive = filterPatterns(pos, neg, '', false) || []; - let intersected = filterPatterns(neg, pos, '-?', true) || []; - let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive); - return subpatterns.join('|'); -} + // current character position in p + var pos; + // the partial path so far, including a trailing slash if any + var current; + // the partial path without a trailing slash (except when pointing at a root) + var base; + // the partial path scanned in the previous round, with slash + var previous; -function splitToRanges(min, max) { - let nines = 1; - let zeros = 1; + start(); - let stop = countNines(min, nines); - let stops = new Set([max]); + function start() { + // Skip over roots + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; - while (min <= stop && stop <= max) { - stops.add(stop); - nines += 1; - stop = countNines(min, nines); + // On windows, check that the root exists. On unix there is no need. + if (isWindows && !knownHard[base]) { + fs$3.lstat(base, function(err) { + if (err) return cb(err); + knownHard[base] = true; + LOOP(); + }); + } else { + process.nextTick(LOOP); + } } - stop = countZeros(max + 1, zeros) - 1; + // walk down the path, swapping out linked pathparts for their real + // values + function LOOP() { + // stop if scanned past end of path + if (pos >= p.length) { + if (cache) cache[original] = p; + return cb(null, p); + } - while (min < stop && stop <= max) { - stops.add(stop); - zeros += 1; - stop = countZeros(max + 1, zeros) - 1; - } + // find the next part + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; - stops = [...stops]; - stops.sort(compare$2); - return stops; -} + // continue if not a symlink + if (knownHard[base] || (cache && cache[base] === base)) { + return process.nextTick(LOOP); + } -/** - * Convert a range to a regex pattern - * @param {Number} `start` - * @param {Number} `stop` - * @return {String} - */ + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + // known symbolic link. no need to stat again. + return gotResolvedLink(cache[base]); + } -function rangeToPattern(start, stop, options) { - if (start === stop) { - return { pattern: start, count: [], digits: 0 }; + return fs$3.lstat(base, gotStat); } - let zipped = zip(start, stop); - let digits = zipped.length; - let pattern = ''; - let count = 0; + function gotStat(err, stat) { + if (err) return cb(err); - for (let i = 0; i < digits; i++) { - let [startDigit, stopDigit] = zipped[i]; + // if not a symlink, skip to the next path part + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + return process.nextTick(LOOP); + } - if (startDigit === stopDigit) { - pattern += startDigit; + // stat & read the link if not read before + // call gotTarget as soon as the link target is known + // dev/ino always return 0 on windows, so skip the check. + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + if (seenLinks.hasOwnProperty(id)) { + return gotTarget(null, seenLinks[id], base); + } + } + fs$3.stat(base, function(err) { + if (err) return cb(err); - } else if (startDigit !== '0' || stopDigit !== '9') { - pattern += toCharacterClass(startDigit, stopDigit); + fs$3.readlink(base, function(err, target) { + if (!isWindows) seenLinks[id] = target; + gotTarget(err, target); + }); + }); + } - } else { - count++; - } + function gotTarget(err, target, base) { + if (err) return cb(err); + + var resolvedLink = pathModule.resolve(previous, target); + if (cache) cache[base] = resolvedLink; + gotResolvedLink(resolvedLink); } - if (count) { - pattern += options.shorthand === true ? '\\d' : '[0-9]'; + function gotResolvedLink(resolvedLink) { + // resolve the link, then start over + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); } +}; - return { pattern, count: [count], digits }; -} +var fs_realpath = realpath; +realpath.realpath = realpath; +realpath.sync = realpathSync; +realpath.realpathSync = realpathSync; +realpath.monkeypatch = monkeypatch; +realpath.unmonkeypatch = unmonkeypatch; -function splitToPatterns(min, max, tok, options) { - let ranges = splitToRanges(min, max); - let tokens = []; - let start = min; - let prev; +var fs$2 = require$$0__default$1['default']; +var origRealpath = fs$2.realpath; +var origRealpathSync = fs$2.realpathSync; - for (let i = 0; i < ranges.length; i++) { - let max = ranges[i]; - let obj = rangeToPattern(String(start), String(max), options); - let zeros = ''; +var version$2 = process.version; +var ok$1 = /^v[0-5]\./.test(version$2); +var old = old$1; - if (!tok.isPadded && prev && prev.pattern === obj.pattern) { - if (prev.count.length > 1) { - prev.count.pop(); - } +function newError (er) { + return er && er.syscall === 'realpath' && ( + er.code === 'ELOOP' || + er.code === 'ENOMEM' || + er.code === 'ENAMETOOLONG' + ) +} - prev.count.push(obj.count[0]); - prev.string = prev.pattern + toQuantifier(prev.count); - start = max + 1; - continue; - } +function realpath (p, cache, cb) { + if (ok$1) { + return origRealpath(p, cache, cb) + } - if (tok.isPadded) { - zeros = padZeros(max, tok, options); + if (typeof cache === 'function') { + cb = cache; + cache = null; + } + origRealpath(p, cache, function (er, result) { + if (newError(er)) { + old.realpath(p, cache, cb); + } else { + cb(er, result); } + }); +} - obj.string = zeros + obj.pattern + toQuantifier(obj.count); - tokens.push(obj); - start = max + 1; - prev = obj; +function realpathSync (p, cache) { + if (ok$1) { + return origRealpathSync(p, cache) } - return tokens; + try { + return origRealpathSync(p, cache) + } catch (er) { + if (newError(er)) { + return old.realpathSync(p, cache) + } else { + throw er + } + } } -function filterPatterns(arr, comparison, prefix, intersection, options) { - let result = []; +function monkeypatch () { + fs$2.realpath = realpath; + fs$2.realpathSync = realpathSync; +} - for (let ele of arr) { - let { string } = ele; +function unmonkeypatch () { + fs$2.realpath = origRealpath; + fs$2.realpathSync = origRealpathSync; +} - // only push if _both_ are negative... - if (!intersection && !contains(comparison, 'string', string)) { - result.push(prefix + string); +var concatMap$1 = function (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i); + if (isArray$1(x)) res.push.apply(res, x); + else res.push(x); } + return res; +}; - // or _both_ are positive - if (intersection && contains(comparison, 'string', string)) { - result.push(prefix + string); - } - } - return result; -} +var isArray$1 = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; -/** - * Zip strings - */ +var balancedMatch = balanced$1; +function balanced$1(a, b, str) { + if (a instanceof RegExp) a = maybeMatch(a, str); + if (b instanceof RegExp) b = maybeMatch(b, str); -function zip(a, b) { - let arr = []; - for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]); - return arr; -} + var r = range(a, b, str); -function compare$2(a, b) { - return a > b ? 1 : b > a ? -1 : 0; + return r && { + start: r[0], + end: r[1], + pre: str.slice(0, r[0]), + body: str.slice(r[0] + a.length, r[1]), + post: str.slice(r[1] + b.length) + }; } -function contains(arr, key, val) { - return arr.some(ele => ele[key] === val); +function maybeMatch(reg, str) { + var m = str.match(reg); + return m ? m[0] : null; } -function countNines(min, len) { - return Number(String(min).slice(0, -len) + '9'.repeat(len)); -} +balanced$1.range = range; +function range(a, b, str) { + var begs, beg, left, right, result; + var ai = str.indexOf(a); + var bi = str.indexOf(b, ai + 1); + var i = ai; -function countZeros(integer, zeros) { - return integer - (integer % Math.pow(10, zeros)); -} + if (ai >= 0 && bi > 0) { + begs = []; + left = str.length; -function toQuantifier(digits) { - let [start = 0, stop = ''] = digits; - if (stop || start > 1) { - return `{${start + (stop ? ',' + stop : '')}}`; + while (i >= 0 && !result) { + if (i == ai) { + begs.push(i); + ai = str.indexOf(a, i + 1); + } else if (begs.length == 1) { + result = [ begs.pop(), bi ]; + } else { + beg = begs.pop(); + if (beg < left) { + left = beg; + right = bi; + } + + bi = str.indexOf(b, i + 1); + } + + i = ai < bi && ai >= 0 ? ai : bi; + } + + if (begs.length) { + result = [ left, right ]; + } } - return ''; -} -function toCharacterClass(a, b, options) { - return `[${a}${(b - a === 1) ? '' : '-'}${b}]`; + return result; } -function hasPadding(str) { - return /^-?(0+)\d/.test(str); -} +var concatMap = concatMap$1; +var balanced = balancedMatch; -function padZeros(value, tok, options) { - if (!tok.isPadded) { - return value; - } +var braceExpansion = expandTop; - let diff = Math.abs(tok.maxLen - String(value).length); - let relax = options.relaxZeros !== false; +var escSlash = '\0SLASH'+Math.random()+'\0'; +var escOpen = '\0OPEN'+Math.random()+'\0'; +var escClose = '\0CLOSE'+Math.random()+'\0'; +var escComma = '\0COMMA'+Math.random()+'\0'; +var escPeriod = '\0PERIOD'+Math.random()+'\0'; - switch (diff) { - case 0: - return ''; - case 1: - return relax ? '0?' : '0'; - case 2: - return relax ? '0{0,2}' : '00'; - default: { - return relax ? `0{0,${diff}}` : `0{${diff}}`; - } - } +function numeric(str) { + return parseInt(str, 10) == str + ? parseInt(str, 10) + : str.charCodeAt(0); } -/** - * Cache - */ +function escapeBraces(str) { + return str.split('\\\\').join(escSlash) + .split('\\{').join(escOpen) + .split('\\}').join(escClose) + .split('\\,').join(escComma) + .split('\\.').join(escPeriod); +} -toRegexRange$1.cache = {}; -toRegexRange$1.clearCache = () => (toRegexRange$1.cache = {}); +function unescapeBraces(str) { + return str.split(escSlash).join('\\') + .split(escOpen).join('{') + .split(escClose).join('}') + .split(escComma).join(',') + .split(escPeriod).join('.'); +} -/** - * Expose `toRegexRange` - */ -var toRegexRange_1 = toRegexRange$1; +// Basically just str.split(","), but handling cases +// where we have nested braced sections, which should be +// treated as individual members, like {a,{b,c},d} +function parseCommaParts(str) { + if (!str) + return ['']; -/*! - * fill-range - * - * Copyright (c) 2014-present, Jon Schlinkert. - * Licensed under the MIT License. - */ + var parts = []; + var m = balanced('{', '}', str); -const util$1 = require$$0__default['default']; -const toRegexRange = toRegexRange_1; + if (!m) + return str.split(','); -const isObject$2 = val => val !== null && typeof val === 'object' && !Array.isArray(val); + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); -const transform = toNumber => { - return value => toNumber === true ? Number(value) : String(value); -}; + p[p.length-1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + if (post.length) { + p[p.length-1] += postParts.shift(); + p.push.apply(p, postParts); + } -const isValidValue = value => { - return typeof value === 'number' || (typeof value === 'string' && value !== ''); -}; + parts.push.apply(parts, p); -const isNumber$1 = num => Number.isInteger(+num); + return parts; +} -const zeros = input => { - let value = `${input}`; - let index = -1; - if (value[0] === '-') value = value.slice(1); - if (value === '0') return false; - while (value[++index] === '0'); - return index > 0; -}; +function expandTop(str) { + if (!str) + return []; -const stringify$7 = (start, end, options) => { - if (typeof start === 'string' || typeof end === 'string') { - return true; + // I don't know why Bash 4.3 does this, but it does. + // Anything starting with {} will have the first two bytes preserved + // but *only* at the top level, so {},a}b will not expand to anything, + // but a{},b}c will be expanded to [a}c,abc]. + // One could argue that this is a bug in Bash, but since the goal of + // this module is to match Bash's rules, we escape a leading {} + if (str.substr(0, 2) === '{}') { + str = '\\{\\}' + str.substr(2); } - return options.stringify === true; -}; -const pad = (input, maxLength, toNumber) => { - if (maxLength > 0) { - let dash = input[0] === '-' ? '-' : ''; - if (dash) input = input.slice(1); - input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0')); - } - if (toNumber === false) { - return String(input); - } - return input; -}; + return expand$2(escapeBraces(str), true).map(unescapeBraces); +} -const toMaxLen = (input, maxLength) => { - let negative = input[0] === '-' ? '-' : ''; - if (negative) { - input = input.slice(1); - maxLength--; - } - while (input.length < maxLength) input = '0' + input; - return negative ? ('-' + input) : input; -}; +function embrace(str) { + return '{' + str + '}'; +} +function isPadded(el) { + return /^-?0\d/.test(el); +} -const toSequence = (parts, options) => { - parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); - parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); +function lte(i, y) { + return i <= y; +} +function gte(i, y) { + return i >= y; +} - let prefix = options.capture ? '' : '?:'; - let positives = ''; - let negatives = ''; - let result; +function expand$2(str, isTop) { + var expansions = []; - if (parts.positives.length) { - positives = parts.positives.join('|'); - } + var m = balanced('{', '}', str); + if (!m || /\$$/.test(m.pre)) return [str]; - if (parts.negatives.length) { - negatives = `-(${prefix}${parts.negatives.join('|')})`; + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); + var isSequence = isNumericSequence || isAlphaSequence; + var isOptions = m.body.indexOf(',') >= 0; + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand$2(str); + } + return [str]; } - if (positives && negatives) { - result = `${positives}|${negatives}`; + var n; + if (isSequence) { + n = m.body.split(/\.\./); } else { - result = positives || negatives; + n = parseCommaParts(m.body); + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand$2(n[0], false).map(embrace); + if (n.length === 1) { + var post = m.post.length + ? expand$2(m.post, false) + : ['']; + return post.map(function(p) { + return m.pre + n[0] + p; + }); + } + } } - if (options.wrap) { - return `(${prefix}${result})`; - } + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. - return result; -}; + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + var post = m.post.length + ? expand$2(m.post, false) + : ['']; -const toRange = (a, b, isNumbers, options) => { - if (isNumbers) { - return toRegexRange(a, b, { wrap: false, ...options }); - } + var N; - let start = String.fromCharCode(a); - if (a === b) return start; + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length); + var incr = n.length == 3 + ? Math.abs(numeric(n[2])) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); - let stop = String.fromCharCode(b); - return `[${start}-${stop}]`; -}; + N = []; -const toRegex = (start, end, options) => { - if (Array.isArray(start)) { - let wrap = options.wrap === true; - let prefix = options.capture ? '' : '?:'; - return wrap ? `(${prefix}${start.join('|')})` : start.join('|'); + for (var i = x; test(i, y); i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') + c = ''; + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) + c = '-' + z + c.slice(1); + else + c = z + c; + } + } + } + N.push(c); + } + } else { + N = concatMap(n, function(el) { return expand$2(el, false) }); } - return toRegexRange(start, end, options); -}; -const rangeError = (...args) => { - return new RangeError('Invalid range arguments: ' + util$1.inspect(...args)); -}; + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k]; + if (!isTop || isSequence || expansion) + expansions.push(expansion); + } + } -const invalidRange = (start, end, options) => { - if (options.strictRanges === true) throw rangeError([start, end]); - return []; -}; + return expansions; +} -const invalidStep = (step, options) => { - if (options.strictRanges === true) { - throw new TypeError(`Expected step "${step}" to be a number`); - } - return []; -}; +var minimatch_1 = minimatch$3; +minimatch$3.Minimatch = Minimatch$1; -const fillNumbers = (start, end, step = 1, options = {}) => { - let a = Number(start); - let b = Number(end); +var path$4 = { sep: '/' }; +try { + path$4 = path__default['default']; +} catch (er) {} - if (!Number.isInteger(a) || !Number.isInteger(b)) { - if (options.strictRanges === true) throw rangeError([start, end]); - return []; - } +var GLOBSTAR = minimatch$3.GLOBSTAR = Minimatch$1.GLOBSTAR = {}; +var expand$1 = braceExpansion; - // fix negative zero - if (a === 0) a = 0; - if (b === 0) b = 0; +var plTypes = { + '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, + '?': { open: '(?:', close: ')?' }, + '+': { open: '(?:', close: ')+' }, + '*': { open: '(?:', close: ')*' }, + '@': { open: '(?:', close: ')' } +}; - let descending = a > b; - let startString = String(start); - let endString = String(end); - let stepString = String(step); - step = Math.max(Math.abs(step), 1); +// any single thing other than / +// don't need to escape / when using new RegExp() +var qmark = '[^/]'; - let padded = zeros(startString) || zeros(endString) || zeros(stepString); - let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0; - let toNumber = padded === false && stringify$7(start, end, options) === false; - let format = options.transform || transform(toNumber); +// * => any number of characters +var star = qmark + '*?'; - if (options.toRegex && step === 1) { - return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options); - } +// ** when dots are allowed. Anything goes, except .. and . +// not (^ or / followed by one or two dots followed by $ or /), +// followed by anything, any number of times. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; - let parts = { negatives: [], positives: [] }; - let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num)); - let range = []; - let index = 0; +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; - while (descending ? a >= b : a <= b) { - if (options.toRegex === true && step > 1) { - push(a); - } else { - range.push(pad(format(a, index), maxLen, toNumber)); - } - a = descending ? a - step : a + step; - index++; - } +// characters that need to be escaped in RegExp. +var reSpecials = charSet('().*{}+?[]^$\\!'); - if (options.toRegex === true) { - return step > 1 - ? toSequence(parts, options) - : toRegex(range, null, { wrap: false, ...options }); - } +// "abc" -> { a:true, b:true, c:true } +function charSet (s) { + return s.split('').reduce(function (set, c) { + set[c] = true; + return set + }, {}) +} - return range; -}; +// normalizes slashes. +var slashSplit = /\/+/; -const fillLetters = (start, end, step = 1, options = {}) => { - if ((!isNumber$1(start) && start.length > 1) || (!isNumber$1(end) && end.length > 1)) { - return invalidRange(start, end, options); +minimatch$3.filter = filter; +function filter (pattern, options) { + options = options || {}; + return function (p, i, list) { + return minimatch$3(p, pattern, options) } +} +function ext (a, b) { + a = a || {}; + b = b || {}; + var t = {}; + Object.keys(b).forEach(function (k) { + t[k] = b[k]; + }); + Object.keys(a).forEach(function (k) { + t[k] = a[k]; + }); + return t +} - let format = options.transform || (val => String.fromCharCode(val)); - let a = `${start}`.charCodeAt(0); - let b = `${end}`.charCodeAt(0); - - let descending = a > b; - let min = Math.min(a, b); - let max = Math.max(a, b); +minimatch$3.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch$3 - if (options.toRegex && step === 1) { - return toRange(min, max, false, options); - } + var orig = minimatch$3; - let range = []; - let index = 0; + var m = function minimatch (p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)) + }; - while (descending ? a >= b : a <= b) { - range.push(format(a, index)); - a = descending ? a - step : a + step; - index++; - } + m.Minimatch = function Minimatch (pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)) + }; - if (options.toRegex === true) { - return toRegex(range, null, { wrap: false, options }); - } + return m +}; - return range; +Minimatch$1.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch$1 + return minimatch$3.defaults(def).Minimatch }; -const fill$2 = (start, end, step, options = {}) => { - if (end == null && isValidValue(start)) { - return [start]; +function minimatch$3 (p, pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') } - if (!isValidValue(start) || !isValidValue(end)) { - return invalidRange(start, end, options); + if (!options) options = {}; + + // shortcut: comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + return false } - if (typeof step === 'function') { - return fill$2(start, end, 1, { transform: step }); + // "" only matches "" + if (pattern.trim() === '') return p === '' + + return new Minimatch$1(pattern, options).match(p) +} + +function Minimatch$1 (pattern, options) { + if (!(this instanceof Minimatch$1)) { + return new Minimatch$1(pattern, options) } - if (isObject$2(step)) { - return fill$2(start, end, 0, step); + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') } - let opts = { ...options }; - if (opts.capture === true) opts.wrap = true; - step = step || opts.step || 1; + if (!options) options = {}; + pattern = pattern.trim(); - if (!isNumber$1(step)) { - if (step != null && !isObject$2(step)) return invalidStep(step, opts); - return fill$2(start, end, 1, step); + // windows support: need to use /, not \ + if (path$4.sep !== '/') { + pattern = pattern.split(path$4.sep).join('/'); } - if (isNumber$1(start) && isNumber$1(end)) { - return fillNumbers(start, end, step, opts); - } + this.options = options; + this.set = []; + this.pattern = pattern; + this.regexp = null; + this.negate = false; + this.comment = false; + this.empty = false; - return fillLetters(start, end, Math.max(Math.abs(step), 1), opts); -}; + // make the set of regexps etc. + this.make(); +} -var fillRange = fill$2; +Minimatch$1.prototype.debug = function () {}; -const fill$1 = fillRange; -const utils$1 = utils$3; +Minimatch$1.prototype.make = make; +function make () { + // don't do it more than once. + if (this._made) return -const compile$1 = (ast, options = {}) => { - let walk = (node, parent = {}) => { - let invalidBlock = utils$1.isInvalidBrace(parent); - let invalidNode = node.invalid === true && options.escapeInvalid === true; - let invalid = invalidBlock === true || invalidNode === true; - let prefix = options.escapeInvalid === true ? '\\' : ''; - let output = ''; + var pattern = this.pattern; + var options = this.options; - if (node.isOpen === true) { - return prefix + node.value; - } - if (node.isClose === true) { - return prefix + node.value; - } + // empty patterns and comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + this.comment = true; + return + } + if (!pattern) { + this.empty = true; + return + } - if (node.type === 'open') { - return invalid ? (prefix + node.value) : '('; - } + // step 1: figure out negation, etc. + this.parseNegate(); - if (node.type === 'close') { - return invalid ? (prefix + node.value) : ')'; - } + // step 2: expand braces + var set = this.globSet = this.braceExpand(); - if (node.type === 'comma') { - return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|'); - } + if (options.debug) this.debug = console.error; - if (node.value) { - return node.value; - } + this.debug(this.pattern, set); - if (node.nodes && node.ranges > 0) { - let args = utils$1.reduce(node.nodes); - let range = fill$1(...args, { ...options, wrap: false, toRegex: true }); + // step 3: now we have a set, so turn each one into a series of path-portion + // matching patterns. + // These will be regexps, except in the case of "**", which is + // set to the GLOBSTAR object for globstar behavior, + // and will not contain any / characters + set = this.globParts = set.map(function (s) { + return s.split(slashSplit) + }); - if (range.length !== 0) { - return args.length > 1 && range.length > 1 ? `(${range})` : range; - } - } + this.debug(this.pattern, set); - if (node.nodes) { - for (let child of node.nodes) { - output += walk(child, node); - } - } - return output; - }; + // glob --> regexps + set = set.map(function (s, si, set) { + return s.map(this.parse, this) + }, this); - return walk(ast); -}; + this.debug(this.pattern, set); -var compile_1 = compile$1; + // filter out everything that didn't compile properly. + set = set.filter(function (s) { + return s.indexOf(false) === -1 + }); -const fill = fillRange; -const stringify$6 = stringify$8; -const utils = utils$3; + this.debug(this.pattern, set); -const append = (queue = '', stash = '', enclose = false) => { - let result = []; + this.set = set; +} - queue = [].concat(queue); - stash = [].concat(stash); +Minimatch$1.prototype.parseNegate = parseNegate; +function parseNegate () { + var pattern = this.pattern; + var negate = false; + var options = this.options; + var negateOffset = 0; - if (!stash.length) return queue; - if (!queue.length) { - return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash; + if (options.nonegate) return + + for (var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === '!' + ; i++) { + negate = !negate; + negateOffset++; } - for (let item of queue) { - if (Array.isArray(item)) { - for (let value of item) { - result.push(append(value, stash, enclose)); - } + if (negateOffset) this.pattern = pattern.substr(negateOffset); + this.negate = negate; +} + +// Brace expansion: +// a{b,c}d -> abd acd +// a{b,}c -> abc ac +// a{0..3}d -> a0d a1d a2d a3d +// a{b,c{d,e}f}g -> abg acdfg acefg +// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg +// +// Invalid sets are not expanded. +// a{2..}b -> a{2..}b +// a{b}c -> a{b}c +minimatch$3.braceExpand = function (pattern, options) { + return braceExpand(pattern, options) +}; + +Minimatch$1.prototype.braceExpand = braceExpand; + +function braceExpand (pattern, options) { + if (!options) { + if (this instanceof Minimatch$1) { + options = this.options; } else { - for (let ele of stash) { - if (enclose === true && typeof ele === 'string') ele = `{${ele}}`; - result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele)); - } + options = {}; } } - return utils.flatten(result); -}; -const expand$1 = (ast, options = {}) => { - let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit; + pattern = typeof pattern === 'undefined' + ? this.pattern : pattern; - let walk = (node, parent = {}) => { - node.queue = []; + if (typeof pattern === 'undefined') { + throw new TypeError('undefined pattern') + } - let p = parent; - let q = parent.queue; + if (options.nobrace || + !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern] + } - while (p.type !== 'brace' && p.type !== 'root' && p.parent) { - p = p.parent; - q = p.queue; - } + return expand$1(pattern) +} - if (node.invalid || node.dollar) { - q.push(append(q.pop(), stringify$6(node, options))); - return; - } +// parse a component of the expanded set. +// At this point, no pattern may contain "/" in it +// so we're going to return a 2d array, where each entry is the full +// pattern, split on '/', and then turned into a regular expression. +// A regexp is made at the end which joins each array with an +// escaped /, and another full one which joins each regexp with |. +// +// Following the lead of Bash 4.1, note that "**" only has special meaning +// when it is the *only* thing in a path portion. Otherwise, any series +// of * is equivalent to a single *. Globstar behavior is enabled by +// default, and can be disabled by setting options.noglobstar. +Minimatch$1.prototype.parse = parse$3; +var SUBPARSE = {}; +function parse$3 (pattern, isSub) { + if (pattern.length > 1024 * 64) { + throw new TypeError('pattern is too long') + } - if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) { - q.push(append(q.pop(), ['{}'])); - return; - } + var options = this.options; - if (node.nodes && node.ranges > 0) { - let args = utils.reduce(node.nodes); + // shortcuts + if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '') return '' - if (utils.exceedsLimit(...args, options.step, rangeLimit)) { - throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.'); - } + var re = ''; + var hasMagic = !!options.nocase; + var escaping = false; + // ? => one single character + var patternListStack = []; + var negativeLists = []; + var stateChar; + var inClass = false; + var reClassStart = -1; + var classStart = -1; + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)'; + var self = this; - let range = fill(...args, options); - if (range.length === 0) { - range = stringify$6(node, options); + function clearStateChar () { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case '*': + re += star; + hasMagic = true; + break + case '?': + re += qmark; + hasMagic = true; + break + default: + re += '\\' + stateChar; + break } - - q.push(append(q.pop(), range)); - node.nodes = []; - return; + self.debug('clearStateChar %j %j', stateChar, re); + stateChar = false; } + } - let enclose = utils.encloseBrace(node); - let queue = node.queue; - let block = node; + for (var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c); - while (block.type !== 'brace' && block.type !== 'root' && block.parent) { - block = block.parent; - queue = block.queue; + // skip over any that are escaped. + if (escaping && reSpecials[c]) { + re += '\\' + c; + escaping = false; + continue } - for (let i = 0; i < node.nodes.length; i++) { - let child = node.nodes[i]; + switch (c) { + case '/': + // completely not allowed, even escaped. + // Should already be path-split by now. + return false - if (child.type === 'comma' && node.type === 'brace') { - if (i === 1) queue.push(''); - queue.push(''); - continue; - } + case '\\': + clearStateChar(); + escaping = true; + continue - if (child.type === 'close') { - q.push(append(q.pop(), queue, enclose)); - continue; - } + // the various stateChar values + // for the "extglob" stuff. + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); - if (child.value && child.type !== 'open') { - queue.push(append(queue.pop(), child.value)); - continue; - } + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + if (inClass) { + this.debug(' in class'); + if (c === '!' && i === classStart + 1) c = '^'; + re += c; + continue + } - if (child.nodes) { - walk(child, node); - } - } + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar); + clearStateChar(); + stateChar = c; + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar(); + continue - return queue; - }; + case '(': + if (inClass) { + re += '('; + continue + } - return utils.flatten(walk(ast)); -}; + if (!stateChar) { + re += '\\('; + continue + } -var expand_1 = expand$1; + patternListStack.push({ + type: stateChar, + start: i - 1, + reStart: re.length, + open: plTypes[stateChar].open, + close: plTypes[stateChar].close + }); + // negation is (?:(?!js)[^/]*) + re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; + this.debug('plType %j %j', stateChar, re); + stateChar = false; + continue -var constants$2 = { - MAX_LENGTH: 1024 * 64, + case ')': + if (inClass || !patternListStack.length) { + re += '\\)'; + continue + } - // Digits - CHAR_0: '0', /* 0 */ - CHAR_9: '9', /* 9 */ + clearStateChar(); + hasMagic = true; + var pl = patternListStack.pop(); + // negation is (?:(?!js)[^/]*) + // The others are (?:) + re += pl.close; + if (pl.type === '!') { + negativeLists.push(pl); + } + pl.reEnd = re.length; + continue - // Alphabet chars. - CHAR_UPPERCASE_A: 'A', /* A */ - CHAR_LOWERCASE_A: 'a', /* a */ - CHAR_UPPERCASE_Z: 'Z', /* Z */ - CHAR_LOWERCASE_Z: 'z', /* z */ + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|'; + escaping = false; + continue + } - CHAR_LEFT_PARENTHESES: '(', /* ( */ - CHAR_RIGHT_PARENTHESES: ')', /* ) */ + clearStateChar(); + re += '|'; + continue - CHAR_ASTERISK: '*', /* * */ + // these are mostly the same in regexp and glob + case '[': + // swallow any state-tracking char before the [ + clearStateChar(); - // Non-alphabetic chars. - CHAR_AMPERSAND: '&', /* & */ - CHAR_AT: '@', /* @ */ - CHAR_BACKSLASH: '\\', /* \ */ - CHAR_BACKTICK: '`', /* ` */ - CHAR_CARRIAGE_RETURN: '\r', /* \r */ - CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */ - CHAR_COLON: ':', /* : */ - CHAR_COMMA: ',', /* , */ - CHAR_DOLLAR: '$', /* . */ - CHAR_DOT: '.', /* . */ - CHAR_DOUBLE_QUOTE: '"', /* " */ - CHAR_EQUAL: '=', /* = */ - CHAR_EXCLAMATION_MARK: '!', /* ! */ - CHAR_FORM_FEED: '\f', /* \f */ - CHAR_FORWARD_SLASH: '/', /* / */ - CHAR_HASH: '#', /* # */ - CHAR_HYPHEN_MINUS: '-', /* - */ - CHAR_LEFT_ANGLE_BRACKET: '<', /* < */ - CHAR_LEFT_CURLY_BRACE: '{', /* { */ - CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */ - CHAR_LINE_FEED: '\n', /* \n */ - CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */ - CHAR_PERCENT: '%', /* % */ - CHAR_PLUS: '+', /* + */ - CHAR_QUESTION_MARK: '?', /* ? */ - CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */ - CHAR_RIGHT_CURLY_BRACE: '}', /* } */ - CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */ - CHAR_SEMICOLON: ';', /* ; */ - CHAR_SINGLE_QUOTE: '\'', /* ' */ - CHAR_SPACE: ' ', /* */ - CHAR_TAB: '\t', /* \t */ - CHAR_UNDERSCORE: '_', /* _ */ - CHAR_VERTICAL_LINE: '|', /* | */ - CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */ -}; + if (inClass) { + re += '\\' + c; + continue + } -const stringify$5 = stringify$8; + inClass = true; + classStart = i; + reClassStart = re.length; + re += c; + continue -/** - * Constants - */ + case ']': + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += '\\' + c; + escaping = false; + continue + } -const { - MAX_LENGTH: MAX_LENGTH$3, - CHAR_BACKSLASH, /* \ */ - CHAR_BACKTICK, /* ` */ - CHAR_COMMA: CHAR_COMMA$1, /* , */ - CHAR_DOT, /* . */ - CHAR_LEFT_PARENTHESES, /* ( */ - CHAR_RIGHT_PARENTHESES, /* ) */ - CHAR_LEFT_CURLY_BRACE, /* { */ - CHAR_RIGHT_CURLY_BRACE, /* } */ - CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$1, /* [ */ - CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$1, /* ] */ - CHAR_DOUBLE_QUOTE: CHAR_DOUBLE_QUOTE$1, /* " */ - CHAR_SINGLE_QUOTE: CHAR_SINGLE_QUOTE$1, /* ' */ - CHAR_NO_BREAK_SPACE, - CHAR_ZERO_WIDTH_NOBREAK_SPACE -} = constants$2; + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i); + try { + RegExp('[' + cs + ']'); + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE); + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'; + hasMagic = hasMagic || sp[1]; + inClass = false; + continue + } + } -/** - * parse - */ + // finish up the class. + hasMagic = true; + inClass = false; + re += c; + continue -const parse$6 = (input, options = {}) => { - if (typeof input !== 'string') { - throw new TypeError('Expected a string'); - } + default: + // swallow any state char that wasn't consumed + clearStateChar(); - let opts = options || {}; - let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$3, opts.maxLength) : MAX_LENGTH$3; - if (input.length > max) { - throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`); - } + if (escaping) { + // no need + escaping = false; + } else if (reSpecials[c] + && !(c === '^' && inClass)) { + re += '\\'; + } - let ast = { type: 'root', input, nodes: [] }; - let stack = [ast]; - let block = ast; - let prev = ast; - let brackets = 0; - let length = input.length; - let index = 0; - let depth = 0; - let value; + re += c; - /** - * Helpers - */ + } // switch + } // for - const advance = () => input[index++]; - const push = node => { - if (node.type === 'text' && prev.type === 'dot') { - prev.type = 'text'; - } + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + cs = pattern.substr(classStart + 1); + sp = this.parse(cs, SUBPARSE); + re = re.substr(0, reClassStart) + '\\[' + sp[0]; + hasMagic = hasMagic || sp[1]; + } - if (prev && prev.type === 'text' && node.type === 'text') { - prev.value += node.value; - return; - } + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + pl.open.length); + this.debug('setting tail', re, pl); + // maybe some even number of \, then maybe 1 \, followed by a | + tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = '\\'; + } - block.nodes.push(node); - node.parent = block; - node.prev = prev; - prev = node; - return node; - }; + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + '|' + }); - push({ type: 'bos' }); + this.debug('tail=%j\n %s', tail, tail, pl, re); + var t = pl.type === '*' ? star + : pl.type === '?' ? qmark + : '\\' + pl.type; - while (index < length) { - block = stack[stack.length - 1]; - value = advance(); + hasMagic = true; + re = re.slice(0, pl.reStart) + t + '\\(' + tail; + } - /** - * Invalid chars - */ + // handle trailing things that only matter at the very end. + clearStateChar(); + if (escaping) { + // trailing \\ + re += '\\\\'; + } - if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) { - continue; - } + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false; + switch (re.charAt(0)) { + case '.': + case '[': + case '(': addPatternStart = true; + } - /** - * Escaped chars - */ + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n]; - if (value === CHAR_BACKSLASH) { - push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() }); - continue; - } + var nlBefore = re.slice(0, nl.reStart); + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8); + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd); + var nlAfter = re.slice(nl.reEnd); - /** - * Right square bracket (literal): ']' - */ + nlLast += nlAfter; - if (value === CHAR_RIGHT_SQUARE_BRACKET$1) { - push({ type: 'text', value: '\\' + value }); - continue; + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1; + var cleanAfter = nlAfter; + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, ''); } + nlAfter = cleanAfter; - /** - * Left square bracket: '[' - */ - - if (value === CHAR_LEFT_SQUARE_BRACKET$1) { - brackets++; - let next; + var dollar = ''; + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$'; + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast; + re = newRe; + } - while (index < length && (next = advance())) { - value += next; + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== '' && hasMagic) { + re = '(?=.)' + re; + } - if (next === CHAR_LEFT_SQUARE_BRACKET$1) { - brackets++; - continue; - } + if (addPatternStart) { + re = patternStart + re; + } - if (next === CHAR_BACKSLASH) { - value += advance(); - continue; - } + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [re, hasMagic] + } - if (next === CHAR_RIGHT_SQUARE_BRACKET$1) { - brackets--; + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern) + } - if (brackets === 0) { - break; - } - } - } + var flags = options.nocase ? 'i' : ''; + try { + var regExp = new RegExp('^' + re + '$', flags); + } catch (er) { + // If it was an invalid regular expression, then it can't match + // anything. This trick looks for a character after the end of + // the string, which is of course impossible, except in multi-line + // mode, but it's not a /m regex. + return new RegExp('$.') + } - push({ type: 'text', value }); - continue; - } + regExp._glob = pattern; + regExp._src = re; - /** - * Parentheses - */ + return regExp +} - if (value === CHAR_LEFT_PARENTHESES) { - block = push({ type: 'paren', nodes: [] }); - stack.push(block); - push({ type: 'text', value }); - continue; - } +minimatch$3.makeRe = function (pattern, options) { + return new Minimatch$1(pattern, options || {}).makeRe() +}; - if (value === CHAR_RIGHT_PARENTHESES) { - if (block.type !== 'paren') { - push({ type: 'text', value }); - continue; - } - block = stack.pop(); - push({ type: 'text', value }); - block = stack[stack.length - 1]; - continue; - } +Minimatch$1.prototype.makeRe = makeRe; +function makeRe () { + if (this.regexp || this.regexp === false) return this.regexp - /** - * Quotes: '|"|` - */ + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set; - if (value === CHAR_DOUBLE_QUOTE$1 || value === CHAR_SINGLE_QUOTE$1 || value === CHAR_BACKTICK) { - let open = value; - let next; + if (!set.length) { + this.regexp = false; + return this.regexp + } + var options = this.options; - if (options.keepQuotes !== true) { - value = ''; - } + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot; + var flags = options.nocase ? 'i' : ''; - while (index < length && (next = advance())) { - if (next === CHAR_BACKSLASH) { - value += next + advance(); - continue; - } + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return (p === GLOBSTAR) ? twoStar + : (typeof p === 'string') ? regExpEscape(p) + : p._src + }).join('\\\/') + }).join('|'); - if (next === open) { - if (options.keepQuotes === true) value += next; - break; - } + // must match entire pattern + // ending in a * or ** will make it less strict. + re = '^(?:' + re + ')$'; - value += next; - } + // can match anything, as long as it's not this. + if (this.negate) re = '^(?!' + re + ').*$'; - push({ type: 'text', value }); - continue; - } + try { + this.regexp = new RegExp(re, flags); + } catch (ex) { + this.regexp = false; + } + return this.regexp +} - /** - * Left curly brace: '{' - */ +minimatch$3.match = function (list, pattern, options) { + options = options || {}; + var mm = new Minimatch$1(pattern, options); + list = list.filter(function (f) { + return mm.match(f) + }); + if (mm.options.nonull && !list.length) { + list.push(pattern); + } + return list +}; - if (value === CHAR_LEFT_CURLY_BRACE) { - depth++; +Minimatch$1.prototype.match = match; +function match (f, partial) { + this.debug('match', f, this.pattern); + // short-circuit in the case of busted things. + // comments, etc. + if (this.comment) return false + if (this.empty) return f === '' - let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true; - let brace = { - type: 'brace', - open: true, - close: false, - dollar, - depth, - commas: 0, - ranges: 0, - nodes: [] - }; + if (f === '/' && partial) return true - block = push(brace); - stack.push(block); - push({ type: 'open', value }); - continue; - } + var options = this.options; - /** - * Right curly brace: '}' - */ + // windows: need to use /, not \ + if (path$4.sep !== '/') { + f = f.split(path$4.sep).join('/'); + } - if (value === CHAR_RIGHT_CURLY_BRACE) { - if (block.type !== 'brace') { - push({ type: 'text', value }); - continue; - } + // treat the test path as a set of pathparts. + f = f.split(slashSplit); + this.debug(this.pattern, 'split', f); - let type = 'close'; - block = stack.pop(); - block.close = true; + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. - push({ type, value }); - depth--; + var set = this.set; + this.debug(this.pattern, 'set', set); - block = stack[stack.length - 1]; - continue; + // Find the basename of the path by looking for the last non-empty segment + var filename; + var i; + for (i = f.length - 1; i >= 0; i--) { + filename = f[i]; + if (filename) break + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i]; + var file = f; + if (options.matchBase && pattern.length === 1) { + file = [filename]; } + var hit = this.matchOne(file, pattern, partial); + if (hit) { + if (options.flipNegate) return true + return !this.negate + } + } - /** - * Comma: ',' - */ + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false + return this.negate +} - if (value === CHAR_COMMA$1 && depth > 0) { - if (block.ranges > 0) { - block.ranges = 0; - let open = block.nodes.shift(); - block.nodes = [open, { type: 'text', value: stringify$5(block) }]; - } +// set partial to true to test if, for example, +// "/a/b" matches the start of "/*/b/*/d" +// Partial means, if you run out of file before you run +// out of pattern, then that's fine, as long as all +// the parts match. +Minimatch$1.prototype.matchOne = function (file, pattern, partial) { + var options = this.options; - push({ type: 'comma', value }); - block.commas++; - continue; - } + this.debug('matchOne', + { 'this': this, file: file, pattern: pattern }); - /** - * Dot: '.' - */ + this.debug('matchOne', file.length, pattern.length); - if (value === CHAR_DOT && depth > 0 && block.commas === 0) { - let siblings = block.nodes; + for (var fi = 0, + pi = 0, + fl = file.length, + pl = pattern.length + ; (fi < fl) && (pi < pl) + ; fi++, pi++) { + this.debug('matchOne loop'); + var p = pattern[pi]; + var f = file[fi]; - if (depth === 0 || siblings.length === 0) { - push({ type: 'text', value }); - continue; - } + this.debug(pattern, p, f); - if (prev.type === 'dot') { - block.range = []; - prev.value += value; - prev.type = 'range'; + // should be impossible. + // some invalid regexp stuff in the set. + if (p === false) return false - if (block.nodes.length !== 3 && block.nodes.length !== 5) { - block.invalid = true; - block.ranges = 0; - prev.type = 'text'; - continue; - } + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]); - block.ranges++; - block.args = []; - continue; + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + var fr = fi; + var pr = pi + 1; + if (pr === pl) { + this.debug('** at the end'); + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || + (!options.dot && file[fi].charAt(0) === '.')) return false + } + return true } - if (prev.type === 'range') { - siblings.pop(); + // ok, let's see if we can swallow whatever we can. + while (fr < fl) { + var swallowee = file[fr]; - let before = siblings[siblings.length - 1]; - before.value += prev.value + value; - prev = before; - block.ranges--; - continue; + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); + + // XXX remove this slice. Just pass the start index. + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee); + // found a match. + return true + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === '.' || swallowee === '..' || + (!options.dot && swallowee.charAt(0) === '.')) { + this.debug('dot detected!', file, fr, pattern, pr); + break + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue'); + fr++; + } } - push({ type: 'dot', value }); - continue; + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug('\n>>> no match, partial?', file, fr, pattern, pr); + if (fr === fl) return true + } + return false } - /** - * Text - */ + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit; + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase(); + } else { + hit = f === p; + } + this.debug('string match', p, f, hit); + } else { + hit = f.match(p); + this.debug('pattern match', p, f, hit); + } - push({ type: 'text', value }); + if (!hit) return false } - // Mark imbalanced braces and brackets as invalid - do { - block = stack.pop(); - - if (block.type !== 'root') { - block.nodes.forEach(node => { - if (!node.nodes) { - if (node.type === 'open') node.isOpen = true; - if (node.type === 'close') node.isClose = true; - if (!node.nodes) node.type = 'text'; - node.invalid = true; - } - }); + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* - // get the location of the block on parent.nodes (block's siblings) - let parent = stack[stack.length - 1]; - let index = parent.nodes.indexOf(block); - // replace the (invalid) block with it's nodes - parent.nodes.splice(index, 1, ...block.nodes); - } - } while (stack.length > 0); + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = (fi === fl - 1) && (file[fi] === ''); + return emptyFileEnd + } - push({ type: 'eos' }); - return ast; + // should be unreachable. + throw new Error('wtf?') }; -var parse_1$2 = parse$6; +// replace stuff like \* with * +function globUnescape (s) { + return s.replace(/\\(.)/g, '$1') +} -const stringify$4 = stringify$8; -const compile = compile_1; -const expand = expand_1; -const parse$5 = parse_1$2; +function regExpEscape (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') +} -/** - * Expand the given pattern or create a regex-compatible string. - * - * ```js - * const braces = require('braces'); - * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)'] - * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c'] - * ``` - * @param {String} `str` - * @param {Object} `options` - * @return {String} - * @api public - */ +var inherits$2 = {exports: {}}; -const braces$1 = (input, options = {}) => { - let output = []; +var inherits_browser = {exports: {}}; - if (Array.isArray(input)) { - for (let pattern of input) { - let result = braces$1.create(pattern, options); - if (Array.isArray(result)) { - output.push(...result); - } else { - output.push(result); - } +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + inherits_browser.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); } - } else { - output = [].concat(braces$1.create(input, options)); - } + }; +} else { + // old school shim for old browsers + inherits_browser.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; +} - if (options && options.expand === true && options.nodupes === true) { - output = [...new Set(output)]; - } - return output; -}; +try { + var util$1 = require$$0__default$2['default']; + /* istanbul ignore next */ + if (typeof util$1.inherits !== 'function') throw ''; + inherits$2.exports = util$1.inherits; +} catch (e) { + /* istanbul ignore next */ + inherits$2.exports = inherits_browser.exports; +} -/** - * Parse the given `str` with the given `options`. - * - * ```js - * // braces.parse(pattern, [, options]); - * const ast = braces.parse('a/{b,c}/d'); - * console.log(ast); - * ``` - * @param {String} pattern Brace pattern to parse - * @param {Object} options - * @return {Object} Returns an AST - * @api public - */ +var pathIsAbsolute = {exports: {}}; -braces$1.parse = (input, options = {}) => parse$5(input, options); +function posix(path) { + return path.charAt(0) === '/'; +} -/** - * Creates a braces string from an AST, or an AST node. - * - * ```js - * const braces = require('braces'); - * let ast = braces.parse('foo/{a,b}/bar'); - * console.log(stringify(ast.nodes[2])); //=> '{a,b}' - * ``` - * @param {String} `input` Brace pattern or AST. - * @param {Object} `options` - * @return {Array} Returns an array of expanded values. - * @api public - */ +function win32(path) { + // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 + var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; + var result = splitDeviceRe.exec(path); + var device = result[1] || ''; + var isUnc = Boolean(device && device.charAt(1) !== ':'); -braces$1.stringify = (input, options = {}) => { - if (typeof input === 'string') { - return stringify$4(braces$1.parse(input, options), options); - } - return stringify$4(input, options); -}; + // UNC paths are always absolute + return Boolean(result[2] || isUnc); +} -/** - * Compiles a brace pattern into a regex-compatible, optimized string. - * This method is called by the main [braces](#braces) function by default. - * - * ```js - * const braces = require('braces'); - * console.log(braces.compile('a/{b,c}/d')); - * //=> ['a/(b|c)/d'] - * ``` - * @param {String} `input` Brace pattern or AST. - * @param {Object} `options` - * @return {Array} Returns an array of expanded values. - * @api public - */ +pathIsAbsolute.exports = process.platform === 'win32' ? win32 : posix; +pathIsAbsolute.exports.posix = posix; +pathIsAbsolute.exports.win32 = win32; -braces$1.compile = (input, options = {}) => { - if (typeof input === 'string') { - input = braces$1.parse(input, options); - } - return compile(input, options); -}; +var common$2 = {}; -/** - * Expands a brace pattern into an array. This method is called by the - * main [braces](#braces) function when `options.expand` is true. Before - * using this method it's recommended that you read the [performance notes](#performance)) - * and advantages of using [.compile](#compile) instead. - * - * ```js - * const braces = require('braces'); - * console.log(braces.expand('a/{b,c}/d')); - * //=> ['a/b/d', 'a/c/d']; - * ``` - * @param {String} `pattern` Brace pattern - * @param {Object} `options` - * @return {Array} Returns an array of expanded values. - * @api public - */ +common$2.alphasort = alphasort; +common$2.alphasorti = alphasorti; +common$2.setopts = setopts$2; +common$2.ownProp = ownProp$2; +common$2.makeAbs = makeAbs; +common$2.finish = finish; +common$2.mark = mark; +common$2.isIgnored = isIgnored$2; +common$2.childrenIgnored = childrenIgnored$2; -braces$1.expand = (input, options = {}) => { - if (typeof input === 'string') { - input = braces$1.parse(input, options); - } +function ownProp$2 (obj, field) { + return Object.prototype.hasOwnProperty.call(obj, field) +} - let result = expand(input, options); +var path$3 = path__default['default']; +var minimatch$2 = minimatch_1; +var isAbsolute$2 = pathIsAbsolute.exports; +var Minimatch = minimatch$2.Minimatch; - // filter out empty strings if specified - if (options.noempty === true) { - result = result.filter(Boolean); - } +function alphasorti (a, b) { + return a.toLowerCase().localeCompare(b.toLowerCase()) +} - // filter out duplicates if specified - if (options.nodupes === true) { - result = [...new Set(result)]; - } +function alphasort (a, b) { + return a.localeCompare(b) +} - return result; -}; +function setupIgnores (self, options) { + self.ignore = options.ignore || []; -/** - * Processes a brace pattern and returns either an expanded array - * (if `options.expand` is true), a highly optimized regex-compatible string. - * This method is called by the main [braces](#braces) function. - * - * ```js - * const braces = require('braces'); - * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}')) - * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)' - * ``` - * @param {String} `pattern` Brace pattern - * @param {Object} `options` - * @return {Array} Returns an array of expanded values. - * @api public - */ + if (!Array.isArray(self.ignore)) + self.ignore = [self.ignore]; -braces$1.create = (input, options = {}) => { - if (input === '' || input.length < 3) { - return [input]; + if (self.ignore.length) { + self.ignore = self.ignore.map(ignoreMap); } +} - return options.expand !== true - ? braces$1.compile(input, options) - : braces$1.expand(input, options); -}; +// ignore patterns are always in dot:true mode. +function ignoreMap (pattern) { + var gmatcher = null; + if (pattern.slice(-3) === '/**') { + var gpattern = pattern.replace(/(\/\*\*)+$/, ''); + gmatcher = new Minimatch(gpattern, { dot: true }); + } -/** - * Expose "braces" - */ + return { + matcher: new Minimatch(pattern, { dot: true }), + gmatcher: gmatcher + } +} -var braces_1 = braces$1; +function setopts$2 (self, pattern, options) { + if (!options) + options = {}; -var require$$0$4 = [ - "3dm", - "3ds", - "3g2", - "3gp", - "7z", - "a", - "aac", - "adp", - "ai", - "aif", - "aiff", - "alz", - "ape", - "apk", - "appimage", - "ar", - "arj", - "asf", - "au", - "avi", - "bak", - "baml", - "bh", - "bin", - "bk", - "bmp", - "btif", - "bz2", - "bzip2", - "cab", - "caf", - "cgm", - "class", - "cmx", - "cpio", - "cr2", - "cur", - "dat", - "dcm", - "deb", - "dex", - "djvu", - "dll", - "dmg", - "dng", - "doc", - "docm", - "docx", - "dot", - "dotm", - "dra", - "DS_Store", - "dsk", - "dts", - "dtshd", - "dvb", - "dwg", - "dxf", - "ecelp4800", - "ecelp7470", - "ecelp9600", - "egg", - "eol", - "eot", - "epub", - "exe", - "f4v", - "fbs", - "fh", - "fla", - "flac", - "flatpak", - "fli", - "flv", - "fpx", - "fst", - "fvt", - "g3", - "gh", - "gif", - "graffle", - "gz", - "gzip", - "h261", - "h263", - "h264", - "icns", - "ico", - "ief", - "img", - "ipa", - "iso", - "jar", - "jpeg", - "jpg", - "jpgv", - "jpm", - "jxr", - "key", - "ktx", - "lha", - "lib", - "lvp", - "lz", - "lzh", - "lzma", - "lzo", - "m3u", - "m4a", - "m4v", - "mar", - "mdi", - "mht", - "mid", - "midi", - "mj2", - "mka", - "mkv", - "mmr", - "mng", - "mobi", - "mov", - "movie", - "mp3", - "mp4", - "mp4a", - "mpeg", - "mpg", - "mpga", - "mxu", - "nef", - "npx", - "numbers", - "nupkg", - "o", - "odp", - "ods", - "odt", - "oga", - "ogg", - "ogv", - "otf", - "ott", - "pages", - "pbm", - "pcx", - "pdb", - "pdf", - "pea", - "pgm", - "pic", - "png", - "pnm", - "pot", - "potm", - "potx", - "ppa", - "ppam", - "ppm", - "pps", - "ppsm", - "ppsx", - "ppt", - "pptm", - "pptx", - "psd", - "pya", - "pyc", - "pyo", - "pyv", - "qt", - "rar", - "ras", - "raw", - "resources", - "rgb", - "rip", - "rlc", - "rmf", - "rmvb", - "rpm", - "rtf", - "rz", - "s3m", - "s7z", - "scpt", - "sgi", - "shar", - "snap", - "sil", - "sketch", - "slk", - "smv", - "snk", - "so", - "stl", - "suo", - "sub", - "swf", - "tar", - "tbz", - "tbz2", - "tga", - "tgz", - "thmx", - "tif", - "tiff", - "tlz", - "ttc", - "ttf", - "txz", - "udf", - "uvh", - "uvi", - "uvm", - "uvp", - "uvs", - "uvu", - "viv", - "vob", - "war", - "wav", - "wax", - "wbmp", - "wdp", - "weba", - "webm", - "webp", - "whl", - "wim", - "wm", - "wma", - "wmv", - "wmx", - "woff", - "woff2", - "wrm", - "wvx", - "xbm", - "xif", - "xla", - "xlam", - "xls", - "xlsb", - "xlsm", - "xlsx", - "xlt", - "xltm", - "xltx", - "xm", - "xmind", - "xpi", - "xpm", - "xwd", - "xz", - "z", - "zip", - "zipx" -]; + // base-matching: just use globstar for that. + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar") + } + pattern = "**/" + pattern; + } -var binaryExtensions$1 = require$$0$4; + self.silent = !!options.silent; + self.pattern = pattern; + self.strict = options.strict !== false; + self.realpath = !!options.realpath; + self.realpathCache = options.realpathCache || Object.create(null); + self.follow = !!options.follow; + self.dot = !!options.dot; + self.mark = !!options.mark; + self.nodir = !!options.nodir; + if (self.nodir) + self.mark = true; + self.sync = !!options.sync; + self.nounique = !!options.nounique; + self.nonull = !!options.nonull; + self.nosort = !!options.nosort; + self.nocase = !!options.nocase; + self.stat = !!options.stat; + self.noprocess = !!options.noprocess; + self.absolute = !!options.absolute; -const path$1 = require$$0__default$2['default']; -const binaryExtensions = binaryExtensions$1; + self.maxLength = options.maxLength || Infinity; + self.cache = options.cache || Object.create(null); + self.statCache = options.statCache || Object.create(null); + self.symlinks = options.symlinks || Object.create(null); -const extensions$1 = new Set(binaryExtensions); + setupIgnores(self, options); -var isBinaryPath$1 = filePath => extensions$1.has(path$1.extname(filePath).slice(1).toLowerCase()); + self.changedCwd = false; + var cwd = process.cwd(); + if (!ownProp$2(options, "cwd")) + self.cwd = cwd; + else { + self.cwd = path$3.resolve(options.cwd); + self.changedCwd = self.cwd !== cwd; + } -var constants$1 = {}; + self.root = options.root || path$3.resolve(self.cwd, "/"); + self.root = path$3.resolve(self.root); + if (process.platform === "win32") + self.root = self.root.replace(/\\/g, "/"); -(function (exports) { + // TODO: is an absolute `cwd` supposed to be resolved against `root`? + // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') + self.cwdAbs = isAbsolute$2(self.cwd) ? self.cwd : makeAbs(self, self.cwd); + if (process.platform === "win32") + self.cwdAbs = self.cwdAbs.replace(/\\/g, "/"); + self.nomount = !!options.nomount; -const {sep} = require$$0__default$2['default']; -const {platform} = process; -const os = require$$0__default$1['default']; + // disable comments and negation in Minimatch. + // Note that they are not supported in Glob itself anyway. + options.nonegate = true; + options.nocomment = true; -exports.EV_ALL = 'all'; -exports.EV_READY = 'ready'; -exports.EV_ADD = 'add'; -exports.EV_CHANGE = 'change'; -exports.EV_ADD_DIR = 'addDir'; -exports.EV_UNLINK = 'unlink'; -exports.EV_UNLINK_DIR = 'unlinkDir'; -exports.EV_RAW = 'raw'; -exports.EV_ERROR = 'error'; + self.minimatch = new Minimatch(pattern, options); + self.options = self.minimatch.options; +} -exports.STR_DATA = 'data'; -exports.STR_END = 'end'; -exports.STR_CLOSE = 'close'; +function finish (self) { + var nou = self.nounique; + var all = nou ? [] : Object.create(null); -exports.FSEVENT_CREATED = 'created'; -exports.FSEVENT_MODIFIED = 'modified'; -exports.FSEVENT_DELETED = 'deleted'; -exports.FSEVENT_MOVED = 'moved'; -exports.FSEVENT_CLONED = 'cloned'; -exports.FSEVENT_UNKNOWN = 'unknown'; -exports.FSEVENT_TYPE_FILE = 'file'; -exports.FSEVENT_TYPE_DIRECTORY = 'directory'; -exports.FSEVENT_TYPE_SYMLINK = 'symlink'; + for (var i = 0, l = self.matches.length; i < l; i ++) { + var matches = self.matches[i]; + if (!matches || Object.keys(matches).length === 0) { + if (self.nonull) { + // do like the shell, and spit out the literal glob + var literal = self.minimatch.globSet[i]; + if (nou) + all.push(literal); + else + all[literal] = true; + } + } else { + // had matches + var m = Object.keys(matches); + if (nou) + all.push.apply(all, m); + else + m.forEach(function (m) { + all[m] = true; + }); + } + } -exports.KEY_LISTENERS = 'listeners'; -exports.KEY_ERR = 'errHandlers'; -exports.KEY_RAW = 'rawEmitters'; -exports.HANDLER_KEYS = [exports.KEY_LISTENERS, exports.KEY_ERR, exports.KEY_RAW]; + if (!nou) + all = Object.keys(all); -exports.DOT_SLASH = `.${sep}`; + if (!self.nosort) + all = all.sort(self.nocase ? alphasorti : alphasort); -exports.BACK_SLASH_RE = /\\/g; -exports.DOUBLE_SLASH_RE = /\/\//; -exports.SLASH_OR_BACK_SLASH_RE = /[/\\]/; -exports.DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/; -exports.REPLACER_RE = /^\.[/\\]/; + // at *some* point we statted all of these + if (self.mark) { + for (var i = 0; i < all.length; i++) { + all[i] = self._mark(all[i]); + } + if (self.nodir) { + all = all.filter(function (e) { + var notDir = !(/\/$/.test(e)); + var c = self.cache[e] || self.cache[makeAbs(self, e)]; + if (notDir && c) + notDir = c !== 'DIR' && !Array.isArray(c); + return notDir + }); + } + } -exports.SLASH = '/'; -exports.SLASH_SLASH = '//'; -exports.BRACE_START = '{'; -exports.BANG = '!'; -exports.ONE_DOT = '.'; -exports.TWO_DOTS = '..'; -exports.STAR = '*'; -exports.GLOBSTAR = '**'; -exports.ROOT_GLOBSTAR = '/**/*'; -exports.SLASH_GLOBSTAR = '/**'; -exports.DIR_SUFFIX = 'Dir'; -exports.ANYMATCH_OPTS = {dot: true}; -exports.STRING_TYPE = 'string'; -exports.FUNCTION_TYPE = 'function'; -exports.EMPTY_STR = ''; -exports.EMPTY_FN = () => {}; -exports.IDENTITY_FN = val => val; + if (self.ignore.length) + all = all.filter(function(m) { + return !isIgnored$2(self, m) + }); -exports.isWindows = platform === 'win32'; -exports.isMacos = platform === 'darwin'; -exports.isLinux = platform === 'linux'; -exports.isIBMi = os.type() === 'OS400'; -}(constants$1)); + self.found = all; +} -const fs$2 = require$$0__default$3['default']; -const sysPath$2 = require$$0__default$2['default']; -const { promisify: promisify$2 } = require$$0__default['default']; -const isBinaryPath = isBinaryPath$1; -const { - isWindows: isWindows$1, - isLinux, - EMPTY_FN: EMPTY_FN$2, - EMPTY_STR: EMPTY_STR$1, - KEY_LISTENERS, - KEY_ERR, - KEY_RAW, - HANDLER_KEYS, - EV_CHANGE: EV_CHANGE$2, - EV_ADD: EV_ADD$2, - EV_ADD_DIR: EV_ADD_DIR$2, - EV_ERROR: EV_ERROR$2, - STR_DATA: STR_DATA$1, - STR_END: STR_END$2, - BRACE_START: BRACE_START$1, - STAR -} = constants$1; +function mark (self, p) { + var abs = makeAbs(self, p); + var c = self.cache[abs]; + var m = p; + if (c) { + var isDir = c === 'DIR' || Array.isArray(c); + var slash = p.slice(-1) === '/'; -const THROTTLE_MODE_WATCH = 'watch'; + if (isDir && !slash) + m += '/'; + else if (!isDir && slash) + m = m.slice(0, -1); -const open = promisify$2(fs$2.open); -const stat$2 = promisify$2(fs$2.stat); -const lstat$1 = promisify$2(fs$2.lstat); -const close = promisify$2(fs$2.close); -const fsrealpath = promisify$2(fs$2.realpath); + if (m !== p) { + var mabs = makeAbs(self, m); + self.statCache[mabs] = self.statCache[abs]; + self.cache[mabs] = self.cache[abs]; + } + } -const statMethods$1 = { lstat: lstat$1, stat: stat$2 }; + return m +} -// TODO: emit errors properly. Example: EMFILE on Macos. -const foreach = (val, fn) => { - if (val instanceof Set) { - val.forEach(fn); +// lotta situps... +function makeAbs (self, f) { + var abs = f; + if (f.charAt(0) === '/') { + abs = path$3.join(self.root, f); + } else if (isAbsolute$2(f) || f === '') { + abs = f; + } else if (self.changedCwd) { + abs = path$3.resolve(self.cwd, f); } else { - fn(val); + abs = path$3.resolve(f); } -}; -const addAndConvert = (main, prop, item) => { - let container = main[prop]; - if (!(container instanceof Set)) { - main[prop] = container = new Set([container]); - } - container.add(item); -}; + if (process.platform === 'win32') + abs = abs.replace(/\\/g, '/'); -const clearItem = cont => key => { - const set = cont[key]; - if (set instanceof Set) { - set.clear(); - } else { - delete cont[key]; - } -}; + return abs +} -const delFromSet = (main, prop, item) => { - const container = main[prop]; - if (container instanceof Set) { - container.delete(item); - } else if (container === item) { - delete main[prop]; - } -}; -const isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val; +// Return true, if pattern ends with globstar '**', for the accompanying parent directory. +// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents +function isIgnored$2 (self, path) { + if (!self.ignore.length) + return false -/** - * @typedef {String} Path - */ + return self.ignore.some(function(item) { + return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) + }) +} -// fs_watch helpers +function childrenIgnored$2 (self, path) { + if (!self.ignore.length) + return false -// object to hold per-process fs_watch instances -// (may be shared across chokidar FSWatcher instances) + return self.ignore.some(function(item) { + return !!(item.gmatcher && item.gmatcher.match(path)) + }) +} -/** - * @typedef {Object} FsWatchContainer - * @property {Set} listeners - * @property {Set} errHandlers - * @property {Set} rawEmitters - * @property {fs.FSWatcher=} watcher - * @property {Boolean=} watcherUnusable - */ +var sync$1 = globSync$1; +globSync$1.GlobSync = GlobSync$1; -/** - * @type {Map} - */ -const FsWatchInstances = new Map(); +var fs$1 = require$$0__default$1['default']; +var rp$1 = fs_realpath; +var minimatch$1 = minimatch_1; +var path$2 = path__default['default']; +var assert$1 = assert__default['default']; +var isAbsolute$1 = pathIsAbsolute.exports; +var common$1 = common$2; +common$1.alphasort; +common$1.alphasorti; +var setopts$1 = common$1.setopts; +var ownProp$1 = common$1.ownProp; +var childrenIgnored$1 = common$1.childrenIgnored; +var isIgnored$1 = common$1.isIgnored; -/** - * Instantiates the fs_watch interface - * @param {String} path to be watched - * @param {Object} options to be passed to fs_watch - * @param {Function} listener main event handler - * @param {Function} errHandler emits info about errors - * @param {Function} emitRaw emits raw event data - * @returns {fs.FSWatcher} new fsevents instance - */ -function createFsWatchInstance(path, options, listener, errHandler, emitRaw) { - const handleEvent = (rawEvent, evPath) => { - listener(path); - emitRaw(rawEvent, evPath, {watchedPath: path}); +function globSync$1 (pattern, options) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') - // emit based on events occurring for files from a directory's watcher in - // case the file's watcher misses it (and rely on throttling to de-dupe) - if (evPath && path !== evPath) { - fsWatchBroadcast( - sysPath$2.resolve(path, evPath), KEY_LISTENERS, sysPath$2.join(path, evPath) - ); - } - }; - try { - return fs$2.watch(path, options, handleEvent); - } catch (error) { - errHandler(error); - } + return new GlobSync$1(pattern, options).found } -/** - * Helper for passing fs_watch event data to a collection of listeners - * @param {Path} fullPath absolute path bound to fs_watch instance - * @param {String} type listener type - * @param {*=} val1 arguments to be passed to listeners - * @param {*=} val2 - * @param {*=} val3 - */ -const fsWatchBroadcast = (fullPath, type, val1, val2, val3) => { - const cont = FsWatchInstances.get(fullPath); - if (!cont) return; - foreach(cont[type], (listener) => { - listener(val1, val2, val3); - }); -}; +function GlobSync$1 (pattern, options) { + if (!pattern) + throw new Error('must provide pattern') -/** - * Instantiates the fs_watch interface or binds listeners - * to an existing one covering the same file system entry - * @param {String} path - * @param {String} fullPath absolute path - * @param {Object} options to be passed to fs_watch - * @param {Object} handlers container for event listener functions - */ -const setFsWatchListener = (path, fullPath, options, handlers) => { - const {listener, errHandler, rawEmitter} = handlers; - let cont = FsWatchInstances.get(fullPath); + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') - /** @type {fs.FSWatcher=} */ - let watcher; - if (!options.persistent) { - watcher = createFsWatchInstance( - path, options, listener, errHandler, rawEmitter - ); - return watcher.close.bind(watcher); + if (!(this instanceof GlobSync$1)) + return new GlobSync$1(pattern, options) + + setopts$1(this, pattern, options); + + if (this.noprocess) + return this + + var n = this.minimatch.set.length; + this.matches = new Array(n); + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false); } - if (cont) { - addAndConvert(cont, KEY_LISTENERS, listener); - addAndConvert(cont, KEY_ERR, errHandler); - addAndConvert(cont, KEY_RAW, rawEmitter); - } else { - watcher = createFsWatchInstance( - path, - options, - fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), - errHandler, // no need to use broadcast here - fsWatchBroadcast.bind(null, fullPath, KEY_RAW) - ); - if (!watcher) return; - watcher.on(EV_ERROR$2, async (error) => { - const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR); - cont.watcherUnusable = true; // documented since Node 10.4.1 - // Workaround for https://github.com/joyent/node/issues/4337 - if (isWindows$1 && error.code === 'EPERM') { + this._finish(); +} + +GlobSync$1.prototype._finish = function () { + assert$1(this instanceof GlobSync$1); + if (this.realpath) { + var self = this; + this.matches.forEach(function (matchset, index) { + var set = self.matches[index] = Object.create(null); + for (var p in matchset) { try { - const fd = await open(path, 'r'); - await close(fd); - broadcastErr(error); - } catch (err) {} - } else { - broadcastErr(error); + p = self._makeAbs(p); + var real = rp$1.realpathSync(p, self.realpathCache); + set[real] = true; + } catch (er) { + if (er.syscall === 'stat') + set[self._makeAbs(p)] = true; + else + throw er + } } }); - cont = { - listeners: listener, - errHandlers: errHandler, - rawEmitters: rawEmitter, - watcher - }; - FsWatchInstances.set(fullPath, cont); } - // const index = cont.listeners.indexOf(listener); - - // removes this instance's listeners and closes the underlying fs_watch - // instance if there are no more listeners left - return () => { - delFromSet(cont, KEY_LISTENERS, listener); - delFromSet(cont, KEY_ERR, errHandler); - delFromSet(cont, KEY_RAW, rawEmitter); - if (isEmptySet(cont.listeners)) { - // Check to protect against issue gh-730. - // if (cont.watcherUnusable) { - cont.watcher.close(); - // } - FsWatchInstances.delete(fullPath); - HANDLER_KEYS.forEach(clearItem(cont)); - cont.watcher = undefined; - Object.freeze(cont); - } - }; + common$1.finish(this); }; -// fs_watchFile helpers - -// object to hold per-process fs_watchFile instances -// (may be shared across chokidar FSWatcher instances) -const FsWatchFileInstances = new Map(); -/** - * Instantiates the fs_watchFile interface or binds listeners - * to an existing one covering the same file system entry - * @param {String} path to be watched - * @param {String} fullPath absolute path - * @param {Object} options options to be passed to fs_watchFile - * @param {Object} handlers container for event listener functions - * @returns {Function} closer - */ -const setFsWatchFileListener = (path, fullPath, options, handlers) => { - const {listener, rawEmitter} = handlers; - let cont = FsWatchFileInstances.get(fullPath); +GlobSync$1.prototype._process = function (pattern, index, inGlobStar) { + assert$1(this instanceof GlobSync$1); - const copts = cont && cont.options; - if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) { - fs$2.unwatchFile(fullPath); - cont = undefined; + // Get the first [n] parts of pattern that are all strings. + var n = 0; + while (typeof pattern[n] === 'string') { + n ++; } + // now n is the index of the first one that is *not* a string. - /* eslint-enable no-unused-vars, prefer-destructuring */ + // See if there's anything else + var prefix; + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index); + return - if (cont) { - addAndConvert(cont, KEY_LISTENERS, listener); - addAndConvert(cont, KEY_RAW, rawEmitter); - } else { - // TODO - // listeners.add(listener); - // rawEmitters.add(rawEmitter); - cont = { - listeners: listener, - rawEmitters: rawEmitter, - options, - watcher: fs$2.watchFile(fullPath, options, (curr, prev) => { - foreach(cont.rawEmitters, (rawEmitter) => { - rawEmitter(EV_CHANGE$2, fullPath, {curr, prev}); - }); - const currmtime = curr.mtimeMs; - if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) { - foreach(cont.listeners, (listener) => listener(path, curr)); - } - }) - }; - FsWatchFileInstances.set(fullPath, cont); + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null; + break + + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/'); + break } - // const index = cont.listeners.indexOf(listener); - // Removes this instance's listeners and closes the underlying fs_watchFile - // instance if there are no more listeners left. - return () => { - delFromSet(cont, KEY_LISTENERS, listener); - delFromSet(cont, KEY_RAW, rawEmitter); - if (isEmptySet(cont.listeners)) { - FsWatchFileInstances.delete(fullPath); - fs$2.unwatchFile(fullPath); - cont.options = cont.watcher = undefined; - Object.freeze(cont); - } - }; -}; + var remain = pattern.slice(n); -/** - * @mixin - */ -class NodeFsHandler$1 { + // get the list of entries. + var read; + if (prefix === null) + read = '.'; + else if (isAbsolute$1(prefix) || isAbsolute$1(pattern.join('/'))) { + if (!prefix || !isAbsolute$1(prefix)) + prefix = '/' + prefix; + read = prefix; + } else + read = prefix; -/** - * @param {import("../index").FSWatcher} fsW - */ -constructor(fsW) { - this.fsw = fsW; - this._boundHandleError = (error) => fsW._handleError(error); -} + var abs = this._makeAbs(read); -/** - * Watch file for changes with fs_watchFile or fs_watch. - * @param {String} path to file or dir - * @param {Function} listener on fs change - * @returns {Function} closer for the watcher instance - */ -_watchWithNodeFs(path, listener) { - const opts = this.fsw.options; - const directory = sysPath$2.dirname(path); - const basename = sysPath$2.basename(path); - const parent = this.fsw._getWatchedDir(directory); - parent.add(basename); - const absolutePath = sysPath$2.resolve(path); - const options = {persistent: opts.persistent}; - if (!listener) listener = EMPTY_FN$2; + //if ignored, skip processing + if (childrenIgnored$1(this, read)) + return - let closer; - if (opts.usePolling) { - options.interval = opts.enableBinaryInterval && isBinaryPath(basename) ? - opts.binaryInterval : opts.interval; - closer = setFsWatchFileListener(path, absolutePath, options, { - listener, - rawEmitter: this.fsw._emitRaw - }); - } else { - closer = setFsWatchListener(path, absolutePath, options, { - listener, - errHandler: this._boundHandleError, - rawEmitter: this.fsw._emitRaw - }); - } - return closer; -} + var isGlobStar = remain[0] === minimatch$1.GLOBSTAR; + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar); + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar); +}; -/** - * Watch a file and emit add event if warranted. - * @param {Path} file Path - * @param {fs.Stats} stats result of fs_stat - * @param {Boolean} initialAdd was the file added at watch instantiation? - * @returns {Function} closer for the watcher instance - */ -_handleFile(file, stats, initialAdd) { - if (this.fsw.closed) { - return; - } - const dirname = sysPath$2.dirname(file); - const basename = sysPath$2.basename(file); - const parent = this.fsw._getWatchedDir(dirname); - // stats is always present - let prevStats = stats; - // if the file is already being watched, do nothing - if (parent.has(basename)) return; +GlobSync$1.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar); - const listener = async (path, newStats) => { - if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return; - if (!newStats || newStats.mtimeMs === 0) { - try { - const newStats = await stat$2(file); - if (this.fsw.closed) return; - // Check that change event was not fired because of changed only accessTime. - const at = newStats.atimeMs; - const mt = newStats.mtimeMs; - if (!at || at <= mt || mt !== prevStats.mtimeMs) { - this.fsw._emit(EV_CHANGE$2, file, newStats); - } - if (isLinux && prevStats.ino !== newStats.ino) { - this.fsw._closeFile(path); - prevStats = newStats; - this.fsw._addPathCloser(path, this._watchWithNodeFs(file, listener)); - } else { - prevStats = newStats; - } - } catch (error) { - // Fix issues where mtime is null but file is still present - this.fsw._remove(dirname, basename); - } - // add is about to be emitted if file not already tracked in parent - } else if (parent.has(basename)) { - // Check that change event was not fired because of changed only accessTime. - const at = newStats.atimeMs; - const mt = newStats.mtimeMs; - if (!at || at <= mt || mt !== prevStats.mtimeMs) { - this.fsw._emit(EV_CHANGE$2, file, newStats); + // if the abs isn't a dir, then nothing can match! + if (!entries) + return + + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0]; + var negate = !!this.minimatch.negate; + var rawGlob = pn._glob; + var dotOk = this.dot || rawGlob.charAt(0) === '.'; + + var matchedEntries = []; + for (var i = 0; i < entries.length; i++) { + var e = entries[i]; + if (e.charAt(0) !== '.' || dotOk) { + var m; + if (negate && !prefix) { + m = !e.match(pn); + } else { + m = e.match(pn); } - prevStats = newStats; + if (m) + matchedEntries.push(e); } - }; - // kick off the watcher - const closer = this._watchWithNodeFs(file, listener); - - // emit an add event if we're supposed to - if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) { - if (!this.fsw._throttle(EV_ADD$2, file, 0)) return; - this.fsw._emit(EV_ADD$2, file, stats); } - return closer; -} + var len = matchedEntries.length; + // If there are no matched entries, then nothing matches. + if (len === 0) + return -/** - * Handle symlinks encountered while reading a dir. - * @param {Object} entry returned by readdirp - * @param {String} directory path of dir being read - * @param {String} path of this item - * @param {String} item basename of this item - * @returns {Promise} true if no more processing is needed for this entry. - */ -async _handleSymlink(entry, directory, path, item) { - if (this.fsw.closed) { - return; - } - const full = entry.fullPath; - const dir = this.fsw._getWatchedDir(directory); + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. - if (!this.fsw.options.followSymlinks) { - // watch symlink directly (don't follow) and detect changes - this.fsw._incrReadyCount(); - const linkPath = await fsrealpath(path); - if (this.fsw.closed) return; - if (dir.has(item)) { - if (this.fsw._symlinkPaths.get(full) !== linkPath) { - this.fsw._symlinkPaths.set(full, linkPath); - this.fsw._emit(EV_CHANGE$2, path, entry.stats); + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null); + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i]; + if (prefix) { + if (prefix.slice(-1) !== '/') + e = prefix + '/' + e; + else + e = prefix + e; } - } else { - dir.add(item); - this.fsw._symlinkPaths.set(full, linkPath); - this.fsw._emit(EV_ADD$2, path, entry.stats); + + if (e.charAt(0) === '/' && !this.nomount) { + e = path$2.join(this.root, e); + } + this._emitMatch(index, e); } - this.fsw._emitReady(); - return true; + // This was the last one, and no stats were needed + return } - // don't follow the same symlink more than once - if (this.fsw._symlinkPaths.has(full)) { - return true; + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift(); + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i]; + var newPattern; + if (prefix) + newPattern = [prefix, e]; + else + newPattern = [e]; + this._process(newPattern.concat(remain), index, inGlobStar); } +}; - this.fsw._symlinkPaths.set(full, true); -} -_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) { - // Normalize the directory name on Windows - directory = sysPath$2.join(directory, EMPTY_STR$1); +GlobSync$1.prototype._emitMatch = function (index, e) { + if (isIgnored$1(this, e)) + return - if (!wh.hasGlob) { - throttler = this.fsw._throttle('readdir', directory, 1000); - if (!throttler) return; + var abs = this._makeAbs(e); + + if (this.mark) + e = this._mark(e); + + if (this.absolute) { + e = abs; } - const previous = this.fsw._getWatchedDir(wh.path); - const current = new Set(); + if (this.matches[index][e]) + return - let stream = this.fsw._readdirp(directory, { - fileFilter: entry => wh.filterPath(entry), - directoryFilter: entry => wh.filterDir(entry), - depth: 0 - }).on(STR_DATA$1, async (entry) => { - if (this.fsw.closed) { - stream = undefined; - return; - } - const item = entry.path; - let path = sysPath$2.join(directory, item); - current.add(item); - - if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) { - return; - } - - if (this.fsw.closed) { - stream = undefined; - return; - } - // Files that present in current directory snapshot - // but absent in previous are added to watch list and - // emit `add` event. - if (item === target || !target && !previous.has(item)) { - this.fsw._incrReadyCount(); + if (this.nodir) { + var c = this.cache[abs]; + if (c === 'DIR' || Array.isArray(c)) + return + } - // ensure relativeness of path is preserved in case of watcher reuse - path = sysPath$2.join(dir, sysPath$2.relative(dir, path)); + this.matches[index][e] = true; - this._addToNodeFs(path, initialAdd, wh, depth + 1); - } - }).on(EV_ERROR$2, this._boundHandleError); + if (this.stat) + this._stat(e); +}; - return new Promise(resolve => - stream.once(STR_END$2, () => { - if (this.fsw.closed) { - stream = undefined; - return; - } - const wasThrottled = throttler ? throttler.clear() : false; - resolve(); +GlobSync$1.prototype._readdirInGlobStar = function (abs) { + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false) - // Files that absent in current directory snapshot - // but present in previous emit `remove` event - // and are removed from @watched[directory]. - previous.getChildren().filter((item) => { - return item !== directory && - !current.has(item) && - // in case of intersecting globs; - // a path may have been filtered out of this readdir, but - // shouldn't be removed because it matches a different glob - (!wh.hasGlob || wh.filterPath({ - fullPath: sysPath$2.resolve(directory, item) - })); - }).forEach((item) => { - this.fsw._remove(directory, item); - }); + var entries; + var lstat; + try { + lstat = fs$1.lstatSync(abs); + } catch (er) { + if (er.code === 'ENOENT') { + // lstat failed, doesn't exist + return null + } + } - stream = undefined; + var isSym = lstat && lstat.isSymbolicLink(); + this.symlinks[abs] = isSym; - // one more time for any missed in case changes came in extremely quickly - if (wasThrottled) this._handleRead(directory, false, wh, target, dir, depth, throttler); - }) - ); -} + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) + this.cache[abs] = 'FILE'; + else + entries = this._readdir(abs, false); -/** - * Read directory to add / remove files from `@watched` list and re-read it on change. - * @param {String} dir fs path - * @param {fs.Stats} stats - * @param {Boolean} initialAdd - * @param {Number} depth relative to user-supplied path - * @param {String} target child path targeted for watch - * @param {Object} wh Common watch helpers for this path - * @param {String} realpath - * @returns {Promise} closer for the watcher instance. - */ -async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) { - const parentDir = this.fsw._getWatchedDir(sysPath$2.dirname(dir)); - const tracked = parentDir.has(sysPath$2.basename(dir)); - if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) { - if (!wh.hasGlob || wh.globFilter(dir)) this.fsw._emit(EV_ADD_DIR$2, dir, stats); - } + return entries +}; - // ensure dir is tracked (harmless if redundant) - parentDir.add(sysPath$2.basename(dir)); - this.fsw._getWatchedDir(dir); - let throttler; - let closer; +GlobSync$1.prototype._readdir = function (abs, inGlobStar) { - const oDepth = this.fsw.options.depth; - if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) { - if (!target) { - await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler); - if (this.fsw.closed) return; - } + if (inGlobStar && !ownProp$1(this.symlinks, abs)) + return this._readdirInGlobStar(abs) - closer = this._watchWithNodeFs(dir, (dirPath, stats) => { - // if current directory is removed, do nothing - if (stats && stats.mtimeMs === 0) return; + if (ownProp$1(this.cache, abs)) { + var c = this.cache[abs]; + if (!c || c === 'FILE') + return null - this._handleRead(dirPath, false, wh, target, dir, depth, throttler); - }); + if (Array.isArray(c)) + return c } - return closer; -} -/** - * Handle added file, directory, or glob pattern. - * Delegates call to _handleFile / _handleDir after checks. - * @param {String} path to file or ir - * @param {Boolean} initialAdd was the file added at watch instantiation? - * @param {Object} priorWh depth relative to user-supplied path - * @param {Number} depth Child path actually targeted for watch - * @param {String=} target Child path actually targeted for watch - * @returns {Promise} - */ -async _addToNodeFs(path, initialAdd, priorWh, depth, target) { - const ready = this.fsw._emitReady; - if (this.fsw._isIgnored(path) || this.fsw.closed) { - ready(); - return false; + try { + return this._readdirEntries(abs, fs$1.readdirSync(abs)) + } catch (er) { + this._readdirError(abs, er); + return null } +}; - const wh = this.fsw._getWatchHelpers(path, depth); - if (!wh.hasGlob && priorWh) { - wh.hasGlob = priorWh.hasGlob; - wh.globFilter = priorWh.globFilter; - wh.filterPath = entry => priorWh.filterPath(entry); - wh.filterDir = entry => priorWh.filterDir(entry); +GlobSync$1.prototype._readdirEntries = function (abs, entries) { + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i]; + if (abs === '/') + e = abs + e; + else + e = abs + '/' + e; + this.cache[e] = true; + } } - // evaluate what is at the path we're being asked to watch - try { - const stats = await statMethods$1[wh.statMethod](wh.watchPath); - if (this.fsw.closed) return; - if (this.fsw._isIgnored(wh.watchPath, stats)) { - ready(); - return false; - } + this.cache[abs] = entries; - const follow = this.fsw.options.followSymlinks && !path.includes(STAR) && !path.includes(BRACE_START$1); - let closer; - if (stats.isDirectory()) { - const absPath = sysPath$2.resolve(path); - const targetPath = follow ? await fsrealpath(path) : path; - if (this.fsw.closed) return; - closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath); - if (this.fsw.closed) return; - // preserve this symlink's target path - if (absPath !== targetPath && targetPath !== undefined) { - this.fsw._symlinkPaths.set(absPath, targetPath); - } - } else if (stats.isSymbolicLink()) { - const targetPath = follow ? await fsrealpath(path) : path; - if (this.fsw.closed) return; - const parent = sysPath$2.dirname(wh.watchPath); - this.fsw._getWatchedDir(parent).add(wh.watchPath); - this.fsw._emit(EV_ADD$2, wh.watchPath, stats); - closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath); - if (this.fsw.closed) return; + // mark and cache dir-ness + return entries +}; - // preserve this symlink's target path - if (targetPath !== undefined) { - this.fsw._symlinkPaths.set(sysPath$2.resolve(path), targetPath); +GlobSync$1.prototype._readdirError = function (f, er) { + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f); + this.cache[abs] = 'FILE'; + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd); + error.path = this.cwd; + error.code = er.code; + throw error } - } else { - closer = this._handleFile(wh.watchPath, stats, initialAdd); - } - ready(); + break - this.fsw._addPathCloser(path, closer); - return false; + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false; + break - } catch (error) { - if (this.fsw._handleError(error)) { - ready(); - return path; - } + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false; + if (this.strict) + throw er + if (!this.silent) + console.error('glob error', er); + break } -} - -} +}; -var nodefsHandler = NodeFsHandler$1; +GlobSync$1.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { -var fseventsHandler = {exports: {}}; + var entries = this._readdir(abs, inGlobStar); -const fs$1 = require$$0__default$3['default']; -const sysPath$1 = require$$0__default$2['default']; -const { promisify: promisify$1 } = require$$0__default['default']; + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return -let fsevents; -try { - fsevents = undefined; -} catch (error) { - if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error); -} + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1); + var gspref = prefix ? [ prefix ] : []; + var noGlobStar = gspref.concat(remainWithoutGlobStar); -if (fsevents) { - // TODO: real check - const mtch = process.version.match(/v(\d+)\.(\d+)/); - if (mtch && mtch[1] && mtch[2]) { - const maj = Number.parseInt(mtch[1], 10); - const min = Number.parseInt(mtch[2], 10); - if (maj === 8 && min < 16) { - fsevents = undefined; - } - } -} + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false); -const { - EV_ADD: EV_ADD$1, - EV_CHANGE: EV_CHANGE$1, - EV_ADD_DIR: EV_ADD_DIR$1, - EV_UNLINK: EV_UNLINK$1, - EV_ERROR: EV_ERROR$1, - STR_DATA, - STR_END: STR_END$1, - FSEVENT_CREATED, - FSEVENT_MODIFIED, - FSEVENT_DELETED, - FSEVENT_MOVED, - // FSEVENT_CLONED, - FSEVENT_UNKNOWN, - FSEVENT_TYPE_FILE, - FSEVENT_TYPE_DIRECTORY, - FSEVENT_TYPE_SYMLINK, + var len = entries.length; + var isSym = this.symlinks[abs]; - ROOT_GLOBSTAR, - DIR_SUFFIX, - DOT_SLASH, - FUNCTION_TYPE: FUNCTION_TYPE$1, - EMPTY_FN: EMPTY_FN$1, - IDENTITY_FN -} = constants$1; + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return -const Depth = (value) => isNaN(value) ? {} : {depth: value}; + for (var i = 0; i < len; i++) { + var e = entries[i]; + if (e.charAt(0) === '.' && !this.dot) + continue -const stat$1 = promisify$1(fs$1.stat); -const lstat = promisify$1(fs$1.lstat); -const realpath = promisify$1(fs$1.realpath); + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar); + this._process(instead, index, true); -const statMethods = { stat: stat$1, lstat }; + var below = gspref.concat(entries[i], remain); + this._process(below, index, true); + } +}; -/** - * @typedef {String} Path - */ +GlobSync$1.prototype._processSimple = function (prefix, index) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var exists = this._stat(prefix); -/** - * @typedef {Object} FsEventsWatchContainer - * @property {Set} listeners - * @property {Function} rawEmitter - * @property {{stop: Function}} watcher - */ + if (!this.matches[index]) + this.matches[index] = Object.create(null); -// fsevents instance helper functions -/** - * Object to hold per-process fsevents instances (may be shared across chokidar FSWatcher instances) - * @type {Map} - */ -const FSEventsWatchers = new Map(); + // If it doesn't exist, then just mark the lack of results + if (!exists) + return -// Threshold of duplicate path prefixes at which to start -// consolidating going forward -const consolidateThreshhold = 10; + if (prefix && isAbsolute$1(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix); + if (prefix.charAt(0) === '/') { + prefix = path$2.join(this.root, prefix); + } else { + prefix = path$2.resolve(this.root, prefix); + if (trail) + prefix += '/'; + } + } -const wrongEventFlags = new Set([ - 69888, 70400, 71424, 72704, 73472, 131328, 131840, 262912 -]); + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/'); -/** - * Instantiates the fsevents interface - * @param {Path} path path to be watched - * @param {Function} callback called when fsevents is bound and ready - * @returns {{stop: Function}} new fsevents instance - */ -const createFSEventsInstance = (path, callback) => { - const stop = fsevents.watch(path, callback); - return {stop}; + // Mark this as a match + this._emitMatch(index, prefix); }; -/** - * Instantiates the fsevents interface or binds listeners to an existing one covering - * the same file tree. - * @param {Path} path - to be watched - * @param {Path} realPath - real path for symlinks - * @param {Function} listener - called when fsevents emits events - * @param {Function} rawEmitter - passes data to listeners of the 'raw' event - * @returns {Function} closer - */ -function setFSEventsListener(path, realPath, listener, rawEmitter) { - let watchPath = sysPath$1.extname(realPath) ? sysPath$1.dirname(realPath) : realPath; - - const parentPath = sysPath$1.dirname(watchPath); - let cont = FSEventsWatchers.get(watchPath); +// Returns either 'DIR', 'FILE', or false +GlobSync$1.prototype._stat = function (f) { + var abs = this._makeAbs(f); + var needDir = f.slice(-1) === '/'; - // If we've accumulated a substantial number of paths that - // could have been consolidated by watching one directory - // above the current one, create a watcher on the parent - // path instead, so that we do consolidate going forward. - if (couldConsolidate(parentPath)) { - watchPath = parentPath; - } + if (f.length > this.maxLength) + return false - const resolvedPath = sysPath$1.resolve(path); - const hasSymlink = resolvedPath !== realPath; + if (!this.stat && ownProp$1(this.cache, abs)) { + var c = this.cache[abs]; - const filteredListener = (fullPath, flags, info) => { - if (hasSymlink) fullPath = fullPath.replace(realPath, resolvedPath); - if ( - fullPath === resolvedPath || - !fullPath.indexOf(resolvedPath + sysPath$1.sep) - ) listener(fullPath, flags, info); - }; + if (Array.isArray(c)) + c = 'DIR'; - // check if there is already a watcher on a parent path - // modifies `watchPath` to the parent path when it finds a match - let watchedParent = false; - for (const watchedPath of FSEventsWatchers.keys()) { - if (realPath.indexOf(sysPath$1.resolve(watchedPath) + sysPath$1.sep) === 0) { - watchPath = watchedPath; - cont = FSEventsWatchers.get(watchPath); - watchedParent = true; - break; - } - } + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return c - if (cont || watchedParent) { - cont.listeners.add(filteredListener); - } else { - cont = { - listeners: new Set([filteredListener]), - rawEmitter, - watcher: createFSEventsInstance(watchPath, (fullPath, flags) => { - if (!cont.listeners.size) return; - const info = fsevents.getInfo(fullPath, flags); - cont.listeners.forEach(list => { - list(fullPath, flags, info); - }); + if (needDir && c === 'FILE') + return false - cont.rawEmitter(info.event, fullPath, info); - }) - }; - FSEventsWatchers.set(watchPath, cont); + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. } - - // removes this instance's listeners and closes the underlying fsevents - // instance if there are no more listeners left - return () => { - const lst = cont.listeners; - - lst.delete(filteredListener); - if (!lst.size) { - FSEventsWatchers.delete(watchPath); - if (cont.watcher) return cont.watcher.stop().then(() => { - cont.rawEmitter = cont.watcher = undefined; - Object.freeze(cont); - }); + var stat = this.statCache[abs]; + if (!stat) { + var lstat; + try { + lstat = fs$1.lstatSync(abs); + } catch (er) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false; + return false + } } - }; -} -// Decide whether or not we should start a new higher-level -// parent watcher -const couldConsolidate = (path) => { - let count = 0; - for (const watchPath of FSEventsWatchers.keys()) { - if (watchPath.indexOf(path) === 0) { - count++; - if (count >= consolidateThreshhold) { - return true; + if (lstat && lstat.isSymbolicLink()) { + try { + stat = fs$1.statSync(abs); + } catch (er) { + stat = lstat; } + } else { + stat = lstat; } } - return false; -}; + this.statCache[abs] = stat; -// returns boolean indicating whether fsevents can be used -const canUse = () => fsevents && FSEventsWatchers.size < 128; + var c = true; + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE'; -// determines subdirectory traversal levels from root to path -const calcDepth = (path, root) => { - let i = 0; - while (!path.indexOf(root) && (path = sysPath$1.dirname(path)) !== root) i++; - return i; + this.cache[abs] = this.cache[abs] || c; + + if (needDir && c === 'FILE') + return false + + return c }; -// returns boolean indicating whether the fsevents' event info has the same type -// as the one returned by fs.stat -const sameTypes = (info, stats) => ( - info.type === FSEVENT_TYPE_DIRECTORY && stats.isDirectory() || - info.type === FSEVENT_TYPE_SYMLINK && stats.isSymbolicLink() || - info.type === FSEVENT_TYPE_FILE && stats.isFile() -); +GlobSync$1.prototype._mark = function (p) { + return common$1.mark(this, p) +}; -/** - * @mixin - */ -class FsEventsHandler$1 { +GlobSync$1.prototype._makeAbs = function (f) { + return common$1.makeAbs(this, f) +}; -/** - * @param {import('../index').FSWatcher} fsw - */ -constructor(fsw) { - this.fsw = fsw; -} -checkIgnored(path, stats) { - const ipaths = this.fsw._ignoredPaths; - if (this.fsw._isIgnored(path, stats)) { - ipaths.add(path); - if (stats && stats.isDirectory()) { - ipaths.add(path + ROOT_GLOBSTAR); - } - return true; - } +// Returns a wrapper function that returns a wrapped callback +// The wrapper function should do some stuff, and return a +// presumably different callback function. +// This makes sure that own properties are retained, so that +// decorations and such are not lost along the way. +var wrappy_1 = wrappy$2; +function wrappy$2 (fn, cb) { + if (fn && cb) return wrappy$2(fn)(cb) - ipaths.delete(path); - ipaths.delete(path + ROOT_GLOBSTAR); -} + if (typeof fn !== 'function') + throw new TypeError('need wrapper function') -addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) { - const event = watchedDir.has(item) ? EV_CHANGE$1 : EV_ADD$1; - this.handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts); -} + Object.keys(fn).forEach(function (k) { + wrapper[k] = fn[k]; + }); -async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts) { - try { - const stats = await stat$1(path); - if (this.fsw.closed) return; - if (sameTypes(info, stats)) { - this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); - } else { - this.handleEvent(EV_UNLINK$1, path, fullPath, realPath, parent, watchedDir, item, info, opts); + return wrapper + + function wrapper() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; } - } catch (error) { - if (error.code === 'EACCES') { - this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); - } else { - this.handleEvent(EV_UNLINK$1, path, fullPath, realPath, parent, watchedDir, item, info, opts); + var ret = fn.apply(this, args); + var cb = args[args.length-1]; + if (typeof ret === 'function' && ret !== cb) { + Object.keys(cb).forEach(function (k) { + ret[k] = cb[k]; + }); } + return ret } } -handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts) { - if (this.fsw.closed || this.checkIgnored(path)) return; +var once$3 = {exports: {}}; - if (event === EV_UNLINK$1) { - const isDirectory = info.type === FSEVENT_TYPE_DIRECTORY; - // suppress unlink events on never before seen files - if (isDirectory || watchedDir.has(item)) { - this.fsw._remove(parent, item, isDirectory); - } - } else { - if (event === EV_ADD$1) { - // track new directories - if (info.type === FSEVENT_TYPE_DIRECTORY) this.fsw._getWatchedDir(path); +var wrappy$1 = wrappy_1; +once$3.exports = wrappy$1(once$2); +once$3.exports.strict = wrappy$1(onceStrict); - if (info.type === FSEVENT_TYPE_SYMLINK && opts.followSymlinks) { - // push symlinks back to the top of the stack to get handled - const curDepth = opts.depth === undefined ? - undefined : calcDepth(fullPath, realPath) + 1; - return this._addToFsEvents(path, false, true, curDepth); - } +once$2.proto = once$2(function () { + Object.defineProperty(Function.prototype, 'once', { + value: function () { + return once$2(this) + }, + configurable: true + }); - // track new paths - // (other than symlinks being followed, which will be tracked soon) - this.fsw._getWatchedDir(parent).add(item); - } - /** - * @type {'add'|'addDir'|'unlink'|'unlinkDir'} - */ - const eventName = info.type === FSEVENT_TYPE_DIRECTORY ? event + DIR_SUFFIX : event; - this.fsw._emit(eventName, path); - if (eventName === EV_ADD_DIR$1) this._addToFsEvents(path, false, true); + Object.defineProperty(Function.prototype, 'onceStrict', { + value: function () { + return onceStrict(this) + }, + configurable: true + }); +}); + +function once$2 (fn) { + var f = function () { + if (f.called) return f.value + f.called = true; + return f.value = fn.apply(this, arguments) + }; + f.called = false; + return f +} + +function onceStrict (fn) { + var f = function () { + if (f.called) + throw new Error(f.onceError) + f.called = true; + return f.value = fn.apply(this, arguments) + }; + var name = fn.name || 'Function wrapped with `once`'; + f.onceError = name + " shouldn't be called more than once"; + f.called = false; + return f +} + +var wrappy = wrappy_1; +var reqs = Object.create(null); +var once$1 = once$3.exports; + +var inflight_1 = wrappy(inflight$1); + +function inflight$1 (key, cb) { + if (reqs[key]) { + reqs[key].push(cb); + return null + } else { + reqs[key] = [cb]; + return makeres(key) } } -/** - * Handle symlinks encountered during directory scan - * @param {String} watchPath - file/dir path to be watched with fsevents - * @param {String} realPath - real path (in case of symlinks) - * @param {Function} transform - path transformer - * @param {Function} globFilter - path filter in case a glob pattern was provided - * @returns {Function} closer for the watcher instance -*/ -_watchWithFsEvents(watchPath, realPath, transform, globFilter) { - if (this.fsw.closed || this.fsw._isIgnored(watchPath)) return; - const opts = this.fsw.options; - const watchCallback = async (fullPath, flags, info) => { - if (this.fsw.closed) return; - if ( - opts.depth !== undefined && - calcDepth(fullPath, realPath) > opts.depth - ) return; - const path = transform(sysPath$1.join( - watchPath, sysPath$1.relative(watchPath, fullPath) - )); - if (globFilter && !globFilter(path)) return; - // ensure directories are tracked - const parent = sysPath$1.dirname(path); - const item = sysPath$1.basename(path); - const watchedDir = this.fsw._getWatchedDir( - info.type === FSEVENT_TYPE_DIRECTORY ? path : parent - ); +function makeres (key) { + return once$1(function RES () { + var cbs = reqs[key]; + var len = cbs.length; + var args = slice$1(arguments); - // correct for wrong events emitted - if (wrongEventFlags.has(flags) || info.event === FSEVENT_UNKNOWN) { - if (typeof opts.ignored === FUNCTION_TYPE$1) { - let stats; - try { - stats = await stat$1(path); - } catch (error) {} - if (this.fsw.closed) return; - if (this.checkIgnored(path, stats)) return; - if (sameTypes(info, stats)) { - this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); - } else { - this.handleEvent(EV_UNLINK$1, path, fullPath, realPath, parent, watchedDir, item, info, opts); - } - } else { - this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts); + // XXX It's somewhat ambiguous whether a new callback added in this + // pass should be queued for later execution if something in the + // list of callbacks throws, or if it should just be discarded. + // However, it's such an edge case that it hardly matters, and either + // choice is likely as surprising as the other. + // As it happens, we do go ahead and schedule it for later execution. + try { + for (var i = 0; i < len; i++) { + cbs[i].apply(null, args); } - } else { - switch (info.event) { - case FSEVENT_CREATED: - case FSEVENT_MODIFIED: - return this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); - case FSEVENT_DELETED: - case FSEVENT_MOVED: - return this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } finally { + if (cbs.length > len) { + // added more in the interim. + // de-zalgo, just in case, but don't call again. + cbs.splice(0, len); + process.nextTick(function () { + RES.apply(null, args); + }); + } else { + delete reqs[key]; } } - }; + }) +} - const closer = setFSEventsListener( - watchPath, - realPath, - watchCallback, - this.fsw._emitRaw - ); +function slice$1 (args) { + var length = args.length; + var array = []; - this.fsw._emitReady(); - return closer; + for (var i = 0; i < length; i++) array[i] = args[i]; + return array } -/** - * Handle symlinks encountered during directory scan - * @param {String} linkPath path to symlink - * @param {String} fullPath absolute path to the symlink - * @param {Function} transform pre-existing path transformer - * @param {Number} curDepth level of subdirectories traversed to where symlink is - * @returns {Promise} - */ -async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) { - // don't follow the same symlink more than once - if (this.fsw.closed || this.fsw._symlinkPaths.has(fullPath)) return; +// Approach: +// +// 1. Get the minimatch set +// 2. For each pattern in the set, PROCESS(pattern, false) +// 3. Store matches per-set, then uniq them +// +// PROCESS(pattern, inGlobStar) +// Get the first [n] items from pattern that are all strings +// Join these together. This is PREFIX. +// If there is no more remaining, then stat(PREFIX) and +// add to matches if it succeeds. END. +// +// If inGlobStar and PREFIX is symlink and points to dir +// set ENTRIES = [] +// else readdir(PREFIX) as ENTRIES +// If fail, END +// +// with ENTRIES +// If pattern[n] is GLOBSTAR +// // handle the case where the globstar match is empty +// // by pruning it out, and testing the resulting pattern +// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) +// // handle other cases. +// for ENTRY in ENTRIES (not dotfiles) +// // attach globstar + tail onto the entry +// // Mark that this entry is a globstar match +// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) +// +// else // not globstar +// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) +// Test ENTRY against pattern[n] +// If fails, continue +// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) +// +// Caveat: +// Cache all stats and readdirs results to minimize syscall. Since all +// we ever care about is existence and directory-ness, we can just keep +// `true` for files, and [children,...] for directories, or `false` for +// things that don't exist. - this.fsw._symlinkPaths.set(fullPath, true); - this.fsw._incrReadyCount(); +var glob_1 = glob; - try { - const linkTarget = await realpath(linkPath); - if (this.fsw.closed) return; - if (this.fsw._isIgnored(linkTarget)) { - return this.fsw._emitReady(); - } +var fs = require$$0__default$1['default']; +var rp = fs_realpath; +var minimatch = minimatch_1; +var inherits$1 = inherits$2.exports; +var EE = require$$0__default$3['default'].EventEmitter; +var path$1 = path__default['default']; +var assert = assert__default['default']; +var isAbsolute = pathIsAbsolute.exports; +var globSync = sync$1; +var common = common$2; +common.alphasort; +common.alphasorti; +var setopts = common.setopts; +var ownProp = common.ownProp; +var inflight = inflight_1; +var childrenIgnored = common.childrenIgnored; +var isIgnored = common.isIgnored; - this.fsw._incrReadyCount(); +var once = once$3.exports; - // add the linkTarget for watching with a wrapper for transform - // that causes emitted paths to incorporate the link's path - this._addToFsEvents(linkTarget || linkPath, (path) => { - let aliasedPath = linkPath; - if (linkTarget && linkTarget !== DOT_SLASH) { - aliasedPath = path.replace(linkTarget, linkPath); - } else if (path !== DOT_SLASH) { - aliasedPath = sysPath$1.join(linkPath, path); - } - return transform(aliasedPath); - }, false, curDepth); - } catch(error) { - if (this.fsw._handleError(error)) { - return this.fsw._emitReady(); - } +function glob (pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {}; + if (!options) options = {}; + + if (options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return globSync(pattern, options) } + + return new Glob(pattern, options, cb) } -/** - * - * @param {Path} newPath - * @param {fs.Stats} stats - */ -emitAdd(newPath, stats, processPath, opts, forceAdd) { - const pp = processPath(newPath); - const isDir = stats.isDirectory(); - const dirObj = this.fsw._getWatchedDir(sysPath$1.dirname(pp)); - const base = sysPath$1.basename(pp); +glob.sync = globSync; +var GlobSync = glob.GlobSync = globSync.GlobSync; - // ensure empty dirs get tracked - if (isDir) this.fsw._getWatchedDir(pp); - if (dirObj.has(base)) return; - dirObj.add(base); +// old api surface +glob.glob = glob; - if (!opts.ignoreInitial || forceAdd === true) { - this.fsw._emit(isDir ? EV_ADD_DIR$1 : EV_ADD$1, pp, stats); +function extend$1 (origin, add) { + if (add === null || typeof add !== 'object') { + return origin } -} - -initWatch(realPath, path, wh, processPath) { - if (this.fsw.closed) return; - const closer = this._watchWithFsEvents( - wh.watchPath, - sysPath$1.resolve(realPath || wh.watchPath), - processPath, - wh.globFilter - ); - this.fsw._addPathCloser(path, closer); -} -/** - * Handle added path with fsevents - * @param {String} path file/dir path or glob pattern - * @param {Function|Boolean=} transform converts working path to what the user expects - * @param {Boolean=} forceAdd ensure add is emitted - * @param {Number=} priorDepth Level of subdirectories already traversed. - * @returns {Promise} - */ -async _addToFsEvents(path, transform, forceAdd, priorDepth) { - if (this.fsw.closed) { - return; + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; } - const opts = this.fsw.options; - const processPath = typeof transform === FUNCTION_TYPE$1 ? transform : IDENTITY_FN; + return origin +} - const wh = this.fsw._getWatchHelpers(path); +glob.hasMagic = function (pattern, options_) { + var options = extend$1({}, options_); + options.noprocess = true; - // evaluate what is at the path we're being asked to watch - try { - const stats = await statMethods[wh.statMethod](wh.watchPath); - if (this.fsw.closed) return; - if (this.fsw._isIgnored(wh.watchPath, stats)) { - throw null; - } - if (stats.isDirectory()) { - // emit addDir unless this is a glob parent - if (!wh.globFilter) this.emitAdd(processPath(path), stats, processPath, opts, forceAdd); + var g = new Glob(pattern, options); + var set = g.minimatch.set; - // don't recurse further if it would exceed depth setting - if (priorDepth && priorDepth > opts.depth) return; + if (!pattern) + return false - // scan the contents of the dir - this.fsw._readdirp(wh.watchPath, { - fileFilter: entry => wh.filterPath(entry), - directoryFilter: entry => wh.filterDir(entry), - ...Depth(opts.depth - (priorDepth || 0)) - }).on(STR_DATA, (entry) => { - // need to check filterPath on dirs b/c filterDir is less restrictive - if (this.fsw.closed) { - return; - } - if (entry.stats.isDirectory() && !wh.filterPath(entry)) return; + if (set.length > 1) + return true - const joinedPath = sysPath$1.join(wh.watchPath, entry.path); - const {fullPath} = entry; + for (var j = 0; j < set[0].length; j++) { + if (typeof set[0][j] !== 'string') + return true + } - if (wh.followSymlinks && entry.stats.isSymbolicLink()) { - // preserve the current depth here since it can't be derived from - // real paths past the symlink - const curDepth = opts.depth === undefined ? - undefined : calcDepth(joinedPath, sysPath$1.resolve(wh.watchPath)) + 1; + return false +}; - this._handleFsEventsSymlink(joinedPath, fullPath, processPath, curDepth); - } else { - this.emitAdd(joinedPath, entry.stats, processPath, opts, forceAdd); - } - }).on(EV_ERROR$1, EMPTY_FN$1).on(STR_END$1, () => { - this.fsw._emitReady(); - }); - } else { - this.emitAdd(wh.watchPath, stats, processPath, opts, forceAdd); - this.fsw._emitReady(); - } - } catch (error) { - if (!error || this.fsw._handleError(error)) { - // TODO: Strange thing: "should not choke on an ignored watch path" will be failed without 2 ready calls -__- - this.fsw._emitReady(); - this.fsw._emitReady(); - } +glob.Glob = Glob; +inherits$1(Glob, EE); +function Glob (pattern, options, cb) { + if (typeof options === 'function') { + cb = options; + options = null; } - if (opts.persistent && forceAdd !== true) { - if (typeof transform === FUNCTION_TYPE$1) { - // realpath has already been resolved - this.initWatch(undefined, path, wh, processPath); - } else { - let realPath; - try { - realPath = await realpath(wh.watchPath); - } catch (e) {} - this.initWatch(realPath, path, wh, processPath); - } + if (options && options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return new GlobSync(pattern, options) } -} -} + if (!(this instanceof Glob)) + return new Glob(pattern, options, cb) -fseventsHandler.exports = FsEventsHandler$1; -fseventsHandler.exports.canUse = canUse; + setopts(this, pattern, options); + this._didRealPath = false; -const { EventEmitter } = require$$0__default$4['default']; -const fs = require$$0__default$3['default']; -const sysPath = require$$0__default$2['default']; -const { promisify } = require$$0__default['default']; -const readdirp = readdirp_1; -const anymatch = anymatch$2.exports.default; -const globParent = globParent$1; -const isGlob = isGlob$2; -const braces = braces_1; -const normalizePath = normalizePath$2; + // process each pattern in the minimatch set + var n = this.minimatch.set.length; -const NodeFsHandler = nodefsHandler; -const FsEventsHandler = fseventsHandler.exports; -const { - EV_ALL, - EV_READY, - EV_ADD, - EV_CHANGE, - EV_UNLINK, - EV_ADD_DIR, - EV_UNLINK_DIR, - EV_RAW, - EV_ERROR, + // The matches are stored as {: true,...} so that + // duplicates are automagically pruned. + // Later, we do an Object.keys() on these. + // Keep them as a list so we can fill in when nonull is set. + this.matches = new Array(n); - STR_CLOSE, - STR_END, + if (typeof cb === 'function') { + cb = once(cb); + this.on('error', cb); + this.on('end', function (matches) { + cb(null, matches); + }); + } - BACK_SLASH_RE, - DOUBLE_SLASH_RE, - SLASH_OR_BACK_SLASH_RE, - DOT_RE, - REPLACER_RE, + var self = this; + this._processing = 0; - SLASH, - SLASH_SLASH, - BRACE_START, - BANG, - ONE_DOT, - TWO_DOTS, - GLOBSTAR, - SLASH_GLOBSTAR, - ANYMATCH_OPTS, - STRING_TYPE, - FUNCTION_TYPE, - EMPTY_STR, - EMPTY_FN, - - isWindows, - isMacos, - isIBMi -} = constants$1; + this._emitQueue = []; + this._processQueue = []; + this.paused = false; -const stat = promisify(fs.stat); -const readdir = promisify(fs.readdir); + if (this.noprocess) + return this -/** - * @typedef {String} Path - * @typedef {'all'|'add'|'addDir'|'change'|'unlink'|'unlinkDir'|'raw'|'error'|'ready'} EventName - * @typedef {'readdir'|'watch'|'add'|'remove'|'change'} ThrottleType - */ + if (n === 0) + return done() -/** - * - * @typedef {Object} WatchHelpers - * @property {Boolean} followSymlinks - * @property {'stat'|'lstat'} statMethod - * @property {Path} path - * @property {Path} watchPath - * @property {Function} entryPath - * @property {Boolean} hasGlob - * @property {Object} globFilter - * @property {Function} filterPath - * @property {Function} filterDir - */ + var sync = true; + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false, done); + } + sync = false; -const arrify = (value = []) => Array.isArray(value) ? value : [value]; -const flatten$1 = (list, result = []) => { - list.forEach(item => { - if (Array.isArray(item)) { - flatten$1(item, result); - } else { - result.push(item); + function done () { + --self._processing; + if (self._processing <= 0) { + if (sync) { + process.nextTick(function () { + self._finish(); + }); + } else { + self._finish(); + } } - }); - return result; -}; - -const unifyPaths = (paths_) => { - /** - * @type {Array} - */ - const paths = flatten$1(arrify(paths_)); - if (!paths.every(p => typeof p === STRING_TYPE)) { - throw new TypeError(`Non-string provided as watch path: ${paths}`); } - return paths.map(normalizePathToUnix); -}; +} -// If SLASH_SLASH occurs at the beginning of path, it is not replaced -// because "//StoragePC/DrivePool/Movies" is a valid network path -const toUnix = (string) => { - let str = string.replace(BACK_SLASH_RE, SLASH); - let prepend = false; - if (str.startsWith(SLASH_SLASH)) { - prepend = true; - } - while (str.match(DOUBLE_SLASH_RE)) { - str = str.replace(DOUBLE_SLASH_RE, SLASH); - } - if (prepend) { - str = SLASH + str; - } - return str; -}; +Glob.prototype._finish = function () { + assert(this instanceof Glob); + if (this.aborted) + return -// Our version of upath.normalize -// TODO: this is not equal to path-normalize module - investigate why -const normalizePathToUnix = (path) => toUnix(sysPath.normalize(toUnix(path))); + if (this.realpath && !this._didRealpath) + return this._realpath() -const normalizeIgnored = (cwd = EMPTY_STR) => (path) => { - if (typeof path !== STRING_TYPE) return path; - return normalizePathToUnix(sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path)); + common.finish(this); + this.emit('end', this.found); }; -const getAbsolutePath = (path, cwd) => { - if (sysPath.isAbsolute(path)) { - return path; - } - if (path.startsWith(BANG)) { - return BANG + sysPath.join(cwd, path.slice(1)); +Glob.prototype._realpath = function () { + if (this._didRealpath) + return + + this._didRealpath = true; + + var n = this.matches.length; + if (n === 0) + return this._finish() + + var self = this; + for (var i = 0; i < this.matches.length; i++) + this._realpathSet(i, next); + + function next () { + if (--n === 0) + self._finish(); } - return sysPath.join(cwd, path); }; -const undef = (opts, key) => opts[key] === undefined; +Glob.prototype._realpathSet = function (index, cb) { + var matchset = this.matches[index]; + if (!matchset) + return cb() -/** - * Directory entry. - * @property {Path} path - * @property {Set} items - */ -class DirEntry { - /** - * @param {Path} dir - * @param {Function} removeWatcher - */ - constructor(dir, removeWatcher) { - this.path = dir; - this._removeWatcher = removeWatcher; - /** @type {Set} */ - this.items = new Set(); - } + var found = Object.keys(matchset); + var self = this; + var n = found.length; - add(item) { - const {items} = this; - if (!items) return; - if (item !== ONE_DOT && item !== TWO_DOTS) items.add(item); - } + if (n === 0) + return cb() - async remove(item) { - const {items} = this; - if (!items) return; - items.delete(item); - if (items.size > 0) return; + var set = this.matches[index] = Object.create(null); + found.forEach(function (p, i) { + // If there's a problem with the stat, then it means that + // one or more of the links in the realpath couldn't be + // resolved. just return the abs value in that case. + p = self._makeAbs(p); + rp.realpath(p, self.realpathCache, function (er, real) { + if (!er) + set[real] = true; + else if (er.syscall === 'stat') + set[p] = true; + else + self.emit('error', er); // srsly wtf right here - const dir = this.path; - try { - await readdir(dir); - } catch (err) { - if (this._removeWatcher) { - this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir)); + if (--n === 0) { + self.matches[index] = set; + cb(); } - } - } + }); + }); +}; - has(item) { - const {items} = this; - if (!items) return; - return items.has(item); - } +Glob.prototype._mark = function (p) { + return common.mark(this, p) +}; - /** - * @returns {Array} - */ - getChildren() { - const {items} = this; - if (!items) return; - return [...items.values()]; - } +Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +}; - dispose() { - this.items.clear(); - delete this.path; - delete this._removeWatcher; - delete this.items; - Object.freeze(this); - } -} +Glob.prototype.abort = function () { + this.aborted = true; + this.emit('abort'); +}; -const STAT_METHOD_F = 'stat'; -const STAT_METHOD_L = 'lstat'; -class WatchHelper { - constructor(path, watchPath, follow, fsw) { - this.fsw = fsw; - this.path = path = path.replace(REPLACER_RE, EMPTY_STR); - this.watchPath = watchPath; - this.fullWatchPath = sysPath.resolve(watchPath); - this.hasGlob = watchPath !== path; - /** @type {object|boolean} */ - if (path === EMPTY_STR) this.hasGlob = false; - this.globSymlink = this.hasGlob && follow ? undefined : false; - this.globFilter = this.hasGlob ? anymatch(path, undefined, ANYMATCH_OPTS) : false; - this.dirParts = this.getDirParts(path); - this.dirParts.forEach((parts) => { - if (parts.length > 1) parts.pop(); - }); - this.followSymlinks = follow; - this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L; +Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true; + this.emit('pause'); } +}; - checkGlobSymlink(entry) { - // only need to resolve once - // first entry should always have entry.parentDir === EMPTY_STR - if (this.globSymlink === undefined) { - this.globSymlink = entry.fullParentDir === this.fullWatchPath ? - false : {realPath: entry.fullParentDir, linkPath: this.fullWatchPath}; +Glob.prototype.resume = function () { + if (this.paused) { + this.emit('resume'); + this.paused = false; + if (this._emitQueue.length) { + var eq = this._emitQueue.slice(0); + this._emitQueue.length = 0; + for (var i = 0; i < eq.length; i ++) { + var e = eq[i]; + this._emitMatch(e[0], e[1]); + } } - - if (this.globSymlink) { - return entry.fullPath.replace(this.globSymlink.realPath, this.globSymlink.linkPath); + if (this._processQueue.length) { + var pq = this._processQueue.slice(0); + this._processQueue.length = 0; + for (var i = 0; i < pq.length; i ++) { + var p = pq[i]; + this._processing--; + this._process(p[0], p[1], p[2], p[3]); + } } - - return entry.fullPath; } +}; - entryPath(entry) { - return sysPath.join(this.watchPath, - sysPath.relative(this.watchPath, this.checkGlobSymlink(entry)) - ); - } +Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob); + assert(typeof cb === 'function'); - filterPath(entry) { - const {stats} = entry; - if (stats && stats.isSymbolicLink()) return this.filterDir(entry); - const resolvedPath = this.entryPath(entry); - const matchesGlob = this.hasGlob && typeof this.globFilter === FUNCTION_TYPE ? - this.globFilter(resolvedPath) : true; - return matchesGlob && - this.fsw._isntIgnored(resolvedPath, stats) && - this.fsw._hasReadPermissions(stats); - } + if (this.aborted) + return - getDirParts(path) { - if (!this.hasGlob) return []; - const parts = []; - const expandedPath = path.includes(BRACE_START) ? braces.expand(path) : [path]; - expandedPath.forEach((path) => { - parts.push(sysPath.relative(this.watchPath, path).split(SLASH_OR_BACK_SLASH_RE)); - }); - return parts; + this._processing++; + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]); + return } - filterDir(entry) { - if (this.hasGlob) { - const entryParts = this.getDirParts(this.checkGlobSymlink(entry)); - let globstar = false; - this.unmatchedGlob = !this.dirParts.some((parts) => { - return parts.every((part, i) => { - if (part === GLOBSTAR) globstar = true; - return globstar || !entryParts[0][i] || anymatch(part, entryParts[0][i], ANYMATCH_OPTS); - }); - }); - } - return !this.unmatchedGlob && this.fsw._isntIgnored(this.entryPath(entry), entry.stats); + //console.error('PROCESS %d', this._processing, pattern) + + // Get the first [n] parts of pattern that are all strings. + var n = 0; + while (typeof pattern[n] === 'string') { + n ++; } -} + // now n is the index of the first one that is *not* a string. -/** - * Watches files & directories for changes. Emitted events: - * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error` - * - * new FSWatcher() - * .add(directories) - * .on('add', path => log('File', path, 'was added')) - */ -class FSWatcher extends EventEmitter { -// Not indenting methods for history sake; for now. -constructor(_opts) { - super(); + // see if there's anything else + var prefix; + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index, cb); + return - const opts = {}; - if (_opts) Object.assign(opts, _opts); // for frozen objects + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null; + break - /** @type {Map} */ - this._watched = new Map(); - /** @type {Map} */ - this._closers = new Map(); - /** @type {Set} */ - this._ignoredPaths = new Set(); + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/'); + break + } - /** @type {Map} */ - this._throttled = new Map(); + var remain = pattern.slice(n); - /** @type {Map} */ - this._symlinkPaths = new Map(); + // get the list of entries. + var read; + if (prefix === null) + read = '.'; + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix; + read = prefix; + } else + read = prefix; - this._streams = new Set(); - this.closed = false; + var abs = this._makeAbs(read); - // Set up default options. - if (undef(opts, 'persistent')) opts.persistent = true; - if (undef(opts, 'ignoreInitial')) opts.ignoreInitial = false; - if (undef(opts, 'ignorePermissionErrors')) opts.ignorePermissionErrors = false; - if (undef(opts, 'interval')) opts.interval = 100; - if (undef(opts, 'binaryInterval')) opts.binaryInterval = 300; - if (undef(opts, 'disableGlobbing')) opts.disableGlobbing = false; - opts.enableBinaryInterval = opts.binaryInterval !== opts.interval; + //if ignored, skip _processing + if (childrenIgnored(this, read)) + return cb() - // Enable fsevents on OS X when polling isn't explicitly enabled. - if (undef(opts, 'useFsEvents')) opts.useFsEvents = !opts.usePolling; + var isGlobStar = remain[0] === minimatch.GLOBSTAR; + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb); + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb); +}; - // If we can't use fsevents, ensure the options reflect it's disabled. - const canUseFsEvents = FsEventsHandler.canUse(); - if (!canUseFsEvents) opts.useFsEvents = false; +Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this; + this._readdir(abs, inGlobStar, function (er, entries) { + return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }); +}; - // Use polling on Mac if not using fsevents. - // Other platforms use non-polling fs_watch. - if (undef(opts, 'usePolling') && !opts.useFsEvents) { - opts.usePolling = isMacos; - } +Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - // Always default to polling on IBM i because fs.watch() is not available on IBM i. - if(isIBMi) { - opts.usePolling = true; - } + // if the abs isn't a dir, then nothing can match! + if (!entries) + return cb() - // Global override (useful for end-developers that need to force polling for all - // instances of chokidar, regardless of usage/dependency depth) - const envPoll = process.env.CHOKIDAR_USEPOLLING; - if (envPoll !== undefined) { - const envLower = envPoll.toLowerCase(); + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0]; + var negate = !!this.minimatch.negate; + var rawGlob = pn._glob; + var dotOk = this.dot || rawGlob.charAt(0) === '.'; - if (envLower === 'false' || envLower === '0') { - opts.usePolling = false; - } else if (envLower === 'true' || envLower === '1') { - opts.usePolling = true; - } else { - opts.usePolling = !!envLower; + var matchedEntries = []; + for (var i = 0; i < entries.length; i++) { + var e = entries[i]; + if (e.charAt(0) !== '.' || dotOk) { + var m; + if (negate && !prefix) { + m = !e.match(pn); + } else { + m = e.match(pn); + } + if (m) + matchedEntries.push(e); } } - const envInterval = process.env.CHOKIDAR_INTERVAL; - if (envInterval) { - opts.interval = Number.parseInt(envInterval, 10); - } - - // Editor atomic write normalization enabled by default with fs.watch - if (undef(opts, 'atomic')) opts.atomic = !opts.usePolling && !opts.useFsEvents; - if (opts.atomic) this._pendingUnlinks = new Map(); - if (undef(opts, 'followSymlinks')) opts.followSymlinks = true; + //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) - if (undef(opts, 'awaitWriteFinish')) opts.awaitWriteFinish = false; - if (opts.awaitWriteFinish === true) opts.awaitWriteFinish = {}; - const awf = opts.awaitWriteFinish; - if (awf) { - if (!awf.stabilityThreshold) awf.stabilityThreshold = 2000; - if (!awf.pollInterval) awf.pollInterval = 100; - this._pendingWrites = new Map(); - } - if (opts.ignored) opts.ignored = arrify(opts.ignored); + var len = matchedEntries.length; + // If there are no matched entries, then nothing matches. + if (len === 0) + return cb() - let readyCalls = 0; - this._emitReady = () => { - readyCalls++; - if (readyCalls >= this._readyCount) { - this._emitReady = EMPTY_FN; - this._readyEmitted = true; - // use process.nextTick to allow time for listener to be bound - process.nextTick(() => this.emit(EV_READY)); - } - }; - this._emitRaw = (...args) => this.emit(EV_RAW, ...args); - this._readyEmitted = false; - this.options = opts; + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. - // Initialize with proper watcher. - if (opts.useFsEvents) { - this._fsEventsHandler = new FsEventsHandler(this); - } else { - this._nodeFsHandler = new NodeFsHandler(this); - } + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null); - // You’re frozen when your heart’s not open. - Object.freeze(opts); -} + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i]; + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e; + else + e = prefix + e; + } -// Public methods - -/** - * Adds paths to be watched on an existing FSWatcher instance - * @param {Path|Array} paths_ - * @param {String=} _origAdd private; for handling non-existent paths to be watched - * @param {Boolean=} _internal private; indicates a non-user add - * @returns {FSWatcher} for chaining - */ -add(paths_, _origAdd, _internal) { - const {cwd, disableGlobbing} = this.options; - this.closed = false; - let paths = unifyPaths(paths_); - if (cwd) { - paths = paths.map((path) => { - const absPath = getAbsolutePath(path, cwd); - - // Check `path` instead of `absPath` because the cwd portion can't be a glob - if (disableGlobbing || !isGlob(path)) { - return absPath; + if (e.charAt(0) === '/' && !this.nomount) { + e = path$1.join(this.root, e); } - return normalizePath(absPath); - }); + this._emitMatch(index, e); + } + // This was the last one, and no stats were needed + return cb() } - // set aside negated glob strings - paths = paths.filter((path) => { - if (path.startsWith(BANG)) { - this._ignoredPaths.add(path.slice(1)); - return false; + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift(); + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i]; + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e; + else + e = prefix + e; } - - // if a path is being added that was previously ignored, stop ignoring it - this._ignoredPaths.delete(path); - this._ignoredPaths.delete(path + SLASH_GLOBSTAR); - - // reset the cached userIgnored anymatch fn - // to make ignoredPaths changes effective - this._userIgnored = undefined; - - return true; - }); - - if (this.options.useFsEvents && this._fsEventsHandler) { - if (!this._readyCount) this._readyCount = paths.length; - if (this.options.persistent) this._readyCount *= 2; - paths.forEach((path) => this._fsEventsHandler._addToFsEvents(path)); - } else { - if (!this._readyCount) this._readyCount = 0; - this._readyCount += paths.length; - Promise.all( - paths.map(async path => { - const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, 0, 0, _origAdd); - if (res) this._emitReady(); - return res; - }) - ).then(results => { - if (this.closed) return; - results.filter(item => item).forEach(item => { - this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item)); - }); - }); + this._process([e].concat(remain), index, inGlobStar, cb); } + cb(); +}; - return this; -} - -/** - * Close watchers or start ignoring events from specified paths. - * @param {Path|Array} paths_ - string or array of strings, file/directory paths and/or globs - * @returns {FSWatcher} for chaining -*/ -unwatch(paths_) { - if (this.closed) return this; - const paths = unifyPaths(paths_); - const {cwd} = this.options; +Glob.prototype._emitMatch = function (index, e) { + if (this.aborted) + return - paths.forEach((path) => { - // convert to absolute path unless relative path already matches - if (!sysPath.isAbsolute(path) && !this._closers.has(path)) { - if (cwd) path = sysPath.join(cwd, path); - path = sysPath.resolve(path); - } + if (isIgnored(this, e)) + return - this._closePath(path); + if (this.paused) { + this._emitQueue.push([index, e]); + return + } - this._ignoredPaths.add(path); - if (this._watched.has(path)) { - this._ignoredPaths.add(path + SLASH_GLOBSTAR); - } + var abs = isAbsolute(e) ? e : this._makeAbs(e); - // reset the cached userIgnored anymatch fn - // to make ignoredPaths changes effective - this._userIgnored = undefined; - }); + if (this.mark) + e = this._mark(e); - return this; -} + if (this.absolute) + e = abs; -/** - * Close watchers and remove all listeners from watched paths. - * @returns {Promise}. -*/ -close() { - if (this.closed) return this._closePromise; - this.closed = true; + if (this.matches[index][e]) + return - // Memory management. - this.removeAllListeners(); - const closers = []; - this._closers.forEach(closerList => closerList.forEach(closer => { - const promise = closer(); - if (promise instanceof Promise) closers.push(promise); - })); - this._streams.forEach(stream => stream.destroy()); - this._userIgnored = undefined; - this._readyCount = 0; - this._readyEmitted = false; - this._watched.forEach(dirent => dirent.dispose()); - ['closers', 'watched', 'streams', 'symlinkPaths', 'throttled'].forEach(key => { - this[`_${key}`].clear(); - }); + if (this.nodir) { + var c = this.cache[abs]; + if (c === 'DIR' || Array.isArray(c)) + return + } - this._closePromise = closers.length ? Promise.all(closers).then(() => undefined) : Promise.resolve(); - return this._closePromise; -} + this.matches[index][e] = true; -/** - * Expose list of watched paths - * @returns {Object} for chaining -*/ -getWatched() { - const watchList = {}; - this._watched.forEach((entry, dir) => { - const key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir; - watchList[key || ONE_DOT] = entry.getChildren().sort(); - }); - return watchList; -} + var st = this.statCache[abs]; + if (st) + this.emit('stat', e, st); -emitWithAll(event, args) { - this.emit(...args); - if (event !== EV_ERROR) this.emit(EV_ALL, ...args); -} + this.emit('match', e); +}; -// Common helpers -// -------------- +Glob.prototype._readdirInGlobStar = function (abs, cb) { + if (this.aborted) + return -/** - * Normalize and emit events. - * Calling _emit DOES NOT MEAN emit() would be called! - * @param {EventName} event Type of event - * @param {Path} path File or directory path - * @param {*=} val1 arguments to be passed with event - * @param {*=} val2 - * @param {*=} val3 - * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag - */ -async _emit(event, path, val1, val2, val3) { - if (this.closed) return; + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false, cb) - const opts = this.options; - if (isWindows) path = sysPath.normalize(path); - if (opts.cwd) path = sysPath.relative(opts.cwd, path); - /** @type Array */ - const args = [event, path]; - if (val3 !== undefined) args.push(val1, val2, val3); - else if (val2 !== undefined) args.push(val1, val2); - else if (val1 !== undefined) args.push(val1); + var lstatkey = 'lstat\0' + abs; + var self = this; + var lstatcb = inflight(lstatkey, lstatcb_); - const awf = opts.awaitWriteFinish; - let pw; - if (awf && (pw = this._pendingWrites.get(path))) { - pw.lastChange = new Date(); - return this; - } + if (lstatcb) + fs.lstat(abs, lstatcb); - if (opts.atomic) { - if (event === EV_UNLINK) { - this._pendingUnlinks.set(path, args); - setTimeout(() => { - this._pendingUnlinks.forEach((entry, path) => { - this.emit(...entry); - this.emit(EV_ALL, ...entry); - this._pendingUnlinks.delete(path); - }); - }, typeof opts.atomic === 'number' ? opts.atomic : 100); - return this; - } - if (event === EV_ADD && this._pendingUnlinks.has(path)) { - event = args[0] = EV_CHANGE; - this._pendingUnlinks.delete(path); - } - } + function lstatcb_ (er, lstat) { + if (er && er.code === 'ENOENT') + return cb() - if (awf && (event === EV_ADD || event === EV_CHANGE) && this._readyEmitted) { - const awfEmit = (err, stats) => { - if (err) { - event = args[0] = EV_ERROR; - args[1] = err; - this.emitWithAll(event, args); - } else if (stats) { - // if stats doesn't exist the file must have been deleted - if (args.length > 2) { - args[2] = stats; - } else { - args.push(stats); - } - this.emitWithAll(event, args); - } - }; + var isSym = lstat && lstat.isSymbolicLink(); + self.symlinks[abs] = isSym; - this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit); - return this; + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) { + self.cache[abs] = 'FILE'; + cb(); + } else + self._readdir(abs, false, cb); } +}; - if (event === EV_CHANGE) { - const isThrottled = !this._throttle(EV_CHANGE, path, 50); - if (isThrottled) return this; - } +Glob.prototype._readdir = function (abs, inGlobStar, cb) { + if (this.aborted) + return - if (opts.alwaysStat && val1 === undefined && - (event === EV_ADD || event === EV_ADD_DIR || event === EV_CHANGE) - ) { - const fullPath = opts.cwd ? sysPath.join(opts.cwd, path) : path; - let stats; - try { - stats = await stat(fullPath); - } catch (err) {} - // Suppress event when fs_stat fails, to avoid sending undefined 'stat' - if (!stats || this.closed) return; - args.push(stats); - } - this.emitWithAll(event, args); + cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb); + if (!cb) + return - return this; -} + //console.error('RD %j %j', +inGlobStar, abs) + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs, cb) -/** - * Common handler for errors - * @param {Error} error - * @returns {Error|Boolean} The error if defined, otherwise the value of the FSWatcher instance's `closed` flag - */ -_handleError(error) { - const code = error && error.code; - if (error && code !== 'ENOENT' && code !== 'ENOTDIR' && - (!this.options.ignorePermissionErrors || (code !== 'EPERM' && code !== 'EACCES')) - ) { - this.emit(EV_ERROR, error); - } - return error || this.closed; -} + if (ownProp(this.cache, abs)) { + var c = this.cache[abs]; + if (!c || c === 'FILE') + return cb() -/** - * Helper utility for throttling - * @param {ThrottleType} actionType type being throttled - * @param {Path} path being acted upon - * @param {Number} timeout duration of time to suppress duplicate actions - * @returns {Object|false} tracking object or false if action should be suppressed - */ -_throttle(actionType, path, timeout) { - if (!this._throttled.has(actionType)) { - this._throttled.set(actionType, new Map()); + if (Array.isArray(c)) + return cb(null, c) } + fs.readdir(abs, readdirCb(this, abs, cb)); +}; - /** @type {Map} */ - const action = this._throttled.get(actionType); - /** @type {Object} */ - const actionPath = action.get(path); - - if (actionPath) { - actionPath.count++; - return false; +function readdirCb (self, abs, cb) { + return function (er, entries) { + if (er) + self._readdirError(abs, er, cb); + else + self._readdirEntries(abs, entries, cb); } - - let timeoutObject; - const clear = () => { - const item = action.get(path); - const count = item ? item.count : 0; - action.delete(path); - clearTimeout(timeoutObject); - if (item) clearTimeout(item.timeoutObject); - return count; - }; - timeoutObject = setTimeout(clear, timeout); - const thr = {timeoutObject, clear, count: 0}; - action.set(path, thr); - return thr; -} - -_incrReadyCount() { - return this._readyCount++; } -/** - * Awaits write operation to finish. - * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback. - * @param {Path} path being acted upon - * @param {Number} threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished - * @param {EventName} event - * @param {Function} awfEmit Callback to be called when ready for event to be emitted. - */ -_awaitWriteFinish(path, threshold, event, awfEmit) { - let timeoutHandler; +Glob.prototype._readdirEntries = function (abs, entries, cb) { + if (this.aborted) + return - let fullPath = path; - if (this.options.cwd && !sysPath.isAbsolute(path)) { - fullPath = sysPath.join(this.options.cwd, path); + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i]; + if (abs === '/') + e = abs + e; + else + e = abs + '/' + e; + this.cache[e] = true; + } } - const now = new Date(); - - const awaitWriteFinish = (prevStat) => { - fs.stat(fullPath, (err, curStat) => { - if (err || !this._pendingWrites.has(path)) { - if (err && err.code !== 'ENOENT') awfEmit(err); - return; - } + this.cache[abs] = entries; + return cb(null, entries) +}; - const now = Number(new Date()); +Glob.prototype._readdirError = function (f, er, cb) { + if (this.aborted) + return - if (prevStat && curStat.size !== prevStat.size) { - this._pendingWrites.get(path).lastChange = now; + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f); + this.cache[abs] = 'FILE'; + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd); + error.path = this.cwd; + error.code = er.code; + this.emit('error', error); + this.abort(); } - const pw = this._pendingWrites.get(path); - const df = now - pw.lastChange; + break - if (df >= threshold) { - this._pendingWrites.delete(path); - awfEmit(undefined, curStat); - } else { - timeoutHandler = setTimeout( - awaitWriteFinish, - this.options.awaitWriteFinish.pollInterval, - curStat - ); - } - }); - }; + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false; + break - if (!this._pendingWrites.has(path)) { - this._pendingWrites.set(path, { - lastChange: now, - cancelWait: () => { - this._pendingWrites.delete(path); - clearTimeout(timeoutHandler); - return event; + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false; + if (this.strict) { + this.emit('error', er); + // If the error is handled, then we abort + // if not, we threw out of here + this.abort(); } - }); - timeoutHandler = setTimeout( - awaitWriteFinish, - this.options.awaitWriteFinish.pollInterval - ); + if (!this.silent) + console.error('glob error', er); + break } -} -_getGlobIgnored() { - return [...this._ignoredPaths.values()]; -} + return cb() +}; -/** - * Determines whether user has asked to ignore this path. - * @param {Path} path filepath or dir - * @param {fs.Stats=} stats result of fs.stat - * @returns {Boolean} - */ -_isIgnored(path, stats) { - if (this.options.atomic && DOT_RE.test(path)) return true; - if (!this._userIgnored) { - const {cwd} = this.options; - const ign = this.options.ignored; +Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this; + this._readdir(abs, inGlobStar, function (er, entries) { + self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb); + }); +}; - const ignored = ign && ign.map(normalizeIgnored(cwd)); - const paths = arrify(ignored) - .filter((path) => typeof path === STRING_TYPE && !isGlob(path)) - .map((path) => path + SLASH_GLOBSTAR); - const list = this._getGlobIgnored().map(normalizeIgnored(cwd)).concat(ignored, paths); - this._userIgnored = anymatch(list, undefined, ANYMATCH_OPTS); - } - return this._userIgnored([path, stats]); -} +Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + //console.error('pgs2', prefix, remain[0], entries) -_isntIgnored(path, stat) { - return !this._isIgnored(path, stat); -} + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return cb() -/** - * Provides a set of common helpers and properties relating to symlink and glob handling. - * @param {Path} path file, directory, or glob pattern being watched - * @param {Number=} depth at any depth > 0, this isn't a glob - * @returns {WatchHelper} object containing helpers for this path - */ -_getWatchHelpers(path, depth) { - const watchPath = depth || this.options.disableGlobbing || !isGlob(path) ? path : globParent(path); - const follow = this.options.followSymlinks; + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1); + var gspref = prefix ? [ prefix ] : []; + var noGlobStar = gspref.concat(remainWithoutGlobStar); - return new WatchHelper(path, watchPath, follow, this); -} + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false, cb); -// Directory helpers -// ----------------- + var isSym = this.symlinks[abs]; + var len = entries.length; -/** - * Provides directory tracking objects - * @param {String} directory path of the directory - * @returns {DirEntry} the directory's tracking object - */ -_getWatchedDir(directory) { - if (!this._boundRemove) this._boundRemove = this._remove.bind(this); - const dir = sysPath.resolve(directory); - if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove)); - return this._watched.get(dir); -} + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return cb() -// File helpers -// ------------ + for (var i = 0; i < len; i++) { + var e = entries[i]; + if (e.charAt(0) === '.' && !this.dot) + continue -/** - * Check for read permissions. - * Based on this answer on SO: https://stackoverflow.com/a/11781404/1358405 - * @param {fs.Stats} stats - object, result of fs_stat - * @returns {Boolean} indicates whether the file can be read -*/ -_hasReadPermissions(stats) { - if (this.options.ignorePermissionErrors) return true; + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar); + this._process(instead, index, true, cb); - // stats.mode may be bigint - const md = stats && Number.parseInt(stats.mode, 10); - const st = md & 0o777; - const it = Number.parseInt(st.toString(8)[0], 10); - return Boolean(4 & it); -} + var below = gspref.concat(entries[i], remain); + this._process(below, index, true, cb); + } -/** - * Handles emitting unlink events for - * files and directories, and via recursion, for - * files and directories within directories that are unlinked - * @param {String} directory within which the following item is located - * @param {String} item base path of item/directory - * @returns {void} -*/ -_remove(directory, item, isDirectory) { - // if what is being deleted is a directory, get that directory's paths - // for recursive deleting and cleaning of watched object - // if it is not a directory, nestedDirectoryChildren will be empty array - const path = sysPath.join(directory, item); - const fullPath = sysPath.resolve(path); - isDirectory = isDirectory != null - ? isDirectory - : this._watched.has(path) || this._watched.has(fullPath); + cb(); +}; - // prevent duplicate handling in case of arriving here nearly simultaneously - // via multiple paths (such as _handleFile and _handleDir) - if (!this._throttle('remove', path, 100)) return; +Glob.prototype._processSimple = function (prefix, index, cb) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var self = this; + this._stat(prefix, function (er, exists) { + self._processSimple2(prefix, index, er, exists, cb); + }); +}; +Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { - // if the only watched file is removed, watch for its return - if (!isDirectory && !this.options.useFsEvents && this._watched.size === 1) { - this.add(directory, item, true); + //console.error('ps2', prefix, exists) + + if (!this.matches[index]) + this.matches[index] = Object.create(null); + + // If it doesn't exist, then just mark the lack of results + if (!exists) + return cb() + + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix); + if (prefix.charAt(0) === '/') { + prefix = path$1.join(this.root, prefix); + } else { + prefix = path$1.resolve(this.root, prefix); + if (trail) + prefix += '/'; + } } - // This will create a new entry in the watched object in either case - // so we got to do the directory check beforehand - const wp = this._getWatchedDir(path); - const nestedDirectoryChildren = wp.getChildren(); + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/'); - // Recursively remove children directories / files. - nestedDirectoryChildren.forEach(nested => this._remove(path, nested)); + // Mark this as a match + this._emitMatch(index, prefix); + cb(); +}; - // Check if item was on the watched list and remove it - const parent = this._getWatchedDir(directory); - const wasTracked = parent.has(item); - parent.remove(item); +// Returns either 'DIR', 'FILE', or false +Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f); + var needDir = f.slice(-1) === '/'; - // Fixes issue #1042 -> Relative paths were detected and added as symlinks - // (https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L612), - // but never removed from the map in case the path was deleted. - // This leads to an incorrect state if the path was recreated: - // https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L553 - if (this._symlinkPaths.has(fullPath)) { - this._symlinkPaths.delete(fullPath); - } + if (f.length > this.maxLength) + return cb() - // If we wait for this file to be fully written, cancel the wait. - let relPath = path; - if (this.options.cwd) relPath = sysPath.relative(this.options.cwd, path); - if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) { - const event = this._pendingWrites.get(relPath).cancelWait(); - if (event === EV_ADD) return; + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs]; + + if (Array.isArray(c)) + c = 'DIR'; + + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return cb(null, c) + + if (needDir && c === 'FILE') + return cb() + + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } + var stat = this.statCache[abs]; + if (stat !== undefined) { + if (stat === false) + return cb(null, stat) + else { + var type = stat.isDirectory() ? 'DIR' : 'FILE'; + if (needDir && type === 'FILE') + return cb() + else + return cb(null, type, stat) + } } - // The Entry will either be a directory that just got removed - // or a bogus entry to a file, in either case we have to remove it - this._watched.delete(path); - this._watched.delete(fullPath); - const eventName = isDirectory ? EV_UNLINK_DIR : EV_UNLINK; - if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path); + var self = this; + var statcb = inflight('stat\0' + abs, lstatcb_); + if (statcb) + fs.lstat(abs, statcb); - // Avoid conflicts if we later create another file with the same name - if (!this.options.useFsEvents) { - this._closePath(path); + function lstatcb_ (er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + // If it's a symlink, then treat it as the target, unless + // the target does not exist, then treat it as a file. + return fs.stat(abs, function (er, stat) { + if (er) + self._stat2(f, abs, null, lstat, cb); + else + self._stat2(f, abs, er, stat, cb); + }) + } else { + self._stat2(f, abs, er, lstat, cb); + } } -} +}; -/** - * Closes all watchers for a path - * @param {Path} path +Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false; + return cb() + } + + var needDir = f.slice(-1) === '/'; + this.statCache[abs] = stat; + + if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) + return cb(null, false, stat) + + var c = true; + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE'; + this.cache[abs] = this.cache[abs] || c; + + if (needDir && c === 'FILE') + return cb() + + return cb(null, c, stat) +}; + +/*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT */ -_closePath(path) { - this._closeFile(path); - const dir = sysPath.dirname(path); - this._getWatchedDir(dir).remove(sysPath.basename(path)); -} + +var isBuffer = function isBuffer (obj) { + return obj != null && obj.constructor != null && + typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +}; + +const proc$1 = process; + +var own$b = {}.hasOwnProperty; /** - * Closes only file-specific watchers - * @param {Path} path + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Position} Position + * @typedef {import('unist').Point} Point */ -_closeFile(path) { - const closers = this._closers.get(path); - if (!closers) return; - closers.forEach(closer => closer()); - this._closers.delete(path); -} /** + * Stringify one point, a position (start and end points), or a node’s + * positional information. * - * @param {Path} path - * @param {Function} closer + * @param {Node|Position|Point} [value] + * @returns {string} */ -_addPathCloser(path, closer) { - if (!closer) return; - let list = this._closers.get(path); - if (!list) { - list = []; - this._closers.set(path, list); +function stringifyPosition$1(value) { + // Nothing. + if (!value || typeof value !== 'object') { + return '' } - list.push(closer); -} -_readdirp(root, opts) { - if (this.closed) return; - const options = {type: EV_ALL, alwaysStat: true, lstat: true, ...opts}; - let stream = readdirp(root, options); - this._streams.add(stream); - stream.once(STR_CLOSE, () => { - stream = undefined; - }); - stream.once(STR_END, () => { - if (stream) { - this._streams.delete(stream); - stream = undefined; - } - }); - return stream; + // Node. + if (own$b.call(value, 'position') || own$b.call(value, 'type')) { + // @ts-ignore looks like a node. + return position(value.position) + } + + // Position. + if (own$b.call(value, 'start') || own$b.call(value, 'end')) { + // @ts-ignore looks like a position. + return position(value) + } + + // Point. + if (own$b.call(value, 'line') || own$b.call(value, 'column')) { + // @ts-ignore looks like a point. + return point$1(value) + } + + // ? + return '' } +/** + * @param {Point} point + * @returns {string} + */ +function point$1(point) { + return index$1(point && point.line) + ':' + index$1(point && point.column) } -// Export FSWatcher class -chokidar$1.FSWatcher = FSWatcher; +/** + * @param {Position} pos + * @returns {string} + */ +function position(pos) { + return point$1(pos && pos.start) + '-' + point$1(pos && pos.end) +} /** - * Instantiates watcher with paths to be tracked. - * @param {String|Array} paths file/directory paths and/or globs - * @param {Object=} options chokidar opts - * @returns an instance of FSWatcher for chaining. + * @param {number} value + * @returns {number} */ -const watch = (paths, options) => { - const watcher = new FSWatcher(options); - watcher.add(paths); - return watcher; -}; +function index$1(value) { + return value && typeof value === 'number' ? value : 1 +} -chokidar$1.watch = watch; +/** + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Position} Position + * @typedef {import('unist').Point} Point + */ -var textTable = function (rows_, opts) { - if (!opts) opts = {}; - var hsep = opts.hsep === undefined ? ' ' : opts.hsep; - var align = opts.align || []; - var stringLength = opts.stringLength - || function (s) { return String(s).length; } - ; - - var dotsizes = reduce(rows_, function (acc, row) { - forEach(row, function (c, ix) { - var n = dotindex(c); - if (!acc[ix] || n > acc[ix]) acc[ix] = n; - }); - return acc; - }, []); - - var rows = map$6(rows_, function (row) { - return map$6(row, function (c_, ix) { - var c = String(c_); - if (align[ix] === '.') { - var index = dotindex(c); - var size = dotsizes[ix] + (/\./.test(c) ? 1 : 2) - - (stringLength(c) - index) - ; - return c + Array(size).join(' '); - } - else return c; - }); - }); - - var sizes = reduce(rows, function (acc, row) { - forEach(row, function (c, ix) { - var n = stringLength(c); - if (!acc[ix] || n > acc[ix]) acc[ix] = n; - }); - return acc; - }, []); - - return map$6(rows, function (row) { - return map$6(row, function (c, ix) { - var n = (sizes[ix] - stringLength(c)) || 0; - var s = Array(Math.max(n + 1, 1)).join(' '); - if (align[ix] === 'r' || align[ix] === '.') { - return s + c; - } - if (align[ix] === 'c') { - return Array(Math.ceil(n / 2 + 1)).join(' ') - + c + Array(Math.floor(n / 2 + 1)).join(' ') - ; - } - - return c + s; - }).join(hsep).replace(/\s+$/, ''); - }).join('\n'); -}; +class VFileMessage extends Error { + /** + * Constructor of a message for `reason` at `place` from `origin`. + * When an error is passed in as `reason`, copies the `stack`. + * + * @param {string|Error} reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given. + * @param {Node|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional). + * @param {string} [origin] Place in code the message originates from (`string`, optional). + */ + constructor(reason, place, origin) { + /** @type {[string?, string?]} */ + var parts = [null, null]; + /** @type {Position} */ + var position = { + start: {line: null, column: null}, + end: {line: null, column: null} + }; + /** @type {number} */ + var index; -function dotindex (c) { - var m = /\.[^.]*$/.exec(c); - return m ? m.index + 1 : c.length; -} + super(); -function reduce (xs, f, init) { - if (xs.reduce) return xs.reduce(f, init); - var i = 0; - var acc = arguments.length >= 3 ? init : xs[i++]; - for (; i < xs.length; i++) { - f(acc, xs[i], i); + if (typeof place === 'string') { + origin = place; + place = null; } - return acc; -} -function forEach (xs, f) { - if (xs.forEach) return xs.forEach(f); - for (var i = 0; i < xs.length; i++) { - f.call(xs, xs[i], i); + if (typeof origin === 'string') { + index = origin.indexOf(':'); + + if (index === -1) { + parts[1] = origin; + } else { + parts[0] = origin.slice(0, index); + parts[1] = origin.slice(index + 1); + } } -} -function map$6 (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f.call(xs, xs[i], i)); + if (place) { + // Node. + if ('type' in place || 'position' in place) { + if (place.position) { + position = place.position; + } + } + // Position. + else if ('start' in place || 'end' in place) { + // @ts-ignore Looks like a position. + position = place; + } + // Point. + else if ('line' in place || 'column' in place) { + // @ts-ignore Looks like a point. + position.start = place; + } } - return res; -} -var camelcase$1 = {exports: {}}; + // Fields from `Error` + this.name = stringifyPosition$1(place) || '1:1'; + this.message = typeof reason === 'object' ? reason.message : reason; + this.stack = typeof reason === 'object' ? reason.stack : ''; -const preserveCamelCase = string => { - let isLastCharLower = false; - let isLastCharUpper = false; - let isLastLastCharUpper = false; + /** + * Reason for message. + * @type {string} + */ + this.reason = this.message; + /** + * Starting line of error. + * @type {number?} + */ + this.line = position.start.line; + /** + * Starting column of error. + * @type {number?} + */ + this.column = position.start.column; + /** + * Namespace of warning. + * @type {string?} + */ + this.source = parts[0]; + /** + * Category of message. + * @type {string?} + */ + this.ruleId = parts[1]; + /** + * Full range information, when available. + * Has start and end properties, both set to an object with line and column, set to number?. + * @type {Position?} + */ + this.position = position; - for (let i = 0; i < string.length; i++) { - const character = string[i]; + // The following fields are “well known”. + // Not standard. + // Feel free to add other non-standard fields to your messages. - if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) { - string = string.slice(0, i) + '-' + string.slice(i); - isLastCharLower = false; - isLastLastCharUpper = isLastCharUpper; - isLastCharUpper = true; - i++; - } else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) { - string = string.slice(0, i - 1) + '-' + string.slice(i - 1); - isLastLastCharUpper = isLastCharUpper; - isLastCharUpper = false; - isLastCharLower = true; - } else { - isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character; - isLastLastCharUpper = isLastCharUpper; - isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character; - } - } + /* eslint-disable no-unused-expressions */ + /** + * You may add a file property with a path of a file (used throughout the VFile ecosystem). + * @type {string?} + */ + this.file; + /** + * If true, marks associated file as no longer processable. + * @type {boolean?} + */ + this.fatal; + /** + * You may add a url property with a link to documentation for the message. + * @type {string?} + */ + this.url; + /** + * You may add a note property with a long form description of the message (supported by vfile-reporter). + * @type {string?} + */ + this.note; + /* eslint-enable no-unused-expressions */ + } +} - return string; -}; +VFileMessage.prototype.file = ''; +VFileMessage.prototype.name = ''; +VFileMessage.prototype.reason = ''; +VFileMessage.prototype.message = ''; +VFileMessage.prototype.stack = ''; +VFileMessage.prototype.fatal = null; +VFileMessage.prototype.column = null; +VFileMessage.prototype.line = null; +VFileMessage.prototype.source = null; +VFileMessage.prototype.ruleId = null; +VFileMessage.prototype.position = null; -const camelCase = (input, options) => { - if (!(typeof input === 'string' || Array.isArray(input))) { - throw new TypeError('Expected the input to be `string | string[]`'); - } +/** + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Position} Position + * @typedef {import('unist').Point} Point + * + * @typedef {'ascii'|'utf8'|'utf-8'|'utf16le'|'ucs2'|'ucs-2'|'base64'|'latin1'|'binary'|'hex'} BufferEncoding + * Encodings supported by the buffer class. + * This is a copy of the typing from Node, copied to prevent Node globals from + * being needed. + * Copied from: + * + * @typedef {string|Uint8Array} VFileValue Contents of the file. + * Can either be text, or a Buffer like structure. + * This does not directly use type `Buffer`, because it can also be used in a + * browser context. + * Instead this leverages `Uint8Array` which is the base type for `Buffer`, + * and a native JavaScript construct. + * + * @typedef {VFileValue|VFileOptions|VFile} VFileCompatible Things that can be + * passed to the constructor. + * + * @typedef VFileCoreOptions + * @property {VFileValue} [value] + * @property {string} [cwd] + * @property {Array.} [history] + * @property {string} [path] + * @property {string} [basename] + * @property {string} [stem] + * @property {string} [extname] + * @property {string} [dirname] + * @property {Object.} [data] + * + * @typedef {{[key: string]: unknown} & VFileCoreOptions} VFileOptions + * Configuration: a bunch of keys that will be shallow copied over to the new + * file. + * + * @typedef {Object.} VFileReporterSettings + * @typedef {(files: VFile[], options: T) => string} VFileReporter + */ - options = Object.assign({ - pascalCase: false - }, options); +// Order of setting (least specific to most), we need this because otherwise +// `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a +// stem can be set. +var order = ['history', 'path', 'basename', 'stem', 'extname', 'dirname']; - const postProcess = x => options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x; +class VFile { + /** + * Create a new virtual file. + * + * If `options` is `string` or `Buffer`, treats it as `{value: options}`. + * If `options` is a `VFile`, shallow copies its data over to the new file. + * All other given fields are set on the newly created `VFile`. + * + * Path related properties are set in the following order (least specific to + * most specific): `history`, `path`, `basename`, `stem`, `extname`, + * `dirname`. + * + * It’s not possible to set either `dirname` or `extname` without setting + * either `history`, `path`, `basename`, or `stem` as well. + * + * @param {VFileCompatible} [value] + */ + constructor(value) { + var index = -1; + /** @type {VFileOptions} */ + var options; + /** @type {string} */ + var prop; - if (Array.isArray(input)) { - input = input.map(x => x.trim()) - .filter(x => x.length) - .join('-'); - } else { - input = input.trim(); - } + if (!value) { + options = {}; + } else if (typeof value === 'string' || isBuffer(value)) { + // @ts-ignore Looks like a buffer. + options = {value}; + } else { + // @ts-ignore Looks like file or options. + options = value; + } - if (input.length === 0) { - return ''; - } + /** + * Place to store custom information. + * It’s OK to store custom data directly on the file, moving it to `data` + * gives a little more privacy. + * @type {Object.} + */ + this.data = {}; - if (input.length === 1) { - return options.pascalCase ? input.toUpperCase() : input.toLowerCase(); - } + /** + * List of messages associated with the file. + * @type {Array.} + */ + this.messages = []; - const hasUpperCase = input !== input.toLowerCase(); + /** + * List of file paths the file moved between. + * @type {Array.} + */ + this.history = []; - if (hasUpperCase) { - input = preserveCamelCase(input); - } + /** + * Base of `path`. + * Defaults to `process.cwd()` (`/` in browsers). + * @type {string} + */ + this.cwd = proc$1.cwd(); - input = input - .replace(/^[_.\- ]+/, '') - .toLowerCase() - .replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase()) - .replace(/\d+(\w|$)/g, m => m.toUpperCase()); + /* eslint-disable no-unused-expressions */ + /** + * Raw value. + * @type {VFileValue} + */ + this.value; - return postProcess(input); -}; + // The below are non-standard, they are “well-known”. + // As in, used in several tools. -camelcase$1.exports = camelCase; -// TODO: Remove this for the next major release -camelcase$1.exports.default = camelCase; + /** + * Whether a file was saved to disk. + * This is used by vfile reporters. + * @type {boolean} + */ + this.stored; -var minimist$1 = function (args, opts) { - if (!opts) opts = {}; - - var flags = { bools : {}, strings : {}, unknownFn: null }; + /** + * Sometimes files have a non-string representation. + * This can be stored in the `result` field. + * One example is when turning markdown into React nodes. + * This is used by unified to store non-string results. + * @type {unknown} + */ + this.result; + /* eslint-enable no-unused-expressions */ - if (typeof opts['unknown'] === 'function') { - flags.unknownFn = opts['unknown']; + // Set path related properties in the correct order. + while (++index < order.length) { + prop = order[index]; + + // Note: we specifically use `in` instead of `hasOwnProperty` to accept + // `vfile`s too. + if (prop in options && options[prop] !== undefined) { + this[prop] = prop === 'history' ? options[prop].concat() : options[prop]; + } } - if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { - flags.allBools = true; - } else { - [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { - flags.bools[key] = true; - }); + // Set non-path related properties. + for (prop in options) { + if (!order.includes(prop)) { + this[prop] = options[prop]; + } } - - var aliases = {}; - Object.keys(opts.alias || {}).forEach(function (key) { - aliases[key] = [].concat(opts.alias[key]); - aliases[key].forEach(function (x) { - aliases[x] = [key].concat(aliases[key].filter(function (y) { - return x !== y; - })); - }); - }); - - [].concat(opts.string).filter(Boolean).forEach(function (key) { - flags.strings[key] = true; - if (aliases[key]) { - flags.strings[aliases[key]] = true; - } - }); + } - var defaults = opts['default'] || {}; - - var argv = { _ : [] }; - Object.keys(flags.bools).forEach(function (key) { - setArg(key, defaults[key] === undefined ? false : defaults[key]); - }); - - var notFlags = []; + /** + * Access full path (`~/index.min.js`). + */ + get path() { + return this.history[this.history.length - 1] + } - if (args.indexOf('--') !== -1) { - notFlags = args.slice(args.indexOf('--')+1); - args = args.slice(0, args.indexOf('--')); - } + /** + * Set full path (`~/index.min.js`). + * Cannot be nullified. + */ + set path(path) { + assertNonEmpty(path, 'path'); - function argDefined(key, arg) { - return (flags.allBools && /^--[^=]+$/.test(arg)) || - flags.strings[key] || flags.bools[key] || aliases[key]; + if (this.path !== path) { + this.history.push(path); } + } - function setArg (key, val, arg) { - if (arg && flags.unknownFn && !argDefined(key, arg)) { - if (flags.unknownFn(arg) === false) return; - } + /** + * Access parent path (`~`). + */ + get dirname() { + return typeof this.path === 'string' ? path__default['default'].dirname(this.path) : undefined + } - var value = !flags.strings[key] && isNumber(val) - ? Number(val) : val - ; - setKey(argv, key.split('.'), value); - - (aliases[key] || []).forEach(function (x) { - setKey(argv, x.split('.'), value); - }); - } + /** + * Set parent path (`~`). + * Cannot be set if there's no `path` yet. + */ + set dirname(dirname) { + assertPath(this.path, 'dirname'); + this.path = path__default['default'].join(dirname || '', this.basename); + } - function setKey (obj, keys, value) { - var o = obj; - for (var i = 0; i < keys.length-1; i++) { - var key = keys[i]; - if (key === '__proto__') return; - if (o[key] === undefined) o[key] = {}; - if (o[key] === Object.prototype || o[key] === Number.prototype - || o[key] === String.prototype) o[key] = {}; - if (o[key] === Array.prototype) o[key] = []; - o = o[key]; - } + /** + * Access basename (including extname) (`index.min.js`). + */ + get basename() { + return typeof this.path === 'string' ? path__default['default'].basename(this.path) : undefined + } - var key = keys[keys.length - 1]; - if (key === '__proto__') return; - if (o === Object.prototype || o === Number.prototype - || o === String.prototype) o = {}; - if (o === Array.prototype) o = []; - if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { - o[key] = value; - } - else if (Array.isArray(o[key])) { - o[key].push(value); - } - else { - o[key] = [ o[key], value ]; - } - } - - function aliasIsBoolean(key) { - return aliases[key].some(function (x) { - return flags.bools[x]; - }); - } + /** + * Set basename (`index.min.js`). + * Cannot contain path separators. + * Cannot be nullified either (use `file.path = file.dirname` instead). + */ + set basename(basename) { + assertNonEmpty(basename, 'basename'); + assertPart(basename, 'basename'); + this.path = path__default['default'].join(this.dirname || '', basename); + } - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - - if (/^--.+=/.test(arg)) { - // Using [\s\S] instead of . because js doesn't support the - // 'dotall' regex modifier. See: - // http://stackoverflow.com/a/1068308/13216 - var m = arg.match(/^--([^=]+)=([\s\S]*)$/); - var key = m[1]; - var value = m[2]; - if (flags.bools[key]) { - value = value !== 'false'; - } - setArg(key, value, arg); - } - else if (/^--no-.+/.test(arg)) { - var key = arg.match(/^--no-(.+)/)[1]; - setArg(key, false, arg); - } - else if (/^--.+/.test(arg)) { - var key = arg.match(/^--(.+)/)[1]; - var next = args[i + 1]; - if (next !== undefined && !/^-/.test(next) - && !flags.bools[key] - && !flags.allBools - && (aliases[key] ? !aliasIsBoolean(key) : true)) { - setArg(key, next, arg); - i++; - } - else if (/^(true|false)$/.test(next)) { - setArg(key, next === 'true', arg); - i++; - } - else { - setArg(key, flags.strings[key] ? '' : true, arg); - } - } - else if (/^-[^-]+/.test(arg)) { - var letters = arg.slice(1,-1).split(''); - - var broken = false; - for (var j = 0; j < letters.length; j++) { - var next = arg.slice(j+2); - - if (next === '-') { - setArg(letters[j], next, arg); - continue; - } - - if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { - setArg(letters[j], next.split('=')[1], arg); - broken = true; - break; - } - - if (/[A-Za-z]/.test(letters[j]) - && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { - setArg(letters[j], next, arg); - broken = true; - break; - } - - if (letters[j+1] && letters[j+1].match(/\W/)) { - setArg(letters[j], arg.slice(j+2), arg); - broken = true; - break; - } - else { - setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); - } - } - - var key = arg.slice(-1)[0]; - if (!broken && key !== '-') { - if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) - && !flags.bools[key] - && (aliases[key] ? !aliasIsBoolean(key) : true)) { - setArg(key, args[i+1], arg); - i++; - } - else if (args[i+1] && /^(true|false)$/.test(args[i+1])) { - setArg(key, args[i+1] === 'true', arg); - i++; - } - else { - setArg(key, flags.strings[key] ? '' : true, arg); - } - } - } - else { - if (!flags.unknownFn || flags.unknownFn(arg) !== false) { - argv._.push( - flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) - ); - } - if (opts.stopEarly) { - argv._.push.apply(argv._, args.slice(i + 1)); - break; - } - } - } - - Object.keys(defaults).forEach(function (key) { - if (!hasKey(argv, key.split('.'))) { - setKey(argv, key.split('.'), defaults[key]); - - (aliases[key] || []).forEach(function (x) { - setKey(argv, x.split('.'), defaults[key]); - }); - } - }); - - if (opts['--']) { - argv['--'] = new Array(); - notFlags.forEach(function(key) { - argv['--'].push(key); - }); - } - else { - notFlags.forEach(function(key) { - argv._.push(key); - }); - } + /** + * Access extname (including dot) (`.js`). + */ + get extname() { + return typeof this.path === 'string' ? path__default['default'].extname(this.path) : undefined + } - return argv; -}; + /** + * Set extname (including dot) (`.js`). + * Cannot be set if there's no `path` yet and cannot contain path separators. + */ + set extname(extname) { + assertPart(extname, 'extname'); + assertPath(this.path, 'extname'); -function hasKey (obj, keys) { - var o = obj; - keys.slice(0,-1).forEach(function (key) { - o = (o[key] || {}); - }); + if (extname) { + if (extname.charCodeAt(0) !== 46 /* `.` */) { + throw new Error('`extname` must start with `.`') + } - var key = keys[keys.length - 1]; - return key in o; -} + if (extname.includes('.', 1)) { + throw new Error('`extname` cannot contain multiple dots') + } + } -function isNumber (x) { - if (typeof x === 'number') return true; - if (/^0x[0-9a-f]+$/i.test(x)) return true; - return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); -} + this.path = path__default['default'].join(this.dirname, this.stem + (extname || '')); + } -// This is a generated file. Do not edit. -var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/; -var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\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\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\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\u0AF9\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-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\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-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\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-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/; -var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\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\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\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\u09FC\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\u0AF9-\u0AFF\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\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\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\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\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-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\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-\u191E\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\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\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\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-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\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-\uFE2F\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/; + /** + * Access stem (w/o extname) (`index.min`). + */ + get stem() { + return typeof this.path === 'string' + ? path__default['default'].basename(this.path, this.extname) + : undefined + } -var unicode = { - Space_Separator: Space_Separator, - ID_Start: ID_Start, - ID_Continue: ID_Continue -}; + /** + * Set stem (w/o extname) (`index.min`). + * Cannot be nullified, and cannot contain path separators. + */ + set stem(stem) { + assertNonEmpty(stem, 'stem'); + assertPart(stem, 'stem'); + this.path = path__default['default'].join(this.dirname || '', stem + (this.extname || '')); + } -var util = { - isSpaceSeparator (c) { - return typeof c === 'string' && unicode.Space_Separator.test(c) - }, + /** + * Serialize the file. + * + * @param {BufferEncoding} [encoding='utf8'] If `file.value` is a buffer, `encoding` is used to serialize buffers. + * @returns {string} + */ + toString(encoding) { + // @ts-ignore string’s don’t accept the parameter, but buffers do. + return (this.value || '').toString(encoding) + } - isIdStartChar (c) { - return typeof c === 'string' && ( - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c === '$') || (c === '_') || - unicode.ID_Start.test(c) - ) - }, + /** + * Create a message and associates it w/ the file. + * + * @param {string|Error} reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given. + * @param {Node|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional). + * @param {string} [origin] Place in code the message originates from (`string`, optional). + * @returns {VFileMessage} + */ + message(reason, place, origin) { + var message = new VFileMessage(reason, place, origin); - isIdContinueChar (c) { - return typeof c === 'string' && ( - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - (c === '$') || (c === '_') || - (c === '\u200C') || (c === '\u200D') || - unicode.ID_Continue.test(c) - ) - }, + if (this.path) { + message.name = this.path + ':' + message.name; + message.file = this.path; + } - isDigit (c) { - return typeof c === 'string' && /[0-9]/.test(c) - }, + message.fatal = false; - isHexDigit (c) { - return typeof c === 'string' && /[0-9A-Fa-f]/.test(c) - }, -}; + this.messages.push(message); -let source; -let parseState; -let stack; -let pos; -let line; -let column; -let token; -let key; -let root$1; + return message + } -var parse$4 = function parse (text, reviver) { - source = String(text); - parseState = 'start'; - stack = []; - pos = 0; - line = 1; - column = 0; - token = undefined; - key = undefined; - root$1 = undefined; + /** + * Info: create a message, associate it with the file, and mark the fatality + * as `null`. + * Calls `message()` internally. + * + * @param {string|Error} reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given. + * @param {Node|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional). + * @param {string} [origin] Place in code the message originates from (`string`, optional). + * @returns {VFileMessage} + */ + info(reason, place, origin) { + var message = this.message(reason, place, origin); - do { - token = lex(); + message.fatal = null; - // This code is unreachable. - // if (!parseStates[parseState]) { - // throw invalidParseState() - // } + return message + } - parseStates[parseState](); - } while (token.type !== 'eof') + /** + * Fail: create a message, associate it with the file, mark the fatality as + * `true`. + * Note: fatal errors mean a file is no longer processable. + * Calls `message()` internally. + * + * @param {string|Error} reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given. + * @param {Node|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional). + * @param {string} [origin] Place in code the message originates from (`string`, optional). + * @returns {never} + */ + fail(reason, place, origin) { + var message = this.message(reason, place, origin); - if (typeof reviver === 'function') { - return internalize({'': root$1}, '', reviver) - } + message.fatal = true; - return root$1 -}; + throw message + } +} -function internalize (holder, name, reviver) { - const value = holder[name]; - if (value != null && typeof value === 'object') { - for (const key in value) { - const replacement = internalize(value, key, reviver); - if (replacement === undefined) { - delete value[key]; - } else { - value[key] = replacement; - } - } - } +/** + * Assert that `part` is not a path (as in, does not contain `path.sep`). + * + * @param {string} part + * @param {string} name + * @returns {void} + */ +function assertPart(part, name) { + if (part && part.includes(path__default['default'].sep)) { + throw new Error( + '`' + name + '` cannot be a path: did not expect `' + path__default['default'].sep + '`' + ) + } +} - return reviver.call(holder, name, value) +/** + * Assert that `part` is not empty. + * + * @param {string} part + * @param {string} name + * @returns {void} + */ +function assertNonEmpty(part, name) { + if (!part) { + throw new Error('`' + name + '` cannot be empty') + } } -let lexState; -let buffer$2; -let doubleQuote; -let sign; -let c; +/** + * Assert `path` exists. + * + * @param {string} path + * @param {string} name + * @returns {void} + */ +function assertPath(path, name) { + if (!path) { + throw new Error('Setting `' + name + '` requires `path` to be set too') + } +} -function lex () { - lexState = 'default'; - buffer$2 = ''; - doubleQuote = false; - sign = 1; +/** + * @typedef {import('vfile').VFileValue} Value + * @typedef {import('vfile').VFileOptions} Options + * @typedef {import('vfile').BufferEncoding} BufferEncoding + * + * @typedef {number|string} Mode + * @typedef {BufferEncoding|{encoding?: null|BufferEncoding, flag?: string}} ReadOptions + * @typedef {BufferEncoding|{encoding?: null|BufferEncoding, mode: Mode?, flag?: string}} WriteOptions + * + * @typedef {string|Uint8Array} Path Path of the file. + * @typedef {Path|URL|Options|VFile} Compatible Things that can be + * passed to the function. + */ - for (;;) { - c = peek(); +/** + * Create a virtual file from a description. + * If `options` is a string or a buffer, it’s used as the path. + * If it’s a VFile itself, it’s returned instead. + * In all other cases, the options are passed through to `vfile()`. + * + * @param {Compatible} [options] + * @returns {VFile} + */ +function toVFile(options) { + if (typeof options === 'string' || isBuffer(options)) { + options = {path: String(options)}; + } else if (options instanceof url.URL) { + options = {path: url.fileURLToPath(options)}; + } - // This code is unreachable. - // if (!lexStates[lexState]) { - // throw invalidLexState(lexState) - // } + return looksLikeAVFile$1(options) ? options : new VFile(options) +} - const token = lexStates[lexState](); - if (token) { - return token - } - } +/** + * Create a virtual file and read it in, synchronously. + * + * @param {Compatible} description + * @param {ReadOptions} [options] + * @returns {VFile} + */ +function readSync(description, options) { + var file = toVFile(description); + file.value = require$$0__default$1['default'].readFileSync(path__default['default'].resolve(file.cwd, file.path), options); + return file } -function peek () { - if (source[pos]) { - return String.fromCodePoint(source.codePointAt(pos)) - } +/** + * Create a virtual file and write it in, synchronously. + * + * @param {Compatible} description + * @param {WriteOptions} [options] + * @returns {VFile} + */ +function writeSync(description, options) { + var file = toVFile(description); + require$$0__default$1['default'].writeFileSync(path__default['default'].resolve(file.cwd, file.path), file.value || '', options); + return file } -function read () { - const c = peek(); +const read$2 = + /** + * @type {{ + * (description: Compatible, options: ReadOptions, callback: Callback): void + * (description: Compatible, callback: Callback): void + * (description: Compatible, options?: ReadOptions): Promise + * }} + */ + ( + /** + * Create a virtual file and read it in, asynchronously. + * + * @param {Compatible} description + * @param {ReadOptions} [options] + * @param {Callback} [callback] + */ + function (description, options, callback) { + var file = toVFile(description); - if (c === '\n') { - line++; - column = 0; - } else if (c) { - column += c.length; - } else { - column++; - } + if (!callback && typeof options === 'function') { + callback = options; + options = null; + } - if (c) { - pos += c.length; - } + if (!callback) { + return new Promise(executor) + } - return c -} + executor(resolve, callback); -const lexStates = { - default () { - switch (c) { - case '\t': - case '\v': - case '\f': - case ' ': - case '\u00A0': - case '\uFEFF': - case '\n': - case '\r': - case '\u2028': - case '\u2029': - read(); - return + /** + * @param {VFile} result + */ + function resolve(result) { + callback(null, result); + } - case '/': - read(); - lexState = 'comment'; - return + /** + * @param {(x: VFile) => void} resolve + * @param {(x: Error, y?: VFile) => void} reject + */ + function executor(resolve, reject) { + /** @type {string} */ + var fp; - case undefined: - read(); - return newToken('eof') + try { + fp = path__default['default'].resolve(file.cwd, file.path); + } catch (error) { + return reject(error) } - if (util.isSpaceSeparator(c)) { - read(); - return + require$$0__default$1['default'].readFile(fp, options, done); + + /** + * @param {Error} error + * @param {Value} result + */ + function done(error, result) { + if (error) { + reject(error); + } else { + file.value = result; + resolve(file); + } } + } + } + ); - // This code is unreachable. - // if (!lexStates[parseState]) { - // throw invalidLexState(parseState) - // } +const write = + /** + * @type {{ + * (description: Compatible, options: WriteOptions, callback: Callback): void + * (description: Compatible, callback: Callback): void + * (description: Compatible, options?: WriteOptions): Promise + * }} + */ + ( + /** + * Create a virtual file and write it in, asynchronously. + * + * @param {Compatible} description + * @param {WriteOptions} [options] + * @param {Callback} [callback] + */ + function (description, options, callback) { + var file = toVFile(description); - return lexStates[parseState]() - }, + // Weird, right? Otherwise `fs` doesn’t accept it. + if (!callback && typeof options === 'function') { + callback = options; + options = undefined; + } - comment () { - switch (c) { - case '*': - read(); - lexState = 'multiLineComment'; - return + if (!callback) { + return new Promise(executor) + } - case '/': - read(); - lexState = 'singleLineComment'; - return - } + executor(resolve, callback); - throw invalidChar(read()) - }, + /** + * @param {VFile} result + */ + function resolve(result) { + callback(null, result); + } - multiLineComment () { - switch (c) { - case '*': - read(); - lexState = 'multiLineCommentAsterisk'; - return + /** + * @param {(x: VFile) => void} resolve + * @param {(x: Error, y?: VFile) => void} reject + */ + function executor(resolve, reject) { + /** @type {string} */ + var fp; - case undefined: - throw invalidChar(read()) + try { + fp = path__default['default'].resolve(file.cwd, file.path); + } catch (error) { + return reject(error) } - read(); - }, - - multiLineCommentAsterisk () { - switch (c) { - case '*': - read(); - return - - case '/': - read(); - lexState = 'default'; - return + require$$0__default$1['default'].writeFile(fp, file.value || '', options, done); - case undefined: - throw invalidChar(read()) + /** + * @param {Error} error + */ + function done(error) { + if (error) { + reject(error); + } else { + resolve(file); + } } + } + } + ); - read(); - lexState = 'multiLineComment'; - }, - - singleLineComment () { - switch (c) { - case '\n': - case '\r': - case '\u2028': - case '\u2029': - read(); - lexState = 'default'; - return +/** + * @param {Compatible} value + * @returns {value is VFile} + */ +function looksLikeAVFile$1(value) { + return ( + value && + typeof value === 'object' && + 'message' in value && + 'messages' in value + ) +} - case undefined: - read(); - return newToken('eof') - } +toVFile.readSync = readSync; +toVFile.writeSync = writeSync; +toVFile.read = read$2; +toVFile.write = write; - read(); - }, +/** + * @typedef {import('fs').Stats} Stats + * @typedef {import('vfile').VFile} VFile + * @typedef {import('./ignore.js').Ignore} Ignore + * @typedef {import('ignore').Ignore} GitIgnore + * + * @typedef Options + * @property {string} cwd + * @property {Array.} extensions + * @property {boolean|undefined} silentlyIgnore + * @property {Array.} ignorePatterns + * @property {Ignore} ignore + * + * @typedef SearchResults + * @property {fs.Stats|undefined} stats + * @property {boolean|undefined} ignored + * + * @typedef Result + * @property {Array.} input + * @property {VFile[]} output + * + * @typedef CleanResult + * @property {boolean} oneFileMode + * @property {VFile[]} files + * + * @callback Callback + * @param {Error|null} error + * @param {CleanResult} [result] + */ - value () { - switch (c) { - case '{': - case '[': - return newToken('punctuator', read()) +/** + * Search `patterns`, a mix of globs, paths, and files. + * + * @param {Array.} input + * @param {Options} options + * @param {Callback} callback + */ +function finder(input, options, callback) { + expand(input, options, (error, result) => { + // Glob errors are unusual. + // other errors are on the vfile results. + /* c8 ignore next 2 */ + if (error || !result) { + callback(error); + } else { + callback(null, {oneFileMode: oneFileMode(result), files: result.output}); + } + }); +} - case 'n': - read(); - literal('ull'); - return newToken('null', null) +/** + * Expand the given glob patterns, search given and found directories, and map + * to vfiles. + * + * @param {Array.} input + * @param {Options} options + * @param {(error: Error|null, result?: Result) => void} next + */ +function expand(input, options, next) { + /** @type {Array.} */ + let paths = []; + let actual = 0; + let expected = 0; + let index = -1; + /** @type {boolean|undefined} */ + let failed; - case 't': - read(); - literal('rue'); - return newToken('boolean', true) + while (++index < input.length) { + let file = input[index]; + if (typeof file === 'string') { + if (glob_1.hasMagic(file)) { + expected++; + glob_1(file, {cwd: options.cwd}, (error, files) => { + // Glob errors are unusual. + /* c8 ignore next 3 */ + if (failed) { + return + } - case 'f': - read(); - literal('alse'); - return newToken('boolean', false) + // Glob errors are unusual. + /* c8 ignore next 4 */ + if (error) { + failed = true; + done1(error); + } else { + actual++; + paths = paths.concat(files); - case '-': - case '+': - if (read() === '-') { - sign = -1; + if (actual === expected) { + search$1(paths, options, done1); } + } + }); + } else { + // `relative` to make the paths canonical. + file = + path__default$1['default'].relative(options.cwd, path__default$1['default'].resolve(options.cwd, file)) || '.'; + paths.push(file); + } + } else { + const fp = file.path ? path__default$1['default'].relative(options.cwd, file.path) : options.cwd; + file.cwd = options.cwd; + file.path = fp; + file.history = [fp]; + paths.push(file); + } + } - lexState = 'sign'; - return + if (!expected) { + search$1(paths, options, done1); + } - case '.': - buffer$2 = read(); - lexState = 'decimalPointLeading'; - return + /** + * @param {Error|null} error + * @param {Array} [files] + */ + function done1(error, files) { + // `search` currently does not give errors. + /* c8 ignore next 2 */ + if (error || !files) { + next(error); + } else { + next(null, {input: paths, output: files}); + } + } +} - case '0': - buffer$2 = read(); - lexState = 'zero'; - return +/** + * Search `paths`. + * + * @param {Array.} input + * @param {Options & {nested?: boolean}} options + * @param {(error: Error|null, files: Array.) => void} next + */ +function search$1(input, options, next) { + const extraIgnore = ignore().add(options.ignorePatterns); + let expected = 0; + let actual = 0; + let index = -1; + /** @type {Array.} */ + let files = []; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - buffer$2 = read(); - lexState = 'decimalInteger'; - return + while (++index < input.length) { + each(input[index]); + } - case 'I': - read(); - literal('nfinity'); - return newToken('numeric', Infinity) + if (!expected) { + next(null, files); + } - case 'N': - read(); - literal('aN'); - return newToken('numeric', NaN) + /** + * @param {string|VFile} file + */ + function each(file) { + const ext = typeof file === 'string' ? path__default$1['default'].extname(file) : file.extname; - case '"': - case "'": - doubleQuote = (read() === '"'); - buffer$2 = ''; - lexState = 'string'; - return - } + // Normalise globs. + if (typeof file === 'string') { + file = file.split('/').join(path__default$1['default'].sep); + } - throw invalidChar(read()) - }, + const part = base$1(file); - identifierNameStartEscape () { - if (c !== 'u') { - throw invalidChar(read()) - } + if (options.nested && (part.charAt(0) === '.' || part === 'node_modules')) { + return + } - read(); - const u = unicodeEscape(); - switch (u) { - case '$': - case '_': - break + expected++; - default: - if (!util.isIdStartChar(u)) { - throw invalidIdentifier() + statAndIgnore( + file, + Object.assign({}, options, {extraIgnore}), + (error, result) => { + const ignored = result && result.ignored; + const dir = result && result.stats && result.stats.isDirectory(); + + if (ignored && (options.nested || options.silentlyIgnore)) { + return one(null, []) + } + + if (!ignored && dir) { + return fs__default['default'].readdir( + path__default$1['default'].resolve(options.cwd, filePath(file)), + (error, basenames) => { + // Should not happen often: the directory is `stat`ed first, which was ok, + // but reading it is not. + /* c8 ignore next 9 */ + if (error) { + const otherFile = toVFile(filePath(file)); + otherFile.cwd = options.cwd; + + try { + otherFile.fail('Cannot read directory'); + } catch {} + + one(null, [otherFile]); + } else { + search$1( + basenames.map((name) => path__default$1['default'].join(filePath(file), name)), + Object.assign({}, options, {nested: true}), + one + ); + } } - - break + ) } - buffer$2 += u; - lexState = 'identifierName'; - }, + if ( + !dir && + options.nested && + options.extensions.length > 0 && + !options.extensions.includes(ext) + ) { + return one(null, []) + } - identifierName () { - switch (c) { - case '$': - case '_': - case '\u200C': - case '\u200D': - buffer$2 += read(); - return + file = toVFile(file); + file.cwd = options.cwd; - case '\\': - read(); - lexState = 'identifierNameEscape'; - return + if (ignored) { + try { + file.fail('Cannot process specified file: it’s ignored'); + // C8 bug on Node@12 + /* c8 ignore next 1 */ + } catch {} } - if (util.isIdContinueChar(c)) { - buffer$2 += read(); - return + if (error && error.code === 'ENOENT') { + try { + file.fail( + error.syscall === 'stat' ? 'No such file or directory' : error + ); + // C8 bug on Node@12 + /* c8 ignore next 1 */ + } catch {} } - return newToken('identifier', buffer$2) - }, - - identifierNameEscape () { - if (c !== 'u') { - throw invalidChar(read()) - } + one(null, [file]); + } + ); - read(); - const u = unicodeEscape(); - switch (u) { - case '$': - case '_': - case '\u200C': - case '\u200D': - break + /** + * Error is never given. Always given `results`. + * + * @param {Error|null} _ + * @param {Array.} results + */ + function one(_, results) { + /* istanbul ignore else - Always given. */ + if (results) { + files = files.concat(results); + } - default: - if (!util.isIdContinueChar(u)) { - throw invalidIdentifier() - } + actual++; - break - } + if (actual === expected) { + next(null, files); + } + } + } +} - buffer$2 += u; - lexState = 'identifierName'; - }, +/** + * @param {VFile|string} file + * @param {Options & {extraIgnore: GitIgnore}} options + * @param {(error: NodeJS.ErrnoException|null, result?: SearchResults) => void} callback + */ +function statAndIgnore(file, options, callback) { + const fp = path__default$1['default'].resolve(options.cwd, filePath(file)); + const normal = path__default$1['default'].relative(options.cwd, fp); + let expected = 1; + let actual = 0; + /** @type {Stats|undefined} */ + let stats; + /** @type {boolean|undefined} */ + let ignored; - sign () { - switch (c) { - case '.': - buffer$2 = read(); - lexState = 'decimalPointLeading'; - return + if (typeof file === 'string' || !file.value) { + expected++; + fs__default['default'].stat(fp, (error, value) => { + stats = value; + onStartOrCheck(error); + }); + } - case '0': - buffer$2 = read(); - lexState = 'zero'; - return + options.ignore.check(fp, (error, value) => { + ignored = value; + onStartOrCheck(error); + }); - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - buffer$2 = read(); - lexState = 'decimalInteger'; - return + /** + * @param {Error|null} error + */ + function onStartOrCheck(error) { + actual++; - case 'I': - read(); - literal('nfinity'); - return newToken('numeric', sign * Infinity) + if (error) { + callback(error); + actual = -1; + } else if (actual === expected) { + callback(null, { + stats, + ignored: + ignored || + (normal === '' || + normal === '..' || + normal.charAt(0) === path__default$1['default'].sep || + normal.slice(0, 3) === '..' + path__default$1['default'].sep + ? false + : options.extraIgnore.ignores(normal)) + }); + } + } +} - case 'N': - read(); - literal('aN'); - return newToken('numeric', NaN) - } +/** + * @param {string|VFile} file + * @returns {string} + */ +function base$1(file) { + return typeof file === 'string' ? path__default$1['default'].basename(file) : file.basename +} - throw invalidChar(read()) - }, +/** + * @param {string|VFile} file + * @returns {string} + */ +function filePath(file) { + return typeof file === 'string' ? file : file.path +} - zero () { - switch (c) { - case '.': - buffer$2 += read(); - lexState = 'decimalPoint'; - return +/** + * @param {Result} result + * @returns {boolean} + */ +function oneFileMode(result) { + return ( + result.output.length === 1 && + result.input.length === 1 && + result.output[0].path === result.input[0] + ) +} - case 'e': - case 'E': - buffer$2 += read(); - lexState = 'decimalExponent'; - return +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Settings} Settings + * @typedef {import('./index.js').Configuration} Configuration + */ - case 'x': - case 'X': - buffer$2 += read(); - lexState = 'hexadecimal'; - return +/** + * @param {Context} context + * @param {Settings} settings + * @param {Callback} next + */ +function fileSystem$1(context, settings, next) { + if (context.files.length === 0) { + next(); + } else { + finder( + context.files, + { + cwd: settings.cwd, + extensions: settings.extensions, + silentlyIgnore: settings.silentlyIgnore, + ignorePatterns: settings.ignorePatterns, + ignore: new Ignore({ + cwd: settings.cwd, + detectIgnore: settings.detectIgnore, + ignoreName: settings.ignoreName, + ignorePath: settings.ignorePath, + ignorePathResolveFrom: settings.ignorePathResolveFrom + }) + }, + (error, result) => { + // Glob errors typically don’t occur. + /* c8 ignore next 4 */ + if (!result) { + next(error); + return } - return newToken('numeric', sign * 0) - }, - - decimalInteger () { - switch (c) { - case '.': - buffer$2 += read(); - lexState = 'decimalPoint'; - return + const output = result.files; - case 'e': - case 'E': - buffer$2 += read(); - lexState = 'decimalExponent'; - return - } + // Sort alphabetically. + // Everything is unique so we do not care about cases where left and right + // are equal. + output.sort(sortAlphabetically); - if (util.isDigit(c)) { - buffer$2 += read(); - return + // Mark as given. + // This allows outputting files, which can be pretty dangerous, so it’s + // “hidden”. + let index = -1; + while (++index < output.length) { + output[index].data.unifiedEngineGiven = true; } - return newToken('numeric', sign * Number(buffer$2)) - }, + context.files = output; - decimalPointLeading () { - if (util.isDigit(c)) { - buffer$2 += read(); - lexState = 'decimalFraction'; - return + // If `out` was not set, detect it based on whether one file was given. + if (settings.out === null || settings.out === undefined) { + settings.out = result.oneFileMode; } - throw invalidChar(read()) - }, - - decimalPoint () { - switch (c) { - case 'e': - case 'E': - buffer$2 += read(); - lexState = 'decimalExponent'; - return - } + next(error); + } + ); + } - if (util.isDigit(c)) { - buffer$2 += read(); - lexState = 'decimalFraction'; - return - } + /** + * @param {VFile} left + * @param {VFile} right + * @returns {number} + */ + function sortAlphabetically(left, right) { + return left.path < right.path ? -1 : 1 + } +} - return newToken('numeric', sign * Number(buffer$2)) - }, +/* eslint-disable node/no-deprecated-api */ - decimalFraction () { - switch (c) { - case 'e': - case 'E': - buffer$2 += read(); - lexState = 'decimalExponent'; - return - } +var toString$2 = Object.prototype.toString; - if (util.isDigit(c)) { - buffer$2 += read(); - return - } +var isModern = ( + typeof Buffer !== 'undefined' && + typeof Buffer.alloc === 'function' && + typeof Buffer.allocUnsafe === 'function' && + typeof Buffer.from === 'function' +); - return newToken('numeric', sign * Number(buffer$2)) - }, +function isArrayBuffer (input) { + return toString$2.call(input).slice(8, -1) === 'ArrayBuffer' +} - decimalExponent () { - switch (c) { - case '+': - case '-': - buffer$2 += read(); - lexState = 'decimalExponentSign'; - return - } +function fromArrayBuffer (obj, byteOffset, length) { + byteOffset >>>= 0; - if (util.isDigit(c)) { - buffer$2 += read(); - lexState = 'decimalExponentInteger'; - return - } + var maxLength = obj.byteLength - byteOffset; - throw invalidChar(read()) - }, + if (maxLength < 0) { + throw new RangeError("'offset' is out of bounds") + } - decimalExponentSign () { - if (util.isDigit(c)) { - buffer$2 += read(); - lexState = 'decimalExponentInteger'; - return - } + if (length === undefined) { + length = maxLength; + } else { + length >>>= 0; - throw invalidChar(read()) - }, + if (length > maxLength) { + throw new RangeError("'length' is out of bounds") + } + } - decimalExponentInteger () { - if (util.isDigit(c)) { - buffer$2 += read(); - return - } + return isModern + ? Buffer.from(obj.slice(byteOffset, byteOffset + length)) + : new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length))) +} - return newToken('numeric', sign * Number(buffer$2)) - }, +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8'; + } - hexadecimal () { - if (util.isHexDigit(c)) { - buffer$2 += read(); - lexState = 'hexadecimalInteger'; - return - } + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } - throw invalidChar(read()) - }, + return isModern + ? Buffer.from(string, encoding) + : new Buffer(string, encoding) +} - hexadecimalInteger () { - if (util.isHexDigit(c)) { - buffer$2 += read(); - return - } +function bufferFrom$1 (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } - return newToken('numeric', sign * Number(buffer$2)) - }, + if (isArrayBuffer(value)) { + return fromArrayBuffer(value, encodingOrOffset, length) + } - string () { - switch (c) { - case '\\': - read(); - buffer$2 += escape(); - return + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } - case '"': - if (doubleQuote) { - read(); - return newToken('string', buffer$2) - } + return isModern + ? Buffer.from(value) + : new Buffer(value) +} - buffer$2 += read(); - return +var bufferFrom_1 = bufferFrom$1; - case "'": - if (!doubleQuote) { - read(); - return newToken('string', buffer$2) - } +var typedarray = {}; - buffer$2 += read(); - return +(function (exports) { +var undefined$1 = (void 0); // Paranoia - case '\n': - case '\r': - throw invalidChar(read()) +// Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to +// create, and consume so much memory, that the browser appears frozen. +var MAX_ARRAY_LENGTH = 1e5; - case '\u2028': - case '\u2029': - separatorChar(c); - break +// Approximations of internal ECMAScript conversion functions +var ECMAScript = (function() { + // Stash a copy in case other scripts modify these + var opts = Object.prototype.toString, + ophop = Object.prototype.hasOwnProperty; - case undefined: - throw invalidChar(read()) - } + return { + // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues: + Class: function(v) { return opts.call(v).replace(/^\[object *|\]$/g, ''); }, + HasProperty: function(o, p) { return p in o; }, + HasOwnProperty: function(o, p) { return ophop.call(o, p); }, + IsCallable: function(o) { return typeof o === 'function'; }, + ToInt32: function(v) { return v >> 0; }, + ToUint32: function(v) { return v >>> 0; } + }; +}()); - buffer$2 += read(); - }, +// Snapshot intrinsics +var LN2 = Math.LN2, + abs = Math.abs, + floor = Math.floor, + log = Math.log, + min = Math.min, + pow = Math.pow, + round = Math.round; - start () { - switch (c) { - case '{': - case '[': - return newToken('punctuator', read()) +// ES5: lock down object properties +function configureProperties(obj) { + if (getOwnPropNames && defineProp) { + var props = getOwnPropNames(obj), i; + for (i = 0; i < props.length; i += 1) { + defineProp(obj, props[i], { + value: obj[props[i]], + writable: false, + enumerable: false, + configurable: false + }); + } + } +} - // This code is unreachable since the default lexState handles eof. - // case undefined: - // return newToken('eof') - } +// emulate ES5 getter/setter API using legacy APIs +// http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx +// (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but +// note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless) +var defineProp; +if (Object.defineProperty && (function() { + try { + Object.defineProperty({}, 'x', {}); + return true; + } catch (e) { + return false; + } + })()) { + defineProp = Object.defineProperty; +} else { + defineProp = function(o, p, desc) { + if (!o === Object(o)) throw new TypeError("Object.defineProperty called on non-object"); + if (ECMAScript.HasProperty(desc, 'get') && Object.prototype.__defineGetter__) { Object.prototype.__defineGetter__.call(o, p, desc.get); } + if (ECMAScript.HasProperty(desc, 'set') && Object.prototype.__defineSetter__) { Object.prototype.__defineSetter__.call(o, p, desc.set); } + if (ECMAScript.HasProperty(desc, 'value')) { o[p] = desc.value; } + return o; + }; +} - lexState = 'value'; - }, +var getOwnPropNames = Object.getOwnPropertyNames || function (o) { + if (o !== Object(o)) throw new TypeError("Object.getOwnPropertyNames called on non-object"); + var props = [], p; + for (p in o) { + if (ECMAScript.HasOwnProperty(o, p)) { + props.push(p); + } + } + return props; +}; - beforePropertyName () { - switch (c) { - case '$': - case '_': - buffer$2 = read(); - lexState = 'identifierName'; - return +// ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value) +// for index in 0 ... obj.length +function makeArrayAccessors(obj) { + if (!defineProp) { return; } - case '\\': - read(); - lexState = 'identifierNameStartEscape'; - return + if (obj.length > MAX_ARRAY_LENGTH) throw new RangeError("Array too large for polyfill"); - case '}': - return newToken('punctuator', read()) + function makeArrayAccessor(index) { + defineProp(obj, index, { + 'get': function() { return obj._getter(index); }, + 'set': function(v) { obj._setter(index, v); }, + enumerable: true, + configurable: false + }); + } - case '"': - case "'": - doubleQuote = (read() === '"'); - lexState = 'string'; - return - } + var i; + for (i = 0; i < obj.length; i += 1) { + makeArrayAccessor(i); + } +} - if (util.isIdStartChar(c)) { - buffer$2 += read(); - lexState = 'identifierName'; - return - } +// Internal conversion functions: +// pack() - take a number (interpreted as Type), output a byte array +// unpack() - take a byte array, output a Type-like number - throw invalidChar(read()) - }, +function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; } +function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; } - afterPropertyName () { - if (c === ':') { - return newToken('punctuator', read()) - } +function packI8(n) { return [n & 0xff]; } +function unpackI8(bytes) { return as_signed(bytes[0], 8); } - throw invalidChar(read()) - }, +function packU8(n) { return [n & 0xff]; } +function unpackU8(bytes) { return as_unsigned(bytes[0], 8); } - beforePropertyValue () { - lexState = 'value'; - }, +function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; } - afterPropertyValue () { - switch (c) { - case ',': - case '}': - return newToken('punctuator', read()) - } +function packI16(n) { return [(n >> 8) & 0xff, n & 0xff]; } +function unpackI16(bytes) { return as_signed(bytes[0] << 8 | bytes[1], 16); } - throw invalidChar(read()) - }, +function packU16(n) { return [(n >> 8) & 0xff, n & 0xff]; } +function unpackU16(bytes) { return as_unsigned(bytes[0] << 8 | bytes[1], 16); } - beforeArrayValue () { - if (c === ']') { - return newToken('punctuator', read()) - } +function packI32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } +function unpackI32(bytes) { return as_signed(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } - lexState = 'value'; - }, +function packU32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } +function unpackU32(bytes) { return as_unsigned(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } - afterArrayValue () { - switch (c) { - case ',': - case ']': - return newToken('punctuator', read()) - } +function packIEEE754(v, ebits, fbits) { - throw invalidChar(read()) - }, + var bias = (1 << (ebits - 1)) - 1, + s, e, f, i, bits, str, bytes; - end () { - // This code is unreachable since it's handled by the default lexState. - // if (c === undefined) { - // read() - // return newToken('eof') - // } + function roundToEven(n) { + var w = floor(n), f = n - w; + if (f < 0.5) + return w; + if (f > 0.5) + return w + 1; + return w % 2 ? w + 1 : w; + } - throw invalidChar(read()) - }, -}; + // Compute sign, exponent, fraction + if (v !== v) { + // NaN + // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping + e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0; + } else if (v === Infinity || v === -Infinity) { + e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0; + } else if (v === 0) { + e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0; + } else { + s = v < 0; + v = abs(v); -function newToken (type, value) { - return { - type, - value, - line, - column, + if (v >= pow(2, 1 - bias)) { + e = min(floor(log(v) / LN2), 1023); + f = roundToEven(v / pow(2, e) * pow(2, fbits)); + if (f / pow(2, fbits) >= 2) { + e = e + 1; + f = 1; + } + if (e > bias) { + // Overflow + e = (1 << ebits) - 1; + f = 0; + } else { + // Normalized + e = e + bias; + f = f - pow(2, fbits); + } + } else { + // Denormalized + e = 0; + f = roundToEven(v / pow(2, 1 - bias - fbits)); } -} - -function literal (s) { - for (const c of s) { - const p = peek(); + } - if (p !== c) { - throw invalidChar(read()) - } + // Pack sign, exponent, fraction + bits = []; + for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); } + for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); } + bits.push(s ? 1 : 0); + bits.reverse(); + str = bits.join(''); - read(); - } + // Bits to bytes + bytes = []; + while (str.length) { + bytes.push(parseInt(str.substring(0, 8), 2)); + str = str.substring(8); + } + return bytes; } -function escape () { - const c = peek(); - switch (c) { - case 'b': - read(); - return '\b' - - case 'f': - read(); - return '\f' +function unpackIEEE754(bytes, ebits, fbits) { - case 'n': - read(); - return '\n' + // Bytes to bits + var bits = [], i, j, b, str, + bias, s, e, f; - case 'r': - read(); - return '\r' + for (i = bytes.length; i; i -= 1) { + b = bytes[i - 1]; + for (j = 8; j; j -= 1) { + bits.push(b % 2 ? 1 : 0); b = b >> 1; + } + } + bits.reverse(); + str = bits.join(''); - case 't': - read(); - return '\t' + // Unpack sign, exponent, fraction + bias = (1 << (ebits - 1)) - 1; + s = parseInt(str.substring(0, 1), 2) ? -1 : 1; + e = parseInt(str.substring(1, 1 + ebits), 2); + f = parseInt(str.substring(1 + ebits), 2); - case 'v': - read(); - return '\v' + // Produce number + if (e === (1 << ebits) - 1) { + return f !== 0 ? NaN : s * Infinity; + } else if (e > 0) { + // Normalized + return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); + } else if (f !== 0) { + // Denormalized + return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); + } else { + return s < 0 ? -0 : 0; + } +} - case '0': - read(); - if (util.isDigit(peek())) { - throw invalidChar(read()) - } +function unpackF64(b) { return unpackIEEE754(b, 11, 52); } +function packF64(v) { return packIEEE754(v, 11, 52); } +function unpackF32(b) { return unpackIEEE754(b, 8, 23); } +function packF32(v) { return packIEEE754(v, 8, 23); } - return '\0' - case 'x': - read(); - return hexEscape() +// +// 3 The ArrayBuffer Type +// - case 'u': - read(); - return unicodeEscape() +(function() { - case '\n': - case '\u2028': - case '\u2029': - read(); - return '' + /** @constructor */ + var ArrayBuffer = function ArrayBuffer(length) { + length = ECMAScript.ToInt32(length); + if (length < 0) throw new RangeError('ArrayBuffer size is not a small enough positive integer'); - case '\r': - read(); - if (peek() === '\n') { - read(); - } + this.byteLength = length; + this._bytes = []; + this._bytes.length = length; - return '' + var i; + for (i = 0; i < this.byteLength; i += 1) { + this._bytes[i] = 0; + } - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - throw invalidChar(read()) + configureProperties(this); + }; - case undefined: - throw invalidChar(read()) - } + exports.ArrayBuffer = exports.ArrayBuffer || ArrayBuffer; - return read() -} + // + // 4 The ArrayBufferView Type + // -function hexEscape () { - let buffer = ''; - let c = peek(); + // NOTE: this constructor is not exported + /** @constructor */ + var ArrayBufferView = function ArrayBufferView() { + //this.buffer = null; + //this.byteOffset = 0; + //this.byteLength = 0; + }; - if (!util.isHexDigit(c)) { - throw invalidChar(read()) - } + // + // 5 The Typed Array View Types + // - buffer += read(); + function makeConstructor(bytesPerElement, pack, unpack) { + // Each TypedArray type requires a distinct constructor instance with + // identical logic, which this produces. - c = peek(); - if (!util.isHexDigit(c)) { - throw invalidChar(read()) - } + var ctor; + ctor = function(buffer, byteOffset, length) { + var array, sequence, i, s; - buffer += read(); + if (!arguments.length || typeof arguments[0] === 'number') { + // Constructor(unsigned long length) + this.length = ECMAScript.ToInt32(arguments[0]); + if (length < 0) throw new RangeError('ArrayBufferView size is not a small enough positive integer'); - return String.fromCodePoint(parseInt(buffer, 16)) -} + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + } else if (typeof arguments[0] === 'object' && arguments[0].constructor === ctor) { + // Constructor(TypedArray array) + array = arguments[0]; -function unicodeEscape () { - let buffer = ''; - let count = 4; + this.length = array.length; + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; - while (count-- > 0) { - const c = peek(); - if (!util.isHexDigit(c)) { - throw invalidChar(read()) + for (i = 0; i < this.length; i += 1) { + this._setter(i, array._getter(i)); } + } else if (typeof arguments[0] === 'object' && + !(arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { + // Constructor(sequence array) + sequence = arguments[0]; - buffer += read(); - } - - return String.fromCodePoint(parseInt(buffer, 16)) -} + this.length = ECMAScript.ToUint32(sequence.length); + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; -const parseStates = { - start () { - if (token.type === 'eof') { - throw invalidEOF() + for (i = 0; i < this.length; i += 1) { + s = sequence[i]; + this._setter(i, Number(s)); } + } else if (typeof arguments[0] === 'object' && + (arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { + // Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, optional unsigned long length) + this.buffer = buffer; - push(); - }, + this.byteOffset = ECMAScript.ToUint32(byteOffset); + if (this.byteOffset > this.buffer.byteLength) { + throw new RangeError("byteOffset out of range"); + } - beforePropertyName () { - switch (token.type) { - case 'identifier': - case 'string': - key = token.value; - parseState = 'afterPropertyName'; - return + if (this.byteOffset % this.BYTES_PER_ELEMENT) { + // The given byteOffset must be a multiple of the element + // size of the specific type, otherwise an exception is raised. + throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size."); + } - case 'punctuator': - // This code is unreachable since it's handled by the lexState. - // if (token.value !== '}') { - // throw invalidToken() - // } + if (arguments.length < 3) { + this.byteLength = this.buffer.byteLength - this.byteOffset; - pop(); - return + if (this.byteLength % this.BYTES_PER_ELEMENT) { + throw new RangeError("length of buffer minus byteOffset not a multiple of the element size"); + } + this.length = this.byteLength / this.BYTES_PER_ELEMENT; + } else { + this.length = ECMAScript.ToUint32(length); + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + } - case 'eof': - throw invalidEOF() + if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { + throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); } + } else { + throw new TypeError("Unexpected argument type(s)"); + } - // This code is unreachable since it's handled by the lexState. - // throw invalidToken() - }, + this.constructor = ctor; - afterPropertyName () { - // This code is unreachable since it's handled by the lexState. - // if (token.type !== 'punctuator' || token.value !== ':') { - // throw invalidToken() - // } + configureProperties(this); + makeArrayAccessors(this); + }; - if (token.type === 'eof') { - throw invalidEOF() - } + ctor.prototype = new ArrayBufferView(); + ctor.prototype.BYTES_PER_ELEMENT = bytesPerElement; + ctor.prototype._pack = pack; + ctor.prototype._unpack = unpack; + ctor.BYTES_PER_ELEMENT = bytesPerElement; - parseState = 'beforePropertyValue'; - }, + // getter type (unsigned long index); + ctor.prototype._getter = function(index) { + if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); - beforePropertyValue () { - if (token.type === 'eof') { - throw invalidEOF() - } + index = ECMAScript.ToUint32(index); + if (index >= this.length) { + return undefined$1; + } - push(); - }, + var bytes = [], i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + bytes.push(this.buffer._bytes[o]); + } + return this._unpack(bytes); + }; - beforeArrayValue () { - if (token.type === 'eof') { - throw invalidEOF() - } + // NONSTANDARD: convenience alias for getter: type get(unsigned long index); + ctor.prototype.get = ctor.prototype._getter; - if (token.type === 'punctuator' && token.value === ']') { - pop(); - return - } + // setter void (unsigned long index, type value); + ctor.prototype._setter = function(index, value) { + if (arguments.length < 2) throw new SyntaxError("Not enough arguments"); - push(); - }, + index = ECMAScript.ToUint32(index); + if (index >= this.length) { + return undefined$1; + } - afterPropertyValue () { - // This code is unreachable since it's handled by the lexState. - // if (token.type !== 'punctuator') { - // throw invalidToken() - // } + var bytes = this._pack(value), i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + this.buffer._bytes[o] = bytes[i]; + } + }; - if (token.type === 'eof') { - throw invalidEOF() - } + // void set(TypedArray array, optional unsigned long offset); + // void set(sequence array, optional unsigned long offset); + ctor.prototype.set = function(index, value) { + if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); + var array, sequence, offset, len, + i, s, d, + byteOffset, byteLength, tmp; - switch (token.value) { - case ',': - parseState = 'beforePropertyName'; - return + if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) { + // void set(TypedArray array, optional unsigned long offset); + array = arguments[0]; + offset = ECMAScript.ToUint32(arguments[1]); - case '}': - pop(); + if (offset + array.length > this.length) { + throw new RangeError("Offset plus length of array is out of range"); } - // This code is unreachable since it's handled by the lexState. - // throw invalidToken() - }, - - afterArrayValue () { - // This code is unreachable since it's handled by the lexState. - // if (token.type !== 'punctuator') { - // throw invalidToken() - // } + byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT; + byteLength = array.length * this.BYTES_PER_ELEMENT; - if (token.type === 'eof') { - throw invalidEOF() + if (array.buffer === this.buffer) { + tmp = []; + for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) { + tmp[i] = array.buffer._bytes[s]; + } + for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) { + this.buffer._bytes[d] = tmp[i]; + } + } else { + for (i = 0, s = array.byteOffset, d = byteOffset; + i < byteLength; i += 1, s += 1, d += 1) { + this.buffer._bytes[d] = array.buffer._bytes[s]; + } } + } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') { + // void set(sequence array, optional unsigned long offset); + sequence = arguments[0]; + len = ECMAScript.ToUint32(sequence.length); + offset = ECMAScript.ToUint32(arguments[1]); - switch (token.value) { - case ',': - parseState = 'beforeArrayValue'; - return + if (offset + len > this.length) { + throw new RangeError("Offset plus length of array is out of range"); + } - case ']': - pop(); + for (i = 0; i < len; i += 1) { + s = sequence[i]; + this._setter(offset + i, Number(s)); } + } else { + throw new TypeError("Unexpected argument type(s)"); + } + }; - // This code is unreachable since it's handled by the lexState. - // throw invalidToken() - }, + // TypedArray subarray(long begin, optional long end); + ctor.prototype.subarray = function(start, end) { + function clamp(v, min, max) { return v < min ? min : v > max ? max : v; } - end () { - // This code is unreachable since it's handled by the lexState. - // if (token.type !== 'eof') { - // throw invalidToken() - // } - }, -}; + start = ECMAScript.ToInt32(start); + end = ECMAScript.ToInt32(end); -function push () { - let value; + if (arguments.length < 1) { start = 0; } + if (arguments.length < 2) { end = this.length; } - switch (token.type) { - case 'punctuator': - switch (token.value) { - case '{': - value = {}; - break + if (start < 0) { start = this.length + start; } + if (end < 0) { end = this.length + end; } - case '[': - value = []; - break - } + start = clamp(start, 0, this.length); + end = clamp(end, 0, this.length); - break + var len = end - start; + if (len < 0) { + len = 0; + } - case 'null': - case 'boolean': - case 'numeric': - case 'string': - value = token.value; - break + return new this.constructor( + this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len); + }; - // This code is unreachable. - // default: - // throw invalidToken() - } + return ctor; + } - if (root$1 === undefined) { - root$1 = value; - } else { - const parent = stack[stack.length - 1]; - if (Array.isArray(parent)) { - parent.push(value); - } else { - parent[key] = value; - } - } + var Int8Array = makeConstructor(1, packI8, unpackI8); + var Uint8Array = makeConstructor(1, packU8, unpackU8); + var Uint8ClampedArray = makeConstructor(1, packU8Clamped, unpackU8); + var Int16Array = makeConstructor(2, packI16, unpackI16); + var Uint16Array = makeConstructor(2, packU16, unpackU16); + var Int32Array = makeConstructor(4, packI32, unpackI32); + var Uint32Array = makeConstructor(4, packU32, unpackU32); + var Float32Array = makeConstructor(4, packF32, unpackF32); + var Float64Array = makeConstructor(8, packF64, unpackF64); - if (value !== null && typeof value === 'object') { - stack.push(value); + exports.Int8Array = exports.Int8Array || Int8Array; + exports.Uint8Array = exports.Uint8Array || Uint8Array; + exports.Uint8ClampedArray = exports.Uint8ClampedArray || Uint8ClampedArray; + exports.Int16Array = exports.Int16Array || Int16Array; + exports.Uint16Array = exports.Uint16Array || Uint16Array; + exports.Int32Array = exports.Int32Array || Int32Array; + exports.Uint32Array = exports.Uint32Array || Uint32Array; + exports.Float32Array = exports.Float32Array || Float32Array; + exports.Float64Array = exports.Float64Array || Float64Array; +}()); - if (Array.isArray(value)) { - parseState = 'beforeArrayValue'; - } else { - parseState = 'beforePropertyName'; - } - } else { - const current = stack[stack.length - 1]; - if (current == null) { - parseState = 'end'; - } else if (Array.isArray(current)) { - parseState = 'afterArrayValue'; - } else { - parseState = 'afterPropertyValue'; - } - } -} +// +// 6 The DataView View Type +// -function pop () { - stack.pop(); +(function() { + function r(array, index) { + return ECMAScript.IsCallable(array.get) ? array.get(index) : array[index]; + } - const current = stack[stack.length - 1]; - if (current == null) { - parseState = 'end'; - } else if (Array.isArray(current)) { - parseState = 'afterArrayValue'; - } else { - parseState = 'afterPropertyValue'; + var IS_BIG_ENDIAN = (function() { + var u16array = new(exports.Uint16Array)([0x1234]), + u8array = new(exports.Uint8Array)(u16array.buffer); + return r(u8array, 0) === 0x12; + }()); + + // Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, + // optional unsigned long byteLength) + /** @constructor */ + var DataView = function DataView(buffer, byteOffset, byteLength) { + if (arguments.length === 0) { + buffer = new exports.ArrayBuffer(0); + } else if (!(buffer instanceof exports.ArrayBuffer || ECMAScript.Class(buffer) === 'ArrayBuffer')) { + throw new TypeError("TypeError"); } -} -// This code is unreachable. -// function invalidParseState () { -// return new Error(`JSON5: invalid parse state '${parseState}'`) -// } + this.buffer = buffer || new exports.ArrayBuffer(0); -// This code is unreachable. -// function invalidLexState (state) { -// return new Error(`JSON5: invalid lex state '${state}'`) -// } + this.byteOffset = ECMAScript.ToUint32(byteOffset); + if (this.byteOffset > this.buffer.byteLength) { + throw new RangeError("byteOffset out of range"); + } -function invalidChar (c) { - if (c === undefined) { - return syntaxError(`JSON5: invalid end of input at ${line}:${column}`) + if (arguments.length < 3) { + this.byteLength = this.buffer.byteLength - this.byteOffset; + } else { + this.byteLength = ECMAScript.ToUint32(byteLength); } - return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`) -} + if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { + throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); + } -function invalidEOF () { - return syntaxError(`JSON5: invalid end of input at ${line}:${column}`) -} + configureProperties(this); + }; -// This code is unreachable. -// function invalidToken () { -// if (token.type === 'eof') { -// return syntaxError(`JSON5: invalid end of input at ${line}:${column}`) -// } + function makeGetter(arrayType) { + return function(byteOffset, littleEndian) { -// const c = String.fromCodePoint(token.value.codePointAt(0)) -// return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`) -// } + byteOffset = ECMAScript.ToUint32(byteOffset); -function invalidIdentifier () { - column -= 5; - return syntaxError(`JSON5: invalid identifier character at ${line}:${column}`) -} + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { + throw new RangeError("Array index out of range"); + } + byteOffset += this.byteOffset; -function separatorChar (c) { - console.warn(`JSON5: '${formatChar(c)}' in strings is not valid ECMAScript; consider escaping`); -} + var uint8Array = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT), + bytes = [], i; + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { + bytes.push(r(uint8Array, i)); + } -function formatChar (c) { - const replacements = { - "'": "\\'", - '"': '\\"', - '\\': '\\\\', - '\b': '\\b', - '\f': '\\f', - '\n': '\\n', - '\r': '\\r', - '\t': '\\t', - '\v': '\\v', - '\0': '\\0', - '\u2028': '\\u2028', - '\u2029': '\\u2029', - }; + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { + bytes.reverse(); + } - if (replacements[c]) { - return replacements[c] - } + return r(new arrayType(new exports.Uint8Array(bytes).buffer), 0); + }; + } - if (c < ' ') { - const hexString = c.charCodeAt(0).toString(16); - return '\\x' + ('00' + hexString).substring(hexString.length) - } + DataView.prototype.getUint8 = makeGetter(exports.Uint8Array); + DataView.prototype.getInt8 = makeGetter(exports.Int8Array); + DataView.prototype.getUint16 = makeGetter(exports.Uint16Array); + DataView.prototype.getInt16 = makeGetter(exports.Int16Array); + DataView.prototype.getUint32 = makeGetter(exports.Uint32Array); + DataView.prototype.getInt32 = makeGetter(exports.Int32Array); + DataView.prototype.getFloat32 = makeGetter(exports.Float32Array); + DataView.prototype.getFloat64 = makeGetter(exports.Float64Array); - return c -} + function makeSetter(arrayType) { + return function(byteOffset, value, littleEndian) { -function syntaxError (message) { - const err = new SyntaxError(message); - err.lineNumber = line; - err.columnNumber = column; - return err -} + byteOffset = ECMAScript.ToUint32(byteOffset); + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { + throw new RangeError("Array index out of range"); + } -var stringify$3 = function stringify (value, replacer, space) { - const stack = []; - let indent = ''; - let propertyList; - let replacerFunc; - let gap = ''; - let quote; + // Get bytes + var typeArray = new arrayType([value]), + byteArray = new exports.Uint8Array(typeArray.buffer), + bytes = [], i, byteView; - if ( - replacer != null && - typeof replacer === 'object' && - !Array.isArray(replacer) - ) { - space = replacer.space; - quote = replacer.quote; - replacer = replacer.replacer; - } + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { + bytes.push(r(byteArray, i)); + } - if (typeof replacer === 'function') { - replacerFunc = replacer; - } else if (Array.isArray(replacer)) { - propertyList = []; - for (const v of replacer) { - let item; + // Flip if necessary + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { + bytes.reverse(); + } - if (typeof v === 'string') { - item = v; - } else if ( - typeof v === 'number' || - v instanceof String || - v instanceof Number - ) { - item = String(v); - } + // Write them + byteView = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT); + byteView.set(bytes); + }; + } - if (item !== undefined && propertyList.indexOf(item) < 0) { - propertyList.push(item); - } - } - } + DataView.prototype.setUint8 = makeSetter(exports.Uint8Array); + DataView.prototype.setInt8 = makeSetter(exports.Int8Array); + DataView.prototype.setUint16 = makeSetter(exports.Uint16Array); + DataView.prototype.setInt16 = makeSetter(exports.Int16Array); + DataView.prototype.setUint32 = makeSetter(exports.Uint32Array); + DataView.prototype.setInt32 = makeSetter(exports.Int32Array); + DataView.prototype.setFloat32 = makeSetter(exports.Float32Array); + DataView.prototype.setFloat64 = makeSetter(exports.Float64Array); - if (space instanceof Number) { - space = Number(space); - } else if (space instanceof String) { - space = String(space); - } + exports.DataView = exports.DataView || DataView; - if (typeof space === 'number') { - if (space > 0) { - space = Math.min(10, Math.floor(space)); - gap = ' '.substr(0, space); - } - } else if (typeof space === 'string') { - gap = space.substr(0, 10); - } +}()); +}(typedarray)); - return serializeProperty('', {'': value}) +var Writable = require$$1__default['default'].Writable; +var inherits = inherits$2.exports; +var bufferFrom = bufferFrom_1; - function serializeProperty (key, holder) { - let value = holder[key]; - if (value != null) { - if (typeof value.toJSON5 === 'function') { - value = value.toJSON5(key); - } else if (typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - } +if (typeof Uint8Array === 'undefined') { + var U8 = typedarray.Uint8Array; +} else { + var U8 = Uint8Array; +} - if (replacerFunc) { - value = replacerFunc.call(holder, key, value); - } +function ConcatStream(opts, cb) { + if (!(this instanceof ConcatStream)) return new ConcatStream(opts, cb) - if (value instanceof Number) { - value = Number(value); - } else if (value instanceof String) { - value = String(value); - } else if (value instanceof Boolean) { - value = value.valueOf(); - } - - switch (value) { - case null: return 'null' - case true: return 'true' - case false: return 'false' - } - - if (typeof value === 'string') { - return quoteString(value) - } - - if (typeof value === 'number') { - return String(value) - } + if (typeof opts === 'function') { + cb = opts; + opts = {}; + } + if (!opts) opts = {}; - if (typeof value === 'object') { - return Array.isArray(value) ? serializeArray(value) : serializeObject(value) - } + var encoding = opts.encoding; + var shouldInferEncoding = false; - return undefined + if (!encoding) { + shouldInferEncoding = true; + } else { + encoding = String(encoding).toLowerCase(); + if (encoding === 'u8' || encoding === 'uint8') { + encoding = 'uint8array'; } + } - function quoteString (value) { - const quotes = { - "'": 0.1, - '"': 0.2, - }; + Writable.call(this, { objectMode: true }); - const replacements = { - "'": "\\'", - '"': '\\"', - '\\': '\\\\', - '\b': '\\b', - '\f': '\\f', - '\n': '\\n', - '\r': '\\r', - '\t': '\\t', - '\v': '\\v', - '\0': '\\0', - '\u2028': '\\u2028', - '\u2029': '\\u2029', - }; + this.encoding = encoding; + this.shouldInferEncoding = shouldInferEncoding; - let product = ''; + if (cb) this.on('finish', function () { cb(this.getBody()); }); + this.body = []; +} - for (let i = 0; i < value.length; i++) { - const c = value[i]; - switch (c) { - case "'": - case '"': - quotes[c]++; - product += c; - continue +var concatStream = ConcatStream; +inherits(ConcatStream, Writable); - case '\0': - if (util.isDigit(value[i + 1])) { - product += '\\x00'; - continue - } - } +ConcatStream.prototype._write = function(chunk, enc, next) { + this.body.push(chunk); + next(); +}; - if (replacements[c]) { - product += replacements[c]; - continue - } +ConcatStream.prototype.inferEncoding = function (buff) { + var firstBuffer = buff === undefined ? this.body[0] : buff; + if (Buffer.isBuffer(firstBuffer)) return 'buffer' + if (typeof Uint8Array !== 'undefined' && firstBuffer instanceof Uint8Array) return 'uint8array' + if (Array.isArray(firstBuffer)) return 'array' + if (typeof firstBuffer === 'string') return 'string' + if (Object.prototype.toString.call(firstBuffer) === "[object Object]") return 'object' + return 'buffer' +}; - if (c < ' ') { - let hexString = c.charCodeAt(0).toString(16); - product += '\\x' + ('00' + hexString).substring(hexString.length); - continue - } +ConcatStream.prototype.getBody = function () { + if (!this.encoding && this.body.length === 0) return [] + if (this.shouldInferEncoding) this.encoding = this.inferEncoding(); + if (this.encoding === 'array') return arrayConcat(this.body) + if (this.encoding === 'string') return stringConcat(this.body) + if (this.encoding === 'buffer') return bufferConcat(this.body) + if (this.encoding === 'uint8array') return u8Concat(this.body) + return this.body +}; - product += c; - } +function isArrayish (arr) { + return /Array\]$/.test(Object.prototype.toString.call(arr)) +} - const quoteChar = quote || Object.keys(quotes).reduce((a, b) => (quotes[a] < quotes[b]) ? a : b); +function isBufferish (p) { + return typeof p === 'string' || isArrayish(p) || (p && typeof p.subarray === 'function') +} - product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]); +function stringConcat (parts) { + var strings = []; + for (var i = 0; i < parts.length; i++) { + var p = parts[i]; + if (typeof p === 'string') { + strings.push(p); + } else if (Buffer.isBuffer(p)) { + strings.push(p); + } else if (isBufferish(p)) { + strings.push(bufferFrom(p)); + } else { + strings.push(bufferFrom(String(p))); + } + } + if (Buffer.isBuffer(parts[0])) { + strings = Buffer.concat(strings); + strings = strings.toString('utf8'); + } else { + strings = strings.join(''); + } + return strings +} - return quoteChar + product + quoteChar +function bufferConcat (parts) { + var bufs = []; + for (var i = 0; i < parts.length; i++) { + var p = parts[i]; + if (Buffer.isBuffer(p)) { + bufs.push(p); + } else if (isBufferish(p)) { + bufs.push(bufferFrom(p)); + } else { + bufs.push(bufferFrom(String(p))); } + } + return Buffer.concat(bufs) +} - function serializeObject (value) { - if (stack.indexOf(value) >= 0) { - throw TypeError('Converting circular structure to JSON5') - } +function arrayConcat (parts) { + var res = []; + for (var i = 0; i < parts.length; i++) { + res.push.apply(res, parts[i]); + } + return res +} - stack.push(value); +function u8Concat (parts) { + var len = 0; + for (var i = 0; i < parts.length; i++) { + if (typeof parts[i] === 'string') { + parts[i] = bufferFrom(parts[i]); + } + len += parts[i].length; + } + var u8 = new U8(len); + for (var i = 0, offset = 0; i < parts.length; i++) { + var part = parts[i]; + for (var j = 0; j < part.length; j++) { + u8[offset++] = part[j]; + } + } + return u8 +} - let stepback = indent; - indent = indent + gap; +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Settings} Settings + */ - let keys = propertyList || Object.keys(value); - let partial = []; - for (const key of keys) { - const propertyString = serializeProperty(key, value); - if (propertyString !== undefined) { - let member = serializeKey(key) + ':'; - if (gap !== '') { - member += ' '; - } - member += propertyString; - partial.push(member); - } - } +const debug$9 = createDebug('unified-engine:file-set-pipeline:stdin'); - let final; - if (partial.length === 0) { - final = '{}'; - } else { - let properties; - if (gap === '') { - properties = partial.join(','); - final = '{' + properties + '}'; - } else { - let separator = ',\n' + indent; - properties = partial.join(separator); - final = '{\n' + indent + properties + ',\n' + stepback + '}'; - } - } +/** + * @param {Context} context + * @param {Settings} settings + * @param {Callback} next + */ +function stdin(context, settings, next) { + if (settings.files && settings.files.length > 0) { + debug$9('Ignoring `streamIn`'); - stack.pop(); - indent = stepback; - return final - } + /** @type {Error|undefined} */ + let error; - function serializeKey (key) { - if (key.length === 0) { - return quoteString(key) - } + if (settings.filePath) { + error = new Error( + 'Do not pass both `--file-path` and real files.\nDid you mean to pass stdin instead of files?' + ); + } - const firstChar = String.fromCodePoint(key.codePointAt(0)); - if (!util.isIdStartChar(firstChar)) { - return quoteString(key) - } + next(error); - for (let i = firstChar.length; i < key.length; i++) { - if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) { - return quoteString(key) - } - } + return + } - return key - } + // @ts-expect-error: does exist on `stdin`. + if (settings.streamIn.isTTY) { + debug$9('Cannot read from `tty` stream'); + next(new Error('No input')); - function serializeArray (value) { - if (stack.indexOf(value) >= 0) { - throw TypeError('Converting circular structure to JSON5') - } + return + } - stack.push(value); + debug$9('Reading from `streamIn`'); - let stepback = indent; - indent = indent + gap; + settings.streamIn.pipe( + concatStream({encoding: 'string'}, (value) => { + const file = toVFile(settings.filePath); - let partial = []; - for (let i = 0; i < value.length; i++) { - const propertyString = serializeProperty(String(i), value); - partial.push((propertyString !== undefined) ? propertyString : 'null'); - } + debug$9('Read from `streamIn`'); - let final; - if (partial.length === 0) { - final = '[]'; - } else { - if (gap === '') { - let properties = partial.join(','); - final = '[' + properties + ']'; - } else { - let separator = ',\n' + indent; - let properties = partial.join(separator); - final = '[\n' + indent + properties + ',\n' + stepback + ']'; - } - } + file.cwd = settings.cwd; + file.value = value; + file.data.unifiedEngineGiven = true; + file.data.unifiedEngineStreamIn = true; - stack.pop(); - indent = stepback; - return final - } -}; + context.files = [file]; -const JSON5 = { - parse: parse$4, - stringify: stringify$3, -}; + // If `out` was not set, set `out`. + settings.out = + settings.out === null || settings.out === undefined + ? true + : settings.out; -var lib$3 = JSON5; + next(); + }) + ); +} -var dist$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - 'default': lib$3 -}); +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Pipeline} Pipeline + */ -var require$$3$1 = /*@__PURE__*/getAugmentedNamespace(dist$1); - -var require$$5$1 = [ - { - long: "help", - description: "output usage information", - short: "h", - type: "boolean", - "default": false - }, - { - long: "version", - description: "output version number", - short: "v", - type: "boolean", - "default": false - }, - { - long: "output", - description: "specify output location", - short: "o", - value: "[path]" - }, - { - long: "rc-path", - description: "specify configuration file", - short: "r", - type: "string", - value: "" - }, - { - long: "ignore-path", - description: "specify ignore file", - short: "i", - type: "string", - value: "" - }, - { - long: "setting", - description: "specify settings", - short: "s", - type: "string", - value: "" - }, - { - long: "ext", - description: "specify extensions", - short: "e", - type: "string", - value: "" - }, - { - long: "use", - description: "use plugins", - short: "u", - type: "string", - value: "" - }, - { - long: "watch", - description: "watch for changes and reprocess", - short: "w", - type: "boolean", - "default": false - }, - { - long: "quiet", - description: "output only warnings and errors", - short: "q", - type: "boolean", - "default": false - }, - { - long: "silent", - description: "output only errors", - short: "S", - type: "boolean", - "default": false - }, - { - long: "frail", - description: "exit with 1 on warnings", - short: "f", - type: "boolean", - "default": false - }, - { - long: "tree", - description: "specify input and output as syntax tree", - short: "t", - type: "boolean", - "default": false - }, - { - long: "report", - description: "specify reporter", - type: "string", - value: "" - }, - { - long: "file-path", - description: "specify path to process as", - type: "string", - value: "" - }, - { - long: "ignore-path-resolve-from", - description: "resolve patterns in `ignore-path` from its directory or cwd", - type: "string", - value: "dir|cwd", - "default": "dir" - }, - { - long: "ignore-pattern", - description: "specify ignore patterns", - type: "string", - value: "" - }, - { - long: "silently-ignore", - description: "do not fail when given ignored files", - type: "boolean" - }, - { - long: "tree-in", - description: "specify input as syntax tree", - type: "boolean" - }, - { - long: "tree-out", - description: "output syntax tree", - type: "boolean" - }, - { - long: "inspect", - description: "output formatted syntax tree", - type: "boolean" - }, - { - long: "stdout", - description: "specify writing to stdout", - type: "boolean", - truelike: true - }, - { - long: "color", - description: "specify color in report", - type: "boolean", - "default": true - }, - { - long: "config", - description: "search for configuration files", - type: "boolean", - "default": true - }, - { - long: "ignore", - description: "search for ignore files", - type: "boolean", - "default": true - } -]; +class FileSet extends node_events.EventEmitter { + /** + * FileSet constructor. + * A FileSet is created to process multiple files through unified processors. + * This set, containing all files, is exposed to plugins as an argument to the + * attacher. + */ + constructor() { + super(); -var table = textTable; -var camelcase = camelcase$1.exports; -var minimist = minimist$1; -var json5 = require$$3$1; -var fault = fault_1; -var schema$1 = require$$5$1; + /** @type {Array.} */ + this.files = []; + /** @type {string[]} */ + this.origins = []; + /** @type {Completer[]} */ + this.plugins = []; + /** @type {number} */ + this.expected = 0; + /** @type {number} */ + this.actual = 0; + /** @type {Pipeline} */ + this.pipeline = trough(); -var options_1 = options$1; + // Called when a single file has completed it’s pipeline, triggering `done` + // when all files are complete. + this.on('one', () => { + this.actual++; -// Schema for `minimist`. -var minischema = { - unknown: handleUnknownArgument, - default: {}, - alias: {}, - string: [], - boolean: [] -}; + if (this.actual >= this.expected) { + this.emit('done'); + } + }); + } -schema$1.forEach(addEach); + /** + * Access the files in a set. + */ + valueOf() { + return this.files + } -// Parse CLI options. -function options$1(flags, configuration) { - var extension = configuration.extensions[0]; - var name = configuration.name; - var config = toCamelCase(minimist(flags, minischema)); - var help; - var ext; - var report; + /** + * Attach middleware to the pipeline on `fileSet`. + * + * @param {Completer} plugin + */ + use(plugin) { + const pipeline = this.pipeline; + let duplicate = false; - schema$1.forEach(function (option) { - if (option.type === 'string' && config[option.long] === '') { - throw fault('Missing value:%s', inspect(option).join(' ')) + if (plugin && plugin.pluginId) { + duplicate = this.plugins.some((fn) => fn.pluginId === plugin.pluginId); } - }); - ext = commaSeparated(config.ext); - report = reporter(config.report); + if (!duplicate && this.plugins.includes(plugin)) { + duplicate = true; + } - help = [ - inspectAll(schema$1), - '', - 'Examples:', - '', - ' # Process `input.' + extension + '`', - ' $ ' + name + ' input.' + extension + ' -o output.' + extension, - '', - ' # Pipe', - ' $ ' + name + ' < input.' + extension + ' > output.' + extension, - '', - ' # Rewrite all applicable files', - ' $ ' + name + ' . -o' - ].join('\n'); + if (!duplicate) { + this.plugins.push(plugin); + pipeline.use(plugin); + } - return { - helpMessage: help, - // “hidden” feature, makes testing easier. - cwd: configuration.cwd, - processor: configuration.processor, - help: config.help, - version: config.version, - files: config._, - filePath: config.filePath, - watch: config.watch, - extensions: ext.length === 0 ? configuration.extensions : ext, - output: config.output, - out: config.stdout, - tree: config.tree, - treeIn: config.treeIn, - treeOut: config.treeOut, - inspect: config.inspect, - rcName: configuration.rcName, - packageField: configuration.packageField, - rcPath: config.rcPath, - detectConfig: config.config, - settings: settings(config.setting), - ignoreName: configuration.ignoreName, - ignorePath: config.ignorePath, - ignorePathResolveFrom: config.ignorePathResolveFrom, - ignorePatterns: commaSeparated(config.ignorePattern), - silentlyIgnore: config.silentlyIgnore, - detectIgnore: config.ignore, - pluginPrefix: configuration.pluginPrefix, - plugins: plugins(config.use), - reporter: report[0], - reporterOptions: report[1], - color: config.color, - silent: config.silent, - quiet: config.quiet, - frail: config.frail + return this } -} -function addEach(option) { - var value = option.default; + /** + * Add a file to be processed. + * The given file is processed like other files with a few differences: + * + * * Ignored when their file path is already added + * * Never written to the file system or streamOut + * * Not reported for + * + * @param {string|VFile} file + */ + add(file) { + if (typeof file === 'string') { + file = toVFile(file); + } - minischema.default[option.long] = value === undefined ? null : value; + // Prevent files from being added multiple times. + if (this.origins.includes(file.history[0])) { + return this + } - if (option.type in minischema) { - minischema[option.type].push(option.long); - } + this.origins.push(file.history[0]); - if (option.short) { - minischema.alias[option.short] = option.long; + // Add. + this.valueOf().push(file); + this.expected++; + + // Force an asynchronous operation. + // This ensures that files which fall through the file pipeline immediately + // (such as, when already fatally failed) still queue up correctly. + setImmediate(() => { + this.emit('add', file); + }); + + return this } } -// Parse `extensions`. -function commaSeparated(value) { - return flatten(normalize(value).map(splitList)) -} +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Context} Context + */ -// Parse `plugins`. -function plugins(value) { - var result = {}; +const debug$8 = createDebug('unified-engine:file-pipeline:read'); - normalize(value) - .map(splitOptions) - .forEach(function (value) { - result[value[0]] = value[1] ? parseConfig(value[1], {}) : null; - }); +/** + * Fill a file with its value when not already filled. + * + * @param {Context} context + * @param {VFile} file + * @param {Callback} next + */ +function read$1(context, file, next) { + let filePath = file.path; - return result -} + if (file.value || file.data.unifiedEngineStreamIn) { + debug$8('Not reading file `%s` with `value`', filePath); + next(); + } else if (statistics(file).fatal) { + debug$8('Not reading failed file `%s`', filePath); + next(); + } else { + filePath = path__default$1['default'].resolve(context.settings.cwd, filePath); -// Parse `reporter`: only one is accepted. -function reporter(value) { - var all = normalize(value) - .map(splitOptions) - .map(function (value) { - return [value[0], value[1] ? parseConfig(value[1], {}) : null] - }); + debug$8('Reading `%s` in `%s`', filePath, 'utf8'); + fs__default['default'].readFile(filePath, 'utf8', (error, value) => { + debug$8('Read `%s` (error: %s)', filePath, error); - return all[all.length - 1] || [] + file.value = value || ''; + + next(error); + }); + } } -// Parse `settings`. -function settings(value) { - var cache = {}; +/** + * Has own property. + * + * @type {Function} + */ - normalize(value).forEach(function (value) { - parseConfig(value, cache); - }); +var has = Object.prototype.hasOwnProperty; - return cache -} +/** + * To string. + * + * @type {Function} + */ -// Parse configuration. -function parseConfig(flags, cache) { - var flag; - var message; +var toString$1 = Object.prototype.toString; - try { - flags = toCamelCase(parseJSON(flags)); - } catch (error) { - // Fix position - message = error.message.replace(/at(?= position)/, 'around'); +/** + * Test whether a value is "empty". + * + * @param {Mixed} val + * @return {Boolean} + */ - throw fault('Cannot parse `%s` as JSON: %s', flags, message) - } +function isEmpty(val) { + // Null and Undefined... + if (val == null) return true - for (flag in flags) { - cache[flag] = flags[flag]; - } + // Booleans... + if ('boolean' == typeof val) return false - return cache -} + // Numbers... + if ('number' == typeof val) return val === 0 -// Handle an unknown flag. -function handleUnknownArgument(flag) { - // Glob. - if (flag.charAt(0) !== '-') { - return - } + // Strings... + if ('string' == typeof val) return val.length === 0 - // Long options, always unknown. - if (flag.charAt(1) === '-') { - throw fault('Unknown option `%s`, expected:\n%s', flag, inspectAll(schema$1)) - } + // Functions... + if ('function' == typeof val) return val.length === 0 - // Short options, can be grouped. - flag.slice(1).split('').forEach(each); + // Arrays... + if (Array.isArray(val)) return val.length === 0 - function each(key) { - var length = schema$1.length; - var index = -1; - var option; + // Errors... + if (val instanceof Error) return val.message === '' - while (++index < length) { - option = schema$1[index]; + // Objects... + if (val.toString == toString$1) { + switch (val.toString()) { - if (option.short === key) { - return + // Maps, Sets, Files and Errors... + case '[object File]': + case '[object Map]': + case '[object Set]': { + return val.size === 0 } - } - throw fault( - 'Unknown short option `-%s`, expected:\n%s', - key, - inspectAll(schema$1.filter(short)) - ) - } + // Plain objects... + case '[object Object]': { + for (var key in val) { + if (has.call(val, key)) return false + } - function short(option) { - return option.short + return true + } + } } -} -// Inspect all `options`. -function inspectAll(options) { - return table(options.map(inspect)) + // Anything else... + return false } -// Inspect one `option`. -function inspect(option) { - var description = option.description; - var long = option.long; +/** + * Export `isEmpty`. + * + * @type {Function} + */ - if (option.default === true || option.truelike) { - description += ' (on by default)'; - long = '[no-]' + long; - } +var lib$1 = isEmpty; - return [ - '', - option.short ? '-' + option.short : '', - '--' + long + (option.value ? ' ' + option.value : ''), - description - ] -} +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Context} Context + */ -// Normalize `value`. -function normalize(value) { - if (!value) { - return [] - } +const debug$7 = createDebug('unified-engine:file-pipeline:configure'); - if (typeof value === 'string') { - return [value] +/** + * Collect configuration for a file based on the context. + * + * @param {Context} context + * @param {VFile} file + * @param {Callback} next + */ +function configure$2(context, file, next) { + if (statistics(file).fatal) { + return next() } - return flatten(value.map(normalize)) -} + context.configuration.load(file.path, (error, configuration) => { + let index = -1; -// Flatten `values`. -function flatten(values) { - return [].concat.apply([], values) -} + if (!configuration) { + return next(error) + } -function splitOptions(value) { - return value.split('=') -} + // Could be missing if a `configTransform` returns weird things. + /* c8 ignore next 1 */ + const plugins = configuration.plugins || []; -function splitList(value) { - return value.split(',') -} + // Store configuration on the context object. + debug$7('Using settings `%j`', configuration.settings); + context.processor.data('settings', configuration.settings); -// Transform the keys on an object to camel-case, recursivly. -function toCamelCase(object) { - var result = {}; - var value; - var key; + debug$7('Using `%d` plugins', plugins.length); - for (key in object) { - value = object[key]; + while (++index < plugins.length) { + const plugin = plugins[index][0]; + let options = plugins[index][1]; - if (value && typeof value === 'object' && !('length' in value)) { - value = toCamelCase(value); - } + if (options === false) { + continue + } - result[camelcase(key)] = value; - } + // Allow for default arguments in es2020. + /* c8 ignore next 6 */ + if ( + options === null || + (typeof options === 'object' && lib$1(options)) + ) { + options = undefined; + } - return result -} + debug$7( + 'Using plugin `%s`, with options `%j`', + // @ts-expect-error: `displayName` sure can exist on functions. + plugin.displayName || plugin.name || 'function', + options + ); -// Parse a (lazy?) JSON config. -function parseJSON(value) { - return json5.parse('{' + value + '}') -} + try { + context.processor.use(plugin, options, context.fileSet); + /* Should not happen anymore! */ + /* c8 ignore next 3 */ + } catch (error_) { + return next(error_) + } + } -var stream = require$$0__default$5['default']; -var engine = lib$4; -var chalk = source$1; -var chokidar = chokidar$1; -var options = options_1; + next(); + }); +} -var lib$2 = start$3; +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('./index.js').Context} Context + */ -var noop$2 = Function.prototype; +const debug$6 = createDebug('unified-engine:file-pipeline:parse'); -// Fake TTY stream. -var ttyStream = new stream.Readable(); -ttyStream.isTTY = true; +/** + * Fill a file with a tree. + * + * @param {Context} context + * @param {VFile} file + */ +function parse$2(context, file) { + if (statistics(file).fatal) { + return + } -// Exit, lazily, with the correct exit status code. -var exitStatus = 0; + if (context.settings.treeIn) { + debug$6('Not parsing already parsed document'); -process.on('exit', onexit); + try { + context.tree = parseJson_1(file.toString()); + } catch (error) { + const message = file.message( + new Error('Cannot read file as JSON\n' + error.message) + ); + message.fatal = true; + } -// Handle uncaught errors, such as from unexpected async behaviour. -process.on('uncaughtException', fail$1); + // Add the preferred extension to ensure the file, when serialized, is + // correctly recognised. + // Only add it if there is a path — not if the file is for example stdin. + if (file.path) { + file.extname = context.settings.extensions[0]; + } -// Start the CLI. -function start$3(cliConfig) { - var config; - var output; - var watcher; + file.value = ''; - try { - config = options(process.argv.slice(2), cliConfig); - } catch (error) { - return fail$1(error, true) + return } - if (config.help) { - process.stdout.write( - [ - 'Usage: ' + cliConfig.name + ' [options] [path | glob ...]', - '', - ' ' + cliConfig.description, - '', - 'Options:', - '', - config.helpMessage, - '' - ].join('\n'), - noop$2 - ); + debug$6('Parsing `%s`', file.path); - return - } + context.tree = context.processor.parse(file); - if (config.version) { - process.stdout.write(cliConfig.version + '\n', noop$2); + debug$6('Parsed document'); +} - return - } +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Context} Context + */ - // Modify `config` for watching. - if (config.watch) { - output = config.output; +const debug$5 = createDebug('unified-engine:file-pipeline:transform'); - // Do not read from stdin(4). - config.streamIn = ttyStream; +/** + * Transform the tree associated with a file with configured plugins. + * + * @param {Context} context + * @param {VFile} file + * @param {Callback} next + */ +function transform$2(context, file, next) { + if (statistics(file).fatal) { + next(); + } else { + debug$5('Transforming document `%s`', file.path); + // @ts-expect-error: `tree` is defined at this point. + context.processor.run(context.tree, file, (error, node) => { + debug$5('Transformed document (error: %s)', error); + context.tree = node; + next(error); + }); + } +} - // Do not write to stdout(4). - config.out = false; +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Context} Context + */ - process.stderr.write( - chalk.bold('Watching...') + ' (press CTRL+C to exit)\n', - noop$2 - ); +const debug$4 = createDebug('unified-engine:file-pipeline:queue'); - // Prevent infinite loop if set to regeneration. - if (output === true) { - config.output = false; +const own$a = {}.hasOwnProperty; - process.stderr.write( - chalk.yellow('Note') + ': Ignoring `--output` until exit.\n', - noop$2 - ); - } +/** + * Queue all files which came this far. + * When the last file gets here, run the file-set pipeline and flush the queue. + * + * @param {Context} context + * @param {VFile} file + * @param {Callback} next + */ +function queue(context, file, next) { + let origin = file.history[0]; + // @ts-expect-error: store a completion map on the `fileSet`. + let map = context.fileSet.complete; + let complete = true; + + if (!map) { + map = {}; + // @ts-expect-error: store a completion map on the `fileSet`. + context.fileSet.complete = map; } - // Initial run. - engine(config, done); + debug$4('Queueing `%s`', origin); - // Handle complete run. - function done(err, code, context) { - if (err) { - clean(); - fail$1(err); - } else { - exitStatus = code; + map[origin] = next; - if (config.watch && !watcher) { - subscribe(context); - } - } + const files = context.fileSet.valueOf(); + let index = -1; + while (++index < files.length) { + each(files[index]); } - // Clean the watcher. - function clean() { - if (watcher) { - watcher.close(); - watcher = null; - } + if (!complete) { + debug$4('Not flushing: some files cannot be flushed'); + return } - // Subscribe a chokidar watcher to all processed files. - function subscribe(context) { - watcher = chokidar - .watch(context.fileSet.origins, {cwd: config.cwd, ignoreInitial: true}) - .on('error', done) - .on('change', onchange); - - process.on('SIGINT', onsigint); + // @ts-expect-error: Reset map. + context.fileSet.complete = {}; + context.fileSet.pipeline.run(context.fileSet, done); - function onchange(filePath) { - config.files = [filePath]; + /** + * @param {VFile} file + */ + function each(file) { + const key = file.history[0]; - engine(config, done); + if (statistics(file).fatal) { + return } - function onsigint() { - // Hide the `^C` in terminal. - process.stderr.write('\n', noop$2); + if (typeof map[key] === 'function') { + debug$4('`%s` can be flushed', key); + } else { + debug$4('Interupting flush: `%s` is not finished', key); + complete = false; + } + } - clean(); + /** + * @param {Error|Null} error + */ + function done(error) { + debug$4('Flushing: all files can be flushed'); - // Do another process if `output` specified regeneration. - if (output === true) { - config.output = output; - config.watch = false; - engine(config, done); + // Flush. + for (origin in map) { + if (own$a.call(map, origin)) { + map[origin](error); } } } } -// Print an error, optionally with stack. -function fail$1(err, pretty) { - var message = - (pretty ? String(err).trim() : err.stack) || - /* istanbul ignore next - Old versions of Node */ err; +var own$9 = {}.hasOwnProperty; - exitStatus = 1; +var bold = ansiColor(1, 22); +var dim = ansiColor(2, 22); +var yellow = ansiColor(33, 39); +var green = ansiColor(32, 39); - process.stderr.write(message.trim() + '\n', noop$2); -} +// ANSI color regex. +/* eslint-disable-next-line no-control-regex */ +var colorExpression = /(?:(?:\u001B\[)|\u009B)(?:\d{1,3})?(?:(?:;\d{0,3})*)?[A-M|f-m]|\u001B[A-M]/g; -function onexit() { - /* eslint-disable unicorn/no-process-exit */ - process.exit(exitStatus); - /* eslint-enable unicorn/no-process-exit */ +/** + * Inspects a node, without using color. + * + * @param {unknown} node + * @param {InspectOptions} [options] + * @returns {string} + */ +function inspectNoColor(node, options) { + return inspectColor(node, options).replace(colorExpression, '') } -var unifiedArgs = lib$2; +/** + * Inspects a node, using color. + * + * @param {unknown} tree + * @param {InspectOptions} [options] + * @returns {string} + */ +function inspectColor(tree, options) { + var positions = + !options || + options.showPositions === null || + options.showPositions === undefined + ? true + : options.showPositions; -var require$$0$3 = [ - "md", - "markdown", - "mdown", - "mkdn", - "mkd", - "mdwn", - "mkdown", - "ron" -]; + return inspectValue(tree) -var markdownExtensions = require$$0$3; + /** + * @param {unknown} node + * @returns {string} + */ + function inspectValue(node) { + if (node && typeof node === 'object' && 'length' in node) { + // @ts-ignore looks like a list of nodes. + return inspectNodes(node) + } -var bail_1 = bail$1; + // @ts-ignore looks like a single node. + if (node && node.type) { + // @ts-ignore looks like a single node. + return inspectTree(node) + } -function bail$1(err) { - if (err) { - throw err + return inspectNonTree(node) } -} - -var hasOwn = Object.prototype.hasOwnProperty; -var toStr = Object.prototype.toString; -var defineProperty = Object.defineProperty; -var gOPD = Object.getOwnPropertyDescriptor; -var isArray = function isArray(arr) { - if (typeof Array.isArray === 'function') { - return Array.isArray(arr); - } + /** + * @param {unknown} value + * @returns {string} + */ + function inspectNonTree(value) { + return JSON.stringify(value) + } - return toStr.call(arr) === '[object Array]'; -}; + /** + * @param {Node[]} nodes + * @returns {string} + */ + function inspectNodes(nodes) { + /** @type {Array.} */ + var result = []; + var index = -1; -var isPlainObject = function isPlainObject(obj) { - if (!obj || toStr.call(obj) !== '[object Object]') { - return false; - } + while (++index < nodes.length) { + result.push( + dim((index < nodes.length - 1 ? '├' : '└') + '─' + index) + + ' ' + + indent( + inspectValue(nodes[index]), + (index < nodes.length - 1 ? dim('│') : ' ') + ' ', + true + ) + ); + } - var hasOwnConstructor = hasOwn.call(obj, 'constructor'); - var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); - // Not own constructor property must be Object - if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { - return false; - } + return result.join('\n') + } - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - var key; - for (key in obj) { /**/ } + /** + * @param {Object.} object + * @returns {string} + */ + function inspectFields(object) { + /** @type {Array.} */ + var result = []; + /** @type {string} */ + var key; + /** @type {unknown} */ + var value; + /** @type {string} */ + var formatted; - return typeof key === 'undefined' || hasOwn.call(obj, key); -}; + for (key in object) { + /* c8 ignore next 1 */ + if (!own$9.call(object, key)) continue -// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target -var setProperty = function setProperty(target, options) { - if (defineProperty && options.name === '__proto__') { - defineProperty(target, options.name, { - enumerable: true, - configurable: true, - value: options.newValue, - writable: true - }); - } else { - target[options.name] = options.newValue; - } -}; + value = object[key]; -// Return undefined instead of __proto__ if '__proto__' is not an own property -var getProperty = function getProperty(obj, name) { - if (name === '__proto__') { - if (!hasOwn.call(obj, name)) { - return void 0; - } else if (gOPD) { - // In early versions of node, obj['__proto__'] is buggy when obj has - // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. - return gOPD(obj, name).value; - } - } + if ( + value === undefined || + // Standard keys defined by unist that we format differently. + // + key === 'type' || + key === 'value' || + key === 'children' || + key === 'position' || + // Ignore `name` (from xast) and `tagName` (from `hast`) when string. + (typeof value === 'string' && (key === 'name' || key === 'tagName')) + ) { + continue + } - return obj[name]; -}; + // A single node. + if ( + value && + typeof value === 'object' && + // @ts-ignore looks like a node. + value.type && + key !== 'data' && + key !== 'attributes' && + key !== 'properties' + ) { + // @ts-ignore looks like a node. + formatted = inspectTree(value); + } + // A list of nodes. + else if ( + value && + typeof value === 'object' && + 'length' in value && + value[0] && + value[0].type + ) { + // @ts-ignore looks like a list of nodes. + formatted = '\n' + inspectNodes(value); + } else { + formatted = inspectNonTree(value); + } -var extend$2 = function extend() { - var options, name, src, copy, copyIsArray, clone; - var target = arguments[0]; - var i = 1; - var length = arguments.length; - var deep = false; + result.push( + key + dim(':') + (/\s/.test(formatted.charAt(0)) ? '' : ' ') + formatted + ); + } - // Handle a deep copy situation - if (typeof target === 'boolean') { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { - target = {}; - } + return indent( + result.join('\n'), + // @ts-ignore looks like a parent node. + (object.children && object.children.length > 0 ? dim('│') : ' ') + ' ' + ) + } - for (; i < length; ++i) { - options = arguments[i]; - // Only deal with non-null/undefined values - if (options != null) { - // Extend the base object - for (name in options) { - src = getProperty(target, name); - copy = getProperty(options, name); + /** + * @param {Node} node + * @returns {string} + */ + function inspectTree(node) { + var result = [formatNode(node)]; + var fields = inspectFields(node); + // @ts-ignore looks like a parent. + var content = inspectNodes(node.children || []); + if (fields) result.push(fields); + if (content) result.push(content); + return result.join('\n') + } - // Prevent never-ending loop - if (target !== copy) { - // Recurse if we're merging plain objects or arrays - if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { - if (copyIsArray) { - copyIsArray = false; - clone = src && isArray(src) ? src : []; - } else { - clone = src && isPlainObject(src) ? src : {}; - } + /** + * Colored node formatter. + * + * @param {Node} node + * @returns {string} + */ + function formatNode(node) { + var result = [bold(node.type)]; + var kind = node.tagName || node.name; + var position = positions ? stringifyPosition(node.position) : ''; - // Never move original objects, clone them - setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); + if (typeof kind === 'string') { + result.push('<', kind, '>'); + } - // Don't bring in undefined values - } else if (typeof copy !== 'undefined') { - setProperty(target, { name: name, newValue: copy }); - } - } - } - } - } + if (node.children) { + // @ts-ignore looks like a parent. + result.push(dim('['), yellow(node.children.length), dim(']')); + } else if (typeof node.value === 'string') { + result.push(' ', green(inspectNonTree(node.value))); + } - // Return the modified object - return target; -}; + if (position) { + result.push(' ', dim('('), position, dim(')')); + } -var stringify$2 = unistUtilStringifyPosition; + return result.join('') + } +} -var vfileMessage = VMessage$1; +/** + * @param {string} value + * @param {string} indentation + * @param {boolean} [ignoreFirst=false] + * @returns {string} + */ +function indent(value, indentation, ignoreFirst) { + var lines = value.split('\n'); + var index = ignoreFirst ? 0 : -1; -// Inherit from `Error#`. -function VMessagePrototype() {} -VMessagePrototype.prototype = Error.prototype; -VMessage$1.prototype = new VMessagePrototype(); + if (!value) return value -// Message properties. -var proto = VMessage$1.prototype; + while (++index < lines.length) { + lines[index] = indentation + lines[index]; + } -proto.file = ''; -proto.name = ''; -proto.reason = ''; -proto.message = ''; -proto.stack = ''; -proto.fatal = null; -proto.column = null; -proto.line = null; + return lines.join('\n') +} -// Construct a new VMessage. -// -// Note: We cannot invoke `Error` on the created context, as that adds readonly -// `line` and `column` attributes on Safari 9, thus throwing and failing the -// data. -function VMessage$1(reason, position, origin) { - var parts; - var range; - var location; +/** + * @param {Position} value + * @returns {string} + */ +function stringifyPosition(value) { + /** @type {Position} */ + // @ts-ignore + var position = value || {}; + /** @type {Array.} */ + var result = []; + /** @type {Array.} */ + var positions = []; + /** @type {Array.} */ + var offsets = []; - if (typeof position === 'string') { - origin = position; - position = null; - } + point(position.start); + point(position.end); - parts = parseOrigin(origin); - range = stringify$2(position) || '1:1'; + if (positions.length > 0) result.push(positions.join('-')); + if (offsets.length > 0) result.push(offsets.join('-')); - location = { - start: {line: null, column: null}, - end: {line: null, column: null} - }; + return result.join(', ') - // Node. - if (position && position.position) { - position = position.position; - } + /** + * @param {Point} value + */ + function point(value) { + if (value) { + positions.push((value.line || 1) + ':' + (value.column || 1)); - if (position) { - // Position. - if (position.start) { - location = position; - position = position.start; - } else { - // Point. - location.start = position; + if ('offset' in value) { + offsets.push(String(value.offset || 0)); + } } } - - if (reason.stack) { - this.stack = reason.stack; - reason = reason.message; - } - - this.message = reason; - this.name = range; - this.reason = reason; - this.line = position ? position.line : null; - this.column = position ? position.column : null; - this.location = location; - this.source = parts[0]; - this.ruleId = parts[1]; } -function parseOrigin(origin) { - var result = [null, null]; - var index; - - if (typeof origin === 'string') { - index = origin.indexOf(':'); +/** + * Factory to wrap values in ANSI colours. + * + * @param {number} open + * @param {number} close + * @returns {function(string): string} + */ +function ansiColor(open, close) { + return color - if (index === -1) { - result[1] = origin; - } else { - result[0] = origin.slice(0, index); - result[1] = origin.slice(index + 1); - } + /** + * @param {string} value + * @returns {string} + */ + function color(value) { + return '\u001B[' + open + 'm' + value + '\u001B[' + close + 'm' } - - return result } -var minpath = require$$0__default$2['default']; +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('./index.js').Context} Context + */ -var minproc = process; +const debug$3 = createDebug('unified-engine:file-pipeline:stringify'); -var p = minpath; -var proc$1 = minproc; -var buffer$1 = isBuffer; +/** + * Stringify a tree. + * + * @param {Context} context + * @param {VFile} file + */ +function stringify$1(context, file) { + /** @type {unknown} */ + let value; -var core$1 = VFile$1; + if (statistics(file).fatal) { + debug$3('Not compiling failed document'); + return + } -var own$c = {}.hasOwnProperty; + if ( + !context.settings.output && + !context.settings.out && + !context.settings.alwaysStringify + ) { + debug$3('Not compiling document without output settings'); + return + } -// Order of setting (least specific to most), we need this because otherwise -// `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a -// stem can be set. -var order$3 = ['history', 'path', 'basename', 'stem', 'extname', 'dirname']; + debug$3('Compiling `%s`', file.path); -VFile$1.prototype.toString = toString$6; + if (context.settings.inspect) { + // Add a `txt` extension if there is a path. + if (file.path) { + file.extname = '.txt'; + } -// Access full path (`~/index.min.js`). -Object.defineProperty(VFile$1.prototype, 'path', {get: getPath, set: setPath}); + value = + (context.settings.color ? inspectColor : inspectNoColor)(context.tree) + + '\n'; + } else if (context.settings.treeOut) { + // Add a `json` extension to ensure the file is correctly seen as JSON. + // Only add it if there is a path — not if the file is for example stdin. + if (file.path) { + file.extname = '.json'; + } -// Access parent path (`~`). -Object.defineProperty(VFile$1.prototype, 'dirname', { - get: getDirname, - set: setDirname -}); + // Add the line feed to create a valid UNIX file. + value = JSON.stringify(context.tree, null, 2) + '\n'; + } else { + // @ts-expect-error: `tree` is defined if we came this far. + value = context.processor.stringify(context.tree, file); + } -// Access basename (`index.min.js`). -Object.defineProperty(VFile$1.prototype, 'basename', { - get: getBasename, - set: setBasename -}); + if (value === undefined || value === null) ; else if (typeof value === 'string' || isBuffer(value)) { + // @ts-expect-error: `isBuffer` checks buffer. + file.value = value; + } else { + file.result = value; + } -// Access extname (`.js`). -Object.defineProperty(VFile$1.prototype, 'extname', { - get: getExtname, - set: setExtname -}); + debug$3('Serialized document'); +} -// Access stem (`index.min`). -Object.defineProperty(VFile$1.prototype, 'stem', {get: getStem, set: setStem}); +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Context} Context + */ -// Construct a new file. -function VFile$1(options) { - var prop; - var index; +const debug$2 = createDebug('unified-engine:file-pipeline:copy'); - if (!options) { - options = {}; - } else if (typeof options === 'string' || buffer$1(options)) { - options = {contents: options}; - } else if ('message' in options && 'messages' in options) { - return options - } +/** + * Move a file. + * + * @param {Context} context + * @param {VFile} file + * @param {Callback} next + */ +function copy(context, file, next) { + const output = context.settings.output; + const currentPath = file.path; - if (!(this instanceof VFile$1)) { - return new VFile$1(options) + if (typeof output !== 'string') { + debug$2('Not copying'); + next(); + return } - this.data = {}; - this.messages = []; - this.history = []; - this.cwd = proc$1.cwd(); + const outpath = path__default$1['default'].resolve(context.settings.cwd, output); - // Set path related properties in the correct order. - index = -1; + debug$2('Copying `%s`', currentPath); - while (++index < order$3.length) { - prop = order$3[index]; + fs__default['default'].stat(outpath, (error, stats) => { + if (error) { + if ( + error.code !== 'ENOENT' || + output.charAt(output.length - 1) === path__default$1['default'].sep + ) { + return next( + new Error('Cannot read output directory. Error:\n' + error.message) + ) + } - if (own$c.call(options, prop)) { - this[prop] = options[prop]; + // This is either given an error, or the parent exists which is a directory, + // but we should keep the basename of the given file. + fs__default['default'].stat(path__default$1['default'].dirname(outpath), (error) => { + if (error) { + next( + new Error('Cannot read parent directory. Error:\n' + error.message) + ); + } else { + done(false); + } + }); + } else { + done(stats.isDirectory()); } - } + }); - // Set non-path related properties. - for (prop in options) { - if (order$3.indexOf(prop) < 0) { - this[prop] = options[prop]; + /** + * @param {boolean} directory + */ + function done(directory) { + if (!directory && context.fileSet.expected > 1) { + return next( + new Error('Cannot write multiple files to single output: ' + outpath) + ) } - } -} -function getPath() { - return this.history[this.history.length - 1] -} + file[directory ? 'dirname' : 'path'] = path__default$1['default'].relative(file.cwd, outpath); -function setPath(path) { - assertNonEmpty(path, 'path'); + debug$2('Copying document from %s to %s', currentPath, file.path); - if (this.path !== path) { - this.history.push(path); + next(); } } -function getDirname() { - return typeof this.path === 'string' ? p.dirname(this.path) : undefined -} +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Context} Context + */ -function setDirname(dirname) { - assertPath(this.path, 'dirname'); - this.path = p.join(dirname || '', this.basename); -} +const debug$1 = createDebug('unified-engine:file-pipeline:stdout'); -function getBasename() { - return typeof this.path === 'string' ? p.basename(this.path) : undefined +/** + * Write a virtual file to `streamOut`. + * Ignored when `output` is given, more than one file was processed, or `out` + * is false. + * + * @param {Context} context + * @param {VFile} file + * @param {Callback} next + */ +function stdout(context, file, next) { + if (!file.data.unifiedEngineGiven) { + debug$1('Ignoring programmatically added file'); + next(); + } else if ( + statistics(file).fatal || + context.settings.output || + !context.settings.out + ) { + debug$1('Ignoring writing to `streamOut`'); + next(); + } else { + debug$1('Writing document to `streamOut`'); + context.settings.streamOut.write(file.toString(), next); + } } -function setBasename(basename) { - assertNonEmpty(basename, 'basename'); - assertPart(basename, 'basename'); - this.path = p.join(this.dirname || '', basename); -} +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Context} Context + */ -function getExtname() { - return typeof this.path === 'string' ? p.extname(this.path) : undefined -} +const debug = createDebug('unified-engine:file-pipeline:file-system'); -function setExtname(extname) { - assertPart(extname, 'extname'); - assertPath(this.path, 'extname'); - - if (extname) { - if (extname.charCodeAt(0) !== 46 /* `.` */) { - throw new Error('`extname` must start with `.`') - } - - if (extname.indexOf('.', 1) > -1) { - throw new Error('`extname` cannot contain multiple dots') - } +/** + * Write a virtual file to the file-system. + * Ignored when `output` is not given. + * + * @param {Context} context + * @param {VFile} file + * @param {Callback} next + */ +function fileSystem(context, file, next) { + if (!context.settings.output) { + debug('Ignoring writing to file-system'); + return next() } - this.path = p.join(this.dirname, this.stem + (extname || '')); -} - -function getStem() { - return typeof this.path === 'string' - ? p.basename(this.path, this.extname) - : undefined -} - -function setStem(stem) { - assertNonEmpty(stem, 'stem'); - assertPart(stem, 'stem'); - this.path = p.join(this.dirname || '', stem + (this.extname || '')); -} - -// Get the value of the file. -function toString$6(encoding) { - return (this.contents || '').toString(encoding) -} - -// Assert that `part` is not a path (i.e., does not contain `p.sep`). -function assertPart(part, name) { - if (part && part.indexOf(p.sep) > -1) { - throw new Error( - '`' + name + '` cannot be a path: did not expect `' + p.sep + '`' - ) + if (!file.data.unifiedEngineGiven) { + debug('Ignoring programmatically added file'); + return next() } -} -// Assert that `part` is not empty. -function assertNonEmpty(part, name) { - if (!part) { - throw new Error('`' + name + '` cannot be empty') - } -} + let destinationPath = file.path; -// Assert `path` exists. -function assertPath(path, name) { - if (!path) { - throw new Error('Setting `' + name + '` requires `path` to be set too') + if (!destinationPath) { + debug('Cannot write file without a `destinationPath`'); + return next(new Error('Cannot write file without an output path')) } -} - -var VMessage = vfileMessage; -var VFile = core$1; -var lib$1 = VFile; - -VFile.prototype.message = message; -VFile.prototype.info = info; -VFile.prototype.fail = fail; - -// Create a message with `reason` at `position`. -// When an error is passed in as `reason`, copies the stack. -function message(reason, position, origin) { - var message = new VMessage(reason, position, origin); - - if (this.path) { - message.name = this.path + ':' + message.name; - message.file = this.path; + if (statistics(file).fatal) { + debug('Cannot write file with a fatal error'); + return next() } - message.fatal = false; + destinationPath = path__default$1['default'].resolve(context.settings.cwd, destinationPath); + debug('Writing document to `%s`', destinationPath); - this.messages.push(message); - - return message + file.stored = true; + fs__default['default'].writeFile(destinationPath, file.toString(), next); } -// Fail: creates a vmessage, associates it with the file, and throws it. -function fail() { - var message = this.message.apply(this, arguments); +/** + * @typedef {import('trough').Pipeline} Pipeline + * @typedef {import('vfile').VFile} VFile + * @typedef {import('vfile-message').VFileMessage} VFileMessage + * @typedef {import('unist').Node} Node + * @typedef {import('unified').Processor} Processor + * @typedef {import('../file-set.js').FileSet} FileSet + * @typedef {import('../configuration.js').Configuration} Configuration + * @typedef {import('../index.js').Settings} Settings + */ - message.fatal = true; +// This pipeline ensures each of the pipes always runs: even if the read pipe +// fails, queue and write run. +const filePipeline = trough() + .use(chunk(trough().use(read$1).use(configure$2).use(parse$2).use(transform$2))) + .use(chunk(trough().use(queue))) + .use(chunk(trough().use(stringify$1).use(copy).use(stdout).use(fileSystem))); - throw message -} +/** + * Factory to run a pipe. + * Wraps a pipe to trigger an error on the `file` in `context`, but still call + * `next`. + * + * @param {Pipeline} pipe + */ +function chunk(pipe) { + return run -// Info: creates a vmessage, associates it with the file, and marks the fatality -// as null. -function info() { - var message = this.message.apply(this, arguments); + /** + * Run the bound pipe and handle any errors. + * + * @param {Context} context + * @param {VFile} file + * @param {() => void} next + */ + function run(context, file, next) { + pipe.run(context, file, (/** @type {VFileMessage|null} */ error) => { + const messages = file.messages; - message.fatal = null; + if (error) { + const index = messages.indexOf(error); - return message -} + if (index === -1) { + Object.assign(file.message(error), {fatal: true}); + } else { + messages[index].fatal = true; + } + } -var vfile$1 = lib$1; + next(); + }); + } +} -var bail = bail_1; -var buffer = isBuffer; -var extend$1 = extend$2; -var plain = isPlainObj; -var trough = trough_1; -var vfile = vfile$1; +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('trough').Callback} Callback + * @typedef {import('./index.js').Settings} Settings + * @typedef {import('./index.js').Configuration} Configuration + */ -// Expose a frozen processor. -var unified_1 = unified$1().freeze(); +/** + * Transform all files. + * + * @param {Context} context + * @param {Settings} settings + * @param {Callback} next + */ +function transform$1(context, settings, next) { + const fileSet = new FileSet(); -var slice$1 = [].slice; -var own$b = {}.hasOwnProperty; + context.fileSet = fileSet; -// Process pipeline. -var pipeline = trough() - .use(pipelineParse) - .use(pipelineRun) - .use(pipelineStringify); + fileSet.on('add', (/** @type {VFile} */ file) => { + filePipeline.run( + { + configuration: context.configuration, + // Needed `any`s + // type-coverage:ignore-next-line + processor: settings.processor(), + fileSet, + settings + }, + file, + (/** @type {Error|null} */ error) => { + // Does not occur as all failures in `filePipeLine` are failed on each + // file. + // Still, just to ensure things work in the future, we add an extra check. + /* c8 ignore next 4 */ + if (error) { + Object.assign(file.message(error), {fatal: true}); + } -function pipelineParse(p, ctx) { - ctx.tree = p.parse(ctx.file); -} + fileSet.emit('one', file); + } + ); + }); -function pipelineRun(p, ctx, next) { - p.run(ctx.tree, ctx.file, done); + fileSet.on('done', next); - function done(error, tree, file) { - if (error) { - next(error); - } else { - ctx.tree = tree; - ctx.file = file; - next(); + if (context.files.length === 0) { + next(); + } else { + let index = -1; + while (++index < context.files.length) { + fileSet.add(context.files[index]); } } } -function pipelineStringify(p, ctx) { - var result = p.stringify(ctx.tree, ctx.file); +function hasFlag(flag, argv = process__default['default'].argv) { + const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); + const position = argv.indexOf(prefix + flag); + const terminatorPosition = argv.indexOf('--'); + return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); +} - if (result === undefined || result === null) ; else if (typeof result === 'string' || buffer(result)) { - if ('value' in ctx.file) { - ctx.file.value = result; - } +const {env} = process__default['default']; - ctx.file.contents = result; - } else { - ctx.file.result = result; - } +let flagForceColor; +if (hasFlag('no-color') || + hasFlag('no-colors') || + hasFlag('color=false') || + hasFlag('color=never')) { + flagForceColor = 0; +} else if (hasFlag('color') || + hasFlag('colors') || + hasFlag('color=true') || + hasFlag('color=always')) { + flagForceColor = 1; } -// Function to create the first processor. -function unified$1() { - var attachers = []; - var transformers = trough(); - var namespace = {}; - var freezeIndex = -1; - var frozen; - - // Data management. - processor.data = data; +function envForceColor() { + if ('FORCE_COLOR' in env) { + if (env.FORCE_COLOR === 'true') { + return 1; + } - // Lock. - processor.freeze = freeze; + if (env.FORCE_COLOR === 'false') { + return 0; + } - // Plugins. - processor.attachers = attachers; - processor.use = use; + return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); + } +} - // API. - processor.parse = parse; - processor.stringify = stringify; - processor.run = run; - processor.runSync = runSync; - processor.process = process; - processor.processSync = processSync; +function translateLevel(level) { + if (level === 0) { + return false; + } - // Expose. - return processor + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; +} - // Create a new processor based on the processor in the current scope. - function processor() { - var destination = unified$1(); - var index = -1; +function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { + const noFlagForceColor = envForceColor(); + if (noFlagForceColor !== undefined) { + flagForceColor = noFlagForceColor; + } - while (++index < attachers.length) { - destination.use.apply(null, attachers[index]); - } + const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; - destination.data(extend$1(true, {}, namespace)); + if (forceColor === 0) { + return 0; + } - return destination - } + if (sniffFlags) { + if (hasFlag('color=16m') || + hasFlag('color=full') || + hasFlag('color=truecolor')) { + return 3; + } - // Freeze: used to signal a processor that has finished configuration. - // - // For example, take unified itself: it’s frozen. - // Plugins should not be added to it. - // Rather, it should be extended, by invoking it, before modifying it. - // - // In essence, always invoke this when exporting a processor. - function freeze() { - var values; - var transformer; + if (hasFlag('color=256')) { + return 2; + } + } - if (frozen) { - return processor - } + if (haveStream && !streamIsTTY && forceColor === undefined) { + return 0; + } - while (++freezeIndex < attachers.length) { - values = attachers[freezeIndex]; + const min = forceColor || 0; - if (values[1] === false) { - continue - } + if (env.TERM === 'dumb') { + return min; + } - if (values[1] === true) { - values[1] = undefined; - } + if (process__default['default'].platform === 'win32') { + // Windows 10 build 10586 is the first Windows release that supports 256 colors. + // Windows 10 build 14931 is the first release that supports 16m/TrueColor. + const osRelease = require$$0__default['default'].release().split('.'); + if ( + Number(osRelease[0]) >= 10 && + Number(osRelease[2]) >= 10586 + ) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } - transformer = values[0].apply(processor, values.slice(1)); + return 1; + } - if (typeof transformer === 'function') { - transformers.use(transformer); - } - } + if ('CI' in env) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') { + return 1; + } - frozen = true; - freezeIndex = Infinity; + return min; + } - return processor - } + if ('TEAMCITY_VERSION' in env) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; + } - // Data management. - // Getter / setter for processor-specific informtion. - function data(key, value) { - if (typeof key === 'string') { - // Set `key`. - if (arguments.length === 2) { - assertUnfrozen('data', frozen); - namespace[key] = value; - return processor - } + if (env.COLORTERM === 'truecolor') { + return 3; + } - // Get `key`. - return (own$b.call(namespace, key) && namespace[key]) || null - } + if ('TERM_PROGRAM' in env) { + const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); - // Set space. - if (key) { - assertUnfrozen('data', frozen); - namespace = key; - return processor - } + switch (env.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Apple_Terminal': + return 2; + // No default + } + } - // Get space. - return namespace - } + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } - // Plugin management. - // - // Pass it: - // * an attacher and options, - // * a preset, - // * a list of presets, attachers, and arguments (list of attachers and - // options). - function use(value) { - var settings; + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } - assertUnfrozen('use', frozen); + if ('COLORTERM' in env) { + return 1; + } - if (value === null || value === undefined) ; else if (typeof value === 'function') { - addPlugin.apply(null, arguments); - } else if (typeof value === 'object') { - if ('length' in value) { - addList(value); - } else { - addPreset(value); - } - } else { - throw new Error('Expected usable value, not `' + value + '`') - } + return min; +} - if (settings) { - namespace.settings = extend$1(namespace.settings || {}, settings); - } +function createSupportsColor(stream, options = {}) { + const level = _supportsColor(stream, { + streamIsTTY: stream && stream.isTTY, + ...options + }); - return processor + return translateLevel(level); +} - function addPreset(result) { - addList(result.plugins); +const supportsColor = { + stdout: createSupportsColor({isTTY: tty__default['default'].isatty(1)}), + stderr: createSupportsColor({isTTY: tty__default['default'].isatty(2)}) +}; - if (result.settings) { - settings = extend$1(settings || {}, result.settings); - } - } +function ansiRegex({onlyFirst = false} = {}) { + const pattern = [ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' + ].join('|'); - function add(value) { - if (typeof value === 'function') { - addPlugin(value); - } else if (typeof value === 'object') { - if ('length' in value) { - addPlugin.apply(null, value); - } else { - addPreset(value); - } - } else { - throw new Error('Expected usable value, not `' + value + '`') - } - } + return new RegExp(pattern, onlyFirst ? undefined : 'g'); +} - function addList(plugins) { - var index = -1; +function stripAnsi(string) { + if (typeof string !== 'string') { + throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``); + } - if (plugins === null || plugins === undefined) ; else if (typeof plugins === 'object' && 'length' in plugins) { - while (++index < plugins.length) { - add(plugins[index]); - } - } else { - throw new Error('Expected a list of plugins, not `' + plugins + '`') - } - } + return string.replace(ansiRegex(), ''); +} - function addPlugin(plugin, value) { - var entry = find(plugin); +/* eslint-disable yoda */ - if (entry) { - if (plain(entry[1]) && plain(value)) { - value = extend$1(true, entry[1], value); - } +function isFullwidthCodePoint(codePoint) { + if (!Number.isInteger(codePoint)) { + return false; + } - entry[1] = value; - } else { - attachers.push(slice$1.call(arguments)); - } - } - } + // Code points are derived from: + // https://unicode.org/Public/UNIDATA/EastAsianWidth.txt + return codePoint >= 0x1100 && ( + codePoint <= 0x115F || // Hangul Jamo + codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET + codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || + // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + (0x3250 <= codePoint && codePoint <= 0x4DBF) || + // CJK Unified Ideographs .. Yi Radicals + (0x4E00 <= codePoint && codePoint <= 0xA4C6) || + // Hangul Jamo Extended-A + (0xA960 <= codePoint && codePoint <= 0xA97C) || + // Hangul Syllables + (0xAC00 <= codePoint && codePoint <= 0xD7A3) || + // CJK Compatibility Ideographs + (0xF900 <= codePoint && codePoint <= 0xFAFF) || + // Vertical Forms + (0xFE10 <= codePoint && codePoint <= 0xFE19) || + // CJK Compatibility Forms .. Small Form Variants + (0xFE30 <= codePoint && codePoint <= 0xFE6B) || + // Halfwidth and Fullwidth Forms + (0xFF01 <= codePoint && codePoint <= 0xFF60) || + (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || + // Kana Supplement + (0x1B000 <= codePoint && codePoint <= 0x1B001) || + // Enclosed Ideographic Supplement + (0x1F200 <= codePoint && codePoint <= 0x1F251) || + // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + (0x20000 <= codePoint && codePoint <= 0x3FFFD) + ); +} - function find(plugin) { - var index = -1; +var emojiRegex = function () { + // https://mths.be/emoji + return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g; +}; - while (++index < attachers.length) { - if (attachers[index][0] === plugin) { - return attachers[index] - } - } - } +function stringWidth(string) { + if (typeof string !== 'string' || string.length === 0) { + return 0; + } - // Parse a file (in string or vfile representation) into a unist node using - // the `Parser` on the processor. - function parse(doc) { - var file = vfile(doc); - var Parser; + string = stripAnsi(string); - freeze(); - Parser = processor.Parser; - assertParser('parse', Parser); + if (string.length === 0) { + return 0; + } - if (newable(Parser, 'parse')) { - return new Parser(String(file), file).parse() - } + string = string.replace(emojiRegex(), ' '); - return Parser(String(file), file) // eslint-disable-line new-cap - } + let width = 0; - // Run transforms on a unist node representation of a file (in string or - // vfile representation), async. - function run(node, file, cb) { - assertNode(node); - freeze(); + for (let index = 0; index < string.length; index++) { + const codePoint = string.codePointAt(index); - if (!cb && typeof file === 'function') { - cb = file; - file = null; - } + // Ignore control characters + if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) { + continue; + } - if (!cb) { - return new Promise(executor) - } + // Ignore combining characters + if (codePoint >= 0x300 && codePoint <= 0x36F) { + continue; + } - executor(null, cb); + // Surrogates + if (codePoint > 0xFFFF) { + index++; + } - function executor(resolve, reject) { - transformers.run(node, vfile(file), done); + width += isFullwidthCodePoint(codePoint) ? 2 : 1; + } - function done(error, tree, file) { - tree = tree || node; - if (error) { - reject(error); - } else if (resolve) { - resolve(tree); - } else { - cb(null, tree, file); - } - } - } - } + return width; +} - // Run transforms on a unist node representation of a file (in string or - // vfile representation), sync. - function runSync(node, file) { - var result; - var complete; +/*! + * repeat-string + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ - run(node, file, done); +/** + * Results cache + */ - assertDone('runSync', 'run', complete); +var res = ''; +var cache; - return result +/** + * Expose `repeat` + */ - function done(error, tree) { - complete = true; - result = tree; - bail(error); - } - } +var repeatString = repeat; - // Stringify a unist node representation of a file (in string or vfile - // representation) into a string using the `Compiler` on the processor. - function stringify(node, doc) { - var file = vfile(doc); - var Compiler; +/** + * Repeat the given `string` the specified `number` + * of times. + * + * **Example:** + * + * ```js + * var repeat = require('repeat-string'); + * repeat('A', 5); + * //=> AAAAA + * ``` + * + * @param {String} `string` The string to repeat + * @param {Number} `number` The number of times to repeat the string + * @return {String} Repeated string + * @api public + */ - freeze(); - Compiler = processor.Compiler; - assertCompiler('stringify', Compiler); - assertNode(node); +function repeat(str, num) { + if (typeof str !== 'string') { + throw new TypeError('expected a string'); + } - if (newable(Compiler, 'compile')) { - return new Compiler(node, file).compile() - } + // cover common, quick use cases + if (num === 1) return str; + if (num === 2) return str + str; - return Compiler(node, file) // eslint-disable-line new-cap + var max = str.length * num; + if (cache !== str || typeof cache === 'undefined') { + cache = str; + res = ''; + } else if (res.length >= max) { + return res.substr(0, max); } - // Parse a file (in string or vfile representation) into a unist node using - // the `Parser` on the processor, then run transforms on that node, and - // compile the resulting node using the `Compiler` on the processor, and - // store that result on the vfile. - function process(doc, cb) { - freeze(); - assertParser('process', processor.Parser); - assertCompiler('process', processor.Compiler); - - if (!cb) { - return new Promise(executor) + while (max > res.length && num > 1) { + if (num & 1) { + res += str; } - executor(null, cb); - - function executor(resolve, reject) { - var file = vfile(doc); - - pipeline.run(processor, {file: file}, done); - - function done(error) { - if (error) { - reject(error); - } else if (resolve) { - resolve(file); - } else { - cb(null, file); - } - } - } + num >>= 1; + str += str; } - // Process the given document (in string or vfile representation), sync. - function processSync(doc) { - var file; - var complete; - - freeze(); - assertParser('processSync', processor.Parser); - assertCompiler('processSync', processor.Compiler); - file = vfile(doc); - - process(file, done); + res += str; + res = res.substr(0, max); + return res; +} - assertDone('processSync', 'process', complete); +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('vfile-message').VFileMessage} VFileMessage + */ - return file +var severities = {true: 2, false: 1, null: 0, undefined: 0}; - function done(error) { - complete = true; - bail(error); - } - } +/** + * @template {VFile} F + * @param {F} file + * @returns {F} + */ +function sort(file) { + file.messages.sort(comparator); + return file } -// Check if `value` is a constructor. -function newable(value, name) { +/** + * @param {VFileMessage} a + * @param {VFileMessage} b + * @returns {number} + */ +function comparator(a, b) { return ( - typeof value === 'function' && - value.prototype && - // A function with keys in its prototype is probably a constructor. - // Classes’ prototype methods are not enumerable, so we check if some value - // exists in the prototype. - (keys(value.prototype) || name in value.prototype) + check$1(a, b, 'line') || + check$1(a, b, 'column') || + severities[b.fatal] - severities[a.fatal] || + compare(a, b, 'source') || + compare(a, b, 'ruleId') || + compare(a, b, 'reason') || + 0 ) } -// Check if `value` is an object with keys. -function keys(value) { - var key; - for (key in value) { - return true - } - - return false +/** + * @param {VFileMessage} a + * @param {VFileMessage} b + * @param {string} property + * @returns {number} + */ +function check$1(a, b, property) { + return (a[property] || 0) - (b[property] || 0) } -// Assert a parser is available. -function assertParser(name, Parser) { - if (typeof Parser !== 'function') { - throw new Error('Cannot `' + name + '` without `Parser`') - } +/** + * @param {VFileMessage} a + * @param {VFileMessage} b + * @param {string} property + * @returns {number} + */ +function compare(a, b, property) { + return String(a[property] || '').localeCompare(b[property] || '') } -// Assert a compiler is available. -function assertCompiler(name, Compiler) { - if (typeof Compiler !== 'function') { - throw new Error('Cannot `' + name + '` without `Compiler`') - } -} +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('vfile-message').VFileMessage} VFileMessage + * @typedef {import('vfile-statistics').Statistics} Statistics + * + * @typedef Options + * @property {boolean} [color] + * @property {boolean} [silent=false] + * @property {boolean} [quiet=false] + * @property {boolean} [verbose=false] + * @property {string} [defaultName=''] + * + * @typedef _Row + * @property {string} place + * @property {string} label + * @property {string} reason + * @property {string} ruleId + * @property {string} source + * + * @typedef _FileRow + * @property {'file'} type + * @property {VFile} file + * @property {Statistics} stats + * + * @typedef {{[x: string]: number}} _Sizes + * + * @typedef _Info + * @property {Array.<_FileRow|_Row>} rows + * @property {Statistics} stats + * @property {_Sizes} sizes + */ -// Assert the processor is not frozen. -function assertUnfrozen(name, frozen) { - if (frozen) { - throw new Error( - 'Cannot invoke `' + - name + - '` on a frozen processor.\nCreate a new processor first, by invoking it: use `processor()` instead of `processor`.' - ) - } -} +var own$8 = {}.hasOwnProperty; -// Assert `node` is a unist node. -function assertNode(node) { - if (!node || typeof node.type !== 'string') { - throw new Error('Expected node, got `' + node + '`') - } -} - -// Assert that `complete` is `true`. -function assertDone(name, asyncName, complete) { - if (!complete) { - throw new Error( - '`' + name + '` finished async. Use `' + asyncName + '` instead' - ) - } -} +// @ts-ignore Types are incorrect. +var supported = supportsColor.stderr.hasBasic; -var mdastUtilToString$1 = toString$5; +// `log-symbols` without chalk, ignored for Windows: +/* c8 ignore next 4 */ +var chars = + process.platform === 'win32' + ? {error: '×', warning: '‼'} + : {error: '✖', warning: '⚠'}; -// Get the text content of a node. -// Prefer the node’s plain-text fields, otherwise serialize its children, -// and if the given value is an array, serialize the nodes in it. -function toString$5(node) { - return ( - (node && - (node.value || - node.alt || - node.title || - ('children' in node && all$2(node.children)) || - ('length' in node && all$2(node)))) || - '' - ) -} +var labels = {true: 'error', false: 'warning', null: 'info', undefined: 'info'}; -function all$2(values) { - var result = []; - var index = -1; +/** + * Report a file’s messages. + * + * @param {Error|VFile|Array.} [files] + * @param {Options} [options] + * @returns {string} + */ +function reporter$1(files, options = {}) { + /** @type {boolean} */ + var one; - while (++index < values.length) { - result[index] = toString$5(values[index]); + if (!files) { + return '' } - return result.join('') -} - -var assign$5 = Object.assign; + // Error. + if ('name' in files && 'message' in files) { + return String(files.stack || files) + } -var assign_1 = assign$5; + // One file. + if (!Array.isArray(files)) { + one = true; + files = [files]; + } -var own$a = {}.hasOwnProperty; + return format(transform(files, options), one, options) +} -var hasOwnProperty$2 = own$a; +/** + * @param {Array.} files + * @param {Options} options + * @returns {_Info} + */ +function transform(files, options) { + var index = -1; + /** @type {Array.<_FileRow|_Row>} */ + var rows = []; + /** @type {Array.} */ + var all = []; + /** @type {number} */ + var offset; + /** @type {_Sizes} */ + var sizes = {}; + /** @type {Array.} */ + var messages; + /** @type {VFileMessage} */ + var message; + /** @type {_Row} */ + var row; + /** @type {Array.<_Row>} */ + var messageRows; + /** @type {string} */ + var key; -function normalizeIdentifier$4(value) { - return ( - value // Collapse Markdown whitespace. - .replace(/[\t\n\r ]+/g, ' ') // Trim. - .replace(/^ | $/g, '') // Some characters are considered “uppercase”, but if their lowercase - // counterpart is uppercased will result in a different uppercase - // character. - // Hence, to get that form, we perform both lower- and uppercase. - // Upper case makes sure keys will not interact with default prototypal - // methods: no object method is uppercase. - .toLowerCase() - .toUpperCase() - ) -} + while (++index < files.length) { + // @ts-ignore it works fine. + messages = sort({messages: [...files[index].messages]}).messages; + messageRows = []; + offset = -1; -var normalizeIdentifier_1 = normalizeIdentifier$4; + while (++offset < messages.length) { + message = messages[offset]; -var fromCharCode$4 = String.fromCharCode; + if (!options.silent || message.fatal) { + all.push(message); -var fromCharCode_1 = fromCharCode$4; + row = { + place: stringifyPosition$1( + message.position.end.line && message.position.end.column + ? message.position + : message.position.start + ), + label: labels[message.fatal], + reason: + (message.stack || message.message) + + (options.verbose && message.note ? '\n' + message.note : ''), + ruleId: message.ruleId || '', + source: message.source || '' + }; -var fromCharCode$3 = fromCharCode_1; + for (key in row) { + if (own$8.call(row, key)) { + sizes[key] = Math.max(size$1(row[key]), sizes[key] || 0); + } + } -function safeFromInt$1(value, base) { - var code = parseInt(value, base); + messageRows.push(row); + } + } - if ( - // C0 except for HT, LF, FF, CR, space - code < 9 || - code === 11 || - (code > 13 && code < 32) || // Control character (DEL) of the basic block and C1 controls. - (code > 126 && code < 160) || // Lone high surrogates and low surrogates. - (code > 55295 && code < 57344) || // Noncharacters. - (code > 64975 && code < 65008) || - (code & 65535) === 65535 || - (code & 65535) === 65534 || // Out of range - code > 1114111 - ) { - return '\uFFFD' + if ((!options.quiet && !options.silent) || messageRows.length > 0) { + rows.push( + {type: 'file', file: files[index], stats: statistics(messages)}, + ...messageRows + ); + } } - return fromCharCode$3(code) + return {rows, stats: statistics(all), sizes} } -var safeFromInt_1 = safeFromInt$1; - -var content$3 = {}; - -function markdownLineEnding$k(code) { - return code < -2 -} +/** + * @param {_Info} map + * @param {boolean} one + * @param {Options} options + */ +function format(map, one, options) { + /** @type {boolean} */ + var enabled = + options.color === undefined || options.color === null + ? supported + : options.color; + /** @type {Array.} */ + var lines = []; + var index = -1; + /** @type {Statistics} */ + var stats; + /** @type {_FileRow|_Row} */ + var row; + /** @type {string} */ + var line; + /** @type {string} */ + var reason; + /** @type {string} */ + var rest; + /** @type {RegExpMatchArray} */ + var match; -var markdownLineEnding_1 = markdownLineEnding$k; + while (++index < map.rows.length) { + row = map.rows[index]; -function markdownSpace$a(code) { - return code === -2 || code === -1 || code === 32 -} + if ('type' in row) { + stats = row.stats; + line = row.file.history[0] || options.defaultName || ''; -var markdownSpace_1 = markdownSpace$a; + line = + one && !options.defaultName && !row.file.history[0] + ? '' + : (enabled + ? '\u001B[4m' /* Underline. */ + + (stats.fatal + ? '\u001B[31m' /* Red. */ + : stats.total + ? '\u001B[33m' /* Yellow. */ + : '\u001B[32m') /* Green. */ + + line + + '\u001B[39m\u001B[24m' + : line) + + (row.file.stored && row.file.path !== row.file.history[0] + ? ' > ' + row.file.path + : ''); -var markdownSpace$9 = markdownSpace_1; + if (!stats.total) { + line = + (line ? line + ': ' : '') + + (row.file.stored + ? enabled + ? '\u001B[33mwritten\u001B[39m' /* Yellow. */ + : 'written' + : 'no issues found'); + } -function spaceFactory(effects, ok, type, max) { - var limit = max ? max - 1 : Infinity; - var size = 0; - return start + if (line) { + if (index && !('type' in map.rows[index - 1])) { + lines.push(''); + } - function start(code) { - if (markdownSpace$9(code)) { - effects.enter(type); - return prefix(code) - } + lines.push(line); + } + } else { + reason = row.reason; + match = /\r?\n|\r/.exec(reason); - return ok(code) - } + if (match) { + rest = reason.slice(match.index); + reason = reason.slice(0, match.index); + } else { + rest = ''; + } - function prefix(code) { - if (markdownSpace$9(code) && size++ < limit) { - effects.consume(code); - return prefix + lines.push( + ( + ' ' + + repeatString(' ', map.sizes.place - size$1(row.place)) + + row.place + + ' ' + + (enabled + ? (row.label === 'error' + ? '\u001B[31m' /* Red. */ + : '\u001B[33m') /* Yellow. */ + + row.label + + '\u001B[39m' + : row.label) + + repeatString(' ', map.sizes.label - size$1(row.label)) + + ' ' + + reason + + repeatString(' ', map.sizes.reason - size$1(reason)) + + ' ' + + row.ruleId + + repeatString(' ', map.sizes.ruleId - size$1(row.ruleId)) + + ' ' + + (row.source || '') + ).replace(/ +$/, '') + rest + ); } - - effects.exit(type); - return ok(code) } -} - -var factorySpace$i = spaceFactory; - -Object.defineProperty(content$3, '__esModule', {value: true}); -var markdownLineEnding$j = markdownLineEnding_1; -var factorySpace$h = factorySpace$i; - -var tokenize$2 = initializeContent; + stats = map.stats; -function initializeContent(effects) { - var contentStart = effects.attempt( - this.parser.constructs.contentInitial, - afterContentStartConstruct, - paragraphInitial - ); - var previous; - return contentStart + if (stats.fatal || stats.warn) { + line = ''; - function afterContentStartConstruct(code) { - if (code === null) { - effects.consume(code); - return + if (stats.fatal) { + line = + (enabled + ? '\u001B[31m' /* Red. */ + chars.error + '\u001B[39m' + : chars.error) + + ' ' + + stats.fatal + + ' ' + + (labels.true + (stats.fatal === 1 ? '' : 's')); } - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return factorySpace$h(effects, contentStart, 'linePrefix') - } - - function paragraphInitial(code) { - effects.enter('paragraph'); - return lineStart(code) - } - - function lineStart(code) { - var token = effects.enter('chunkText', { - contentType: 'text', - previous: previous - }); - - if (previous) { - previous.next = token; + if (stats.warn) { + line = + (line ? line + ', ' : '') + + (enabled + ? '\u001B[33m' /* Yellow. */ + chars.warning + '\u001B[39m' + : chars.warning) + + ' ' + + stats.warn + + ' ' + + (labels.false + (stats.warn === 1 ? '' : 's')); } - previous = token; - return data(code) - } - - function data(code) { - if (code === null) { - effects.exit('chunkText'); - effects.exit('paragraph'); - effects.consume(code); - return + if (stats.total !== stats.fatal && stats.total !== stats.warn) { + line = stats.total + ' messages (' + line + ')'; } - if (markdownLineEnding$j(code)) { - effects.consume(code); - effects.exit('chunkText'); - return lineStart - } // Data. - - effects.consume(code); - return data + lines.push('', line); } -} - -content$3.tokenize = tokenize$2; -var document$3 = {}; - -var markdownLineEnding$i = markdownLineEnding_1; -var factorySpace$g = factorySpace$i; - -var partialBlankLine$4 = { - tokenize: tokenizePartialBlankLine, - partial: true -}; - -function tokenizePartialBlankLine(effects, ok, nok) { - return factorySpace$g(effects, afterWhitespace, 'linePrefix') - - function afterWhitespace(code) { - return code === null || markdownLineEnding$i(code) ? ok(code) : nok(code) - } + return lines.join('\n') } -var partialBlankLine_1 = partialBlankLine$4; - -Object.defineProperty(document$3, '__esModule', {value: true}); +/** + * Get the length of `value`, ignoring ANSI sequences. + * + * @param {string} value + * @returns {number} + */ +function size$1(value) { + var match = /\r?\n|\r/.exec(value); + return stringWidth(match ? value.slice(0, match.index) : value) +} -var markdownLineEnding$h = markdownLineEnding_1; -var factorySpace$f = factorySpace$i; -var partialBlankLine$3 = partialBlankLine_1; +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('../index.js').VFileReporter} VFileReporter + * @typedef {import('./index.js').Settings} Settings + * @typedef {import('./index.js').Configuration} Configuration + */ -var tokenize$1 = initializeDocument; -var containerConstruct = { - tokenize: tokenizeContainer -}; -var lazyFlowConstruct = { - tokenize: tokenizeLazyFlow -}; +/** + * @typedef Context + * @property {Array.} files + * @property {Configuration} [configuration] + */ -function initializeDocument(effects) { - var self = this; - var stack = []; - var continued = 0; - var inspectConstruct = { - tokenize: tokenizeInspect, - partial: true - }; - var inspectResult; - var childFlow; - var childToken; - return start +/** + * @param {Context} context + * @param {Settings} settings + */ +async function log(context, settings) { + /** @type {VFileReporter} */ + let func = reporter$1; - function start(code) { - if (continued < stack.length) { - self.containerState = stack[continued][1]; - return effects.attempt( - stack[continued][0].continuation, - documentContinue, - documentContinued - )(code) + if (typeof settings.reporter === 'string') { + try { + // @ts-expect-error: Assume loaded value is a vfile reporter. + func = await loadPlugin(settings.reporter, { + cwd: settings.cwd, + prefix: 'vfile-reporter' + }); + } catch { + throw new Error('Could not find reporter `' + settings.reporter + '`') } - - return documentContinued(code) + } else if (settings.reporter) { + func = settings.reporter; } - function documentContinue(code) { - continued++; - return start(code) - } + let diagnostics = func( + context.files.filter((file) => file.data.unifiedEngineGiven), + Object.assign({}, settings.reporterOptions, { + quiet: settings.quiet, + silent: settings.silent, + color: settings.color + }) + ); - function documentContinued(code) { - // If we’re in a concrete construct (such as when expecting another line of - // HTML, or we resulted in lazy content), we can immediately start flow. - if (inspectResult && inspectResult.flowContinue) { - return flowStart(code) + if (diagnostics) { + if (diagnostics.charAt(diagnostics.length - 1) !== '\n') { + diagnostics += '\n'; } - self.interrupt = - childFlow && - childFlow.currentConstruct && - childFlow.currentConstruct.interruptible; - self.containerState = {}; - return effects.attempt( - containerConstruct, - containerContinue, - flowStart - )(code) - } - - function containerContinue(code) { - stack.push([self.currentConstruct, self.containerState]); - self.containerState = undefined; - return documentContinued(code) + return new Promise((resolve) => { + settings.streamError.write(diagnostics, resolve); + }) } +} - function flowStart(code) { - if (code === null) { - exitContainers(0, true); - effects.consume(code); - return - } - - childFlow = childFlow || self.parser.flow(self.now()); - effects.enter('chunkFlow', { - contentType: 'flow', - previous: childToken, - _tokenizer: childFlow - }); - return flowContinue(code) - } +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('../configuration.js').Configuration} Configuration + * @typedef {import('../index.js').Settings} Settings + */ - function flowContinue(code) { - if (code === null) { - continueFlow(effects.exit('chunkFlow')); - return flowStart(code) - } +const fileSetPipeline = trough() + .use(configure$3) + .use(fileSystem$1) + .use(stdin) + .use(transform$1) + .use(log); - if (markdownLineEnding$h(code)) { - effects.consume(code); - continueFlow(effects.exit('chunkFlow')); - return effects.check(inspectConstruct, documentAfterPeek) - } +/** + * @typedef {import('vfile').VFile} VFile + * @typedef {import('unified').Processor} Processor + * @typedef {import('./file-set.js').FileSet} FileSet + * @typedef {import('./file-set.js').Completer} Completer + * @typedef {import('./ignore.js').ResolveFrom} ResolveFrom + * @typedef {import('./configuration.js').ConfigTransform} ConfigTransform + * @typedef {import('./configuration.js').Preset} Preset + * + * @typedef VFileReporterFields + * @property {boolean} [color] + * @property {boolean} [quiet] + * @property {boolean} [silent] + * + * @typedef {{[key: string]: unknown} & VFileReporterFields} VFileReporterOptions + * + * @callback VFileReporter + * @param {VFile[]} files + * @param {VFileReporterOptions} options + * @returns {string} + * + * @typedef Settings + * @property {Options['processor']} processor + * @property {Exclude} cwd + * @property {Exclude} files + * @property {Exclude} extensions + * @property {Exclude} streamIn + * @property {Options['filePath']} filePath + * @property {Exclude} streamOut + * @property {Exclude} streamError + * @property {Options['out']} out + * @property {Options['output']} output + * @property {Options['alwaysStringify']} alwaysStringify + * @property {Options['tree']} tree + * @property {Options['treeIn']} treeIn + * @property {Options['treeOut']} treeOut + * @property {Options['inspect']} inspect + * @property {Options['rcName']} rcName + * @property {Options['packageField']} packageField + * @property {Options['detectConfig']} detectConfig + * @property {Options['rcPath']} rcPath + * @property {Exclude} settings + * @property {Options['ignoreName']} ignoreName + * @property {Options['detectIgnore']} detectIgnore + * @property {Options['ignorePath']} ignorePath + * @property {Options['ignorePathResolveFrom']} ignorePathResolveFrom + * @property {Exclude} ignorePatterns + * @property {Options['silentlyIgnore']} silentlyIgnore + * @property {Options['plugins']} plugins + * @property {Options['pluginPrefix']} pluginPrefix + * @property {Options['configTransform']} configTransform + * @property {Options['defaultConfig']} defaultConfig + * @property {Options['reporter']} reporter + * @property {Options['reporterOptions']} reporterOptions + * @property {Options['color']} color + * @property {Options['silent']} silent + * @property {Options['quiet']} quiet + * @property {Options['frail']} frail + * + * @typedef Options + * Options for unified engine + * @property {() => Processor} processor + * Unified processor to transform files + * @property {string} [cwd] + * Directory to search files in, load plugins from, and more. + * Defaults to `process.cwd()`. + * @property {Array} [files] + * Paths or globs to files and directories, or virtual files, to process. + * @property {string[]} [extensions] + * If `files` matches directories, include `files` with `extensions` + * @property {NodeJS.ReadableStream} [streamIn] + * Stream to read from if no files are found or given. + * Defaults to `process.stdin`. + * @property {string} [filePath] + * File path to process the given file on `streamIn` as. + * @property {NodeJS.WritableStream} [streamOut] + * Stream to write processed files to. + * Defaults to `process.stdout`. + * @property {NodeJS.WritableStream} [streamError] + * Stream to write the report (if any) to. + * Defaults to `process.stderr`. + * @property {boolean} [out=false] + * Whether to write the processed file to `streamOut` + * @property {boolean|string} [output=false] + * Whether to write successfully processed files, and where to. + * + * * When `true`, overwrites the given files + * * When `false`, does not write to the file system + * * When pointing to an existing directory, files are written to that + * directory and keep their original basenames + * * When the parent directory of the given path exists and one file is + * processed, the file is written to the given path + * @property {boolean} [alwaysStringify=false] + * Whether to always serialize successfully processed files. + * @property {boolean} [tree=false] + * Whether to treat both input and output as a syntax tree. + * @property {boolean} [treeIn] + * Whether to treat input as a syntax tree. + * Defaults to `options.tree`. + * @property {boolean} [treeOut] + * Whether to treat output as a syntax tree. + * Defaults to `options.tree`. + * @property {boolean} [inspect=false] + * Whether to output a formatted syntax tree. + * @property {string} [rcName] + * Name of configuration files to load. + * @property {string} [packageField] + * Property at which configuration can be found in `package.json` files + * @property {boolean} [detectConfig] + * Whether to search for configuration files. + * Defaults to `true` if `rcName` or `packageField` are given + * @property {string} [rcPath] + * Filepath to a configuration file to load. + * @property {Preset['settings']} [settings] + * Configuration for the parser and compiler of the processor. + * @property {string} [ignoreName] + * Name of ignore files to load. + * @property {boolean} [detectIgnore] + * Whether to search for ignore files. + * Defaults to `true` if `ignoreName` is given. + * @property {string} [ignorePath] + * Filepath to an ignore file to load. + * @property {ResolveFrom} [ignorePathResolveFrom] + * Resolve patterns in `ignorePath` from the current working + * directory (`'cwd'`) or the ignore file’s directory (`'dir'`, default). + * @property {string[]} [ignorePatterns] + * Patterns to ignore in addition to ignore files + * @property {boolean} [silentlyIgnore=false] + * Skip given files if they are ignored. + * @property {Preset['plugins']} [plugins] + * Plugins to use. + * @property {string} [pluginPrefix] + * Prefix to use when searching for plugins + * @property {ConfigTransform} [configTransform] + * Transform config files from a different schema. + * @property {Preset} [defaultConfig] + * Default configuration to use if no config file is given or found. + * @property {VFileReporter|string} [reporter] + * Reporter to use + * Defaults to `vfile-reporter` + * @property {VFileReporterOptions} [reporterOptions] + * Config to pass to the used reporter. + * @property {VFileReporterOptions['color']} [color=false] + * Whether to report with ANSI color sequences. + * @property {VFileReporterOptions['silent']} [silent=false] + * Report only fatal errors + * @property {VFileReporterOptions['quiet']} [quiet=false] + * Do not report successful files + * @property {boolean} [frail=false] + * Call back with an unsuccessful (`1`) code on warnings as well as errors + * + * @typedef Context + * Processing context. + * @property {VFile[]} [files] + * Processed files. + * @property {FileSet} [fileSet] + * Internally used information + * + * @callback Callback + * Callback called when processing according to options is complete. + * Invoked with either a fatal error if processing went horribly wrong + * (probably due to incorrect configuration), or a status code and the + * processing context. + * @param {Error|null} error + * @param {0|1} [status] + * @param {Context} [context] + * @returns {void} + */ - effects.consume(code); - return flowContinue - } +/** + * Run the file set pipeline once. + * `callback` is called with a fatal error, or with a status code (`0` on + * success, `1` on failure). + * + * @param {Options} options + * @param {Callback} callback + */ +function engine(options, callback) { + /** @type {Settings} */ + const settings = {}; + /** @type {NodeJS.ReadStream} */ + // @ts-expect-error: `PassThrough` sure is readable. + let stdin = new stream.PassThrough(); - function documentAfterPeek(code) { - exitContainers( - inspectResult.continued, - inspectResult && inspectResult.flowEnd - ); - continued = 0; - return start(code) - } + try { + stdin = process__default$1['default'].stdin; + // Obscure bug in Node (seen on Windows). + // See: , + // . + /* c8 ignore next 1 */ + } catch {} - function continueFlow(token) { - if (childToken) childToken.next = token; - childToken = token; - childFlow.lazy = inspectResult && inspectResult.lazy; - childFlow.defineSkip(token.start); - childFlow.write(self.sliceStream(token)); + if (!callback) { + throw new Error('Missing `callback`') } - function exitContainers(size, end) { - var index = stack.length; // Close the flow. - - if (childFlow && end) { - childFlow.write([null]); - childToken = childFlow = undefined; - } // Exit open containers. - - while (index-- > size) { - self.containerState = stack[index][1]; - stack[index][0].exit.call(self, effects); - } - - stack.length = size; + // Needed `any`s + // type-coverage:ignore-next-line + if (!options || !options.processor) { + return next(new Error('Missing `processor`')) } - function tokenizeInspect(effects, ok) { - var subcontinued = 0; - inspectResult = {}; - return inspectStart - - function inspectStart(code) { - if (subcontinued < stack.length) { - self.containerState = stack[subcontinued][1]; - return effects.attempt( - stack[subcontinued][0].continuation, - inspectContinue, - inspectLess - )(code) - } // If we’re continued but in a concrete flow, we can’t have more - // containers. - - if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) { - inspectResult.flowContinue = true; - return inspectDone(code) - } - - self.interrupt = - childFlow.currentConstruct && childFlow.currentConstruct.interruptible; - self.containerState = {}; - return effects.attempt( - containerConstruct, - inspectFlowEnd, - inspectDone - )(code) - } - - function inspectContinue(code) { - subcontinued++; - return self.containerState._closeFlow - ? inspectFlowEnd(code) - : inspectStart(code) - } + // Processor. + // Needed `any`s + // type-coverage:ignore-next-line + settings.processor = options.processor; - function inspectLess(code) { - if (childFlow.currentConstruct && childFlow.currentConstruct.lazy) { - // Maybe another container? - self.containerState = {}; - return effects.attempt( - containerConstruct, - inspectFlowEnd, // Maybe flow, or a blank line? - effects.attempt( - lazyFlowConstruct, - inspectFlowEnd, - effects.check(partialBlankLine$3, inspectFlowEnd, inspectLazy) - ) - )(code) - } // Otherwise we’re interrupting. + // Path to run as. + settings.cwd = options.cwd || process__default$1['default'].cwd(); - return inspectFlowEnd(code) - } + // Input. + settings.files = options.files || []; + settings.extensions = (options.extensions || []).map((ext) => + ext.charAt(0) === '.' ? ext : '.' + ext + ); - function inspectLazy(code) { - // Act as if all containers are continued. - subcontinued = stack.length; - inspectResult.lazy = true; - inspectResult.flowContinue = true; - return inspectDone(code) - } // We’re done with flow if we have more containers, or an interruption. + settings.filePath = options.filePath; + settings.streamIn = options.streamIn || stdin; - function inspectFlowEnd(code) { - inspectResult.flowEnd = true; - return inspectDone(code) - } + // Output. + settings.streamOut = options.streamOut || process__default$1['default'].stdout; + settings.streamError = options.streamError || process__default$1['default'].stderr; + settings.alwaysStringify = options.alwaysStringify; + settings.output = options.output; + settings.out = options.out; - function inspectDone(code) { - inspectResult.continued = subcontinued; - self.interrupt = self.containerState = undefined; - return ok(code) - } + // Null overwrites config settings, `undefined` does not. + if (settings.output === null || settings.output === undefined) { + settings.output = undefined; } -} - -function tokenizeContainer(effects, ok, nok) { - return factorySpace$f( - effects, - effects.attempt(this.parser.constructs.document, ok, nok), - 'linePrefix', - this.parser.constructs.disable.null.indexOf('codeIndented') > -1 - ? undefined - : 4 - ) -} - -function tokenizeLazyFlow(effects, ok, nok) { - return factorySpace$f( - effects, - effects.lazy(this.parser.constructs.flow, ok, nok), - 'linePrefix', - this.parser.constructs.disable.null.indexOf('codeIndented') > -1 - ? undefined - : 4 - ) -} -document$3.tokenize = tokenize$1; - -var flow$7 = {}; + if (settings.output && settings.out) { + return next(new Error('Cannot accept both `output` and `out`')) + } -// Counts tabs based on their expanded size, and CR+LF as one character. + // Process phase management. + const tree = options.tree || false; -function sizeChunks$2(chunks) { - var index = -1; - var size = 0; + settings.treeIn = options.treeIn; + settings.treeOut = options.treeOut; + settings.inspect = options.inspect; - while (++index < chunks.length) { - size += typeof chunks[index] === 'string' ? chunks[index].length : 1; + if (settings.treeIn === null || settings.treeIn === undefined) { + settings.treeIn = tree; } - return size -} - -var sizeChunks_1 = sizeChunks$2; - -var sizeChunks$1 = sizeChunks_1; + if (settings.treeOut === null || settings.treeOut === undefined) { + settings.treeOut = tree; + } -function prefixSize$4(events, type) { - var tail = events[events.length - 1]; - if (!tail || tail[1].type !== type) return 0 - return sizeChunks$1(tail[2].sliceStream(tail[1])) -} + // Configuration. + const detectConfig = options.detectConfig; + const hasConfig = Boolean(options.rcName || options.packageField); -var prefixSize_1 = prefixSize$4; + if (detectConfig && !hasConfig) { + return next( + new Error('Missing `rcName` or `packageField` with `detectConfig`') + ) + } -var splice$2 = [].splice; + settings.detectConfig = + detectConfig === null || detectConfig === undefined + ? hasConfig + : detectConfig; + settings.rcName = options.rcName; + settings.rcPath = options.rcPath; + settings.packageField = options.packageField; + settings.settings = options.settings || {}; + settings.configTransform = options.configTransform; + settings.defaultConfig = options.defaultConfig; -var splice_1 = splice$2; + // Ignore. + const detectIgnore = options.detectIgnore; + const hasIgnore = Boolean(options.ignoreName); -var splice$1 = splice_1; + settings.detectIgnore = + detectIgnore === null || detectIgnore === undefined + ? hasIgnore + : detectIgnore; + settings.ignoreName = options.ignoreName; + settings.ignorePath = options.ignorePath; + settings.ignorePathResolveFrom = options.ignorePathResolveFrom || 'dir'; + settings.ignorePatterns = options.ignorePatterns || []; + settings.silentlyIgnore = Boolean(options.silentlyIgnore); -// causes a stack overflow in V8 when trying to insert 100k items for instance. + if (detectIgnore && !hasIgnore) { + return next(new Error('Missing `ignoreName` with `detectIgnore`')) + } -function chunkedSplice$8(list, start, remove, items) { - var end = list.length; - var chunkStart = 0; - var parameters; // Make start between zero and `end` (included). + // Plugins. + settings.pluginPrefix = options.pluginPrefix; + settings.plugins = options.plugins || []; - if (start < 0) { - start = -start > end ? 0 : end + start; - } else { - start = start > end ? end : start; - } + // Reporting. + settings.reporter = options.reporter; + settings.reporterOptions = options.reporterOptions; + settings.color = options.color || false; + settings.silent = options.silent; + settings.quiet = options.quiet; + settings.frail = options.frail; - remove = remove > 0 ? remove : 0; // No need to chunk the items if there’s only a couple (10k) items. + // Process. + fileSetPipeline.run({files: options.files || []}, settings, next); - if (items.length < 10000) { - parameters = Array.from(items); - parameters.unshift(start, remove); - splice$1.apply(list, parameters); - } else { - // Delete `remove` items starting from `start` - if (remove) splice$1.apply(list, [start, remove]); // Insert the items in chunks to not cause stack overflows. + /** + * @param {Error|null} error + * @param {Context} [context] + */ + function next(error, context) { + const stats = statistics((context || {}).files); + const failed = Boolean( + settings.frail ? stats.fatal || stats.warn : stats.fatal + ); - while (chunkStart < items.length) { - parameters = items.slice(chunkStart, chunkStart + 10000); - parameters.unshift(start, 0); - splice$1.apply(list, parameters); - chunkStart += 10000; - start += 10000; + if (error) { + callback(error); + } else { + callback(null, failed ? 1 : 0, context); } } } -var chunkedSplice_1 = chunkedSplice$8; - -var assign$4 = assign_1; - -function shallow$6(object) { - return assign$4({}, object) -} - -var shallow_1 = shallow$6; - -var assign$3 = assign_1; -var chunkedSplice$7 = chunkedSplice_1; -var shallow$5 = shallow_1; - -function subtokenize$2(events) { - var jumps = {}; - var index = -1; - var event; - var lineIndex; - var otherIndex; - var otherEvent; - var parameters; - var subevents; - var more; - - while (++index < events.length) { - while (index in jumps) { - index = jumps[index]; - } - - event = events[index]; // Add a hook for the GFM tasklist extension, which needs to know if text - // is in the first content of a list item. - - if ( - index && - event[1].type === 'chunkFlow' && - events[index - 1][1].type === 'listItemPrefix' - ) { - subevents = event[1]._tokenizer.events; - otherIndex = 0; - - if ( - otherIndex < subevents.length && - subevents[otherIndex][1].type === 'lineEndingBlank' - ) { - otherIndex += 2; - } - - if ( - otherIndex < subevents.length && - subevents[otherIndex][1].type === 'content' - ) { - while (++otherIndex < subevents.length) { - if (subevents[otherIndex][1].type === 'content') { - break - } - - if (subevents[otherIndex][1].type === 'chunkText') { - subevents[otherIndex][1].isInFirstContentOfListItem = true; - otherIndex++; - } - } - } - } // Enter. - - if (event[0] === 'enter') { - if (event[1].contentType) { - assign$3(jumps, subcontent(events, index)); - index = jumps[index]; - more = true; - } - } // Exit. - else if (event[1]._container || event[1]._movePreviousLineEndings) { - otherIndex = index; - lineIndex = undefined; - - while (otherIndex--) { - otherEvent = events[otherIndex]; - - if ( - otherEvent[1].type === 'lineEnding' || - otherEvent[1].type === 'lineEndingBlank' - ) { - if (otherEvent[0] === 'enter') { - if (lineIndex) { - events[lineIndex][1].type = 'lineEndingBlank'; +var textTable = function (rows_, opts) { + if (!opts) opts = {}; + var hsep = opts.hsep === undefined ? ' ' : opts.hsep; + var align = opts.align || []; + var stringLength = opts.stringLength + || function (s) { return String(s).length; } + ; + + var dotsizes = reduce(rows_, function (acc, row) { + forEach(row, function (c, ix) { + var n = dotindex(c); + if (!acc[ix] || n > acc[ix]) acc[ix] = n; + }); + return acc; + }, []); + + var rows = map$2(rows_, function (row) { + return map$2(row, function (c_, ix) { + var c = String(c_); + if (align[ix] === '.') { + var index = dotindex(c); + var size = dotsizes[ix] + (/\./.test(c) ? 1 : 2) + - (stringLength(c) - index) + ; + return c + Array(size).join(' '); } + else return c; + }); + }); + + var sizes = reduce(rows, function (acc, row) { + forEach(row, function (c, ix) { + var n = stringLength(c); + if (!acc[ix] || n > acc[ix]) acc[ix] = n; + }); + return acc; + }, []); + + return map$2(rows, function (row) { + return map$2(row, function (c, ix) { + var n = (sizes[ix] - stringLength(c)) || 0; + var s = Array(Math.max(n + 1, 1)).join(' '); + if (align[ix] === 'r' || align[ix] === '.') { + return s + c; + } + if (align[ix] === 'c') { + return Array(Math.ceil(n / 2 + 1)).join(' ') + + c + Array(Math.floor(n / 2 + 1)).join(' ') + ; + } + + return c + s; + }).join(hsep).replace(/\s+$/, ''); + }).join('\n'); +}; - otherEvent[1].type = 'lineEnding'; - lineIndex = otherIndex; - } - } else { - break - } - } - - if (lineIndex) { - // Fix position. - event[1].end = shallow$5(events[lineIndex][1].start); // Switch container exit w/ line endings. +function dotindex (c) { + var m = /\.[^.]*$/.exec(c); + return m ? m.index + 1 : c.length; +} - parameters = events.slice(lineIndex, index); - parameters.unshift(event); - chunkedSplice$7(events, lineIndex, index - lineIndex + 1, parameters); - } +function reduce (xs, f, init) { + if (xs.reduce) return xs.reduce(f, init); + var i = 0; + var acc = arguments.length >= 3 ? init : xs[i++]; + for (; i < xs.length; i++) { + f(acc, xs[i], i); } - } - - return !more + return acc; } -function subcontent(events, eventIndex) { - var token = events[eventIndex][1]; - var context = events[eventIndex][2]; - var startPosition = eventIndex - 1; - var startPositions = []; - var tokenizer = - token._tokenizer || context.parser[token.contentType](token.start); - var childEvents = tokenizer.events; - var jumps = []; - var gaps = {}; - var stream; - var previous; - var index; - var entered; - var end; - var adjust; // Loop forward through the linked tokens to pass them in order to the - // subtokenizer. - - while (token) { - // Find the position of the event for this token. - while (events[++startPosition][1] !== token) { - // Empty. +function forEach (xs, f) { + if (xs.forEach) return xs.forEach(f); + for (var i = 0; i < xs.length; i++) { + f.call(xs, xs[i], i); } +} - startPositions.push(startPosition); - - if (!token._tokenizer) { - stream = context.sliceStream(token); - - if (!token.next) { - stream.push(null); - } - - if (previous) { - tokenizer.defineSkip(token.start); - } - - if (token.isInFirstContentOfListItem) { - tokenizer._gfmTasklistFirstContentOfListItem = true; - } - - tokenizer.write(stream); - - if (token.isInFirstContentOfListItem) { - tokenizer._gfmTasklistFirstContentOfListItem = undefined; - } - } // Unravel the next token. - - previous = token; - token = token.next; - } // Now, loop back through all events (and linked tokens), to figure out which - // parts belong where. - - token = previous; - index = childEvents.length; - - while (index--) { - // Make sure we’ve at least seen something (final eol is part of the last - // token). - if (childEvents[index][0] === 'enter') { - entered = true; - } else if ( - // Find a void token that includes a break. - entered && - childEvents[index][1].type === childEvents[index - 1][1].type && - childEvents[index][1].start.line !== childEvents[index][1].end.line - ) { - add(childEvents.slice(index + 1, end)); - // Help GC. - token._tokenizer = token.next = undefined; - token = token.previous; - end = index + 1; +function map$2 (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f.call(xs, xs[i], i)); } - } - - // Help GC. - tokenizer.events = token._tokenizer = token.next = undefined; // Do head: - - add(childEvents.slice(0, end)); - index = -1; - adjust = 0; - - while (++index < jumps.length) { - gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; - adjust += jumps[index][1] - jumps[index][0] - 1; - } - - return gaps - - function add(slice) { - var start = startPositions.pop(); - jumps.unshift([start, start + slice.length - 1]); - chunkedSplice$7(events, start, 2, slice); - } + return res; } -var subtokenize_1 = subtokenize$2; +var camelcase$1 = {exports: {}}; -var markdownLineEnding$g = markdownLineEnding_1; -var prefixSize$3 = prefixSize_1; -var subtokenize$1 = subtokenize_1; -var factorySpace$e = factorySpace$i; +const preserveCamelCase = (string, locale) => { + let isLastCharLower = false; + let isLastCharUpper = false; + let isLastLastCharUpper = false; -// No name because it must not be turned off. -var content$2 = { - tokenize: tokenizeContent, - resolve: resolveContent, - interruptible: true, - lazy: true -}; -var continuationConstruct = { - tokenize: tokenizeContinuation, - partial: true -}; // Content is transparent: it’s parsed right now. That way, definitions are also -// parsed right now: before text in paragraphs (specifically, media) are parsed. + for (let i = 0; i < string.length; i++) { + const character = string[i]; -function resolveContent(events) { - subtokenize$1(events); - return events -} + if (isLastCharLower && /[\p{Lu}]/u.test(character)) { + string = string.slice(0, i) + '-' + string.slice(i); + isLastCharLower = false; + isLastLastCharUpper = isLastCharUpper; + isLastCharUpper = true; + i++; + } else if (isLastCharUpper && isLastLastCharUpper && /[\p{Ll}]/u.test(character)) { + string = string.slice(0, i - 1) + '-' + string.slice(i - 1); + isLastLastCharUpper = isLastCharUpper; + isLastCharUpper = false; + isLastCharLower = true; + } else { + isLastCharLower = character.toLocaleLowerCase(locale) === character && character.toLocaleUpperCase(locale) !== character; + isLastLastCharUpper = isLastCharUpper; + isLastCharUpper = character.toLocaleUpperCase(locale) === character && character.toLocaleLowerCase(locale) !== character; + } + } -function tokenizeContent(effects, ok) { - var previous; - return start + return string; +}; - function start(code) { - effects.enter('content'); - previous = effects.enter('chunkContent', { - contentType: 'content' - }); - return data(code) - } +const preserveConsecutiveUppercase = input => { + return input.replace(/^[\p{Lu}](?![\p{Lu}])/gu, m1 => m1.toLowerCase()); +}; - function data(code) { - if (code === null) { - return contentEnd(code) - } +const postProcess = (input, options) => { + return input.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu, (_, p1) => p1.toLocaleUpperCase(options.locale)) + .replace(/\d+([\p{Alpha}\p{N}_]|$)/gu, m => m.toLocaleUpperCase(options.locale)); +}; - if (markdownLineEnding$g(code)) { - return effects.check( - continuationConstruct, - contentContinue, - contentEnd - )(code) - } // Data. +const camelCase = (input, options) => { + if (!(typeof input === 'string' || Array.isArray(input))) { + throw new TypeError('Expected the input to be `string | string[]`'); + } - effects.consume(code); - return data - } + options = { + pascalCase: false, + preserveConsecutiveUppercase: false, + ...options + }; - function contentEnd(code) { - effects.exit('chunkContent'); - effects.exit('content'); - return ok(code) - } + if (Array.isArray(input)) { + input = input.map(x => x.trim()) + .filter(x => x.length) + .join('-'); + } else { + input = input.trim(); + } - function contentContinue(code) { - effects.consume(code); - effects.exit('chunkContent'); - previous = previous.next = effects.enter('chunkContent', { - contentType: 'content', - previous: previous - }); - return data - } -} + if (input.length === 0) { + return ''; + } -function tokenizeContinuation(effects, ok, nok) { - var self = this; - return startLookahead + if (input.length === 1) { + return options.pascalCase ? input.toLocaleUpperCase(options.locale) : input.toLocaleLowerCase(options.locale); + } - function startLookahead(code) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return factorySpace$e(effects, prefixed, 'linePrefix') - } + const hasUpperCase = input !== input.toLocaleLowerCase(options.locale); - function prefixed(code) { - if (code === null || markdownLineEnding$g(code)) { - return nok(code) - } + if (hasUpperCase) { + input = preserveCamelCase(input, options.locale); + } - if ( - self.parser.constructs.disable.null.indexOf('codeIndented') > -1 || - prefixSize$3(self.events, 'linePrefix') < 4 - ) { - return effects.interrupt(self.parser.constructs.flow, nok, ok)(code) - } + input = input.replace(/^[_.\- ]+/, ''); - return ok(code) - } -} + if (options.preserveConsecutiveUppercase) { + input = preserveConsecutiveUppercase(input); + } else { + input = input.toLocaleLowerCase(); + } -var content_1 = content$2; + if (options.pascalCase) { + input = input.charAt(0).toLocaleUpperCase(options.locale) + input.slice(1); + } -Object.defineProperty(flow$7, '__esModule', {value: true}); + return postProcess(input, options); +}; -var content$1 = content_1; -var factorySpace$d = factorySpace$i; -var partialBlankLine$2 = partialBlankLine_1; +camelcase$1.exports = camelCase; +// TODO: Remove this for the next major release +camelcase$1.exports.default = camelCase; -var tokenize = initializeFlow; +var camelcase = camelcase$1.exports; -function initializeFlow(effects) { - var self = this; - var initial = effects.attempt( - // Try to parse a blank line. - partialBlankLine$2, - atBlankEnding, // Try to parse initial flow (essentially, only code). - effects.attempt( - this.parser.constructs.flowInitial, - afterConstruct, - factorySpace$d( - effects, - effects.attempt( - this.parser.constructs.flow, - afterConstruct, - effects.attempt(content$1, afterConstruct) - ), - 'linePrefix' - ) - ) - ); - return initial +var minimist = function (args, opts) { + if (!opts) opts = {}; + + var flags = { bools : {}, strings : {}, unknownFn: null }; - function atBlankEnding(code) { - if (code === null) { - effects.consume(code); - return + if (typeof opts['unknown'] === 'function') { + flags.unknownFn = opts['unknown']; } - effects.enter('lineEndingBlank'); - effects.consume(code); - effects.exit('lineEndingBlank'); - self.currentConstruct = undefined; - return initial - } - - function afterConstruct(code) { - if (code === null) { - effects.consume(code); - return + if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { + flags.allBools = true; + } else { + [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { + flags.bools[key] = true; + }); } + + var aliases = {}; + Object.keys(opts.alias || {}).forEach(function (key) { + aliases[key] = [].concat(opts.alias[key]); + aliases[key].forEach(function (x) { + aliases[x] = [key].concat(aliases[key].filter(function (y) { + return x !== y; + })); + }); + }); - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - self.currentConstruct = undefined; - return initial - } -} - -flow$7.tokenize = tokenize; - -var text$5 = {}; - -Object.defineProperty(text$5, '__esModule', {value: true}); - -var assign$2 = assign_1; -var shallow$4 = shallow_1; - -var text$4 = initializeFactory('text'); -var string$1 = initializeFactory('string'); -var resolver = { - resolveAll: createResolver() -}; - -function initializeFactory(field) { - return { - tokenize: initializeText, - resolveAll: createResolver( - field === 'text' ? resolveAllLineSuffixes : undefined - ) - } + [].concat(opts.string).filter(Boolean).forEach(function (key) { + flags.strings[key] = true; + if (aliases[key]) { + flags.strings[aliases[key]] = true; + } + }); - function initializeText(effects) { - var self = this; - var constructs = this.parser.constructs[field]; - var text = effects.attempt(constructs, start, notText); - return start + var defaults = opts['default'] || {}; + + var argv = { _ : [] }; + Object.keys(flags.bools).forEach(function (key) { + setArg(key, defaults[key] === undefined ? false : defaults[key]); + }); + + var notFlags = []; - function start(code) { - return atBreak(code) ? text(code) : notText(code) + if (args.indexOf('--') !== -1) { + notFlags = args.slice(args.indexOf('--')+1); + args = args.slice(0, args.indexOf('--')); } - function notText(code) { - if (code === null) { - effects.consume(code); - return - } - - effects.enter('data'); - effects.consume(code); - return data + function argDefined(key, arg) { + return (flags.allBools && /^--[^=]+$/.test(arg)) || + flags.strings[key] || flags.bools[key] || aliases[key]; } - function data(code) { - if (atBreak(code)) { - effects.exit('data'); - return text(code) - } // Data. + function setArg (key, val, arg) { + if (arg && flags.unknownFn && !argDefined(key, arg)) { + if (flags.unknownFn(arg) === false) return; + } - effects.consume(code); - return data + var value = !flags.strings[key] && isNumber(val) + ? Number(val) : val + ; + setKey(argv, key.split('.'), value); + + (aliases[key] || []).forEach(function (x) { + setKey(argv, x.split('.'), value); + }); } - function atBreak(code) { - var list = constructs[code]; - var index = -1; - - if (code === null) { - return true - } - - if (list) { - while (++index < list.length) { - if ( - !list[index].previous || - list[index].previous.call(self, self.previous) - ) { - return true - } + function setKey (obj, keys, value) { + var o = obj; + for (var i = 0; i < keys.length-1; i++) { + var key = keys[i]; + if (key === '__proto__') return; + if (o[key] === undefined) o[key] = {}; + if (o[key] === Object.prototype || o[key] === Number.prototype + || o[key] === String.prototype) o[key] = {}; + if (o[key] === Array.prototype) o[key] = []; + o = o[key]; } - } - } - } -} - -function createResolver(extraResolver) { - return resolveAllText - - function resolveAllText(events, context) { - var index = -1; - var enter; // A rather boring computation (to merge adjacent `data` events) which - // improves mm performance by 29%. - while (++index <= events.length) { - if (enter === undefined) { - if (events[index] && events[index][1].type === 'data') { - enter = index; - index++; + var key = keys[keys.length - 1]; + if (key === '__proto__') return; + if (o === Object.prototype || o === Number.prototype + || o === String.prototype) o = {}; + if (o === Array.prototype) o = []; + if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { + o[key] = value; } - } else if (!events[index] || events[index][1].type !== 'data') { - // Don’t do anything if there is one data token. - if (index !== enter + 2) { - events[enter][1].end = events[index - 1][1].end; - events.splice(enter + 2, index - enter - 2); - index = enter + 2; + else if (Array.isArray(o[key])) { + o[key].push(value); + } + else { + o[key] = [ o[key], value ]; } - - enter = undefined; - } + } + + function aliasIsBoolean(key) { + return aliases[key].some(function (x) { + return flags.bools[x]; + }); } - return extraResolver ? extraResolver(events, context) : events - } -} // A rather ugly set of instructions which again looks at chunks in the input -// stream. -// The reason to do this here is that it is *much* faster to parse in reverse. -// And that we can’t hook into `null` to split the line suffix before an EOF. -// To do: figure out if we can make this into a clean utility, or even in core. -// As it will be useful for GFMs literal autolink extension (and maybe even -// tables?) - -function resolveAllLineSuffixes(events, context) { - var eventIndex = -1; - var chunks; - var data; - var chunk; - var index; - var bufferIndex; - var size; - var tabs; - var token; - - while (++eventIndex <= events.length) { - if ( - (eventIndex === events.length || - events[eventIndex][1].type === 'lineEnding') && - events[eventIndex - 1][1].type === 'data' - ) { - data = events[eventIndex - 1][1]; - chunks = context.sliceStream(data); - index = chunks.length; - bufferIndex = -1; - size = 0; - tabs = undefined; - - while (index--) { - chunk = chunks[index]; - - if (typeof chunk === 'string') { - bufferIndex = chunk.length; - - while (chunk.charCodeAt(bufferIndex - 1) === 32) { - size++; - bufferIndex--; - } - - if (bufferIndex) break - bufferIndex = -1; - } // Number - else if (chunk === -2) { - tabs = true; - size++; - } else if (chunk === -1); + for (var i = 0; i < args.length; i++) { + var arg = args[i]; + + if (/^--.+=/.test(arg)) { + // Using [\s\S] instead of . because js doesn't support the + // 'dotall' regex modifier. See: + // http://stackoverflow.com/a/1068308/13216 + var m = arg.match(/^--([^=]+)=([\s\S]*)$/); + var key = m[1]; + var value = m[2]; + if (flags.bools[key]) { + value = value !== 'false'; + } + setArg(key, value, arg); + } + else if (/^--no-.+/.test(arg)) { + var key = arg.match(/^--no-(.+)/)[1]; + setArg(key, false, arg); + } + else if (/^--.+/.test(arg)) { + var key = arg.match(/^--(.+)/)[1]; + var next = args[i + 1]; + if (next !== undefined && !/^-/.test(next) + && !flags.bools[key] + && !flags.allBools + && (aliases[key] ? !aliasIsBoolean(key) : true)) { + setArg(key, next, arg); + i++; + } + else if (/^(true|false)$/.test(next)) { + setArg(key, next === 'true', arg); + i++; + } + else { + setArg(key, flags.strings[key] ? '' : true, arg); + } + } + else if (/^-[^-]+/.test(arg)) { + var letters = arg.slice(1,-1).split(''); + + var broken = false; + for (var j = 0; j < letters.length; j++) { + var next = arg.slice(j+2); + + if (next === '-') { + setArg(letters[j], next, arg); + continue; + } + + if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { + setArg(letters[j], next.split('=')[1], arg); + broken = true; + break; + } + + if (/[A-Za-z]/.test(letters[j]) + && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { + setArg(letters[j], next, arg); + broken = true; + break; + } + + if (letters[j+1] && letters[j+1].match(/\W/)) { + setArg(letters[j], arg.slice(j+2), arg); + broken = true; + break; + } + else { + setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); + } + } + + var key = arg.slice(-1)[0]; + if (!broken && key !== '-') { + if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) + && !flags.bools[key] + && (aliases[key] ? !aliasIsBoolean(key) : true)) { + setArg(key, args[i+1], arg); + i++; + } + else if (args[i+1] && /^(true|false)$/.test(args[i+1])) { + setArg(key, args[i+1] === 'true', arg); + i++; + } + else { + setArg(key, flags.strings[key] ? '' : true, arg); + } + } + } else { - // Replacement character, exit. - index++; - break + if (!flags.unknownFn || flags.unknownFn(arg) !== false) { + argv._.push( + flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) + ); + } + if (opts.stopEarly) { + argv._.push.apply(argv._, args.slice(i + 1)); + break; + } } - } - - if (size) { - token = { - type: - eventIndex === events.length || tabs || size < 2 - ? 'lineSuffix' - : 'hardBreakTrailing', - start: { - line: data.end.line, - column: data.end.column - size, - offset: data.end.offset - size, - _index: data.start._index + index, - _bufferIndex: index - ? bufferIndex - : data.start._bufferIndex + bufferIndex - }, - end: shallow$4(data.end) - }; - data.end = shallow$4(token.start); - - if (data.start.offset === data.end.offset) { - assign$2(data, token); - } else { - events.splice( - eventIndex, - 0, - ['enter', token, context], - ['exit', token, context] - ); - eventIndex += 2; + } + + Object.keys(defaults).forEach(function (key) { + if (!hasKey(argv, key.split('.'))) { + setKey(argv, key.split('.'), defaults[key]); + + (aliases[key] || []).forEach(function (x) { + setKey(argv, x.split('.'), defaults[key]); + }); } - } - - eventIndex++; + }); + + if (opts['--']) { + argv['--'] = new Array(); + notFlags.forEach(function(key) { + argv['--'].push(key); + }); + } + else { + notFlags.forEach(function(key) { + argv._.push(key); + }); } - } - return events -} + return argv; +}; -text$5.resolver = resolver; -text$5.string = string$1; -text$5.text = text$4; +function hasKey (obj, keys) { + var o = obj; + keys.slice(0,-1).forEach(function (key) { + o = (o[key] || {}); + }); -function miniflat$3(value) { - return value === null || value === undefined - ? [] - : 'length' in value - ? value - : [value] + var key = keys[keys.length - 1]; + return key in o; } -var miniflat_1 = miniflat$3; - -var hasOwnProperty$1 = hasOwnProperty$2; -var chunkedSplice$6 = chunkedSplice_1; -var miniflat$2 = miniflat_1; - -function combineExtensions$2(extensions) { - var all = {}; - var index = -1; - - while (++index < extensions.length) { - extension$1(all, extensions[index]); - } - - return all +function isNumber (x) { + if (typeof x === 'number') return true; + if (/^0x[0-9a-f]+$/i.test(x)) return true; + return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); } -function extension$1(all, extension) { - var hook; - var left; - var right; - var code; +// This is a generated file. Do not edit. +var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/; +var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\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\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\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\u0AF9\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-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\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-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\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-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/; +var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\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\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\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\u09FC\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\u0AF9-\u0AFF\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\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\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\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\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-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\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-\u191E\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\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\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\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-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\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-\uFE2F\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/; - for (hook in extension) { - left = hasOwnProperty$1.call(all, hook) ? all[hook] : (all[hook] = {}); - right = extension[hook]; +var unicode = { + Space_Separator: Space_Separator, + ID_Start: ID_Start, + ID_Continue: ID_Continue +}; - for (code in right) { - left[code] = constructs$3( - miniflat$2(right[code]), - hasOwnProperty$1.call(left, code) ? left[code] : [] - ); - } - } -} +var util = { + isSpaceSeparator (c) { + return typeof c === 'string' && unicode.Space_Separator.test(c) + }, -function constructs$3(list, existing) { - var index = -1; - var before = []; + isIdStartChar (c) { + return typeof c === 'string' && ( + (c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c === '$') || (c === '_') || + unicode.ID_Start.test(c) + ) + }, - while (++index < list.length) { -(list[index].add === 'after' ? existing : before).push(list[index]); - } + isIdContinueChar (c) { + return typeof c === 'string' && ( + (c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + (c === '$') || (c === '_') || + (c === '\u200C') || (c === '\u200D') || + unicode.ID_Continue.test(c) + ) + }, - chunkedSplice$6(existing, 0, 0, before); - return existing -} + isDigit (c) { + return typeof c === 'string' && /[0-9]/.test(c) + }, + + isHexDigit (c) { + return typeof c === 'string' && /[0-9A-Fa-f]/.test(c) + }, +}; -var combineExtensions_1 = combineExtensions$2; +let source; +let parseState; +let stack; +let pos; +let line; +let column; +let token; +let key; +let root$1; -var chunkedSplice$5 = chunkedSplice_1; +var parse$1 = function parse (text, reviver) { + source = String(text); + parseState = 'start'; + stack = []; + pos = 0; + line = 1; + column = 0; + token = undefined; + key = undefined; + root$1 = undefined; -function chunkedPush$3(list, items) { - if (list.length) { - chunkedSplice$5(list, list.length, 0, items); - return list - } + do { + token = lex(); - return items -} + // This code is unreachable. + // if (!parseStates[parseState]) { + // throw invalidParseState() + // } -var chunkedPush_1 = chunkedPush$3; + parseStates[parseState](); + } while (token.type !== 'eof') -function resolveAll$4(constructs, events, context) { - var called = []; - var index = -1; - var resolve; + if (typeof reviver === 'function') { + return internalize({'': root$1}, '', reviver) + } - while (++index < constructs.length) { - resolve = constructs[index].resolveAll; + return root$1 +}; - if (resolve && called.indexOf(resolve) < 0) { - events = resolve(events, context); - called.push(resolve); +function internalize (holder, name, reviver) { + const value = holder[name]; + if (value != null && typeof value === 'object') { + for (const key in value) { + const replacement = internalize(value, key, reviver); + if (replacement === undefined) { + delete value[key]; + } else { + value[key] = replacement; + } + } } - } - return events + return reviver.call(holder, name, value) } -var resolveAll_1 = resolveAll$4; +let lexState; +let buffer; +let doubleQuote; +let sign; +let c; -var fromCharCode$2 = fromCharCode_1; +function lex () { + lexState = 'default'; + buffer = ''; + doubleQuote = false; + sign = 1; -function serializeChunks$1(chunks) { - var index = -1; - var result = []; - var chunk; - var value; - var atTab; + for (;;) { + c = peek(); - while (++index < chunks.length) { - chunk = chunks[index]; + // This code is unreachable. + // if (!lexStates[lexState]) { + // throw invalidLexState(lexState) + // } - if (typeof chunk === 'string') { - value = chunk; - } else if (chunk === -5) { - value = '\r'; - } else if (chunk === -4) { - value = '\n'; - } else if (chunk === -3) { - value = '\r' + '\n'; - } else if (chunk === -2) { - value = '\t'; - } else if (chunk === -1) { - if (atTab) continue - value = ' '; - } else { - // Currently only replacement character. - value = fromCharCode$2(chunk); + const token = lexStates[lexState](); + if (token) { + return token + } } - - atTab = chunk === -2; - result.push(value); - } - - return result.join('') } -var serializeChunks_1 = serializeChunks$1; - -function sliceChunks$1(chunks, token) { - var startIndex = token.start._index; - var startBufferIndex = token.start._bufferIndex; - var endIndex = token.end._index; - var endBufferIndex = token.end._bufferIndex; - var view; +function peek () { + if (source[pos]) { + return String.fromCodePoint(source.codePointAt(pos)) + } +} - if (startIndex === endIndex) { - view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]; - } else { - view = chunks.slice(startIndex, endIndex); +function read () { + const c = peek(); - if (startBufferIndex > -1) { - view[0] = view[0].slice(startBufferIndex); + if (c === '\n') { + line++; + column = 0; + } else if (c) { + column += c.length; + } else { + column++; } - if (endBufferIndex > 0) { - view.push(chunks[endIndex].slice(0, endBufferIndex)); + if (c) { + pos += c.length; } - } - return view + return c } -var sliceChunks_1 = sliceChunks$1; - -var assign$1 = assign_1; -var markdownLineEnding$f = markdownLineEnding_1; -var chunkedPush$2 = chunkedPush_1; -var chunkedSplice$4 = chunkedSplice_1; -var miniflat$1 = miniflat_1; -var resolveAll$3 = resolveAll_1; -var serializeChunks = serializeChunks_1; -var shallow$3 = shallow_1; -var sliceChunks = sliceChunks_1; - -// Create a tokenizer. -// Tokenizers deal with one type of data (e.g., containers, flow, text). -// The parser is the object dealing with it all. -// `initialize` works like other constructs, except that only its `tokenize` -// function is used, in which case it doesn’t receive an `ok` or `nok`. -// `from` can be given to set the point before the first character, although -// when further lines are indented, they must be set with `defineSkip`. -function createTokenizer$1(parser, initialize, from) { - var point = from - ? shallow$3(from) - : { - line: 1, - column: 1, - offset: 0 - }; - var columnStart = {}; - var resolveAllConstructs = []; - var chunks = []; - var stack = []; - - var effects = { - consume: consume, - enter: enter, - exit: exit, - attempt: constructFactory(onsuccessfulconstruct), - check: constructFactory(onsuccessfulcheck), - interrupt: constructFactory(onsuccessfulcheck, { - interrupt: true - }), - lazy: constructFactory(onsuccessfulcheck, { - lazy: true - }) - }; // State and tools for resolving and serializing. +const lexStates = { + default () { + switch (c) { + case '\t': + case '\v': + case '\f': + case ' ': + case '\u00A0': + case '\uFEFF': + case '\n': + case '\r': + case '\u2028': + case '\u2029': + read(); + return - var context = { - previous: null, - events: [], - parser: parser, - sliceStream: sliceStream, - sliceSerialize: sliceSerialize, - now: now, - defineSkip: skip, - write: write - }; // The state function. + case '/': + read(); + lexState = 'comment'; + return - var state = initialize.tokenize.call(context, effects); // Track which character we expect to be consumed, to catch bugs. + case undefined: + read(); + return newToken('eof') + } - if (initialize.resolveAll) { - resolveAllConstructs.push(initialize); - } // Store where we are in the input stream. + if (util.isSpaceSeparator(c)) { + read(); + return + } - point._index = 0; - point._bufferIndex = -1; - return context + // This code is unreachable. + // if (!lexStates[parseState]) { + // throw invalidLexState(parseState) + // } - function write(slice) { - chunks = chunkedPush$2(chunks, slice); - main(); // Exit if we’re not done, resolve might change stuff. + return lexStates[parseState]() + }, - if (chunks[chunks.length - 1] !== null) { - return [] - } + comment () { + switch (c) { + case '*': + read(); + lexState = 'multiLineComment'; + return - addResult(initialize, 0); // Otherwise, resolve, and exit. + case '/': + read(); + lexState = 'singleLineComment'; + return + } - context.events = resolveAll$3(resolveAllConstructs, context.events, context); - return context.events - } // - // Tools. - // + throw invalidChar(read()) + }, - function sliceSerialize(token) { - return serializeChunks(sliceStream(token)) - } + multiLineComment () { + switch (c) { + case '*': + read(); + lexState = 'multiLineCommentAsterisk'; + return - function sliceStream(token) { - return sliceChunks(chunks, token) - } + case undefined: + throw invalidChar(read()) + } - function now() { - return shallow$3(point) - } + read(); + }, - function skip(value) { - columnStart[value.line] = value.column; - accountForPotentialSkip(); - } // - // State management. - // - // Main loop (note that `_index` and `_bufferIndex` in `point` are modified by - // `consume`). - // Here is where we walk through the chunks, which either include strings of - // several characters, or numerical character codes. - // The reason to do this in a loop instead of a call is so the stack can - // drain. + multiLineCommentAsterisk () { + switch (c) { + case '*': + read(); + return - function main() { - var chunkIndex; - var chunk; + case '/': + read(); + lexState = 'default'; + return - while (point._index < chunks.length) { - chunk = chunks[point._index]; // If we’re in a buffer chunk, loop through it. + case undefined: + throw invalidChar(read()) + } - if (typeof chunk === 'string') { - chunkIndex = point._index; + read(); + lexState = 'multiLineComment'; + }, - if (point._bufferIndex < 0) { - point._bufferIndex = 0; - } + singleLineComment () { + switch (c) { + case '\n': + case '\r': + case '\u2028': + case '\u2029': + read(); + lexState = 'default'; + return - while ( - point._index === chunkIndex && - point._bufferIndex < chunk.length - ) { - go(chunk.charCodeAt(point._bufferIndex)); + case undefined: + read(); + return newToken('eof') } - } else { - go(chunk); - } - } - } // Deal with one code. - - function go(code) { - state = state(code); - } // Move a character forward. - function consume(code) { - if (markdownLineEnding$f(code)) { - point.line++; - point.column = 1; - point.offset += code === -3 ? 2 : 1; - accountForPotentialSkip(); - } else if (code !== -1) { - point.column++; - point.offset++; - } // Not in a string chunk. + read(); + }, - if (point._bufferIndex < 0) { - point._index++; - } else { - point._bufferIndex++; // At end of string chunk. - - if (point._bufferIndex === chunks[point._index].length) { - point._bufferIndex = -1; - point._index++; - } - } // Expose the previous character. - - context.previous = code; // Mark as consumed. - } // Start a token. + value () { + switch (c) { + case '{': + case '[': + return newToken('punctuator', read()) - function enter(type, fields) { - var token = fields || {}; - token.type = type; - token.start = now(); - context.events.push(['enter', token, context]); - stack.push(token); - return token - } // Stop a token. + case 'n': + read(); + literal('ull'); + return newToken('null', null) - function exit(type) { - var token = stack.pop(); - token.end = now(); - context.events.push(['exit', token, context]); - return token - } // Use results. + case 't': + read(); + literal('rue'); + return newToken('boolean', true) - function onsuccessfulconstruct(construct, info) { - addResult(construct, info.from); - } // Discard results. + case 'f': + read(); + literal('alse'); + return newToken('boolean', false) - function onsuccessfulcheck(construct, info) { - info.restore(); - } // Factory to attempt/check/interrupt. + case '-': + case '+': + if (read() === '-') { + sign = -1; + } - function constructFactory(onreturn, fields) { - return hook // Handle either an object mapping codes to constructs, a list of - // constructs, or a single construct. + lexState = 'sign'; + return - function hook(constructs, returnState, bogusState) { - var listOfConstructs; - var constructIndex; - var currentConstruct; - var info; - return constructs.tokenize || 'length' in constructs - ? handleListOfConstructs(miniflat$1(constructs)) - : handleMapOfConstructs - - function handleMapOfConstructs(code) { - if (code in constructs || null in constructs) { - return handleListOfConstructs( - constructs.null - ? /* c8 ignore next */ - miniflat$1(constructs[code]).concat(miniflat$1(constructs.null)) - : constructs[code] - )(code) - } + case '.': + buffer = read(); + lexState = 'decimalPointLeading'; + return - return bogusState(code) - } + case '0': + buffer = read(); + lexState = 'zero'; + return - function handleListOfConstructs(list) { - listOfConstructs = list; - constructIndex = 0; - return handleConstruct(list[constructIndex]) - } + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + buffer = read(); + lexState = 'decimalInteger'; + return - function handleConstruct(construct) { - return start + case 'I': + read(); + literal('nfinity'); + return newToken('numeric', Infinity) - function start(code) { - // To do: not nede to store if there is no bogus state, probably? - // Currently doesn’t work because `inspect` in document does a check - // w/o a bogus, which doesn’t make sense. But it does seem to help perf - // by not storing. - info = store(); - currentConstruct = construct; + case 'N': + read(); + literal('aN'); + return newToken('numeric', NaN) - if (!construct.partial) { - context.currentConstruct = construct; - } + case '"': + case "'": + doubleQuote = (read() === '"'); + buffer = ''; + lexState = 'string'; + return + } - if ( - construct.name && - context.parser.constructs.disable.null.indexOf(construct.name) > -1 - ) { - return nok() - } + throw invalidChar(read()) + }, - return construct.tokenize.call( - fields ? assign$1({}, context, fields) : context, - effects, - ok, - nok - )(code) + identifierNameStartEscape () { + if (c !== 'u') { + throw invalidChar(read()) } - } - function ok(code) { - onreturn(currentConstruct, info); - return returnState - } + read(); + const u = unicodeEscape(); + switch (u) { + case '$': + case '_': + break - function nok(code) { - info.restore(); + default: + if (!util.isIdStartChar(u)) { + throw invalidIdentifier() + } - if (++constructIndex < listOfConstructs.length) { - return handleConstruct(listOfConstructs[constructIndex]) + break } - return bogusState - } - } - } - - function addResult(construct, from) { - if (construct.resolveAll && resolveAllConstructs.indexOf(construct) < 0) { - resolveAllConstructs.push(construct); - } + buffer += u; + lexState = 'identifierName'; + }, - if (construct.resolve) { - chunkedSplice$4( - context.events, - from, - context.events.length - from, - construct.resolve(context.events.slice(from), context) - ); - } + identifierName () { + switch (c) { + case '$': + case '_': + case '\u200C': + case '\u200D': + buffer += read(); + return - if (construct.resolveTo) { - context.events = construct.resolveTo(context.events, context); - } - } + case '\\': + read(); + lexState = 'identifierNameEscape'; + return + } - function store() { - var startPoint = now(); - var startPrevious = context.previous; - var startCurrentConstruct = context.currentConstruct; - var startEventsIndex = context.events.length; - var startStack = Array.from(stack); - return { - restore: restore, - from: startEventsIndex - } + if (util.isIdContinueChar(c)) { + buffer += read(); + return + } - function restore() { - point = startPoint; - context.previous = startPrevious; - context.currentConstruct = startCurrentConstruct; - context.events.length = startEventsIndex; - stack = startStack; - accountForPotentialSkip(); - } - } + return newToken('identifier', buffer) + }, - function accountForPotentialSkip() { - if (point.line in columnStart && point.column < 2) { - point.column = columnStart[point.line]; - point.offset += columnStart[point.line] - 1; - } - } -} + identifierNameEscape () { + if (c !== 'u') { + throw invalidChar(read()) + } -var createTokenizer_1 = createTokenizer$1; + read(); + const u = unicodeEscape(); + switch (u) { + case '$': + case '_': + case '\u200C': + case '\u200D': + break -var constructs$2 = {}; + default: + if (!util.isIdContinueChar(u)) { + throw invalidIdentifier() + } -function markdownLineEndingOrSpace$9(code) { - return code < 0 || code === 32 -} + break + } -var markdownLineEndingOrSpace_1 = markdownLineEndingOrSpace$9; + buffer += u; + lexState = 'identifierName'; + }, -// This module is generated by `script/`. -// -// CommonMark handles attention (emphasis, strong) markers based on what comes -// before or after them. -// One such difference is if those characters are Unicode punctuation. -// This script is generated from the Unicode data. -var unicodePunctuation$3 = /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/; + sign () { + switch (c) { + case '.': + buffer = read(); + lexState = 'decimalPointLeading'; + return -var unicodePunctuationRegex$2 = unicodePunctuation$3; + case '0': + buffer = read(); + lexState = 'zero'; + return -var fromCharCode$1 = fromCharCode_1; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + buffer = read(); + lexState = 'decimalInteger'; + return -function regexCheck$9(regex) { - return check + case 'I': + read(); + literal('nfinity'); + return newToken('numeric', sign * Infinity) - function check(code) { - return regex.test(fromCharCode$1(code)) - } -} + case 'N': + read(); + literal('aN'); + return newToken('numeric', NaN) + } -var regexCheck_1 = regexCheck$9; + throw invalidChar(read()) + }, -var unicodePunctuationRegex$1 = unicodePunctuationRegex$2; -var regexCheck$8 = regexCheck_1; + zero () { + switch (c) { + case '.': + buffer += read(); + lexState = 'decimalPoint'; + return -// In fact adds to the bundle size. + case 'e': + case 'E': + buffer += read(); + lexState = 'decimalExponent'; + return -var unicodePunctuation$2 = regexCheck$8(unicodePunctuationRegex$1); + case 'x': + case 'X': + buffer += read(); + lexState = 'hexadecimal'; + return + } -var unicodePunctuation_1 = unicodePunctuation$2; + return newToken('numeric', sign * 0) + }, -var regexCheck$7 = regexCheck_1; + decimalInteger () { + switch (c) { + case '.': + buffer += read(); + lexState = 'decimalPoint'; + return -var unicodeWhitespace$2 = regexCheck$7(/\s/); + case 'e': + case 'E': + buffer += read(); + lexState = 'decimalExponent'; + return + } -var unicodeWhitespace_1 = unicodeWhitespace$2; + if (util.isDigit(c)) { + buffer += read(); + return + } -var markdownLineEndingOrSpace$8 = markdownLineEndingOrSpace_1; -var unicodePunctuation$1 = unicodePunctuation_1; -var unicodeWhitespace$1 = unicodeWhitespace_1; + return newToken('numeric', sign * Number(buffer)) + }, -// Classify whether a character is unicode whitespace, unicode punctuation, or -// anything else. -// Used for attention (emphasis, strong), whose sequences can open or close -// based on the class of surrounding characters. -function classifyCharacter$2(code) { - if ( - code === null || - markdownLineEndingOrSpace$8(code) || - unicodeWhitespace$1(code) - ) { - return 1 - } + decimalPointLeading () { + if (util.isDigit(c)) { + buffer += read(); + lexState = 'decimalFraction'; + return + } - if (unicodePunctuation$1(code)) { - return 2 - } -} + throw invalidChar(read()) + }, -var classifyCharacter_1 = classifyCharacter$2; + decimalPoint () { + switch (c) { + case 'e': + case 'E': + buffer += read(); + lexState = 'decimalExponent'; + return + } -// chunks (replacement characters, tabs, or line endings). + if (util.isDigit(c)) { + buffer += read(); + lexState = 'decimalFraction'; + return + } -function movePoint$1(point, offset) { - point.column += offset; - point.offset += offset; - point._bufferIndex += offset; - return point -} + return newToken('numeric', sign * Number(buffer)) + }, -var movePoint_1 = movePoint$1; + decimalFraction () { + switch (c) { + case 'e': + case 'E': + buffer += read(); + lexState = 'decimalExponent'; + return + } -var chunkedPush$1 = chunkedPush_1; -var chunkedSplice$3 = chunkedSplice_1; -var classifyCharacter$1 = classifyCharacter_1; -var movePoint = movePoint_1; -var resolveAll$2 = resolveAll_1; -var shallow$2 = shallow_1; + if (util.isDigit(c)) { + buffer += read(); + return + } -var attention$1 = { - name: 'attention', - tokenize: tokenizeAttention, - resolveAll: resolveAllAttention -}; + return newToken('numeric', sign * Number(buffer)) + }, -function resolveAllAttention(events, context) { - var index = -1; - var open; - var group; - var text; - var openingSequence; - var closingSequence; - var use; - var nextEvents; - var offset; // Walk through all events. - // - // Note: performance of this is fine on an mb of normal markdown, but it’s - // a bottleneck for malicious stuff. + decimalExponent () { + switch (c) { + case '+': + case '-': + buffer += read(); + lexState = 'decimalExponentSign'; + return + } - while (++index < events.length) { - // Find a token that can close. - if ( - events[index][0] === 'enter' && - events[index][1].type === 'attentionSequence' && - events[index][1]._close - ) { - open = index; // Now walk back to find an opener. + if (util.isDigit(c)) { + buffer += read(); + lexState = 'decimalExponentInteger'; + return + } - while (open--) { - // Find a token that can open the closer. - if ( - events[open][0] === 'exit' && - events[open][1].type === 'attentionSequence' && - events[open][1]._open && // If the markers are the same: - context.sliceSerialize(events[open][1]).charCodeAt(0) === - context.sliceSerialize(events[index][1]).charCodeAt(0) - ) { - // If the opening can close or the closing can open, - // and the close size *is not* a multiple of three, - // but the sum of the opening and closing size *is* multiple of three, - // then don’t match. - if ( - (events[open][1]._close || events[index][1]._open) && - (events[index][1].end.offset - events[index][1].start.offset) % 3 && - !( - (events[open][1].end.offset - - events[open][1].start.offset + - events[index][1].end.offset - - events[index][1].start.offset) % - 3 - ) - ) { - continue - } // Number of markers to use from the sequence. + throw invalidChar(read()) + }, - use = - events[open][1].end.offset - events[open][1].start.offset > 1 && - events[index][1].end.offset - events[index][1].start.offset > 1 - ? 2 - : 1; - openingSequence = { - type: use > 1 ? 'strongSequence' : 'emphasisSequence', - start: movePoint(shallow$2(events[open][1].end), -use), - end: shallow$2(events[open][1].end) - }; - closingSequence = { - type: use > 1 ? 'strongSequence' : 'emphasisSequence', - start: shallow$2(events[index][1].start), - end: movePoint(shallow$2(events[index][1].start), use) - }; - text = { - type: use > 1 ? 'strongText' : 'emphasisText', - start: shallow$2(events[open][1].end), - end: shallow$2(events[index][1].start) - }; - group = { - type: use > 1 ? 'strong' : 'emphasis', - start: shallow$2(openingSequence.start), - end: shallow$2(closingSequence.end) - }; - events[open][1].end = shallow$2(openingSequence.start); - events[index][1].start = shallow$2(closingSequence.end); - nextEvents = []; // If there are more markers in the opening, add them before. + decimalExponentSign () { + if (util.isDigit(c)) { + buffer += read(); + lexState = 'decimalExponentInteger'; + return + } - if (events[open][1].end.offset - events[open][1].start.offset) { - nextEvents = chunkedPush$1(nextEvents, [ - ['enter', events[open][1], context], - ['exit', events[open][1], context] - ]); - } // Opening. + throw invalidChar(read()) + }, - nextEvents = chunkedPush$1(nextEvents, [ - ['enter', group, context], - ['enter', openingSequence, context], - ['exit', openingSequence, context], - ['enter', text, context] - ]); // Between. + decimalExponentInteger () { + if (util.isDigit(c)) { + buffer += read(); + return + } - nextEvents = chunkedPush$1( - nextEvents, - resolveAll$2( - context.parser.constructs.insideSpan.null, - events.slice(open + 1, index), - context - ) - ); // Closing. + return newToken('numeric', sign * Number(buffer)) + }, - nextEvents = chunkedPush$1(nextEvents, [ - ['exit', text, context], - ['enter', closingSequence, context], - ['exit', closingSequence, context], - ['exit', group, context] - ]); // If there are more markers in the closing, add them after. + hexadecimal () { + if (util.isHexDigit(c)) { + buffer += read(); + lexState = 'hexadecimalInteger'; + return + } - if (events[index][1].end.offset - events[index][1].start.offset) { - offset = 2; - nextEvents = chunkedPush$1(nextEvents, [ - ['enter', events[index][1], context], - ['exit', events[index][1], context] - ]); - } else { - offset = 0; - } + throw invalidChar(read()) + }, - chunkedSplice$3(events, open - 1, index - open + 3, nextEvents); - index = open + nextEvents.length - offset - 2; - break + hexadecimalInteger () { + if (util.isHexDigit(c)) { + buffer += read(); + return } - } - } - } // Remove remaining sequences. - - index = -1; - while (++index < events.length) { - if (events[index][1].type === 'attentionSequence') { - events[index][1].type = 'data'; - } - } + return newToken('numeric', sign * Number(buffer)) + }, - return events -} + string () { + switch (c) { + case '\\': + read(); + buffer += escape(); + return -function tokenizeAttention(effects, ok) { - var before = classifyCharacter$1(this.previous); - var marker; - return start + case '"': + if (doubleQuote) { + read(); + return newToken('string', buffer) + } - function start(code) { - effects.enter('attentionSequence'); - marker = code; - return sequence(code) - } + buffer += read(); + return - function sequence(code) { - var token; - var after; - var open; - var close; + case "'": + if (!doubleQuote) { + read(); + return newToken('string', buffer) + } - if (code === marker) { - effects.consume(code); - return sequence - } + buffer += read(); + return - token = effects.exit('attentionSequence'); - after = classifyCharacter$1(code); - open = !after || (after === 2 && before); - close = !before || (before === 2 && after); - token._open = marker === 42 ? open : open && (before || !close); - token._close = marker === 42 ? close : close && (after || !open); - return ok(code) - } -} + case '\n': + case '\r': + throw invalidChar(read()) -var attention_1 = attention$1; + case '\u2028': + case '\u2029': + separatorChar(c); + break -var regexCheck$6 = regexCheck_1; + case undefined: + throw invalidChar(read()) + } -var asciiAlpha$4 = regexCheck$6(/[A-Za-z]/); + buffer += read(); + }, -var asciiAlpha_1 = asciiAlpha$4; + start () { + switch (c) { + case '{': + case '[': + return newToken('punctuator', read()) -var regexCheck$5 = regexCheck_1; + // This code is unreachable since the default lexState handles eof. + // case undefined: + // return newToken('eof') + } -var asciiAlphanumeric$5 = regexCheck$5(/[\dA-Za-z]/); + lexState = 'value'; + }, -var asciiAlphanumeric_1 = asciiAlphanumeric$5; + beforePropertyName () { + switch (c) { + case '$': + case '_': + buffer = read(); + lexState = 'identifierName'; + return -var regexCheck$4 = regexCheck_1; + case '\\': + read(); + lexState = 'identifierNameStartEscape'; + return -var asciiAtext$1 = regexCheck$4(/[#-'*+\--9=?A-Z^-~]/); + case '}': + return newToken('punctuator', read()) -var asciiAtext_1 = asciiAtext$1; + case '"': + case "'": + doubleQuote = (read() === '"'); + lexState = 'string'; + return + } -// Note: EOF is seen as ASCII control here, because `null < 32 == true`. -function asciiControl$3(code) { - return ( - // Special whitespace codes (which have negative values), C0 and Control - // character DEL - code < 32 || code === 127 - ) -} + if (util.isIdStartChar(c)) { + buffer += read(); + lexState = 'identifierName'; + return + } -var asciiControl_1 = asciiControl$3; + throw invalidChar(read()) + }, -var asciiAlpha$3 = asciiAlpha_1; -var asciiAlphanumeric$4 = asciiAlphanumeric_1; -var asciiAtext = asciiAtext_1; -var asciiControl$2 = asciiControl_1; + afterPropertyName () { + if (c === ':') { + return newToken('punctuator', read()) + } -var autolink$1 = { - name: 'autolink', - tokenize: tokenizeAutolink -}; + throw invalidChar(read()) + }, -function tokenizeAutolink(effects, ok, nok) { - var size = 1; - return start + beforePropertyValue () { + lexState = 'value'; + }, - function start(code) { - effects.enter('autolink'); - effects.enter('autolinkMarker'); - effects.consume(code); - effects.exit('autolinkMarker'); - effects.enter('autolinkProtocol'); - return open - } + afterPropertyValue () { + switch (c) { + case ',': + case '}': + return newToken('punctuator', read()) + } - function open(code) { - if (asciiAlpha$3(code)) { - effects.consume(code); - return schemeOrEmailAtext - } + throw invalidChar(read()) + }, - return asciiAtext(code) ? emailAtext(code) : nok(code) - } + beforeArrayValue () { + if (c === ']') { + return newToken('punctuator', read()) + } - function schemeOrEmailAtext(code) { - return code === 43 || code === 45 || code === 46 || asciiAlphanumeric$4(code) - ? schemeInsideOrEmailAtext(code) - : emailAtext(code) - } + lexState = 'value'; + }, - function schemeInsideOrEmailAtext(code) { - if (code === 58) { - effects.consume(code); - return urlInside - } + afterArrayValue () { + switch (c) { + case ',': + case ']': + return newToken('punctuator', read()) + } - if ( - (code === 43 || code === 45 || code === 46 || asciiAlphanumeric$4(code)) && - size++ < 32 - ) { - effects.consume(code); - return schemeInsideOrEmailAtext - } + throw invalidChar(read()) + }, - return emailAtext(code) - } + end () { + // This code is unreachable since it's handled by the default lexState. + // if (c === undefined) { + // read() + // return newToken('eof') + // } - function urlInside(code) { - if (code === 62) { - effects.exit('autolinkProtocol'); - return end(code) - } + throw invalidChar(read()) + }, +}; - if (code === 32 || code === 60 || asciiControl$2(code)) { - return nok(code) +function newToken (type, value) { + return { + type, + value, + line, + column, } +} - effects.consume(code); - return urlInside - } +function literal (s) { + for (const c of s) { + const p = peek(); - function emailAtext(code) { - if (code === 64) { - effects.consume(code); - size = 0; - return emailAtSignOrDot - } + if (p !== c) { + throw invalidChar(read()) + } - if (asciiAtext(code)) { - effects.consume(code); - return emailAtext + read(); } +} - return nok(code) - } - - function emailAtSignOrDot(code) { - return asciiAlphanumeric$4(code) ? emailLabel(code) : nok(code) - } +function escape () { + const c = peek(); + switch (c) { + case 'b': + read(); + return '\b' - function emailLabel(code) { - if (code === 46) { - effects.consume(code); - size = 0; - return emailAtSignOrDot - } + case 'f': + read(); + return '\f' - if (code === 62) { - // Exit, then change the type. - effects.exit('autolinkProtocol').type = 'autolinkEmail'; - return end(code) - } + case 'n': + read(); + return '\n' - return emailValue(code) - } + case 'r': + read(); + return '\r' - function emailValue(code) { - if ((code === 45 || asciiAlphanumeric$4(code)) && size++ < 63) { - effects.consume(code); - return code === 45 ? emailValue : emailLabel - } + case 't': + read(); + return '\t' - return nok(code) - } + case 'v': + read(); + return '\v' - function end(code) { - effects.enter('autolinkMarker'); - effects.consume(code); - effects.exit('autolinkMarker'); - effects.exit('autolink'); - return ok - } -} + case '0': + read(); + if (util.isDigit(peek())) { + throw invalidChar(read()) + } -var autolink_1 = autolink$1; + return '\0' -var markdownSpace$8 = markdownSpace_1; -var factorySpace$c = factorySpace$i; + case 'x': + read(); + return hexEscape() -var blockQuote$1 = { - name: 'blockQuote', - tokenize: tokenizeBlockQuoteStart, - continuation: { - tokenize: tokenizeBlockQuoteContinuation - }, - exit: exit$1 -}; + case 'u': + read(); + return unicodeEscape() -function tokenizeBlockQuoteStart(effects, ok, nok) { - var self = this; - return start + case '\n': + case '\u2028': + case '\u2029': + read(); + return '' - function start(code) { - if (code === 62) { - if (!self.containerState.open) { - effects.enter('blockQuote', { - _container: true - }); - self.containerState.open = true; - } + case '\r': + read(); + if (peek() === '\n') { + read(); + } - effects.enter('blockQuotePrefix'); - effects.enter('blockQuoteMarker'); - effects.consume(code); - effects.exit('blockQuoteMarker'); - return after - } + return '' - return nok(code) - } + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + throw invalidChar(read()) - function after(code) { - if (markdownSpace$8(code)) { - effects.enter('blockQuotePrefixWhitespace'); - effects.consume(code); - effects.exit('blockQuotePrefixWhitespace'); - effects.exit('blockQuotePrefix'); - return ok + case undefined: + throw invalidChar(read()) } - effects.exit('blockQuotePrefix'); - return ok(code) - } -} - -function tokenizeBlockQuoteContinuation(effects, ok, nok) { - return factorySpace$c( - effects, - effects.attempt(blockQuote$1, ok, nok), - 'linePrefix', - this.parser.constructs.disable.null.indexOf('codeIndented') > -1 - ? undefined - : 4 - ) -} - -function exit$1(effects) { - effects.exit('blockQuote'); + return read() } -var blockQuote_1 = blockQuote$1; +function hexEscape () { + let buffer = ''; + let c = peek(); -var regexCheck$3 = regexCheck_1; + if (!util.isHexDigit(c)) { + throw invalidChar(read()) + } -var asciiPunctuation$1 = regexCheck$3(/[!-/:-@[-`{-~]/); + buffer += read(); -var asciiPunctuation_1 = asciiPunctuation$1; + c = peek(); + if (!util.isHexDigit(c)) { + throw invalidChar(read()) + } -var asciiPunctuation = asciiPunctuation_1; + buffer += read(); -var characterEscape$2 = { - name: 'characterEscape', - tokenize: tokenizeCharacterEscape -}; + return String.fromCodePoint(parseInt(buffer, 16)) +} -function tokenizeCharacterEscape(effects, ok, nok) { - return start +function unicodeEscape () { + let buffer = ''; + let count = 4; - function start(code) { - effects.enter('characterEscape'); - effects.enter('escapeMarker'); - effects.consume(code); - effects.exit('escapeMarker'); - return open - } + while (count-- > 0) { + const c = peek(); + if (!util.isHexDigit(c)) { + throw invalidChar(read()) + } - function open(code) { - if (asciiPunctuation(code)) { - effects.enter('characterEscapeValue'); - effects.consume(code); - effects.exit('characterEscapeValue'); - effects.exit('characterEscape'); - return ok + buffer += read(); } - return nok(code) - } + return String.fromCodePoint(parseInt(buffer, 16)) } -var characterEscape_1 = characterEscape$2; - -const AEli$2 = "Æ"; -const AElig$2 = "Æ"; -const AM$2 = "&"; -const AMP$2 = "&"; -const Aacut$2 = "Á"; -const Aacute$2 = "Á"; -const Abreve$2 = "Ă"; -const Acir$2 = "Â"; -const Acirc$2 = "Â"; -const Acy$2 = "А"; -const Afr$2 = "𝔄"; -const Agrav$2 = "À"; -const Agrave$2 = "À"; -const Alpha$2 = "Α"; -const Amacr$2 = "Ā"; -const And$2 = "⩓"; -const Aogon$2 = "Ą"; -const Aopf$2 = "𝔸"; -const ApplyFunction$2 = "⁡"; -const Arin$2 = "Å"; -const Aring$2 = "Å"; -const Ascr$2 = "𝒜"; -const Assign$2 = "≔"; -const Atild$2 = "Ã"; -const Atilde$2 = "Ã"; -const Aum$2 = "Ä"; -const Auml$2 = "Ä"; -const Backslash$2 = "∖"; -const Barv$2 = "⫧"; -const Barwed$2 = "⌆"; -const Bcy$2 = "Б"; -const Because$2 = "∵"; -const Bernoullis$2 = "ℬ"; -const Beta$2 = "Β"; -const Bfr$2 = "𝔅"; -const Bopf$2 = "𝔹"; -const Breve$2 = "˘"; -const Bscr$2 = "ℬ"; -const Bumpeq$2 = "≎"; -const CHcy$2 = "Ч"; -const COP$2 = "©"; -const COPY$2 = "©"; -const Cacute$2 = "Ć"; -const Cap$2 = "⋒"; -const CapitalDifferentialD$2 = "ⅅ"; -const Cayleys$2 = "ℭ"; -const Ccaron$2 = "Č"; -const Ccedi$2 = "Ç"; -const Ccedil$2 = "Ç"; -const Ccirc$2 = "Ĉ"; -const Cconint$2 = "∰"; -const Cdot$2 = "Ċ"; -const Cedilla$2 = "¸"; -const CenterDot$2 = "·"; -const Cfr$2 = "ℭ"; -const Chi$2 = "Χ"; -const CircleDot$2 = "⊙"; -const CircleMinus$2 = "⊖"; -const CirclePlus$2 = "⊕"; -const CircleTimes$2 = "⊗"; -const ClockwiseContourIntegral$2 = "∲"; -const CloseCurlyDoubleQuote$2 = "”"; -const CloseCurlyQuote$2 = "’"; -const Colon$2 = "∷"; -const Colone$2 = "⩴"; -const Congruent$2 = "≡"; -const Conint$2 = "∯"; -const ContourIntegral$2 = "∮"; -const Copf$2 = "ℂ"; -const Coproduct$2 = "∐"; -const CounterClockwiseContourIntegral$2 = "∳"; -const Cross$2 = "⨯"; -const Cscr$2 = "𝒞"; -const Cup$2 = "⋓"; -const CupCap$2 = "≍"; -const DD$2 = "ⅅ"; -const DDotrahd$2 = "⤑"; -const DJcy$2 = "Ђ"; -const DScy$2 = "Ѕ"; -const DZcy$2 = "Џ"; -const Dagger$2 = "‡"; -const Darr$2 = "↡"; -const Dashv$2 = "⫤"; -const Dcaron$2 = "Ď"; -const Dcy$2 = "Д"; -const Del$2 = "∇"; -const Delta$2 = "Δ"; -const Dfr$2 = "𝔇"; -const DiacriticalAcute$2 = "´"; -const DiacriticalDot$2 = "˙"; -const DiacriticalDoubleAcute$2 = "˝"; -const DiacriticalGrave$2 = "`"; -const DiacriticalTilde$2 = "˜"; -const Diamond$2 = "⋄"; -const DifferentialD$2 = "ⅆ"; -const Dopf$2 = "𝔻"; -const Dot$2 = "¨"; -const DotDot$2 = "⃜"; -const DotEqual$2 = "≐"; -const DoubleContourIntegral$2 = "∯"; -const DoubleDot$2 = "¨"; -const DoubleDownArrow$2 = "⇓"; -const DoubleLeftArrow$2 = "⇐"; -const DoubleLeftRightArrow$2 = "⇔"; -const DoubleLeftTee$2 = "⫤"; -const DoubleLongLeftArrow$2 = "⟸"; -const DoubleLongLeftRightArrow$2 = "⟺"; -const DoubleLongRightArrow$2 = "⟹"; -const DoubleRightArrow$2 = "⇒"; -const DoubleRightTee$2 = "⊨"; -const DoubleUpArrow$2 = "⇑"; -const DoubleUpDownArrow$2 = "⇕"; -const DoubleVerticalBar$2 = "∥"; -const DownArrow$2 = "↓"; -const DownArrowBar$2 = "⤓"; -const DownArrowUpArrow$2 = "⇵"; -const DownBreve$2 = "̑"; -const DownLeftRightVector$2 = "⥐"; -const DownLeftTeeVector$2 = "⥞"; -const DownLeftVector$2 = "↽"; -const DownLeftVectorBar$2 = "⥖"; -const DownRightTeeVector$2 = "⥟"; -const DownRightVector$2 = "⇁"; -const DownRightVectorBar$2 = "⥗"; -const DownTee$2 = "⊤"; -const DownTeeArrow$2 = "↧"; -const Downarrow$2 = "⇓"; -const Dscr$2 = "𝒟"; -const Dstrok$2 = "Đ"; -const ENG$2 = "Ŋ"; -const ET$2 = "Ð"; -const ETH$2 = "Ð"; -const Eacut$2 = "É"; -const Eacute$2 = "É"; -const Ecaron$2 = "Ě"; -const Ecir$2 = "Ê"; -const Ecirc$2 = "Ê"; -const Ecy$2 = "Э"; -const Edot$2 = "Ė"; -const Efr$2 = "𝔈"; -const Egrav$2 = "È"; -const Egrave$2 = "È"; -const Element$2 = "∈"; -const Emacr$2 = "Ē"; -const EmptySmallSquare$2 = "◻"; -const EmptyVerySmallSquare$2 = "▫"; -const Eogon$2 = "Ę"; -const Eopf$2 = "𝔼"; -const Epsilon$2 = "Ε"; -const Equal$2 = "⩵"; -const EqualTilde$2 = "≂"; -const Equilibrium$2 = "⇌"; -const Escr$2 = "ℰ"; -const Esim$2 = "⩳"; -const Eta$2 = "Η"; -const Eum$2 = "Ë"; -const Euml$2 = "Ë"; -const Exists$2 = "∃"; -const ExponentialE$2 = "ⅇ"; -const Fcy$2 = "Ф"; -const Ffr$2 = "𝔉"; -const FilledSmallSquare$2 = "◼"; -const FilledVerySmallSquare$2 = "▪"; -const Fopf$2 = "𝔽"; -const ForAll$2 = "∀"; -const Fouriertrf$2 = "ℱ"; -const Fscr$2 = "ℱ"; -const GJcy$2 = "Ѓ"; -const G$2 = ">"; -const GT$2 = ">"; -const Gamma$2 = "Γ"; -const Gammad$2 = "Ϝ"; -const Gbreve$2 = "Ğ"; -const Gcedil$2 = "Ģ"; -const Gcirc$2 = "Ĝ"; -const Gcy$2 = "Г"; -const Gdot$2 = "Ġ"; -const Gfr$2 = "𝔊"; -const Gg$2 = "⋙"; -const Gopf$2 = "𝔾"; -const GreaterEqual$2 = "≥"; -const GreaterEqualLess$2 = "⋛"; -const GreaterFullEqual$2 = "≧"; -const GreaterGreater$2 = "⪢"; -const GreaterLess$2 = "≷"; -const GreaterSlantEqual$2 = "⩾"; -const GreaterTilde$2 = "≳"; -const Gscr$2 = "𝒢"; -const Gt$2 = "≫"; -const HARDcy$2 = "Ъ"; -const Hacek$2 = "ˇ"; -const Hat$2 = "^"; -const Hcirc$2 = "Ĥ"; -const Hfr$2 = "ℌ"; -const HilbertSpace$2 = "ℋ"; -const Hopf$2 = "ℍ"; -const HorizontalLine$2 = "─"; -const Hscr$2 = "ℋ"; -const Hstrok$2 = "Ħ"; -const HumpDownHump$2 = "≎"; -const HumpEqual$2 = "≏"; -const IEcy$2 = "Е"; -const IJlig$2 = "IJ"; -const IOcy$2 = "Ё"; -const Iacut$2 = "Í"; -const Iacute$2 = "Í"; -const Icir$2 = "Î"; -const Icirc$2 = "Î"; -const Icy$2 = "И"; -const Idot$2 = "İ"; -const Ifr$2 = "ℑ"; -const Igrav$2 = "Ì"; -const Igrave$2 = "Ì"; -const Im$2 = "ℑ"; -const Imacr$2 = "Ī"; -const ImaginaryI$2 = "ⅈ"; -const Implies$2 = "⇒"; -const Int$2 = "∬"; -const Integral$2 = "∫"; -const Intersection$2 = "⋂"; -const InvisibleComma$2 = "⁣"; -const InvisibleTimes$2 = "⁢"; -const Iogon$2 = "Į"; -const Iopf$2 = "𝕀"; -const Iota$2 = "Ι"; -const Iscr$2 = "ℐ"; -const Itilde$2 = "Ĩ"; -const Iukcy$2 = "І"; -const Ium$2 = "Ï"; -const Iuml$2 = "Ï"; -const Jcirc$2 = "Ĵ"; -const Jcy$2 = "Й"; -const Jfr$2 = "𝔍"; -const Jopf$2 = "𝕁"; -const Jscr$2 = "𝒥"; -const Jsercy$2 = "Ј"; -const Jukcy$2 = "Є"; -const KHcy$2 = "Х"; -const KJcy$2 = "Ќ"; -const Kappa$2 = "Κ"; -const Kcedil$2 = "Ķ"; -const Kcy$2 = "К"; -const Kfr$2 = "𝔎"; -const Kopf$2 = "𝕂"; -const Kscr$2 = "𝒦"; -const LJcy$2 = "Љ"; -const L$2 = "<"; -const LT$2 = "<"; -const Lacute$2 = "Ĺ"; -const Lambda$2 = "Λ"; -const Lang$2 = "⟪"; -const Laplacetrf$2 = "ℒ"; -const Larr$2 = "↞"; -const Lcaron$2 = "Ľ"; -const Lcedil$2 = "Ļ"; -const Lcy$2 = "Л"; -const LeftAngleBracket$2 = "⟨"; -const LeftArrow$2 = "←"; -const LeftArrowBar$2 = "⇤"; -const LeftArrowRightArrow$2 = "⇆"; -const LeftCeiling$2 = "⌈"; -const LeftDoubleBracket$2 = "⟦"; -const LeftDownTeeVector$2 = "⥡"; -const LeftDownVector$2 = "⇃"; -const LeftDownVectorBar$2 = "⥙"; -const LeftFloor$2 = "⌊"; -const LeftRightArrow$2 = "↔"; -const LeftRightVector$2 = "⥎"; -const LeftTee$2 = "⊣"; -const LeftTeeArrow$2 = "↤"; -const LeftTeeVector$2 = "⥚"; -const LeftTriangle$2 = "⊲"; -const LeftTriangleBar$2 = "⧏"; -const LeftTriangleEqual$2 = "⊴"; -const LeftUpDownVector$2 = "⥑"; -const LeftUpTeeVector$2 = "⥠"; -const LeftUpVector$2 = "↿"; -const LeftUpVectorBar$2 = "⥘"; -const LeftVector$2 = "↼"; -const LeftVectorBar$2 = "⥒"; -const Leftarrow$2 = "⇐"; -const Leftrightarrow$2 = "⇔"; -const LessEqualGreater$2 = "⋚"; -const LessFullEqual$2 = "≦"; -const LessGreater$2 = "≶"; -const LessLess$2 = "⪡"; -const LessSlantEqual$2 = "⩽"; -const LessTilde$2 = "≲"; -const Lfr$2 = "𝔏"; -const Ll$2 = "⋘"; -const Lleftarrow$2 = "⇚"; -const Lmidot$2 = "Ŀ"; -const LongLeftArrow$2 = "⟵"; -const LongLeftRightArrow$2 = "⟷"; -const LongRightArrow$2 = "⟶"; -const Longleftarrow$2 = "⟸"; -const Longleftrightarrow$2 = "⟺"; -const Longrightarrow$2 = "⟹"; -const Lopf$2 = "𝕃"; -const LowerLeftArrow$2 = "↙"; -const LowerRightArrow$2 = "↘"; -const Lscr$2 = "ℒ"; -const Lsh$2 = "↰"; -const Lstrok$2 = "Ł"; -const Lt$2 = "≪"; -const Mcy$2 = "М"; -const MediumSpace$2 = " "; -const Mellintrf$2 = "ℳ"; -const Mfr$2 = "𝔐"; -const MinusPlus$2 = "∓"; -const Mopf$2 = "𝕄"; -const Mscr$2 = "ℳ"; -const Mu$2 = "Μ"; -const NJcy$2 = "Њ"; -const Nacute$2 = "Ń"; -const Ncaron$2 = "Ň"; -const Ncedil$2 = "Ņ"; -const Ncy$2 = "Н"; -const NegativeMediumSpace$2 = "​"; -const NegativeThickSpace$2 = "​"; -const NegativeThinSpace$2 = "​"; -const NegativeVeryThinSpace$2 = "​"; -const NestedGreaterGreater$2 = "≫"; -const NestedLessLess$2 = "≪"; -const NewLine$2 = "\n"; -const Nfr$2 = "𝔑"; -const NoBreak$2 = "⁠"; -const NonBreakingSpace$2 = " "; -const Nopf$2 = "ℕ"; -const Not$2 = "⫬"; -const NotCongruent$2 = "≢"; -const NotCupCap$2 = "≭"; -const NotDoubleVerticalBar$2 = "∦"; -const NotElement$2 = "∉"; -const NotEqual$2 = "≠"; -const NotEqualTilde$2 = "≂̸"; -const NotExists$2 = "∄"; -const NotGreater$2 = "≯"; -const NotGreaterEqual$2 = "≱"; -const NotGreaterFullEqual$2 = "≧̸"; -const NotGreaterGreater$2 = "≫̸"; -const NotGreaterLess$2 = "≹"; -const NotGreaterSlantEqual$2 = "⩾̸"; -const NotGreaterTilde$2 = "≵"; -const NotHumpDownHump$2 = "≎̸"; -const NotHumpEqual$2 = "≏̸"; -const NotLeftTriangle$2 = "⋪"; -const NotLeftTriangleBar$2 = "⧏̸"; -const NotLeftTriangleEqual$2 = "⋬"; -const NotLess$2 = "≮"; -const NotLessEqual$2 = "≰"; -const NotLessGreater$2 = "≸"; -const NotLessLess$2 = "≪̸"; -const NotLessSlantEqual$2 = "⩽̸"; -const NotLessTilde$2 = "≴"; -const NotNestedGreaterGreater$2 = "⪢̸"; -const NotNestedLessLess$2 = "⪡̸"; -const NotPrecedes$2 = "⊀"; -const NotPrecedesEqual$2 = "⪯̸"; -const NotPrecedesSlantEqual$2 = "⋠"; -const NotReverseElement$2 = "∌"; -const NotRightTriangle$2 = "⋫"; -const NotRightTriangleBar$2 = "⧐̸"; -const NotRightTriangleEqual$2 = "⋭"; -const NotSquareSubset$2 = "⊏̸"; -const NotSquareSubsetEqual$2 = "⋢"; -const NotSquareSuperset$2 = "⊐̸"; -const NotSquareSupersetEqual$2 = "⋣"; -const NotSubset$2 = "⊂⃒"; -const NotSubsetEqual$2 = "⊈"; -const NotSucceeds$2 = "⊁"; -const NotSucceedsEqual$2 = "⪰̸"; -const NotSucceedsSlantEqual$2 = "⋡"; -const NotSucceedsTilde$2 = "≿̸"; -const NotSuperset$2 = "⊃⃒"; -const NotSupersetEqual$2 = "⊉"; -const NotTilde$2 = "≁"; -const NotTildeEqual$2 = "≄"; -const NotTildeFullEqual$2 = "≇"; -const NotTildeTilde$2 = "≉"; -const NotVerticalBar$2 = "∤"; -const Nscr$2 = "𝒩"; -const Ntild$2 = "Ñ"; -const Ntilde$2 = "Ñ"; -const Nu$2 = "Ν"; -const OElig$2 = "Œ"; -const Oacut$2 = "Ó"; -const Oacute$2 = "Ó"; -const Ocir$2 = "Ô"; -const Ocirc$2 = "Ô"; -const Ocy$2 = "О"; -const Odblac$2 = "Ő"; -const Ofr$2 = "𝔒"; -const Ograv$2 = "Ò"; -const Ograve$2 = "Ò"; -const Omacr$2 = "Ō"; -const Omega$2 = "Ω"; -const Omicron$2 = "Ο"; -const Oopf$2 = "𝕆"; -const OpenCurlyDoubleQuote$2 = "“"; -const OpenCurlyQuote$2 = "‘"; -const Or$2 = "⩔"; -const Oscr$2 = "𝒪"; -const Oslas$2 = "Ø"; -const Oslash$2 = "Ø"; -const Otild$2 = "Õ"; -const Otilde$2 = "Õ"; -const Otimes$2 = "⨷"; -const Oum$2 = "Ö"; -const Ouml$2 = "Ö"; -const OverBar$2 = "‾"; -const OverBrace$2 = "⏞"; -const OverBracket$2 = "⎴"; -const OverParenthesis$2 = "⏜"; -const PartialD$2 = "∂"; -const Pcy$2 = "П"; -const Pfr$2 = "𝔓"; -const Phi$2 = "Φ"; -const Pi$2 = "Π"; -const PlusMinus$2 = "±"; -const Poincareplane$2 = "ℌ"; -const Popf$2 = "ℙ"; -const Pr$2 = "⪻"; -const Precedes$2 = "≺"; -const PrecedesEqual$2 = "⪯"; -const PrecedesSlantEqual$2 = "≼"; -const PrecedesTilde$2 = "≾"; -const Prime$2 = "″"; -const Product$2 = "∏"; -const Proportion$2 = "∷"; -const Proportional$2 = "∝"; -const Pscr$2 = "𝒫"; -const Psi$2 = "Ψ"; -const QUO$2 = "\""; -const QUOT$2 = "\""; -const Qfr$2 = "𝔔"; -const Qopf$2 = "ℚ"; -const Qscr$2 = "𝒬"; -const RBarr$2 = "⤐"; -const RE$2 = "®"; -const REG$2 = "®"; -const Racute$2 = "Ŕ"; -const Rang$2 = "⟫"; -const Rarr$2 = "↠"; -const Rarrtl$2 = "⤖"; -const Rcaron$2 = "Ř"; -const Rcedil$2 = "Ŗ"; -const Rcy$2 = "Р"; -const Re$2 = "ℜ"; -const ReverseElement$2 = "∋"; -const ReverseEquilibrium$2 = "⇋"; -const ReverseUpEquilibrium$2 = "⥯"; -const Rfr$2 = "ℜ"; -const Rho$2 = "Ρ"; -const RightAngleBracket$2 = "⟩"; -const RightArrow$2 = "→"; -const RightArrowBar$2 = "⇥"; -const RightArrowLeftArrow$2 = "⇄"; -const RightCeiling$2 = "⌉"; -const RightDoubleBracket$2 = "⟧"; -const RightDownTeeVector$2 = "⥝"; -const RightDownVector$2 = "⇂"; -const RightDownVectorBar$2 = "⥕"; -const RightFloor$2 = "⌋"; -const RightTee$2 = "⊢"; -const RightTeeArrow$2 = "↦"; -const RightTeeVector$2 = "⥛"; -const RightTriangle$2 = "⊳"; -const RightTriangleBar$2 = "⧐"; -const RightTriangleEqual$2 = "⊵"; -const RightUpDownVector$2 = "⥏"; -const RightUpTeeVector$2 = "⥜"; -const RightUpVector$2 = "↾"; -const RightUpVectorBar$2 = "⥔"; -const RightVector$2 = "⇀"; -const RightVectorBar$2 = "⥓"; -const Rightarrow$2 = "⇒"; -const Ropf$2 = "ℝ"; -const RoundImplies$2 = "⥰"; -const Rrightarrow$2 = "⇛"; -const Rscr$2 = "ℛ"; -const Rsh$2 = "↱"; -const RuleDelayed$2 = "⧴"; -const SHCHcy$2 = "Щ"; -const SHcy$2 = "Ш"; -const SOFTcy$2 = "Ь"; -const Sacute$2 = "Ś"; -const Sc$2 = "⪼"; -const Scaron$2 = "Š"; -const Scedil$2 = "Ş"; -const Scirc$2 = "Ŝ"; -const Scy$2 = "С"; -const Sfr$2 = "𝔖"; -const ShortDownArrow$2 = "↓"; -const ShortLeftArrow$2 = "←"; -const ShortRightArrow$2 = "→"; -const ShortUpArrow$2 = "↑"; -const Sigma$2 = "Σ"; -const SmallCircle$2 = "∘"; -const Sopf$2 = "𝕊"; -const Sqrt$2 = "√"; -const Square$2 = "□"; -const SquareIntersection$2 = "⊓"; -const SquareSubset$2 = "⊏"; -const SquareSubsetEqual$2 = "⊑"; -const SquareSuperset$2 = "⊐"; -const SquareSupersetEqual$2 = "⊒"; -const SquareUnion$2 = "⊔"; -const Sscr$2 = "𝒮"; -const Star$2 = "⋆"; -const Sub$2 = "⋐"; -const Subset$2 = "⋐"; -const SubsetEqual$2 = "⊆"; -const Succeeds$2 = "≻"; -const SucceedsEqual$2 = "⪰"; -const SucceedsSlantEqual$2 = "≽"; -const SucceedsTilde$2 = "≿"; -const SuchThat$2 = "∋"; -const Sum$2 = "∑"; -const Sup$2 = "⋑"; -const Superset$2 = "⊃"; -const SupersetEqual$2 = "⊇"; -const Supset$2 = "⋑"; -const THOR$2 = "Þ"; -const THORN$2 = "Þ"; -const TRADE$2 = "™"; -const TSHcy$2 = "Ћ"; -const TScy$2 = "Ц"; -const Tab$2 = "\t"; -const Tau$2 = "Τ"; -const Tcaron$2 = "Ť"; -const Tcedil$2 = "Ţ"; -const Tcy$2 = "Т"; -const Tfr$2 = "𝔗"; -const Therefore$2 = "∴"; -const Theta$2 = "Θ"; -const ThickSpace$2 = "  "; -const ThinSpace$2 = " "; -const Tilde$2 = "∼"; -const TildeEqual$2 = "≃"; -const TildeFullEqual$2 = "≅"; -const TildeTilde$2 = "≈"; -const Topf$2 = "𝕋"; -const TripleDot$2 = "⃛"; -const Tscr$2 = "𝒯"; -const Tstrok$2 = "Ŧ"; -const Uacut$2 = "Ú"; -const Uacute$2 = "Ú"; -const Uarr$2 = "↟"; -const Uarrocir$2 = "⥉"; -const Ubrcy$2 = "Ў"; -const Ubreve$2 = "Ŭ"; -const Ucir$2 = "Û"; -const Ucirc$2 = "Û"; -const Ucy$2 = "У"; -const Udblac$2 = "Ű"; -const Ufr$2 = "𝔘"; -const Ugrav$2 = "Ù"; -const Ugrave$2 = "Ù"; -const Umacr$2 = "Ū"; -const UnderBar$2 = "_"; -const UnderBrace$2 = "⏟"; -const UnderBracket$2 = "⎵"; -const UnderParenthesis$2 = "⏝"; -const Union$2 = "⋃"; -const UnionPlus$2 = "⊎"; -const Uogon$2 = "Ų"; -const Uopf$2 = "𝕌"; -const UpArrow$2 = "↑"; -const UpArrowBar$2 = "⤒"; -const UpArrowDownArrow$2 = "⇅"; -const UpDownArrow$2 = "↕"; -const UpEquilibrium$2 = "⥮"; -const UpTee$2 = "⊥"; -const UpTeeArrow$2 = "↥"; -const Uparrow$2 = "⇑"; -const Updownarrow$2 = "⇕"; -const UpperLeftArrow$2 = "↖"; -const UpperRightArrow$2 = "↗"; -const Upsi$2 = "ϒ"; -const Upsilon$2 = "Υ"; -const Uring$2 = "Ů"; -const Uscr$2 = "𝒰"; -const Utilde$2 = "Ũ"; -const Uum$2 = "Ü"; -const Uuml$2 = "Ü"; -const VDash$2 = "⊫"; -const Vbar$2 = "⫫"; -const Vcy$2 = "В"; -const Vdash$2 = "⊩"; -const Vdashl$2 = "⫦"; -const Vee$2 = "⋁"; -const Verbar$2 = "‖"; -const Vert$2 = "‖"; -const VerticalBar$2 = "∣"; -const VerticalLine$2 = "|"; -const VerticalSeparator$2 = "❘"; -const VerticalTilde$2 = "≀"; -const VeryThinSpace$2 = " "; -const Vfr$2 = "𝔙"; -const Vopf$2 = "𝕍"; -const Vscr$2 = "𝒱"; -const Vvdash$2 = "⊪"; -const Wcirc$2 = "Ŵ"; -const Wedge$2 = "⋀"; -const Wfr$2 = "𝔚"; -const Wopf$2 = "𝕎"; -const Wscr$2 = "𝒲"; -const Xfr$2 = "𝔛"; -const Xi$2 = "Ξ"; -const Xopf$2 = "𝕏"; -const Xscr$2 = "𝒳"; -const YAcy$2 = "Я"; -const YIcy$2 = "Ї"; -const YUcy$2 = "Ю"; -const Yacut$2 = "Ý"; -const Yacute$2 = "Ý"; -const Ycirc$2 = "Ŷ"; -const Ycy$2 = "Ы"; -const Yfr$2 = "𝔜"; -const Yopf$2 = "𝕐"; -const Yscr$2 = "𝒴"; -const Yuml$2 = "Ÿ"; -const ZHcy$2 = "Ж"; -const Zacute$2 = "Ź"; -const Zcaron$2 = "Ž"; -const Zcy$2 = "З"; -const Zdot$2 = "Ż"; -const ZeroWidthSpace$2 = "​"; -const Zeta$2 = "Ζ"; -const Zfr$2 = "ℨ"; -const Zopf$2 = "ℤ"; -const Zscr$2 = "𝒵"; -const aacut$2 = "á"; -const aacute$2 = "á"; -const abreve$2 = "ă"; -const ac$2 = "∾"; -const acE$2 = "∾̳"; -const acd$2 = "∿"; -const acir$2 = "â"; -const acirc$2 = "â"; -const acut$2 = "´"; -const acute$2 = "´"; -const acy$2 = "а"; -const aeli$2 = "æ"; -const aelig$2 = "æ"; -const af$2 = "⁡"; -const afr$2 = "𝔞"; -const agrav$2 = "à"; -const agrave$2 = "à"; -const alefsym$2 = "ℵ"; -const aleph$2 = "ℵ"; -const alpha$2 = "α"; -const amacr$2 = "ā"; -const amalg$2 = "⨿"; -const am$2 = "&"; -const amp$2 = "&"; -const and$2 = "∧"; -const andand$2 = "⩕"; -const andd$2 = "⩜"; -const andslope$2 = "⩘"; -const andv$2 = "⩚"; -const ang$2 = "∠"; -const ange$2 = "⦤"; -const angle$2 = "∠"; -const angmsd$2 = "∡"; -const angmsdaa$2 = "⦨"; -const angmsdab$2 = "⦩"; -const angmsdac$2 = "⦪"; -const angmsdad$2 = "⦫"; -const angmsdae$2 = "⦬"; -const angmsdaf$2 = "⦭"; -const angmsdag$2 = "⦮"; -const angmsdah$2 = "⦯"; -const angrt$2 = "∟"; -const angrtvb$2 = "⊾"; -const angrtvbd$2 = "⦝"; -const angsph$2 = "∢"; -const angst$2 = "Å"; -const angzarr$2 = "⍼"; -const aogon$2 = "ą"; -const aopf$2 = "𝕒"; -const ap$2 = "≈"; -const apE$2 = "⩰"; -const apacir$2 = "⩯"; -const ape$2 = "≊"; -const apid$2 = "≋"; -const apos$2 = "'"; -const approx$2 = "≈"; -const approxeq$2 = "≊"; -const arin$2 = "å"; -const aring$2 = "å"; -const ascr$2 = "𝒶"; -const ast$2 = "*"; -const asymp$2 = "≈"; -const asympeq$2 = "≍"; -const atild$2 = "ã"; -const atilde$2 = "ã"; -const aum$2 = "ä"; -const auml$2 = "ä"; -const awconint$2 = "∳"; -const awint$2 = "⨑"; -const bNot$2 = "⫭"; -const backcong$2 = "≌"; -const backepsilon$2 = "϶"; -const backprime$2 = "‵"; -const backsim$2 = "∽"; -const backsimeq$2 = "⋍"; -const barvee$2 = "⊽"; -const barwed$2 = "⌅"; -const barwedge$2 = "⌅"; -const bbrk$2 = "⎵"; -const bbrktbrk$2 = "⎶"; -const bcong$2 = "≌"; -const bcy$2 = "б"; -const bdquo$2 = "„"; -const becaus$2 = "∵"; -const because$2 = "∵"; -const bemptyv$2 = "⦰"; -const bepsi$2 = "϶"; -const bernou$2 = "ℬ"; -const beta$2 = "β"; -const beth$2 = "ℶ"; -const between$2 = "≬"; -const bfr$2 = "𝔟"; -const bigcap$2 = "⋂"; -const bigcirc$2 = "◯"; -const bigcup$2 = "⋃"; -const bigodot$2 = "⨀"; -const bigoplus$2 = "⨁"; -const bigotimes$2 = "⨂"; -const bigsqcup$2 = "⨆"; -const bigstar$2 = "★"; -const bigtriangledown$2 = "▽"; -const bigtriangleup$2 = "△"; -const biguplus$2 = "⨄"; -const bigvee$2 = "⋁"; -const bigwedge$2 = "⋀"; -const bkarow$2 = "⤍"; -const blacklozenge$2 = "⧫"; -const blacksquare$2 = "▪"; -const blacktriangle$2 = "▴"; -const blacktriangledown$2 = "▾"; -const blacktriangleleft$2 = "◂"; -const blacktriangleright$2 = "▸"; -const blank$2 = "␣"; -const blk12$2 = "▒"; -const blk14$2 = "░"; -const blk34$2 = "▓"; -const block$2 = "█"; -const bne$2 = "=⃥"; -const bnequiv$2 = "≡⃥"; -const bnot$2 = "⌐"; -const bopf$2 = "𝕓"; -const bot$2 = "⊥"; -const bottom$2 = "⊥"; -const bowtie$2 = "⋈"; -const boxDL$2 = "╗"; -const boxDR$2 = "╔"; -const boxDl$2 = "╖"; -const boxDr$2 = "╓"; -const boxH$2 = "═"; -const boxHD$2 = "╦"; -const boxHU$2 = "╩"; -const boxHd$2 = "╤"; -const boxHu$2 = "╧"; -const boxUL$2 = "╝"; -const boxUR$2 = "╚"; -const boxUl$2 = "╜"; -const boxUr$2 = "╙"; -const boxV$2 = "║"; -const boxVH$2 = "╬"; -const boxVL$2 = "╣"; -const boxVR$2 = "╠"; -const boxVh$2 = "╫"; -const boxVl$2 = "╢"; -const boxVr$2 = "╟"; -const boxbox$2 = "⧉"; -const boxdL$2 = "╕"; -const boxdR$2 = "╒"; -const boxdl$2 = "┐"; -const boxdr$2 = "┌"; -const boxh$2 = "─"; -const boxhD$2 = "╥"; -const boxhU$2 = "╨"; -const boxhd$2 = "┬"; -const boxhu$2 = "┴"; -const boxminus$2 = "⊟"; -const boxplus$2 = "⊞"; -const boxtimes$2 = "⊠"; -const boxuL$2 = "╛"; -const boxuR$2 = "╘"; -const boxul$2 = "┘"; -const boxur$2 = "└"; -const boxv$2 = "│"; -const boxvH$2 = "╪"; -const boxvL$2 = "╡"; -const boxvR$2 = "╞"; -const boxvh$2 = "┼"; -const boxvl$2 = "┤"; -const boxvr$2 = "├"; -const bprime$2 = "‵"; -const breve$2 = "˘"; -const brvba$2 = "¦"; -const brvbar$2 = "¦"; -const bscr$2 = "𝒷"; -const bsemi$2 = "⁏"; -const bsim$2 = "∽"; -const bsime$2 = "⋍"; -const bsol$2 = "\\"; -const bsolb$2 = "⧅"; -const bsolhsub$2 = "⟈"; -const bull$2 = "•"; -const bullet$2 = "•"; -const bump$2 = "≎"; -const bumpE$2 = "⪮"; -const bumpe$2 = "≏"; -const bumpeq$2 = "≏"; -const cacute$2 = "ć"; -const cap$2 = "∩"; -const capand$2 = "⩄"; -const capbrcup$2 = "⩉"; -const capcap$2 = "⩋"; -const capcup$2 = "⩇"; -const capdot$2 = "⩀"; -const caps$2 = "∩︀"; -const caret$2 = "⁁"; -const caron$2 = "ˇ"; -const ccaps$2 = "⩍"; -const ccaron$2 = "č"; -const ccedi$2 = "ç"; -const ccedil$2 = "ç"; -const ccirc$2 = "ĉ"; -const ccups$2 = "⩌"; -const ccupssm$2 = "⩐"; -const cdot$2 = "ċ"; -const cedi$2 = "¸"; -const cedil$2 = "¸"; -const cemptyv$2 = "⦲"; -const cen$2 = "¢"; -const cent$2 = "¢"; -const centerdot$2 = "·"; -const cfr$2 = "𝔠"; -const chcy$2 = "ч"; -const check$3 = "✓"; -const checkmark$2 = "✓"; -const chi$2 = "χ"; -const cir$2 = "○"; -const cirE$2 = "⧃"; -const circ$2 = "ˆ"; -const circeq$2 = "≗"; -const circlearrowleft$2 = "↺"; -const circlearrowright$2 = "↻"; -const circledR$2 = "®"; -const circledS$2 = "Ⓢ"; -const circledast$2 = "⊛"; -const circledcirc$2 = "⊚"; -const circleddash$2 = "⊝"; -const cire$2 = "≗"; -const cirfnint$2 = "⨐"; -const cirmid$2 = "⫯"; -const cirscir$2 = "⧂"; -const clubs$2 = "♣"; -const clubsuit$2 = "♣"; -const colon$2 = ":"; -const colone$2 = "≔"; -const coloneq$2 = "≔"; -const comma$2 = ","; -const commat$2 = "@"; -const comp$2 = "∁"; -const compfn$2 = "∘"; -const complement$2 = "∁"; -const complexes$2 = "ℂ"; -const cong$2 = "≅"; -const congdot$2 = "⩭"; -const conint$2 = "∮"; -const copf$2 = "𝕔"; -const coprod$2 = "∐"; -const cop$2 = "©"; -const copy$2 = "©"; -const copysr$2 = "℗"; -const crarr$2 = "↵"; -const cross$2 = "✗"; -const cscr$2 = "𝒸"; -const csub$2 = "⫏"; -const csube$2 = "⫑"; -const csup$2 = "⫐"; -const csupe$2 = "⫒"; -const ctdot$2 = "⋯"; -const cudarrl$2 = "⤸"; -const cudarrr$2 = "⤵"; -const cuepr$2 = "⋞"; -const cuesc$2 = "⋟"; -const cularr$2 = "↶"; -const cularrp$2 = "⤽"; -const cup$2 = "∪"; -const cupbrcap$2 = "⩈"; -const cupcap$2 = "⩆"; -const cupcup$2 = "⩊"; -const cupdot$2 = "⊍"; -const cupor$2 = "⩅"; -const cups$2 = "∪︀"; -const curarr$2 = "↷"; -const curarrm$2 = "⤼"; -const curlyeqprec$2 = "⋞"; -const curlyeqsucc$2 = "⋟"; -const curlyvee$2 = "⋎"; -const curlywedge$2 = "⋏"; -const curre$2 = "¤"; -const curren$2 = "¤"; -const curvearrowleft$2 = "↶"; -const curvearrowright$2 = "↷"; -const cuvee$2 = "⋎"; -const cuwed$2 = "⋏"; -const cwconint$2 = "∲"; -const cwint$2 = "∱"; -const cylcty$2 = "⌭"; -const dArr$2 = "⇓"; -const dHar$2 = "⥥"; -const dagger$2 = "†"; -const daleth$2 = "ℸ"; -const darr$2 = "↓"; -const dash$2 = "‐"; -const dashv$2 = "⊣"; -const dbkarow$2 = "⤏"; -const dblac$2 = "˝"; -const dcaron$2 = "ď"; -const dcy$2 = "д"; -const dd$2 = "ⅆ"; -const ddagger$2 = "‡"; -const ddarr$2 = "⇊"; -const ddotseq$2 = "⩷"; -const de$2 = "°"; -const deg$2 = "°"; -const delta$2 = "δ"; -const demptyv$2 = "⦱"; -const dfisht$2 = "⥿"; -const dfr$2 = "𝔡"; -const dharl$2 = "⇃"; -const dharr$2 = "⇂"; -const diam$2 = "⋄"; -const diamond$2 = "⋄"; -const diamondsuit$2 = "♦"; -const diams$2 = "♦"; -const die$2 = "¨"; -const digamma$2 = "ϝ"; -const disin$2 = "⋲"; -const div$2 = "÷"; -const divid$2 = "÷"; -const divide$2 = "÷"; -const divideontimes$2 = "⋇"; -const divonx$2 = "⋇"; -const djcy$2 = "ђ"; -const dlcorn$2 = "⌞"; -const dlcrop$2 = "⌍"; -const dollar$2 = "$"; -const dopf$2 = "𝕕"; -const dot$2 = "˙"; -const doteq$2 = "≐"; -const doteqdot$2 = "≑"; -const dotminus$2 = "∸"; -const dotplus$2 = "∔"; -const dotsquare$2 = "⊡"; -const doublebarwedge$2 = "⌆"; -const downarrow$2 = "↓"; -const downdownarrows$2 = "⇊"; -const downharpoonleft$2 = "⇃"; -const downharpoonright$2 = "⇂"; -const drbkarow$2 = "⤐"; -const drcorn$2 = "⌟"; -const drcrop$2 = "⌌"; -const dscr$2 = "𝒹"; -const dscy$2 = "ѕ"; -const dsol$2 = "⧶"; -const dstrok$2 = "đ"; -const dtdot$2 = "⋱"; -const dtri$2 = "▿"; -const dtrif$2 = "▾"; -const duarr$2 = "⇵"; -const duhar$2 = "⥯"; -const dwangle$2 = "⦦"; -const dzcy$2 = "џ"; -const dzigrarr$2 = "⟿"; -const eDDot$2 = "⩷"; -const eDot$2 = "≑"; -const eacut$2 = "é"; -const eacute$2 = "é"; -const easter$2 = "⩮"; -const ecaron$2 = "ě"; -const ecir$2 = "ê"; -const ecirc$2 = "ê"; -const ecolon$2 = "≕"; -const ecy$2 = "э"; -const edot$2 = "ė"; -const ee$2 = "ⅇ"; -const efDot$2 = "≒"; -const efr$2 = "𝔢"; -const eg$2 = "⪚"; -const egrav$2 = "è"; -const egrave$2 = "è"; -const egs$2 = "⪖"; -const egsdot$2 = "⪘"; -const el$2 = "⪙"; -const elinters$2 = "⏧"; -const ell$2 = "ℓ"; -const els$2 = "⪕"; -const elsdot$2 = "⪗"; -const emacr$2 = "ē"; -const empty$2 = "∅"; -const emptyset$2 = "∅"; -const emptyv$2 = "∅"; -const emsp13$2 = " "; -const emsp14$2 = " "; -const emsp$2 = " "; -const eng$2 = "ŋ"; -const ensp$2 = " "; -const eogon$2 = "ę"; -const eopf$2 = "𝕖"; -const epar$2 = "⋕"; -const eparsl$2 = "⧣"; -const eplus$2 = "⩱"; -const epsi$2 = "ε"; -const epsilon$2 = "ε"; -const epsiv$2 = "ϵ"; -const eqcirc$2 = "≖"; -const eqcolon$2 = "≕"; -const eqsim$2 = "≂"; -const eqslantgtr$2 = "⪖"; -const eqslantless$2 = "⪕"; -const equals$2 = "="; -const equest$2 = "≟"; -const equiv$2 = "≡"; -const equivDD$2 = "⩸"; -const eqvparsl$2 = "⧥"; -const erDot$2 = "≓"; -const erarr$2 = "⥱"; -const escr$2 = "ℯ"; -const esdot$2 = "≐"; -const esim$2 = "≂"; -const eta$2 = "η"; -const et$2 = "ð"; -const eth$2 = "ð"; -const eum$2 = "ë"; -const euml$2 = "ë"; -const euro$2 = "€"; -const excl$2 = "!"; -const exist$2 = "∃"; -const expectation$2 = "ℰ"; -const exponentiale$2 = "ⅇ"; -const fallingdotseq$2 = "≒"; -const fcy$2 = "ф"; -const female$2 = "♀"; -const ffilig$2 = "ffi"; -const fflig$2 = "ff"; -const ffllig$2 = "ffl"; -const ffr$2 = "𝔣"; -const filig$2 = "fi"; -const fjlig$2 = "fj"; -const flat$2 = "♭"; -const fllig$2 = "fl"; -const fltns$2 = "▱"; -const fnof$2 = "ƒ"; -const fopf$2 = "𝕗"; -const forall$2 = "∀"; -const fork$2 = "⋔"; -const forkv$2 = "⫙"; -const fpartint$2 = "⨍"; -const frac1$2 = "¼"; -const frac12$2 = "½"; -const frac13$2 = "⅓"; -const frac14$2 = "¼"; -const frac15$2 = "⅕"; -const frac16$2 = "⅙"; -const frac18$2 = "⅛"; -const frac23$2 = "⅔"; -const frac25$2 = "⅖"; -const frac3$2 = "¾"; -const frac34$2 = "¾"; -const frac35$2 = "⅗"; -const frac38$2 = "⅜"; -const frac45$2 = "⅘"; -const frac56$2 = "⅚"; -const frac58$2 = "⅝"; -const frac78$2 = "⅞"; -const frasl$2 = "⁄"; -const frown$2 = "⌢"; -const fscr$2 = "𝒻"; -const gE$2 = "≧"; -const gEl$2 = "⪌"; -const gacute$2 = "ǵ"; -const gamma$2 = "γ"; -const gammad$2 = "ϝ"; -const gap$2 = "⪆"; -const gbreve$2 = "ğ"; -const gcirc$2 = "ĝ"; -const gcy$2 = "г"; -const gdot$2 = "ġ"; -const ge$2 = "≥"; -const gel$2 = "⋛"; -const geq$2 = "≥"; -const geqq$2 = "≧"; -const geqslant$2 = "⩾"; -const ges$2 = "⩾"; -const gescc$2 = "⪩"; -const gesdot$2 = "⪀"; -const gesdoto$2 = "⪂"; -const gesdotol$2 = "⪄"; -const gesl$2 = "⋛︀"; -const gesles$2 = "⪔"; -const gfr$2 = "𝔤"; -const gg$2 = "≫"; -const ggg$2 = "⋙"; -const gimel$2 = "ℷ"; -const gjcy$2 = "ѓ"; -const gl$2 = "≷"; -const glE$2 = "⪒"; -const gla$2 = "⪥"; -const glj$2 = "⪤"; -const gnE$2 = "≩"; -const gnap$2 = "⪊"; -const gnapprox$2 = "⪊"; -const gne$2 = "⪈"; -const gneq$2 = "⪈"; -const gneqq$2 = "≩"; -const gnsim$2 = "⋧"; -const gopf$2 = "𝕘"; -const grave$2 = "`"; -const gscr$2 = "ℊ"; -const gsim$2 = "≳"; -const gsime$2 = "⪎"; -const gsiml$2 = "⪐"; -const g$2 = ">"; -const gt$2 = ">"; -const gtcc$2 = "⪧"; -const gtcir$2 = "⩺"; -const gtdot$2 = "⋗"; -const gtlPar$2 = "⦕"; -const gtquest$2 = "⩼"; -const gtrapprox$2 = "⪆"; -const gtrarr$2 = "⥸"; -const gtrdot$2 = "⋗"; -const gtreqless$2 = "⋛"; -const gtreqqless$2 = "⪌"; -const gtrless$2 = "≷"; -const gtrsim$2 = "≳"; -const gvertneqq$2 = "≩︀"; -const gvnE$2 = "≩︀"; -const hArr$2 = "⇔"; -const hairsp$2 = " "; -const half$2 = "½"; -const hamilt$2 = "ℋ"; -const hardcy$2 = "ъ"; -const harr$2 = "↔"; -const harrcir$2 = "⥈"; -const harrw$2 = "↭"; -const hbar$2 = "ℏ"; -const hcirc$2 = "ĥ"; -const hearts$2 = "♥"; -const heartsuit$2 = "♥"; -const hellip$2 = "…"; -const hercon$2 = "⊹"; -const hfr$2 = "𝔥"; -const hksearow$2 = "⤥"; -const hkswarow$2 = "⤦"; -const hoarr$2 = "⇿"; -const homtht$2 = "∻"; -const hookleftarrow$2 = "↩"; -const hookrightarrow$2 = "↪"; -const hopf$2 = "𝕙"; -const horbar$2 = "―"; -const hscr$2 = "𝒽"; -const hslash$2 = "ℏ"; -const hstrok$2 = "ħ"; -const hybull$2 = "⁃"; -const hyphen$2 = "‐"; -const iacut$2 = "í"; -const iacute$2 = "í"; -const ic$2 = "⁣"; -const icir$2 = "î"; -const icirc$2 = "î"; -const icy$2 = "и"; -const iecy$2 = "е"; -const iexc$2 = "¡"; -const iexcl$2 = "¡"; -const iff$2 = "⇔"; -const ifr$2 = "𝔦"; -const igrav$2 = "ì"; -const igrave$2 = "ì"; -const ii$2 = "ⅈ"; -const iiiint$2 = "⨌"; -const iiint$2 = "∭"; -const iinfin$2 = "⧜"; -const iiota$2 = "℩"; -const ijlig$2 = "ij"; -const imacr$2 = "ī"; -const image$3 = "ℑ"; -const imagline$2 = "ℐ"; -const imagpart$2 = "ℑ"; -const imath$2 = "ı"; -const imof$2 = "⊷"; -const imped$2 = "Ƶ"; -const incare$2 = "℅"; -const infin$2 = "∞"; -const infintie$2 = "⧝"; -const inodot$2 = "ı"; -const int$3 = "∫"; -const intcal$2 = "⊺"; -const integers$2 = "ℤ"; -const intercal$2 = "⊺"; -const intlarhk$2 = "⨗"; -const intprod$2 = "⨼"; -const iocy$2 = "ё"; -const iogon$2 = "į"; -const iopf$2 = "𝕚"; -const iota$2 = "ι"; -const iprod$2 = "⨼"; -const iques$2 = "¿"; -const iquest$2 = "¿"; -const iscr$2 = "𝒾"; -const isin$2 = "∈"; -const isinE$2 = "⋹"; -const isindot$2 = "⋵"; -const isins$2 = "⋴"; -const isinsv$2 = "⋳"; -const isinv$2 = "∈"; -const it$2 = "⁢"; -const itilde$2 = "ĩ"; -const iukcy$2 = "і"; -const ium$2 = "ï"; -const iuml$2 = "ï"; -const jcirc$2 = "ĵ"; -const jcy$2 = "й"; -const jfr$2 = "𝔧"; -const jmath$2 = "ȷ"; -const jopf$2 = "𝕛"; -const jscr$2 = "𝒿"; -const jsercy$2 = "ј"; -const jukcy$2 = "є"; -const kappa$2 = "κ"; -const kappav$2 = "ϰ"; -const kcedil$2 = "ķ"; -const kcy$2 = "к"; -const kfr$2 = "𝔨"; -const kgreen$2 = "ĸ"; -const khcy$2 = "х"; -const kjcy$2 = "ќ"; -const kopf$2 = "𝕜"; -const kscr$2 = "𝓀"; -const lAarr$2 = "⇚"; -const lArr$2 = "⇐"; -const lAtail$2 = "⤛"; -const lBarr$2 = "⤎"; -const lE$2 = "≦"; -const lEg$2 = "⪋"; -const lHar$2 = "⥢"; -const lacute$2 = "ĺ"; -const laemptyv$2 = "⦴"; -const lagran$2 = "ℒ"; -const lambda$2 = "λ"; -const lang$2 = "⟨"; -const langd$2 = "⦑"; -const langle$2 = "⟨"; -const lap$2 = "⪅"; -const laqu$2 = "«"; -const laquo$2 = "«"; -const larr$2 = "←"; -const larrb$2 = "⇤"; -const larrbfs$2 = "⤟"; -const larrfs$2 = "⤝"; -const larrhk$2 = "↩"; -const larrlp$2 = "↫"; -const larrpl$2 = "⤹"; -const larrsim$2 = "⥳"; -const larrtl$2 = "↢"; -const lat$2 = "⪫"; -const latail$2 = "⤙"; -const late$2 = "⪭"; -const lates$2 = "⪭︀"; -const lbarr$2 = "⤌"; -const lbbrk$2 = "❲"; -const lbrace$2 = "{"; -const lbrack$2 = "["; -const lbrke$2 = "⦋"; -const lbrksld$2 = "⦏"; -const lbrkslu$2 = "⦍"; -const lcaron$2 = "ľ"; -const lcedil$2 = "ļ"; -const lceil$2 = "⌈"; -const lcub$2 = "{"; -const lcy$2 = "л"; -const ldca$2 = "⤶"; -const ldquo$2 = "“"; -const ldquor$2 = "„"; -const ldrdhar$2 = "⥧"; -const ldrushar$2 = "⥋"; -const ldsh$2 = "↲"; -const le$2 = "≤"; -const leftarrow$2 = "←"; -const leftarrowtail$2 = "↢"; -const leftharpoondown$2 = "↽"; -const leftharpoonup$2 = "↼"; -const leftleftarrows$2 = "⇇"; -const leftrightarrow$2 = "↔"; -const leftrightarrows$2 = "⇆"; -const leftrightharpoons$2 = "⇋"; -const leftrightsquigarrow$2 = "↭"; -const leftthreetimes$2 = "⋋"; -const leg$2 = "⋚"; -const leq$2 = "≤"; -const leqq$2 = "≦"; -const leqslant$2 = "⩽"; -const les$2 = "⩽"; -const lescc$2 = "⪨"; -const lesdot$2 = "⩿"; -const lesdoto$2 = "⪁"; -const lesdotor$2 = "⪃"; -const lesg$2 = "⋚︀"; -const lesges$2 = "⪓"; -const lessapprox$2 = "⪅"; -const lessdot$2 = "⋖"; -const lesseqgtr$2 = "⋚"; -const lesseqqgtr$2 = "⪋"; -const lessgtr$2 = "≶"; -const lesssim$2 = "≲"; -const lfisht$2 = "⥼"; -const lfloor$2 = "⌊"; -const lfr$2 = "𝔩"; -const lg$2 = "≶"; -const lgE$2 = "⪑"; -const lhard$2 = "↽"; -const lharu$2 = "↼"; -const lharul$2 = "⥪"; -const lhblk$2 = "▄"; -const ljcy$2 = "љ"; -const ll$2 = "≪"; -const llarr$2 = "⇇"; -const llcorner$2 = "⌞"; -const llhard$2 = "⥫"; -const lltri$2 = "◺"; -const lmidot$2 = "ŀ"; -const lmoust$2 = "⎰"; -const lmoustache$2 = "⎰"; -const lnE$2 = "≨"; -const lnap$2 = "⪉"; -const lnapprox$2 = "⪉"; -const lne$2 = "⪇"; -const lneq$2 = "⪇"; -const lneqq$2 = "≨"; -const lnsim$2 = "⋦"; -const loang$2 = "⟬"; -const loarr$2 = "⇽"; -const lobrk$2 = "⟦"; -const longleftarrow$2 = "⟵"; -const longleftrightarrow$2 = "⟷"; -const longmapsto$2 = "⟼"; -const longrightarrow$2 = "⟶"; -const looparrowleft$2 = "↫"; -const looparrowright$2 = "↬"; -const lopar$2 = "⦅"; -const lopf$2 = "𝕝"; -const loplus$2 = "⨭"; -const lotimes$2 = "⨴"; -const lowast$2 = "∗"; -const lowbar$2 = "_"; -const loz$2 = "◊"; -const lozenge$2 = "◊"; -const lozf$2 = "⧫"; -const lpar$2 = "("; -const lparlt$2 = "⦓"; -const lrarr$2 = "⇆"; -const lrcorner$2 = "⌟"; -const lrhar$2 = "⇋"; -const lrhard$2 = "⥭"; -const lrm$2 = "‎"; -const lrtri$2 = "⊿"; -const lsaquo$2 = "‹"; -const lscr$2 = "𝓁"; -const lsh$2 = "↰"; -const lsim$2 = "≲"; -const lsime$2 = "⪍"; -const lsimg$2 = "⪏"; -const lsqb$2 = "["; -const lsquo$2 = "‘"; -const lsquor$2 = "‚"; -const lstrok$2 = "ł"; -const l$2 = "<"; -const lt$3 = "<"; -const ltcc$2 = "⪦"; -const ltcir$2 = "⩹"; -const ltdot$2 = "⋖"; -const lthree$2 = "⋋"; -const ltimes$2 = "⋉"; -const ltlarr$2 = "⥶"; -const ltquest$2 = "⩻"; -const ltrPar$2 = "⦖"; -const ltri$2 = "◃"; -const ltrie$2 = "⊴"; -const ltrif$2 = "◂"; -const lurdshar$2 = "⥊"; -const luruhar$2 = "⥦"; -const lvertneqq$2 = "≨︀"; -const lvnE$2 = "≨︀"; -const mDDot$2 = "∺"; -const mac$2 = "¯"; -const macr$2 = "¯"; -const male$2 = "♂"; -const malt$2 = "✠"; -const maltese$2 = "✠"; -const map$5 = "↦"; -const mapsto$2 = "↦"; -const mapstodown$2 = "↧"; -const mapstoleft$2 = "↤"; -const mapstoup$2 = "↥"; -const marker$2 = "▮"; -const mcomma$2 = "⨩"; -const mcy$2 = "м"; -const mdash$2 = "—"; -const measuredangle$2 = "∡"; -const mfr$2 = "𝔪"; -const mho$2 = "℧"; -const micr$2 = "µ"; -const micro$2 = "µ"; -const mid$2 = "∣"; -const midast$2 = "*"; -const midcir$2 = "⫰"; -const middo$2 = "·"; -const middot$2 = "·"; -const minus$2 = "−"; -const minusb$2 = "⊟"; -const minusd$2 = "∸"; -const minusdu$2 = "⨪"; -const mlcp$2 = "⫛"; -const mldr$2 = "…"; -const mnplus$2 = "∓"; -const models$2 = "⊧"; -const mopf$2 = "𝕞"; -const mp$2 = "∓"; -const mscr$2 = "𝓂"; -const mstpos$2 = "∾"; -const mu$2 = "μ"; -const multimap$2 = "⊸"; -const mumap$2 = "⊸"; -const nGg$2 = "⋙̸"; -const nGt$2 = "≫⃒"; -const nGtv$2 = "≫̸"; -const nLeftarrow$2 = "⇍"; -const nLeftrightarrow$2 = "⇎"; -const nLl$2 = "⋘̸"; -const nLt$2 = "≪⃒"; -const nLtv$2 = "≪̸"; -const nRightarrow$2 = "⇏"; -const nVDash$2 = "⊯"; -const nVdash$2 = "⊮"; -const nabla$2 = "∇"; -const nacute$2 = "ń"; -const nang$2 = "∠⃒"; -const nap$2 = "≉"; -const napE$2 = "⩰̸"; -const napid$2 = "≋̸"; -const napos$2 = "ʼn"; -const napprox$2 = "≉"; -const natur$2 = "♮"; -const natural$2 = "♮"; -const naturals$2 = "ℕ"; -const nbs$2 = " "; -const nbsp$2 = " "; -const nbump$2 = "≎̸"; -const nbumpe$2 = "≏̸"; -const ncap$2 = "⩃"; -const ncaron$2 = "ň"; -const ncedil$2 = "ņ"; -const ncong$2 = "≇"; -const ncongdot$2 = "⩭̸"; -const ncup$2 = "⩂"; -const ncy$2 = "н"; -const ndash$2 = "–"; -const ne$2 = "≠"; -const neArr$2 = "⇗"; -const nearhk$2 = "⤤"; -const nearr$2 = "↗"; -const nearrow$2 = "↗"; -const nedot$2 = "≐̸"; -const nequiv$2 = "≢"; -const nesear$2 = "⤨"; -const nesim$2 = "≂̸"; -const nexist$2 = "∄"; -const nexists$2 = "∄"; -const nfr$2 = "𝔫"; -const ngE$2 = "≧̸"; -const nge$2 = "≱"; -const ngeq$2 = "≱"; -const ngeqq$2 = "≧̸"; -const ngeqslant$2 = "⩾̸"; -const nges$2 = "⩾̸"; -const ngsim$2 = "≵"; -const ngt$2 = "≯"; -const ngtr$2 = "≯"; -const nhArr$2 = "⇎"; -const nharr$2 = "↮"; -const nhpar$2 = "⫲"; -const ni$2 = "∋"; -const nis$2 = "⋼"; -const nisd$2 = "⋺"; -const niv$2 = "∋"; -const njcy$2 = "њ"; -const nlArr$2 = "⇍"; -const nlE$2 = "≦̸"; -const nlarr$2 = "↚"; -const nldr$2 = "‥"; -const nle$2 = "≰"; -const nleftarrow$2 = "↚"; -const nleftrightarrow$2 = "↮"; -const nleq$2 = "≰"; -const nleqq$2 = "≦̸"; -const nleqslant$2 = "⩽̸"; -const nles$2 = "⩽̸"; -const nless$2 = "≮"; -const nlsim$2 = "≴"; -const nlt$2 = "≮"; -const nltri$2 = "⋪"; -const nltrie$2 = "⋬"; -const nmid$2 = "∤"; -const nopf$2 = "𝕟"; -const no$2 = "¬"; -const not$2 = "¬"; -const notin$2 = "∉"; -const notinE$2 = "⋹̸"; -const notindot$2 = "⋵̸"; -const notinva$2 = "∉"; -const notinvb$2 = "⋷"; -const notinvc$2 = "⋶"; -const notni$2 = "∌"; -const notniva$2 = "∌"; -const notnivb$2 = "⋾"; -const notnivc$2 = "⋽"; -const npar$2 = "∦"; -const nparallel$2 = "∦"; -const nparsl$2 = "⫽⃥"; -const npart$2 = "∂̸"; -const npolint$2 = "⨔"; -const npr$2 = "⊀"; -const nprcue$2 = "⋠"; -const npre$2 = "⪯̸"; -const nprec$2 = "⊀"; -const npreceq$2 = "⪯̸"; -const nrArr$2 = "⇏"; -const nrarr$2 = "↛"; -const nrarrc$2 = "⤳̸"; -const nrarrw$2 = "↝̸"; -const nrightarrow$2 = "↛"; -const nrtri$2 = "⋫"; -const nrtrie$2 = "⋭"; -const nsc$2 = "⊁"; -const nsccue$2 = "⋡"; -const nsce$2 = "⪰̸"; -const nscr$2 = "𝓃"; -const nshortmid$2 = "∤"; -const nshortparallel$2 = "∦"; -const nsim$2 = "≁"; -const nsime$2 = "≄"; -const nsimeq$2 = "≄"; -const nsmid$2 = "∤"; -const nspar$2 = "∦"; -const nsqsube$2 = "⋢"; -const nsqsupe$2 = "⋣"; -const nsub$2 = "⊄"; -const nsubE$2 = "⫅̸"; -const nsube$2 = "⊈"; -const nsubset$2 = "⊂⃒"; -const nsubseteq$2 = "⊈"; -const nsubseteqq$2 = "⫅̸"; -const nsucc$2 = "⊁"; -const nsucceq$2 = "⪰̸"; -const nsup$2 = "⊅"; -const nsupE$2 = "⫆̸"; -const nsupe$2 = "⊉"; -const nsupset$2 = "⊃⃒"; -const nsupseteq$2 = "⊉"; -const nsupseteqq$2 = "⫆̸"; -const ntgl$2 = "≹"; -const ntild$2 = "ñ"; -const ntilde$2 = "ñ"; -const ntlg$2 = "≸"; -const ntriangleleft$2 = "⋪"; -const ntrianglelefteq$2 = "⋬"; -const ntriangleright$2 = "⋫"; -const ntrianglerighteq$2 = "⋭"; -const nu$2 = "ν"; -const num$2 = "#"; -const numero$2 = "№"; -const numsp$2 = " "; -const nvDash$2 = "⊭"; -const nvHarr$2 = "⤄"; -const nvap$2 = "≍⃒"; -const nvdash$2 = "⊬"; -const nvge$2 = "≥⃒"; -const nvgt$2 = ">⃒"; -const nvinfin$2 = "⧞"; -const nvlArr$2 = "⤂"; -const nvle$2 = "≤⃒"; -const nvlt$2 = "<⃒"; -const nvltrie$2 = "⊴⃒"; -const nvrArr$2 = "⤃"; -const nvrtrie$2 = "⊵⃒"; -const nvsim$2 = "∼⃒"; -const nwArr$2 = "⇖"; -const nwarhk$2 = "⤣"; -const nwarr$2 = "↖"; -const nwarrow$2 = "↖"; -const nwnear$2 = "⤧"; -const oS$2 = "Ⓢ"; -const oacut$2 = "ó"; -const oacute$2 = "ó"; -const oast$2 = "⊛"; -const ocir$2 = "ô"; -const ocirc$2 = "ô"; -const ocy$2 = "о"; -const odash$2 = "⊝"; -const odblac$2 = "ő"; -const odiv$2 = "⨸"; -const odot$2 = "⊙"; -const odsold$2 = "⦼"; -const oelig$2 = "œ"; -const ofcir$2 = "⦿"; -const ofr$2 = "𝔬"; -const ogon$2 = "˛"; -const ograv$2 = "ò"; -const ograve$2 = "ò"; -const ogt$2 = "⧁"; -const ohbar$2 = "⦵"; -const ohm$2 = "Ω"; -const oint$2 = "∮"; -const olarr$2 = "↺"; -const olcir$2 = "⦾"; -const olcross$2 = "⦻"; -const oline$2 = "‾"; -const olt$2 = "⧀"; -const omacr$2 = "ō"; -const omega$2 = "ω"; -const omicron$2 = "ο"; -const omid$2 = "⦶"; -const ominus$2 = "⊖"; -const oopf$2 = "𝕠"; -const opar$2 = "⦷"; -const operp$2 = "⦹"; -const oplus$2 = "⊕"; -const or$2 = "∨"; -const orarr$2 = "↻"; -const ord$2 = "º"; -const order$2 = "ℴ"; -const orderof$2 = "ℴ"; -const ordf$2 = "ª"; -const ordm$2 = "º"; -const origof$2 = "⊶"; -const oror$2 = "⩖"; -const orslope$2 = "⩗"; -const orv$2 = "⩛"; -const oscr$2 = "ℴ"; -const oslas$2 = "ø"; -const oslash$2 = "ø"; -const osol$2 = "⊘"; -const otild$2 = "õ"; -const otilde$2 = "õ"; -const otimes$2 = "⊗"; -const otimesas$2 = "⨶"; -const oum$2 = "ö"; -const ouml$2 = "ö"; -const ovbar$2 = "⌽"; -const par$2 = "¶"; -const para$2 = "¶"; -const parallel$2 = "∥"; -const parsim$2 = "⫳"; -const parsl$2 = "⫽"; -const part$2 = "∂"; -const pcy$2 = "п"; -const percnt$2 = "%"; -const period$2 = "."; -const permil$2 = "‰"; -const perp$2 = "⊥"; -const pertenk$2 = "‱"; -const pfr$2 = "𝔭"; -const phi$2 = "φ"; -const phiv$2 = "ϕ"; -const phmmat$2 = "ℳ"; -const phone$2 = "☎"; -const pi$2 = "π"; -const pitchfork$2 = "⋔"; -const piv$2 = "ϖ"; -const planck$2 = "ℏ"; -const planckh$2 = "ℎ"; -const plankv$2 = "ℏ"; -const plus$2 = "+"; -const plusacir$2 = "⨣"; -const plusb$2 = "⊞"; -const pluscir$2 = "⨢"; -const plusdo$2 = "∔"; -const plusdu$2 = "⨥"; -const pluse$2 = "⩲"; -const plusm$2 = "±"; -const plusmn$2 = "±"; -const plussim$2 = "⨦"; -const plustwo$2 = "⨧"; -const pm$2 = "±"; -const pointint$2 = "⨕"; -const popf$2 = "𝕡"; -const poun$2 = "£"; -const pound$2 = "£"; -const pr$2 = "≺"; -const prE$2 = "⪳"; -const prap$2 = "⪷"; -const prcue$2 = "≼"; -const pre$2 = "⪯"; -const prec$2 = "≺"; -const precapprox$2 = "⪷"; -const preccurlyeq$2 = "≼"; -const preceq$2 = "⪯"; -const precnapprox$2 = "⪹"; -const precneqq$2 = "⪵"; -const precnsim$2 = "⋨"; -const precsim$2 = "≾"; -const prime$2 = "′"; -const primes$2 = "ℙ"; -const prnE$2 = "⪵"; -const prnap$2 = "⪹"; -const prnsim$2 = "⋨"; -const prod$2 = "∏"; -const profalar$2 = "⌮"; -const profline$2 = "⌒"; -const profsurf$2 = "⌓"; -const prop$2 = "∝"; -const propto$2 = "∝"; -const prsim$2 = "≾"; -const prurel$2 = "⊰"; -const pscr$2 = "𝓅"; -const psi$2 = "ψ"; -const puncsp$2 = " "; -const qfr$2 = "𝔮"; -const qint$2 = "⨌"; -const qopf$2 = "𝕢"; -const qprime$2 = "⁗"; -const qscr$2 = "𝓆"; -const quaternions$2 = "ℍ"; -const quatint$2 = "⨖"; -const quest$2 = "?"; -const questeq$2 = "≟"; -const quo$2 = "\""; -const quot$2 = "\""; -const rAarr$2 = "⇛"; -const rArr$2 = "⇒"; -const rAtail$2 = "⤜"; -const rBarr$2 = "⤏"; -const rHar$2 = "⥤"; -const race$2 = "∽̱"; -const racute$2 = "ŕ"; -const radic$2 = "√"; -const raemptyv$2 = "⦳"; -const rang$2 = "⟩"; -const rangd$2 = "⦒"; -const range$2 = "⦥"; -const rangle$2 = "⟩"; -const raqu$2 = "»"; -const raquo$2 = "»"; -const rarr$2 = "→"; -const rarrap$2 = "⥵"; -const rarrb$2 = "⇥"; -const rarrbfs$2 = "⤠"; -const rarrc$2 = "⤳"; -const rarrfs$2 = "⤞"; -const rarrhk$2 = "↪"; -const rarrlp$2 = "↬"; -const rarrpl$2 = "⥅"; -const rarrsim$2 = "⥴"; -const rarrtl$2 = "↣"; -const rarrw$2 = "↝"; -const ratail$2 = "⤚"; -const ratio$2 = "∶"; -const rationals$2 = "ℚ"; -const rbarr$2 = "⤍"; -const rbbrk$2 = "❳"; -const rbrace$2 = "}"; -const rbrack$2 = "]"; -const rbrke$2 = "⦌"; -const rbrksld$2 = "⦎"; -const rbrkslu$2 = "⦐"; -const rcaron$2 = "ř"; -const rcedil$2 = "ŗ"; -const rceil$2 = "⌉"; -const rcub$2 = "}"; -const rcy$2 = "р"; -const rdca$2 = "⤷"; -const rdldhar$2 = "⥩"; -const rdquo$2 = "”"; -const rdquor$2 = "”"; -const rdsh$2 = "↳"; -const real$2 = "ℜ"; -const realine$2 = "ℛ"; -const realpart$2 = "ℜ"; -const reals$2 = "ℝ"; -const rect$2 = "▭"; -const re$6 = "®"; -const reg$2 = "®"; -const rfisht$2 = "⥽"; -const rfloor$2 = "⌋"; -const rfr$2 = "𝔯"; -const rhard$2 = "⇁"; -const rharu$2 = "⇀"; -const rharul$2 = "⥬"; -const rho$2 = "ρ"; -const rhov$2 = "ϱ"; -const rightarrow$2 = "→"; -const rightarrowtail$2 = "↣"; -const rightharpoondown$2 = "⇁"; -const rightharpoonup$2 = "⇀"; -const rightleftarrows$2 = "⇄"; -const rightleftharpoons$2 = "⇌"; -const rightrightarrows$2 = "⇉"; -const rightsquigarrow$2 = "↝"; -const rightthreetimes$2 = "⋌"; -const ring$2 = "˚"; -const risingdotseq$2 = "≓"; -const rlarr$2 = "⇄"; -const rlhar$2 = "⇌"; -const rlm$2 = "‏"; -const rmoust$2 = "⎱"; -const rmoustache$2 = "⎱"; -const rnmid$2 = "⫮"; -const roang$2 = "⟭"; -const roarr$2 = "⇾"; -const robrk$2 = "⟧"; -const ropar$2 = "⦆"; -const ropf$2 = "𝕣"; -const roplus$2 = "⨮"; -const rotimes$2 = "⨵"; -const rpar$2 = ")"; -const rpargt$2 = "⦔"; -const rppolint$2 = "⨒"; -const rrarr$2 = "⇉"; -const rsaquo$2 = "›"; -const rscr$2 = "𝓇"; -const rsh$2 = "↱"; -const rsqb$2 = "]"; -const rsquo$2 = "’"; -const rsquor$2 = "’"; -const rthree$2 = "⋌"; -const rtimes$2 = "⋊"; -const rtri$2 = "▹"; -const rtrie$2 = "⊵"; -const rtrif$2 = "▸"; -const rtriltri$2 = "⧎"; -const ruluhar$2 = "⥨"; -const rx$2 = "℞"; -const sacute$2 = "ś"; -const sbquo$2 = "‚"; -const sc$2 = "≻"; -const scE$2 = "⪴"; -const scap$2 = "⪸"; -const scaron$2 = "š"; -const sccue$2 = "≽"; -const sce$2 = "⪰"; -const scedil$2 = "ş"; -const scirc$2 = "ŝ"; -const scnE$2 = "⪶"; -const scnap$2 = "⪺"; -const scnsim$2 = "⋩"; -const scpolint$2 = "⨓"; -const scsim$2 = "≿"; -const scy$2 = "с"; -const sdot$2 = "⋅"; -const sdotb$2 = "⊡"; -const sdote$2 = "⩦"; -const seArr$2 = "⇘"; -const searhk$2 = "⤥"; -const searr$2 = "↘"; -const searrow$2 = "↘"; -const sec$2 = "§"; -const sect$2 = "§"; -const semi$2 = ";"; -const seswar$2 = "⤩"; -const setminus$2 = "∖"; -const setmn$2 = "∖"; -const sext$2 = "✶"; -const sfr$2 = "𝔰"; -const sfrown$2 = "⌢"; -const sharp$2 = "♯"; -const shchcy$2 = "щ"; -const shcy$2 = "ш"; -const shortmid$2 = "∣"; -const shortparallel$2 = "∥"; -const sh$2 = "­"; -const shy$2 = "­"; -const sigma$2 = "σ"; -const sigmaf$2 = "ς"; -const sigmav$2 = "ς"; -const sim$2 = "∼"; -const simdot$2 = "⩪"; -const sime$2 = "≃"; -const simeq$2 = "≃"; -const simg$2 = "⪞"; -const simgE$2 = "⪠"; -const siml$2 = "⪝"; -const simlE$2 = "⪟"; -const simne$2 = "≆"; -const simplus$2 = "⨤"; -const simrarr$2 = "⥲"; -const slarr$2 = "←"; -const smallsetminus$2 = "∖"; -const smashp$2 = "⨳"; -const smeparsl$2 = "⧤"; -const smid$2 = "∣"; -const smile$2 = "⌣"; -const smt$2 = "⪪"; -const smte$2 = "⪬"; -const smtes$2 = "⪬︀"; -const softcy$2 = "ь"; -const sol$2 = "/"; -const solb$2 = "⧄"; -const solbar$2 = "⌿"; -const sopf$2 = "𝕤"; -const spades$2 = "♠"; -const spadesuit$2 = "♠"; -const spar$2 = "∥"; -const sqcap$2 = "⊓"; -const sqcaps$2 = "⊓︀"; -const sqcup$2 = "⊔"; -const sqcups$2 = "⊔︀"; -const sqsub$2 = "⊏"; -const sqsube$2 = "⊑"; -const sqsubset$2 = "⊏"; -const sqsubseteq$2 = "⊑"; -const sqsup$2 = "⊐"; -const sqsupe$2 = "⊒"; -const sqsupset$2 = "⊐"; -const sqsupseteq$2 = "⊒"; -const squ$2 = "□"; -const square$2 = "□"; -const squarf$2 = "▪"; -const squf$2 = "▪"; -const srarr$2 = "→"; -const sscr$2 = "𝓈"; -const ssetmn$2 = "∖"; -const ssmile$2 = "⌣"; -const sstarf$2 = "⋆"; -const star$2 = "☆"; -const starf$2 = "★"; -const straightepsilon$2 = "ϵ"; -const straightphi$2 = "ϕ"; -const strns$2 = "¯"; -const sub$2 = "⊂"; -const subE$2 = "⫅"; -const subdot$2 = "⪽"; -const sube$2 = "⊆"; -const subedot$2 = "⫃"; -const submult$2 = "⫁"; -const subnE$2 = "⫋"; -const subne$2 = "⊊"; -const subplus$2 = "⪿"; -const subrarr$2 = "⥹"; -const subset$2 = "⊂"; -const subseteq$2 = "⊆"; -const subseteqq$2 = "⫅"; -const subsetneq$2 = "⊊"; -const subsetneqq$2 = "⫋"; -const subsim$2 = "⫇"; -const subsub$2 = "⫕"; -const subsup$2 = "⫓"; -const succ$2 = "≻"; -const succapprox$2 = "⪸"; -const succcurlyeq$2 = "≽"; -const succeq$2 = "⪰"; -const succnapprox$2 = "⪺"; -const succneqq$2 = "⪶"; -const succnsim$2 = "⋩"; -const succsim$2 = "≿"; -const sum$2 = "∑"; -const sung$2 = "♪"; -const sup$2 = "⊃"; -const sup1$2 = "¹"; -const sup2$2 = "²"; -const sup3$2 = "³"; -const supE$2 = "⫆"; -const supdot$2 = "⪾"; -const supdsub$2 = "⫘"; -const supe$2 = "⊇"; -const supedot$2 = "⫄"; -const suphsol$2 = "⟉"; -const suphsub$2 = "⫗"; -const suplarr$2 = "⥻"; -const supmult$2 = "⫂"; -const supnE$2 = "⫌"; -const supne$2 = "⊋"; -const supplus$2 = "⫀"; -const supset$2 = "⊃"; -const supseteq$2 = "⊇"; -const supseteqq$2 = "⫆"; -const supsetneq$2 = "⊋"; -const supsetneqq$2 = "⫌"; -const supsim$2 = "⫈"; -const supsub$2 = "⫔"; -const supsup$2 = "⫖"; -const swArr$2 = "⇙"; -const swarhk$2 = "⤦"; -const swarr$2 = "↙"; -const swarrow$2 = "↙"; -const swnwar$2 = "⤪"; -const szli$2 = "ß"; -const szlig$2 = "ß"; -const target$2 = "⌖"; -const tau$2 = "τ"; -const tbrk$2 = "⎴"; -const tcaron$2 = "ť"; -const tcedil$2 = "ţ"; -const tcy$2 = "т"; -const tdot$2 = "⃛"; -const telrec$2 = "⌕"; -const tfr$2 = "𝔱"; -const there4$2 = "∴"; -const therefore$2 = "∴"; -const theta$2 = "θ"; -const thetasym$2 = "ϑ"; -const thetav$2 = "ϑ"; -const thickapprox$2 = "≈"; -const thicksim$2 = "∼"; -const thinsp$2 = " "; -const thkap$2 = "≈"; -const thksim$2 = "∼"; -const thor$2 = "þ"; -const thorn$2 = "þ"; -const tilde$2 = "˜"; -const time$2 = "×"; -const times$2 = "×"; -const timesb$2 = "⊠"; -const timesbar$2 = "⨱"; -const timesd$2 = "⨰"; -const tint$2 = "∭"; -const toea$2 = "⤨"; -const top$2 = "⊤"; -const topbot$2 = "⌶"; -const topcir$2 = "⫱"; -const topf$2 = "𝕥"; -const topfork$2 = "⫚"; -const tosa$2 = "⤩"; -const tprime$2 = "‴"; -const trade$2 = "™"; -const triangle$2 = "▵"; -const triangledown$2 = "▿"; -const triangleleft$2 = "◃"; -const trianglelefteq$2 = "⊴"; -const triangleq$2 = "≜"; -const triangleright$2 = "▹"; -const trianglerighteq$2 = "⊵"; -const tridot$2 = "◬"; -const trie$2 = "≜"; -const triminus$2 = "⨺"; -const triplus$2 = "⨹"; -const trisb$2 = "⧍"; -const tritime$2 = "⨻"; -const trpezium$2 = "⏢"; -const tscr$2 = "𝓉"; -const tscy$2 = "ц"; -const tshcy$2 = "ћ"; -const tstrok$2 = "ŧ"; -const twixt$2 = "≬"; -const twoheadleftarrow$2 = "↞"; -const twoheadrightarrow$2 = "↠"; -const uArr$2 = "⇑"; -const uHar$2 = "⥣"; -const uacut$2 = "ú"; -const uacute$2 = "ú"; -const uarr$2 = "↑"; -const ubrcy$2 = "ў"; -const ubreve$2 = "ŭ"; -const ucir$2 = "û"; -const ucirc$2 = "û"; -const ucy$2 = "у"; -const udarr$2 = "⇅"; -const udblac$2 = "ű"; -const udhar$2 = "⥮"; -const ufisht$2 = "⥾"; -const ufr$2 = "𝔲"; -const ugrav$2 = "ù"; -const ugrave$2 = "ù"; -const uharl$2 = "↿"; -const uharr$2 = "↾"; -const uhblk$2 = "▀"; -const ulcorn$2 = "⌜"; -const ulcorner$2 = "⌜"; -const ulcrop$2 = "⌏"; -const ultri$2 = "◸"; -const umacr$2 = "ū"; -const um$2 = "¨"; -const uml$2 = "¨"; -const uogon$2 = "ų"; -const uopf$2 = "𝕦"; -const uparrow$2 = "↑"; -const updownarrow$2 = "↕"; -const upharpoonleft$2 = "↿"; -const upharpoonright$2 = "↾"; -const uplus$2 = "⊎"; -const upsi$2 = "υ"; -const upsih$2 = "ϒ"; -const upsilon$2 = "υ"; -const upuparrows$2 = "⇈"; -const urcorn$2 = "⌝"; -const urcorner$2 = "⌝"; -const urcrop$2 = "⌎"; -const uring$2 = "ů"; -const urtri$2 = "◹"; -const uscr$2 = "𝓊"; -const utdot$2 = "⋰"; -const utilde$2 = "ũ"; -const utri$2 = "▵"; -const utrif$2 = "▴"; -const uuarr$2 = "⇈"; -const uum$2 = "ü"; -const uuml$2 = "ü"; -const uwangle$2 = "⦧"; -const vArr$2 = "⇕"; -const vBar$2 = "⫨"; -const vBarv$2 = "⫩"; -const vDash$2 = "⊨"; -const vangrt$2 = "⦜"; -const varepsilon$2 = "ϵ"; -const varkappa$2 = "ϰ"; -const varnothing$2 = "∅"; -const varphi$2 = "ϕ"; -const varpi$2 = "ϖ"; -const varpropto$2 = "∝"; -const varr$2 = "↕"; -const varrho$2 = "ϱ"; -const varsigma$2 = "ς"; -const varsubsetneq$2 = "⊊︀"; -const varsubsetneqq$2 = "⫋︀"; -const varsupsetneq$2 = "⊋︀"; -const varsupsetneqq$2 = "⫌︀"; -const vartheta$2 = "ϑ"; -const vartriangleleft$2 = "⊲"; -const vartriangleright$2 = "⊳"; -const vcy$2 = "в"; -const vdash$2 = "⊢"; -const vee$2 = "∨"; -const veebar$2 = "⊻"; -const veeeq$2 = "≚"; -const vellip$2 = "⋮"; -const verbar$2 = "|"; -const vert$2 = "|"; -const vfr$2 = "𝔳"; -const vltri$2 = "⊲"; -const vnsub$2 = "⊂⃒"; -const vnsup$2 = "⊃⃒"; -const vopf$2 = "𝕧"; -const vprop$2 = "∝"; -const vrtri$2 = "⊳"; -const vscr$2 = "𝓋"; -const vsubnE$2 = "⫋︀"; -const vsubne$2 = "⊊︀"; -const vsupnE$2 = "⫌︀"; -const vsupne$2 = "⊋︀"; -const vzigzag$2 = "⦚"; -const wcirc$2 = "ŵ"; -const wedbar$2 = "⩟"; -const wedge$2 = "∧"; -const wedgeq$2 = "≙"; -const weierp$2 = "℘"; -const wfr$2 = "𝔴"; -const wopf$2 = "𝕨"; -const wp$2 = "℘"; -const wr$2 = "≀"; -const wreath$2 = "≀"; -const wscr$2 = "𝓌"; -const xcap$2 = "⋂"; -const xcirc$2 = "◯"; -const xcup$2 = "⋃"; -const xdtri$2 = "▽"; -const xfr$2 = "𝔵"; -const xhArr$2 = "⟺"; -const xharr$2 = "⟷"; -const xi$2 = "ξ"; -const xlArr$2 = "⟸"; -const xlarr$2 = "⟵"; -const xmap$2 = "⟼"; -const xnis$2 = "⋻"; -const xodot$2 = "⨀"; -const xopf$2 = "𝕩"; -const xoplus$2 = "⨁"; -const xotime$2 = "⨂"; -const xrArr$2 = "⟹"; -const xrarr$2 = "⟶"; -const xscr$2 = "𝓍"; -const xsqcup$2 = "⨆"; -const xuplus$2 = "⨄"; -const xutri$2 = "△"; -const xvee$2 = "⋁"; -const xwedge$2 = "⋀"; -const yacut$2 = "ý"; -const yacute$2 = "ý"; -const yacy$2 = "я"; -const ycirc$2 = "ŷ"; -const ycy$2 = "ы"; -const ye$2 = "¥"; -const yen$2 = "¥"; -const yfr$2 = "𝔶"; -const yicy$2 = "ї"; -const yopf$2 = "𝕪"; -const yscr$2 = "𝓎"; -const yucy$2 = "ю"; -const yum$2 = "ÿ"; -const yuml$2 = "ÿ"; -const zacute$2 = "ź"; -const zcaron$2 = "ž"; -const zcy$2 = "з"; -const zdot$2 = "ż"; -const zeetrf$2 = "ℨ"; -const zeta$2 = "ζ"; -const zfr$2 = "𝔷"; -const zhcy$2 = "ж"; -const zigrarr$2 = "⇝"; -const zopf$2 = "𝕫"; -const zscr$2 = "𝓏"; -const zwj$2 = "‍"; -const zwnj$2 = "‌"; -var require$$0$2 = { - AEli: AEli$2, - AElig: AElig$2, - AM: AM$2, - AMP: AMP$2, - Aacut: Aacut$2, - Aacute: Aacute$2, - Abreve: Abreve$2, - Acir: Acir$2, - Acirc: Acirc$2, - Acy: Acy$2, - Afr: Afr$2, - Agrav: Agrav$2, - Agrave: Agrave$2, - Alpha: Alpha$2, - Amacr: Amacr$2, - And: And$2, - Aogon: Aogon$2, - Aopf: Aopf$2, - ApplyFunction: ApplyFunction$2, - Arin: Arin$2, - Aring: Aring$2, - Ascr: Ascr$2, - Assign: Assign$2, - Atild: Atild$2, - Atilde: Atilde$2, - Aum: Aum$2, - Auml: Auml$2, - Backslash: Backslash$2, - Barv: Barv$2, - Barwed: Barwed$2, - Bcy: Bcy$2, - Because: Because$2, - Bernoullis: Bernoullis$2, - Beta: Beta$2, - Bfr: Bfr$2, - Bopf: Bopf$2, - Breve: Breve$2, - Bscr: Bscr$2, - Bumpeq: Bumpeq$2, - CHcy: CHcy$2, - COP: COP$2, - COPY: COPY$2, - Cacute: Cacute$2, - Cap: Cap$2, - CapitalDifferentialD: CapitalDifferentialD$2, - Cayleys: Cayleys$2, - Ccaron: Ccaron$2, - Ccedi: Ccedi$2, - Ccedil: Ccedil$2, - Ccirc: Ccirc$2, - Cconint: Cconint$2, - Cdot: Cdot$2, - Cedilla: Cedilla$2, - CenterDot: CenterDot$2, - Cfr: Cfr$2, - Chi: Chi$2, - CircleDot: CircleDot$2, - CircleMinus: CircleMinus$2, - CirclePlus: CirclePlus$2, - CircleTimes: CircleTimes$2, - ClockwiseContourIntegral: ClockwiseContourIntegral$2, - CloseCurlyDoubleQuote: CloseCurlyDoubleQuote$2, - CloseCurlyQuote: CloseCurlyQuote$2, - Colon: Colon$2, - Colone: Colone$2, - Congruent: Congruent$2, - Conint: Conint$2, - ContourIntegral: ContourIntegral$2, - Copf: Copf$2, - Coproduct: Coproduct$2, - CounterClockwiseContourIntegral: CounterClockwiseContourIntegral$2, - Cross: Cross$2, - Cscr: Cscr$2, - Cup: Cup$2, - CupCap: CupCap$2, - DD: DD$2, - DDotrahd: DDotrahd$2, - DJcy: DJcy$2, - DScy: DScy$2, - DZcy: DZcy$2, - Dagger: Dagger$2, - Darr: Darr$2, - Dashv: Dashv$2, - Dcaron: Dcaron$2, - Dcy: Dcy$2, - Del: Del$2, - Delta: Delta$2, - Dfr: Dfr$2, - DiacriticalAcute: DiacriticalAcute$2, - DiacriticalDot: DiacriticalDot$2, - DiacriticalDoubleAcute: DiacriticalDoubleAcute$2, - DiacriticalGrave: DiacriticalGrave$2, - DiacriticalTilde: DiacriticalTilde$2, - Diamond: Diamond$2, - DifferentialD: DifferentialD$2, - Dopf: Dopf$2, - Dot: Dot$2, - DotDot: DotDot$2, - DotEqual: DotEqual$2, - DoubleContourIntegral: DoubleContourIntegral$2, - DoubleDot: DoubleDot$2, - DoubleDownArrow: DoubleDownArrow$2, - DoubleLeftArrow: DoubleLeftArrow$2, - DoubleLeftRightArrow: DoubleLeftRightArrow$2, - DoubleLeftTee: DoubleLeftTee$2, - DoubleLongLeftArrow: DoubleLongLeftArrow$2, - DoubleLongLeftRightArrow: DoubleLongLeftRightArrow$2, - DoubleLongRightArrow: DoubleLongRightArrow$2, - DoubleRightArrow: DoubleRightArrow$2, - DoubleRightTee: DoubleRightTee$2, - DoubleUpArrow: DoubleUpArrow$2, - DoubleUpDownArrow: DoubleUpDownArrow$2, - DoubleVerticalBar: DoubleVerticalBar$2, - DownArrow: DownArrow$2, - DownArrowBar: DownArrowBar$2, - DownArrowUpArrow: DownArrowUpArrow$2, - DownBreve: DownBreve$2, - DownLeftRightVector: DownLeftRightVector$2, - DownLeftTeeVector: DownLeftTeeVector$2, - DownLeftVector: DownLeftVector$2, - DownLeftVectorBar: DownLeftVectorBar$2, - DownRightTeeVector: DownRightTeeVector$2, - DownRightVector: DownRightVector$2, - DownRightVectorBar: DownRightVectorBar$2, - DownTee: DownTee$2, - DownTeeArrow: DownTeeArrow$2, - Downarrow: Downarrow$2, - Dscr: Dscr$2, - Dstrok: Dstrok$2, - ENG: ENG$2, - ET: ET$2, - ETH: ETH$2, - Eacut: Eacut$2, - Eacute: Eacute$2, - Ecaron: Ecaron$2, - Ecir: Ecir$2, - Ecirc: Ecirc$2, - Ecy: Ecy$2, - Edot: Edot$2, - Efr: Efr$2, - Egrav: Egrav$2, - Egrave: Egrave$2, - Element: Element$2, - Emacr: Emacr$2, - EmptySmallSquare: EmptySmallSquare$2, - EmptyVerySmallSquare: EmptyVerySmallSquare$2, - Eogon: Eogon$2, - Eopf: Eopf$2, - Epsilon: Epsilon$2, - Equal: Equal$2, - EqualTilde: EqualTilde$2, - Equilibrium: Equilibrium$2, - Escr: Escr$2, - Esim: Esim$2, - Eta: Eta$2, - Eum: Eum$2, - Euml: Euml$2, - Exists: Exists$2, - ExponentialE: ExponentialE$2, - Fcy: Fcy$2, - Ffr: Ffr$2, - FilledSmallSquare: FilledSmallSquare$2, - FilledVerySmallSquare: FilledVerySmallSquare$2, - Fopf: Fopf$2, - ForAll: ForAll$2, - Fouriertrf: Fouriertrf$2, - Fscr: Fscr$2, - GJcy: GJcy$2, - G: G$2, - GT: GT$2, - Gamma: Gamma$2, - Gammad: Gammad$2, - Gbreve: Gbreve$2, - Gcedil: Gcedil$2, - Gcirc: Gcirc$2, - Gcy: Gcy$2, - Gdot: Gdot$2, - Gfr: Gfr$2, - Gg: Gg$2, - Gopf: Gopf$2, - GreaterEqual: GreaterEqual$2, - GreaterEqualLess: GreaterEqualLess$2, - GreaterFullEqual: GreaterFullEqual$2, - GreaterGreater: GreaterGreater$2, - GreaterLess: GreaterLess$2, - GreaterSlantEqual: GreaterSlantEqual$2, - GreaterTilde: GreaterTilde$2, - Gscr: Gscr$2, - Gt: Gt$2, - HARDcy: HARDcy$2, - Hacek: Hacek$2, - Hat: Hat$2, - Hcirc: Hcirc$2, - Hfr: Hfr$2, - HilbertSpace: HilbertSpace$2, - Hopf: Hopf$2, - HorizontalLine: HorizontalLine$2, - Hscr: Hscr$2, - Hstrok: Hstrok$2, - HumpDownHump: HumpDownHump$2, - HumpEqual: HumpEqual$2, - IEcy: IEcy$2, - IJlig: IJlig$2, - IOcy: IOcy$2, - Iacut: Iacut$2, - Iacute: Iacute$2, - Icir: Icir$2, - Icirc: Icirc$2, - Icy: Icy$2, - Idot: Idot$2, - Ifr: Ifr$2, - Igrav: Igrav$2, - Igrave: Igrave$2, - Im: Im$2, - Imacr: Imacr$2, - ImaginaryI: ImaginaryI$2, - Implies: Implies$2, - Int: Int$2, - Integral: Integral$2, - Intersection: Intersection$2, - InvisibleComma: InvisibleComma$2, - InvisibleTimes: InvisibleTimes$2, - Iogon: Iogon$2, - Iopf: Iopf$2, - Iota: Iota$2, - Iscr: Iscr$2, - Itilde: Itilde$2, - Iukcy: Iukcy$2, - Ium: Ium$2, - Iuml: Iuml$2, - Jcirc: Jcirc$2, - Jcy: Jcy$2, - Jfr: Jfr$2, - Jopf: Jopf$2, - Jscr: Jscr$2, - Jsercy: Jsercy$2, - Jukcy: Jukcy$2, - KHcy: KHcy$2, - KJcy: KJcy$2, - Kappa: Kappa$2, - Kcedil: Kcedil$2, - Kcy: Kcy$2, - Kfr: Kfr$2, - Kopf: Kopf$2, - Kscr: Kscr$2, - LJcy: LJcy$2, - L: L$2, - LT: LT$2, - Lacute: Lacute$2, - Lambda: Lambda$2, - Lang: Lang$2, - Laplacetrf: Laplacetrf$2, - Larr: Larr$2, - Lcaron: Lcaron$2, - Lcedil: Lcedil$2, - Lcy: Lcy$2, - LeftAngleBracket: LeftAngleBracket$2, - LeftArrow: LeftArrow$2, - LeftArrowBar: LeftArrowBar$2, - LeftArrowRightArrow: LeftArrowRightArrow$2, - LeftCeiling: LeftCeiling$2, - LeftDoubleBracket: LeftDoubleBracket$2, - LeftDownTeeVector: LeftDownTeeVector$2, - LeftDownVector: LeftDownVector$2, - LeftDownVectorBar: LeftDownVectorBar$2, - LeftFloor: LeftFloor$2, - LeftRightArrow: LeftRightArrow$2, - LeftRightVector: LeftRightVector$2, - LeftTee: LeftTee$2, - LeftTeeArrow: LeftTeeArrow$2, - LeftTeeVector: LeftTeeVector$2, - LeftTriangle: LeftTriangle$2, - LeftTriangleBar: LeftTriangleBar$2, - LeftTriangleEqual: LeftTriangleEqual$2, - LeftUpDownVector: LeftUpDownVector$2, - LeftUpTeeVector: LeftUpTeeVector$2, - LeftUpVector: LeftUpVector$2, - LeftUpVectorBar: LeftUpVectorBar$2, - LeftVector: LeftVector$2, - LeftVectorBar: LeftVectorBar$2, - Leftarrow: Leftarrow$2, - Leftrightarrow: Leftrightarrow$2, - LessEqualGreater: LessEqualGreater$2, - LessFullEqual: LessFullEqual$2, - LessGreater: LessGreater$2, - LessLess: LessLess$2, - LessSlantEqual: LessSlantEqual$2, - LessTilde: LessTilde$2, - Lfr: Lfr$2, - Ll: Ll$2, - Lleftarrow: Lleftarrow$2, - Lmidot: Lmidot$2, - LongLeftArrow: LongLeftArrow$2, - LongLeftRightArrow: LongLeftRightArrow$2, - LongRightArrow: LongRightArrow$2, - Longleftarrow: Longleftarrow$2, - Longleftrightarrow: Longleftrightarrow$2, - Longrightarrow: Longrightarrow$2, - Lopf: Lopf$2, - LowerLeftArrow: LowerLeftArrow$2, - LowerRightArrow: LowerRightArrow$2, - Lscr: Lscr$2, - Lsh: Lsh$2, - Lstrok: Lstrok$2, - Lt: Lt$2, - "Map": "⤅", - Mcy: Mcy$2, - MediumSpace: MediumSpace$2, - Mellintrf: Mellintrf$2, - Mfr: Mfr$2, - MinusPlus: MinusPlus$2, - Mopf: Mopf$2, - Mscr: Mscr$2, - Mu: Mu$2, - NJcy: NJcy$2, - Nacute: Nacute$2, - Ncaron: Ncaron$2, - Ncedil: Ncedil$2, - Ncy: Ncy$2, - NegativeMediumSpace: NegativeMediumSpace$2, - NegativeThickSpace: NegativeThickSpace$2, - NegativeThinSpace: NegativeThinSpace$2, - NegativeVeryThinSpace: NegativeVeryThinSpace$2, - NestedGreaterGreater: NestedGreaterGreater$2, - NestedLessLess: NestedLessLess$2, - NewLine: NewLine$2, - Nfr: Nfr$2, - NoBreak: NoBreak$2, - NonBreakingSpace: NonBreakingSpace$2, - Nopf: Nopf$2, - Not: Not$2, - NotCongruent: NotCongruent$2, - NotCupCap: NotCupCap$2, - NotDoubleVerticalBar: NotDoubleVerticalBar$2, - NotElement: NotElement$2, - NotEqual: NotEqual$2, - NotEqualTilde: NotEqualTilde$2, - NotExists: NotExists$2, - NotGreater: NotGreater$2, - NotGreaterEqual: NotGreaterEqual$2, - NotGreaterFullEqual: NotGreaterFullEqual$2, - NotGreaterGreater: NotGreaterGreater$2, - NotGreaterLess: NotGreaterLess$2, - NotGreaterSlantEqual: NotGreaterSlantEqual$2, - NotGreaterTilde: NotGreaterTilde$2, - NotHumpDownHump: NotHumpDownHump$2, - NotHumpEqual: NotHumpEqual$2, - NotLeftTriangle: NotLeftTriangle$2, - NotLeftTriangleBar: NotLeftTriangleBar$2, - NotLeftTriangleEqual: NotLeftTriangleEqual$2, - NotLess: NotLess$2, - NotLessEqual: NotLessEqual$2, - NotLessGreater: NotLessGreater$2, - NotLessLess: NotLessLess$2, - NotLessSlantEqual: NotLessSlantEqual$2, - NotLessTilde: NotLessTilde$2, - NotNestedGreaterGreater: NotNestedGreaterGreater$2, - NotNestedLessLess: NotNestedLessLess$2, - NotPrecedes: NotPrecedes$2, - NotPrecedesEqual: NotPrecedesEqual$2, - NotPrecedesSlantEqual: NotPrecedesSlantEqual$2, - NotReverseElement: NotReverseElement$2, - NotRightTriangle: NotRightTriangle$2, - NotRightTriangleBar: NotRightTriangleBar$2, - NotRightTriangleEqual: NotRightTriangleEqual$2, - NotSquareSubset: NotSquareSubset$2, - NotSquareSubsetEqual: NotSquareSubsetEqual$2, - NotSquareSuperset: NotSquareSuperset$2, - NotSquareSupersetEqual: NotSquareSupersetEqual$2, - NotSubset: NotSubset$2, - NotSubsetEqual: NotSubsetEqual$2, - NotSucceeds: NotSucceeds$2, - NotSucceedsEqual: NotSucceedsEqual$2, - NotSucceedsSlantEqual: NotSucceedsSlantEqual$2, - NotSucceedsTilde: NotSucceedsTilde$2, - NotSuperset: NotSuperset$2, - NotSupersetEqual: NotSupersetEqual$2, - NotTilde: NotTilde$2, - NotTildeEqual: NotTildeEqual$2, - NotTildeFullEqual: NotTildeFullEqual$2, - NotTildeTilde: NotTildeTilde$2, - NotVerticalBar: NotVerticalBar$2, - Nscr: Nscr$2, - Ntild: Ntild$2, - Ntilde: Ntilde$2, - Nu: Nu$2, - OElig: OElig$2, - Oacut: Oacut$2, - Oacute: Oacute$2, - Ocir: Ocir$2, - Ocirc: Ocirc$2, - Ocy: Ocy$2, - Odblac: Odblac$2, - Ofr: Ofr$2, - Ograv: Ograv$2, - Ograve: Ograve$2, - Omacr: Omacr$2, - Omega: Omega$2, - Omicron: Omicron$2, - Oopf: Oopf$2, - OpenCurlyDoubleQuote: OpenCurlyDoubleQuote$2, - OpenCurlyQuote: OpenCurlyQuote$2, - Or: Or$2, - Oscr: Oscr$2, - Oslas: Oslas$2, - Oslash: Oslash$2, - Otild: Otild$2, - Otilde: Otilde$2, - Otimes: Otimes$2, - Oum: Oum$2, - Ouml: Ouml$2, - OverBar: OverBar$2, - OverBrace: OverBrace$2, - OverBracket: OverBracket$2, - OverParenthesis: OverParenthesis$2, - PartialD: PartialD$2, - Pcy: Pcy$2, - Pfr: Pfr$2, - Phi: Phi$2, - Pi: Pi$2, - PlusMinus: PlusMinus$2, - Poincareplane: Poincareplane$2, - Popf: Popf$2, - Pr: Pr$2, - Precedes: Precedes$2, - PrecedesEqual: PrecedesEqual$2, - PrecedesSlantEqual: PrecedesSlantEqual$2, - PrecedesTilde: PrecedesTilde$2, - Prime: Prime$2, - Product: Product$2, - Proportion: Proportion$2, - Proportional: Proportional$2, - Pscr: Pscr$2, - Psi: Psi$2, - QUO: QUO$2, - QUOT: QUOT$2, - Qfr: Qfr$2, - Qopf: Qopf$2, - Qscr: Qscr$2, - RBarr: RBarr$2, - RE: RE$2, - REG: REG$2, - Racute: Racute$2, - Rang: Rang$2, - Rarr: Rarr$2, - Rarrtl: Rarrtl$2, - Rcaron: Rcaron$2, - Rcedil: Rcedil$2, - Rcy: Rcy$2, - Re: Re$2, - ReverseElement: ReverseElement$2, - ReverseEquilibrium: ReverseEquilibrium$2, - ReverseUpEquilibrium: ReverseUpEquilibrium$2, - Rfr: Rfr$2, - Rho: Rho$2, - RightAngleBracket: RightAngleBracket$2, - RightArrow: RightArrow$2, - RightArrowBar: RightArrowBar$2, - RightArrowLeftArrow: RightArrowLeftArrow$2, - RightCeiling: RightCeiling$2, - RightDoubleBracket: RightDoubleBracket$2, - RightDownTeeVector: RightDownTeeVector$2, - RightDownVector: RightDownVector$2, - RightDownVectorBar: RightDownVectorBar$2, - RightFloor: RightFloor$2, - RightTee: RightTee$2, - RightTeeArrow: RightTeeArrow$2, - RightTeeVector: RightTeeVector$2, - RightTriangle: RightTriangle$2, - RightTriangleBar: RightTriangleBar$2, - RightTriangleEqual: RightTriangleEqual$2, - RightUpDownVector: RightUpDownVector$2, - RightUpTeeVector: RightUpTeeVector$2, - RightUpVector: RightUpVector$2, - RightUpVectorBar: RightUpVectorBar$2, - RightVector: RightVector$2, - RightVectorBar: RightVectorBar$2, - Rightarrow: Rightarrow$2, - Ropf: Ropf$2, - RoundImplies: RoundImplies$2, - Rrightarrow: Rrightarrow$2, - Rscr: Rscr$2, - Rsh: Rsh$2, - RuleDelayed: RuleDelayed$2, - SHCHcy: SHCHcy$2, - SHcy: SHcy$2, - SOFTcy: SOFTcy$2, - Sacute: Sacute$2, - Sc: Sc$2, - Scaron: Scaron$2, - Scedil: Scedil$2, - Scirc: Scirc$2, - Scy: Scy$2, - Sfr: Sfr$2, - ShortDownArrow: ShortDownArrow$2, - ShortLeftArrow: ShortLeftArrow$2, - ShortRightArrow: ShortRightArrow$2, - ShortUpArrow: ShortUpArrow$2, - Sigma: Sigma$2, - SmallCircle: SmallCircle$2, - Sopf: Sopf$2, - Sqrt: Sqrt$2, - Square: Square$2, - SquareIntersection: SquareIntersection$2, - SquareSubset: SquareSubset$2, - SquareSubsetEqual: SquareSubsetEqual$2, - SquareSuperset: SquareSuperset$2, - SquareSupersetEqual: SquareSupersetEqual$2, - SquareUnion: SquareUnion$2, - Sscr: Sscr$2, - Star: Star$2, - Sub: Sub$2, - Subset: Subset$2, - SubsetEqual: SubsetEqual$2, - Succeeds: Succeeds$2, - SucceedsEqual: SucceedsEqual$2, - SucceedsSlantEqual: SucceedsSlantEqual$2, - SucceedsTilde: SucceedsTilde$2, - SuchThat: SuchThat$2, - Sum: Sum$2, - Sup: Sup$2, - Superset: Superset$2, - SupersetEqual: SupersetEqual$2, - Supset: Supset$2, - THOR: THOR$2, - THORN: THORN$2, - TRADE: TRADE$2, - TSHcy: TSHcy$2, - TScy: TScy$2, - Tab: Tab$2, - Tau: Tau$2, - Tcaron: Tcaron$2, - Tcedil: Tcedil$2, - Tcy: Tcy$2, - Tfr: Tfr$2, - Therefore: Therefore$2, - Theta: Theta$2, - ThickSpace: ThickSpace$2, - ThinSpace: ThinSpace$2, - Tilde: Tilde$2, - TildeEqual: TildeEqual$2, - TildeFullEqual: TildeFullEqual$2, - TildeTilde: TildeTilde$2, - Topf: Topf$2, - TripleDot: TripleDot$2, - Tscr: Tscr$2, - Tstrok: Tstrok$2, - Uacut: Uacut$2, - Uacute: Uacute$2, - Uarr: Uarr$2, - Uarrocir: Uarrocir$2, - Ubrcy: Ubrcy$2, - Ubreve: Ubreve$2, - Ucir: Ucir$2, - Ucirc: Ucirc$2, - Ucy: Ucy$2, - Udblac: Udblac$2, - Ufr: Ufr$2, - Ugrav: Ugrav$2, - Ugrave: Ugrave$2, - Umacr: Umacr$2, - UnderBar: UnderBar$2, - UnderBrace: UnderBrace$2, - UnderBracket: UnderBracket$2, - UnderParenthesis: UnderParenthesis$2, - Union: Union$2, - UnionPlus: UnionPlus$2, - Uogon: Uogon$2, - Uopf: Uopf$2, - UpArrow: UpArrow$2, - UpArrowBar: UpArrowBar$2, - UpArrowDownArrow: UpArrowDownArrow$2, - UpDownArrow: UpDownArrow$2, - UpEquilibrium: UpEquilibrium$2, - UpTee: UpTee$2, - UpTeeArrow: UpTeeArrow$2, - Uparrow: Uparrow$2, - Updownarrow: Updownarrow$2, - UpperLeftArrow: UpperLeftArrow$2, - UpperRightArrow: UpperRightArrow$2, - Upsi: Upsi$2, - Upsilon: Upsilon$2, - Uring: Uring$2, - Uscr: Uscr$2, - Utilde: Utilde$2, - Uum: Uum$2, - Uuml: Uuml$2, - VDash: VDash$2, - Vbar: Vbar$2, - Vcy: Vcy$2, - Vdash: Vdash$2, - Vdashl: Vdashl$2, - Vee: Vee$2, - Verbar: Verbar$2, - Vert: Vert$2, - VerticalBar: VerticalBar$2, - VerticalLine: VerticalLine$2, - VerticalSeparator: VerticalSeparator$2, - VerticalTilde: VerticalTilde$2, - VeryThinSpace: VeryThinSpace$2, - Vfr: Vfr$2, - Vopf: Vopf$2, - Vscr: Vscr$2, - Vvdash: Vvdash$2, - Wcirc: Wcirc$2, - Wedge: Wedge$2, - Wfr: Wfr$2, - Wopf: Wopf$2, - Wscr: Wscr$2, - Xfr: Xfr$2, - Xi: Xi$2, - Xopf: Xopf$2, - Xscr: Xscr$2, - YAcy: YAcy$2, - YIcy: YIcy$2, - YUcy: YUcy$2, - Yacut: Yacut$2, - Yacute: Yacute$2, - Ycirc: Ycirc$2, - Ycy: Ycy$2, - Yfr: Yfr$2, - Yopf: Yopf$2, - Yscr: Yscr$2, - Yuml: Yuml$2, - ZHcy: ZHcy$2, - Zacute: Zacute$2, - Zcaron: Zcaron$2, - Zcy: Zcy$2, - Zdot: Zdot$2, - ZeroWidthSpace: ZeroWidthSpace$2, - Zeta: Zeta$2, - Zfr: Zfr$2, - Zopf: Zopf$2, - Zscr: Zscr$2, - aacut: aacut$2, - aacute: aacute$2, - abreve: abreve$2, - ac: ac$2, - acE: acE$2, - acd: acd$2, - acir: acir$2, - acirc: acirc$2, - acut: acut$2, - acute: acute$2, - acy: acy$2, - aeli: aeli$2, - aelig: aelig$2, - af: af$2, - afr: afr$2, - agrav: agrav$2, - agrave: agrave$2, - alefsym: alefsym$2, - aleph: aleph$2, - alpha: alpha$2, - amacr: amacr$2, - amalg: amalg$2, - am: am$2, - amp: amp$2, - and: and$2, - andand: andand$2, - andd: andd$2, - andslope: andslope$2, - andv: andv$2, - ang: ang$2, - ange: ange$2, - angle: angle$2, - angmsd: angmsd$2, - angmsdaa: angmsdaa$2, - angmsdab: angmsdab$2, - angmsdac: angmsdac$2, - angmsdad: angmsdad$2, - angmsdae: angmsdae$2, - angmsdaf: angmsdaf$2, - angmsdag: angmsdag$2, - angmsdah: angmsdah$2, - angrt: angrt$2, - angrtvb: angrtvb$2, - angrtvbd: angrtvbd$2, - angsph: angsph$2, - angst: angst$2, - angzarr: angzarr$2, - aogon: aogon$2, - aopf: aopf$2, - ap: ap$2, - apE: apE$2, - apacir: apacir$2, - ape: ape$2, - apid: apid$2, - apos: apos$2, - approx: approx$2, - approxeq: approxeq$2, - arin: arin$2, - aring: aring$2, - ascr: ascr$2, - ast: ast$2, - asymp: asymp$2, - asympeq: asympeq$2, - atild: atild$2, - atilde: atilde$2, - aum: aum$2, - auml: auml$2, - awconint: awconint$2, - awint: awint$2, - bNot: bNot$2, - backcong: backcong$2, - backepsilon: backepsilon$2, - backprime: backprime$2, - backsim: backsim$2, - backsimeq: backsimeq$2, - barvee: barvee$2, - barwed: barwed$2, - barwedge: barwedge$2, - bbrk: bbrk$2, - bbrktbrk: bbrktbrk$2, - bcong: bcong$2, - bcy: bcy$2, - bdquo: bdquo$2, - becaus: becaus$2, - because: because$2, - bemptyv: bemptyv$2, - bepsi: bepsi$2, - bernou: bernou$2, - beta: beta$2, - beth: beth$2, - between: between$2, - bfr: bfr$2, - bigcap: bigcap$2, - bigcirc: bigcirc$2, - bigcup: bigcup$2, - bigodot: bigodot$2, - bigoplus: bigoplus$2, - bigotimes: bigotimes$2, - bigsqcup: bigsqcup$2, - bigstar: bigstar$2, - bigtriangledown: bigtriangledown$2, - bigtriangleup: bigtriangleup$2, - biguplus: biguplus$2, - bigvee: bigvee$2, - bigwedge: bigwedge$2, - bkarow: bkarow$2, - blacklozenge: blacklozenge$2, - blacksquare: blacksquare$2, - blacktriangle: blacktriangle$2, - blacktriangledown: blacktriangledown$2, - blacktriangleleft: blacktriangleleft$2, - blacktriangleright: blacktriangleright$2, - blank: blank$2, - blk12: blk12$2, - blk14: blk14$2, - blk34: blk34$2, - block: block$2, - bne: bne$2, - bnequiv: bnequiv$2, - bnot: bnot$2, - bopf: bopf$2, - bot: bot$2, - bottom: bottom$2, - bowtie: bowtie$2, - boxDL: boxDL$2, - boxDR: boxDR$2, - boxDl: boxDl$2, - boxDr: boxDr$2, - boxH: boxH$2, - boxHD: boxHD$2, - boxHU: boxHU$2, - boxHd: boxHd$2, - boxHu: boxHu$2, - boxUL: boxUL$2, - boxUR: boxUR$2, - boxUl: boxUl$2, - boxUr: boxUr$2, - boxV: boxV$2, - boxVH: boxVH$2, - boxVL: boxVL$2, - boxVR: boxVR$2, - boxVh: boxVh$2, - boxVl: boxVl$2, - boxVr: boxVr$2, - boxbox: boxbox$2, - boxdL: boxdL$2, - boxdR: boxdR$2, - boxdl: boxdl$2, - boxdr: boxdr$2, - boxh: boxh$2, - boxhD: boxhD$2, - boxhU: boxhU$2, - boxhd: boxhd$2, - boxhu: boxhu$2, - boxminus: boxminus$2, - boxplus: boxplus$2, - boxtimes: boxtimes$2, - boxuL: boxuL$2, - boxuR: boxuR$2, - boxul: boxul$2, - boxur: boxur$2, - boxv: boxv$2, - boxvH: boxvH$2, - boxvL: boxvL$2, - boxvR: boxvR$2, - boxvh: boxvh$2, - boxvl: boxvl$2, - boxvr: boxvr$2, - bprime: bprime$2, - breve: breve$2, - brvba: brvba$2, - brvbar: brvbar$2, - bscr: bscr$2, - bsemi: bsemi$2, - bsim: bsim$2, - bsime: bsime$2, - bsol: bsol$2, - bsolb: bsolb$2, - bsolhsub: bsolhsub$2, - bull: bull$2, - bullet: bullet$2, - bump: bump$2, - bumpE: bumpE$2, - bumpe: bumpe$2, - bumpeq: bumpeq$2, - cacute: cacute$2, - cap: cap$2, - capand: capand$2, - capbrcup: capbrcup$2, - capcap: capcap$2, - capcup: capcup$2, - capdot: capdot$2, - caps: caps$2, - caret: caret$2, - caron: caron$2, - ccaps: ccaps$2, - ccaron: ccaron$2, - ccedi: ccedi$2, - ccedil: ccedil$2, - ccirc: ccirc$2, - ccups: ccups$2, - ccupssm: ccupssm$2, - cdot: cdot$2, - cedi: cedi$2, - cedil: cedil$2, - cemptyv: cemptyv$2, - cen: cen$2, - cent: cent$2, - centerdot: centerdot$2, - cfr: cfr$2, - chcy: chcy$2, - check: check$3, - checkmark: checkmark$2, - chi: chi$2, - cir: cir$2, - cirE: cirE$2, - circ: circ$2, - circeq: circeq$2, - circlearrowleft: circlearrowleft$2, - circlearrowright: circlearrowright$2, - circledR: circledR$2, - circledS: circledS$2, - circledast: circledast$2, - circledcirc: circledcirc$2, - circleddash: circleddash$2, - cire: cire$2, - cirfnint: cirfnint$2, - cirmid: cirmid$2, - cirscir: cirscir$2, - clubs: clubs$2, - clubsuit: clubsuit$2, - colon: colon$2, - colone: colone$2, - coloneq: coloneq$2, - comma: comma$2, - commat: commat$2, - comp: comp$2, - compfn: compfn$2, - complement: complement$2, - complexes: complexes$2, - cong: cong$2, - congdot: congdot$2, - conint: conint$2, - copf: copf$2, - coprod: coprod$2, - cop: cop$2, - copy: copy$2, - copysr: copysr$2, - crarr: crarr$2, - cross: cross$2, - cscr: cscr$2, - csub: csub$2, - csube: csube$2, - csup: csup$2, - csupe: csupe$2, - ctdot: ctdot$2, - cudarrl: cudarrl$2, - cudarrr: cudarrr$2, - cuepr: cuepr$2, - cuesc: cuesc$2, - cularr: cularr$2, - cularrp: cularrp$2, - cup: cup$2, - cupbrcap: cupbrcap$2, - cupcap: cupcap$2, - cupcup: cupcup$2, - cupdot: cupdot$2, - cupor: cupor$2, - cups: cups$2, - curarr: curarr$2, - curarrm: curarrm$2, - curlyeqprec: curlyeqprec$2, - curlyeqsucc: curlyeqsucc$2, - curlyvee: curlyvee$2, - curlywedge: curlywedge$2, - curre: curre$2, - curren: curren$2, - curvearrowleft: curvearrowleft$2, - curvearrowright: curvearrowright$2, - cuvee: cuvee$2, - cuwed: cuwed$2, - cwconint: cwconint$2, - cwint: cwint$2, - cylcty: cylcty$2, - dArr: dArr$2, - dHar: dHar$2, - dagger: dagger$2, - daleth: daleth$2, - darr: darr$2, - dash: dash$2, - dashv: dashv$2, - dbkarow: dbkarow$2, - dblac: dblac$2, - dcaron: dcaron$2, - dcy: dcy$2, - dd: dd$2, - ddagger: ddagger$2, - ddarr: ddarr$2, - ddotseq: ddotseq$2, - de: de$2, - deg: deg$2, - delta: delta$2, - demptyv: demptyv$2, - dfisht: dfisht$2, - dfr: dfr$2, - dharl: dharl$2, - dharr: dharr$2, - diam: diam$2, - diamond: diamond$2, - diamondsuit: diamondsuit$2, - diams: diams$2, - die: die$2, - digamma: digamma$2, - disin: disin$2, - div: div$2, - divid: divid$2, - divide: divide$2, - divideontimes: divideontimes$2, - divonx: divonx$2, - djcy: djcy$2, - dlcorn: dlcorn$2, - dlcrop: dlcrop$2, - dollar: dollar$2, - dopf: dopf$2, - dot: dot$2, - doteq: doteq$2, - doteqdot: doteqdot$2, - dotminus: dotminus$2, - dotplus: dotplus$2, - dotsquare: dotsquare$2, - doublebarwedge: doublebarwedge$2, - downarrow: downarrow$2, - downdownarrows: downdownarrows$2, - downharpoonleft: downharpoonleft$2, - downharpoonright: downharpoonright$2, - drbkarow: drbkarow$2, - drcorn: drcorn$2, - drcrop: drcrop$2, - dscr: dscr$2, - dscy: dscy$2, - dsol: dsol$2, - dstrok: dstrok$2, - dtdot: dtdot$2, - dtri: dtri$2, - dtrif: dtrif$2, - duarr: duarr$2, - duhar: duhar$2, - dwangle: dwangle$2, - dzcy: dzcy$2, - dzigrarr: dzigrarr$2, - eDDot: eDDot$2, - eDot: eDot$2, - eacut: eacut$2, - eacute: eacute$2, - easter: easter$2, - ecaron: ecaron$2, - ecir: ecir$2, - ecirc: ecirc$2, - ecolon: ecolon$2, - ecy: ecy$2, - edot: edot$2, - ee: ee$2, - efDot: efDot$2, - efr: efr$2, - eg: eg$2, - egrav: egrav$2, - egrave: egrave$2, - egs: egs$2, - egsdot: egsdot$2, - el: el$2, - elinters: elinters$2, - ell: ell$2, - els: els$2, - elsdot: elsdot$2, - emacr: emacr$2, - empty: empty$2, - emptyset: emptyset$2, - emptyv: emptyv$2, - emsp13: emsp13$2, - emsp14: emsp14$2, - emsp: emsp$2, - eng: eng$2, - ensp: ensp$2, - eogon: eogon$2, - eopf: eopf$2, - epar: epar$2, - eparsl: eparsl$2, - eplus: eplus$2, - epsi: epsi$2, - epsilon: epsilon$2, - epsiv: epsiv$2, - eqcirc: eqcirc$2, - eqcolon: eqcolon$2, - eqsim: eqsim$2, - eqslantgtr: eqslantgtr$2, - eqslantless: eqslantless$2, - equals: equals$2, - equest: equest$2, - equiv: equiv$2, - equivDD: equivDD$2, - eqvparsl: eqvparsl$2, - erDot: erDot$2, - erarr: erarr$2, - escr: escr$2, - esdot: esdot$2, - esim: esim$2, - eta: eta$2, - et: et$2, - eth: eth$2, - eum: eum$2, - euml: euml$2, - euro: euro$2, - excl: excl$2, - exist: exist$2, - expectation: expectation$2, - exponentiale: exponentiale$2, - fallingdotseq: fallingdotseq$2, - fcy: fcy$2, - female: female$2, - ffilig: ffilig$2, - fflig: fflig$2, - ffllig: ffllig$2, - ffr: ffr$2, - filig: filig$2, - fjlig: fjlig$2, - flat: flat$2, - fllig: fllig$2, - fltns: fltns$2, - fnof: fnof$2, - fopf: fopf$2, - forall: forall$2, - fork: fork$2, - forkv: forkv$2, - fpartint: fpartint$2, - frac1: frac1$2, - frac12: frac12$2, - frac13: frac13$2, - frac14: frac14$2, - frac15: frac15$2, - frac16: frac16$2, - frac18: frac18$2, - frac23: frac23$2, - frac25: frac25$2, - frac3: frac3$2, - frac34: frac34$2, - frac35: frac35$2, - frac38: frac38$2, - frac45: frac45$2, - frac56: frac56$2, - frac58: frac58$2, - frac78: frac78$2, - frasl: frasl$2, - frown: frown$2, - fscr: fscr$2, - gE: gE$2, - gEl: gEl$2, - gacute: gacute$2, - gamma: gamma$2, - gammad: gammad$2, - gap: gap$2, - gbreve: gbreve$2, - gcirc: gcirc$2, - gcy: gcy$2, - gdot: gdot$2, - ge: ge$2, - gel: gel$2, - geq: geq$2, - geqq: geqq$2, - geqslant: geqslant$2, - ges: ges$2, - gescc: gescc$2, - gesdot: gesdot$2, - gesdoto: gesdoto$2, - gesdotol: gesdotol$2, - gesl: gesl$2, - gesles: gesles$2, - gfr: gfr$2, - gg: gg$2, - ggg: ggg$2, - gimel: gimel$2, - gjcy: gjcy$2, - gl: gl$2, - glE: glE$2, - gla: gla$2, - glj: glj$2, - gnE: gnE$2, - gnap: gnap$2, - gnapprox: gnapprox$2, - gne: gne$2, - gneq: gneq$2, - gneqq: gneqq$2, - gnsim: gnsim$2, - gopf: gopf$2, - grave: grave$2, - gscr: gscr$2, - gsim: gsim$2, - gsime: gsime$2, - gsiml: gsiml$2, - g: g$2, - gt: gt$2, - gtcc: gtcc$2, - gtcir: gtcir$2, - gtdot: gtdot$2, - gtlPar: gtlPar$2, - gtquest: gtquest$2, - gtrapprox: gtrapprox$2, - gtrarr: gtrarr$2, - gtrdot: gtrdot$2, - gtreqless: gtreqless$2, - gtreqqless: gtreqqless$2, - gtrless: gtrless$2, - gtrsim: gtrsim$2, - gvertneqq: gvertneqq$2, - gvnE: gvnE$2, - hArr: hArr$2, - hairsp: hairsp$2, - half: half$2, - hamilt: hamilt$2, - hardcy: hardcy$2, - harr: harr$2, - harrcir: harrcir$2, - harrw: harrw$2, - hbar: hbar$2, - hcirc: hcirc$2, - hearts: hearts$2, - heartsuit: heartsuit$2, - hellip: hellip$2, - hercon: hercon$2, - hfr: hfr$2, - hksearow: hksearow$2, - hkswarow: hkswarow$2, - hoarr: hoarr$2, - homtht: homtht$2, - hookleftarrow: hookleftarrow$2, - hookrightarrow: hookrightarrow$2, - hopf: hopf$2, - horbar: horbar$2, - hscr: hscr$2, - hslash: hslash$2, - hstrok: hstrok$2, - hybull: hybull$2, - hyphen: hyphen$2, - iacut: iacut$2, - iacute: iacute$2, - ic: ic$2, - icir: icir$2, - icirc: icirc$2, - icy: icy$2, - iecy: iecy$2, - iexc: iexc$2, - iexcl: iexcl$2, - iff: iff$2, - ifr: ifr$2, - igrav: igrav$2, - igrave: igrave$2, - ii: ii$2, - iiiint: iiiint$2, - iiint: iiint$2, - iinfin: iinfin$2, - iiota: iiota$2, - ijlig: ijlig$2, - imacr: imacr$2, - image: image$3, - imagline: imagline$2, - imagpart: imagpart$2, - imath: imath$2, - imof: imof$2, - imped: imped$2, - "in": "∈", - incare: incare$2, - infin: infin$2, - infintie: infintie$2, - inodot: inodot$2, - int: int$3, - intcal: intcal$2, - integers: integers$2, - intercal: intercal$2, - intlarhk: intlarhk$2, - intprod: intprod$2, - iocy: iocy$2, - iogon: iogon$2, - iopf: iopf$2, - iota: iota$2, - iprod: iprod$2, - iques: iques$2, - iquest: iquest$2, - iscr: iscr$2, - isin: isin$2, - isinE: isinE$2, - isindot: isindot$2, - isins: isins$2, - isinsv: isinsv$2, - isinv: isinv$2, - it: it$2, - itilde: itilde$2, - iukcy: iukcy$2, - ium: ium$2, - iuml: iuml$2, - jcirc: jcirc$2, - jcy: jcy$2, - jfr: jfr$2, - jmath: jmath$2, - jopf: jopf$2, - jscr: jscr$2, - jsercy: jsercy$2, - jukcy: jukcy$2, - kappa: kappa$2, - kappav: kappav$2, - kcedil: kcedil$2, - kcy: kcy$2, - kfr: kfr$2, - kgreen: kgreen$2, - khcy: khcy$2, - kjcy: kjcy$2, - kopf: kopf$2, - kscr: kscr$2, - lAarr: lAarr$2, - lArr: lArr$2, - lAtail: lAtail$2, - lBarr: lBarr$2, - lE: lE$2, - lEg: lEg$2, - lHar: lHar$2, - lacute: lacute$2, - laemptyv: laemptyv$2, - lagran: lagran$2, - lambda: lambda$2, - lang: lang$2, - langd: langd$2, - langle: langle$2, - lap: lap$2, - laqu: laqu$2, - laquo: laquo$2, - larr: larr$2, - larrb: larrb$2, - larrbfs: larrbfs$2, - larrfs: larrfs$2, - larrhk: larrhk$2, - larrlp: larrlp$2, - larrpl: larrpl$2, - larrsim: larrsim$2, - larrtl: larrtl$2, - lat: lat$2, - latail: latail$2, - late: late$2, - lates: lates$2, - lbarr: lbarr$2, - lbbrk: lbbrk$2, - lbrace: lbrace$2, - lbrack: lbrack$2, - lbrke: lbrke$2, - lbrksld: lbrksld$2, - lbrkslu: lbrkslu$2, - lcaron: lcaron$2, - lcedil: lcedil$2, - lceil: lceil$2, - lcub: lcub$2, - lcy: lcy$2, - ldca: ldca$2, - ldquo: ldquo$2, - ldquor: ldquor$2, - ldrdhar: ldrdhar$2, - ldrushar: ldrushar$2, - ldsh: ldsh$2, - le: le$2, - leftarrow: leftarrow$2, - leftarrowtail: leftarrowtail$2, - leftharpoondown: leftharpoondown$2, - leftharpoonup: leftharpoonup$2, - leftleftarrows: leftleftarrows$2, - leftrightarrow: leftrightarrow$2, - leftrightarrows: leftrightarrows$2, - leftrightharpoons: leftrightharpoons$2, - leftrightsquigarrow: leftrightsquigarrow$2, - leftthreetimes: leftthreetimes$2, - leg: leg$2, - leq: leq$2, - leqq: leqq$2, - leqslant: leqslant$2, - les: les$2, - lescc: lescc$2, - lesdot: lesdot$2, - lesdoto: lesdoto$2, - lesdotor: lesdotor$2, - lesg: lesg$2, - lesges: lesges$2, - lessapprox: lessapprox$2, - lessdot: lessdot$2, - lesseqgtr: lesseqgtr$2, - lesseqqgtr: lesseqqgtr$2, - lessgtr: lessgtr$2, - lesssim: lesssim$2, - lfisht: lfisht$2, - lfloor: lfloor$2, - lfr: lfr$2, - lg: lg$2, - lgE: lgE$2, - lhard: lhard$2, - lharu: lharu$2, - lharul: lharul$2, - lhblk: lhblk$2, - ljcy: ljcy$2, - ll: ll$2, - llarr: llarr$2, - llcorner: llcorner$2, - llhard: llhard$2, - lltri: lltri$2, - lmidot: lmidot$2, - lmoust: lmoust$2, - lmoustache: lmoustache$2, - lnE: lnE$2, - lnap: lnap$2, - lnapprox: lnapprox$2, - lne: lne$2, - lneq: lneq$2, - lneqq: lneqq$2, - lnsim: lnsim$2, - loang: loang$2, - loarr: loarr$2, - lobrk: lobrk$2, - longleftarrow: longleftarrow$2, - longleftrightarrow: longleftrightarrow$2, - longmapsto: longmapsto$2, - longrightarrow: longrightarrow$2, - looparrowleft: looparrowleft$2, - looparrowright: looparrowright$2, - lopar: lopar$2, - lopf: lopf$2, - loplus: loplus$2, - lotimes: lotimes$2, - lowast: lowast$2, - lowbar: lowbar$2, - loz: loz$2, - lozenge: lozenge$2, - lozf: lozf$2, - lpar: lpar$2, - lparlt: lparlt$2, - lrarr: lrarr$2, - lrcorner: lrcorner$2, - lrhar: lrhar$2, - lrhard: lrhard$2, - lrm: lrm$2, - lrtri: lrtri$2, - lsaquo: lsaquo$2, - lscr: lscr$2, - lsh: lsh$2, - lsim: lsim$2, - lsime: lsime$2, - lsimg: lsimg$2, - lsqb: lsqb$2, - lsquo: lsquo$2, - lsquor: lsquor$2, - lstrok: lstrok$2, - l: l$2, - lt: lt$3, - ltcc: ltcc$2, - ltcir: ltcir$2, - ltdot: ltdot$2, - lthree: lthree$2, - ltimes: ltimes$2, - ltlarr: ltlarr$2, - ltquest: ltquest$2, - ltrPar: ltrPar$2, - ltri: ltri$2, - ltrie: ltrie$2, - ltrif: ltrif$2, - lurdshar: lurdshar$2, - luruhar: luruhar$2, - lvertneqq: lvertneqq$2, - lvnE: lvnE$2, - mDDot: mDDot$2, - mac: mac$2, - macr: macr$2, - male: male$2, - malt: malt$2, - maltese: maltese$2, - map: map$5, - mapsto: mapsto$2, - mapstodown: mapstodown$2, - mapstoleft: mapstoleft$2, - mapstoup: mapstoup$2, - marker: marker$2, - mcomma: mcomma$2, - mcy: mcy$2, - mdash: mdash$2, - measuredangle: measuredangle$2, - mfr: mfr$2, - mho: mho$2, - micr: micr$2, - micro: micro$2, - mid: mid$2, - midast: midast$2, - midcir: midcir$2, - middo: middo$2, - middot: middot$2, - minus: minus$2, - minusb: minusb$2, - minusd: minusd$2, - minusdu: minusdu$2, - mlcp: mlcp$2, - mldr: mldr$2, - mnplus: mnplus$2, - models: models$2, - mopf: mopf$2, - mp: mp$2, - mscr: mscr$2, - mstpos: mstpos$2, - mu: mu$2, - multimap: multimap$2, - mumap: mumap$2, - nGg: nGg$2, - nGt: nGt$2, - nGtv: nGtv$2, - nLeftarrow: nLeftarrow$2, - nLeftrightarrow: nLeftrightarrow$2, - nLl: nLl$2, - nLt: nLt$2, - nLtv: nLtv$2, - nRightarrow: nRightarrow$2, - nVDash: nVDash$2, - nVdash: nVdash$2, - nabla: nabla$2, - nacute: nacute$2, - nang: nang$2, - nap: nap$2, - napE: napE$2, - napid: napid$2, - napos: napos$2, - napprox: napprox$2, - natur: natur$2, - natural: natural$2, - naturals: naturals$2, - nbs: nbs$2, - nbsp: nbsp$2, - nbump: nbump$2, - nbumpe: nbumpe$2, - ncap: ncap$2, - ncaron: ncaron$2, - ncedil: ncedil$2, - ncong: ncong$2, - ncongdot: ncongdot$2, - ncup: ncup$2, - ncy: ncy$2, - ndash: ndash$2, - ne: ne$2, - neArr: neArr$2, - nearhk: nearhk$2, - nearr: nearr$2, - nearrow: nearrow$2, - nedot: nedot$2, - nequiv: nequiv$2, - nesear: nesear$2, - nesim: nesim$2, - nexist: nexist$2, - nexists: nexists$2, - nfr: nfr$2, - ngE: ngE$2, - nge: nge$2, - ngeq: ngeq$2, - ngeqq: ngeqq$2, - ngeqslant: ngeqslant$2, - nges: nges$2, - ngsim: ngsim$2, - ngt: ngt$2, - ngtr: ngtr$2, - nhArr: nhArr$2, - nharr: nharr$2, - nhpar: nhpar$2, - ni: ni$2, - nis: nis$2, - nisd: nisd$2, - niv: niv$2, - njcy: njcy$2, - nlArr: nlArr$2, - nlE: nlE$2, - nlarr: nlarr$2, - nldr: nldr$2, - nle: nle$2, - nleftarrow: nleftarrow$2, - nleftrightarrow: nleftrightarrow$2, - nleq: nleq$2, - nleqq: nleqq$2, - nleqslant: nleqslant$2, - nles: nles$2, - nless: nless$2, - nlsim: nlsim$2, - nlt: nlt$2, - nltri: nltri$2, - nltrie: nltrie$2, - nmid: nmid$2, - nopf: nopf$2, - no: no$2, - not: not$2, - notin: notin$2, - notinE: notinE$2, - notindot: notindot$2, - notinva: notinva$2, - notinvb: notinvb$2, - notinvc: notinvc$2, - notni: notni$2, - notniva: notniva$2, - notnivb: notnivb$2, - notnivc: notnivc$2, - npar: npar$2, - nparallel: nparallel$2, - nparsl: nparsl$2, - npart: npart$2, - npolint: npolint$2, - npr: npr$2, - nprcue: nprcue$2, - npre: npre$2, - nprec: nprec$2, - npreceq: npreceq$2, - nrArr: nrArr$2, - nrarr: nrarr$2, - nrarrc: nrarrc$2, - nrarrw: nrarrw$2, - nrightarrow: nrightarrow$2, - nrtri: nrtri$2, - nrtrie: nrtrie$2, - nsc: nsc$2, - nsccue: nsccue$2, - nsce: nsce$2, - nscr: nscr$2, - nshortmid: nshortmid$2, - nshortparallel: nshortparallel$2, - nsim: nsim$2, - nsime: nsime$2, - nsimeq: nsimeq$2, - nsmid: nsmid$2, - nspar: nspar$2, - nsqsube: nsqsube$2, - nsqsupe: nsqsupe$2, - nsub: nsub$2, - nsubE: nsubE$2, - nsube: nsube$2, - nsubset: nsubset$2, - nsubseteq: nsubseteq$2, - nsubseteqq: nsubseteqq$2, - nsucc: nsucc$2, - nsucceq: nsucceq$2, - nsup: nsup$2, - nsupE: nsupE$2, - nsupe: nsupe$2, - nsupset: nsupset$2, - nsupseteq: nsupseteq$2, - nsupseteqq: nsupseteqq$2, - ntgl: ntgl$2, - ntild: ntild$2, - ntilde: ntilde$2, - ntlg: ntlg$2, - ntriangleleft: ntriangleleft$2, - ntrianglelefteq: ntrianglelefteq$2, - ntriangleright: ntriangleright$2, - ntrianglerighteq: ntrianglerighteq$2, - nu: nu$2, - num: num$2, - numero: numero$2, - numsp: numsp$2, - nvDash: nvDash$2, - nvHarr: nvHarr$2, - nvap: nvap$2, - nvdash: nvdash$2, - nvge: nvge$2, - nvgt: nvgt$2, - nvinfin: nvinfin$2, - nvlArr: nvlArr$2, - nvle: nvle$2, - nvlt: nvlt$2, - nvltrie: nvltrie$2, - nvrArr: nvrArr$2, - nvrtrie: nvrtrie$2, - nvsim: nvsim$2, - nwArr: nwArr$2, - nwarhk: nwarhk$2, - nwarr: nwarr$2, - nwarrow: nwarrow$2, - nwnear: nwnear$2, - oS: oS$2, - oacut: oacut$2, - oacute: oacute$2, - oast: oast$2, - ocir: ocir$2, - ocirc: ocirc$2, - ocy: ocy$2, - odash: odash$2, - odblac: odblac$2, - odiv: odiv$2, - odot: odot$2, - odsold: odsold$2, - oelig: oelig$2, - ofcir: ofcir$2, - ofr: ofr$2, - ogon: ogon$2, - ograv: ograv$2, - ograve: ograve$2, - ogt: ogt$2, - ohbar: ohbar$2, - ohm: ohm$2, - oint: oint$2, - olarr: olarr$2, - olcir: olcir$2, - olcross: olcross$2, - oline: oline$2, - olt: olt$2, - omacr: omacr$2, - omega: omega$2, - omicron: omicron$2, - omid: omid$2, - ominus: ominus$2, - oopf: oopf$2, - opar: opar$2, - operp: operp$2, - oplus: oplus$2, - or: or$2, - orarr: orarr$2, - ord: ord$2, - order: order$2, - orderof: orderof$2, - ordf: ordf$2, - ordm: ordm$2, - origof: origof$2, - oror: oror$2, - orslope: orslope$2, - orv: orv$2, - oscr: oscr$2, - oslas: oslas$2, - oslash: oslash$2, - osol: osol$2, - otild: otild$2, - otilde: otilde$2, - otimes: otimes$2, - otimesas: otimesas$2, - oum: oum$2, - ouml: ouml$2, - ovbar: ovbar$2, - par: par$2, - para: para$2, - parallel: parallel$2, - parsim: parsim$2, - parsl: parsl$2, - part: part$2, - pcy: pcy$2, - percnt: percnt$2, - period: period$2, - permil: permil$2, - perp: perp$2, - pertenk: pertenk$2, - pfr: pfr$2, - phi: phi$2, - phiv: phiv$2, - phmmat: phmmat$2, - phone: phone$2, - pi: pi$2, - pitchfork: pitchfork$2, - piv: piv$2, - planck: planck$2, - planckh: planckh$2, - plankv: plankv$2, - plus: plus$2, - plusacir: plusacir$2, - plusb: plusb$2, - pluscir: pluscir$2, - plusdo: plusdo$2, - plusdu: plusdu$2, - pluse: pluse$2, - plusm: plusm$2, - plusmn: plusmn$2, - plussim: plussim$2, - plustwo: plustwo$2, - pm: pm$2, - pointint: pointint$2, - popf: popf$2, - poun: poun$2, - pound: pound$2, - pr: pr$2, - prE: prE$2, - prap: prap$2, - prcue: prcue$2, - pre: pre$2, - prec: prec$2, - precapprox: precapprox$2, - preccurlyeq: preccurlyeq$2, - preceq: preceq$2, - precnapprox: precnapprox$2, - precneqq: precneqq$2, - precnsim: precnsim$2, - precsim: precsim$2, - prime: prime$2, - primes: primes$2, - prnE: prnE$2, - prnap: prnap$2, - prnsim: prnsim$2, - prod: prod$2, - profalar: profalar$2, - profline: profline$2, - profsurf: profsurf$2, - prop: prop$2, - propto: propto$2, - prsim: prsim$2, - prurel: prurel$2, - pscr: pscr$2, - psi: psi$2, - puncsp: puncsp$2, - qfr: qfr$2, - qint: qint$2, - qopf: qopf$2, - qprime: qprime$2, - qscr: qscr$2, - quaternions: quaternions$2, - quatint: quatint$2, - quest: quest$2, - questeq: questeq$2, - quo: quo$2, - quot: quot$2, - rAarr: rAarr$2, - rArr: rArr$2, - rAtail: rAtail$2, - rBarr: rBarr$2, - rHar: rHar$2, - race: race$2, - racute: racute$2, - radic: radic$2, - raemptyv: raemptyv$2, - rang: rang$2, - rangd: rangd$2, - range: range$2, - rangle: rangle$2, - raqu: raqu$2, - raquo: raquo$2, - rarr: rarr$2, - rarrap: rarrap$2, - rarrb: rarrb$2, - rarrbfs: rarrbfs$2, - rarrc: rarrc$2, - rarrfs: rarrfs$2, - rarrhk: rarrhk$2, - rarrlp: rarrlp$2, - rarrpl: rarrpl$2, - rarrsim: rarrsim$2, - rarrtl: rarrtl$2, - rarrw: rarrw$2, - ratail: ratail$2, - ratio: ratio$2, - rationals: rationals$2, - rbarr: rbarr$2, - rbbrk: rbbrk$2, - rbrace: rbrace$2, - rbrack: rbrack$2, - rbrke: rbrke$2, - rbrksld: rbrksld$2, - rbrkslu: rbrkslu$2, - rcaron: rcaron$2, - rcedil: rcedil$2, - rceil: rceil$2, - rcub: rcub$2, - rcy: rcy$2, - rdca: rdca$2, - rdldhar: rdldhar$2, - rdquo: rdquo$2, - rdquor: rdquor$2, - rdsh: rdsh$2, - real: real$2, - realine: realine$2, - realpart: realpart$2, - reals: reals$2, - rect: rect$2, - re: re$6, - reg: reg$2, - rfisht: rfisht$2, - rfloor: rfloor$2, - rfr: rfr$2, - rhard: rhard$2, - rharu: rharu$2, - rharul: rharul$2, - rho: rho$2, - rhov: rhov$2, - rightarrow: rightarrow$2, - rightarrowtail: rightarrowtail$2, - rightharpoondown: rightharpoondown$2, - rightharpoonup: rightharpoonup$2, - rightleftarrows: rightleftarrows$2, - rightleftharpoons: rightleftharpoons$2, - rightrightarrows: rightrightarrows$2, - rightsquigarrow: rightsquigarrow$2, - rightthreetimes: rightthreetimes$2, - ring: ring$2, - risingdotseq: risingdotseq$2, - rlarr: rlarr$2, - rlhar: rlhar$2, - rlm: rlm$2, - rmoust: rmoust$2, - rmoustache: rmoustache$2, - rnmid: rnmid$2, - roang: roang$2, - roarr: roarr$2, - robrk: robrk$2, - ropar: ropar$2, - ropf: ropf$2, - roplus: roplus$2, - rotimes: rotimes$2, - rpar: rpar$2, - rpargt: rpargt$2, - rppolint: rppolint$2, - rrarr: rrarr$2, - rsaquo: rsaquo$2, - rscr: rscr$2, - rsh: rsh$2, - rsqb: rsqb$2, - rsquo: rsquo$2, - rsquor: rsquor$2, - rthree: rthree$2, - rtimes: rtimes$2, - rtri: rtri$2, - rtrie: rtrie$2, - rtrif: rtrif$2, - rtriltri: rtriltri$2, - ruluhar: ruluhar$2, - rx: rx$2, - sacute: sacute$2, - sbquo: sbquo$2, - sc: sc$2, - scE: scE$2, - scap: scap$2, - scaron: scaron$2, - sccue: sccue$2, - sce: sce$2, - scedil: scedil$2, - scirc: scirc$2, - scnE: scnE$2, - scnap: scnap$2, - scnsim: scnsim$2, - scpolint: scpolint$2, - scsim: scsim$2, - scy: scy$2, - sdot: sdot$2, - sdotb: sdotb$2, - sdote: sdote$2, - seArr: seArr$2, - searhk: searhk$2, - searr: searr$2, - searrow: searrow$2, - sec: sec$2, - sect: sect$2, - semi: semi$2, - seswar: seswar$2, - setminus: setminus$2, - setmn: setmn$2, - sext: sext$2, - sfr: sfr$2, - sfrown: sfrown$2, - sharp: sharp$2, - shchcy: shchcy$2, - shcy: shcy$2, - shortmid: shortmid$2, - shortparallel: shortparallel$2, - sh: sh$2, - shy: shy$2, - sigma: sigma$2, - sigmaf: sigmaf$2, - sigmav: sigmav$2, - sim: sim$2, - simdot: simdot$2, - sime: sime$2, - simeq: simeq$2, - simg: simg$2, - simgE: simgE$2, - siml: siml$2, - simlE: simlE$2, - simne: simne$2, - simplus: simplus$2, - simrarr: simrarr$2, - slarr: slarr$2, - smallsetminus: smallsetminus$2, - smashp: smashp$2, - smeparsl: smeparsl$2, - smid: smid$2, - smile: smile$2, - smt: smt$2, - smte: smte$2, - smtes: smtes$2, - softcy: softcy$2, - sol: sol$2, - solb: solb$2, - solbar: solbar$2, - sopf: sopf$2, - spades: spades$2, - spadesuit: spadesuit$2, - spar: spar$2, - sqcap: sqcap$2, - sqcaps: sqcaps$2, - sqcup: sqcup$2, - sqcups: sqcups$2, - sqsub: sqsub$2, - sqsube: sqsube$2, - sqsubset: sqsubset$2, - sqsubseteq: sqsubseteq$2, - sqsup: sqsup$2, - sqsupe: sqsupe$2, - sqsupset: sqsupset$2, - sqsupseteq: sqsupseteq$2, - squ: squ$2, - square: square$2, - squarf: squarf$2, - squf: squf$2, - srarr: srarr$2, - sscr: sscr$2, - ssetmn: ssetmn$2, - ssmile: ssmile$2, - sstarf: sstarf$2, - star: star$2, - starf: starf$2, - straightepsilon: straightepsilon$2, - straightphi: straightphi$2, - strns: strns$2, - sub: sub$2, - subE: subE$2, - subdot: subdot$2, - sube: sube$2, - subedot: subedot$2, - submult: submult$2, - subnE: subnE$2, - subne: subne$2, - subplus: subplus$2, - subrarr: subrarr$2, - subset: subset$2, - subseteq: subseteq$2, - subseteqq: subseteqq$2, - subsetneq: subsetneq$2, - subsetneqq: subsetneqq$2, - subsim: subsim$2, - subsub: subsub$2, - subsup: subsup$2, - succ: succ$2, - succapprox: succapprox$2, - succcurlyeq: succcurlyeq$2, - succeq: succeq$2, - succnapprox: succnapprox$2, - succneqq: succneqq$2, - succnsim: succnsim$2, - succsim: succsim$2, - sum: sum$2, - sung: sung$2, - sup: sup$2, - sup1: sup1$2, - sup2: sup2$2, - sup3: sup3$2, - supE: supE$2, - supdot: supdot$2, - supdsub: supdsub$2, - supe: supe$2, - supedot: supedot$2, - suphsol: suphsol$2, - suphsub: suphsub$2, - suplarr: suplarr$2, - supmult: supmult$2, - supnE: supnE$2, - supne: supne$2, - supplus: supplus$2, - supset: supset$2, - supseteq: supseteq$2, - supseteqq: supseteqq$2, - supsetneq: supsetneq$2, - supsetneqq: supsetneqq$2, - supsim: supsim$2, - supsub: supsub$2, - supsup: supsup$2, - swArr: swArr$2, - swarhk: swarhk$2, - swarr: swarr$2, - swarrow: swarrow$2, - swnwar: swnwar$2, - szli: szli$2, - szlig: szlig$2, - target: target$2, - tau: tau$2, - tbrk: tbrk$2, - tcaron: tcaron$2, - tcedil: tcedil$2, - tcy: tcy$2, - tdot: tdot$2, - telrec: telrec$2, - tfr: tfr$2, - there4: there4$2, - therefore: therefore$2, - theta: theta$2, - thetasym: thetasym$2, - thetav: thetav$2, - thickapprox: thickapprox$2, - thicksim: thicksim$2, - thinsp: thinsp$2, - thkap: thkap$2, - thksim: thksim$2, - thor: thor$2, - thorn: thorn$2, - tilde: tilde$2, - time: time$2, - times: times$2, - timesb: timesb$2, - timesbar: timesbar$2, - timesd: timesd$2, - tint: tint$2, - toea: toea$2, - top: top$2, - topbot: topbot$2, - topcir: topcir$2, - topf: topf$2, - topfork: topfork$2, - tosa: tosa$2, - tprime: tprime$2, - trade: trade$2, - triangle: triangle$2, - triangledown: triangledown$2, - triangleleft: triangleleft$2, - trianglelefteq: trianglelefteq$2, - triangleq: triangleq$2, - triangleright: triangleright$2, - trianglerighteq: trianglerighteq$2, - tridot: tridot$2, - trie: trie$2, - triminus: triminus$2, - triplus: triplus$2, - trisb: trisb$2, - tritime: tritime$2, - trpezium: trpezium$2, - tscr: tscr$2, - tscy: tscy$2, - tshcy: tshcy$2, - tstrok: tstrok$2, - twixt: twixt$2, - twoheadleftarrow: twoheadleftarrow$2, - twoheadrightarrow: twoheadrightarrow$2, - uArr: uArr$2, - uHar: uHar$2, - uacut: uacut$2, - uacute: uacute$2, - uarr: uarr$2, - ubrcy: ubrcy$2, - ubreve: ubreve$2, - ucir: ucir$2, - ucirc: ucirc$2, - ucy: ucy$2, - udarr: udarr$2, - udblac: udblac$2, - udhar: udhar$2, - ufisht: ufisht$2, - ufr: ufr$2, - ugrav: ugrav$2, - ugrave: ugrave$2, - uharl: uharl$2, - uharr: uharr$2, - uhblk: uhblk$2, - ulcorn: ulcorn$2, - ulcorner: ulcorner$2, - ulcrop: ulcrop$2, - ultri: ultri$2, - umacr: umacr$2, - um: um$2, - uml: uml$2, - uogon: uogon$2, - uopf: uopf$2, - uparrow: uparrow$2, - updownarrow: updownarrow$2, - upharpoonleft: upharpoonleft$2, - upharpoonright: upharpoonright$2, - uplus: uplus$2, - upsi: upsi$2, - upsih: upsih$2, - upsilon: upsilon$2, - upuparrows: upuparrows$2, - urcorn: urcorn$2, - urcorner: urcorner$2, - urcrop: urcrop$2, - uring: uring$2, - urtri: urtri$2, - uscr: uscr$2, - utdot: utdot$2, - utilde: utilde$2, - utri: utri$2, - utrif: utrif$2, - uuarr: uuarr$2, - uum: uum$2, - uuml: uuml$2, - uwangle: uwangle$2, - vArr: vArr$2, - vBar: vBar$2, - vBarv: vBarv$2, - vDash: vDash$2, - vangrt: vangrt$2, - varepsilon: varepsilon$2, - varkappa: varkappa$2, - varnothing: varnothing$2, - varphi: varphi$2, - varpi: varpi$2, - varpropto: varpropto$2, - varr: varr$2, - varrho: varrho$2, - varsigma: varsigma$2, - varsubsetneq: varsubsetneq$2, - varsubsetneqq: varsubsetneqq$2, - varsupsetneq: varsupsetneq$2, - varsupsetneqq: varsupsetneqq$2, - vartheta: vartheta$2, - vartriangleleft: vartriangleleft$2, - vartriangleright: vartriangleright$2, - vcy: vcy$2, - vdash: vdash$2, - vee: vee$2, - veebar: veebar$2, - veeeq: veeeq$2, - vellip: vellip$2, - verbar: verbar$2, - vert: vert$2, - vfr: vfr$2, - vltri: vltri$2, - vnsub: vnsub$2, - vnsup: vnsup$2, - vopf: vopf$2, - vprop: vprop$2, - vrtri: vrtri$2, - vscr: vscr$2, - vsubnE: vsubnE$2, - vsubne: vsubne$2, - vsupnE: vsupnE$2, - vsupne: vsupne$2, - vzigzag: vzigzag$2, - wcirc: wcirc$2, - wedbar: wedbar$2, - wedge: wedge$2, - wedgeq: wedgeq$2, - weierp: weierp$2, - wfr: wfr$2, - wopf: wopf$2, - wp: wp$2, - wr: wr$2, - wreath: wreath$2, - wscr: wscr$2, - xcap: xcap$2, - xcirc: xcirc$2, - xcup: xcup$2, - xdtri: xdtri$2, - xfr: xfr$2, - xhArr: xhArr$2, - xharr: xharr$2, - xi: xi$2, - xlArr: xlArr$2, - xlarr: xlarr$2, - xmap: xmap$2, - xnis: xnis$2, - xodot: xodot$2, - xopf: xopf$2, - xoplus: xoplus$2, - xotime: xotime$2, - xrArr: xrArr$2, - xrarr: xrarr$2, - xscr: xscr$2, - xsqcup: xsqcup$2, - xuplus: xuplus$2, - xutri: xutri$2, - xvee: xvee$2, - xwedge: xwedge$2, - yacut: yacut$2, - yacute: yacute$2, - yacy: yacy$2, - ycirc: ycirc$2, - ycy: ycy$2, - ye: ye$2, - yen: yen$2, - yfr: yfr$2, - yicy: yicy$2, - yopf: yopf$2, - yscr: yscr$2, - yucy: yucy$2, - yum: yum$2, - yuml: yuml$2, - zacute: zacute$2, - zcaron: zcaron$2, - zcy: zcy$2, - zdot: zdot$2, - zeetrf: zeetrf$2, - zeta: zeta$2, - zfr: zfr$2, - zhcy: zhcy$2, - zigrarr: zigrarr$2, - zopf: zopf$2, - zscr: zscr$2, - zwj: zwj$2, - zwnj: zwnj$2 -}; +const parseStates = { + start () { + if (token.type === 'eof') { + throw invalidEOF() + } -var characterEntities$2 = require$$0$2; + push$1(); + }, -var decodeEntity_1$2 = decodeEntity$3; + beforePropertyName () { + switch (token.type) { + case 'identifier': + case 'string': + key = token.value; + parseState = 'afterPropertyName'; + return -var own$9 = {}.hasOwnProperty; + case 'punctuator': + // This code is unreachable since it's handled by the lexState. + // if (token.value !== '}') { + // throw invalidToken() + // } -function decodeEntity$3(characters) { - return own$9.call(characterEntities$2, characters) - ? characterEntities$2[characters] - : false -} + pop(); + return -var regexCheck$2 = regexCheck_1; + case 'eof': + throw invalidEOF() + } -var asciiDigit$3 = regexCheck$2(/\d/); + // This code is unreachable since it's handled by the lexState. + // throw invalidToken() + }, -var asciiDigit_1 = asciiDigit$3; + afterPropertyName () { + // This code is unreachable since it's handled by the lexState. + // if (token.type !== 'punctuator' || token.value !== ':') { + // throw invalidToken() + // } -var regexCheck$1 = regexCheck_1; + if (token.type === 'eof') { + throw invalidEOF() + } -var asciiHexDigit$1 = regexCheck$1(/[\dA-Fa-f]/); + parseState = 'beforePropertyValue'; + }, -var asciiHexDigit_1 = asciiHexDigit$1; + beforePropertyValue () { + if (token.type === 'eof') { + throw invalidEOF() + } -var decodeEntity$2 = decodeEntity_1$2; -var asciiAlphanumeric$3 = asciiAlphanumeric_1; -var asciiDigit$2 = asciiDigit_1; -var asciiHexDigit = asciiHexDigit_1; + push$1(); + }, -function _interopDefaultLegacy$1(e) { - return e && typeof e === 'object' && 'default' in e ? e : {default: e} -} + beforeArrayValue () { + if (token.type === 'eof') { + throw invalidEOF() + } -var decodeEntity__default = /*#__PURE__*/ _interopDefaultLegacy$1(decodeEntity$2); + if (token.type === 'punctuator' && token.value === ']') { + pop(); + return + } -var characterReference$2 = { - name: 'characterReference', - tokenize: tokenizeCharacterReference -}; + push$1(); + }, -function tokenizeCharacterReference(effects, ok, nok) { - var self = this; - var size = 0; - var max; - var test; - return start + afterPropertyValue () { + // This code is unreachable since it's handled by the lexState. + // if (token.type !== 'punctuator') { + // throw invalidToken() + // } - function start(code) { - effects.enter('characterReference'); - effects.enter('characterReferenceMarker'); - effects.consume(code); - effects.exit('characterReferenceMarker'); - return open - } + if (token.type === 'eof') { + throw invalidEOF() + } - function open(code) { - if (code === 35) { - effects.enter('characterReferenceMarkerNumeric'); - effects.consume(code); - effects.exit('characterReferenceMarkerNumeric'); - return numeric - } + switch (token.value) { + case ',': + parseState = 'beforePropertyName'; + return - effects.enter('characterReferenceValue'); - max = 31; - test = asciiAlphanumeric$3; - return value(code) - } + case '}': + pop(); + } - function numeric(code) { - if (code === 88 || code === 120) { - effects.enter('characterReferenceMarkerHexadecimal'); - effects.consume(code); - effects.exit('characterReferenceMarkerHexadecimal'); - effects.enter('characterReferenceValue'); - max = 6; - test = asciiHexDigit; - return value - } + // This code is unreachable since it's handled by the lexState. + // throw invalidToken() + }, - effects.enter('characterReferenceValue'); - max = 7; - test = asciiDigit$2; - return value(code) - } + afterArrayValue () { + // This code is unreachable since it's handled by the lexState. + // if (token.type !== 'punctuator') { + // throw invalidToken() + // } - function value(code) { - var token; + if (token.type === 'eof') { + throw invalidEOF() + } - if (code === 59 && size) { - token = effects.exit('characterReferenceValue'); + switch (token.value) { + case ',': + parseState = 'beforeArrayValue'; + return - if ( - test === asciiAlphanumeric$3 && - !decodeEntity__default['default'](self.sliceSerialize(token)) - ) { - return nok(code) - } + case ']': + pop(); + } - effects.enter('characterReferenceMarker'); - effects.consume(code); - effects.exit('characterReferenceMarker'); - effects.exit('characterReference'); - return ok - } + // This code is unreachable since it's handled by the lexState. + // throw invalidToken() + }, - if (test(code) && size++ < max) { - effects.consume(code); - return value - } + end () { + // This code is unreachable since it's handled by the lexState. + // if (token.type !== 'eof') { + // throw invalidToken() + // } + }, +}; - return nok(code) - } -} +function push$1 () { + let value; -var characterReference_1 = characterReference$2; + switch (token.type) { + case 'punctuator': + switch (token.value) { + case '{': + value = {}; + break -var markdownLineEnding$e = markdownLineEnding_1; -var markdownLineEndingOrSpace$7 = markdownLineEndingOrSpace_1; -var prefixSize$2 = prefixSize_1; -var factorySpace$b = factorySpace$i; + case '[': + value = []; + break + } -var codeFenced$1 = { - name: 'codeFenced', - tokenize: tokenizeCodeFenced, - concrete: true -}; + break -function tokenizeCodeFenced(effects, ok, nok) { - var self = this; - var closingFenceConstruct = { - tokenize: tokenizeClosingFence, - partial: true - }; - var initialPrefix = prefixSize$2(this.events, 'linePrefix'); - var sizeOpen = 0; - var marker; - return start + case 'null': + case 'boolean': + case 'numeric': + case 'string': + value = token.value; + break - function start(code) { - effects.enter('codeFenced'); - effects.enter('codeFencedFence'); - effects.enter('codeFencedFenceSequence'); - marker = code; - return sequenceOpen(code) - } - - function sequenceOpen(code) { - if (code === marker) { - effects.consume(code); - sizeOpen++; - return sequenceOpen - } - - effects.exit('codeFencedFenceSequence'); - return sizeOpen < 3 - ? nok(code) - : factorySpace$b(effects, infoOpen, 'whitespace')(code) - } - - function infoOpen(code) { - if (code === null || markdownLineEnding$e(code)) { - return openAfter(code) + // This code is unreachable. + // default: + // throw invalidToken() } - effects.enter('codeFencedFenceInfo'); - effects.enter('chunkString', { - contentType: 'string' - }); - return info(code) - } - - function info(code) { - if (code === null || markdownLineEndingOrSpace$7(code)) { - effects.exit('chunkString'); - effects.exit('codeFencedFenceInfo'); - return factorySpace$b(effects, infoAfter, 'whitespace')(code) + if (root$1 === undefined) { + root$1 = value; + } else { + const parent = stack[stack.length - 1]; + if (Array.isArray(parent)) { + parent.push(value); + } else { + parent[key] = value; + } } - if (code === 96 && code === marker) return nok(code) - effects.consume(code); - return info - } + if (value !== null && typeof value === 'object') { + stack.push(value); - function infoAfter(code) { - if (code === null || markdownLineEnding$e(code)) { - return openAfter(code) + if (Array.isArray(value)) { + parseState = 'beforeArrayValue'; + } else { + parseState = 'beforePropertyName'; + } + } else { + const current = stack[stack.length - 1]; + if (current == null) { + parseState = 'end'; + } else if (Array.isArray(current)) { + parseState = 'afterArrayValue'; + } else { + parseState = 'afterPropertyValue'; + } } +} - effects.enter('codeFencedFenceMeta'); - effects.enter('chunkString', { - contentType: 'string' - }); - return meta(code) - } +function pop () { + stack.pop(); - function meta(code) { - if (code === null || markdownLineEnding$e(code)) { - effects.exit('chunkString'); - effects.exit('codeFencedFenceMeta'); - return openAfter(code) + const current = stack[stack.length - 1]; + if (current == null) { + parseState = 'end'; + } else if (Array.isArray(current)) { + parseState = 'afterArrayValue'; + } else { + parseState = 'afterPropertyValue'; } +} - if (code === 96 && code === marker) return nok(code) - effects.consume(code); - return meta - } +// This code is unreachable. +// function invalidParseState () { +// return new Error(`JSON5: invalid parse state '${parseState}'`) +// } - function openAfter(code) { - effects.exit('codeFencedFence'); - return self.interrupt ? ok(code) : content(code) - } +// This code is unreachable. +// function invalidLexState (state) { +// return new Error(`JSON5: invalid lex state '${state}'`) +// } - function content(code) { - if (code === null) { - return after(code) +function invalidChar (c) { + if (c === undefined) { + return syntaxError(`JSON5: invalid end of input at ${line}:${column}`) } - if (markdownLineEnding$e(code)) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return effects.attempt( - closingFenceConstruct, - after, - initialPrefix - ? factorySpace$b(effects, content, 'linePrefix', initialPrefix + 1) - : content - ) - } + return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`) +} - effects.enter('codeFlowValue'); - return contentContinue(code) - } +function invalidEOF () { + return syntaxError(`JSON5: invalid end of input at ${line}:${column}`) +} - function contentContinue(code) { - if (code === null || markdownLineEnding$e(code)) { - effects.exit('codeFlowValue'); - return content(code) - } +// This code is unreachable. +// function invalidToken () { +// if (token.type === 'eof') { +// return syntaxError(`JSON5: invalid end of input at ${line}:${column}`) +// } - effects.consume(code); - return contentContinue - } +// const c = String.fromCodePoint(token.value.codePointAt(0)) +// return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`) +// } - function after(code) { - effects.exit('codeFenced'); - return ok(code) - } +function invalidIdentifier () { + column -= 5; + return syntaxError(`JSON5: invalid identifier character at ${line}:${column}`) +} - function tokenizeClosingFence(effects, ok, nok) { - var size = 0; - return factorySpace$b( - effects, - closingSequenceStart, - 'linePrefix', - this.parser.constructs.disable.null.indexOf('codeIndented') > -1 - ? undefined - : 4 - ) +function separatorChar (c) { + console.warn(`JSON5: '${formatChar(c)}' in strings is not valid ECMAScript; consider escaping`); +} - function closingSequenceStart(code) { - effects.enter('codeFencedFence'); - effects.enter('codeFencedFenceSequence'); - return closingSequence(code) - } +function formatChar (c) { + const replacements = { + "'": "\\'", + '"': '\\"', + '\\': '\\\\', + '\b': '\\b', + '\f': '\\f', + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\v': '\\v', + '\0': '\\0', + '\u2028': '\\u2028', + '\u2029': '\\u2029', + }; - function closingSequence(code) { - if (code === marker) { - effects.consume(code); - size++; - return closingSequence - } + if (replacements[c]) { + return replacements[c] + } - if (size < sizeOpen) return nok(code) - effects.exit('codeFencedFenceSequence'); - return factorySpace$b(effects, closingSequenceEnd, 'whitespace')(code) + if (c < ' ') { + const hexString = c.charCodeAt(0).toString(16); + return '\\x' + ('00' + hexString).substring(hexString.length) } - function closingSequenceEnd(code) { - if (code === null || markdownLineEnding$e(code)) { - effects.exit('codeFencedFence'); - return ok(code) - } + return c +} - return nok(code) - } - } +function syntaxError (message) { + const err = new SyntaxError(message); + err.lineNumber = line; + err.columnNumber = column; + return err } -var codeFenced_1 = codeFenced$1; +var stringify = function stringify (value, replacer, space) { + const stack = []; + let indent = ''; + let propertyList; + let replacerFunc; + let gap = ''; + let quote; -var markdownLineEnding$d = markdownLineEnding_1; -var chunkedSplice$2 = chunkedSplice_1; -var prefixSize$1 = prefixSize_1; -var factorySpace$a = factorySpace$i; + if ( + replacer != null && + typeof replacer === 'object' && + !Array.isArray(replacer) + ) { + space = replacer.space; + quote = replacer.quote; + replacer = replacer.replacer; + } -var codeIndented$1 = { - name: 'codeIndented', - tokenize: tokenizeCodeIndented, - resolve: resolveCodeIndented -}; -var indentedContentConstruct = { - tokenize: tokenizeIndentedContent, - partial: true -}; + if (typeof replacer === 'function') { + replacerFunc = replacer; + } else if (Array.isArray(replacer)) { + propertyList = []; + for (const v of replacer) { + let item; -function resolveCodeIndented(events, context) { - var code = { - type: 'codeIndented', - start: events[0][1].start, - end: events[events.length - 1][1].end - }; - chunkedSplice$2(events, 0, 0, [['enter', code, context]]); - chunkedSplice$2(events, events.length, 0, [['exit', code, context]]); - return events -} + if (typeof v === 'string') { + item = v; + } else if ( + typeof v === 'number' || + v instanceof String || + v instanceof Number + ) { + item = String(v); + } -function tokenizeCodeIndented(effects, ok, nok) { - return effects.attempt(indentedContentConstruct, afterPrefix, nok) + if (item !== undefined && propertyList.indexOf(item) < 0) { + propertyList.push(item); + } + } + } - function afterPrefix(code) { - if (code === null) { - return ok(code) + if (space instanceof Number) { + space = Number(space); + } else if (space instanceof String) { + space = String(space); } - if (markdownLineEnding$d(code)) { - return effects.attempt(indentedContentConstruct, afterPrefix, ok)(code) + if (typeof space === 'number') { + if (space > 0) { + space = Math.min(10, Math.floor(space)); + gap = ' '.substr(0, space); + } + } else if (typeof space === 'string') { + gap = space.substr(0, 10); } - effects.enter('codeFlowValue'); - return content(code) - } + return serializeProperty('', {'': value}) - function content(code) { - if (code === null || markdownLineEnding$d(code)) { - effects.exit('codeFlowValue'); - return afterPrefix(code) - } + function serializeProperty (key, holder) { + let value = holder[key]; + if (value != null) { + if (typeof value.toJSON5 === 'function') { + value = value.toJSON5(key); + } else if (typeof value.toJSON === 'function') { + value = value.toJSON(key); + } + } - effects.consume(code); - return content - } -} + if (replacerFunc) { + value = replacerFunc.call(holder, key, value); + } -function tokenizeIndentedContent(effects, ok, nok) { - var self = this; - return factorySpace$a(effects, afterPrefix, 'linePrefix', 4 + 1) + if (value instanceof Number) { + value = Number(value); + } else if (value instanceof String) { + value = String(value); + } else if (value instanceof Boolean) { + value = value.valueOf(); + } - function afterPrefix(code) { - if (markdownLineEnding$d(code)) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return factorySpace$a(effects, afterPrefix, 'linePrefix', 4 + 1) + switch (value) { + case null: return 'null' + case true: return 'true' + case false: return 'false' + } + + if (typeof value === 'string') { + return quoteString(value) + } + + if (typeof value === 'number') { + return String(value) + } + + if (typeof value === 'object') { + return Array.isArray(value) ? serializeArray(value) : serializeObject(value) + } + + return undefined } - return prefixSize$1(self.events, 'linePrefix') < 4 ? nok(code) : ok(code) - } -} + function quoteString (value) { + const quotes = { + "'": 0.1, + '"': 0.2, + }; -var codeIndented_1 = codeIndented$1; + const replacements = { + "'": "\\'", + '"': '\\"', + '\\': '\\\\', + '\b': '\\b', + '\f': '\\f', + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\v': '\\v', + '\0': '\\0', + '\u2028': '\\u2028', + '\u2029': '\\u2029', + }; -var markdownLineEnding$c = markdownLineEnding_1; + let product = ''; -var codeText$1 = { - name: 'codeText', - tokenize: tokenizeCodeText, - resolve: resolveCodeText, - previous: previous$1 -}; + for (let i = 0; i < value.length; i++) { + const c = value[i]; + switch (c) { + case "'": + case '"': + quotes[c]++; + product += c; + continue -function resolveCodeText(events) { - var tailExitIndex = events.length - 4; - var headEnterIndex = 3; - var index; - var enter; // If we start and end with an EOL or a space. + case '\0': + if (util.isDigit(value[i + 1])) { + product += '\\x00'; + continue + } + } - if ( - (events[headEnterIndex][1].type === 'lineEnding' || - events[headEnterIndex][1].type === 'space') && - (events[tailExitIndex][1].type === 'lineEnding' || - events[tailExitIndex][1].type === 'space') - ) { - index = headEnterIndex; // And we have data. + if (replacements[c]) { + product += replacements[c]; + continue + } - while (++index < tailExitIndex) { - if (events[index][1].type === 'codeTextData') { - // Then we have padding. - events[tailExitIndex][1].type = events[headEnterIndex][1].type = - 'codeTextPadding'; - headEnterIndex += 2; - tailExitIndex -= 2; - break - } - } - } // Merge adjacent spaces and data. + if (c < ' ') { + let hexString = c.charCodeAt(0).toString(16); + product += '\\x' + ('00' + hexString).substring(hexString.length); + continue + } - index = headEnterIndex - 1; - tailExitIndex++; + product += c; + } - while (++index <= tailExitIndex) { - if (enter === undefined) { - if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') { - enter = index; - } - } else if ( - index === tailExitIndex || - events[index][1].type === 'lineEnding' - ) { - events[enter][1].type = 'codeTextData'; + const quoteChar = quote || Object.keys(quotes).reduce((a, b) => (quotes[a] < quotes[b]) ? a : b); - if (index !== enter + 2) { - events[enter][1].end = events[index - 1][1].end; - events.splice(enter + 2, index - enter - 2); - tailExitIndex -= index - enter - 2; - index = enter + 2; - } + product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]); - enter = undefined; + return quoteChar + product + quoteChar } - } - return events -} + function serializeObject (value) { + if (stack.indexOf(value) >= 0) { + throw TypeError('Converting circular structure to JSON5') + } -function previous$1(code) { - // If there is a previous code, there will always be a tail. - return ( - code !== 96 || - this.events[this.events.length - 1][1].type === 'characterEscape' - ) -} + stack.push(value); -function tokenizeCodeText(effects, ok, nok) { - var sizeOpen = 0; - var size; - var token; - return start + let stepback = indent; + indent = indent + gap; - function start(code) { - effects.enter('codeText'); - effects.enter('codeTextSequence'); - return openingSequence(code) - } + let keys = propertyList || Object.keys(value); + let partial = []; + for (const key of keys) { + const propertyString = serializeProperty(key, value); + if (propertyString !== undefined) { + let member = serializeKey(key) + ':'; + if (gap !== '') { + member += ' '; + } + member += propertyString; + partial.push(member); + } + } - function openingSequence(code) { - if (code === 96) { - effects.consume(code); - sizeOpen++; - return openingSequence + let final; + if (partial.length === 0) { + final = '{}'; + } else { + let properties; + if (gap === '') { + properties = partial.join(','); + final = '{' + properties + '}'; + } else { + let separator = ',\n' + indent; + properties = partial.join(separator); + final = '{\n' + indent + properties + ',\n' + stepback + '}'; + } + } + + stack.pop(); + indent = stepback; + return final } - effects.exit('codeTextSequence'); - return gap(code) - } + function serializeKey (key) { + if (key.length === 0) { + return quoteString(key) + } - function gap(code) { - // EOF. - if (code === null) { - return nok(code) - } // Closing fence? - // Could also be data. + const firstChar = String.fromCodePoint(key.codePointAt(0)); + if (!util.isIdStartChar(firstChar)) { + return quoteString(key) + } - if (code === 96) { - token = effects.enter('codeTextSequence'); - size = 0; - return closingSequence(code) - } // Tabs don’t work, and virtual spaces don’t make sense. + for (let i = firstChar.length; i < key.length; i++) { + if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) { + return quoteString(key) + } + } - if (code === 32) { - effects.enter('space'); - effects.consume(code); - effects.exit('space'); - return gap + return key } - if (markdownLineEnding$c(code)) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return gap - } // Data. + function serializeArray (value) { + if (stack.indexOf(value) >= 0) { + throw TypeError('Converting circular structure to JSON5') + } - effects.enter('codeTextData'); - return data(code) - } // In code. + stack.push(value); - function data(code) { - if ( - code === null || - code === 32 || - code === 96 || - markdownLineEnding$c(code) - ) { - effects.exit('codeTextData'); - return gap(code) + let stepback = indent; + indent = indent + gap; + + let partial = []; + for (let i = 0; i < value.length; i++) { + const propertyString = serializeProperty(String(i), value); + partial.push((propertyString !== undefined) ? propertyString : 'null'); + } + + let final; + if (partial.length === 0) { + final = '[]'; + } else { + if (gap === '') { + let properties = partial.join(','); + final = '[' + properties + ']'; + } else { + let separator = ',\n' + indent; + let properties = partial.join(separator); + final = '[\n' + indent + properties + ',\n' + stepback + ']'; + } + } + + stack.pop(); + indent = stepback; + return final } +}; - effects.consume(code); - return data - } // Closing fence. +const JSON5 = { + parse: parse$1, + stringify, +}; - function closingSequence(code) { - // More. - if (code === 96) { - effects.consume(code); - size++; - return closingSequence - } // Done! +var lib = JSON5; - if (size === sizeOpen) { - effects.exit('codeTextSequence'); - effects.exit('codeText'); - return ok(code) - } // More or less accents: mark as data. +/** + * @typedef Option + * @property {'boolean'|'string'} [type='string'] + * @property {string} long + * @property {string} description + * @property {string} [value] + * @property {string} [short] + * @property {boolean|string} [default=''] + * @property {boolean} [truelike=false] + */ - token.type = 'codeTextData'; - return data(code) +/** @type {Option[]} */ +const schema = [ + { + long: 'help', + description: 'output usage information', + short: 'h', + type: 'boolean', + default: false + }, + { + long: 'version', + description: 'output version number', + short: 'v', + type: 'boolean', + default: false + }, + { + long: 'output', + description: 'specify output location', + short: 'o', + value: '[path]' + }, + { + long: 'rc-path', + description: 'specify configuration file', + short: 'r', + type: 'string', + value: '' + }, + { + long: 'ignore-path', + description: 'specify ignore file', + short: 'i', + type: 'string', + value: '' + }, + { + long: 'setting', + description: 'specify settings', + short: 's', + type: 'string', + value: '' + }, + { + long: 'ext', + description: 'specify extensions', + short: 'e', + type: 'string', + value: '' + }, + { + long: 'use', + description: 'use plugins', + short: 'u', + type: 'string', + value: '' + }, + { + long: 'watch', + description: 'watch for changes and reprocess', + short: 'w', + type: 'boolean', + default: false + }, + { + long: 'quiet', + description: 'output only warnings and errors', + short: 'q', + type: 'boolean', + default: false + }, + { + long: 'silent', + description: 'output only errors', + short: 'S', + type: 'boolean', + default: false + }, + { + long: 'frail', + description: 'exit with 1 on warnings', + short: 'f', + type: 'boolean', + default: false + }, + { + long: 'tree', + description: 'specify input and output as syntax tree', + short: 't', + type: 'boolean', + default: false + }, + { + long: 'report', + description: 'specify reporter', + type: 'string', + value: '' + }, + { + long: 'file-path', + description: 'specify path to process as', + type: 'string', + value: '' + }, + { + long: 'ignore-path-resolve-from', + description: 'resolve patterns in `ignore-path` from its directory or cwd', + type: 'string', + value: 'dir|cwd', + default: 'dir' + }, + { + long: 'ignore-pattern', + description: 'specify ignore patterns', + type: 'string', + value: '' + }, + { + long: 'silently-ignore', + description: 'do not fail when given ignored files', + type: 'boolean' + }, + { + long: 'tree-in', + description: 'specify input as syntax tree', + type: 'boolean' + }, + { + long: 'tree-out', + description: 'output syntax tree', + type: 'boolean' + }, + { + long: 'inspect', + description: 'output formatted syntax tree', + type: 'boolean' + }, + { + long: 'stdout', + description: 'specify writing to stdout', + type: 'boolean', + truelike: true + }, + { + long: 'color', + description: 'specify color in report', + type: 'boolean', + default: true + }, + { + long: 'config', + description: 'search for configuration files', + type: 'boolean', + default: true + }, + { + long: 'ignore', + description: 'search for ignore files', + type: 'boolean', + default: true } -} +]; -var codeText_1 = codeText$1; +/** + * @typedef {import('unified-engine').Options} EngineOptions + * @typedef {import('./schema.js').Option} Option + * + * @typedef {Required< + * Pick< + * EngineOptions, + * | 'extensions' + * | 'ignoreName' + * | 'packageField' + * | 'pluginPrefix' + * | 'processor' + * | 'rcName' + * > + * >} RequiredEngineOptions + * + * @typedef ArgsOptionsFields + * @property {string} name + * Name of executable + * @property {string} description + * Description of executable + * @property {string} version + * Version (semver) of executable + * + * @typedef {RequiredEngineOptions & Pick & ArgsOptionsFields} Options + */ -var asciiControl$1 = asciiControl_1; -var markdownLineEndingOrSpace$6 = markdownLineEndingOrSpace_1; -var markdownLineEnding$b = markdownLineEnding_1; +const own$7 = {}.hasOwnProperty; -// eslint-disable-next-line max-params -function destinationFactory( - effects, - ok, - nok, - type, - literalType, - literalMarkerType, - rawType, - stringType, - max -) { - var limit = max || Infinity; - var balance = 0; - return start +/** + * Schema for `minimist`. + */ +const minischema = { + unknown: handleUnknownArgument, + /** @type {Record} */ + default: {}, + /** @type {Record} */ + alias: {}, + /** @type {string[]} */ + string: [], + /** @type {string[]} */ + boolean: [] +}; - function start(code) { - if (code === 60) { - effects.enter(type); - effects.enter(literalType); - effects.enter(literalMarkerType); - effects.consume(code); - effects.exit(literalMarkerType); - return destinationEnclosedBefore - } +let index = -1; +while (++index < schema.length) { + addEach(schema[index]); +} - if (asciiControl$1(code) || code === 41) { - return nok(code) - } +/** + * Parse CLI options. + * + * @param {string[]} flags + * @param {Options} configuration + */ +function options(flags, configuration) { + const extension = configuration.extensions[0]; + const name = configuration.name; + const config = toCamelCase(minimist(flags, minischema)); + let index = -1; - effects.enter(type); - effects.enter(rawType); - effects.enter(stringType); - effects.enter('chunkString', { - contentType: 'string' - }); - return destinationRaw(code) + while (++index < schema.length) { + const option = schema[index]; + if (option.type === 'string' && config[option.long] === '') { + throw fault('Missing value:%s', inspect(option).join(' ')) + } } - function destinationEnclosedBefore(code) { - if (code === 62) { - effects.enter(literalMarkerType); - effects.consume(code); - effects.exit(literalMarkerType); - effects.exit(literalType); - effects.exit(type); - return ok - } + const ext = commaSeparated(/** @type {string} */ (config.ext)); + const report = reporter(/** @type {string} */ (config.report)); + const help = [ + inspectAll(schema), + '', + 'Examples:', + '', + ' # Process `input.' + extension + '`', + ' $ ' + name + ' input.' + extension + ' -o output.' + extension, + '', + ' # Pipe', + ' $ ' + name + ' < input.' + extension + ' > output.' + extension, + '', + ' # Rewrite all applicable files', + ' $ ' + name + ' . -o' + ].join('\n'); - effects.enter(stringType); - effects.enter('chunkString', { - contentType: 'string' - }); - return destinationEnclosed(code) + return { + helpMessage: help, + cwd: configuration.cwd, + processor: configuration.processor, + help: config.help, + version: config.version, + files: config._, + filePath: config.filePath, + watch: config.watch, + extensions: ext.length === 0 ? configuration.extensions : ext, + output: config.output, + out: config.stdout, + tree: config.tree, + treeIn: config.treeIn, + treeOut: config.treeOut, + inspect: config.inspect, + rcName: configuration.rcName, + packageField: configuration.packageField, + rcPath: config.rcPath, + detectConfig: config.config, + settings: /** @type {Record} */ ( + settings(/** @type {string} */ (config.setting)) + ), + ignoreName: configuration.ignoreName, + ignorePath: config.ignorePath, + ignorePathResolveFrom: config.ignorePathResolveFrom, + ignorePatterns: commaSeparated( + /** @type {string} */ (config.ignorePattern) + ), + silentlyIgnore: config.silentlyIgnore, + detectIgnore: config.ignore, + pluginPrefix: configuration.pluginPrefix, + plugins: plugins$2(/** @type {string} */ (config.use)), + reporter: report[0], + reporterOptions: report[1], + color: config.color, + silent: config.silent, + quiet: config.quiet, + frail: config.frail } +} - function destinationEnclosed(code) { - if (code === 62) { - effects.exit('chunkString'); - effects.exit(stringType); - return destinationEnclosedBefore(code) - } +/** + * @param {Option} option + */ +function addEach(option) { + const value = option.default; - if (code === null || code === 60 || markdownLineEnding$b(code)) { - return nok(code) - } + minischema.default[option.long] = value === undefined ? null : value; - effects.consume(code); - return code === 92 ? destinationEnclosedEscape : destinationEnclosed + if (option.type && option.type in minischema) { + minischema[option.type].push(option.long); } - function destinationEnclosedEscape(code) { - if (code === 60 || code === 62 || code === 92) { - effects.consume(code); - return destinationEnclosed - } - - return destinationEnclosed(code) + if (option.short) { + minischema.alias[option.short] = option.long; } +} - function destinationRaw(code) { - if (code === 40) { - if (++balance > limit) return nok(code) - effects.consume(code); - return destinationRaw - } - - if (code === 41) { - if (!balance--) { - effects.exit('chunkString'); - effects.exit(stringType); - effects.exit(rawType); - effects.exit(type); - return ok(code) - } - - effects.consume(code); - return destinationRaw - } +/** + * Parse `extensions`. + * + * @param {string[]|string|null|undefined} value + * @returns {string[]} + */ +function commaSeparated(value) { + return flatten(normalize(value).map((d) => splitList(d))) +} - if (code === null || markdownLineEndingOrSpace$6(code)) { - if (balance) return nok(code) - effects.exit('chunkString'); - effects.exit(stringType); - effects.exit(rawType); - effects.exit(type); - return ok(code) - } +/** + * Parse `plugins`. + * + * @param {string[]|string|null|undefined} value + * @returns {Record|undefined>} + */ +function plugins$2(value) { + const normalized = normalize(value).map((d) => splitOptions(d)); + let index = -1; + /** @type {Record|undefined>} */ + const result = {}; - if (asciiControl$1(code)) return nok(code) - effects.consume(code); - return code === 92 ? destinationRawEscape : destinationRaw + while (++index < normalized.length) { + const value = normalized[index]; + result[value[0]] = value[1] ? parseConfig(value[1], {}) : undefined; } - function destinationRawEscape(code) { - if (code === 40 || code === 41 || code === 92) { - effects.consume(code); - return destinationRaw - } - - return destinationRaw(code) - } + return result } -var factoryDestination$2 = destinationFactory; +/** + * Parse `reporter`: only one is accepted. + * + * @param {string[]|string|null|undefined} value + * @returns {[string|undefined, Record|undefined]} + */ +function reporter(value) { + const all = normalize(value) + .map((d) => splitOptions(d)) + .map( + /** + * @returns {[string, Record|undefined]} + */ + (value) => [value[0], value[1] ? parseConfig(value[1], {}) : undefined] + ); -var markdownLineEnding$a = markdownLineEnding_1; -var markdownSpace$7 = markdownSpace_1; + return all[all.length - 1] || [] +} -// eslint-disable-next-line max-params -function labelFactory(effects, ok, nok, type, markerType, stringType) { - var self = this; - var size = 0; - var data; - return start +/** + * Parse `settings`. + * + * @param {string[]|string|null|undefined} value + * @returns {Record} + */ +function settings(value) { + const normalized = normalize(value); + let index = -1; + /** @type {Record} */ + const cache = {}; - function start(code) { - effects.enter(type); - effects.enter(markerType); - effects.consume(code); - effects.exit(markerType); - effects.enter(stringType); - return atBreak + while (++index < normalized.length) { + parseConfig(normalized[index], cache); } - function atBreak(code) { - if ( - code === null || - code === 91 || - (code === 93 && !data) || - /* c8 ignore next */ - (code === 94 && - /* c8 ignore next */ - !size && - /* c8 ignore next */ - '_hiddenFootnoteSupport' in self.parser.constructs) || - size > 999 - ) { - return nok(code) - } - - if (code === 93) { - effects.exit(stringType); - effects.enter(markerType); - effects.consume(code); - effects.exit(markerType); - effects.exit(type); - return ok - } + return cache +} - if (markdownLineEnding$a(code)) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return atBreak - } +/** + * Parse configuration. + * + * @param {string} value + * @param {Record} cache + * @returns {Record} + */ +function parseConfig(value, cache) { + /** @type {Record} */ + let flags; + /** @type {string} */ + let flag; - effects.enter('chunkString', { - contentType: 'string' - }); - return label(code) + try { + flags = toCamelCase(parseJSON(value)); + } catch (error) { + throw fault( + 'Cannot parse `%s` as JSON: %s', + value, + // Fix position + error.message.replace(/at(?= position)/, 'around') + ) } - function label(code) { - if ( - code === null || - code === 91 || - code === 93 || - markdownLineEnding$a(code) || - size++ > 999 - ) { - effects.exit('chunkString'); - return atBreak(code) + for (flag in flags) { + if (own$7.call(flags, flag)) { + cache[flag] = flags[flag]; } - - effects.consume(code); - data = data || !markdownSpace$7(code); - return code === 92 ? labelEscape : label } - function labelEscape(code) { - if (code === 91 || code === 92 || code === 93) { - effects.consume(code); - size++; - return label - } - - return label(code) - } + return cache } -var factoryLabel$2 = labelFactory; - -var markdownLineEnding$9 = markdownLineEnding_1; -var markdownSpace$6 = markdownSpace_1; -var factorySpace$9 = factorySpace$i; +/** + * Handle an unknown flag. + * + * @param {string} flag + * @returns {boolean} + */ +function handleUnknownArgument(flag) { + // Not a glob. + if (flag.charAt(0) === '-') { + // Long options, always unknown. + if (flag.charAt(1) === '-') { + throw fault( + 'Unknown option `%s`, expected:\n%s', + flag, + inspectAll(schema) + ) + } -function whitespaceFactory(effects, ok) { - var seen; - return start + // Short options, can be grouped. + const found = flag.slice(1).split(''); + const known = schema.filter((d) => d.short); + const knownKeys = new Set(known.map((d) => d.short)); + let index = -1; - function start(code) { - if (markdownLineEnding$9(code)) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - seen = true; - return start + while (++index < found.length) { + const key = found[index]; + if (!knownKeys.has(key)) { + throw fault( + 'Unknown short option `-%s`, expected:\n%s', + key, + inspectAll(known) + ) + } } + } - if (markdownSpace$6(code)) { - return factorySpace$9( - effects, - start, - seen ? 'linePrefix' : 'lineSuffix' - )(code) - } + return true +} - return ok(code) - } +/** + * Inspect all `options`. + * + * @param {Option[]} options + * @returns {string} + */ +function inspectAll(options) { + return textTable(options.map((d) => inspect(d))) } -var factoryWhitespace$2 = whitespaceFactory; +/** + * Inspect one `option`. + * + * @param {Option} option + * @returns {string[]} + */ +function inspect(option) { + let description = option.description; + let long = option.long; -var markdownLineEnding$8 = markdownLineEnding_1; -var factorySpace$8 = factorySpace$i; + if (option.default === true || option.truelike) { + description += ' (on by default)'; + long = '[no-]' + long; + } -function titleFactory(effects, ok, nok, type, markerType, stringType) { - var marker; - return start + return [ + '', + option.short ? '-' + option.short : '', + '--' + long + (option.value ? ' ' + option.value : ''), + description + ] +} - function start(code) { - effects.enter(type); - effects.enter(markerType); - effects.consume(code); - effects.exit(markerType); - marker = code === 40 ? 41 : code; - return atFirstTitleBreak +/** + * Normalize `value`. + * + * @param {string[]|string|null|undefined} value + * @returns {string[]} + */ +function normalize(value) { + if (!value) { + return [] } - function atFirstTitleBreak(code) { - if (code === marker) { - effects.enter(markerType); - effects.consume(code); - effects.exit(markerType); - effects.exit(type); - return ok - } - - effects.enter(stringType); - return atTitleBreak(code) + if (typeof value === 'string') { + return [value] } - function atTitleBreak(code) { - if (code === marker) { - effects.exit(stringType); - return atFirstTitleBreak(marker) - } + return flatten(value.map((d) => normalize(d))) +} - if (code === null) { - return nok(code) - } // Note: blank lines can’t exist in content. +/** + * Flatten `values`. + * + * @param {string|string[]|string[][]} values + * @returns {string[]} + */ +function flatten(values) { + // @ts-expect-error: TS is wrong. + return values.flat() +} - if (markdownLineEnding$8(code)) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return factorySpace$8(effects, atTitleBreak, 'linePrefix') - } +/** + * @param {string} value + * @returns {string[]} + */ +function splitOptions(value) { + return value.split('=') +} - effects.enter('chunkString', { - contentType: 'string' - }); - return title(code) - } +/** + * @param {string} value + * @returns {string[]} + */ +function splitList(value) { + return value.split(',') +} - function title(code) { - if (code === marker || code === null || markdownLineEnding$8(code)) { - effects.exit('chunkString'); - return atTitleBreak(code) - } +/** + * Transform the keys on an object to camel-case, recursivly. + * + * @param {Record} object + * @returns {Record} + */ +function toCamelCase(object) { + /** @type {Record} */ + const result = {}; + /** @type {string} */ + let key; - effects.consume(code); - return code === 92 ? titleEscape : title - } + for (key in object) { + if (own$7.call(object, key)) { + let value = object[key]; - function titleEscape(code) { - if (code === marker || code === 92) { - effects.consume(code); - return title - } + if (value && typeof value === 'object' && !Array.isArray(value)) { + // @ts-expect-error: looks like an object. + value = toCamelCase(value); + } - return title(code) + result[camelcase(key)] = value; + } } -} -var factoryTitle$2 = titleFactory; + return result +} -var markdownLineEnding$7 = markdownLineEnding_1; -var markdownLineEndingOrSpace$5 = markdownLineEndingOrSpace_1; -var normalizeIdentifier$3 = normalizeIdentifier_1; -var factoryDestination$1 = factoryDestination$2; -var factoryLabel$1 = factoryLabel$2; -var factorySpace$7 = factorySpace$i; -var factoryWhitespace$1 = factoryWhitespace$2; -var factoryTitle$1 = factoryTitle$2; +/** + * Parse a (lazy?) JSON config. + * + * @param {string} value + * @returns {Record} + */ +function parseJSON(value) { + return lib.parse('{' + value + '}') +} -var definition$2 = { - name: 'definition', - tokenize: tokenizeDefinition -}; -var titleConstruct = { - tokenize: tokenizeTitle, - partial: true -}; +/** + * @typedef {import('unified-engine').Options} EngineOptions + * @typedef {import('unified-engine').Context} EngineContext + * @typedef {import('unified-engine').Callback} EngineCallback + * @typedef {import('./options.js').Options} Options + */ -function tokenizeDefinition(effects, ok, nok) { - var self = this; - var identifier; - return start +// Fake TTY stream. +const ttyStream = Object.assign(new stream__default['default'].Readable(), {isTTY: true}); - function start(code) { - effects.enter('definition'); - return factoryLabel$1.call( - self, - effects, - labelAfter, - nok, - 'definitionLabel', - 'definitionLabelMarker', - 'definitionLabelString' - )(code) +// Exit, lazily, with the correct exit status code. +let exitStatus = 0; + +process__default$1['default'].on('exit', onexit); + +// Handle uncaught errors, such as from unexpected async behaviour. +process__default$1['default'].on('uncaughtException', fail); + +/** + * Start the CLI. + * + * @param {Options} cliConfig + */ +function args(cliConfig) { + /** @type {EngineOptions & {help: boolean, helpMessage: string, watch: boolean, version: boolean}} */ + let config; + /** @type {chokidar.FSWatcher|undefined} */ + let watcher; + /** @type {boolean|string|undefined} */ + let output; + + try { + // @ts-expect-error: Close enough. + config = options(process__default$1['default'].argv.slice(2), cliConfig); + } catch (error) { + return fail(error, true) } - function labelAfter(code) { - identifier = normalizeIdentifier$3( - self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + if (config.help) { + process__default$1['default'].stdout.write( + [ + 'Usage: ' + cliConfig.name + ' [options] [path | glob ...]', + '', + ' ' + cliConfig.description, + '', + 'Options:', + '', + config.helpMessage, + '' + ].join('\n'), + noop$1 ); - if (code === 58) { - effects.enter('definitionMarker'); - effects.consume(code); - effects.exit('definitionMarker'); // Note: blank lines can’t exist in content. + return + } - return factoryWhitespace$1( - effects, - factoryDestination$1( - effects, - effects.attempt( - titleConstruct, - factorySpace$7(effects, after, 'whitespace'), - factorySpace$7(effects, after, 'whitespace') - ), - nok, - 'definitionDestination', - 'definitionDestinationLiteral', - 'definitionDestinationLiteralMarker', - 'definitionDestinationRaw', - 'definitionDestinationString' - ) - ) - } + if (config.version) { + process__default$1['default'].stdout.write(cliConfig.version + '\n', noop$1); - return nok(code) + return } - function after(code) { - if (code === null || markdownLineEnding$7(code)) { - effects.exit('definition'); + // Modify `config` for watching. + if (config.watch) { + output = config.output; - if (self.parser.defined.indexOf(identifier) < 0) { - self.parser.defined.push(identifier); - } + // Do not read from stdin(4). + config.streamIn = ttyStream; - return ok(code) - } + // Do not write to stdout(4). + config.out = false; - return nok(code) - } -} + process__default$1['default'].stderr.write( + source$1.bold('Watching...') + ' (press CTRL+C to exit)\n', + noop$1 + ); -function tokenizeTitle(effects, ok, nok) { - return start + // Prevent infinite loop if set to regeneration. + if (output === true) { + config.output = false; - function start(code) { - return markdownLineEndingOrSpace$5(code) - ? factoryWhitespace$1(effects, before)(code) - : nok(code) + process__default$1['default'].stderr.write( + source$1.yellow('Note') + ': Ignoring `--output` until exit.\n', + noop$1 + ); + } } - function before(code) { - if (code === 34 || code === 39 || code === 40) { - return factoryTitle$1( - effects, - factorySpace$7(effects, after, 'whitespace'), - nok, - 'definitionTitle', - 'definitionTitleMarker', - 'definitionTitleString' - )(code) - } + // Initial run. + engine(config, done); - return nok(code) - } + /** + * Handle complete run. + * + * @type {EngineCallback} + */ + function done(error, code, context) { + if (error) { + clean(); + fail(error); + } else { + exitStatus = code || 0; - function after(code) { - return code === null || markdownLineEnding$7(code) ? ok(code) : nok(code) + if (config.watch && !watcher && context) { + subscribe(context); + } + } } -} -var definition_1$1 = definition$2; + // Clean the watcher. + function clean() { + if (watcher) { + watcher.close(); + watcher = undefined; + } + } -var markdownLineEnding$6 = markdownLineEnding_1; + /** + * Subscribe a chokidar watcher to all processed files. + * + * @param {EngineContext} context + */ + function subscribe(context) { + watcher = chokidar + // @ts-expect-error: `fileSet` is available. + .watch(context.fileSet.origins, {cwd: config.cwd, ignoreInitial: true}) + .on('error', done) + .on('change', (filePath) => { + config.files = [filePath]; + engine(config, done); + }); -var hardBreakEscape$1 = { - name: 'hardBreakEscape', - tokenize: tokenizeHardBreakEscape -}; + process__default$1['default'].on('SIGINT', onsigint); -function tokenizeHardBreakEscape(effects, ok, nok) { - return start + /** + * Handle a SIGINT. + */ + function onsigint() { + // Hide the `^C` in terminal. + process__default$1['default'].stderr.write('\n', noop$1); - function start(code) { - effects.enter('hardBreakEscape'); - effects.enter('escapeMarker'); - effects.consume(code); - return open - } + clean(); - function open(code) { - if (markdownLineEnding$6(code)) { - effects.exit('escapeMarker'); - effects.exit('hardBreakEscape'); - return ok(code) + // Do another process if `output` specified regeneration. + if (output === true) { + config.output = output; + config.watch = false; + engine(config, done); + } } - - return nok(code) } } -var hardBreakEscape_1 = hardBreakEscape$1; +/** + * Print an error, optionally with stack. + * + * @param {Error} error + * @param {boolean} [pretty=false] + */ +function fail(error, pretty) { + // Old versions of Node + /* c8 ignore next 1 */ + const message = String((pretty ? error : error.stack) || error); -var markdownLineEnding$5 = markdownLineEnding_1; -var markdownLineEndingOrSpace$4 = markdownLineEndingOrSpace_1; -var markdownSpace$5 = markdownSpace_1; -var chunkedSplice$1 = chunkedSplice_1; -var factorySpace$6 = factorySpace$i; + exitStatus = 1; -var headingAtx$1 = { - name: 'headingAtx', - tokenize: tokenizeHeadingAtx, - resolve: resolveHeadingAtx -}; + process__default$1['default'].stderr.write(message.trim() + '\n', noop$1); +} -function resolveHeadingAtx(events, context) { - var contentEnd = events.length - 2; - var contentStart = 3; - var content; - var text; // Prefix whitespace, part of the opening. +function onexit() { + /* eslint-disable unicorn/no-process-exit */ + process__default$1['default'].exit(exitStatus); + /* eslint-enable unicorn/no-process-exit */ +} - if (events[contentStart][1].type === 'whitespace') { - contentStart += 2; - } // Suffix whitespace, part of the closing. +function noop$1() {} - if ( - contentEnd - 2 > contentStart && - events[contentEnd][1].type === 'whitespace' - ) { - contentEnd -= 2; - } +var require$$0 = [ + "md", + "markdown", + "mdown", + "mkdn", + "mkd", + "mdwn", + "mkdown", + "ron" +]; - if ( - events[contentEnd][1].type === 'atxHeadingSequence' && - (contentStart === contentEnd - 1 || - (contentEnd - 4 > contentStart && - events[contentEnd - 2][1].type === 'whitespace')) - ) { - contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; - } +var markdownExtensions = require$$0; - if (contentEnd > contentStart) { - content = { - type: 'atxHeadingText', - start: events[contentStart][1].start, - end: events[contentEnd][1].end - }; - text = { - type: 'chunkText', - start: events[contentStart][1].start, - end: events[contentEnd][1].end, - contentType: 'text' - }; - chunkedSplice$1(events, contentStart, contentEnd - contentStart + 1, [ - ['enter', content, context], - ['enter', text, context], - ['exit', text, context], - ['exit', content, context] - ]); +/** + * Throw a given error. + * + * @param {Error | null | undefined} [error] + */ +function bail(error) { + if (error) { + throw error } - - return events } -function tokenizeHeadingAtx(effects, ok, nok) { - var self = this; - var size = 0; - return start - - function start(code) { - effects.enter('atxHeading'); - effects.enter('atxHeadingSequence'); - return fenceOpenInside(code) - } +var hasOwn = Object.prototype.hasOwnProperty; +var toStr = Object.prototype.toString; +var defineProperty = Object.defineProperty; +var gOPD = Object.getOwnPropertyDescriptor; - function fenceOpenInside(code) { - if (code === 35 && size++ < 6) { - effects.consume(code); - return fenceOpenInside - } +var isArray = function isArray(arr) { + if (typeof Array.isArray === 'function') { + return Array.isArray(arr); + } - if (code === null || markdownLineEndingOrSpace$4(code)) { - effects.exit('atxHeadingSequence'); - return self.interrupt ? ok(code) : headingBreak(code) - } + return toStr.call(arr) === '[object Array]'; +}; - return nok(code) - } +var isPlainObject = function isPlainObject(obj) { + if (!obj || toStr.call(obj) !== '[object Object]') { + return false; + } - function headingBreak(code) { - if (code === 35) { - effects.enter('atxHeadingSequence'); - return sequence(code) - } + var hasOwnConstructor = hasOwn.call(obj, 'constructor'); + var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); + // Not own constructor property must be Object + if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { + return false; + } - if (code === null || markdownLineEnding$5(code)) { - effects.exit('atxHeading'); - return ok(code) - } + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + var key; + for (key in obj) { /**/ } - if (markdownSpace$5(code)) { - return factorySpace$6(effects, headingBreak, 'whitespace')(code) - } + return typeof key === 'undefined' || hasOwn.call(obj, key); +}; - effects.enter('atxHeadingText'); - return data(code) - } +// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target +var setProperty = function setProperty(target, options) { + if (defineProperty && options.name === '__proto__') { + defineProperty(target, options.name, { + enumerable: true, + configurable: true, + value: options.newValue, + writable: true + }); + } else { + target[options.name] = options.newValue; + } +}; - function sequence(code) { - if (code === 35) { - effects.consume(code); - return sequence - } +// Return undefined instead of __proto__ if '__proto__' is not an own property +var getProperty = function getProperty(obj, name) { + if (name === '__proto__') { + if (!hasOwn.call(obj, name)) { + return void 0; + } else if (gOPD) { + // In early versions of node, obj['__proto__'] is buggy when obj has + // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. + return gOPD(obj, name).value; + } + } - effects.exit('atxHeadingSequence'); - return headingBreak(code) - } + return obj[name]; +}; - function data(code) { - if (code === null || code === 35 || markdownLineEndingOrSpace$4(code)) { - effects.exit('atxHeadingText'); - return headingBreak(code) - } +var extend = function extend() { + var options, name, src, copy, copyIsArray, clone; + var target = arguments[0]; + var i = 1; + var length = arguments.length; + var deep = false; - effects.consume(code); - return data - } -} + // Handle a deep copy situation + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { + target = {}; + } -var headingAtx_1 = headingAtx$1; + for (; i < length; ++i) { + options = arguments[i]; + // Only deal with non-null/undefined values + if (options != null) { + // Extend the base object + for (name in options) { + src = getProperty(target, name); + copy = getProperty(options, name); -// This module is copied from . -var basics = [ - 'address', - 'article', - 'aside', - 'base', - 'basefont', - 'blockquote', - 'body', - 'caption', - 'center', - 'col', - 'colgroup', - 'dd', - 'details', - 'dialog', - 'dir', - 'div', - 'dl', - 'dt', - 'fieldset', - 'figcaption', - 'figure', - 'footer', - 'form', - 'frame', - 'frameset', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'head', - 'header', - 'hr', - 'html', - 'iframe', - 'legend', - 'li', - 'link', - 'main', - 'menu', - 'menuitem', - 'nav', - 'noframes', - 'ol', - 'optgroup', - 'option', - 'p', - 'param', - 'section', - 'source', - 'summary', - 'table', - 'tbody', - 'td', - 'tfoot', - 'th', - 'thead', - 'title', - 'tr', - 'track', - 'ul' -]; + // Prevent never-ending loop + if (target !== copy) { + // Recurse if we're merging plain objects or arrays + if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && isArray(src) ? src : []; + } else { + clone = src && isPlainObject(src) ? src : {}; + } -var htmlBlockNames$1 = basics; + // Never move original objects, clone them + setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); -// This module is copied from . -var raws = ['pre', 'script', 'style', 'textarea']; + // Don't bring in undefined values + } else if (typeof copy !== 'undefined') { + setProperty(target, { name: name, newValue: copy }); + } + } + } + } + } -var htmlRawNames$1 = raws; + // Return the modified object + return target; +}; -var asciiAlpha$2 = asciiAlpha_1; -var asciiAlphanumeric$2 = asciiAlphanumeric_1; -var markdownLineEnding$4 = markdownLineEnding_1; -var markdownLineEndingOrSpace$3 = markdownLineEndingOrSpace_1; -var markdownSpace$4 = markdownSpace_1; -var fromCharCode = fromCharCode_1; -var htmlBlockNames = htmlBlockNames$1; -var htmlRawNames = htmlRawNames$1; -var partialBlankLine$1 = partialBlankLine_1; +/** + * @typedef {import('unist').Node} Node + * @typedef {import('vfile').VFileCompatible} VFileCompatible + * @typedef {import('vfile').VFileValue} VFileValue + * @typedef {import('..').Processor} Processor + * @typedef {import('..').Plugin} Plugin + * @typedef {import('..').Preset} Preset + * @typedef {import('..').Pluggable} Pluggable + * @typedef {import('..').PluggableList} PluggableList + * @typedef {import('..').Transformer} Transformer + * @typedef {import('..').Parser} Parser + * @typedef {import('..').Compiler} Compiler + * @typedef {import('..').RunCallback} RunCallback + * @typedef {import('..').ProcessCallback} ProcessCallback + * + * @typedef Context + * @property {Node} tree + * @property {VFile} file + */ -var htmlFlow$1 = { - name: 'htmlFlow', - tokenize: tokenizeHtmlFlow, - resolveTo: resolveToHtmlFlow, - concrete: true -}; -var nextBlankConstruct = { - tokenize: tokenizeNextBlank, - partial: true -}; +// Expose a frozen processor. +const unified = base().freeze(); -function resolveToHtmlFlow(events) { - var index = events.length; +const own$6 = {}.hasOwnProperty; - while (index--) { - if (events[index][0] === 'enter' && events[index][1].type === 'htmlFlow') { - break - } - } +// Function to create the first processor. +/** + * @returns {Processor} + */ +function base() { + const transformers = trough(); + /** @type {Processor['attachers']} */ + const attachers = []; + /** @type {Record} */ + let namespace = {}; + /** @type {boolean|undefined} */ + let frozen; + let freezeIndex = -1; - if (index > 1 && events[index - 2][1].type === 'linePrefix') { - // Add the prefix start to the HTML token. - events[index][1].start = events[index - 2][1].start; // Add the prefix start to the HTML line token. + // Data management. + // @ts-expect-error: overloads are handled. + processor.data = data; + processor.Parser = undefined; + processor.Compiler = undefined; - events[index + 1][1].start = events[index - 2][1].start; // Remove the line prefix. + // Lock. + processor.freeze = freeze; - events.splice(index - 2, 2); - } + // Plugins. + processor.attachers = attachers; + // @ts-expect-error: overloads are handled. + processor.use = use; - return events -} + // API. + processor.parse = parse; + processor.stringify = stringify; + // @ts-expect-error: overloads are handled. + processor.run = run; + processor.runSync = runSync; + // @ts-expect-error: overloads are handled. + processor.process = process; + processor.processSync = processSync; -function tokenizeHtmlFlow(effects, ok, nok) { - var self = this; - var kind; - var startTag; - var buffer; - var index; - var marker; - return start + // Expose. + return processor - function start(code) { - effects.enter('htmlFlow'); - effects.enter('htmlFlowData'); - effects.consume(code); - return open - } + // Create a new processor based on the processor in the current scope. + /** @type {Processor} */ + function processor() { + const destination = base(); + let index = -1; - function open(code) { - if (code === 33) { - effects.consume(code); - return declarationStart + while (++index < attachers.length) { + destination.use(...attachers[index]); } - if (code === 47) { - effects.consume(code); - return tagCloseStart - } + destination.data(extend(true, {}, namespace)); - if (code === 63) { - effects.consume(code); - kind = 3; // While we’re in an instruction instead of a declaration, we’re on a `?` - // right now, so we do need to search for `>`, similar to declarations. - - return self.interrupt ? ok : continuationDeclarationInside - } - - if (asciiAlpha$2(code)) { - effects.consume(code); - buffer = fromCharCode(code); - startTag = true; - return tagName - } - - return nok(code) + return destination } - function declarationStart(code) { - if (code === 45) { - effects.consume(code); - kind = 2; - return commentOpenInside - } + /** + * @param {string|Record} [key] + * @param {unknown} [value] + * @returns {unknown} + */ + function data(key, value) { + if (typeof key === 'string') { + // Set `key`. + if (arguments.length === 2) { + assertUnfrozen('data', frozen); + namespace[key] = value; + return processor + } - if (code === 91) { - effects.consume(code); - kind = 5; - buffer = 'CDATA['; - index = 0; - return cdataOpenInside + // Get `key`. + return (own$6.call(namespace, key) && namespace[key]) || null } - if (asciiAlpha$2(code)) { - effects.consume(code); - kind = 4; - return self.interrupt ? ok : continuationDeclarationInside + // Set space. + if (key) { + assertUnfrozen('data', frozen); + namespace = key; + return processor } - return nok(code) + // Get space. + return namespace } - function commentOpenInside(code) { - if (code === 45) { - effects.consume(code); - return self.interrupt ? ok : continuationDeclarationInside + /** @type {Processor['freeze']} */ + function freeze() { + if (frozen) { + return processor } - return nok(code) - } - - function cdataOpenInside(code) { - if (code === buffer.charCodeAt(index++)) { - effects.consume(code); - return index === buffer.length - ? self.interrupt - ? ok - : continuation - : cdataOpenInside - } + while (++freezeIndex < attachers.length) { + const [attacher, ...options] = attachers[freezeIndex]; - return nok(code) - } + if (options[0] === false) { + continue + } - function tagCloseStart(code) { - if (asciiAlpha$2(code)) { - effects.consume(code); - buffer = fromCharCode(code); - return tagName - } + if (options[0] === true) { + options[1] = undefined; + } - return nok(code) - } + /** @type {Transformer|void} */ + const transformer = attacher.call(processor, ...options); - function tagName(code) { - if ( - code === null || - code === 47 || - code === 62 || - markdownLineEndingOrSpace$3(code) - ) { - if ( - code !== 47 && - startTag && - htmlRawNames.indexOf(buffer.toLowerCase()) > -1 - ) { - kind = 1; - return self.interrupt ? ok(code) : continuation(code) + if (typeof transformer === 'function') { + transformers.use(transformer); } + } - if (htmlBlockNames.indexOf(buffer.toLowerCase()) > -1) { - kind = 6; + frozen = true; + freezeIndex = Number.POSITIVE_INFINITY; - if (code === 47) { - effects.consume(code); - return basicSelfClosing - } + return processor + } - return self.interrupt ? ok(code) : continuation(code) - } + /** + * @param {Pluggable|null|undefined} [value] + * @param {...unknown} options + * @returns {Processor} + */ + function use(value, ...options) { + /** @type {Record|undefined} */ + let settings; - kind = 7; // Do not support complete HTML when interrupting. + assertUnfrozen('use', frozen); - return self.interrupt - ? nok(code) - : startTag - ? completeAttributeNameBefore(code) - : completeClosingTagAfter(code) + if (value === null || value === undefined) ; else if (typeof value === 'function') { + addPlugin(value, ...options); + } else if (typeof value === 'object') { + if (Array.isArray(value)) { + addList(value); + } else { + addPreset(value); + } + } else { + throw new TypeError('Expected usable value, not `' + value + '`') } - if (code === 45 || asciiAlphanumeric$2(code)) { - effects.consume(code); - buffer += fromCharCode(code); - return tagName + if (settings) { + namespace.settings = Object.assign(namespace.settings || {}, settings); } - return nok(code) - } + return processor - function basicSelfClosing(code) { - if (code === 62) { - effects.consume(code); - return self.interrupt ? ok : continuation + /** + * @param {import('..').Pluggable} value + * @returns {void} + */ + function add(value) { + if (typeof value === 'function') { + addPlugin(value); + } else if (typeof value === 'object') { + if (Array.isArray(value)) { + const [plugin, ...options] = value; + addPlugin(plugin, ...options); + } else { + addPreset(value); + } + } else { + throw new TypeError('Expected usable value, not `' + value + '`') + } } - return nok(code) - } + /** + * @param {Preset} result + * @returns {void} + */ + function addPreset(result) { + addList(result.plugins); - function completeClosingTagAfter(code) { - if (markdownSpace$4(code)) { - effects.consume(code); - return completeClosingTagAfter + if (result.settings) { + settings = Object.assign(settings || {}, result.settings); + } } - return completeEnd(code) - } + /** + * @param {PluggableList|null|undefined} [plugins] + * @returns {void} + */ + function addList(plugins) { + let index = -1; - function completeAttributeNameBefore(code) { - if (code === 47) { - effects.consume(code); - return completeEnd + if (plugins === null || plugins === undefined) ; else if (Array.isArray(plugins)) { + while (++index < plugins.length) { + const thing = plugins[index]; + add(thing); + } + } else { + throw new TypeError('Expected a list of plugins, not `' + plugins + '`') + } } - if (code === 58 || code === 95 || asciiAlpha$2(code)) { - effects.consume(code); - return completeAttributeName - } + /** + * @param {Plugin} plugin + * @param {...unknown} [value] + * @returns {void} + */ + function addPlugin(plugin, value) { + let index = -1; + /** @type {Processor['attachers'][number]|undefined} */ + let entry; - if (markdownSpace$4(code)) { - effects.consume(code); - return completeAttributeNameBefore - } + while (++index < attachers.length) { + if (attachers[index][0] === plugin) { + entry = attachers[index]; + break + } + } - return completeEnd(code) - } + if (entry) { + if (isPlainObject$1(entry[1]) && isPlainObject$1(value)) { + value = extend(true, entry[1], value); + } - function completeAttributeName(code) { - if ( - code === 45 || - code === 46 || - code === 58 || - code === 95 || - asciiAlphanumeric$2(code) - ) { - effects.consume(code); - return completeAttributeName + entry[1] = value; + } else { + // @ts-expect-error: fine. + attachers.push([...arguments]); + } } - - return completeAttributeNameAfter(code) } - function completeAttributeNameAfter(code) { - if (code === 61) { - effects.consume(code); - return completeAttributeValueBefore - } + /** @type {Processor['parse']} */ + function parse(doc) { + processor.freeze(); + const file = vfile(doc); + const Parser = processor.Parser; + assertParser('parse', Parser); - if (markdownSpace$4(code)) { - effects.consume(code); - return completeAttributeNameAfter + if (newable(Parser, 'parse')) { + // @ts-expect-error: `newable` checks this. + return new Parser(String(file), file).parse() } - return completeAttributeNameBefore(code) + // @ts-expect-error: `newable` checks this. + return Parser(String(file), file) // eslint-disable-line new-cap } - function completeAttributeValueBefore(code) { - if ( - code === null || - code === 60 || - code === 61 || - code === 62 || - code === 96 - ) { - return nok(code) - } - - if (code === 34 || code === 39) { - effects.consume(code); - marker = code; - return completeAttributeValueQuoted - } + /** @type {Processor['stringify']} */ + function stringify(node, doc) { + processor.freeze(); + const file = vfile(doc); + const Compiler = processor.Compiler; + assertCompiler('stringify', Compiler); + assertNode(node); - if (markdownSpace$4(code)) { - effects.consume(code); - return completeAttributeValueBefore + if (newable(Compiler, 'compile')) { + // @ts-expect-error: `newable` checks this. + return new Compiler(node, file).compile() } - marker = undefined; - return completeAttributeValueUnquoted(code) + // @ts-expect-error: `newable` checks this. + return Compiler(node, file) // eslint-disable-line new-cap } - function completeAttributeValueQuoted(code) { - if (code === marker) { - effects.consume(code); - return completeAttributeValueQuotedAfter - } + /** + * @param {Node} node + * @param {VFileCompatible|RunCallback} [doc] + * @param {RunCallback} [callback] + * @returns {Promise|void} + */ + function run(node, doc, callback) { + assertNode(node); + processor.freeze(); - if (code === null || markdownLineEnding$4(code)) { - return nok(code) + if (!callback && typeof doc === 'function') { + callback = doc; + doc = undefined; } - effects.consume(code); - return completeAttributeValueQuoted - } - - function completeAttributeValueUnquoted(code) { - if ( - code === null || - code === 34 || - code === 39 || - code === 60 || - code === 61 || - code === 62 || - code === 96 || - markdownLineEndingOrSpace$3(code) - ) { - return completeAttributeNameAfter(code) + if (!callback) { + return new Promise(executor) } - effects.consume(code); - return completeAttributeValueUnquoted - } - - function completeAttributeValueQuotedAfter(code) { - if (code === 47 || code === 62 || markdownSpace$4(code)) { - return completeAttributeNameBefore(code) - } + executor(null, callback); - return nok(code) - } + /** + * @param {null|((node: Node) => void)} resolve + * @param {(error: Error) => void} reject + * @returns {void} + */ + function executor(resolve, reject) { + // @ts-expect-error: `doc` can’t be a callback anymore, we checked. + transformers.run(node, vfile(doc), done); - function completeEnd(code) { - if (code === 62) { - effects.consume(code); - return completeAfter + /** + * @param {Error|null} error + * @param {Node} tree + * @param {VFile} file + * @returns {void} + */ + function done(error, tree, file) { + tree = tree || node; + if (error) { + reject(error); + } else if (resolve) { + resolve(tree); + } else { + // @ts-expect-error: `callback` is defined if `resolve` is not. + callback(null, tree, file); + } + } } - - return nok(code) } - function completeAfter(code) { - if (markdownSpace$4(code)) { - effects.consume(code); - return completeAfter - } + /** @type {Processor['runSync']} */ + function runSync(node, file) { + /** @type {Node|undefined} */ + let result; + /** @type {boolean|undefined} */ + let complete; - return code === null || markdownLineEnding$4(code) - ? continuation(code) - : nok(code) - } + processor.run(node, file, done); - function continuation(code) { - if (code === 45 && kind === 2) { - effects.consume(code); - return continuationCommentInside - } + assertDone('runSync', 'run', complete); - if (code === 60 && kind === 1) { - effects.consume(code); - return continuationRawTagOpen - } + // @ts-expect-error: we either bailed on an error or have a tree. + return result - if (code === 62 && kind === 4) { - effects.consume(code); - return continuationClose + /** + * @param {Error|null} [error] + * @param {Node} [tree] + * @returns {void} + */ + function done(error, tree) { + bail(error); + result = tree; + complete = true; } + } - if (code === 63 && kind === 3) { - effects.consume(code); - return continuationDeclarationInside - } + /** + * @param {VFileCompatible} doc + * @param {ProcessCallback} [callback] + * @returns {Promise|undefined} + */ + function process(doc, callback) { + processor.freeze(); + assertParser('process', processor.Parser); + assertCompiler('process', processor.Compiler); - if (code === 93 && kind === 5) { - effects.consume(code); - return continuationCharacterDataInside + if (!callback) { + return new Promise(executor) } - if (markdownLineEnding$4(code) && (kind === 6 || kind === 7)) { - return effects.check( - nextBlankConstruct, - continuationClose, - continuationAtLineEnding - )(code) - } + executor(null, callback); - if (code === null || markdownLineEnding$4(code)) { - return continuationAtLineEnding(code) - } + /** + * @param {null|((file: VFile) => void)} resolve + * @param {(error?: Error|null|undefined) => void} reject + * @returns {void} + */ + function executor(resolve, reject) { + const file = vfile(doc); - effects.consume(code); - return continuation - } + processor.run(processor.parse(file), file, (error, tree, file) => { + if (error || !tree || !file) { + done(error); + } else { + /** @type {unknown} */ + const result = processor.stringify(tree, file); - function continuationAtLineEnding(code) { - effects.exit('htmlFlowData'); - return htmlContinueStart(code) - } + if (result === undefined || result === null) ; else if (looksLikeAVFileValue(result)) { + file.value = result; + } else { + file.result = result; + } - function htmlContinueStart(code) { - if (code === null) { - return done(code) - } + done(error, file); + } + }); - if (markdownLineEnding$4(code)) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return htmlContinueStart + /** + * @param {Error|null|undefined} [error] + * @param {VFile|undefined} [file] + * @returns {void} + */ + function done(error, file) { + if (error || !file) { + reject(error); + } else if (resolve) { + resolve(file); + } else { + // @ts-expect-error: `callback` is defined if `resolve` is not. + callback(null, file); + } + } } - - effects.enter('htmlFlowData'); - return continuation(code) } - function continuationCommentInside(code) { - if (code === 45) { - effects.consume(code); - return continuationDeclarationInside - } + /** @type {Processor['processSync']} */ + function processSync(doc) { + /** @type {boolean|undefined} */ + let complete; - return continuation(code) - } + processor.freeze(); + assertParser('processSync', processor.Parser); + assertCompiler('processSync', processor.Compiler); - function continuationRawTagOpen(code) { - if (code === 47) { - effects.consume(code); - buffer = ''; - return continuationRawEndTag - } + const file = vfile(doc); - return continuation(code) - } + processor.process(file, done); - function continuationRawEndTag(code) { - if (code === 62 && htmlRawNames.indexOf(buffer.toLowerCase()) > -1) { - effects.consume(code); - return continuationClose - } + assertDone('processSync', 'process', complete); - if (asciiAlpha$2(code) && buffer.length < 8) { - effects.consume(code); - buffer += fromCharCode(code); - return continuationRawEndTag - } + return file - return continuation(code) + /** + * @param {Error|null|undefined} [error] + * @returns {void} + */ + function done(error) { + complete = true; + bail(error); + } } +} - function continuationCharacterDataInside(code) { - if (code === 93) { - effects.consume(code); - return continuationDeclarationInside - } +/** + * Check if `value` is a constructor. + * + * @param {unknown} value + * @param {string} name + * @returns {boolean} + */ +function newable(value, name) { + return ( + typeof value === 'function' && + // Prototypes do exist. + // type-coverage:ignore-next-line + value.prototype && + // A function with keys in its prototype is probably a constructor. + // Classes’ prototype methods are not enumerable, so we check if some value + // exists in the prototype. + // type-coverage:ignore-next-line + (keys(value.prototype) || name in value.prototype) + ) +} - return continuation(code) - } +/** + * Check if `value` is an object with keys. + * + * @param {Record} value + * @returns {boolean} + */ +function keys(value) { + /** @type {string} */ + let key; - function continuationDeclarationInside(code) { - if (code === 62) { - effects.consume(code); - return continuationClose + for (key in value) { + if (own$6.call(value, key)) { + return true } - - return continuation(code) } - function continuationClose(code) { - if (code === null || markdownLineEnding$4(code)) { - effects.exit('htmlFlowData'); - return done(code) - } + return false +} - effects.consume(code); - return continuationClose +/** + * Assert a parser is available. + * + * @param {string} name + * @param {unknown} value + * @returns {asserts value is Parser} + */ +function assertParser(name, value) { + if (typeof value !== 'function') { + throw new TypeError('Cannot `' + name + '` without `Parser`') } +} - function done(code) { - effects.exit('htmlFlow'); - return ok(code) +/** + * Assert a compiler is available. + * + * @param {string} name + * @param {unknown} value + * @returns {asserts value is Compiler} + */ +function assertCompiler(name, value) { + if (typeof value !== 'function') { + throw new TypeError('Cannot `' + name + '` without `Compiler`') } } -function tokenizeNextBlank(effects, ok, nok) { - return start - - function start(code) { - effects.exit('htmlFlowData'); - effects.enter('lineEndingBlank'); - effects.consume(code); - effects.exit('lineEndingBlank'); - return effects.attempt(partialBlankLine$1, ok, nok) +/** + * Assert the processor is not frozen. + * + * @param {string} name + * @param {unknown} frozen + * @returns {asserts frozen is false} + */ +function assertUnfrozen(name, frozen) { + if (frozen) { + throw new Error( + 'Cannot call `' + + name + + '` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.' + ) } } -var htmlFlow_1 = htmlFlow$1; +/** + * Assert `node` is a unist node. + * + * @param {unknown} node + * @returns {asserts node is Node} + */ +function assertNode(node) { + // `isPlainObj` unfortunately uses `any` instead of `unknown`. + // type-coverage:ignore-next-line + if (!isPlainObject$1(node) || typeof node.type !== 'string') { + throw new TypeError('Expected node, got `' + node + '`') + // Fine. + } +} -var asciiAlpha$1 = asciiAlpha_1; -var asciiAlphanumeric$1 = asciiAlphanumeric_1; -var markdownLineEnding$3 = markdownLineEnding_1; -var markdownLineEndingOrSpace$2 = markdownLineEndingOrSpace_1; -var markdownSpace$3 = markdownSpace_1; -var factorySpace$5 = factorySpace$i; +/** + * Assert that `complete` is `true`. + * + * @param {string} name + * @param {string} asyncName + * @param {unknown} complete + * @returns {asserts complete is true} + */ +function assertDone(name, asyncName, complete) { + if (!complete) { + throw new Error( + '`' + name + '` finished async. Use `' + asyncName + '` instead' + ) + } +} -var htmlText$1 = { - name: 'htmlText', - tokenize: tokenizeHtmlText -}; +/** + * @param {VFileCompatible} [value] + * @returns {VFile} + */ +function vfile(value) { + return looksLikeAVFile(value) ? value : new VFile(value) +} -function tokenizeHtmlText(effects, ok, nok) { - var self = this; - var marker; - var buffer; - var index; - var returnState; - return start +/** + * @param {VFileCompatible} [value] + * @returns {value is VFile} + */ +function looksLikeAVFile(value) { + return Boolean( + value && + typeof value === 'object' && + 'message' in value && + 'messages' in value + ) +} - function start(code) { - effects.enter('htmlText'); - effects.enter('htmlTextData'); - effects.consume(code); - return open - } +/** + * @param {unknown} [value] + * @returns {value is VFileValue} + */ +function looksLikeAVFileValue(value) { + return typeof value === 'string' || isBuffer(value) +} - function open(code) { - if (code === 33) { - effects.consume(code); - return declarationOpen - } +/** + * @typedef Options + * @property {boolean} [includeImageAlt=true] + */ - if (code === 47) { - effects.consume(code); - return tagCloseStart - } +/** + * Get the text content of a node. + * Prefer the node’s plain-text fields, otherwise serialize its children, + * and if the given value is an array, serialize the nodes in it. + * + * @param {unknown} node + * @param {Options} [options] + * @returns {string} + */ +function toString(node, options) { + var {includeImageAlt = true} = options || {}; + return one(node, includeImageAlt) +} - if (code === 63) { - effects.consume(code); - return instruction - } +/** + * @param {unknown} node + * @param {boolean} includeImageAlt + * @returns {string} + */ +function one(node, includeImageAlt) { + return ( + (node && + typeof node === 'object' && + // @ts-ignore looks like a literal. + (node.value || + // @ts-ignore looks like an image. + (includeImageAlt ? node.alt : '') || + // @ts-ignore looks like a parent. + ('children' in node && all(node.children, includeImageAlt)) || + (Array.isArray(node) && all(node, includeImageAlt)))) || + '' + ) +} - if (asciiAlpha$1(code)) { - effects.consume(code); - return tagOpen - } +/** + * @param {Array.} values + * @param {boolean} includeImageAlt + * @returns {string} + */ +function all(values, includeImageAlt) { + /** @type {Array.} */ + var result = []; + var index = -1; - return nok(code) + while (++index < values.length) { + result[index] = one(values[index], includeImageAlt); } - function declarationOpen(code) { - if (code === 45) { - effects.consume(code); - return commentOpen - } + return result.join('') +} - if (code === 91) { - effects.consume(code); - buffer = 'CDATA['; - index = 0; - return cdataOpen - } +/** + * Like `Array#splice`, but smarter for giant arrays. + * + * `Array#splice` takes all items to be inserted as individual argument which + * causes a stack overflow in V8 when trying to insert 100k items for instance. + * + * Otherwise, this does not return the removed items, and takes `items` as an + * array instead of rest parameters. + * + * @template {unknown} T + * @param {T[]} list + * @param {number} start + * @param {number} remove + * @param {T[]} items + * @returns {void} + */ +function splice(list, start, remove, items) { + const end = list.length; + let chunkStart = 0; + /** @type {unknown[]} */ - if (asciiAlpha$1(code)) { - effects.consume(code); - return declaration - } + let parameters; // Make start between zero and `end` (included). - return nok(code) + if (start < 0) { + start = -start > end ? 0 : end + start; + } else { + start = start > end ? end : start; } - function commentOpen(code) { - if (code === 45) { - effects.consume(code); - return commentStart - } - - return nok(code) - } + remove = remove > 0 ? remove : 0; // No need to chunk the items if there’s only a couple (10k) items. - function commentStart(code) { - if (code === null || code === 62) { - return nok(code) - } + if (items.length < 10000) { + parameters = Array.from(items); + parameters.unshift(start, remove) // @ts-expect-error Hush, it’s fine. + ;[].splice.apply(list, parameters); + } else { + // Delete `remove` items starting from `start` + if (remove) [].splice.apply(list, [start, remove]); // Insert the items in chunks to not cause stack overflows. - if (code === 45) { - effects.consume(code); - return commentStartDash + while (chunkStart < items.length) { + parameters = items.slice(chunkStart, chunkStart + 10000); + parameters.unshift(start, 0) // @ts-expect-error Hush, it’s fine. + ;[].splice.apply(list, parameters); + chunkStart += 10000; + start += 10000; } - - return comment(code) } +} +/** + * Append `items` (an array) at the end of `list` (another array). + * When `list` was empty, returns `items` instead. + * + * This prevents a potentially expensive operation when `list` is empty, + * and adds items in batches to prevent V8 from hanging. + * + * @template {unknown} T + * @param {T[]} list + * @param {T[]} items + * @returns {T[]} + */ - function commentStartDash(code) { - if (code === null || code === 62) { - return nok(code) - } - - return comment(code) +function push(list, items) { + if (list.length > 0) { + splice(list, list.length, 0, items); + return list } - function comment(code) { - if (code === null) { - return nok(code) - } - - if (code === 45) { - effects.consume(code); - return commentClose - } - - if (markdownLineEnding$3(code)) { - returnState = comment; - return atLineEnding(code) - } - - effects.consume(code); - return comment - } + return items +} - function commentClose(code) { - if (code === 45) { - effects.consume(code); - return end - } +/** + * @typedef {import('micromark-util-types').NormalizedExtension} NormalizedExtension + * @typedef {import('micromark-util-types').Extension} Extension + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension + */ - return comment(code) - } +const hasOwnProperty = {}.hasOwnProperty; - function cdataOpen(code) { - if (code === buffer.charCodeAt(index++)) { - effects.consume(code); - return index === buffer.length ? cdata : cdataOpen - } +/** + * Combine several syntax extensions into one. + * + * @param {Extension[]} extensions List of syntax extensions. + * @returns {NormalizedExtension} A single combined extension. + */ +function combineExtensions(extensions) { + /** @type {NormalizedExtension} */ + const all = {}; + let index = -1; - return nok(code) + while (++index < extensions.length) { + syntaxExtension(all, extensions[index]); } - function cdata(code) { - if (code === null) { - return nok(code) - } - - if (code === 93) { - effects.consume(code); - return cdataClose - } + return all +} - if (markdownLineEnding$3(code)) { - returnState = cdata; - return atLineEnding(code) - } +/** + * Merge `extension` into `all`. + * + * @param {NormalizedExtension} all Extension to merge into. + * @param {Extension} extension Extension to merge. + * @returns {void} + */ +function syntaxExtension(all, extension) { + /** @type {string} */ + let hook; - effects.consume(code); - return cdata - } + for (hook in extension) { + const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined; + const left = maybe || (all[hook] = {}); + const right = extension[hook]; + /** @type {string} */ + let code; - function cdataClose(code) { - if (code === 93) { - effects.consume(code); - return cdataEnd + for (code in right) { + if (!hasOwnProperty.call(left, code)) left[code] = []; + const value = right[code]; + constructs( + // @ts-expect-error Looks like a list. + left[code], + Array.isArray(value) ? value : value ? [value] : [] + ); } - - return cdata(code) } +} - function cdataEnd(code) { - if (code === 62) { - return end(code) - } - - if (code === 93) { - effects.consume(code); - return cdataEnd - } +/** + * Merge `list` into `existing` (both lists of constructs). + * Mutates `existing`. + * + * @param {unknown[]} existing + * @param {unknown[]} list + * @returns {void} + */ +function constructs(existing, list) { + let index = -1; + /** @type {unknown[]} */ + const before = []; - return cdata(code) + while (++index < list.length) { +(list[index].add === 'after' ? existing : before).push(list[index]); } - function declaration(code) { - if (code === null || code === 62) { - return end(code) - } + splice(existing, 0, 0, before); +} - if (markdownLineEnding$3(code)) { - returnState = declaration; - return atLineEnding(code) - } +/** + * Combine several HTML extensions into one. + * + * @param {HtmlExtension[]} htmlExtensions List of HTML extensions. + * @returns {HtmlExtension} A single combined extension. + */ +function combineHtmlExtensions(htmlExtensions) { + /** @type {HtmlExtension} */ + const handlers = {}; + let index = -1; - effects.consume(code); - return declaration + while (++index < htmlExtensions.length) { + htmlExtension(handlers, htmlExtensions[index]); } - function instruction(code) { - if (code === null) { - return nok(code) - } - - if (code === 63) { - effects.consume(code); - return instructionClose - } - - if (markdownLineEnding$3(code)) { - returnState = instruction; - return atLineEnding(code) - } + return handlers +} - effects.consume(code); - return instruction - } +/** + * Merge `extension` into `all`. + * + * @param {HtmlExtension} all Extension to merge into. + * @param {HtmlExtension} extension Extension to merge. + * @returns {void} + */ +function htmlExtension(all, extension) { + /** @type {string} */ + let hook; - function instructionClose(code) { - return code === 62 ? end(code) : instruction(code) - } + for (hook in extension) { + const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined; + const left = maybe || (all[hook] = {}); + const right = extension[hook]; + /** @type {string} */ + let type; - function tagCloseStart(code) { - if (asciiAlpha$1(code)) { - effects.consume(code); - return tagClose + if (right) { + for (type in right) { + left[type] = right[type]; + } } - - return nok(code) } +} - function tagClose(code) { - if (code === 45 || asciiAlphanumeric$1(code)) { - effects.consume(code); - return tagClose - } +// This module is generated by `script/`. +// +// CommonMark handles attention (emphasis, strong) markers based on what comes +// before or after them. +// One such difference is if those characters are Unicode punctuation. +// This script is generated from the Unicode data. +const unicodePunctuationRegex = + /[!-/:-@[-`{-~\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/; - return tagCloseBetween(code) - } +/** + * @typedef {import('micromark-util-types').Code} Code + */ +/** + * Check whether the character code represents an ASCII alpha (`a` through `z`, + * case insensitive). + * + * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha. + * + * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`) + * to U+005A (`Z`). + * + * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`) + * to U+007A (`z`). + */ - function tagCloseBetween(code) { - if (markdownLineEnding$3(code)) { - returnState = tagCloseBetween; - return atLineEnding(code) - } +const asciiAlpha = regexCheck(/[A-Za-z]/); +/** + * Check whether the character code represents an ASCII digit (`0` through `9`). + * + * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to + * U+0039 (`9`). + */ - if (markdownSpace$3(code)) { - effects.consume(code); - return tagCloseBetween - } +const asciiDigit = regexCheck(/\d/); +/** + * Check whether the character code represents an ASCII hex digit (`a` through + * `f`, case insensitive, or `0` through `9`). + * + * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex + * digit, or an ASCII lower hex digit. + * + * An **ASCII upper hex digit** is a character in the inclusive range U+0041 + * (`A`) to U+0046 (`F`). + * + * An **ASCII lower hex digit** is a character in the inclusive range U+0061 + * (`a`) to U+0066 (`f`). + */ - return end(code) - } +const asciiHexDigit = regexCheck(/[\dA-Fa-f]/); +/** + * Check whether the character code represents an ASCII alphanumeric (`a` + * through `z`, case insensitive, or `0` through `9`). + * + * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha + * (see `asciiAlpha`). + */ - function tagOpen(code) { - if (code === 45 || asciiAlphanumeric$1(code)) { - effects.consume(code); - return tagOpen - } +const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/); +/** + * Check whether the character code represents ASCII punctuation. + * + * An **ASCII punctuation** is a character in the inclusive ranges U+0021 + * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT + * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT + * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`). + */ - if (code === 47 || code === 62 || markdownLineEndingOrSpace$2(code)) { - return tagOpenBetween(code) - } +const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/); +/** + * Check whether the character code represents an ASCII atext. + * + * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in + * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`), + * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F + * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E + * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE + * (`{`) to U+007E TILDE (`~`). + * + * See: + * **\[RFC5322]**: + * [Internet Message Format](https://tools.ietf.org/html/rfc5322). + * P. Resnick. + * IETF. + */ - return nok(code) - } +const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/); +/** + * Check whether a character code is an ASCII control character. + * + * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL) + * to U+001F (US), or U+007F (DEL). + * + * @param {Code} code + * @returns {code is number} + */ - function tagOpenBetween(code) { - if (code === 47) { - effects.consume(code); - return end - } +function asciiControl(code) { + return ( + // Special whitespace codes (which have negative values), C0 and Control + // character DEL + code !== null && (code < 32 || code === 127) + ) +} +/** + * Check whether a character code is a markdown line ending (see + * `markdownLineEnding`) or markdown space (see `markdownSpace`). + * + * @param {Code} code + * @returns {code is number} + */ - if (code === 58 || code === 95 || asciiAlpha$1(code)) { - effects.consume(code); - return tagOpenAttributeName - } +function markdownLineEndingOrSpace(code) { + return code !== null && (code < 0 || code === 32) +} +/** + * Check whether a character code is a markdown line ending. + * + * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN + * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR). + * + * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE + * RETURN (CR) are replaced by these virtual characters depending on whether + * they occurred together. + * + * @param {Code} code + * @returns {code is number} + */ - if (markdownLineEnding$3(code)) { - returnState = tagOpenBetween; - return atLineEnding(code) - } +function markdownLineEnding(code) { + return code !== null && code < -2 +} +/** + * Check whether a character code is a markdown space. + * + * A **markdown space** is the concrete character U+0020 SPACE (SP) and the + * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT). + * + * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is + * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL + * SPACE (VS) characters, depending on the column at which the tab occurred. + * + * @param {Code} code + * @returns {code is number} + */ - if (markdownSpace$3(code)) { - effects.consume(code); - return tagOpenBetween - } +function markdownSpace(code) { + return code === -2 || code === -1 || code === 32 +} +/** + * Check whether the character code represents Unicode whitespace. + * + * Note that this does handle micromark specific markdown whitespace characters. + * See `markdownLineEndingOrSpace` to check that. + * + * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator, + * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF), + * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**). + * + * See: + * **\[UNICODE]**: + * [The Unicode Standard](https://www.unicode.org/versions/). + * Unicode Consortium. + */ - return end(code) - } +const unicodeWhitespace = regexCheck(/\s/); +/** + * Check whether the character code represents Unicode punctuation. + * + * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation, + * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf` + * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po` + * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII + * punctuation (see `asciiPunctuation`). + * + * See: + * **\[UNICODE]**: + * [The Unicode Standard](https://www.unicode.org/versions/). + * Unicode Consortium. + */ +// Size note: removing ASCII from the regex and using `asciiPunctuation` here +// In fact adds to the bundle size. - function tagOpenAttributeName(code) { - if ( - code === 45 || - code === 46 || - code === 58 || - code === 95 || - asciiAlphanumeric$1(code) - ) { - effects.consume(code); - return tagOpenAttributeName - } +const unicodePunctuation = regexCheck(unicodePunctuationRegex); +/** + * Create a code check from a regex. + * + * @param {RegExp} regex + * @returns {(code: Code) => code is number} + */ - return tagOpenAttributeNameAfter(code) +function regexCheck(regex) { + return check + /** + * Check whether a code matches the bound regex. + * + * @param {Code} code Character code + * @returns {code is number} Whether the character code matches the bound regex + */ + + function check(code) { + return code !== null && regex.test(String.fromCharCode(code)) } +} - function tagOpenAttributeNameAfter(code) { - if (code === 61) { - effects.consume(code); - return tagOpenAttributeValueBefore - } +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + */ +/** + * @param {Effects} effects + * @param {State} ok + * @param {string} type + * @param {number} [max=Infinity] + * @returns {State} + */ - if (markdownLineEnding$3(code)) { - returnState = tagOpenAttributeNameAfter; - return atLineEnding(code) +function factorySpace(effects, ok, type, max) { + const limit = max ? max - 1 : Number.POSITIVE_INFINITY; + let size = 0; + return start + /** @type {State} */ + + function start(code) { + if (markdownSpace(code)) { + effects.enter(type); + return prefix(code) } - if (markdownSpace$3(code)) { + return ok(code) + } + /** @type {State} */ + + function prefix(code) { + if (markdownSpace(code) && size++ < limit) { effects.consume(code); - return tagOpenAttributeNameAfter + return prefix } - return tagOpenBetween(code) + effects.exit(type); + return ok(code) } +} - function tagOpenAttributeValueBefore(code) { - if ( - code === null || - code === 60 || - code === 61 || - code === 62 || - code === 96 - ) { - return nok(code) - } +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').State} State + */ - if (code === 34 || code === 39) { - effects.consume(code); - marker = code; - return tagOpenAttributeValueQuoted - } +/** @type {InitialConstruct} */ +const content$1 = { + tokenize: initializeContent +}; +/** @type {Initializer} */ - if (markdownLineEnding$3(code)) { - returnState = tagOpenAttributeValueBefore; - return atLineEnding(code) - } +function initializeContent(effects) { + const contentStart = effects.attempt( + this.parser.constructs.contentInitial, + afterContentStartConstruct, + paragraphInitial + ); + /** @type {Token} */ - if (markdownSpace$3(code)) { + let previous; + return contentStart + /** @type {State} */ + + function afterContentStartConstruct(code) { + if (code === null) { effects.consume(code); - return tagOpenAttributeValueBefore + return } + effects.enter('lineEnding'); effects.consume(code); - marker = undefined; - return tagOpenAttributeValueUnquoted + effects.exit('lineEnding'); + return factorySpace(effects, contentStart, 'linePrefix') } + /** @type {State} */ - function tagOpenAttributeValueQuoted(code) { - if (code === marker) { - effects.consume(code); - return tagOpenAttributeValueQuotedAfter + function paragraphInitial(code) { + effects.enter('paragraph'); + return lineStart(code) + } + /** @type {State} */ + + function lineStart(code) { + const token = effects.enter('chunkText', { + contentType: 'text', + previous + }); + + if (previous) { + previous.next = token; } + previous = token; + return data(code) + } + /** @type {State} */ + + function data(code) { if (code === null) { - return nok(code) + effects.exit('chunkText'); + effects.exit('paragraph'); + effects.consume(code); + return } - if (markdownLineEnding$3(code)) { - returnState = tagOpenAttributeValueQuoted; - return atLineEnding(code) - } + if (markdownLineEnding(code)) { + effects.consume(code); + effects.exit('chunkText'); + return lineStart + } // Data. effects.consume(code); - return tagOpenAttributeValueQuoted + return data } +} - function tagOpenAttributeValueQuotedAfter(code) { - if (code === 62 || code === 47 || markdownLineEndingOrSpace$2(code)) { - return tagOpenBetween(code) - } +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Point} Point + */ +/** @type {InitialConstruct} */ - return nok(code) - } +const document$2 = { + tokenize: initializeDocument +}; +/** @type {Construct} */ - function tagOpenAttributeValueUnquoted(code) { - if ( - code === null || - code === 34 || - code === 39 || - code === 60 || - code === 61 || - code === 96 - ) { - return nok(code) - } +const containerConstruct = { + tokenize: tokenizeContainer +}; +/** @type {Initializer} */ - if (code === 62 || markdownLineEndingOrSpace$2(code)) { - return tagOpenBetween(code) - } +function initializeDocument(effects) { + const self = this; + /** @type {StackItem[]} */ - effects.consume(code); - return tagOpenAttributeValueUnquoted - } // We can’t have blank lines in content, so no need to worry about empty - // tokens. + const stack = []; + let continued = 0; + /** @type {TokenizeContext|undefined} */ - function atLineEnding(code) { - effects.exit('htmlTextData'); - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return factorySpace$5( - effects, - afterPrefix, - 'linePrefix', - self.parser.constructs.disable.null.indexOf('codeIndented') > -1 - ? undefined - : 4 - ) + let childFlow; + /** @type {Token|undefined} */ + + let childToken; + /** @type {number} */ + + let lineStartOffset; + return start + /** @type {State} */ + + function start(code) { + // First we iterate through the open blocks, starting with the root + // document, and descending through last children down to the last open + // block. + // Each block imposes a condition that the line must satisfy if the block is + // to remain open. + // For example, a block quote requires a `>` character. + // A paragraph requires a non-blank line. + // In this phase we may match all or just some of the open blocks. + // But we cannot close unmatched blocks yet, because we may have a lazy + // continuation line. + if (continued < stack.length) { + const item = stack[continued]; + self.containerState = item[1]; + return effects.attempt( + item[0].continuation, + documentContinue, + checkNewContainers + )(code) + } // Done. + + return checkNewContainers(code) } + /** @type {State} */ - function afterPrefix(code) { - effects.enter('htmlTextData'); - return returnState(code) + function documentContinue(code) { + if (self.containerState._closeFlow) closeFlow(); + continued++; + return start(code) } + /** @type {State} */ - function end(code) { - if (code === 62) { - effects.consume(code); - effects.exit('htmlTextData'); - effects.exit('htmlText'); - return ok - } + function checkNewContainers(code) { + // Next, after consuming the continuation markers for existing blocks, we + // look for new block starts (e.g. `>` for a block quote). + // If we encounter a new block start, we close any blocks unmatched in + // step 1 before creating the new block as a child of the last matched + // block. + if (continued === stack.length) { + // No need to `check` whether there’s a container, of `exitContainers` + // would be moot. + // We can instead immediately `attempt` to parse one. + if (!childFlow) { + return documentContinued(code) + } // If we have concrete content, such as block HTML or fenced code, + // we can’t have containers “pierce” into them, so we can immediately + // start. - return nok(code) + if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) { + return flowStart(code) + } // If we do have flow, it could still be a blank line, + // but we’d be interrupting it w/ a new container if there’s a current + // construct. + + self.interrupt = Boolean(childFlow.currentConstruct); + } // Check if there is a new container. + + self.containerState = {}; + return effects.check( + containerConstruct, + thereIsANewContainer, + thereIsNoNewContainer + )(code) } -} + /** @type {State} */ -var htmlText_1 = htmlText$1; + function thereIsANewContainer(code) { + if (childFlow) closeFlow(); + exitContainers(continued); + return documentContinued(code) + } + /** @type {State} */ -var markdownLineEndingOrSpace$1 = markdownLineEndingOrSpace_1; -var chunkedPush = chunkedPush_1; -var chunkedSplice = chunkedSplice_1; -var normalizeIdentifier$2 = normalizeIdentifier_1; -var resolveAll$1 = resolveAll_1; -var shallow$1 = shallow_1; -var factoryDestination = factoryDestination$2; -var factoryLabel = factoryLabel$2; -var factoryTitle = factoryTitle$2; -var factoryWhitespace = factoryWhitespace$2; + function thereIsNoNewContainer(code) { + self.parser.lazy[self.now().line] = continued !== stack.length; + lineStartOffset = self.now().offset; + return flowStart(code) + } + /** @type {State} */ -var labelEnd$3 = { - name: 'labelEnd', - tokenize: tokenizeLabelEnd, - resolveTo: resolveToLabelEnd, - resolveAll: resolveAllLabelEnd -}; -var resourceConstruct = { - tokenize: tokenizeResource -}; -var fullReferenceConstruct = { - tokenize: tokenizeFullReference -}; -var collapsedReferenceConstruct = { - tokenize: tokenizeCollapsedReference -}; + function documentContinued(code) { + // Try new containers. + self.containerState = {}; + return effects.attempt( + containerConstruct, + containerContinue, + flowStart + )(code) + } + /** @type {State} */ -function resolveAllLabelEnd(events) { - var index = -1; - var token; + function containerContinue(code) { + continued++; + stack.push([self.currentConstruct, self.containerState]); // Try another. - while (++index < events.length) { - token = events[index][1]; + return documentContinued(code) + } + /** @type {State} */ - if ( - !token._used && - (token.type === 'labelImage' || - token.type === 'labelLink' || - token.type === 'labelEnd') - ) { - // Remove the marker. - events.splice(index + 1, token.type === 'labelImage' ? 4 : 2); - token.type = 'data'; - index++; + function flowStart(code) { + if (code === null) { + if (childFlow) closeFlow(); + exitContainers(0); + effects.consume(code); + return } + + childFlow = childFlow || self.parser.flow(self.now()); + effects.enter('chunkFlow', { + contentType: 'flow', + previous: childToken, + _tokenizer: childFlow + }); + return flowContinue(code) } + /** @type {State} */ - return events -} + function flowContinue(code) { + if (code === null) { + writeToChild(effects.exit('chunkFlow'), true); + exitContainers(0); + effects.consume(code); + return + } -function resolveToLabelEnd(events, context) { - var index = events.length; - var offset = 0; - var group; - var label; - var text; - var token; - var open; - var close; - var media; // Find an opening. + if (markdownLineEnding(code)) { + effects.consume(code); + writeToChild(effects.exit('chunkFlow')); // Get ready for the next line. - while (index--) { - token = events[index][1]; + continued = 0; + self.interrupt = undefined; + return start + } - if (open) { - // If we see another link, or inactive link label, we’ve been here before. - if ( - token.type === 'link' || - (token.type === 'labelLink' && token._inactive) - ) { - break - } // Mark other link openings as inactive, as we can’t have links in - // links. + effects.consume(code); + return flowContinue + } + /** + * @param {Token} token + * @param {boolean} [eof] + * @returns {void} + */ - if (events[index][0] === 'enter' && token.type === 'labelLink') { - token._inactive = true; - } - } else if (close) { - if ( - events[index][0] === 'enter' && - (token.type === 'labelImage' || token.type === 'labelLink') && - !token._balanced - ) { - open = index; + function writeToChild(token, eof) { + const stream = self.sliceStream(token); + if (eof) stream.push(null); + token.previous = childToken; + if (childToken) childToken.next = token; + childToken = token; + childFlow.defineSkip(token.start); + childFlow.write(stream); // Alright, so we just added a lazy line: + // + // ```markdown + // > a + // b. + // + // Or: + // + // > ~~~c + // d + // + // Or: + // + // > | e | + // f + // ``` + // + // The construct in the second example (fenced code) does not accept lazy + // lines, so it marked itself as done at the end of its first line, and + // then the content construct parses `d`. + // Most constructs in markdown match on the first line: if the first line + // forms a construct, a non-lazy line can’t “unmake” it. + // + // The construct in the third example is potentially a GFM table, and + // those are *weird*. + // It *could* be a table, from the first line, if the following line + // matches a condition. + // In this case, that second line is lazy, which “unmakes” the first line + // and turns the whole into one content block. + // + // We’ve now parsed the non-lazy and the lazy line, and can figure out + // whether the lazy line started a new flow block. + // If it did, we exit the current containers between the two flow blocks. - if (token.type !== 'labelLink') { - offset = 2; - break + if (self.parser.lazy[token.start.line]) { + let index = childFlow.events.length; + + while (index--) { + if ( + // The token starts before the line ending… + childFlow.events[index][1].start.offset < lineStartOffset && + (!childFlow.events[index][1].end || // …or ends after it. + childFlow.events[index][1].end.offset > lineStartOffset) + ) { + // Exit: there’s still something open, which means it’s a lazy line + // part of something. + return } } - } else if (token.type === 'labelEnd') { - close = index; - } - } - group = { - type: events[open][1].type === 'labelLink' ? 'link' : 'image', - start: shallow$1(events[open][1].start), - end: shallow$1(events[events.length - 1][1].end) - }; - label = { - type: 'label', - start: shallow$1(events[open][1].start), - end: shallow$1(events[close][1].end) - }; - text = { - type: 'labelText', - start: shallow$1(events[open + offset + 2][1].end), - end: shallow$1(events[close - 2][1].start) - }; - media = [ - ['enter', group, context], - ['enter', label, context] - ]; // Opening marker. + const indexBeforeExits = self.events.length; + let indexBeforeFlow = indexBeforeExits; + /** @type {boolean|undefined} */ - media = chunkedPush(media, events.slice(open + 1, open + offset + 3)); // Text open. + let seen; + /** @type {Point|undefined} */ - media = chunkedPush(media, [['enter', text, context]]); // Between. + let point; // Find the previous chunk (the one before the lazy line). - media = chunkedPush( - media, - resolveAll$1( - context.parser.constructs.insideSpan.null, - events.slice(open + offset + 4, close - 3), - context - ) - ); // Text close, marker close, label close. + while (indexBeforeFlow--) { + if ( + self.events[indexBeforeFlow][0] === 'exit' && + self.events[indexBeforeFlow][1].type === 'chunkFlow' + ) { + if (seen) { + point = self.events[indexBeforeFlow][1].end; + break + } - media = chunkedPush(media, [ - ['exit', text, context], - events[close - 2], - events[close - 1], - ['exit', label, context] - ]); // Reference, resource, or so. + seen = true; + } + } - media = chunkedPush(media, events.slice(close + 1)); // Media close. + exitContainers(continued); // Fix positions. - media = chunkedPush(media, [['exit', group, context]]); - chunkedSplice(events, open, events.length, media); - return events -} + index = indexBeforeExits; -function tokenizeLabelEnd(effects, ok, nok) { - var self = this; - var index = self.events.length; - var labelStart; - var defined; // Find an opening. + while (index < self.events.length) { + self.events[index][1].end = Object.assign({}, point); + index++; + } // Inject the exits earlier (they’re still also at the end). - while (index--) { - if ( - (self.events[index][1].type === 'labelImage' || - self.events[index][1].type === 'labelLink') && - !self.events[index][1]._balanced - ) { - labelStart = self.events[index][1]; - break + splice( + self.events, + indexBeforeFlow + 1, + 0, + self.events.slice(indexBeforeExits) + ); // Discard the duplicate exits. + + self.events.length = index; } } + /** + * @param {number} size + * @returns {void} + */ - return start + function exitContainers(size) { + let index = stack.length; // Exit open containers. - function start(code) { - if (!labelStart) { - return nok(code) - } // It’s a balanced bracket, but contains a link. + while (index-- > size) { + const entry = stack[index]; + self.containerState = entry[1]; + entry[0].exit.call(self, effects); + } - if (labelStart._inactive) return balanced(code) - defined = - self.parser.defined.indexOf( - normalizeIdentifier$2( - self.sliceSerialize({ - start: labelStart.end, - end: self.now() - }) - ) - ) > -1; - effects.enter('labelEnd'); - effects.enter('labelMarker'); - effects.consume(code); - effects.exit('labelMarker'); - effects.exit('labelEnd'); - return afterLabelEnd + stack.length = size; } - function afterLabelEnd(code) { - // Resource: `[asd](fgh)`. - if (code === 40) { - return effects.attempt( - resourceConstruct, - ok, - defined ? ok : balanced - )(code) - } // Collapsed (`[asd][]`) or full (`[asd][fgh]`) reference? - - if (code === 91) { - return effects.attempt( - fullReferenceConstruct, - ok, - defined - ? effects.attempt(collapsedReferenceConstruct, ok, balanced) - : balanced - )(code) - } // Shortcut reference: `[asd]`? - - return defined ? ok(code) : balanced(code) + function closeFlow() { + childFlow.write([null]); + childToken = undefined; + childFlow = undefined; + self.containerState._closeFlow = undefined; } +} +/** @type {Tokenizer} */ - function balanced(code) { - labelStart._balanced = true; - return nok(code) - } +function tokenizeContainer(effects, ok, nok) { + return factorySpace( + effects, + effects.attempt(this.parser.constructs.document, ok, nok), + 'linePrefix', + this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + ) } -function tokenizeResource(effects, ok, nok) { - return start +/** + * @typedef {import('micromark-util-types').Code} Code + */ - function start(code) { - effects.enter('resource'); - effects.enter('resourceMarker'); - effects.consume(code); - effects.exit('resourceMarker'); - return factoryWhitespace(effects, open) +/** + * Classify whether a character code represents whitespace, punctuation, or + * something else. + * + * Used for attention (emphasis, strong), whose sequences can open or close + * based on the class of surrounding characters. + * + * Note that eof (`null`) is seen as whitespace. + * + * @param {Code} code + * @returns {number|undefined} + */ +function classifyCharacter(code) { + if ( + code === null || + markdownLineEndingOrSpace(code) || + unicodeWhitespace(code) + ) { + return 1 } - function open(code) { - if (code === 41) { - return end(code) - } + if (unicodePunctuation(code)) { + return 2 + } +} - return factoryDestination( - effects, - destinationAfter, - nok, - 'resourceDestination', - 'resourceDestinationLiteral', - 'resourceDestinationLiteralMarker', - 'resourceDestinationRaw', - 'resourceDestinationString', - 3 - )(code) - } - - function destinationAfter(code) { - return markdownLineEndingOrSpace$1(code) - ? factoryWhitespace(effects, between)(code) - : end(code) - } +/** + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Resolver} Resolver + */ - function between(code) { - if (code === 34 || code === 39 || code === 40) { - return factoryTitle( - effects, - factoryWhitespace(effects, end), - nok, - 'resourceTitle', - 'resourceTitleMarker', - 'resourceTitleString' - )(code) - } +/** + * Call all `resolveAll`s. + * + * @param {{resolveAll?: Resolver}[]} constructs + * @param {Event[]} events + * @param {TokenizeContext} context + * @returns {Event[]} + */ +function resolveAll(constructs, events, context) { + /** @type {Resolver[]} */ + const called = []; + let index = -1; - return end(code) - } + while (++index < constructs.length) { + const resolve = constructs[index].resolveAll; - function end(code) { - if (code === 41) { - effects.enter('resourceMarker'); - effects.consume(code); - effects.exit('resourceMarker'); - effects.exit('resource'); - return ok + if (resolve && !called.includes(resolve)) { + events = resolve(events, context); + called.push(resolve); } - - return nok(code) - } -} - -function tokenizeFullReference(effects, ok, nok) { - var self = this; - return start - - function start(code) { - return factoryLabel.call( - self, - effects, - afterLabel, - nok, - 'reference', - 'referenceMarker', - 'referenceString' - )(code) } - function afterLabel(code) { - return self.parser.defined.indexOf( - normalizeIdentifier$2( - self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) - ) - ) < 0 - ? nok(code) - : ok(code) - } + return events } -function tokenizeCollapsedReference(effects, ok, nok) { - return start - - function start(code) { - effects.enter('reference'); - effects.enter('referenceMarker'); - effects.consume(code); - effects.exit('referenceMarker'); - return open - } +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Point} Point + */ - function open(code) { - if (code === 93) { - effects.enter('referenceMarker'); - effects.consume(code); - effects.exit('referenceMarker'); - effects.exit('reference'); - return ok - } +/** @type {Construct} */ +const attention = { + name: 'attention', + tokenize: tokenizeAttention, + resolveAll: resolveAllAttention +}; +/** + * Take all events and resolve attention to emphasis or strong. + * + * @type {Resolver} + */ - return nok(code) - } -} +function resolveAllAttention(events, context) { + let index = -1; + /** @type {number} */ -var labelEnd_1 = labelEnd$3; + let open; + /** @type {Token} */ -var labelEnd$2 = labelEnd_1; + let group; + /** @type {Token} */ -var labelStartImage$1 = { - name: 'labelStartImage', - tokenize: tokenizeLabelStartImage, - resolveAll: labelEnd$2.resolveAll -}; + let text; + /** @type {Token} */ -function tokenizeLabelStartImage(effects, ok, nok) { - var self = this; - return start + let openingSequence; + /** @type {Token} */ - function start(code) { - effects.enter('labelImage'); - effects.enter('labelImageMarker'); - effects.consume(code); - effects.exit('labelImageMarker'); - return open - } + let closingSequence; + /** @type {number} */ - function open(code) { - if (code === 91) { - effects.enter('labelMarker'); - effects.consume(code); - effects.exit('labelMarker'); - effects.exit('labelImage'); - return after - } + let use; + /** @type {Event[]} */ - return nok(code) - } + let nextEvents; + /** @type {number} */ - function after(code) { - /* c8 ignore next */ - return code === 94 && - /* c8 ignore next */ - '_hiddenFootnoteSupport' in self.parser.constructs - ? /* c8 ignore next */ - nok(code) - : ok(code) - } -} + let offset; // Walk through all events. + // + // Note: performance of this is fine on an mb of normal markdown, but it’s + // a bottleneck for malicious stuff. -var labelStartImage_1 = labelStartImage$1; + while (++index < events.length) { + // Find a token that can close. + if ( + events[index][0] === 'enter' && + events[index][1].type === 'attentionSequence' && + events[index][1]._close + ) { + open = index; // Now walk back to find an opener. -var labelEnd$1 = labelEnd_1; + while (open--) { + // Find a token that can open the closer. + if ( + events[open][0] === 'exit' && + events[open][1].type === 'attentionSequence' && + events[open][1]._open && // If the markers are the same: + context.sliceSerialize(events[open][1]).charCodeAt(0) === + context.sliceSerialize(events[index][1]).charCodeAt(0) + ) { + // If the opening can close or the closing can open, + // and the close size *is not* a multiple of three, + // but the sum of the opening and closing size *is* multiple of three, + // then don’t match. + if ( + (events[open][1]._close || events[index][1]._open) && + (events[index][1].end.offset - events[index][1].start.offset) % 3 && + !( + (events[open][1].end.offset - + events[open][1].start.offset + + events[index][1].end.offset - + events[index][1].start.offset) % + 3 + ) + ) { + continue + } // Number of markers to use from the sequence. -var labelStartLink$1 = { - name: 'labelStartLink', - tokenize: tokenizeLabelStartLink, - resolveAll: labelEnd$1.resolveAll -}; + use = + events[open][1].end.offset - events[open][1].start.offset > 1 && + events[index][1].end.offset - events[index][1].start.offset > 1 + ? 2 + : 1; + const start = Object.assign({}, events[open][1].end); + const end = Object.assign({}, events[index][1].start); + movePoint(start, -use); + movePoint(end, use); + openingSequence = { + type: use > 1 ? 'strongSequence' : 'emphasisSequence', + start, + end: Object.assign({}, events[open][1].end) + }; + closingSequence = { + type: use > 1 ? 'strongSequence' : 'emphasisSequence', + start: Object.assign({}, events[index][1].start), + end + }; + text = { + type: use > 1 ? 'strongText' : 'emphasisText', + start: Object.assign({}, events[open][1].end), + end: Object.assign({}, events[index][1].start) + }; + group = { + type: use > 1 ? 'strong' : 'emphasis', + start: Object.assign({}, openingSequence.start), + end: Object.assign({}, closingSequence.end) + }; + events[open][1].end = Object.assign({}, openingSequence.start); + events[index][1].start = Object.assign({}, closingSequence.end); + nextEvents = []; // If there are more markers in the opening, add them before. -function tokenizeLabelStartLink(effects, ok, nok) { - var self = this; - return start + if (events[open][1].end.offset - events[open][1].start.offset) { + nextEvents = push(nextEvents, [ + ['enter', events[open][1], context], + ['exit', events[open][1], context] + ]); + } // Opening. - function start(code) { - effects.enter('labelLink'); - effects.enter('labelMarker'); - effects.consume(code); - effects.exit('labelMarker'); - effects.exit('labelLink'); - return after - } + nextEvents = push(nextEvents, [ + ['enter', group, context], + ['enter', openingSequence, context], + ['exit', openingSequence, context], + ['enter', text, context] + ]); // Between. - function after(code) { - /* c8 ignore next */ - return code === 94 && - /* c8 ignore next */ - '_hiddenFootnoteSupport' in self.parser.constructs - ? /* c8 ignore next */ - nok(code) - : ok(code) - } -} + nextEvents = push( + nextEvents, + resolveAll( + context.parser.constructs.insideSpan.null, + events.slice(open + 1, index), + context + ) + ); // Closing. -var labelStartLink_1 = labelStartLink$1; + nextEvents = push(nextEvents, [ + ['exit', text, context], + ['enter', closingSequence, context], + ['exit', closingSequence, context], + ['exit', group, context] + ]); // If there are more markers in the closing, add them after. -var factorySpace$4 = factorySpace$i; + if (events[index][1].end.offset - events[index][1].start.offset) { + offset = 2; + nextEvents = push(nextEvents, [ + ['enter', events[index][1], context], + ['exit', events[index][1], context] + ]); + } else { + offset = 0; + } -var lineEnding$1 = { - name: 'lineEnding', - tokenize: tokenizeLineEnding -}; + splice(events, open - 1, index - open + 3, nextEvents); + index = open + nextEvents.length - offset - 2; + break + } + } + } + } // Remove remaining sequences. -function tokenizeLineEnding(effects, ok) { - return start + index = -1; - function start(code) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - return factorySpace$4(effects, ok, 'linePrefix') + while (++index < events.length) { + if (events[index][1].type === 'attentionSequence') { + events[index][1].type = 'data'; + } } -} - -var lineEnding_1 = lineEnding$1; -var markdownLineEnding$2 = markdownLineEnding_1; -var markdownSpace$2 = markdownSpace_1; -var factorySpace$3 = factorySpace$i; + return events +} +/** @type {Tokenizer} */ -var thematicBreak$3 = { - name: 'thematicBreak', - tokenize: tokenizeThematicBreak -}; +function tokenizeAttention(effects, ok) { + const before = classifyCharacter(this.previous); + /** @type {NonNullable} */ -function tokenizeThematicBreak(effects, ok, nok) { - var size = 0; - var marker; + let marker; return start + /** @type {State} */ function start(code) { - effects.enter('thematicBreak'); + effects.enter('attentionSequence'); marker = code; - return atBreak(code) - } - - function atBreak(code) { - if (code === marker) { - effects.enter('thematicBreakSequence'); - return sequence(code) - } - - if (markdownSpace$2(code)) { - return factorySpace$3(effects, atBreak, 'whitespace')(code) - } - - if (size < 3 || (code !== null && !markdownLineEnding$2(code))) { - return nok(code) - } - - effects.exit('thematicBreak'); - return ok(code) + return sequence(code) } + /** @type {State} */ function sequence(code) { if (code === marker) { effects.consume(code); - size++; return sequence } - effects.exit('thematicBreakSequence'); - return atBreak(code) + const token = effects.exit('attentionSequence'); + const after = classifyCharacter(code); + const open = !after || (after === 2 && before); + const close = !before || (before === 2 && after); + token._open = Boolean(marker === 42 ? open : open && (before || !close)); + token._close = Boolean(marker === 42 ? close : close && (after || !open)); + return ok(code) } } +/** + * Move a point a bit. + * + * Note: `move` only works inside lines! It’s not possible to move past other + * chunks (replacement characters, tabs, or line endings). + * + * @param {Point} point + * @param {number} offset + * @returns {void} + */ -var thematicBreak_1$1 = thematicBreak$3; +function movePoint(point, offset) { + point.column += offset; + point.offset += offset; + point._bufferIndex += offset; +} -var asciiDigit$1 = asciiDigit_1; -var markdownSpace$1 = markdownSpace_1; -var prefixSize = prefixSize_1; -var sizeChunks = sizeChunks_1; -var factorySpace$2 = factorySpace$i; -var partialBlankLine = partialBlankLine_1; -var thematicBreak$2 = thematicBreak_1$1; +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + */ -var list$2 = { - name: 'list', - tokenize: tokenizeListStart, - continuation: { - tokenize: tokenizeListContinuation - }, - exit: tokenizeListEnd -}; -var listItemPrefixWhitespaceConstruct = { - tokenize: tokenizeListItemPrefixWhitespace, - partial: true -}; -var indentConstruct = { - tokenize: tokenizeIndent, - partial: true +/** @type {Construct} */ +const autolink = { + name: 'autolink', + tokenize: tokenizeAutolink }; +/** @type {Tokenizer} */ -function tokenizeListStart(effects, ok, nok) { - var self = this; - var initialSize = prefixSize(self.events, 'linePrefix'); - var size = 0; +function tokenizeAutolink(effects, ok, nok) { + let size = 1; return start + /** @type {State} */ function start(code) { - var kind = - self.containerState.type || - (code === 42 || code === 43 || code === 45 - ? 'listUnordered' - : 'listOrdered'); - - if ( - kind === 'listUnordered' - ? !self.containerState.marker || code === self.containerState.marker - : asciiDigit$1(code) - ) { - if (!self.containerState.type) { - self.containerState.type = kind; - effects.enter(kind, { - _container: true - }); - } - - if (kind === 'listUnordered') { - effects.enter('listItemPrefix'); - return code === 42 || code === 45 - ? effects.check(thematicBreak$2, nok, atMarker)(code) - : atMarker(code) - } + effects.enter('autolink'); + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.enter('autolinkProtocol'); + return open + } + /** @type {State} */ - if (!self.interrupt || code === 49) { - effects.enter('listItemPrefix'); - effects.enter('listItemValue'); - return inside(code) - } + function open(code) { + if (asciiAlpha(code)) { + effects.consume(code); + return schemeOrEmailAtext } - return nok(code) + return asciiAtext(code) ? emailAtext(code) : nok(code) + } + /** @type {State} */ + + function schemeOrEmailAtext(code) { + return code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code) + ? schemeInsideOrEmailAtext(code) + : emailAtext(code) } + /** @type {State} */ - function inside(code) { - if (asciiDigit$1(code) && ++size < 10) { + function schemeInsideOrEmailAtext(code) { + if (code === 58) { effects.consume(code); - return inside + return urlInside } if ( - (!self.interrupt || size < 2) && - (self.containerState.marker - ? code === self.containerState.marker - : code === 41 || code === 46) + (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && + size++ < 32 ) { - effects.exit('listItemValue'); - return atMarker(code) + effects.consume(code); + return schemeInsideOrEmailAtext } - return nok(code) + return emailAtext(code) } + /** @type {State} */ + + function urlInside(code) { + if (code === 62) { + effects.exit('autolinkProtocol'); + return end(code) + } + + if (code === null || code === 32 || code === 60 || asciiControl(code)) { + return nok(code) + } - function atMarker(code) { - effects.enter('listItemMarker'); effects.consume(code); - effects.exit('listItemMarker'); - self.containerState.marker = self.containerState.marker || code; - return effects.check( - partialBlankLine, // Can’t be empty when interrupting. - self.interrupt ? nok : onBlank, - effects.attempt( - listItemPrefixWhitespaceConstruct, - endOfPrefix, - otherPrefix - ) - ) + return urlInside } + /** @type {State} */ - function onBlank(code) { - self.containerState.initialBlankLine = true; - initialSize++; - return endOfPrefix(code) - } + function emailAtext(code) { + if (code === 64) { + effects.consume(code); + size = 0; + return emailAtSignOrDot + } - function otherPrefix(code) { - if (markdownSpace$1(code)) { - effects.enter('listItemPrefixWhitespace'); + if (asciiAtext(code)) { effects.consume(code); - effects.exit('listItemPrefixWhitespace'); - return endOfPrefix + return emailAtext } return nok(code) } + /** @type {State} */ - function endOfPrefix(code) { - self.containerState.size = - initialSize + sizeChunks(self.sliceStream(effects.exit('listItemPrefix'))); - return ok(code) + function emailAtSignOrDot(code) { + return asciiAlphanumeric(code) ? emailLabel(code) : nok(code) } -} + /** @type {State} */ -function tokenizeListContinuation(effects, ok, nok) { - var self = this; - self.containerState._closeFlow = undefined; - return effects.check(partialBlankLine, onBlank, notBlank) + function emailLabel(code) { + if (code === 46) { + effects.consume(code); + size = 0; + return emailAtSignOrDot + } - function onBlank(code) { - self.containerState.furtherBlankLines = - self.containerState.furtherBlankLines || - self.containerState.initialBlankLine; // We have a blank line. - // Still, try to consume at most the items size. + if (code === 62) { + // Exit, then change the type. + effects.exit('autolinkProtocol').type = 'autolinkEmail'; + return end(code) + } - return factorySpace$2( - effects, - ok, - 'listItemIndent', - self.containerState.size + 1 - )(code) + return emailValue(code) } + /** @type {State} */ - function notBlank(code) { - if (self.containerState.furtherBlankLines || !markdownSpace$1(code)) { - self.containerState.furtherBlankLines = self.containerState.initialBlankLine = undefined; - return notInCurrentItem(code) + function emailValue(code) { + if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) { + effects.consume(code); + return code === 45 ? emailValue : emailLabel } - self.containerState.furtherBlankLines = self.containerState.initialBlankLine = undefined; - return effects.attempt(indentConstruct, ok, notInCurrentItem)(code) + return nok(code) } + /** @type {State} */ - function notInCurrentItem(code) { - // While we do continue, we signal that the flow should be closed. - self.containerState._closeFlow = true; // As we’re closing flow, we’re no longer interrupting. - - self.interrupt = undefined; - return factorySpace$2( - effects, - effects.attempt(list$2, ok, nok), - 'linePrefix', - self.parser.constructs.disable.null.indexOf('codeIndented') > -1 - ? undefined - : 4 - )(code) + function end(code) { + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.exit('autolink'); + return ok } } -function tokenizeIndent(effects, ok, nok) { - var self = this; - return factorySpace$2( - effects, - afterPrefix, - 'listItemIndent', - self.containerState.size + 1 - ) - - function afterPrefix(code) { - return prefixSize(self.events, 'listItemIndent') === - self.containerState.size - ? ok(code) - : nok(code) - } -} +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + */ -function tokenizeListEnd(effects) { - effects.exit(this.containerState.type); -} +/** @type {Construct} */ +const blankLine = { + tokenize: tokenizeBlankLine, + partial: true +}; +/** @type {Tokenizer} */ -function tokenizeListItemPrefixWhitespace(effects, ok, nok) { - var self = this; - return factorySpace$2( - effects, - afterPrefix, - 'listItemPrefixWhitespace', - self.parser.constructs.disable.null.indexOf('codeIndented') > -1 - ? undefined - : 4 + 1 - ) +function tokenizeBlankLine(effects, ok, nok) { + return factorySpace(effects, afterWhitespace, 'linePrefix') + /** @type {State} */ - function afterPrefix(code) { - return markdownSpace$1(code) || - !prefixSize(self.events, 'listItemPrefixWhitespace') - ? nok(code) - : ok(code) + function afterWhitespace(code) { + return code === null || markdownLineEnding(code) ? ok(code) : nok(code) } } -var list_1$1 = list$2; - -var markdownLineEnding$1 = markdownLineEnding_1; -var shallow = shallow_1; -var factorySpace$1 = factorySpace$i; +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Exiter} Exiter + * @typedef {import('micromark-util-types').State} State + */ -var setextUnderline$1 = { - name: 'setextUnderline', - tokenize: tokenizeSetextUnderline, - resolveTo: resolveToSetextUnderline +/** @type {Construct} */ +const blockQuote = { + name: 'blockQuote', + tokenize: tokenizeBlockQuoteStart, + continuation: { + tokenize: tokenizeBlockQuoteContinuation + }, + exit: exit$1 }; +/** @type {Tokenizer} */ -function resolveToSetextUnderline(events, context) { - var index = events.length; - var content; - var text; - var definition; - var heading; // Find the opening of the content. - // It’ll always exist: we don’t tokenize if it isn’t there. +function tokenizeBlockQuoteStart(effects, ok, nok) { + const self = this; + return start + /** @type {State} */ - while (index--) { - if (events[index][0] === 'enter') { - if (events[index][1].type === 'content') { - content = index; - break - } + function start(code) { + if (code === 62) { + const state = self.containerState; - if (events[index][1].type === 'paragraph') { - text = index; - } - } // Exit - else { - if (events[index][1].type === 'content') { - // Remove the content end (if needed we’ll add it later) - events.splice(index, 1); + if (!state.open) { + effects.enter('blockQuote', { + _container: true + }); + state.open = true; } - if (!definition && events[index][1].type === 'definition') { - definition = index; - } + effects.enter('blockQuotePrefix'); + effects.enter('blockQuoteMarker'); + effects.consume(code); + effects.exit('blockQuoteMarker'); + return after } + + return nok(code) } + /** @type {State} */ - heading = { - type: 'setextHeading', - start: shallow(events[text][1].start), - end: shallow(events[events.length - 1][1].end) - }; // Change the paragraph to setext heading text. + function after(code) { + if (markdownSpace(code)) { + effects.enter('blockQuotePrefixWhitespace'); + effects.consume(code); + effects.exit('blockQuotePrefixWhitespace'); + effects.exit('blockQuotePrefix'); + return ok + } - events[text][1].type = 'setextHeadingText'; // If we have definitions in the content, we’ll keep on having content, - // but we need move it. + effects.exit('blockQuotePrefix'); + return ok(code) + } +} +/** @type {Tokenizer} */ - if (definition) { - events.splice(text, 0, ['enter', heading, context]); - events.splice(definition + 1, 0, ['exit', events[content][1], context]); - events[content][1].end = shallow(events[definition][1].end); - } else { - events[content][1] = heading; - } // Add the heading exit at the end. +function tokenizeBlockQuoteContinuation(effects, ok, nok) { + return factorySpace( + effects, + effects.attempt(blockQuote, ok, nok), + 'linePrefix', + this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + ) +} +/** @type {Exiter} */ - events.push(['exit', heading, context]); - return events +function exit$1(effects) { + effects.exit('blockQuote'); } -function tokenizeSetextUnderline(effects, ok, nok) { - var self = this; - var index = self.events.length; - var marker; - var paragraph; // Find an opening. +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + */ - while (index--) { - // Skip enter/exit of line ending, line prefix, and content. - // We can now either have a definition or a paragraph. - if ( - self.events[index][1].type !== 'lineEnding' && - self.events[index][1].type !== 'linePrefix' && - self.events[index][1].type !== 'content' - ) { - paragraph = self.events[index][1].type === 'paragraph'; - break +/** @type {Construct} */ +const characterEscape$1 = { + name: 'characterEscape', + tokenize: tokenizeCharacterEscape +}; +/** @type {Tokenizer} */ + +function tokenizeCharacterEscape(effects, ok, nok) { + return start + /** @type {State} */ + + function start(code) { + effects.enter('characterEscape'); + effects.enter('escapeMarker'); + effects.consume(code); + effects.exit('escapeMarker'); + return open + } + /** @type {State} */ + + function open(code) { + if (asciiPunctuation(code)) { + effects.enter('characterEscapeValue'); + effects.consume(code); + effects.exit('characterEscapeValue'); + effects.exit('characterEscape'); + return ok } + + return nok(code) } +} + +var characterEntities = { + AEli: 'Æ', + AElig: 'Æ', + AM: '&', + AMP: '&', + Aacut: 'Á', + Aacute: 'Á', + Abreve: 'Ă', + Acir: 'Â', + Acirc: 'Â', + Acy: 'А', + Afr: '𝔄', + Agrav: 'À', + Agrave: 'À', + Alpha: 'Α', + Amacr: 'Ā', + And: '⩓', + Aogon: 'Ą', + Aopf: '𝔸', + ApplyFunction: '⁡', + Arin: 'Å', + Aring: 'Å', + Ascr: '𝒜', + Assign: '≔', + Atild: 'Ã', + Atilde: 'Ã', + Aum: 'Ä', + Auml: 'Ä', + Backslash: '∖', + Barv: '⫧', + Barwed: '⌆', + Bcy: 'Б', + Because: '∵', + Bernoullis: 'ℬ', + Beta: 'Β', + Bfr: '𝔅', + Bopf: '𝔹', + Breve: '˘', + Bscr: 'ℬ', + Bumpeq: '≎', + CHcy: 'Ч', + COP: '©', + COPY: '©', + Cacute: 'Ć', + Cap: '⋒', + CapitalDifferentialD: 'ⅅ', + Cayleys: 'ℭ', + Ccaron: 'Č', + Ccedi: 'Ç', + Ccedil: 'Ç', + Ccirc: 'Ĉ', + Cconint: '∰', + Cdot: 'Ċ', + Cedilla: '¸', + CenterDot: '·', + Cfr: 'ℭ', + Chi: 'Χ', + CircleDot: '⊙', + CircleMinus: '⊖', + CirclePlus: '⊕', + CircleTimes: '⊗', + ClockwiseContourIntegral: '∲', + CloseCurlyDoubleQuote: '”', + CloseCurlyQuote: '’', + Colon: '∷', + Colone: '⩴', + Congruent: '≡', + Conint: '∯', + ContourIntegral: '∮', + Copf: 'ℂ', + Coproduct: '∐', + CounterClockwiseContourIntegral: '∳', + Cross: '⨯', + Cscr: '𝒞', + Cup: '⋓', + CupCap: '≍', + DD: 'ⅅ', + DDotrahd: '⤑', + DJcy: 'Ђ', + DScy: 'Ѕ', + DZcy: 'Џ', + Dagger: '‡', + Darr: '↡', + Dashv: '⫤', + Dcaron: 'Ď', + Dcy: 'Д', + Del: '∇', + Delta: 'Δ', + Dfr: '𝔇', + DiacriticalAcute: '´', + DiacriticalDot: '˙', + DiacriticalDoubleAcute: '˝', + DiacriticalGrave: '`', + DiacriticalTilde: '˜', + Diamond: '⋄', + DifferentialD: 'ⅆ', + Dopf: '𝔻', + Dot: '¨', + DotDot: '⃜', + DotEqual: '≐', + DoubleContourIntegral: '∯', + DoubleDot: '¨', + DoubleDownArrow: '⇓', + DoubleLeftArrow: '⇐', + DoubleLeftRightArrow: '⇔', + DoubleLeftTee: '⫤', + DoubleLongLeftArrow: '⟸', + DoubleLongLeftRightArrow: '⟺', + DoubleLongRightArrow: '⟹', + DoubleRightArrow: '⇒', + DoubleRightTee: '⊨', + DoubleUpArrow: '⇑', + DoubleUpDownArrow: '⇕', + DoubleVerticalBar: '∥', + DownArrow: '↓', + DownArrowBar: '⤓', + DownArrowUpArrow: '⇵', + DownBreve: '̑', + DownLeftRightVector: '⥐', + DownLeftTeeVector: '⥞', + DownLeftVector: '↽', + DownLeftVectorBar: '⥖', + DownRightTeeVector: '⥟', + DownRightVector: '⇁', + DownRightVectorBar: '⥗', + DownTee: '⊤', + DownTeeArrow: '↧', + Downarrow: '⇓', + Dscr: '𝒟', + Dstrok: 'Đ', + ENG: 'Ŋ', + ET: 'Ð', + ETH: 'Ð', + Eacut: 'É', + Eacute: 'É', + Ecaron: 'Ě', + Ecir: 'Ê', + Ecirc: 'Ê', + Ecy: 'Э', + Edot: 'Ė', + Efr: '𝔈', + Egrav: 'È', + Egrave: 'È', + Element: '∈', + Emacr: 'Ē', + EmptySmallSquare: '◻', + EmptyVerySmallSquare: '▫', + Eogon: 'Ę', + Eopf: '𝔼', + Epsilon: 'Ε', + Equal: '⩵', + EqualTilde: '≂', + Equilibrium: '⇌', + Escr: 'ℰ', + Esim: '⩳', + Eta: 'Η', + Eum: 'Ë', + Euml: 'Ë', + Exists: '∃', + ExponentialE: 'ⅇ', + Fcy: 'Ф', + Ffr: '𝔉', + FilledSmallSquare: '◼', + FilledVerySmallSquare: '▪', + Fopf: '𝔽', + ForAll: '∀', + Fouriertrf: 'ℱ', + Fscr: 'ℱ', + GJcy: 'Ѓ', + G: '>', + GT: '>', + Gamma: 'Γ', + Gammad: 'Ϝ', + Gbreve: 'Ğ', + Gcedil: 'Ģ', + Gcirc: 'Ĝ', + Gcy: 'Г', + Gdot: 'Ġ', + Gfr: '𝔊', + Gg: '⋙', + Gopf: '𝔾', + GreaterEqual: '≥', + GreaterEqualLess: '⋛', + GreaterFullEqual: '≧', + GreaterGreater: '⪢', + GreaterLess: '≷', + GreaterSlantEqual: '⩾', + GreaterTilde: '≳', + Gscr: '𝒢', + Gt: '≫', + HARDcy: 'Ъ', + Hacek: 'ˇ', + Hat: '^', + Hcirc: 'Ĥ', + Hfr: 'ℌ', + HilbertSpace: 'ℋ', + Hopf: 'ℍ', + HorizontalLine: '─', + Hscr: 'ℋ', + Hstrok: 'Ħ', + HumpDownHump: '≎', + HumpEqual: '≏', + IEcy: 'Е', + IJlig: 'IJ', + IOcy: 'Ё', + Iacut: 'Í', + Iacute: 'Í', + Icir: 'Î', + Icirc: 'Î', + Icy: 'И', + Idot: 'İ', + Ifr: 'ℑ', + Igrav: 'Ì', + Igrave: 'Ì', + Im: 'ℑ', + Imacr: 'Ī', + ImaginaryI: 'ⅈ', + Implies: '⇒', + Int: '∬', + Integral: '∫', + Intersection: '⋂', + InvisibleComma: '⁣', + InvisibleTimes: '⁢', + Iogon: 'Į', + Iopf: '𝕀', + Iota: 'Ι', + Iscr: 'ℐ', + Itilde: 'Ĩ', + Iukcy: 'І', + Ium: 'Ï', + Iuml: 'Ï', + Jcirc: 'Ĵ', + Jcy: 'Й', + Jfr: '𝔍', + Jopf: '𝕁', + Jscr: '𝒥', + Jsercy: 'Ј', + Jukcy: 'Є', + KHcy: 'Х', + KJcy: 'Ќ', + Kappa: 'Κ', + Kcedil: 'Ķ', + Kcy: 'К', + Kfr: '𝔎', + Kopf: '𝕂', + Kscr: '𝒦', + LJcy: 'Љ', + L: '<', + LT: '<', + Lacute: 'Ĺ', + Lambda: 'Λ', + Lang: '⟪', + Laplacetrf: 'ℒ', + Larr: '↞', + Lcaron: 'Ľ', + Lcedil: 'Ļ', + Lcy: 'Л', + LeftAngleBracket: '⟨', + LeftArrow: '←', + LeftArrowBar: '⇤', + LeftArrowRightArrow: '⇆', + LeftCeiling: '⌈', + LeftDoubleBracket: '⟦', + LeftDownTeeVector: '⥡', + LeftDownVector: '⇃', + LeftDownVectorBar: '⥙', + LeftFloor: '⌊', + LeftRightArrow: '↔', + LeftRightVector: '⥎', + LeftTee: '⊣', + LeftTeeArrow: '↤', + LeftTeeVector: '⥚', + LeftTriangle: '⊲', + LeftTriangleBar: '⧏', + LeftTriangleEqual: '⊴', + LeftUpDownVector: '⥑', + LeftUpTeeVector: '⥠', + LeftUpVector: '↿', + LeftUpVectorBar: '⥘', + LeftVector: '↼', + LeftVectorBar: '⥒', + Leftarrow: '⇐', + Leftrightarrow: '⇔', + LessEqualGreater: '⋚', + LessFullEqual: '≦', + LessGreater: '≶', + LessLess: '⪡', + LessSlantEqual: '⩽', + LessTilde: '≲', + Lfr: '𝔏', + Ll: '⋘', + Lleftarrow: '⇚', + Lmidot: 'Ŀ', + LongLeftArrow: '⟵', + LongLeftRightArrow: '⟷', + LongRightArrow: '⟶', + Longleftarrow: '⟸', + Longleftrightarrow: '⟺', + Longrightarrow: '⟹', + Lopf: '𝕃', + LowerLeftArrow: '↙', + LowerRightArrow: '↘', + Lscr: 'ℒ', + Lsh: '↰', + Lstrok: 'Ł', + Lt: '≪', + Map: '⤅', + Mcy: 'М', + MediumSpace: ' ', + Mellintrf: 'ℳ', + Mfr: '𝔐', + MinusPlus: '∓', + Mopf: '𝕄', + Mscr: 'ℳ', + Mu: 'Μ', + NJcy: 'Њ', + Nacute: 'Ń', + Ncaron: 'Ň', + Ncedil: 'Ņ', + Ncy: 'Н', + NegativeMediumSpace: '​', + NegativeThickSpace: '​', + NegativeThinSpace: '​', + NegativeVeryThinSpace: '​', + NestedGreaterGreater: '≫', + NestedLessLess: '≪', + NewLine: '\n', + Nfr: '𝔑', + NoBreak: '⁠', + NonBreakingSpace: ' ', + Nopf: 'ℕ', + Not: '⫬', + NotCongruent: '≢', + NotCupCap: '≭', + NotDoubleVerticalBar: '∦', + NotElement: '∉', + NotEqual: '≠', + NotEqualTilde: '≂̸', + NotExists: '∄', + NotGreater: '≯', + NotGreaterEqual: '≱', + NotGreaterFullEqual: '≧̸', + NotGreaterGreater: '≫̸', + NotGreaterLess: '≹', + NotGreaterSlantEqual: '⩾̸', + NotGreaterTilde: '≵', + NotHumpDownHump: '≎̸', + NotHumpEqual: '≏̸', + NotLeftTriangle: '⋪', + NotLeftTriangleBar: '⧏̸', + NotLeftTriangleEqual: '⋬', + NotLess: '≮', + NotLessEqual: '≰', + NotLessGreater: '≸', + NotLessLess: '≪̸', + NotLessSlantEqual: '⩽̸', + NotLessTilde: '≴', + NotNestedGreaterGreater: '⪢̸', + NotNestedLessLess: '⪡̸', + NotPrecedes: '⊀', + NotPrecedesEqual: '⪯̸', + NotPrecedesSlantEqual: '⋠', + NotReverseElement: '∌', + NotRightTriangle: '⋫', + NotRightTriangleBar: '⧐̸', + NotRightTriangleEqual: '⋭', + NotSquareSubset: '⊏̸', + NotSquareSubsetEqual: '⋢', + NotSquareSuperset: '⊐̸', + NotSquareSupersetEqual: '⋣', + NotSubset: '⊂⃒', + NotSubsetEqual: '⊈', + NotSucceeds: '⊁', + NotSucceedsEqual: '⪰̸', + NotSucceedsSlantEqual: '⋡', + NotSucceedsTilde: '≿̸', + NotSuperset: '⊃⃒', + NotSupersetEqual: '⊉', + NotTilde: '≁', + NotTildeEqual: '≄', + NotTildeFullEqual: '≇', + NotTildeTilde: '≉', + NotVerticalBar: '∤', + Nscr: '𝒩', + Ntild: 'Ñ', + Ntilde: 'Ñ', + Nu: 'Ν', + OElig: 'Œ', + Oacut: 'Ó', + Oacute: 'Ó', + Ocir: 'Ô', + Ocirc: 'Ô', + Ocy: 'О', + Odblac: 'Ő', + Ofr: '𝔒', + Ograv: 'Ò', + Ograve: 'Ò', + Omacr: 'Ō', + Omega: 'Ω', + Omicron: 'Ο', + Oopf: '𝕆', + OpenCurlyDoubleQuote: '“', + OpenCurlyQuote: '‘', + Or: '⩔', + Oscr: '𝒪', + Oslas: 'Ø', + Oslash: 'Ø', + Otild: 'Õ', + Otilde: 'Õ', + Otimes: '⨷', + Oum: 'Ö', + Ouml: 'Ö', + OverBar: '‾', + OverBrace: '⏞', + OverBracket: '⎴', + OverParenthesis: '⏜', + PartialD: '∂', + Pcy: 'П', + Pfr: '𝔓', + Phi: 'Φ', + Pi: 'Π', + PlusMinus: '±', + Poincareplane: 'ℌ', + Popf: 'ℙ', + Pr: '⪻', + Precedes: '≺', + PrecedesEqual: '⪯', + PrecedesSlantEqual: '≼', + PrecedesTilde: '≾', + Prime: '″', + Product: '∏', + Proportion: '∷', + Proportional: '∝', + Pscr: '𝒫', + Psi: 'Ψ', + QUO: '"', + QUOT: '"', + Qfr: '𝔔', + Qopf: 'ℚ', + Qscr: '𝒬', + RBarr: '⤐', + RE: '®', + REG: '®', + Racute: 'Ŕ', + Rang: '⟫', + Rarr: '↠', + Rarrtl: '⤖', + Rcaron: 'Ř', + Rcedil: 'Ŗ', + Rcy: 'Р', + Re: 'ℜ', + ReverseElement: '∋', + ReverseEquilibrium: '⇋', + ReverseUpEquilibrium: '⥯', + Rfr: 'ℜ', + Rho: 'Ρ', + RightAngleBracket: '⟩', + RightArrow: '→', + RightArrowBar: '⇥', + RightArrowLeftArrow: '⇄', + RightCeiling: '⌉', + RightDoubleBracket: '⟧', + RightDownTeeVector: '⥝', + RightDownVector: '⇂', + RightDownVectorBar: '⥕', + RightFloor: '⌋', + RightTee: '⊢', + RightTeeArrow: '↦', + RightTeeVector: '⥛', + RightTriangle: '⊳', + RightTriangleBar: '⧐', + RightTriangleEqual: '⊵', + RightUpDownVector: '⥏', + RightUpTeeVector: '⥜', + RightUpVector: '↾', + RightUpVectorBar: '⥔', + RightVector: '⇀', + RightVectorBar: '⥓', + Rightarrow: '⇒', + Ropf: 'ℝ', + RoundImplies: '⥰', + Rrightarrow: '⇛', + Rscr: 'ℛ', + Rsh: '↱', + RuleDelayed: '⧴', + SHCHcy: 'Щ', + SHcy: 'Ш', + SOFTcy: 'Ь', + Sacute: 'Ś', + Sc: '⪼', + Scaron: 'Š', + Scedil: 'Ş', + Scirc: 'Ŝ', + Scy: 'С', + Sfr: '𝔖', + ShortDownArrow: '↓', + ShortLeftArrow: '←', + ShortRightArrow: '→', + ShortUpArrow: '↑', + Sigma: 'Σ', + SmallCircle: '∘', + Sopf: '𝕊', + Sqrt: '√', + Square: '□', + SquareIntersection: '⊓', + SquareSubset: '⊏', + SquareSubsetEqual: '⊑', + SquareSuperset: '⊐', + SquareSupersetEqual: '⊒', + SquareUnion: '⊔', + Sscr: '𝒮', + Star: '⋆', + Sub: '⋐', + Subset: '⋐', + SubsetEqual: '⊆', + Succeeds: '≻', + SucceedsEqual: '⪰', + SucceedsSlantEqual: '≽', + SucceedsTilde: '≿', + SuchThat: '∋', + Sum: '∑', + Sup: '⋑', + Superset: '⊃', + SupersetEqual: '⊇', + Supset: '⋑', + THOR: 'Þ', + THORN: 'Þ', + TRADE: '™', + TSHcy: 'Ћ', + TScy: 'Ц', + Tab: '\t', + Tau: 'Τ', + Tcaron: 'Ť', + Tcedil: 'Ţ', + Tcy: 'Т', + Tfr: '𝔗', + Therefore: '∴', + Theta: 'Θ', + ThickSpace: '  ', + ThinSpace: ' ', + Tilde: '∼', + TildeEqual: '≃', + TildeFullEqual: '≅', + TildeTilde: '≈', + Topf: '𝕋', + TripleDot: '⃛', + Tscr: '𝒯', + Tstrok: 'Ŧ', + Uacut: 'Ú', + Uacute: 'Ú', + Uarr: '↟', + Uarrocir: '⥉', + Ubrcy: 'Ў', + Ubreve: 'Ŭ', + Ucir: 'Û', + Ucirc: 'Û', + Ucy: 'У', + Udblac: 'Ű', + Ufr: '𝔘', + Ugrav: 'Ù', + Ugrave: 'Ù', + Umacr: 'Ū', + UnderBar: '_', + UnderBrace: '⏟', + UnderBracket: '⎵', + UnderParenthesis: '⏝', + Union: '⋃', + UnionPlus: '⊎', + Uogon: 'Ų', + Uopf: '𝕌', + UpArrow: '↑', + UpArrowBar: '⤒', + UpArrowDownArrow: '⇅', + UpDownArrow: '↕', + UpEquilibrium: '⥮', + UpTee: '⊥', + UpTeeArrow: '↥', + Uparrow: '⇑', + Updownarrow: '⇕', + UpperLeftArrow: '↖', + UpperRightArrow: '↗', + Upsi: 'ϒ', + Upsilon: 'Υ', + Uring: 'Ů', + Uscr: '𝒰', + Utilde: 'Ũ', + Uum: 'Ü', + Uuml: 'Ü', + VDash: '⊫', + Vbar: '⫫', + Vcy: 'В', + Vdash: '⊩', + Vdashl: '⫦', + Vee: '⋁', + Verbar: '‖', + Vert: '‖', + VerticalBar: '∣', + VerticalLine: '|', + VerticalSeparator: '❘', + VerticalTilde: '≀', + VeryThinSpace: ' ', + Vfr: '𝔙', + Vopf: '𝕍', + Vscr: '𝒱', + Vvdash: '⊪', + Wcirc: 'Ŵ', + Wedge: '⋀', + Wfr: '𝔚', + Wopf: '𝕎', + Wscr: '𝒲', + Xfr: '𝔛', + Xi: 'Ξ', + Xopf: '𝕏', + Xscr: '𝒳', + YAcy: 'Я', + YIcy: 'Ї', + YUcy: 'Ю', + Yacut: 'Ý', + Yacute: 'Ý', + Ycirc: 'Ŷ', + Ycy: 'Ы', + Yfr: '𝔜', + Yopf: '𝕐', + Yscr: '𝒴', + Yuml: 'Ÿ', + ZHcy: 'Ж', + Zacute: 'Ź', + Zcaron: 'Ž', + Zcy: 'З', + Zdot: 'Ż', + ZeroWidthSpace: '​', + Zeta: 'Ζ', + Zfr: 'ℨ', + Zopf: 'ℤ', + Zscr: '𝒵', + aacut: 'á', + aacute: 'á', + abreve: 'ă', + ac: '∾', + acE: '∾̳', + acd: '∿', + acir: 'â', + acirc: 'â', + acut: '´', + acute: '´', + acy: 'а', + aeli: 'æ', + aelig: 'æ', + af: '⁡', + afr: '𝔞', + agrav: 'à', + agrave: 'à', + alefsym: 'ℵ', + aleph: 'ℵ', + alpha: 'α', + amacr: 'ā', + amalg: '⨿', + am: '&', + amp: '&', + and: '∧', + andand: '⩕', + andd: '⩜', + andslope: '⩘', + andv: '⩚', + ang: '∠', + ange: '⦤', + angle: '∠', + angmsd: '∡', + angmsdaa: '⦨', + angmsdab: '⦩', + angmsdac: '⦪', + angmsdad: '⦫', + angmsdae: '⦬', + angmsdaf: '⦭', + angmsdag: '⦮', + angmsdah: '⦯', + angrt: '∟', + angrtvb: '⊾', + angrtvbd: '⦝', + angsph: '∢', + angst: 'Å', + angzarr: '⍼', + aogon: 'ą', + aopf: '𝕒', + ap: '≈', + apE: '⩰', + apacir: '⩯', + ape: '≊', + apid: '≋', + apos: "'", + approx: '≈', + approxeq: '≊', + arin: 'å', + aring: 'å', + ascr: '𝒶', + ast: '*', + asymp: '≈', + asympeq: '≍', + atild: 'ã', + atilde: 'ã', + aum: 'ä', + auml: 'ä', + awconint: '∳', + awint: '⨑', + bNot: '⫭', + backcong: '≌', + backepsilon: '϶', + backprime: '‵', + backsim: '∽', + backsimeq: '⋍', + barvee: '⊽', + barwed: '⌅', + barwedge: '⌅', + bbrk: '⎵', + bbrktbrk: '⎶', + bcong: '≌', + bcy: 'б', + bdquo: '„', + becaus: '∵', + because: '∵', + bemptyv: '⦰', + bepsi: '϶', + bernou: 'ℬ', + beta: 'β', + beth: 'ℶ', + between: '≬', + bfr: '𝔟', + bigcap: '⋂', + bigcirc: '◯', + bigcup: '⋃', + bigodot: '⨀', + bigoplus: '⨁', + bigotimes: '⨂', + bigsqcup: '⨆', + bigstar: '★', + bigtriangledown: '▽', + bigtriangleup: '△', + biguplus: '⨄', + bigvee: '⋁', + bigwedge: '⋀', + bkarow: '⤍', + blacklozenge: '⧫', + blacksquare: '▪', + blacktriangle: '▴', + blacktriangledown: '▾', + blacktriangleleft: '◂', + blacktriangleright: '▸', + blank: '␣', + blk12: '▒', + blk14: '░', + blk34: '▓', + block: '█', + bne: '=⃥', + bnequiv: '≡⃥', + bnot: '⌐', + bopf: '𝕓', + bot: '⊥', + bottom: '⊥', + bowtie: '⋈', + boxDL: '╗', + boxDR: '╔', + boxDl: '╖', + boxDr: '╓', + boxH: '═', + boxHD: '╦', + boxHU: '╩', + boxHd: '╤', + boxHu: '╧', + boxUL: '╝', + boxUR: '╚', + boxUl: '╜', + boxUr: '╙', + boxV: '║', + boxVH: '╬', + boxVL: '╣', + boxVR: '╠', + boxVh: '╫', + boxVl: '╢', + boxVr: '╟', + boxbox: '⧉', + boxdL: '╕', + boxdR: '╒', + boxdl: '┐', + boxdr: '┌', + boxh: '─', + boxhD: '╥', + boxhU: '╨', + boxhd: '┬', + boxhu: '┴', + boxminus: '⊟', + boxplus: '⊞', + boxtimes: '⊠', + boxuL: '╛', + boxuR: '╘', + boxul: '┘', + boxur: '└', + boxv: '│', + boxvH: '╪', + boxvL: '╡', + boxvR: '╞', + boxvh: '┼', + boxvl: '┤', + boxvr: '├', + bprime: '‵', + breve: '˘', + brvba: '¦', + brvbar: '¦', + bscr: '𝒷', + bsemi: '⁏', + bsim: '∽', + bsime: '⋍', + bsol: '\\', + bsolb: '⧅', + bsolhsub: '⟈', + bull: '•', + bullet: '•', + bump: '≎', + bumpE: '⪮', + bumpe: '≏', + bumpeq: '≏', + cacute: 'ć', + cap: '∩', + capand: '⩄', + capbrcup: '⩉', + capcap: '⩋', + capcup: '⩇', + capdot: '⩀', + caps: '∩︀', + caret: '⁁', + caron: 'ˇ', + ccaps: '⩍', + ccaron: 'č', + ccedi: 'ç', + ccedil: 'ç', + ccirc: 'ĉ', + ccups: '⩌', + ccupssm: '⩐', + cdot: 'ċ', + cedi: '¸', + cedil: '¸', + cemptyv: '⦲', + cen: '¢', + cent: '¢', + centerdot: '·', + cfr: '𝔠', + chcy: 'ч', + check: '✓', + checkmark: '✓', + chi: 'χ', + cir: '○', + cirE: '⧃', + circ: 'ˆ', + circeq: '≗', + circlearrowleft: '↺', + circlearrowright: '↻', + circledR: '®', + circledS: 'Ⓢ', + circledast: '⊛', + circledcirc: '⊚', + circleddash: '⊝', + cire: '≗', + cirfnint: '⨐', + cirmid: '⫯', + cirscir: '⧂', + clubs: '♣', + clubsuit: '♣', + colon: ':', + colone: '≔', + coloneq: '≔', + comma: ',', + commat: '@', + comp: '∁', + compfn: '∘', + complement: '∁', + complexes: 'ℂ', + cong: '≅', + congdot: '⩭', + conint: '∮', + copf: '𝕔', + coprod: '∐', + cop: '©', + copy: '©', + copysr: '℗', + crarr: '↵', + cross: '✗', + cscr: '𝒸', + csub: '⫏', + csube: '⫑', + csup: '⫐', + csupe: '⫒', + ctdot: '⋯', + cudarrl: '⤸', + cudarrr: '⤵', + cuepr: '⋞', + cuesc: '⋟', + cularr: '↶', + cularrp: '⤽', + cup: '∪', + cupbrcap: '⩈', + cupcap: '⩆', + cupcup: '⩊', + cupdot: '⊍', + cupor: '⩅', + cups: '∪︀', + curarr: '↷', + curarrm: '⤼', + curlyeqprec: '⋞', + curlyeqsucc: '⋟', + curlyvee: '⋎', + curlywedge: '⋏', + curre: '¤', + curren: '¤', + curvearrowleft: '↶', + curvearrowright: '↷', + cuvee: '⋎', + cuwed: '⋏', + cwconint: '∲', + cwint: '∱', + cylcty: '⌭', + dArr: '⇓', + dHar: '⥥', + dagger: '†', + daleth: 'ℸ', + darr: '↓', + dash: '‐', + dashv: '⊣', + dbkarow: '⤏', + dblac: '˝', + dcaron: 'ď', + dcy: 'д', + dd: 'ⅆ', + ddagger: '‡', + ddarr: '⇊', + ddotseq: '⩷', + de: '°', + deg: '°', + delta: 'δ', + demptyv: '⦱', + dfisht: '⥿', + dfr: '𝔡', + dharl: '⇃', + dharr: '⇂', + diam: '⋄', + diamond: '⋄', + diamondsuit: '♦', + diams: '♦', + die: '¨', + digamma: 'ϝ', + disin: '⋲', + div: '÷', + divid: '÷', + divide: '÷', + divideontimes: '⋇', + divonx: '⋇', + djcy: 'ђ', + dlcorn: '⌞', + dlcrop: '⌍', + dollar: '$', + dopf: '𝕕', + dot: '˙', + doteq: '≐', + doteqdot: '≑', + dotminus: '∸', + dotplus: '∔', + dotsquare: '⊡', + doublebarwedge: '⌆', + downarrow: '↓', + downdownarrows: '⇊', + downharpoonleft: '⇃', + downharpoonright: '⇂', + drbkarow: '⤐', + drcorn: '⌟', + drcrop: '⌌', + dscr: '𝒹', + dscy: 'ѕ', + dsol: '⧶', + dstrok: 'đ', + dtdot: '⋱', + dtri: '▿', + dtrif: '▾', + duarr: '⇵', + duhar: '⥯', + dwangle: '⦦', + dzcy: 'џ', + dzigrarr: '⟿', + eDDot: '⩷', + eDot: '≑', + eacut: 'é', + eacute: 'é', + easter: '⩮', + ecaron: 'ě', + ecir: 'ê', + ecirc: 'ê', + ecolon: '≕', + ecy: 'э', + edot: 'ė', + ee: 'ⅇ', + efDot: '≒', + efr: '𝔢', + eg: '⪚', + egrav: 'è', + egrave: 'è', + egs: '⪖', + egsdot: '⪘', + el: '⪙', + elinters: '⏧', + ell: 'ℓ', + els: '⪕', + elsdot: '⪗', + emacr: 'ē', + empty: '∅', + emptyset: '∅', + emptyv: '∅', + emsp13: ' ', + emsp14: ' ', + emsp: ' ', + eng: 'ŋ', + ensp: ' ', + eogon: 'ę', + eopf: '𝕖', + epar: '⋕', + eparsl: '⧣', + eplus: '⩱', + epsi: 'ε', + epsilon: 'ε', + epsiv: 'ϵ', + eqcirc: '≖', + eqcolon: '≕', + eqsim: '≂', + eqslantgtr: '⪖', + eqslantless: '⪕', + equals: '=', + equest: '≟', + equiv: '≡', + equivDD: '⩸', + eqvparsl: '⧥', + erDot: '≓', + erarr: '⥱', + escr: 'ℯ', + esdot: '≐', + esim: '≂', + eta: 'η', + et: 'ð', + eth: 'ð', + eum: 'ë', + euml: 'ë', + euro: '€', + excl: '!', + exist: '∃', + expectation: 'ℰ', + exponentiale: 'ⅇ', + fallingdotseq: '≒', + fcy: 'ф', + female: '♀', + ffilig: 'ffi', + fflig: 'ff', + ffllig: 'ffl', + ffr: '𝔣', + filig: 'fi', + fjlig: 'fj', + flat: '♭', + fllig: 'fl', + fltns: '▱', + fnof: 'ƒ', + fopf: '𝕗', + forall: '∀', + fork: '⋔', + forkv: '⫙', + fpartint: '⨍', + frac1: '¼', + frac12: '½', + frac13: '⅓', + frac14: '¼', + frac15: '⅕', + frac16: '⅙', + frac18: '⅛', + frac23: '⅔', + frac25: '⅖', + frac3: '¾', + frac34: '¾', + frac35: '⅗', + frac38: '⅜', + frac45: '⅘', + frac56: '⅚', + frac58: '⅝', + frac78: '⅞', + frasl: '⁄', + frown: '⌢', + fscr: '𝒻', + gE: '≧', + gEl: '⪌', + gacute: 'ǵ', + gamma: 'γ', + gammad: 'ϝ', + gap: '⪆', + gbreve: 'ğ', + gcirc: 'ĝ', + gcy: 'г', + gdot: 'ġ', + ge: '≥', + gel: '⋛', + geq: '≥', + geqq: '≧', + geqslant: '⩾', + ges: '⩾', + gescc: '⪩', + gesdot: '⪀', + gesdoto: '⪂', + gesdotol: '⪄', + gesl: '⋛︀', + gesles: '⪔', + gfr: '𝔤', + gg: '≫', + ggg: '⋙', + gimel: 'ℷ', + gjcy: 'ѓ', + gl: '≷', + glE: '⪒', + gla: '⪥', + glj: '⪤', + gnE: '≩', + gnap: '⪊', + gnapprox: '⪊', + gne: '⪈', + gneq: '⪈', + gneqq: '≩', + gnsim: '⋧', + gopf: '𝕘', + grave: '`', + gscr: 'ℊ', + gsim: '≳', + gsime: '⪎', + gsiml: '⪐', + g: '>', + gt: '>', + gtcc: '⪧', + gtcir: '⩺', + gtdot: '⋗', + gtlPar: '⦕', + gtquest: '⩼', + gtrapprox: '⪆', + gtrarr: '⥸', + gtrdot: '⋗', + gtreqless: '⋛', + gtreqqless: '⪌', + gtrless: '≷', + gtrsim: '≳', + gvertneqq: '≩︀', + gvnE: '≩︀', + hArr: '⇔', + hairsp: ' ', + half: '½', + hamilt: 'ℋ', + hardcy: 'ъ', + harr: '↔', + harrcir: '⥈', + harrw: '↭', + hbar: 'ℏ', + hcirc: 'ĥ', + hearts: '♥', + heartsuit: '♥', + hellip: '…', + hercon: '⊹', + hfr: '𝔥', + hksearow: '⤥', + hkswarow: '⤦', + hoarr: '⇿', + homtht: '∻', + hookleftarrow: '↩', + hookrightarrow: '↪', + hopf: '𝕙', + horbar: '―', + hscr: '𝒽', + hslash: 'ℏ', + hstrok: 'ħ', + hybull: '⁃', + hyphen: '‐', + iacut: 'í', + iacute: 'í', + ic: '⁣', + icir: 'î', + icirc: 'î', + icy: 'и', + iecy: 'е', + iexc: '¡', + iexcl: '¡', + iff: '⇔', + ifr: '𝔦', + igrav: 'ì', + igrave: 'ì', + ii: 'ⅈ', + iiiint: '⨌', + iiint: '∭', + iinfin: '⧜', + iiota: '℩', + ijlig: 'ij', + imacr: 'ī', + image: 'ℑ', + imagline: 'ℐ', + imagpart: 'ℑ', + imath: 'ı', + imof: '⊷', + imped: 'Ƶ', + in: '∈', + incare: '℅', + infin: '∞', + infintie: '⧝', + inodot: 'ı', + int: '∫', + intcal: '⊺', + integers: 'ℤ', + intercal: '⊺', + intlarhk: '⨗', + intprod: '⨼', + iocy: 'ё', + iogon: 'į', + iopf: '𝕚', + iota: 'ι', + iprod: '⨼', + iques: '¿', + iquest: '¿', + iscr: '𝒾', + isin: '∈', + isinE: '⋹', + isindot: '⋵', + isins: '⋴', + isinsv: '⋳', + isinv: '∈', + it: '⁢', + itilde: 'ĩ', + iukcy: 'і', + ium: 'ï', + iuml: 'ï', + jcirc: 'ĵ', + jcy: 'й', + jfr: '𝔧', + jmath: 'ȷ', + jopf: '𝕛', + jscr: '𝒿', + jsercy: 'ј', + jukcy: 'є', + kappa: 'κ', + kappav: 'ϰ', + kcedil: 'ķ', + kcy: 'к', + kfr: '𝔨', + kgreen: 'ĸ', + khcy: 'х', + kjcy: 'ќ', + kopf: '𝕜', + kscr: '𝓀', + lAarr: '⇚', + lArr: '⇐', + lAtail: '⤛', + lBarr: '⤎', + lE: '≦', + lEg: '⪋', + lHar: '⥢', + lacute: 'ĺ', + laemptyv: '⦴', + lagran: 'ℒ', + lambda: 'λ', + lang: '⟨', + langd: '⦑', + langle: '⟨', + lap: '⪅', + laqu: '«', + laquo: '«', + larr: '←', + larrb: '⇤', + larrbfs: '⤟', + larrfs: '⤝', + larrhk: '↩', + larrlp: '↫', + larrpl: '⤹', + larrsim: '⥳', + larrtl: '↢', + lat: '⪫', + latail: '⤙', + late: '⪭', + lates: '⪭︀', + lbarr: '⤌', + lbbrk: '❲', + lbrace: '{', + lbrack: '[', + lbrke: '⦋', + lbrksld: '⦏', + lbrkslu: '⦍', + lcaron: 'ľ', + lcedil: 'ļ', + lceil: '⌈', + lcub: '{', + lcy: 'л', + ldca: '⤶', + ldquo: '“', + ldquor: '„', + ldrdhar: '⥧', + ldrushar: '⥋', + ldsh: '↲', + le: '≤', + leftarrow: '←', + leftarrowtail: '↢', + leftharpoondown: '↽', + leftharpoonup: '↼', + leftleftarrows: '⇇', + leftrightarrow: '↔', + leftrightarrows: '⇆', + leftrightharpoons: '⇋', + leftrightsquigarrow: '↭', + leftthreetimes: '⋋', + leg: '⋚', + leq: '≤', + leqq: '≦', + leqslant: '⩽', + les: '⩽', + lescc: '⪨', + lesdot: '⩿', + lesdoto: '⪁', + lesdotor: '⪃', + lesg: '⋚︀', + lesges: '⪓', + lessapprox: '⪅', + lessdot: '⋖', + lesseqgtr: '⋚', + lesseqqgtr: '⪋', + lessgtr: '≶', + lesssim: '≲', + lfisht: '⥼', + lfloor: '⌊', + lfr: '𝔩', + lg: '≶', + lgE: '⪑', + lhard: '↽', + lharu: '↼', + lharul: '⥪', + lhblk: '▄', + ljcy: 'љ', + ll: '≪', + llarr: '⇇', + llcorner: '⌞', + llhard: '⥫', + lltri: '◺', + lmidot: 'ŀ', + lmoust: '⎰', + lmoustache: '⎰', + lnE: '≨', + lnap: '⪉', + lnapprox: '⪉', + lne: '⪇', + lneq: '⪇', + lneqq: '≨', + lnsim: '⋦', + loang: '⟬', + loarr: '⇽', + lobrk: '⟦', + longleftarrow: '⟵', + longleftrightarrow: '⟷', + longmapsto: '⟼', + longrightarrow: '⟶', + looparrowleft: '↫', + looparrowright: '↬', + lopar: '⦅', + lopf: '𝕝', + loplus: '⨭', + lotimes: '⨴', + lowast: '∗', + lowbar: '_', + loz: '◊', + lozenge: '◊', + lozf: '⧫', + lpar: '(', + lparlt: '⦓', + lrarr: '⇆', + lrcorner: '⌟', + lrhar: '⇋', + lrhard: '⥭', + lrm: '‎', + lrtri: '⊿', + lsaquo: '‹', + lscr: '𝓁', + lsh: '↰', + lsim: '≲', + lsime: '⪍', + lsimg: '⪏', + lsqb: '[', + lsquo: '‘', + lsquor: '‚', + lstrok: 'ł', + l: '<', + lt: '<', + ltcc: '⪦', + ltcir: '⩹', + ltdot: '⋖', + lthree: '⋋', + ltimes: '⋉', + ltlarr: '⥶', + ltquest: '⩻', + ltrPar: '⦖', + ltri: '◃', + ltrie: '⊴', + ltrif: '◂', + lurdshar: '⥊', + luruhar: '⥦', + lvertneqq: '≨︀', + lvnE: '≨︀', + mDDot: '∺', + mac: '¯', + macr: '¯', + male: '♂', + malt: '✠', + maltese: '✠', + map: '↦', + mapsto: '↦', + mapstodown: '↧', + mapstoleft: '↤', + mapstoup: '↥', + marker: '▮', + mcomma: '⨩', + mcy: 'м', + mdash: '—', + measuredangle: '∡', + mfr: '𝔪', + mho: '℧', + micr: 'µ', + micro: 'µ', + mid: '∣', + midast: '*', + midcir: '⫰', + middo: '·', + middot: '·', + minus: '−', + minusb: '⊟', + minusd: '∸', + minusdu: '⨪', + mlcp: '⫛', + mldr: '…', + mnplus: '∓', + models: '⊧', + mopf: '𝕞', + mp: '∓', + mscr: '𝓂', + mstpos: '∾', + mu: 'μ', + multimap: '⊸', + mumap: '⊸', + nGg: '⋙̸', + nGt: '≫⃒', + nGtv: '≫̸', + nLeftarrow: '⇍', + nLeftrightarrow: '⇎', + nLl: '⋘̸', + nLt: '≪⃒', + nLtv: '≪̸', + nRightarrow: '⇏', + nVDash: '⊯', + nVdash: '⊮', + nabla: '∇', + nacute: 'ń', + nang: '∠⃒', + nap: '≉', + napE: '⩰̸', + napid: '≋̸', + napos: 'ʼn', + napprox: '≉', + natur: '♮', + natural: '♮', + naturals: 'ℕ', + nbs: ' ', + nbsp: ' ', + nbump: '≎̸', + nbumpe: '≏̸', + ncap: '⩃', + ncaron: 'ň', + ncedil: 'ņ', + ncong: '≇', + ncongdot: '⩭̸', + ncup: '⩂', + ncy: 'н', + ndash: '–', + ne: '≠', + neArr: '⇗', + nearhk: '⤤', + nearr: '↗', + nearrow: '↗', + nedot: '≐̸', + nequiv: '≢', + nesear: '⤨', + nesim: '≂̸', + nexist: '∄', + nexists: '∄', + nfr: '𝔫', + ngE: '≧̸', + nge: '≱', + ngeq: '≱', + ngeqq: '≧̸', + ngeqslant: '⩾̸', + nges: '⩾̸', + ngsim: '≵', + ngt: '≯', + ngtr: '≯', + nhArr: '⇎', + nharr: '↮', + nhpar: '⫲', + ni: '∋', + nis: '⋼', + nisd: '⋺', + niv: '∋', + njcy: 'њ', + nlArr: '⇍', + nlE: '≦̸', + nlarr: '↚', + nldr: '‥', + nle: '≰', + nleftarrow: '↚', + nleftrightarrow: '↮', + nleq: '≰', + nleqq: '≦̸', + nleqslant: '⩽̸', + nles: '⩽̸', + nless: '≮', + nlsim: '≴', + nlt: '≮', + nltri: '⋪', + nltrie: '⋬', + nmid: '∤', + nopf: '𝕟', + no: '¬', + not: '¬', + notin: '∉', + notinE: '⋹̸', + notindot: '⋵̸', + notinva: '∉', + notinvb: '⋷', + notinvc: '⋶', + notni: '∌', + notniva: '∌', + notnivb: '⋾', + notnivc: '⋽', + npar: '∦', + nparallel: '∦', + nparsl: '⫽⃥', + npart: '∂̸', + npolint: '⨔', + npr: '⊀', + nprcue: '⋠', + npre: '⪯̸', + nprec: '⊀', + npreceq: '⪯̸', + nrArr: '⇏', + nrarr: '↛', + nrarrc: '⤳̸', + nrarrw: '↝̸', + nrightarrow: '↛', + nrtri: '⋫', + nrtrie: '⋭', + nsc: '⊁', + nsccue: '⋡', + nsce: '⪰̸', + nscr: '𝓃', + nshortmid: '∤', + nshortparallel: '∦', + nsim: '≁', + nsime: '≄', + nsimeq: '≄', + nsmid: '∤', + nspar: '∦', + nsqsube: '⋢', + nsqsupe: '⋣', + nsub: '⊄', + nsubE: '⫅̸', + nsube: '⊈', + nsubset: '⊂⃒', + nsubseteq: '⊈', + nsubseteqq: '⫅̸', + nsucc: '⊁', + nsucceq: '⪰̸', + nsup: '⊅', + nsupE: '⫆̸', + nsupe: '⊉', + nsupset: '⊃⃒', + nsupseteq: '⊉', + nsupseteqq: '⫆̸', + ntgl: '≹', + ntild: 'ñ', + ntilde: 'ñ', + ntlg: '≸', + ntriangleleft: '⋪', + ntrianglelefteq: '⋬', + ntriangleright: '⋫', + ntrianglerighteq: '⋭', + nu: 'ν', + num: '#', + numero: '№', + numsp: ' ', + nvDash: '⊭', + nvHarr: '⤄', + nvap: '≍⃒', + nvdash: '⊬', + nvge: '≥⃒', + nvgt: '>⃒', + nvinfin: '⧞', + nvlArr: '⤂', + nvle: '≤⃒', + nvlt: '<⃒', + nvltrie: '⊴⃒', + nvrArr: '⤃', + nvrtrie: '⊵⃒', + nvsim: '∼⃒', + nwArr: '⇖', + nwarhk: '⤣', + nwarr: '↖', + nwarrow: '↖', + nwnear: '⤧', + oS: 'Ⓢ', + oacut: 'ó', + oacute: 'ó', + oast: '⊛', + ocir: 'ô', + ocirc: 'ô', + ocy: 'о', + odash: '⊝', + odblac: 'ő', + odiv: '⨸', + odot: '⊙', + odsold: '⦼', + oelig: 'œ', + ofcir: '⦿', + ofr: '𝔬', + ogon: '˛', + ograv: 'ò', + ograve: 'ò', + ogt: '⧁', + ohbar: '⦵', + ohm: 'Ω', + oint: '∮', + olarr: '↺', + olcir: '⦾', + olcross: '⦻', + oline: '‾', + olt: '⧀', + omacr: 'ō', + omega: 'ω', + omicron: 'ο', + omid: '⦶', + ominus: '⊖', + oopf: '𝕠', + opar: '⦷', + operp: '⦹', + oplus: '⊕', + or: '∨', + orarr: '↻', + ord: 'º', + order: 'ℴ', + orderof: 'ℴ', + ordf: 'ª', + ordm: 'º', + origof: '⊶', + oror: '⩖', + orslope: '⩗', + orv: '⩛', + oscr: 'ℴ', + oslas: 'ø', + oslash: 'ø', + osol: '⊘', + otild: 'õ', + otilde: 'õ', + otimes: '⊗', + otimesas: '⨶', + oum: 'ö', + ouml: 'ö', + ovbar: '⌽', + par: '¶', + para: '¶', + parallel: '∥', + parsim: '⫳', + parsl: '⫽', + part: '∂', + pcy: 'п', + percnt: '%', + period: '.', + permil: '‰', + perp: '⊥', + pertenk: '‱', + pfr: '𝔭', + phi: 'φ', + phiv: 'ϕ', + phmmat: 'ℳ', + phone: '☎', + pi: 'π', + pitchfork: '⋔', + piv: 'ϖ', + planck: 'ℏ', + planckh: 'ℎ', + plankv: 'ℏ', + plus: '+', + plusacir: '⨣', + plusb: '⊞', + pluscir: '⨢', + plusdo: '∔', + plusdu: '⨥', + pluse: '⩲', + plusm: '±', + plusmn: '±', + plussim: '⨦', + plustwo: '⨧', + pm: '±', + pointint: '⨕', + popf: '𝕡', + poun: '£', + pound: '£', + pr: '≺', + prE: '⪳', + prap: '⪷', + prcue: '≼', + pre: '⪯', + prec: '≺', + precapprox: '⪷', + preccurlyeq: '≼', + preceq: '⪯', + precnapprox: '⪹', + precneqq: '⪵', + precnsim: '⋨', + precsim: '≾', + prime: '′', + primes: 'ℙ', + prnE: '⪵', + prnap: '⪹', + prnsim: '⋨', + prod: '∏', + profalar: '⌮', + profline: '⌒', + profsurf: '⌓', + prop: '∝', + propto: '∝', + prsim: '≾', + prurel: '⊰', + pscr: '𝓅', + psi: 'ψ', + puncsp: ' ', + qfr: '𝔮', + qint: '⨌', + qopf: '𝕢', + qprime: '⁗', + qscr: '𝓆', + quaternions: 'ℍ', + quatint: '⨖', + quest: '?', + questeq: '≟', + quo: '"', + quot: '"', + rAarr: '⇛', + rArr: '⇒', + rAtail: '⤜', + rBarr: '⤏', + rHar: '⥤', + race: '∽̱', + racute: 'ŕ', + radic: '√', + raemptyv: '⦳', + rang: '⟩', + rangd: '⦒', + range: '⦥', + rangle: '⟩', + raqu: '»', + raquo: '»', + rarr: '→', + rarrap: '⥵', + rarrb: '⇥', + rarrbfs: '⤠', + rarrc: '⤳', + rarrfs: '⤞', + rarrhk: '↪', + rarrlp: '↬', + rarrpl: '⥅', + rarrsim: '⥴', + rarrtl: '↣', + rarrw: '↝', + ratail: '⤚', + ratio: '∶', + rationals: 'ℚ', + rbarr: '⤍', + rbbrk: '❳', + rbrace: '}', + rbrack: ']', + rbrke: '⦌', + rbrksld: '⦎', + rbrkslu: '⦐', + rcaron: 'ř', + rcedil: 'ŗ', + rceil: '⌉', + rcub: '}', + rcy: 'р', + rdca: '⤷', + rdldhar: '⥩', + rdquo: '”', + rdquor: '”', + rdsh: '↳', + real: 'ℜ', + realine: 'ℛ', + realpart: 'ℜ', + reals: 'ℝ', + rect: '▭', + re: '®', + reg: '®', + rfisht: '⥽', + rfloor: '⌋', + rfr: '𝔯', + rhard: '⇁', + rharu: '⇀', + rharul: '⥬', + rho: 'ρ', + rhov: 'ϱ', + rightarrow: '→', + rightarrowtail: '↣', + rightharpoondown: '⇁', + rightharpoonup: '⇀', + rightleftarrows: '⇄', + rightleftharpoons: '⇌', + rightrightarrows: '⇉', + rightsquigarrow: '↝', + rightthreetimes: '⋌', + ring: '˚', + risingdotseq: '≓', + rlarr: '⇄', + rlhar: '⇌', + rlm: '‏', + rmoust: '⎱', + rmoustache: '⎱', + rnmid: '⫮', + roang: '⟭', + roarr: '⇾', + robrk: '⟧', + ropar: '⦆', + ropf: '𝕣', + roplus: '⨮', + rotimes: '⨵', + rpar: ')', + rpargt: '⦔', + rppolint: '⨒', + rrarr: '⇉', + rsaquo: '›', + rscr: '𝓇', + rsh: '↱', + rsqb: ']', + rsquo: '’', + rsquor: '’', + rthree: '⋌', + rtimes: '⋊', + rtri: '▹', + rtrie: '⊵', + rtrif: '▸', + rtriltri: '⧎', + ruluhar: '⥨', + rx: '℞', + sacute: 'ś', + sbquo: '‚', + sc: '≻', + scE: '⪴', + scap: '⪸', + scaron: 'š', + sccue: '≽', + sce: '⪰', + scedil: 'ş', + scirc: 'ŝ', + scnE: '⪶', + scnap: '⪺', + scnsim: '⋩', + scpolint: '⨓', + scsim: '≿', + scy: 'с', + sdot: '⋅', + sdotb: '⊡', + sdote: '⩦', + seArr: '⇘', + searhk: '⤥', + searr: '↘', + searrow: '↘', + sec: '§', + sect: '§', + semi: ';', + seswar: '⤩', + setminus: '∖', + setmn: '∖', + sext: '✶', + sfr: '𝔰', + sfrown: '⌢', + sharp: '♯', + shchcy: 'щ', + shcy: 'ш', + shortmid: '∣', + shortparallel: '∥', + sh: '­', + shy: '­', + sigma: 'σ', + sigmaf: 'ς', + sigmav: 'ς', + sim: '∼', + simdot: '⩪', + sime: '≃', + simeq: '≃', + simg: '⪞', + simgE: '⪠', + siml: '⪝', + simlE: '⪟', + simne: '≆', + simplus: '⨤', + simrarr: '⥲', + slarr: '←', + smallsetminus: '∖', + smashp: '⨳', + smeparsl: '⧤', + smid: '∣', + smile: '⌣', + smt: '⪪', + smte: '⪬', + smtes: '⪬︀', + softcy: 'ь', + sol: '/', + solb: '⧄', + solbar: '⌿', + sopf: '𝕤', + spades: '♠', + spadesuit: '♠', + spar: '∥', + sqcap: '⊓', + sqcaps: '⊓︀', + sqcup: '⊔', + sqcups: '⊔︀', + sqsub: '⊏', + sqsube: '⊑', + sqsubset: '⊏', + sqsubseteq: '⊑', + sqsup: '⊐', + sqsupe: '⊒', + sqsupset: '⊐', + sqsupseteq: '⊒', + squ: '□', + square: '□', + squarf: '▪', + squf: '▪', + srarr: '→', + sscr: '𝓈', + ssetmn: '∖', + ssmile: '⌣', + sstarf: '⋆', + star: '☆', + starf: '★', + straightepsilon: 'ϵ', + straightphi: 'ϕ', + strns: '¯', + sub: '⊂', + subE: '⫅', + subdot: '⪽', + sube: '⊆', + subedot: '⫃', + submult: '⫁', + subnE: '⫋', + subne: '⊊', + subplus: '⪿', + subrarr: '⥹', + subset: '⊂', + subseteq: '⊆', + subseteqq: '⫅', + subsetneq: '⊊', + subsetneqq: '⫋', + subsim: '⫇', + subsub: '⫕', + subsup: '⫓', + succ: '≻', + succapprox: '⪸', + succcurlyeq: '≽', + succeq: '⪰', + succnapprox: '⪺', + succneqq: '⪶', + succnsim: '⋩', + succsim: '≿', + sum: '∑', + sung: '♪', + sup: '⊃', + sup1: '¹', + sup2: '²', + sup3: '³', + supE: '⫆', + supdot: '⪾', + supdsub: '⫘', + supe: '⊇', + supedot: '⫄', + suphsol: '⟉', + suphsub: '⫗', + suplarr: '⥻', + supmult: '⫂', + supnE: '⫌', + supne: '⊋', + supplus: '⫀', + supset: '⊃', + supseteq: '⊇', + supseteqq: '⫆', + supsetneq: '⊋', + supsetneqq: '⫌', + supsim: '⫈', + supsub: '⫔', + supsup: '⫖', + swArr: '⇙', + swarhk: '⤦', + swarr: '↙', + swarrow: '↙', + swnwar: '⤪', + szli: 'ß', + szlig: 'ß', + target: '⌖', + tau: 'τ', + tbrk: '⎴', + tcaron: 'ť', + tcedil: 'ţ', + tcy: 'т', + tdot: '⃛', + telrec: '⌕', + tfr: '𝔱', + there4: '∴', + therefore: '∴', + theta: 'θ', + thetasym: 'ϑ', + thetav: 'ϑ', + thickapprox: '≈', + thicksim: '∼', + thinsp: ' ', + thkap: '≈', + thksim: '∼', + thor: 'þ', + thorn: 'þ', + tilde: '˜', + time: '×', + times: '×', + timesb: '⊠', + timesbar: '⨱', + timesd: '⨰', + tint: '∭', + toea: '⤨', + top: '⊤', + topbot: '⌶', + topcir: '⫱', + topf: '𝕥', + topfork: '⫚', + tosa: '⤩', + tprime: '‴', + trade: '™', + triangle: '▵', + triangledown: '▿', + triangleleft: '◃', + trianglelefteq: '⊴', + triangleq: '≜', + triangleright: '▹', + trianglerighteq: '⊵', + tridot: '◬', + trie: '≜', + triminus: '⨺', + triplus: '⨹', + trisb: '⧍', + tritime: '⨻', + trpezium: '⏢', + tscr: '𝓉', + tscy: 'ц', + tshcy: 'ћ', + tstrok: 'ŧ', + twixt: '≬', + twoheadleftarrow: '↞', + twoheadrightarrow: '↠', + uArr: '⇑', + uHar: '⥣', + uacut: 'ú', + uacute: 'ú', + uarr: '↑', + ubrcy: 'ў', + ubreve: 'ŭ', + ucir: 'û', + ucirc: 'û', + ucy: 'у', + udarr: '⇅', + udblac: 'ű', + udhar: '⥮', + ufisht: '⥾', + ufr: '𝔲', + ugrav: 'ù', + ugrave: 'ù', + uharl: '↿', + uharr: '↾', + uhblk: '▀', + ulcorn: '⌜', + ulcorner: '⌜', + ulcrop: '⌏', + ultri: '◸', + umacr: 'ū', + um: '¨', + uml: '¨', + uogon: 'ų', + uopf: '𝕦', + uparrow: '↑', + updownarrow: '↕', + upharpoonleft: '↿', + upharpoonright: '↾', + uplus: '⊎', + upsi: 'υ', + upsih: 'ϒ', + upsilon: 'υ', + upuparrows: '⇈', + urcorn: '⌝', + urcorner: '⌝', + urcrop: '⌎', + uring: 'ů', + urtri: '◹', + uscr: '𝓊', + utdot: '⋰', + utilde: 'ũ', + utri: '▵', + utrif: '▴', + uuarr: '⇈', + uum: 'ü', + uuml: 'ü', + uwangle: '⦧', + vArr: '⇕', + vBar: '⫨', + vBarv: '⫩', + vDash: '⊨', + vangrt: '⦜', + varepsilon: 'ϵ', + varkappa: 'ϰ', + varnothing: '∅', + varphi: 'ϕ', + varpi: 'ϖ', + varpropto: '∝', + varr: '↕', + varrho: 'ϱ', + varsigma: 'ς', + varsubsetneq: '⊊︀', + varsubsetneqq: '⫋︀', + varsupsetneq: '⊋︀', + varsupsetneqq: '⫌︀', + vartheta: 'ϑ', + vartriangleleft: '⊲', + vartriangleright: '⊳', + vcy: 'в', + vdash: '⊢', + vee: '∨', + veebar: '⊻', + veeeq: '≚', + vellip: '⋮', + verbar: '|', + vert: '|', + vfr: '𝔳', + vltri: '⊲', + vnsub: '⊂⃒', + vnsup: '⊃⃒', + vopf: '𝕧', + vprop: '∝', + vrtri: '⊳', + vscr: '𝓋', + vsubnE: '⫋︀', + vsubne: '⊊︀', + vsupnE: '⫌︀', + vsupne: '⊋︀', + vzigzag: '⦚', + wcirc: 'ŵ', + wedbar: '⩟', + wedge: '∧', + wedgeq: '≙', + weierp: '℘', + wfr: '𝔴', + wopf: '𝕨', + wp: '℘', + wr: '≀', + wreath: '≀', + wscr: '𝓌', + xcap: '⋂', + xcirc: '◯', + xcup: '⋃', + xdtri: '▽', + xfr: '𝔵', + xhArr: '⟺', + xharr: '⟷', + xi: 'ξ', + xlArr: '⟸', + xlarr: '⟵', + xmap: '⟼', + xnis: '⋻', + xodot: '⨀', + xopf: '𝕩', + xoplus: '⨁', + xotime: '⨂', + xrArr: '⟹', + xrarr: '⟶', + xscr: '𝓍', + xsqcup: '⨆', + xuplus: '⨄', + xutri: '△', + xvee: '⋁', + xwedge: '⋀', + yacut: 'ý', + yacute: 'ý', + yacy: 'я', + ycirc: 'ŷ', + ycy: 'ы', + ye: '¥', + yen: '¥', + yfr: '𝔶', + yicy: 'ї', + yopf: '𝕪', + yscr: '𝓎', + yucy: 'ю', + yum: 'ÿ', + yuml: 'ÿ', + zacute: 'ź', + zcaron: 'ž', + zcy: 'з', + zdot: 'ż', + zeetrf: 'ℨ', + zeta: 'ζ', + zfr: '𝔷', + zhcy: 'ж', + zigrarr: '⇝', + zopf: '𝕫', + zscr: '𝓏', + zwj: '‍', + zwnj: '‌' +}; + +var own$5 = {}.hasOwnProperty; + +/** + * @param {string} characters + * @returns {string|false} + */ +function decodeEntity(characters) { + return own$5.call(characterEntities, characters) + ? characterEntities[characters] + : false +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code + */ + +/** @type {Construct} */ +const characterReference$1 = { + name: 'characterReference', + tokenize: tokenizeCharacterReference +}; +/** @type {Tokenizer} */ + +function tokenizeCharacterReference(effects, ok, nok) { + const self = this; + let size = 0; + /** @type {number} */ + let max; + /** @type {(code: Code) => code is number} */ + + let test; return start + /** @type {State} */ function start(code) { - if (!self.lazy && (self.interrupt || paragraph)) { - effects.enter('setextHeadingLine'); - effects.enter('setextHeadingLineSequence'); - marker = code; - return closingSequence(code) + effects.enter('characterReference'); + effects.enter('characterReferenceMarker'); + effects.consume(code); + effects.exit('characterReferenceMarker'); + return open + } + /** @type {State} */ + + function open(code) { + if (code === 35) { + effects.enter('characterReferenceMarkerNumeric'); + effects.consume(code); + effects.exit('characterReferenceMarkerNumeric'); + return numeric } - return nok(code) + effects.enter('characterReferenceValue'); + max = 31; + test = asciiAlphanumeric; + return value(code) } + /** @type {State} */ - function closingSequence(code) { - if (code === marker) { + function numeric(code) { + if (code === 88 || code === 120) { + effects.enter('characterReferenceMarkerHexadecimal'); effects.consume(code); - return closingSequence + effects.exit('characterReferenceMarkerHexadecimal'); + effects.enter('characterReferenceValue'); + max = 6; + test = asciiHexDigit; + return value } - effects.exit('setextHeadingLineSequence'); - return factorySpace$1(effects, closingSequenceEnd, 'lineSuffix')(code) + effects.enter('characterReferenceValue'); + max = 7; + test = asciiDigit; + return value(code) } + /** @type {State} */ - function closingSequenceEnd(code) { - if (code === null || markdownLineEnding$1(code)) { - effects.exit('setextHeadingLine'); - return ok(code) + function value(code) { + /** @type {Token} */ + let token; + + if (code === 59 && size) { + token = effects.exit('characterReferenceValue'); + + if ( + test === asciiAlphanumeric && + !decodeEntity(self.sliceSerialize(token)) + ) { + return nok(code) + } + + effects.enter('characterReferenceMarker'); + effects.consume(code); + effects.exit('characterReferenceMarker'); + effects.exit('characterReference'); + return ok + } + + if (test(code) && size++ < max) { + effects.consume(code); + return value } return nok(code) } } -var setextUnderline_1 = setextUnderline$1; - -Object.defineProperty(constructs$2, '__esModule', {value: true}); - -var text$1$1 = text$5; -var attention = attention_1; -var autolink = autolink_1; -var blockQuote = blockQuote_1; -var characterEscape$1 = characterEscape_1; -var characterReference$1 = characterReference_1; -var codeFenced = codeFenced_1; -var codeIndented = codeIndented_1; -var codeText = codeText_1; -var definition$1 = definition_1$1; -var hardBreakEscape = hardBreakEscape_1; -var headingAtx = headingAtx_1; -var htmlFlow = htmlFlow_1; -var htmlText = htmlText_1; -var labelEnd = labelEnd_1; -var labelStartImage = labelStartImage_1; -var labelStartLink = labelStartLink_1; -var lineEnding = lineEnding_1; -var list$1 = list_1$1; -var setextUnderline = setextUnderline_1; -var thematicBreak$1 = thematicBreak_1$1; - -var document$2 = { - 42: list$1, - // Asterisk - 43: list$1, - // Plus sign - 45: list$1, - // Dash - 48: list$1, - // 0 - 49: list$1, - // 1 - 50: list$1, - // 2 - 51: list$1, - // 3 - 52: list$1, - // 4 - 53: list$1, - // 5 - 54: list$1, - // 6 - 55: list$1, - // 7 - 56: list$1, - // 8 - 57: list$1, - // 9 - 62: blockQuote // Greater than -}; -var contentInitial = { - 91: definition$1 // Left square bracket -}; -var flowInitial = { - '-2': codeIndented, - // Horizontal tab - '-1': codeIndented, - // Virtual space - 32: codeIndented // Space -}; -var flow$6 = { - 35: headingAtx, - // Number sign - 42: thematicBreak$1, - // Asterisk - 45: [setextUnderline, thematicBreak$1], - // Dash - 60: htmlFlow, - // Less than - 61: setextUnderline, - // Equals to - 95: thematicBreak$1, - // Underscore - 96: codeFenced, - // Grave accent - 126: codeFenced // Tilde -}; -var string = { - 38: characterReference$1, - // Ampersand - 92: characterEscape$1 // Backslash -}; -var text$3 = { - '-5': lineEnding, - // Carriage return - '-4': lineEnding, - // Line feed - '-3': lineEnding, - // Carriage return + line feed - 33: labelStartImage, - // Exclamation mark - 38: characterReference$1, - // Ampersand - 42: attention, - // Asterisk - 60: [autolink, htmlText], - // Less than - 91: labelStartLink, - // Left square bracket - 92: [hardBreakEscape, characterEscape$1], - // Backslash - 93: labelEnd, - // Right square bracket - 95: attention, - // Underscore - 96: codeText // Grave accent -}; -var insideSpan = { - null: [attention, text$1$1.resolver] -}; -var disable = { - null: [] +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code + */ + +/** @type {Construct} */ +const codeFenced = { + name: 'codeFenced', + tokenize: tokenizeCodeFenced, + concrete: true }; +/** @type {Tokenizer} */ -constructs$2.contentInitial = contentInitial; -constructs$2.disable = disable; -constructs$2.document = document$2; -constructs$2.flow = flow$6; -constructs$2.flowInitial = flowInitial; -constructs$2.insideSpan = insideSpan; -constructs$2.string = string; -constructs$2.text = text$3; - -var content = content$3; -var document$1 = document$3; -var flow$5 = flow$7; -var text$2 = text$5; -var combineExtensions$1 = combineExtensions_1; -var createTokenizer = createTokenizer_1; -var miniflat = miniflat_1; -var constructs$1 = constructs$2; - -function parse$3(options) { - var settings = options || {}; - var parser = { - defined: [], - constructs: combineExtensions$1( - [constructs$1].concat(miniflat(settings.extensions)) - ), - content: create(content), - document: create(document$1), - flow: create(flow$5), - string: create(text$2.string), - text: create(text$2.text) +function tokenizeCodeFenced(effects, ok, nok) { + const self = this; + /** @type {Construct} */ + + const closingFenceConstruct = { + tokenize: tokenizeClosingFence, + partial: true }; - return parser + /** @type {Construct} */ - function create(initializer) { - return creator + const nonLazyLine = { + tokenize: tokenizeNonLazyLine, + partial: true + }; + const tail = this.events[this.events.length - 1]; + const initialPrefix = + tail && tail[1].type === 'linePrefix' + ? tail[2].sliceSerialize(tail[1], true).length + : 0; + let sizeOpen = 0; + /** @type {NonNullable} */ + + let marker; + return start + /** @type {State} */ - function creator(from) { - return createTokenizer(parser, initializer, from) - } + function start(code) { + effects.enter('codeFenced'); + effects.enter('codeFencedFence'); + effects.enter('codeFencedFenceSequence'); + marker = code; + return sequenceOpen(code) } -} + /** @type {State} */ -var parse_1$1 = parse$3; + function sequenceOpen(code) { + if (code === marker) { + effects.consume(code); + sizeOpen++; + return sequenceOpen + } -var search = /[\0\t\n\r]/g; + effects.exit('codeFencedFenceSequence'); + return sizeOpen < 3 + ? nok(code) + : factorySpace(effects, infoOpen, 'whitespace')(code) + } + /** @type {State} */ -function preprocess() { - var start = true; - var column = 1; - var buffer = ''; - var atCarriageReturn; - return preprocessor + function infoOpen(code) { + if (code === null || markdownLineEnding(code)) { + return openAfter(code) + } - function preprocessor(value, encoding, end) { - var chunks = []; - var match; - var next; - var startPosition; - var endPosition; - var code; - value = buffer + value.toString(encoding); - startPosition = 0; - buffer = ''; + effects.enter('codeFencedFenceInfo'); + effects.enter('chunkString', { + contentType: 'string' + }); + return info(code) + } + /** @type {State} */ - if (start) { - if (value.charCodeAt(0) === 65279) { - startPosition++; - } + function info(code) { + if (code === null || markdownLineEndingOrSpace(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceInfo'); + return factorySpace(effects, infoAfter, 'whitespace')(code) + } - start = undefined; + if (code === 96 && code === marker) return nok(code) + effects.consume(code); + return info + } + /** @type {State} */ + + function infoAfter(code) { + if (code === null || markdownLineEnding(code)) { + return openAfter(code) } - while (startPosition < value.length) { - search.lastIndex = startPosition; - match = search.exec(value); - endPosition = match ? match.index : value.length; - code = value.charCodeAt(endPosition); + effects.enter('codeFencedFenceMeta'); + effects.enter('chunkString', { + contentType: 'string' + }); + return meta(code) + } + /** @type {State} */ - if (!match) { - buffer = value.slice(startPosition); - break - } + function meta(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceMeta'); + return openAfter(code) + } - if (code === 10 && startPosition === endPosition && atCarriageReturn) { - chunks.push(-3); - atCarriageReturn = undefined; - } else { - if (atCarriageReturn) { - chunks.push(-5); - atCarriageReturn = undefined; - } + if (code === 96 && code === marker) return nok(code) + effects.consume(code); + return meta + } + /** @type {State} */ - if (startPosition < endPosition) { - chunks.push(value.slice(startPosition, endPosition)); - column += endPosition - startPosition; - } + function openAfter(code) { + effects.exit('codeFencedFence'); + return self.interrupt ? ok(code) : contentStart(code) + } + /** @type {State} */ - if (code === 0) { - chunks.push(65533); - column++; - } else if (code === 9) { - next = Math.ceil(column / 4) * 4; - chunks.push(-2); - - while (column++ < next) chunks.push(-1); - } else if (code === 10) { - chunks.push(-4); - column = 1; - } // Must be carriage return. - else { - atCarriageReturn = true; - column = 1; - } - } + function contentStart(code) { + if (code === null) { + return after(code) + } - startPosition = endPosition + 1; + if (markdownLineEnding(code)) { + return effects.attempt( + nonLazyLine, + effects.attempt( + closingFenceConstruct, + after, + initialPrefix + ? factorySpace( + effects, + contentStart, + 'linePrefix', + initialPrefix + 1 + ) + : contentStart + ), + after + )(code) } - if (end) { - if (atCarriageReturn) chunks.push(-5); - if (buffer) chunks.push(buffer); - chunks.push(null); + effects.enter('codeFlowValue'); + return contentContinue(code) + } + /** @type {State} */ + + function contentContinue(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFlowValue'); + return contentStart(code) } - return chunks + effects.consume(code); + return contentContinue } -} + /** @type {State} */ -var preprocess_1 = preprocess; + function after(code) { + effects.exit('codeFenced'); + return ok(code) + } + /** @type {Tokenizer} */ -var subtokenize = subtokenize_1; + function tokenizeNonLazyLine(effects, ok, nok) { + const self = this; + return start + /** @type {State} */ -function postprocess$1(events) { - while (!subtokenize(events)) { - // Empty + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return lineStart + } + /** @type {State} */ + + function lineStart(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code) + } } + /** @type {Tokenizer} */ - return events -} + function tokenizeClosingFence(effects, ok, nok) { + let size = 0; + return factorySpace( + effects, + closingSequenceStart, + 'linePrefix', + this.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + ) + /** @type {State} */ -var postprocess_1 = postprocess$1; - -const AEli$1 = "Æ"; -const AElig$1 = "Æ"; -const AM$1 = "&"; -const AMP$1 = "&"; -const Aacut$1 = "Á"; -const Aacute$1 = "Á"; -const Abreve$1 = "Ă"; -const Acir$1 = "Â"; -const Acirc$1 = "Â"; -const Acy$1 = "А"; -const Afr$1 = "𝔄"; -const Agrav$1 = "À"; -const Agrave$1 = "À"; -const Alpha$1 = "Α"; -const Amacr$1 = "Ā"; -const And$1 = "⩓"; -const Aogon$1 = "Ą"; -const Aopf$1 = "𝔸"; -const ApplyFunction$1 = "⁡"; -const Arin$1 = "Å"; -const Aring$1 = "Å"; -const Ascr$1 = "𝒜"; -const Assign$1 = "≔"; -const Atild$1 = "Ã"; -const Atilde$1 = "Ã"; -const Aum$1 = "Ä"; -const Auml$1 = "Ä"; -const Backslash$1 = "∖"; -const Barv$1 = "⫧"; -const Barwed$1 = "⌆"; -const Bcy$1 = "Б"; -const Because$1 = "∵"; -const Bernoullis$1 = "ℬ"; -const Beta$1 = "Β"; -const Bfr$1 = "𝔅"; -const Bopf$1 = "𝔹"; -const Breve$1 = "˘"; -const Bscr$1 = "ℬ"; -const Bumpeq$1 = "≎"; -const CHcy$1 = "Ч"; -const COP$1 = "©"; -const COPY$1 = "©"; -const Cacute$1 = "Ć"; -const Cap$1 = "⋒"; -const CapitalDifferentialD$1 = "ⅅ"; -const Cayleys$1 = "ℭ"; -const Ccaron$1 = "Č"; -const Ccedi$1 = "Ç"; -const Ccedil$1 = "Ç"; -const Ccirc$1 = "Ĉ"; -const Cconint$1 = "∰"; -const Cdot$1 = "Ċ"; -const Cedilla$1 = "¸"; -const CenterDot$1 = "·"; -const Cfr$1 = "ℭ"; -const Chi$1 = "Χ"; -const CircleDot$1 = "⊙"; -const CircleMinus$1 = "⊖"; -const CirclePlus$1 = "⊕"; -const CircleTimes$1 = "⊗"; -const ClockwiseContourIntegral$1 = "∲"; -const CloseCurlyDoubleQuote$1 = "”"; -const CloseCurlyQuote$1 = "’"; -const Colon$1 = "∷"; -const Colone$1 = "⩴"; -const Congruent$1 = "≡"; -const Conint$1 = "∯"; -const ContourIntegral$1 = "∮"; -const Copf$1 = "ℂ"; -const Coproduct$1 = "∐"; -const CounterClockwiseContourIntegral$1 = "∳"; -const Cross$1 = "⨯"; -const Cscr$1 = "𝒞"; -const Cup$1 = "⋓"; -const CupCap$1 = "≍"; -const DD$1 = "ⅅ"; -const DDotrahd$1 = "⤑"; -const DJcy$1 = "Ђ"; -const DScy$1 = "Ѕ"; -const DZcy$1 = "Џ"; -const Dagger$1 = "‡"; -const Darr$1 = "↡"; -const Dashv$1 = "⫤"; -const Dcaron$1 = "Ď"; -const Dcy$1 = "Д"; -const Del$1 = "∇"; -const Delta$1 = "Δ"; -const Dfr$1 = "𝔇"; -const DiacriticalAcute$1 = "´"; -const DiacriticalDot$1 = "˙"; -const DiacriticalDoubleAcute$1 = "˝"; -const DiacriticalGrave$1 = "`"; -const DiacriticalTilde$1 = "˜"; -const Diamond$1 = "⋄"; -const DifferentialD$1 = "ⅆ"; -const Dopf$1 = "𝔻"; -const Dot$1 = "¨"; -const DotDot$1 = "⃜"; -const DotEqual$1 = "≐"; -const DoubleContourIntegral$1 = "∯"; -const DoubleDot$1 = "¨"; -const DoubleDownArrow$1 = "⇓"; -const DoubleLeftArrow$1 = "⇐"; -const DoubleLeftRightArrow$1 = "⇔"; -const DoubleLeftTee$1 = "⫤"; -const DoubleLongLeftArrow$1 = "⟸"; -const DoubleLongLeftRightArrow$1 = "⟺"; -const DoubleLongRightArrow$1 = "⟹"; -const DoubleRightArrow$1 = "⇒"; -const DoubleRightTee$1 = "⊨"; -const DoubleUpArrow$1 = "⇑"; -const DoubleUpDownArrow$1 = "⇕"; -const DoubleVerticalBar$1 = "∥"; -const DownArrow$1 = "↓"; -const DownArrowBar$1 = "⤓"; -const DownArrowUpArrow$1 = "⇵"; -const DownBreve$1 = "̑"; -const DownLeftRightVector$1 = "⥐"; -const DownLeftTeeVector$1 = "⥞"; -const DownLeftVector$1 = "↽"; -const DownLeftVectorBar$1 = "⥖"; -const DownRightTeeVector$1 = "⥟"; -const DownRightVector$1 = "⇁"; -const DownRightVectorBar$1 = "⥗"; -const DownTee$1 = "⊤"; -const DownTeeArrow$1 = "↧"; -const Downarrow$1 = "⇓"; -const Dscr$1 = "𝒟"; -const Dstrok$1 = "Đ"; -const ENG$1 = "Ŋ"; -const ET$1 = "Ð"; -const ETH$1 = "Ð"; -const Eacut$1 = "É"; -const Eacute$1 = "É"; -const Ecaron$1 = "Ě"; -const Ecir$1 = "Ê"; -const Ecirc$1 = "Ê"; -const Ecy$1 = "Э"; -const Edot$1 = "Ė"; -const Efr$1 = "𝔈"; -const Egrav$1 = "È"; -const Egrave$1 = "È"; -const Element$1 = "∈"; -const Emacr$1 = "Ē"; -const EmptySmallSquare$1 = "◻"; -const EmptyVerySmallSquare$1 = "▫"; -const Eogon$1 = "Ę"; -const Eopf$1 = "𝔼"; -const Epsilon$1 = "Ε"; -const Equal$1 = "⩵"; -const EqualTilde$1 = "≂"; -const Equilibrium$1 = "⇌"; -const Escr$1 = "ℰ"; -const Esim$1 = "⩳"; -const Eta$1 = "Η"; -const Eum$1 = "Ë"; -const Euml$1 = "Ë"; -const Exists$1 = "∃"; -const ExponentialE$1 = "ⅇ"; -const Fcy$1 = "Ф"; -const Ffr$1 = "𝔉"; -const FilledSmallSquare$1 = "◼"; -const FilledVerySmallSquare$1 = "▪"; -const Fopf$1 = "𝔽"; -const ForAll$1 = "∀"; -const Fouriertrf$1 = "ℱ"; -const Fscr$1 = "ℱ"; -const GJcy$1 = "Ѓ"; -const G$1 = ">"; -const GT$1 = ">"; -const Gamma$1 = "Γ"; -const Gammad$1 = "Ϝ"; -const Gbreve$1 = "Ğ"; -const Gcedil$1 = "Ģ"; -const Gcirc$1 = "Ĝ"; -const Gcy$1 = "Г"; -const Gdot$1 = "Ġ"; -const Gfr$1 = "𝔊"; -const Gg$1 = "⋙"; -const Gopf$1 = "𝔾"; -const GreaterEqual$1 = "≥"; -const GreaterEqualLess$1 = "⋛"; -const GreaterFullEqual$1 = "≧"; -const GreaterGreater$1 = "⪢"; -const GreaterLess$1 = "≷"; -const GreaterSlantEqual$1 = "⩾"; -const GreaterTilde$1 = "≳"; -const Gscr$1 = "𝒢"; -const Gt$1 = "≫"; -const HARDcy$1 = "Ъ"; -const Hacek$1 = "ˇ"; -const Hat$1 = "^"; -const Hcirc$1 = "Ĥ"; -const Hfr$1 = "ℌ"; -const HilbertSpace$1 = "ℋ"; -const Hopf$1 = "ℍ"; -const HorizontalLine$1 = "─"; -const Hscr$1 = "ℋ"; -const Hstrok$1 = "Ħ"; -const HumpDownHump$1 = "≎"; -const HumpEqual$1 = "≏"; -const IEcy$1 = "Е"; -const IJlig$1 = "IJ"; -const IOcy$1 = "Ё"; -const Iacut$1 = "Í"; -const Iacute$1 = "Í"; -const Icir$1 = "Î"; -const Icirc$1 = "Î"; -const Icy$1 = "И"; -const Idot$1 = "İ"; -const Ifr$1 = "ℑ"; -const Igrav$1 = "Ì"; -const Igrave$1 = "Ì"; -const Im$1 = "ℑ"; -const Imacr$1 = "Ī"; -const ImaginaryI$1 = "ⅈ"; -const Implies$1 = "⇒"; -const Int$1 = "∬"; -const Integral$1 = "∫"; -const Intersection$1 = "⋂"; -const InvisibleComma$1 = "⁣"; -const InvisibleTimes$1 = "⁢"; -const Iogon$1 = "Į"; -const Iopf$1 = "𝕀"; -const Iota$1 = "Ι"; -const Iscr$1 = "ℐ"; -const Itilde$1 = "Ĩ"; -const Iukcy$1 = "І"; -const Ium$1 = "Ï"; -const Iuml$1 = "Ï"; -const Jcirc$1 = "Ĵ"; -const Jcy$1 = "Й"; -const Jfr$1 = "𝔍"; -const Jopf$1 = "𝕁"; -const Jscr$1 = "𝒥"; -const Jsercy$1 = "Ј"; -const Jukcy$1 = "Є"; -const KHcy$1 = "Х"; -const KJcy$1 = "Ќ"; -const Kappa$1 = "Κ"; -const Kcedil$1 = "Ķ"; -const Kcy$1 = "К"; -const Kfr$1 = "𝔎"; -const Kopf$1 = "𝕂"; -const Kscr$1 = "𝒦"; -const LJcy$1 = "Љ"; -const L$1 = "<"; -const LT$1 = "<"; -const Lacute$1 = "Ĺ"; -const Lambda$1 = "Λ"; -const Lang$1 = "⟪"; -const Laplacetrf$1 = "ℒ"; -const Larr$1 = "↞"; -const Lcaron$1 = "Ľ"; -const Lcedil$1 = "Ļ"; -const Lcy$1 = "Л"; -const LeftAngleBracket$1 = "⟨"; -const LeftArrow$1 = "←"; -const LeftArrowBar$1 = "⇤"; -const LeftArrowRightArrow$1 = "⇆"; -const LeftCeiling$1 = "⌈"; -const LeftDoubleBracket$1 = "⟦"; -const LeftDownTeeVector$1 = "⥡"; -const LeftDownVector$1 = "⇃"; -const LeftDownVectorBar$1 = "⥙"; -const LeftFloor$1 = "⌊"; -const LeftRightArrow$1 = "↔"; -const LeftRightVector$1 = "⥎"; -const LeftTee$1 = "⊣"; -const LeftTeeArrow$1 = "↤"; -const LeftTeeVector$1 = "⥚"; -const LeftTriangle$1 = "⊲"; -const LeftTriangleBar$1 = "⧏"; -const LeftTriangleEqual$1 = "⊴"; -const LeftUpDownVector$1 = "⥑"; -const LeftUpTeeVector$1 = "⥠"; -const LeftUpVector$1 = "↿"; -const LeftUpVectorBar$1 = "⥘"; -const LeftVector$1 = "↼"; -const LeftVectorBar$1 = "⥒"; -const Leftarrow$1 = "⇐"; -const Leftrightarrow$1 = "⇔"; -const LessEqualGreater$1 = "⋚"; -const LessFullEqual$1 = "≦"; -const LessGreater$1 = "≶"; -const LessLess$1 = "⪡"; -const LessSlantEqual$1 = "⩽"; -const LessTilde$1 = "≲"; -const Lfr$1 = "𝔏"; -const Ll$1 = "⋘"; -const Lleftarrow$1 = "⇚"; -const Lmidot$1 = "Ŀ"; -const LongLeftArrow$1 = "⟵"; -const LongLeftRightArrow$1 = "⟷"; -const LongRightArrow$1 = "⟶"; -const Longleftarrow$1 = "⟸"; -const Longleftrightarrow$1 = "⟺"; -const Longrightarrow$1 = "⟹"; -const Lopf$1 = "𝕃"; -const LowerLeftArrow$1 = "↙"; -const LowerRightArrow$1 = "↘"; -const Lscr$1 = "ℒ"; -const Lsh$1 = "↰"; -const Lstrok$1 = "Ł"; -const Lt$1 = "≪"; -const Mcy$1 = "М"; -const MediumSpace$1 = " "; -const Mellintrf$1 = "ℳ"; -const Mfr$1 = "𝔐"; -const MinusPlus$1 = "∓"; -const Mopf$1 = "𝕄"; -const Mscr$1 = "ℳ"; -const Mu$1 = "Μ"; -const NJcy$1 = "Њ"; -const Nacute$1 = "Ń"; -const Ncaron$1 = "Ň"; -const Ncedil$1 = "Ņ"; -const Ncy$1 = "Н"; -const NegativeMediumSpace$1 = "​"; -const NegativeThickSpace$1 = "​"; -const NegativeThinSpace$1 = "​"; -const NegativeVeryThinSpace$1 = "​"; -const NestedGreaterGreater$1 = "≫"; -const NestedLessLess$1 = "≪"; -const NewLine$1 = "\n"; -const Nfr$1 = "𝔑"; -const NoBreak$1 = "⁠"; -const NonBreakingSpace$1 = " "; -const Nopf$1 = "ℕ"; -const Not$1 = "⫬"; -const NotCongruent$1 = "≢"; -const NotCupCap$1 = "≭"; -const NotDoubleVerticalBar$1 = "∦"; -const NotElement$1 = "∉"; -const NotEqual$1 = "≠"; -const NotEqualTilde$1 = "≂̸"; -const NotExists$1 = "∄"; -const NotGreater$1 = "≯"; -const NotGreaterEqual$1 = "≱"; -const NotGreaterFullEqual$1 = "≧̸"; -const NotGreaterGreater$1 = "≫̸"; -const NotGreaterLess$1 = "≹"; -const NotGreaterSlantEqual$1 = "⩾̸"; -const NotGreaterTilde$1 = "≵"; -const NotHumpDownHump$1 = "≎̸"; -const NotHumpEqual$1 = "≏̸"; -const NotLeftTriangle$1 = "⋪"; -const NotLeftTriangleBar$1 = "⧏̸"; -const NotLeftTriangleEqual$1 = "⋬"; -const NotLess$1 = "≮"; -const NotLessEqual$1 = "≰"; -const NotLessGreater$1 = "≸"; -const NotLessLess$1 = "≪̸"; -const NotLessSlantEqual$1 = "⩽̸"; -const NotLessTilde$1 = "≴"; -const NotNestedGreaterGreater$1 = "⪢̸"; -const NotNestedLessLess$1 = "⪡̸"; -const NotPrecedes$1 = "⊀"; -const NotPrecedesEqual$1 = "⪯̸"; -const NotPrecedesSlantEqual$1 = "⋠"; -const NotReverseElement$1 = "∌"; -const NotRightTriangle$1 = "⋫"; -const NotRightTriangleBar$1 = "⧐̸"; -const NotRightTriangleEqual$1 = "⋭"; -const NotSquareSubset$1 = "⊏̸"; -const NotSquareSubsetEqual$1 = "⋢"; -const NotSquareSuperset$1 = "⊐̸"; -const NotSquareSupersetEqual$1 = "⋣"; -const NotSubset$1 = "⊂⃒"; -const NotSubsetEqual$1 = "⊈"; -const NotSucceeds$1 = "⊁"; -const NotSucceedsEqual$1 = "⪰̸"; -const NotSucceedsSlantEqual$1 = "⋡"; -const NotSucceedsTilde$1 = "≿̸"; -const NotSuperset$1 = "⊃⃒"; -const NotSupersetEqual$1 = "⊉"; -const NotTilde$1 = "≁"; -const NotTildeEqual$1 = "≄"; -const NotTildeFullEqual$1 = "≇"; -const NotTildeTilde$1 = "≉"; -const NotVerticalBar$1 = "∤"; -const Nscr$1 = "𝒩"; -const Ntild$1 = "Ñ"; -const Ntilde$1 = "Ñ"; -const Nu$1 = "Ν"; -const OElig$1 = "Œ"; -const Oacut$1 = "Ó"; -const Oacute$1 = "Ó"; -const Ocir$1 = "Ô"; -const Ocirc$1 = "Ô"; -const Ocy$1 = "О"; -const Odblac$1 = "Ő"; -const Ofr$1 = "𝔒"; -const Ograv$1 = "Ò"; -const Ograve$1 = "Ò"; -const Omacr$1 = "Ō"; -const Omega$1 = "Ω"; -const Omicron$1 = "Ο"; -const Oopf$1 = "𝕆"; -const OpenCurlyDoubleQuote$1 = "“"; -const OpenCurlyQuote$1 = "‘"; -const Or$1 = "⩔"; -const Oscr$1 = "𝒪"; -const Oslas$1 = "Ø"; -const Oslash$1 = "Ø"; -const Otild$1 = "Õ"; -const Otilde$1 = "Õ"; -const Otimes$1 = "⨷"; -const Oum$1 = "Ö"; -const Ouml$1 = "Ö"; -const OverBar$1 = "‾"; -const OverBrace$1 = "⏞"; -const OverBracket$1 = "⎴"; -const OverParenthesis$1 = "⏜"; -const PartialD$1 = "∂"; -const Pcy$1 = "П"; -const Pfr$1 = "𝔓"; -const Phi$1 = "Φ"; -const Pi$1 = "Π"; -const PlusMinus$1 = "±"; -const Poincareplane$1 = "ℌ"; -const Popf$1 = "ℙ"; -const Pr$1 = "⪻"; -const Precedes$1 = "≺"; -const PrecedesEqual$1 = "⪯"; -const PrecedesSlantEqual$1 = "≼"; -const PrecedesTilde$1 = "≾"; -const Prime$1 = "″"; -const Product$1 = "∏"; -const Proportion$1 = "∷"; -const Proportional$1 = "∝"; -const Pscr$1 = "𝒫"; -const Psi$1 = "Ψ"; -const QUO$1 = "\""; -const QUOT$1 = "\""; -const Qfr$1 = "𝔔"; -const Qopf$1 = "ℚ"; -const Qscr$1 = "𝒬"; -const RBarr$1 = "⤐"; -const RE$1 = "®"; -const REG$1 = "®"; -const Racute$1 = "Ŕ"; -const Rang$1 = "⟫"; -const Rarr$1 = "↠"; -const Rarrtl$1 = "⤖"; -const Rcaron$1 = "Ř"; -const Rcedil$1 = "Ŗ"; -const Rcy$1 = "Р"; -const Re$1 = "ℜ"; -const ReverseElement$1 = "∋"; -const ReverseEquilibrium$1 = "⇋"; -const ReverseUpEquilibrium$1 = "⥯"; -const Rfr$1 = "ℜ"; -const Rho$1 = "Ρ"; -const RightAngleBracket$1 = "⟩"; -const RightArrow$1 = "→"; -const RightArrowBar$1 = "⇥"; -const RightArrowLeftArrow$1 = "⇄"; -const RightCeiling$1 = "⌉"; -const RightDoubleBracket$1 = "⟧"; -const RightDownTeeVector$1 = "⥝"; -const RightDownVector$1 = "⇂"; -const RightDownVectorBar$1 = "⥕"; -const RightFloor$1 = "⌋"; -const RightTee$1 = "⊢"; -const RightTeeArrow$1 = "↦"; -const RightTeeVector$1 = "⥛"; -const RightTriangle$1 = "⊳"; -const RightTriangleBar$1 = "⧐"; -const RightTriangleEqual$1 = "⊵"; -const RightUpDownVector$1 = "⥏"; -const RightUpTeeVector$1 = "⥜"; -const RightUpVector$1 = "↾"; -const RightUpVectorBar$1 = "⥔"; -const RightVector$1 = "⇀"; -const RightVectorBar$1 = "⥓"; -const Rightarrow$1 = "⇒"; -const Ropf$1 = "ℝ"; -const RoundImplies$1 = "⥰"; -const Rrightarrow$1 = "⇛"; -const Rscr$1 = "ℛ"; -const Rsh$1 = "↱"; -const RuleDelayed$1 = "⧴"; -const SHCHcy$1 = "Щ"; -const SHcy$1 = "Ш"; -const SOFTcy$1 = "Ь"; -const Sacute$1 = "Ś"; -const Sc$1 = "⪼"; -const Scaron$1 = "Š"; -const Scedil$1 = "Ş"; -const Scirc$1 = "Ŝ"; -const Scy$1 = "С"; -const Sfr$1 = "𝔖"; -const ShortDownArrow$1 = "↓"; -const ShortLeftArrow$1 = "←"; -const ShortRightArrow$1 = "→"; -const ShortUpArrow$1 = "↑"; -const Sigma$1 = "Σ"; -const SmallCircle$1 = "∘"; -const Sopf$1 = "𝕊"; -const Sqrt$1 = "√"; -const Square$1 = "□"; -const SquareIntersection$1 = "⊓"; -const SquareSubset$1 = "⊏"; -const SquareSubsetEqual$1 = "⊑"; -const SquareSuperset$1 = "⊐"; -const SquareSupersetEqual$1 = "⊒"; -const SquareUnion$1 = "⊔"; -const Sscr$1 = "𝒮"; -const Star$1 = "⋆"; -const Sub$1 = "⋐"; -const Subset$1 = "⋐"; -const SubsetEqual$1 = "⊆"; -const Succeeds$1 = "≻"; -const SucceedsEqual$1 = "⪰"; -const SucceedsSlantEqual$1 = "≽"; -const SucceedsTilde$1 = "≿"; -const SuchThat$1 = "∋"; -const Sum$1 = "∑"; -const Sup$1 = "⋑"; -const Superset$1 = "⊃"; -const SupersetEqual$1 = "⊇"; -const Supset$1 = "⋑"; -const THOR$1 = "Þ"; -const THORN$1 = "Þ"; -const TRADE$1 = "™"; -const TSHcy$1 = "Ћ"; -const TScy$1 = "Ц"; -const Tab$1 = "\t"; -const Tau$1 = "Τ"; -const Tcaron$1 = "Ť"; -const Tcedil$1 = "Ţ"; -const Tcy$1 = "Т"; -const Tfr$1 = "𝔗"; -const Therefore$1 = "∴"; -const Theta$1 = "Θ"; -const ThickSpace$1 = "  "; -const ThinSpace$1 = " "; -const Tilde$1 = "∼"; -const TildeEqual$1 = "≃"; -const TildeFullEqual$1 = "≅"; -const TildeTilde$1 = "≈"; -const Topf$1 = "𝕋"; -const TripleDot$1 = "⃛"; -const Tscr$1 = "𝒯"; -const Tstrok$1 = "Ŧ"; -const Uacut$1 = "Ú"; -const Uacute$1 = "Ú"; -const Uarr$1 = "↟"; -const Uarrocir$1 = "⥉"; -const Ubrcy$1 = "Ў"; -const Ubreve$1 = "Ŭ"; -const Ucir$1 = "Û"; -const Ucirc$1 = "Û"; -const Ucy$1 = "У"; -const Udblac$1 = "Ű"; -const Ufr$1 = "𝔘"; -const Ugrav$1 = "Ù"; -const Ugrave$1 = "Ù"; -const Umacr$1 = "Ū"; -const UnderBar$1 = "_"; -const UnderBrace$1 = "⏟"; -const UnderBracket$1 = "⎵"; -const UnderParenthesis$1 = "⏝"; -const Union$1 = "⋃"; -const UnionPlus$1 = "⊎"; -const Uogon$1 = "Ų"; -const Uopf$1 = "𝕌"; -const UpArrow$1 = "↑"; -const UpArrowBar$1 = "⤒"; -const UpArrowDownArrow$1 = "⇅"; -const UpDownArrow$1 = "↕"; -const UpEquilibrium$1 = "⥮"; -const UpTee$1 = "⊥"; -const UpTeeArrow$1 = "↥"; -const Uparrow$1 = "⇑"; -const Updownarrow$1 = "⇕"; -const UpperLeftArrow$1 = "↖"; -const UpperRightArrow$1 = "↗"; -const Upsi$1 = "ϒ"; -const Upsilon$1 = "Υ"; -const Uring$1 = "Ů"; -const Uscr$1 = "𝒰"; -const Utilde$1 = "Ũ"; -const Uum$1 = "Ü"; -const Uuml$1 = "Ü"; -const VDash$1 = "⊫"; -const Vbar$1 = "⫫"; -const Vcy$1 = "В"; -const Vdash$1 = "⊩"; -const Vdashl$1 = "⫦"; -const Vee$1 = "⋁"; -const Verbar$1 = "‖"; -const Vert$1 = "‖"; -const VerticalBar$1 = "∣"; -const VerticalLine$1 = "|"; -const VerticalSeparator$1 = "❘"; -const VerticalTilde$1 = "≀"; -const VeryThinSpace$1 = " "; -const Vfr$1 = "𝔙"; -const Vopf$1 = "𝕍"; -const Vscr$1 = "𝒱"; -const Vvdash$1 = "⊪"; -const Wcirc$1 = "Ŵ"; -const Wedge$1 = "⋀"; -const Wfr$1 = "𝔚"; -const Wopf$1 = "𝕎"; -const Wscr$1 = "𝒲"; -const Xfr$1 = "𝔛"; -const Xi$1 = "Ξ"; -const Xopf$1 = "𝕏"; -const Xscr$1 = "𝒳"; -const YAcy$1 = "Я"; -const YIcy$1 = "Ї"; -const YUcy$1 = "Ю"; -const Yacut$1 = "Ý"; -const Yacute$1 = "Ý"; -const Ycirc$1 = "Ŷ"; -const Ycy$1 = "Ы"; -const Yfr$1 = "𝔜"; -const Yopf$1 = "𝕐"; -const Yscr$1 = "𝒴"; -const Yuml$1 = "Ÿ"; -const ZHcy$1 = "Ж"; -const Zacute$1 = "Ź"; -const Zcaron$1 = "Ž"; -const Zcy$1 = "З"; -const Zdot$1 = "Ż"; -const ZeroWidthSpace$1 = "​"; -const Zeta$1 = "Ζ"; -const Zfr$1 = "ℨ"; -const Zopf$1 = "ℤ"; -const Zscr$1 = "𝒵"; -const aacut$1 = "á"; -const aacute$1 = "á"; -const abreve$1 = "ă"; -const ac$1 = "∾"; -const acE$1 = "∾̳"; -const acd$1 = "∿"; -const acir$1 = "â"; -const acirc$1 = "â"; -const acut$1 = "´"; -const acute$1 = "´"; -const acy$1 = "а"; -const aeli$1 = "æ"; -const aelig$1 = "æ"; -const af$1 = "⁡"; -const afr$1 = "𝔞"; -const agrav$1 = "à"; -const agrave$1 = "à"; -const alefsym$1 = "ℵ"; -const aleph$1 = "ℵ"; -const alpha$1 = "α"; -const amacr$1 = "ā"; -const amalg$1 = "⨿"; -const am$1 = "&"; -const amp$1 = "&"; -const and$1 = "∧"; -const andand$1 = "⩕"; -const andd$1 = "⩜"; -const andslope$1 = "⩘"; -const andv$1 = "⩚"; -const ang$1 = "∠"; -const ange$1 = "⦤"; -const angle$1 = "∠"; -const angmsd$1 = "∡"; -const angmsdaa$1 = "⦨"; -const angmsdab$1 = "⦩"; -const angmsdac$1 = "⦪"; -const angmsdad$1 = "⦫"; -const angmsdae$1 = "⦬"; -const angmsdaf$1 = "⦭"; -const angmsdag$1 = "⦮"; -const angmsdah$1 = "⦯"; -const angrt$1 = "∟"; -const angrtvb$1 = "⊾"; -const angrtvbd$1 = "⦝"; -const angsph$1 = "∢"; -const angst$1 = "Å"; -const angzarr$1 = "⍼"; -const aogon$1 = "ą"; -const aopf$1 = "𝕒"; -const ap$1 = "≈"; -const apE$1 = "⩰"; -const apacir$1 = "⩯"; -const ape$1 = "≊"; -const apid$1 = "≋"; -const apos$1 = "'"; -const approx$1 = "≈"; -const approxeq$1 = "≊"; -const arin$1 = "å"; -const aring$1 = "å"; -const ascr$1 = "𝒶"; -const ast$1 = "*"; -const asymp$1 = "≈"; -const asympeq$1 = "≍"; -const atild$1 = "ã"; -const atilde$1 = "ã"; -const aum$1 = "ä"; -const auml$1 = "ä"; -const awconint$1 = "∳"; -const awint$1 = "⨑"; -const bNot$1 = "⫭"; -const backcong$1 = "≌"; -const backepsilon$1 = "϶"; -const backprime$1 = "‵"; -const backsim$1 = "∽"; -const backsimeq$1 = "⋍"; -const barvee$1 = "⊽"; -const barwed$1 = "⌅"; -const barwedge$1 = "⌅"; -const bbrk$1 = "⎵"; -const bbrktbrk$1 = "⎶"; -const bcong$1 = "≌"; -const bcy$1 = "б"; -const bdquo$1 = "„"; -const becaus$1 = "∵"; -const because$1 = "∵"; -const bemptyv$1 = "⦰"; -const bepsi$1 = "϶"; -const bernou$1 = "ℬ"; -const beta$1 = "β"; -const beth$1 = "ℶ"; -const between$1 = "≬"; -const bfr$1 = "𝔟"; -const bigcap$1 = "⋂"; -const bigcirc$1 = "◯"; -const bigcup$1 = "⋃"; -const bigodot$1 = "⨀"; -const bigoplus$1 = "⨁"; -const bigotimes$1 = "⨂"; -const bigsqcup$1 = "⨆"; -const bigstar$1 = "★"; -const bigtriangledown$1 = "▽"; -const bigtriangleup$1 = "△"; -const biguplus$1 = "⨄"; -const bigvee$1 = "⋁"; -const bigwedge$1 = "⋀"; -const bkarow$1 = "⤍"; -const blacklozenge$1 = "⧫"; -const blacksquare$1 = "▪"; -const blacktriangle$1 = "▴"; -const blacktriangledown$1 = "▾"; -const blacktriangleleft$1 = "◂"; -const blacktriangleright$1 = "▸"; -const blank$1 = "␣"; -const blk12$1 = "▒"; -const blk14$1 = "░"; -const blk34$1 = "▓"; -const block$1 = "█"; -const bne$1 = "=⃥"; -const bnequiv$1 = "≡⃥"; -const bnot$1 = "⌐"; -const bopf$1 = "𝕓"; -const bot$1 = "⊥"; -const bottom$1 = "⊥"; -const bowtie$1 = "⋈"; -const boxDL$1 = "╗"; -const boxDR$1 = "╔"; -const boxDl$1 = "╖"; -const boxDr$1 = "╓"; -const boxH$1 = "═"; -const boxHD$1 = "╦"; -const boxHU$1 = "╩"; -const boxHd$1 = "╤"; -const boxHu$1 = "╧"; -const boxUL$1 = "╝"; -const boxUR$1 = "╚"; -const boxUl$1 = "╜"; -const boxUr$1 = "╙"; -const boxV$1 = "║"; -const boxVH$1 = "╬"; -const boxVL$1 = "╣"; -const boxVR$1 = "╠"; -const boxVh$1 = "╫"; -const boxVl$1 = "╢"; -const boxVr$1 = "╟"; -const boxbox$1 = "⧉"; -const boxdL$1 = "╕"; -const boxdR$1 = "╒"; -const boxdl$1 = "┐"; -const boxdr$1 = "┌"; -const boxh$1 = "─"; -const boxhD$1 = "╥"; -const boxhU$1 = "╨"; -const boxhd$1 = "┬"; -const boxhu$1 = "┴"; -const boxminus$1 = "⊟"; -const boxplus$1 = "⊞"; -const boxtimes$1 = "⊠"; -const boxuL$1 = "╛"; -const boxuR$1 = "╘"; -const boxul$1 = "┘"; -const boxur$1 = "└"; -const boxv$1 = "│"; -const boxvH$1 = "╪"; -const boxvL$1 = "╡"; -const boxvR$1 = "╞"; -const boxvh$1 = "┼"; -const boxvl$1 = "┤"; -const boxvr$1 = "├"; -const bprime$1 = "‵"; -const breve$1 = "˘"; -const brvba$1 = "¦"; -const brvbar$1 = "¦"; -const bscr$1 = "𝒷"; -const bsemi$1 = "⁏"; -const bsim$1 = "∽"; -const bsime$1 = "⋍"; -const bsol$1 = "\\"; -const bsolb$1 = "⧅"; -const bsolhsub$1 = "⟈"; -const bull$1 = "•"; -const bullet$1 = "•"; -const bump$1 = "≎"; -const bumpE$1 = "⪮"; -const bumpe$1 = "≏"; -const bumpeq$1 = "≏"; -const cacute$1 = "ć"; -const cap$1 = "∩"; -const capand$1 = "⩄"; -const capbrcup$1 = "⩉"; -const capcap$1 = "⩋"; -const capcup$1 = "⩇"; -const capdot$1 = "⩀"; -const caps$1 = "∩︀"; -const caret$1 = "⁁"; -const caron$1 = "ˇ"; -const ccaps$1 = "⩍"; -const ccaron$1 = "č"; -const ccedi$1 = "ç"; -const ccedil$1 = "ç"; -const ccirc$1 = "ĉ"; -const ccups$1 = "⩌"; -const ccupssm$1 = "⩐"; -const cdot$1 = "ċ"; -const cedi$1 = "¸"; -const cedil$1 = "¸"; -const cemptyv$1 = "⦲"; -const cen$1 = "¢"; -const cent$1 = "¢"; -const centerdot$1 = "·"; -const cfr$1 = "𝔠"; -const chcy$1 = "ч"; -const check$2 = "✓"; -const checkmark$1 = "✓"; -const chi$1 = "χ"; -const cir$1 = "○"; -const cirE$1 = "⧃"; -const circ$1 = "ˆ"; -const circeq$1 = "≗"; -const circlearrowleft$1 = "↺"; -const circlearrowright$1 = "↻"; -const circledR$1 = "®"; -const circledS$1 = "Ⓢ"; -const circledast$1 = "⊛"; -const circledcirc$1 = "⊚"; -const circleddash$1 = "⊝"; -const cire$1 = "≗"; -const cirfnint$1 = "⨐"; -const cirmid$1 = "⫯"; -const cirscir$1 = "⧂"; -const clubs$1 = "♣"; -const clubsuit$1 = "♣"; -const colon$1 = ":"; -const colone$1 = "≔"; -const coloneq$1 = "≔"; -const comma$1 = ","; -const commat$1 = "@"; -const comp$1 = "∁"; -const compfn$1 = "∘"; -const complement$1 = "∁"; -const complexes$1 = "ℂ"; -const cong$1 = "≅"; -const congdot$1 = "⩭"; -const conint$1 = "∮"; -const copf$1 = "𝕔"; -const coprod$1 = "∐"; -const cop$1 = "©"; -const copy$1 = "©"; -const copysr$1 = "℗"; -const crarr$1 = "↵"; -const cross$1 = "✗"; -const cscr$1 = "𝒸"; -const csub$1 = "⫏"; -const csube$1 = "⫑"; -const csup$1 = "⫐"; -const csupe$1 = "⫒"; -const ctdot$1 = "⋯"; -const cudarrl$1 = "⤸"; -const cudarrr$1 = "⤵"; -const cuepr$1 = "⋞"; -const cuesc$1 = "⋟"; -const cularr$1 = "↶"; -const cularrp$1 = "⤽"; -const cup$1 = "∪"; -const cupbrcap$1 = "⩈"; -const cupcap$1 = "⩆"; -const cupcup$1 = "⩊"; -const cupdot$1 = "⊍"; -const cupor$1 = "⩅"; -const cups$1 = "∪︀"; -const curarr$1 = "↷"; -const curarrm$1 = "⤼"; -const curlyeqprec$1 = "⋞"; -const curlyeqsucc$1 = "⋟"; -const curlyvee$1 = "⋎"; -const curlywedge$1 = "⋏"; -const curre$1 = "¤"; -const curren$1 = "¤"; -const curvearrowleft$1 = "↶"; -const curvearrowright$1 = "↷"; -const cuvee$1 = "⋎"; -const cuwed$1 = "⋏"; -const cwconint$1 = "∲"; -const cwint$1 = "∱"; -const cylcty$1 = "⌭"; -const dArr$1 = "⇓"; -const dHar$1 = "⥥"; -const dagger$1 = "†"; -const daleth$1 = "ℸ"; -const darr$1 = "↓"; -const dash$1 = "‐"; -const dashv$1 = "⊣"; -const dbkarow$1 = "⤏"; -const dblac$1 = "˝"; -const dcaron$1 = "ď"; -const dcy$1 = "д"; -const dd$1 = "ⅆ"; -const ddagger$1 = "‡"; -const ddarr$1 = "⇊"; -const ddotseq$1 = "⩷"; -const de$1 = "°"; -const deg$1 = "°"; -const delta$1 = "δ"; -const demptyv$1 = "⦱"; -const dfisht$1 = "⥿"; -const dfr$1 = "𝔡"; -const dharl$1 = "⇃"; -const dharr$1 = "⇂"; -const diam$1 = "⋄"; -const diamond$1 = "⋄"; -const diamondsuit$1 = "♦"; -const diams$1 = "♦"; -const die$1 = "¨"; -const digamma$1 = "ϝ"; -const disin$1 = "⋲"; -const div$1 = "÷"; -const divid$1 = "÷"; -const divide$1 = "÷"; -const divideontimes$1 = "⋇"; -const divonx$1 = "⋇"; -const djcy$1 = "ђ"; -const dlcorn$1 = "⌞"; -const dlcrop$1 = "⌍"; -const dollar$1 = "$"; -const dopf$1 = "𝕕"; -const dot$1 = "˙"; -const doteq$1 = "≐"; -const doteqdot$1 = "≑"; -const dotminus$1 = "∸"; -const dotplus$1 = "∔"; -const dotsquare$1 = "⊡"; -const doublebarwedge$1 = "⌆"; -const downarrow$1 = "↓"; -const downdownarrows$1 = "⇊"; -const downharpoonleft$1 = "⇃"; -const downharpoonright$1 = "⇂"; -const drbkarow$1 = "⤐"; -const drcorn$1 = "⌟"; -const drcrop$1 = "⌌"; -const dscr$1 = "𝒹"; -const dscy$1 = "ѕ"; -const dsol$1 = "⧶"; -const dstrok$1 = "đ"; -const dtdot$1 = "⋱"; -const dtri$1 = "▿"; -const dtrif$1 = "▾"; -const duarr$1 = "⇵"; -const duhar$1 = "⥯"; -const dwangle$1 = "⦦"; -const dzcy$1 = "џ"; -const dzigrarr$1 = "⟿"; -const eDDot$1 = "⩷"; -const eDot$1 = "≑"; -const eacut$1 = "é"; -const eacute$1 = "é"; -const easter$1 = "⩮"; -const ecaron$1 = "ě"; -const ecir$1 = "ê"; -const ecirc$1 = "ê"; -const ecolon$1 = "≕"; -const ecy$1 = "э"; -const edot$1 = "ė"; -const ee$1 = "ⅇ"; -const efDot$1 = "≒"; -const efr$1 = "𝔢"; -const eg$1 = "⪚"; -const egrav$1 = "è"; -const egrave$1 = "è"; -const egs$1 = "⪖"; -const egsdot$1 = "⪘"; -const el$1 = "⪙"; -const elinters$1 = "⏧"; -const ell$1 = "ℓ"; -const els$1 = "⪕"; -const elsdot$1 = "⪗"; -const emacr$1 = "ē"; -const empty$1 = "∅"; -const emptyset$1 = "∅"; -const emptyv$1 = "∅"; -const emsp13$1 = " "; -const emsp14$1 = " "; -const emsp$1 = " "; -const eng$1 = "ŋ"; -const ensp$1 = " "; -const eogon$1 = "ę"; -const eopf$1 = "𝕖"; -const epar$1 = "⋕"; -const eparsl$1 = "⧣"; -const eplus$1 = "⩱"; -const epsi$1 = "ε"; -const epsilon$1 = "ε"; -const epsiv$1 = "ϵ"; -const eqcirc$1 = "≖"; -const eqcolon$1 = "≕"; -const eqsim$1 = "≂"; -const eqslantgtr$1 = "⪖"; -const eqslantless$1 = "⪕"; -const equals$1 = "="; -const equest$1 = "≟"; -const equiv$1 = "≡"; -const equivDD$1 = "⩸"; -const eqvparsl$1 = "⧥"; -const erDot$1 = "≓"; -const erarr$1 = "⥱"; -const escr$1 = "ℯ"; -const esdot$1 = "≐"; -const esim$1 = "≂"; -const eta$1 = "η"; -const et$1 = "ð"; -const eth$1 = "ð"; -const eum$1 = "ë"; -const euml$1 = "ë"; -const euro$1 = "€"; -const excl$1 = "!"; -const exist$1 = "∃"; -const expectation$1 = "ℰ"; -const exponentiale$1 = "ⅇ"; -const fallingdotseq$1 = "≒"; -const fcy$1 = "ф"; -const female$1 = "♀"; -const ffilig$1 = "ffi"; -const fflig$1 = "ff"; -const ffllig$1 = "ffl"; -const ffr$1 = "𝔣"; -const filig$1 = "fi"; -const fjlig$1 = "fj"; -const flat$1 = "♭"; -const fllig$1 = "fl"; -const fltns$1 = "▱"; -const fnof$1 = "ƒ"; -const fopf$1 = "𝕗"; -const forall$1 = "∀"; -const fork$1 = "⋔"; -const forkv$1 = "⫙"; -const fpartint$1 = "⨍"; -const frac1$1 = "¼"; -const frac12$1 = "½"; -const frac13$1 = "⅓"; -const frac14$1 = "¼"; -const frac15$1 = "⅕"; -const frac16$1 = "⅙"; -const frac18$1 = "⅛"; -const frac23$1 = "⅔"; -const frac25$1 = "⅖"; -const frac3$1 = "¾"; -const frac34$1 = "¾"; -const frac35$1 = "⅗"; -const frac38$1 = "⅜"; -const frac45$1 = "⅘"; -const frac56$1 = "⅚"; -const frac58$1 = "⅝"; -const frac78$1 = "⅞"; -const frasl$1 = "⁄"; -const frown$1 = "⌢"; -const fscr$1 = "𝒻"; -const gE$1 = "≧"; -const gEl$1 = "⪌"; -const gacute$1 = "ǵ"; -const gamma$1 = "γ"; -const gammad$1 = "ϝ"; -const gap$1 = "⪆"; -const gbreve$1 = "ğ"; -const gcirc$1 = "ĝ"; -const gcy$1 = "г"; -const gdot$1 = "ġ"; -const ge$1 = "≥"; -const gel$1 = "⋛"; -const geq$1 = "≥"; -const geqq$1 = "≧"; -const geqslant$1 = "⩾"; -const ges$1 = "⩾"; -const gescc$1 = "⪩"; -const gesdot$1 = "⪀"; -const gesdoto$1 = "⪂"; -const gesdotol$1 = "⪄"; -const gesl$1 = "⋛︀"; -const gesles$1 = "⪔"; -const gfr$1 = "𝔤"; -const gg$1 = "≫"; -const ggg$1 = "⋙"; -const gimel$1 = "ℷ"; -const gjcy$1 = "ѓ"; -const gl$1 = "≷"; -const glE$1 = "⪒"; -const gla$1 = "⪥"; -const glj$1 = "⪤"; -const gnE$1 = "≩"; -const gnap$1 = "⪊"; -const gnapprox$1 = "⪊"; -const gne$1 = "⪈"; -const gneq$1 = "⪈"; -const gneqq$1 = "≩"; -const gnsim$1 = "⋧"; -const gopf$1 = "𝕘"; -const grave$1 = "`"; -const gscr$1 = "ℊ"; -const gsim$1 = "≳"; -const gsime$1 = "⪎"; -const gsiml$1 = "⪐"; -const g$1 = ">"; -const gt$1 = ">"; -const gtcc$1 = "⪧"; -const gtcir$1 = "⩺"; -const gtdot$1 = "⋗"; -const gtlPar$1 = "⦕"; -const gtquest$1 = "⩼"; -const gtrapprox$1 = "⪆"; -const gtrarr$1 = "⥸"; -const gtrdot$1 = "⋗"; -const gtreqless$1 = "⋛"; -const gtreqqless$1 = "⪌"; -const gtrless$1 = "≷"; -const gtrsim$1 = "≳"; -const gvertneqq$1 = "≩︀"; -const gvnE$1 = "≩︀"; -const hArr$1 = "⇔"; -const hairsp$1 = " "; -const half$1 = "½"; -const hamilt$1 = "ℋ"; -const hardcy$1 = "ъ"; -const harr$1 = "↔"; -const harrcir$1 = "⥈"; -const harrw$1 = "↭"; -const hbar$1 = "ℏ"; -const hcirc$1 = "ĥ"; -const hearts$1 = "♥"; -const heartsuit$1 = "♥"; -const hellip$1 = "…"; -const hercon$1 = "⊹"; -const hfr$1 = "𝔥"; -const hksearow$1 = "⤥"; -const hkswarow$1 = "⤦"; -const hoarr$1 = "⇿"; -const homtht$1 = "∻"; -const hookleftarrow$1 = "↩"; -const hookrightarrow$1 = "↪"; -const hopf$1 = "𝕙"; -const horbar$1 = "―"; -const hscr$1 = "𝒽"; -const hslash$1 = "ℏ"; -const hstrok$1 = "ħ"; -const hybull$1 = "⁃"; -const hyphen$1 = "‐"; -const iacut$1 = "í"; -const iacute$1 = "í"; -const ic$1 = "⁣"; -const icir$1 = "î"; -const icirc$1 = "î"; -const icy$1 = "и"; -const iecy$1 = "е"; -const iexc$1 = "¡"; -const iexcl$1 = "¡"; -const iff$1 = "⇔"; -const ifr$1 = "𝔦"; -const igrav$1 = "ì"; -const igrave$1 = "ì"; -const ii$1 = "ⅈ"; -const iiiint$1 = "⨌"; -const iiint$1 = "∭"; -const iinfin$1 = "⧜"; -const iiota$1 = "℩"; -const ijlig$1 = "ij"; -const imacr$1 = "ī"; -const image$2 = "ℑ"; -const imagline$1 = "ℐ"; -const imagpart$1 = "ℑ"; -const imath$1 = "ı"; -const imof$1 = "⊷"; -const imped$1 = "Ƶ"; -const incare$1 = "℅"; -const infin$1 = "∞"; -const infintie$1 = "⧝"; -const inodot$1 = "ı"; -const int$2 = "∫"; -const intcal$1 = "⊺"; -const integers$1 = "ℤ"; -const intercal$1 = "⊺"; -const intlarhk$1 = "⨗"; -const intprod$1 = "⨼"; -const iocy$1 = "ё"; -const iogon$1 = "į"; -const iopf$1 = "𝕚"; -const iota$1 = "ι"; -const iprod$1 = "⨼"; -const iques$1 = "¿"; -const iquest$1 = "¿"; -const iscr$1 = "𝒾"; -const isin$1 = "∈"; -const isinE$1 = "⋹"; -const isindot$1 = "⋵"; -const isins$1 = "⋴"; -const isinsv$1 = "⋳"; -const isinv$1 = "∈"; -const it$1 = "⁢"; -const itilde$1 = "ĩ"; -const iukcy$1 = "і"; -const ium$1 = "ï"; -const iuml$1 = "ï"; -const jcirc$1 = "ĵ"; -const jcy$1 = "й"; -const jfr$1 = "𝔧"; -const jmath$1 = "ȷ"; -const jopf$1 = "𝕛"; -const jscr$1 = "𝒿"; -const jsercy$1 = "ј"; -const jukcy$1 = "є"; -const kappa$1 = "κ"; -const kappav$1 = "ϰ"; -const kcedil$1 = "ķ"; -const kcy$1 = "к"; -const kfr$1 = "𝔨"; -const kgreen$1 = "ĸ"; -const khcy$1 = "х"; -const kjcy$1 = "ќ"; -const kopf$1 = "𝕜"; -const kscr$1 = "𝓀"; -const lAarr$1 = "⇚"; -const lArr$1 = "⇐"; -const lAtail$1 = "⤛"; -const lBarr$1 = "⤎"; -const lE$1 = "≦"; -const lEg$1 = "⪋"; -const lHar$1 = "⥢"; -const lacute$1 = "ĺ"; -const laemptyv$1 = "⦴"; -const lagran$1 = "ℒ"; -const lambda$1 = "λ"; -const lang$1 = "⟨"; -const langd$1 = "⦑"; -const langle$1 = "⟨"; -const lap$1 = "⪅"; -const laqu$1 = "«"; -const laquo$1 = "«"; -const larr$1 = "←"; -const larrb$1 = "⇤"; -const larrbfs$1 = "⤟"; -const larrfs$1 = "⤝"; -const larrhk$1 = "↩"; -const larrlp$1 = "↫"; -const larrpl$1 = "⤹"; -const larrsim$1 = "⥳"; -const larrtl$1 = "↢"; -const lat$1 = "⪫"; -const latail$1 = "⤙"; -const late$1 = "⪭"; -const lates$1 = "⪭︀"; -const lbarr$1 = "⤌"; -const lbbrk$1 = "❲"; -const lbrace$1 = "{"; -const lbrack$1 = "["; -const lbrke$1 = "⦋"; -const lbrksld$1 = "⦏"; -const lbrkslu$1 = "⦍"; -const lcaron$1 = "ľ"; -const lcedil$1 = "ļ"; -const lceil$1 = "⌈"; -const lcub$1 = "{"; -const lcy$1 = "л"; -const ldca$1 = "⤶"; -const ldquo$1 = "“"; -const ldquor$1 = "„"; -const ldrdhar$1 = "⥧"; -const ldrushar$1 = "⥋"; -const ldsh$1 = "↲"; -const le$1 = "≤"; -const leftarrow$1 = "←"; -const leftarrowtail$1 = "↢"; -const leftharpoondown$1 = "↽"; -const leftharpoonup$1 = "↼"; -const leftleftarrows$1 = "⇇"; -const leftrightarrow$1 = "↔"; -const leftrightarrows$1 = "⇆"; -const leftrightharpoons$1 = "⇋"; -const leftrightsquigarrow$1 = "↭"; -const leftthreetimes$1 = "⋋"; -const leg$1 = "⋚"; -const leq$1 = "≤"; -const leqq$1 = "≦"; -const leqslant$1 = "⩽"; -const les$1 = "⩽"; -const lescc$1 = "⪨"; -const lesdot$1 = "⩿"; -const lesdoto$1 = "⪁"; -const lesdotor$1 = "⪃"; -const lesg$1 = "⋚︀"; -const lesges$1 = "⪓"; -const lessapprox$1 = "⪅"; -const lessdot$1 = "⋖"; -const lesseqgtr$1 = "⋚"; -const lesseqqgtr$1 = "⪋"; -const lessgtr$1 = "≶"; -const lesssim$1 = "≲"; -const lfisht$1 = "⥼"; -const lfloor$1 = "⌊"; -const lfr$1 = "𝔩"; -const lg$1 = "≶"; -const lgE$1 = "⪑"; -const lhard$1 = "↽"; -const lharu$1 = "↼"; -const lharul$1 = "⥪"; -const lhblk$1 = "▄"; -const ljcy$1 = "љ"; -const ll$1 = "≪"; -const llarr$1 = "⇇"; -const llcorner$1 = "⌞"; -const llhard$1 = "⥫"; -const lltri$1 = "◺"; -const lmidot$1 = "ŀ"; -const lmoust$1 = "⎰"; -const lmoustache$1 = "⎰"; -const lnE$1 = "≨"; -const lnap$1 = "⪉"; -const lnapprox$1 = "⪉"; -const lne$1 = "⪇"; -const lneq$1 = "⪇"; -const lneqq$1 = "≨"; -const lnsim$1 = "⋦"; -const loang$1 = "⟬"; -const loarr$1 = "⇽"; -const lobrk$1 = "⟦"; -const longleftarrow$1 = "⟵"; -const longleftrightarrow$1 = "⟷"; -const longmapsto$1 = "⟼"; -const longrightarrow$1 = "⟶"; -const looparrowleft$1 = "↫"; -const looparrowright$1 = "↬"; -const lopar$1 = "⦅"; -const lopf$1 = "𝕝"; -const loplus$1 = "⨭"; -const lotimes$1 = "⨴"; -const lowast$1 = "∗"; -const lowbar$1 = "_"; -const loz$1 = "◊"; -const lozenge$1 = "◊"; -const lozf$1 = "⧫"; -const lpar$1 = "("; -const lparlt$1 = "⦓"; -const lrarr$1 = "⇆"; -const lrcorner$1 = "⌟"; -const lrhar$1 = "⇋"; -const lrhard$1 = "⥭"; -const lrm$1 = "‎"; -const lrtri$1 = "⊿"; -const lsaquo$1 = "‹"; -const lscr$1 = "𝓁"; -const lsh$1 = "↰"; -const lsim$1 = "≲"; -const lsime$1 = "⪍"; -const lsimg$1 = "⪏"; -const lsqb$1 = "["; -const lsquo$1 = "‘"; -const lsquor$1 = "‚"; -const lstrok$1 = "ł"; -const l$1 = "<"; -const lt$2 = "<"; -const ltcc$1 = "⪦"; -const ltcir$1 = "⩹"; -const ltdot$1 = "⋖"; -const lthree$1 = "⋋"; -const ltimes$1 = "⋉"; -const ltlarr$1 = "⥶"; -const ltquest$1 = "⩻"; -const ltrPar$1 = "⦖"; -const ltri$1 = "◃"; -const ltrie$1 = "⊴"; -const ltrif$1 = "◂"; -const lurdshar$1 = "⥊"; -const luruhar$1 = "⥦"; -const lvertneqq$1 = "≨︀"; -const lvnE$1 = "≨︀"; -const mDDot$1 = "∺"; -const mac$1 = "¯"; -const macr$1 = "¯"; -const male$1 = "♂"; -const malt$1 = "✠"; -const maltese$1 = "✠"; -const map$4 = "↦"; -const mapsto$1 = "↦"; -const mapstodown$1 = "↧"; -const mapstoleft$1 = "↤"; -const mapstoup$1 = "↥"; -const marker$1 = "▮"; -const mcomma$1 = "⨩"; -const mcy$1 = "м"; -const mdash$1 = "—"; -const measuredangle$1 = "∡"; -const mfr$1 = "𝔪"; -const mho$1 = "℧"; -const micr$1 = "µ"; -const micro$1 = "µ"; -const mid$1 = "∣"; -const midast$1 = "*"; -const midcir$1 = "⫰"; -const middo$1 = "·"; -const middot$1 = "·"; -const minus$1 = "−"; -const minusb$1 = "⊟"; -const minusd$1 = "∸"; -const minusdu$1 = "⨪"; -const mlcp$1 = "⫛"; -const mldr$1 = "…"; -const mnplus$1 = "∓"; -const models$1 = "⊧"; -const mopf$1 = "𝕞"; -const mp$1 = "∓"; -const mscr$1 = "𝓂"; -const mstpos$1 = "∾"; -const mu$1 = "μ"; -const multimap$1 = "⊸"; -const mumap$1 = "⊸"; -const nGg$1 = "⋙̸"; -const nGt$1 = "≫⃒"; -const nGtv$1 = "≫̸"; -const nLeftarrow$1 = "⇍"; -const nLeftrightarrow$1 = "⇎"; -const nLl$1 = "⋘̸"; -const nLt$1 = "≪⃒"; -const nLtv$1 = "≪̸"; -const nRightarrow$1 = "⇏"; -const nVDash$1 = "⊯"; -const nVdash$1 = "⊮"; -const nabla$1 = "∇"; -const nacute$1 = "ń"; -const nang$1 = "∠⃒"; -const nap$1 = "≉"; -const napE$1 = "⩰̸"; -const napid$1 = "≋̸"; -const napos$1 = "ʼn"; -const napprox$1 = "≉"; -const natur$1 = "♮"; -const natural$1 = "♮"; -const naturals$1 = "ℕ"; -const nbs$1 = " "; -const nbsp$1 = " "; -const nbump$1 = "≎̸"; -const nbumpe$1 = "≏̸"; -const ncap$1 = "⩃"; -const ncaron$1 = "ň"; -const ncedil$1 = "ņ"; -const ncong$1 = "≇"; -const ncongdot$1 = "⩭̸"; -const ncup$1 = "⩂"; -const ncy$1 = "н"; -const ndash$1 = "–"; -const ne$1 = "≠"; -const neArr$1 = "⇗"; -const nearhk$1 = "⤤"; -const nearr$1 = "↗"; -const nearrow$1 = "↗"; -const nedot$1 = "≐̸"; -const nequiv$1 = "≢"; -const nesear$1 = "⤨"; -const nesim$1 = "≂̸"; -const nexist$1 = "∄"; -const nexists$1 = "∄"; -const nfr$1 = "𝔫"; -const ngE$1 = "≧̸"; -const nge$1 = "≱"; -const ngeq$1 = "≱"; -const ngeqq$1 = "≧̸"; -const ngeqslant$1 = "⩾̸"; -const nges$1 = "⩾̸"; -const ngsim$1 = "≵"; -const ngt$1 = "≯"; -const ngtr$1 = "≯"; -const nhArr$1 = "⇎"; -const nharr$1 = "↮"; -const nhpar$1 = "⫲"; -const ni$1 = "∋"; -const nis$1 = "⋼"; -const nisd$1 = "⋺"; -const niv$1 = "∋"; -const njcy$1 = "њ"; -const nlArr$1 = "⇍"; -const nlE$1 = "≦̸"; -const nlarr$1 = "↚"; -const nldr$1 = "‥"; -const nle$1 = "≰"; -const nleftarrow$1 = "↚"; -const nleftrightarrow$1 = "↮"; -const nleq$1 = "≰"; -const nleqq$1 = "≦̸"; -const nleqslant$1 = "⩽̸"; -const nles$1 = "⩽̸"; -const nless$1 = "≮"; -const nlsim$1 = "≴"; -const nlt$1 = "≮"; -const nltri$1 = "⋪"; -const nltrie$1 = "⋬"; -const nmid$1 = "∤"; -const nopf$1 = "𝕟"; -const no$1 = "¬"; -const not$1 = "¬"; -const notin$1 = "∉"; -const notinE$1 = "⋹̸"; -const notindot$1 = "⋵̸"; -const notinva$1 = "∉"; -const notinvb$1 = "⋷"; -const notinvc$1 = "⋶"; -const notni$1 = "∌"; -const notniva$1 = "∌"; -const notnivb$1 = "⋾"; -const notnivc$1 = "⋽"; -const npar$1 = "∦"; -const nparallel$1 = "∦"; -const nparsl$1 = "⫽⃥"; -const npart$1 = "∂̸"; -const npolint$1 = "⨔"; -const npr$1 = "⊀"; -const nprcue$1 = "⋠"; -const npre$1 = "⪯̸"; -const nprec$1 = "⊀"; -const npreceq$1 = "⪯̸"; -const nrArr$1 = "⇏"; -const nrarr$1 = "↛"; -const nrarrc$1 = "⤳̸"; -const nrarrw$1 = "↝̸"; -const nrightarrow$1 = "↛"; -const nrtri$1 = "⋫"; -const nrtrie$1 = "⋭"; -const nsc$1 = "⊁"; -const nsccue$1 = "⋡"; -const nsce$1 = "⪰̸"; -const nscr$1 = "𝓃"; -const nshortmid$1 = "∤"; -const nshortparallel$1 = "∦"; -const nsim$1 = "≁"; -const nsime$1 = "≄"; -const nsimeq$1 = "≄"; -const nsmid$1 = "∤"; -const nspar$1 = "∦"; -const nsqsube$1 = "⋢"; -const nsqsupe$1 = "⋣"; -const nsub$1 = "⊄"; -const nsubE$1 = "⫅̸"; -const nsube$1 = "⊈"; -const nsubset$1 = "⊂⃒"; -const nsubseteq$1 = "⊈"; -const nsubseteqq$1 = "⫅̸"; -const nsucc$1 = "⊁"; -const nsucceq$1 = "⪰̸"; -const nsup$1 = "⊅"; -const nsupE$1 = "⫆̸"; -const nsupe$1 = "⊉"; -const nsupset$1 = "⊃⃒"; -const nsupseteq$1 = "⊉"; -const nsupseteqq$1 = "⫆̸"; -const ntgl$1 = "≹"; -const ntild$1 = "ñ"; -const ntilde$1 = "ñ"; -const ntlg$1 = "≸"; -const ntriangleleft$1 = "⋪"; -const ntrianglelefteq$1 = "⋬"; -const ntriangleright$1 = "⋫"; -const ntrianglerighteq$1 = "⋭"; -const nu$1 = "ν"; -const num$1 = "#"; -const numero$1 = "№"; -const numsp$1 = " "; -const nvDash$1 = "⊭"; -const nvHarr$1 = "⤄"; -const nvap$1 = "≍⃒"; -const nvdash$1 = "⊬"; -const nvge$1 = "≥⃒"; -const nvgt$1 = ">⃒"; -const nvinfin$1 = "⧞"; -const nvlArr$1 = "⤂"; -const nvle$1 = "≤⃒"; -const nvlt$1 = "<⃒"; -const nvltrie$1 = "⊴⃒"; -const nvrArr$1 = "⤃"; -const nvrtrie$1 = "⊵⃒"; -const nvsim$1 = "∼⃒"; -const nwArr$1 = "⇖"; -const nwarhk$1 = "⤣"; -const nwarr$1 = "↖"; -const nwarrow$1 = "↖"; -const nwnear$1 = "⤧"; -const oS$1 = "Ⓢ"; -const oacut$1 = "ó"; -const oacute$1 = "ó"; -const oast$1 = "⊛"; -const ocir$1 = "ô"; -const ocirc$1 = "ô"; -const ocy$1 = "о"; -const odash$1 = "⊝"; -const odblac$1 = "ő"; -const odiv$1 = "⨸"; -const odot$1 = "⊙"; -const odsold$1 = "⦼"; -const oelig$1 = "œ"; -const ofcir$1 = "⦿"; -const ofr$1 = "𝔬"; -const ogon$1 = "˛"; -const ograv$1 = "ò"; -const ograve$1 = "ò"; -const ogt$1 = "⧁"; -const ohbar$1 = "⦵"; -const ohm$1 = "Ω"; -const oint$1 = "∮"; -const olarr$1 = "↺"; -const olcir$1 = "⦾"; -const olcross$1 = "⦻"; -const oline$1 = "‾"; -const olt$1 = "⧀"; -const omacr$1 = "ō"; -const omega$1 = "ω"; -const omicron$1 = "ο"; -const omid$1 = "⦶"; -const ominus$1 = "⊖"; -const oopf$1 = "𝕠"; -const opar$1 = "⦷"; -const operp$1 = "⦹"; -const oplus$1 = "⊕"; -const or$1 = "∨"; -const orarr$1 = "↻"; -const ord$1 = "º"; -const order$1 = "ℴ"; -const orderof$1 = "ℴ"; -const ordf$1 = "ª"; -const ordm$1 = "º"; -const origof$1 = "⊶"; -const oror$1 = "⩖"; -const orslope$1 = "⩗"; -const orv$1 = "⩛"; -const oscr$1 = "ℴ"; -const oslas$1 = "ø"; -const oslash$1 = "ø"; -const osol$1 = "⊘"; -const otild$1 = "õ"; -const otilde$1 = "õ"; -const otimes$1 = "⊗"; -const otimesas$1 = "⨶"; -const oum$1 = "ö"; -const ouml$1 = "ö"; -const ovbar$1 = "⌽"; -const par$1 = "¶"; -const para$1 = "¶"; -const parallel$1 = "∥"; -const parsim$1 = "⫳"; -const parsl$1 = "⫽"; -const part$1 = "∂"; -const pcy$1 = "п"; -const percnt$1 = "%"; -const period$1 = "."; -const permil$1 = "‰"; -const perp$1 = "⊥"; -const pertenk$1 = "‱"; -const pfr$1 = "𝔭"; -const phi$1 = "φ"; -const phiv$1 = "ϕ"; -const phmmat$1 = "ℳ"; -const phone$1 = "☎"; -const pi$1 = "π"; -const pitchfork$1 = "⋔"; -const piv$1 = "ϖ"; -const planck$1 = "ℏ"; -const planckh$1 = "ℎ"; -const plankv$1 = "ℏ"; -const plus$1 = "+"; -const plusacir$1 = "⨣"; -const plusb$1 = "⊞"; -const pluscir$1 = "⨢"; -const plusdo$1 = "∔"; -const plusdu$1 = "⨥"; -const pluse$1 = "⩲"; -const plusm$1 = "±"; -const plusmn$1 = "±"; -const plussim$1 = "⨦"; -const plustwo$1 = "⨧"; -const pm$1 = "±"; -const pointint$1 = "⨕"; -const popf$1 = "𝕡"; -const poun$1 = "£"; -const pound$1 = "£"; -const pr$1 = "≺"; -const prE$1 = "⪳"; -const prap$1 = "⪷"; -const prcue$1 = "≼"; -const pre$1 = "⪯"; -const prec$1 = "≺"; -const precapprox$1 = "⪷"; -const preccurlyeq$1 = "≼"; -const preceq$1 = "⪯"; -const precnapprox$1 = "⪹"; -const precneqq$1 = "⪵"; -const precnsim$1 = "⋨"; -const precsim$1 = "≾"; -const prime$1 = "′"; -const primes$1 = "ℙ"; -const prnE$1 = "⪵"; -const prnap$1 = "⪹"; -const prnsim$1 = "⋨"; -const prod$1 = "∏"; -const profalar$1 = "⌮"; -const profline$1 = "⌒"; -const profsurf$1 = "⌓"; -const prop$1 = "∝"; -const propto$1 = "∝"; -const prsim$1 = "≾"; -const prurel$1 = "⊰"; -const pscr$1 = "𝓅"; -const psi$1 = "ψ"; -const puncsp$1 = " "; -const qfr$1 = "𝔮"; -const qint$1 = "⨌"; -const qopf$1 = "𝕢"; -const qprime$1 = "⁗"; -const qscr$1 = "𝓆"; -const quaternions$1 = "ℍ"; -const quatint$1 = "⨖"; -const quest$1 = "?"; -const questeq$1 = "≟"; -const quo$1 = "\""; -const quot$1 = "\""; -const rAarr$1 = "⇛"; -const rArr$1 = "⇒"; -const rAtail$1 = "⤜"; -const rBarr$1 = "⤏"; -const rHar$1 = "⥤"; -const race$1 = "∽̱"; -const racute$1 = "ŕ"; -const radic$1 = "√"; -const raemptyv$1 = "⦳"; -const rang$1 = "⟩"; -const rangd$1 = "⦒"; -const range$1 = "⦥"; -const rangle$1 = "⟩"; -const raqu$1 = "»"; -const raquo$1 = "»"; -const rarr$1 = "→"; -const rarrap$1 = "⥵"; -const rarrb$1 = "⇥"; -const rarrbfs$1 = "⤠"; -const rarrc$1 = "⤳"; -const rarrfs$1 = "⤞"; -const rarrhk$1 = "↪"; -const rarrlp$1 = "↬"; -const rarrpl$1 = "⥅"; -const rarrsim$1 = "⥴"; -const rarrtl$1 = "↣"; -const rarrw$1 = "↝"; -const ratail$1 = "⤚"; -const ratio$1 = "∶"; -const rationals$1 = "ℚ"; -const rbarr$1 = "⤍"; -const rbbrk$1 = "❳"; -const rbrace$1 = "}"; -const rbrack$1 = "]"; -const rbrke$1 = "⦌"; -const rbrksld$1 = "⦎"; -const rbrkslu$1 = "⦐"; -const rcaron$1 = "ř"; -const rcedil$1 = "ŗ"; -const rceil$1 = "⌉"; -const rcub$1 = "}"; -const rcy$1 = "р"; -const rdca$1 = "⤷"; -const rdldhar$1 = "⥩"; -const rdquo$1 = "”"; -const rdquor$1 = "”"; -const rdsh$1 = "↳"; -const real$1 = "ℜ"; -const realine$1 = "ℛ"; -const realpart$1 = "ℜ"; -const reals$1 = "ℝ"; -const rect$1 = "▭"; -const re$5 = "®"; -const reg$1 = "®"; -const rfisht$1 = "⥽"; -const rfloor$1 = "⌋"; -const rfr$1 = "𝔯"; -const rhard$1 = "⇁"; -const rharu$1 = "⇀"; -const rharul$1 = "⥬"; -const rho$1 = "ρ"; -const rhov$1 = "ϱ"; -const rightarrow$1 = "→"; -const rightarrowtail$1 = "↣"; -const rightharpoondown$1 = "⇁"; -const rightharpoonup$1 = "⇀"; -const rightleftarrows$1 = "⇄"; -const rightleftharpoons$1 = "⇌"; -const rightrightarrows$1 = "⇉"; -const rightsquigarrow$1 = "↝"; -const rightthreetimes$1 = "⋌"; -const ring$1 = "˚"; -const risingdotseq$1 = "≓"; -const rlarr$1 = "⇄"; -const rlhar$1 = "⇌"; -const rlm$1 = "‏"; -const rmoust$1 = "⎱"; -const rmoustache$1 = "⎱"; -const rnmid$1 = "⫮"; -const roang$1 = "⟭"; -const roarr$1 = "⇾"; -const robrk$1 = "⟧"; -const ropar$1 = "⦆"; -const ropf$1 = "𝕣"; -const roplus$1 = "⨮"; -const rotimes$1 = "⨵"; -const rpar$1 = ")"; -const rpargt$1 = "⦔"; -const rppolint$1 = "⨒"; -const rrarr$1 = "⇉"; -const rsaquo$1 = "›"; -const rscr$1 = "𝓇"; -const rsh$1 = "↱"; -const rsqb$1 = "]"; -const rsquo$1 = "’"; -const rsquor$1 = "’"; -const rthree$1 = "⋌"; -const rtimes$1 = "⋊"; -const rtri$1 = "▹"; -const rtrie$1 = "⊵"; -const rtrif$1 = "▸"; -const rtriltri$1 = "⧎"; -const ruluhar$1 = "⥨"; -const rx$1 = "℞"; -const sacute$1 = "ś"; -const sbquo$1 = "‚"; -const sc$1 = "≻"; -const scE$1 = "⪴"; -const scap$1 = "⪸"; -const scaron$1 = "š"; -const sccue$1 = "≽"; -const sce$1 = "⪰"; -const scedil$1 = "ş"; -const scirc$1 = "ŝ"; -const scnE$1 = "⪶"; -const scnap$1 = "⪺"; -const scnsim$1 = "⋩"; -const scpolint$1 = "⨓"; -const scsim$1 = "≿"; -const scy$1 = "с"; -const sdot$1 = "⋅"; -const sdotb$1 = "⊡"; -const sdote$1 = "⩦"; -const seArr$1 = "⇘"; -const searhk$1 = "⤥"; -const searr$1 = "↘"; -const searrow$1 = "↘"; -const sec$1 = "§"; -const sect$1 = "§"; -const semi$1 = ";"; -const seswar$1 = "⤩"; -const setminus$1 = "∖"; -const setmn$1 = "∖"; -const sext$1 = "✶"; -const sfr$1 = "𝔰"; -const sfrown$1 = "⌢"; -const sharp$1 = "♯"; -const shchcy$1 = "щ"; -const shcy$1 = "ш"; -const shortmid$1 = "∣"; -const shortparallel$1 = "∥"; -const sh$1 = "­"; -const shy$1 = "­"; -const sigma$1 = "σ"; -const sigmaf$1 = "ς"; -const sigmav$1 = "ς"; -const sim$1 = "∼"; -const simdot$1 = "⩪"; -const sime$1 = "≃"; -const simeq$1 = "≃"; -const simg$1 = "⪞"; -const simgE$1 = "⪠"; -const siml$1 = "⪝"; -const simlE$1 = "⪟"; -const simne$1 = "≆"; -const simplus$1 = "⨤"; -const simrarr$1 = "⥲"; -const slarr$1 = "←"; -const smallsetminus$1 = "∖"; -const smashp$1 = "⨳"; -const smeparsl$1 = "⧤"; -const smid$1 = "∣"; -const smile$1 = "⌣"; -const smt$1 = "⪪"; -const smte$1 = "⪬"; -const smtes$1 = "⪬︀"; -const softcy$1 = "ь"; -const sol$1 = "/"; -const solb$1 = "⧄"; -const solbar$1 = "⌿"; -const sopf$1 = "𝕤"; -const spades$1 = "♠"; -const spadesuit$1 = "♠"; -const spar$1 = "∥"; -const sqcap$1 = "⊓"; -const sqcaps$1 = "⊓︀"; -const sqcup$1 = "⊔"; -const sqcups$1 = "⊔︀"; -const sqsub$1 = "⊏"; -const sqsube$1 = "⊑"; -const sqsubset$1 = "⊏"; -const sqsubseteq$1 = "⊑"; -const sqsup$1 = "⊐"; -const sqsupe$1 = "⊒"; -const sqsupset$1 = "⊐"; -const sqsupseteq$1 = "⊒"; -const squ$1 = "□"; -const square$1 = "□"; -const squarf$1 = "▪"; -const squf$1 = "▪"; -const srarr$1 = "→"; -const sscr$1 = "𝓈"; -const ssetmn$1 = "∖"; -const ssmile$1 = "⌣"; -const sstarf$1 = "⋆"; -const star$1 = "☆"; -const starf$1 = "★"; -const straightepsilon$1 = "ϵ"; -const straightphi$1 = "ϕ"; -const strns$1 = "¯"; -const sub$1 = "⊂"; -const subE$1 = "⫅"; -const subdot$1 = "⪽"; -const sube$1 = "⊆"; -const subedot$1 = "⫃"; -const submult$1 = "⫁"; -const subnE$1 = "⫋"; -const subne$1 = "⊊"; -const subplus$1 = "⪿"; -const subrarr$1 = "⥹"; -const subset$1 = "⊂"; -const subseteq$1 = "⊆"; -const subseteqq$1 = "⫅"; -const subsetneq$1 = "⊊"; -const subsetneqq$1 = "⫋"; -const subsim$1 = "⫇"; -const subsub$1 = "⫕"; -const subsup$1 = "⫓"; -const succ$1 = "≻"; -const succapprox$1 = "⪸"; -const succcurlyeq$1 = "≽"; -const succeq$1 = "⪰"; -const succnapprox$1 = "⪺"; -const succneqq$1 = "⪶"; -const succnsim$1 = "⋩"; -const succsim$1 = "≿"; -const sum$1 = "∑"; -const sung$1 = "♪"; -const sup$1 = "⊃"; -const sup1$1 = "¹"; -const sup2$1 = "²"; -const sup3$1 = "³"; -const supE$1 = "⫆"; -const supdot$1 = "⪾"; -const supdsub$1 = "⫘"; -const supe$1 = "⊇"; -const supedot$1 = "⫄"; -const suphsol$1 = "⟉"; -const suphsub$1 = "⫗"; -const suplarr$1 = "⥻"; -const supmult$1 = "⫂"; -const supnE$1 = "⫌"; -const supne$1 = "⊋"; -const supplus$1 = "⫀"; -const supset$1 = "⊃"; -const supseteq$1 = "⊇"; -const supseteqq$1 = "⫆"; -const supsetneq$1 = "⊋"; -const supsetneqq$1 = "⫌"; -const supsim$1 = "⫈"; -const supsub$1 = "⫔"; -const supsup$1 = "⫖"; -const swArr$1 = "⇙"; -const swarhk$1 = "⤦"; -const swarr$1 = "↙"; -const swarrow$1 = "↙"; -const swnwar$1 = "⤪"; -const szli$1 = "ß"; -const szlig$1 = "ß"; -const target$1 = "⌖"; -const tau$1 = "τ"; -const tbrk$1 = "⎴"; -const tcaron$1 = "ť"; -const tcedil$1 = "ţ"; -const tcy$1 = "т"; -const tdot$1 = "⃛"; -const telrec$1 = "⌕"; -const tfr$1 = "𝔱"; -const there4$1 = "∴"; -const therefore$1 = "∴"; -const theta$1 = "θ"; -const thetasym$1 = "ϑ"; -const thetav$1 = "ϑ"; -const thickapprox$1 = "≈"; -const thicksim$1 = "∼"; -const thinsp$1 = " "; -const thkap$1 = "≈"; -const thksim$1 = "∼"; -const thor$1 = "þ"; -const thorn$1 = "þ"; -const tilde$1 = "˜"; -const time$1 = "×"; -const times$1 = "×"; -const timesb$1 = "⊠"; -const timesbar$1 = "⨱"; -const timesd$1 = "⨰"; -const tint$1 = "∭"; -const toea$1 = "⤨"; -const top$1 = "⊤"; -const topbot$1 = "⌶"; -const topcir$1 = "⫱"; -const topf$1 = "𝕥"; -const topfork$1 = "⫚"; -const tosa$1 = "⤩"; -const tprime$1 = "‴"; -const trade$1 = "™"; -const triangle$1 = "▵"; -const triangledown$1 = "▿"; -const triangleleft$1 = "◃"; -const trianglelefteq$1 = "⊴"; -const triangleq$1 = "≜"; -const triangleright$1 = "▹"; -const trianglerighteq$1 = "⊵"; -const tridot$1 = "◬"; -const trie$1 = "≜"; -const triminus$1 = "⨺"; -const triplus$1 = "⨹"; -const trisb$1 = "⧍"; -const tritime$1 = "⨻"; -const trpezium$1 = "⏢"; -const tscr$1 = "𝓉"; -const tscy$1 = "ц"; -const tshcy$1 = "ћ"; -const tstrok$1 = "ŧ"; -const twixt$1 = "≬"; -const twoheadleftarrow$1 = "↞"; -const twoheadrightarrow$1 = "↠"; -const uArr$1 = "⇑"; -const uHar$1 = "⥣"; -const uacut$1 = "ú"; -const uacute$1 = "ú"; -const uarr$1 = "↑"; -const ubrcy$1 = "ў"; -const ubreve$1 = "ŭ"; -const ucir$1 = "û"; -const ucirc$1 = "û"; -const ucy$1 = "у"; -const udarr$1 = "⇅"; -const udblac$1 = "ű"; -const udhar$1 = "⥮"; -const ufisht$1 = "⥾"; -const ufr$1 = "𝔲"; -const ugrav$1 = "ù"; -const ugrave$1 = "ù"; -const uharl$1 = "↿"; -const uharr$1 = "↾"; -const uhblk$1 = "▀"; -const ulcorn$1 = "⌜"; -const ulcorner$1 = "⌜"; -const ulcrop$1 = "⌏"; -const ultri$1 = "◸"; -const umacr$1 = "ū"; -const um$1 = "¨"; -const uml$1 = "¨"; -const uogon$1 = "ų"; -const uopf$1 = "𝕦"; -const uparrow$1 = "↑"; -const updownarrow$1 = "↕"; -const upharpoonleft$1 = "↿"; -const upharpoonright$1 = "↾"; -const uplus$1 = "⊎"; -const upsi$1 = "υ"; -const upsih$1 = "ϒ"; -const upsilon$1 = "υ"; -const upuparrows$1 = "⇈"; -const urcorn$1 = "⌝"; -const urcorner$1 = "⌝"; -const urcrop$1 = "⌎"; -const uring$1 = "ů"; -const urtri$1 = "◹"; -const uscr$1 = "𝓊"; -const utdot$1 = "⋰"; -const utilde$1 = "ũ"; -const utri$1 = "▵"; -const utrif$1 = "▴"; -const uuarr$1 = "⇈"; -const uum$1 = "ü"; -const uuml$1 = "ü"; -const uwangle$1 = "⦧"; -const vArr$1 = "⇕"; -const vBar$1 = "⫨"; -const vBarv$1 = "⫩"; -const vDash$1 = "⊨"; -const vangrt$1 = "⦜"; -const varepsilon$1 = "ϵ"; -const varkappa$1 = "ϰ"; -const varnothing$1 = "∅"; -const varphi$1 = "ϕ"; -const varpi$1 = "ϖ"; -const varpropto$1 = "∝"; -const varr$1 = "↕"; -const varrho$1 = "ϱ"; -const varsigma$1 = "ς"; -const varsubsetneq$1 = "⊊︀"; -const varsubsetneqq$1 = "⫋︀"; -const varsupsetneq$1 = "⊋︀"; -const varsupsetneqq$1 = "⫌︀"; -const vartheta$1 = "ϑ"; -const vartriangleleft$1 = "⊲"; -const vartriangleright$1 = "⊳"; -const vcy$1 = "в"; -const vdash$1 = "⊢"; -const vee$1 = "∨"; -const veebar$1 = "⊻"; -const veeeq$1 = "≚"; -const vellip$1 = "⋮"; -const verbar$1 = "|"; -const vert$1 = "|"; -const vfr$1 = "𝔳"; -const vltri$1 = "⊲"; -const vnsub$1 = "⊂⃒"; -const vnsup$1 = "⊃⃒"; -const vopf$1 = "𝕧"; -const vprop$1 = "∝"; -const vrtri$1 = "⊳"; -const vscr$1 = "𝓋"; -const vsubnE$1 = "⫋︀"; -const vsubne$1 = "⊊︀"; -const vsupnE$1 = "⫌︀"; -const vsupne$1 = "⊋︀"; -const vzigzag$1 = "⦚"; -const wcirc$1 = "ŵ"; -const wedbar$1 = "⩟"; -const wedge$1 = "∧"; -const wedgeq$1 = "≙"; -const weierp$1 = "℘"; -const wfr$1 = "𝔴"; -const wopf$1 = "𝕨"; -const wp$1 = "℘"; -const wr$1 = "≀"; -const wreath$1 = "≀"; -const wscr$1 = "𝓌"; -const xcap$1 = "⋂"; -const xcirc$1 = "◯"; -const xcup$1 = "⋃"; -const xdtri$1 = "▽"; -const xfr$1 = "𝔵"; -const xhArr$1 = "⟺"; -const xharr$1 = "⟷"; -const xi$1 = "ξ"; -const xlArr$1 = "⟸"; -const xlarr$1 = "⟵"; -const xmap$1 = "⟼"; -const xnis$1 = "⋻"; -const xodot$1 = "⨀"; -const xopf$1 = "𝕩"; -const xoplus$1 = "⨁"; -const xotime$1 = "⨂"; -const xrArr$1 = "⟹"; -const xrarr$1 = "⟶"; -const xscr$1 = "𝓍"; -const xsqcup$1 = "⨆"; -const xuplus$1 = "⨄"; -const xutri$1 = "△"; -const xvee$1 = "⋁"; -const xwedge$1 = "⋀"; -const yacut$1 = "ý"; -const yacute$1 = "ý"; -const yacy$1 = "я"; -const ycirc$1 = "ŷ"; -const ycy$1 = "ы"; -const ye$1 = "¥"; -const yen$1 = "¥"; -const yfr$1 = "𝔶"; -const yicy$1 = "ї"; -const yopf$1 = "𝕪"; -const yscr$1 = "𝓎"; -const yucy$1 = "ю"; -const yum$1 = "ÿ"; -const yuml$1 = "ÿ"; -const zacute$1 = "ź"; -const zcaron$1 = "ž"; -const zcy$1 = "з"; -const zdot$1 = "ż"; -const zeetrf$1 = "ℨ"; -const zeta$1 = "ζ"; -const zfr$1 = "𝔷"; -const zhcy$1 = "ж"; -const zigrarr$1 = "⇝"; -const zopf$1 = "𝕫"; -const zscr$1 = "𝓏"; -const zwj$1 = "‍"; -const zwnj$1 = "‌"; -var require$$0$1 = { - AEli: AEli$1, - AElig: AElig$1, - AM: AM$1, - AMP: AMP$1, - Aacut: Aacut$1, - Aacute: Aacute$1, - Abreve: Abreve$1, - Acir: Acir$1, - Acirc: Acirc$1, - Acy: Acy$1, - Afr: Afr$1, - Agrav: Agrav$1, - Agrave: Agrave$1, - Alpha: Alpha$1, - Amacr: Amacr$1, - And: And$1, - Aogon: Aogon$1, - Aopf: Aopf$1, - ApplyFunction: ApplyFunction$1, - Arin: Arin$1, - Aring: Aring$1, - Ascr: Ascr$1, - Assign: Assign$1, - Atild: Atild$1, - Atilde: Atilde$1, - Aum: Aum$1, - Auml: Auml$1, - Backslash: Backslash$1, - Barv: Barv$1, - Barwed: Barwed$1, - Bcy: Bcy$1, - Because: Because$1, - Bernoullis: Bernoullis$1, - Beta: Beta$1, - Bfr: Bfr$1, - Bopf: Bopf$1, - Breve: Breve$1, - Bscr: Bscr$1, - Bumpeq: Bumpeq$1, - CHcy: CHcy$1, - COP: COP$1, - COPY: COPY$1, - Cacute: Cacute$1, - Cap: Cap$1, - CapitalDifferentialD: CapitalDifferentialD$1, - Cayleys: Cayleys$1, - Ccaron: Ccaron$1, - Ccedi: Ccedi$1, - Ccedil: Ccedil$1, - Ccirc: Ccirc$1, - Cconint: Cconint$1, - Cdot: Cdot$1, - Cedilla: Cedilla$1, - CenterDot: CenterDot$1, - Cfr: Cfr$1, - Chi: Chi$1, - CircleDot: CircleDot$1, - CircleMinus: CircleMinus$1, - CirclePlus: CirclePlus$1, - CircleTimes: CircleTimes$1, - ClockwiseContourIntegral: ClockwiseContourIntegral$1, - CloseCurlyDoubleQuote: CloseCurlyDoubleQuote$1, - CloseCurlyQuote: CloseCurlyQuote$1, - Colon: Colon$1, - Colone: Colone$1, - Congruent: Congruent$1, - Conint: Conint$1, - ContourIntegral: ContourIntegral$1, - Copf: Copf$1, - Coproduct: Coproduct$1, - CounterClockwiseContourIntegral: CounterClockwiseContourIntegral$1, - Cross: Cross$1, - Cscr: Cscr$1, - Cup: Cup$1, - CupCap: CupCap$1, - DD: DD$1, - DDotrahd: DDotrahd$1, - DJcy: DJcy$1, - DScy: DScy$1, - DZcy: DZcy$1, - Dagger: Dagger$1, - Darr: Darr$1, - Dashv: Dashv$1, - Dcaron: Dcaron$1, - Dcy: Dcy$1, - Del: Del$1, - Delta: Delta$1, - Dfr: Dfr$1, - DiacriticalAcute: DiacriticalAcute$1, - DiacriticalDot: DiacriticalDot$1, - DiacriticalDoubleAcute: DiacriticalDoubleAcute$1, - DiacriticalGrave: DiacriticalGrave$1, - DiacriticalTilde: DiacriticalTilde$1, - Diamond: Diamond$1, - DifferentialD: DifferentialD$1, - Dopf: Dopf$1, - Dot: Dot$1, - DotDot: DotDot$1, - DotEqual: DotEqual$1, - DoubleContourIntegral: DoubleContourIntegral$1, - DoubleDot: DoubleDot$1, - DoubleDownArrow: DoubleDownArrow$1, - DoubleLeftArrow: DoubleLeftArrow$1, - DoubleLeftRightArrow: DoubleLeftRightArrow$1, - DoubleLeftTee: DoubleLeftTee$1, - DoubleLongLeftArrow: DoubleLongLeftArrow$1, - DoubleLongLeftRightArrow: DoubleLongLeftRightArrow$1, - DoubleLongRightArrow: DoubleLongRightArrow$1, - DoubleRightArrow: DoubleRightArrow$1, - DoubleRightTee: DoubleRightTee$1, - DoubleUpArrow: DoubleUpArrow$1, - DoubleUpDownArrow: DoubleUpDownArrow$1, - DoubleVerticalBar: DoubleVerticalBar$1, - DownArrow: DownArrow$1, - DownArrowBar: DownArrowBar$1, - DownArrowUpArrow: DownArrowUpArrow$1, - DownBreve: DownBreve$1, - DownLeftRightVector: DownLeftRightVector$1, - DownLeftTeeVector: DownLeftTeeVector$1, - DownLeftVector: DownLeftVector$1, - DownLeftVectorBar: DownLeftVectorBar$1, - DownRightTeeVector: DownRightTeeVector$1, - DownRightVector: DownRightVector$1, - DownRightVectorBar: DownRightVectorBar$1, - DownTee: DownTee$1, - DownTeeArrow: DownTeeArrow$1, - Downarrow: Downarrow$1, - Dscr: Dscr$1, - Dstrok: Dstrok$1, - ENG: ENG$1, - ET: ET$1, - ETH: ETH$1, - Eacut: Eacut$1, - Eacute: Eacute$1, - Ecaron: Ecaron$1, - Ecir: Ecir$1, - Ecirc: Ecirc$1, - Ecy: Ecy$1, - Edot: Edot$1, - Efr: Efr$1, - Egrav: Egrav$1, - Egrave: Egrave$1, - Element: Element$1, - Emacr: Emacr$1, - EmptySmallSquare: EmptySmallSquare$1, - EmptyVerySmallSquare: EmptyVerySmallSquare$1, - Eogon: Eogon$1, - Eopf: Eopf$1, - Epsilon: Epsilon$1, - Equal: Equal$1, - EqualTilde: EqualTilde$1, - Equilibrium: Equilibrium$1, - Escr: Escr$1, - Esim: Esim$1, - Eta: Eta$1, - Eum: Eum$1, - Euml: Euml$1, - Exists: Exists$1, - ExponentialE: ExponentialE$1, - Fcy: Fcy$1, - Ffr: Ffr$1, - FilledSmallSquare: FilledSmallSquare$1, - FilledVerySmallSquare: FilledVerySmallSquare$1, - Fopf: Fopf$1, - ForAll: ForAll$1, - Fouriertrf: Fouriertrf$1, - Fscr: Fscr$1, - GJcy: GJcy$1, - G: G$1, - GT: GT$1, - Gamma: Gamma$1, - Gammad: Gammad$1, - Gbreve: Gbreve$1, - Gcedil: Gcedil$1, - Gcirc: Gcirc$1, - Gcy: Gcy$1, - Gdot: Gdot$1, - Gfr: Gfr$1, - Gg: Gg$1, - Gopf: Gopf$1, - GreaterEqual: GreaterEqual$1, - GreaterEqualLess: GreaterEqualLess$1, - GreaterFullEqual: GreaterFullEqual$1, - GreaterGreater: GreaterGreater$1, - GreaterLess: GreaterLess$1, - GreaterSlantEqual: GreaterSlantEqual$1, - GreaterTilde: GreaterTilde$1, - Gscr: Gscr$1, - Gt: Gt$1, - HARDcy: HARDcy$1, - Hacek: Hacek$1, - Hat: Hat$1, - Hcirc: Hcirc$1, - Hfr: Hfr$1, - HilbertSpace: HilbertSpace$1, - Hopf: Hopf$1, - HorizontalLine: HorizontalLine$1, - Hscr: Hscr$1, - Hstrok: Hstrok$1, - HumpDownHump: HumpDownHump$1, - HumpEqual: HumpEqual$1, - IEcy: IEcy$1, - IJlig: IJlig$1, - IOcy: IOcy$1, - Iacut: Iacut$1, - Iacute: Iacute$1, - Icir: Icir$1, - Icirc: Icirc$1, - Icy: Icy$1, - Idot: Idot$1, - Ifr: Ifr$1, - Igrav: Igrav$1, - Igrave: Igrave$1, - Im: Im$1, - Imacr: Imacr$1, - ImaginaryI: ImaginaryI$1, - Implies: Implies$1, - Int: Int$1, - Integral: Integral$1, - Intersection: Intersection$1, - InvisibleComma: InvisibleComma$1, - InvisibleTimes: InvisibleTimes$1, - Iogon: Iogon$1, - Iopf: Iopf$1, - Iota: Iota$1, - Iscr: Iscr$1, - Itilde: Itilde$1, - Iukcy: Iukcy$1, - Ium: Ium$1, - Iuml: Iuml$1, - Jcirc: Jcirc$1, - Jcy: Jcy$1, - Jfr: Jfr$1, - Jopf: Jopf$1, - Jscr: Jscr$1, - Jsercy: Jsercy$1, - Jukcy: Jukcy$1, - KHcy: KHcy$1, - KJcy: KJcy$1, - Kappa: Kappa$1, - Kcedil: Kcedil$1, - Kcy: Kcy$1, - Kfr: Kfr$1, - Kopf: Kopf$1, - Kscr: Kscr$1, - LJcy: LJcy$1, - L: L$1, - LT: LT$1, - Lacute: Lacute$1, - Lambda: Lambda$1, - Lang: Lang$1, - Laplacetrf: Laplacetrf$1, - Larr: Larr$1, - Lcaron: Lcaron$1, - Lcedil: Lcedil$1, - Lcy: Lcy$1, - LeftAngleBracket: LeftAngleBracket$1, - LeftArrow: LeftArrow$1, - LeftArrowBar: LeftArrowBar$1, - LeftArrowRightArrow: LeftArrowRightArrow$1, - LeftCeiling: LeftCeiling$1, - LeftDoubleBracket: LeftDoubleBracket$1, - LeftDownTeeVector: LeftDownTeeVector$1, - LeftDownVector: LeftDownVector$1, - LeftDownVectorBar: LeftDownVectorBar$1, - LeftFloor: LeftFloor$1, - LeftRightArrow: LeftRightArrow$1, - LeftRightVector: LeftRightVector$1, - LeftTee: LeftTee$1, - LeftTeeArrow: LeftTeeArrow$1, - LeftTeeVector: LeftTeeVector$1, - LeftTriangle: LeftTriangle$1, - LeftTriangleBar: LeftTriangleBar$1, - LeftTriangleEqual: LeftTriangleEqual$1, - LeftUpDownVector: LeftUpDownVector$1, - LeftUpTeeVector: LeftUpTeeVector$1, - LeftUpVector: LeftUpVector$1, - LeftUpVectorBar: LeftUpVectorBar$1, - LeftVector: LeftVector$1, - LeftVectorBar: LeftVectorBar$1, - Leftarrow: Leftarrow$1, - Leftrightarrow: Leftrightarrow$1, - LessEqualGreater: LessEqualGreater$1, - LessFullEqual: LessFullEqual$1, - LessGreater: LessGreater$1, - LessLess: LessLess$1, - LessSlantEqual: LessSlantEqual$1, - LessTilde: LessTilde$1, - Lfr: Lfr$1, - Ll: Ll$1, - Lleftarrow: Lleftarrow$1, - Lmidot: Lmidot$1, - LongLeftArrow: LongLeftArrow$1, - LongLeftRightArrow: LongLeftRightArrow$1, - LongRightArrow: LongRightArrow$1, - Longleftarrow: Longleftarrow$1, - Longleftrightarrow: Longleftrightarrow$1, - Longrightarrow: Longrightarrow$1, - Lopf: Lopf$1, - LowerLeftArrow: LowerLeftArrow$1, - LowerRightArrow: LowerRightArrow$1, - Lscr: Lscr$1, - Lsh: Lsh$1, - Lstrok: Lstrok$1, - Lt: Lt$1, - "Map": "⤅", - Mcy: Mcy$1, - MediumSpace: MediumSpace$1, - Mellintrf: Mellintrf$1, - Mfr: Mfr$1, - MinusPlus: MinusPlus$1, - Mopf: Mopf$1, - Mscr: Mscr$1, - Mu: Mu$1, - NJcy: NJcy$1, - Nacute: Nacute$1, - Ncaron: Ncaron$1, - Ncedil: Ncedil$1, - Ncy: Ncy$1, - NegativeMediumSpace: NegativeMediumSpace$1, - NegativeThickSpace: NegativeThickSpace$1, - NegativeThinSpace: NegativeThinSpace$1, - NegativeVeryThinSpace: NegativeVeryThinSpace$1, - NestedGreaterGreater: NestedGreaterGreater$1, - NestedLessLess: NestedLessLess$1, - NewLine: NewLine$1, - Nfr: Nfr$1, - NoBreak: NoBreak$1, - NonBreakingSpace: NonBreakingSpace$1, - Nopf: Nopf$1, - Not: Not$1, - NotCongruent: NotCongruent$1, - NotCupCap: NotCupCap$1, - NotDoubleVerticalBar: NotDoubleVerticalBar$1, - NotElement: NotElement$1, - NotEqual: NotEqual$1, - NotEqualTilde: NotEqualTilde$1, - NotExists: NotExists$1, - NotGreater: NotGreater$1, - NotGreaterEqual: NotGreaterEqual$1, - NotGreaterFullEqual: NotGreaterFullEqual$1, - NotGreaterGreater: NotGreaterGreater$1, - NotGreaterLess: NotGreaterLess$1, - NotGreaterSlantEqual: NotGreaterSlantEqual$1, - NotGreaterTilde: NotGreaterTilde$1, - NotHumpDownHump: NotHumpDownHump$1, - NotHumpEqual: NotHumpEqual$1, - NotLeftTriangle: NotLeftTriangle$1, - NotLeftTriangleBar: NotLeftTriangleBar$1, - NotLeftTriangleEqual: NotLeftTriangleEqual$1, - NotLess: NotLess$1, - NotLessEqual: NotLessEqual$1, - NotLessGreater: NotLessGreater$1, - NotLessLess: NotLessLess$1, - NotLessSlantEqual: NotLessSlantEqual$1, - NotLessTilde: NotLessTilde$1, - NotNestedGreaterGreater: NotNestedGreaterGreater$1, - NotNestedLessLess: NotNestedLessLess$1, - NotPrecedes: NotPrecedes$1, - NotPrecedesEqual: NotPrecedesEqual$1, - NotPrecedesSlantEqual: NotPrecedesSlantEqual$1, - NotReverseElement: NotReverseElement$1, - NotRightTriangle: NotRightTriangle$1, - NotRightTriangleBar: NotRightTriangleBar$1, - NotRightTriangleEqual: NotRightTriangleEqual$1, - NotSquareSubset: NotSquareSubset$1, - NotSquareSubsetEqual: NotSquareSubsetEqual$1, - NotSquareSuperset: NotSquareSuperset$1, - NotSquareSupersetEqual: NotSquareSupersetEqual$1, - NotSubset: NotSubset$1, - NotSubsetEqual: NotSubsetEqual$1, - NotSucceeds: NotSucceeds$1, - NotSucceedsEqual: NotSucceedsEqual$1, - NotSucceedsSlantEqual: NotSucceedsSlantEqual$1, - NotSucceedsTilde: NotSucceedsTilde$1, - NotSuperset: NotSuperset$1, - NotSupersetEqual: NotSupersetEqual$1, - NotTilde: NotTilde$1, - NotTildeEqual: NotTildeEqual$1, - NotTildeFullEqual: NotTildeFullEqual$1, - NotTildeTilde: NotTildeTilde$1, - NotVerticalBar: NotVerticalBar$1, - Nscr: Nscr$1, - Ntild: Ntild$1, - Ntilde: Ntilde$1, - Nu: Nu$1, - OElig: OElig$1, - Oacut: Oacut$1, - Oacute: Oacute$1, - Ocir: Ocir$1, - Ocirc: Ocirc$1, - Ocy: Ocy$1, - Odblac: Odblac$1, - Ofr: Ofr$1, - Ograv: Ograv$1, - Ograve: Ograve$1, - Omacr: Omacr$1, - Omega: Omega$1, - Omicron: Omicron$1, - Oopf: Oopf$1, - OpenCurlyDoubleQuote: OpenCurlyDoubleQuote$1, - OpenCurlyQuote: OpenCurlyQuote$1, - Or: Or$1, - Oscr: Oscr$1, - Oslas: Oslas$1, - Oslash: Oslash$1, - Otild: Otild$1, - Otilde: Otilde$1, - Otimes: Otimes$1, - Oum: Oum$1, - Ouml: Ouml$1, - OverBar: OverBar$1, - OverBrace: OverBrace$1, - OverBracket: OverBracket$1, - OverParenthesis: OverParenthesis$1, - PartialD: PartialD$1, - Pcy: Pcy$1, - Pfr: Pfr$1, - Phi: Phi$1, - Pi: Pi$1, - PlusMinus: PlusMinus$1, - Poincareplane: Poincareplane$1, - Popf: Popf$1, - Pr: Pr$1, - Precedes: Precedes$1, - PrecedesEqual: PrecedesEqual$1, - PrecedesSlantEqual: PrecedesSlantEqual$1, - PrecedesTilde: PrecedesTilde$1, - Prime: Prime$1, - Product: Product$1, - Proportion: Proportion$1, - Proportional: Proportional$1, - Pscr: Pscr$1, - Psi: Psi$1, - QUO: QUO$1, - QUOT: QUOT$1, - Qfr: Qfr$1, - Qopf: Qopf$1, - Qscr: Qscr$1, - RBarr: RBarr$1, - RE: RE$1, - REG: REG$1, - Racute: Racute$1, - Rang: Rang$1, - Rarr: Rarr$1, - Rarrtl: Rarrtl$1, - Rcaron: Rcaron$1, - Rcedil: Rcedil$1, - Rcy: Rcy$1, - Re: Re$1, - ReverseElement: ReverseElement$1, - ReverseEquilibrium: ReverseEquilibrium$1, - ReverseUpEquilibrium: ReverseUpEquilibrium$1, - Rfr: Rfr$1, - Rho: Rho$1, - RightAngleBracket: RightAngleBracket$1, - RightArrow: RightArrow$1, - RightArrowBar: RightArrowBar$1, - RightArrowLeftArrow: RightArrowLeftArrow$1, - RightCeiling: RightCeiling$1, - RightDoubleBracket: RightDoubleBracket$1, - RightDownTeeVector: RightDownTeeVector$1, - RightDownVector: RightDownVector$1, - RightDownVectorBar: RightDownVectorBar$1, - RightFloor: RightFloor$1, - RightTee: RightTee$1, - RightTeeArrow: RightTeeArrow$1, - RightTeeVector: RightTeeVector$1, - RightTriangle: RightTriangle$1, - RightTriangleBar: RightTriangleBar$1, - RightTriangleEqual: RightTriangleEqual$1, - RightUpDownVector: RightUpDownVector$1, - RightUpTeeVector: RightUpTeeVector$1, - RightUpVector: RightUpVector$1, - RightUpVectorBar: RightUpVectorBar$1, - RightVector: RightVector$1, - RightVectorBar: RightVectorBar$1, - Rightarrow: Rightarrow$1, - Ropf: Ropf$1, - RoundImplies: RoundImplies$1, - Rrightarrow: Rrightarrow$1, - Rscr: Rscr$1, - Rsh: Rsh$1, - RuleDelayed: RuleDelayed$1, - SHCHcy: SHCHcy$1, - SHcy: SHcy$1, - SOFTcy: SOFTcy$1, - Sacute: Sacute$1, - Sc: Sc$1, - Scaron: Scaron$1, - Scedil: Scedil$1, - Scirc: Scirc$1, - Scy: Scy$1, - Sfr: Sfr$1, - ShortDownArrow: ShortDownArrow$1, - ShortLeftArrow: ShortLeftArrow$1, - ShortRightArrow: ShortRightArrow$1, - ShortUpArrow: ShortUpArrow$1, - Sigma: Sigma$1, - SmallCircle: SmallCircle$1, - Sopf: Sopf$1, - Sqrt: Sqrt$1, - Square: Square$1, - SquareIntersection: SquareIntersection$1, - SquareSubset: SquareSubset$1, - SquareSubsetEqual: SquareSubsetEqual$1, - SquareSuperset: SquareSuperset$1, - SquareSupersetEqual: SquareSupersetEqual$1, - SquareUnion: SquareUnion$1, - Sscr: Sscr$1, - Star: Star$1, - Sub: Sub$1, - Subset: Subset$1, - SubsetEqual: SubsetEqual$1, - Succeeds: Succeeds$1, - SucceedsEqual: SucceedsEqual$1, - SucceedsSlantEqual: SucceedsSlantEqual$1, - SucceedsTilde: SucceedsTilde$1, - SuchThat: SuchThat$1, - Sum: Sum$1, - Sup: Sup$1, - Superset: Superset$1, - SupersetEqual: SupersetEqual$1, - Supset: Supset$1, - THOR: THOR$1, - THORN: THORN$1, - TRADE: TRADE$1, - TSHcy: TSHcy$1, - TScy: TScy$1, - Tab: Tab$1, - Tau: Tau$1, - Tcaron: Tcaron$1, - Tcedil: Tcedil$1, - Tcy: Tcy$1, - Tfr: Tfr$1, - Therefore: Therefore$1, - Theta: Theta$1, - ThickSpace: ThickSpace$1, - ThinSpace: ThinSpace$1, - Tilde: Tilde$1, - TildeEqual: TildeEqual$1, - TildeFullEqual: TildeFullEqual$1, - TildeTilde: TildeTilde$1, - Topf: Topf$1, - TripleDot: TripleDot$1, - Tscr: Tscr$1, - Tstrok: Tstrok$1, - Uacut: Uacut$1, - Uacute: Uacute$1, - Uarr: Uarr$1, - Uarrocir: Uarrocir$1, - Ubrcy: Ubrcy$1, - Ubreve: Ubreve$1, - Ucir: Ucir$1, - Ucirc: Ucirc$1, - Ucy: Ucy$1, - Udblac: Udblac$1, - Ufr: Ufr$1, - Ugrav: Ugrav$1, - Ugrave: Ugrave$1, - Umacr: Umacr$1, - UnderBar: UnderBar$1, - UnderBrace: UnderBrace$1, - UnderBracket: UnderBracket$1, - UnderParenthesis: UnderParenthesis$1, - Union: Union$1, - UnionPlus: UnionPlus$1, - Uogon: Uogon$1, - Uopf: Uopf$1, - UpArrow: UpArrow$1, - UpArrowBar: UpArrowBar$1, - UpArrowDownArrow: UpArrowDownArrow$1, - UpDownArrow: UpDownArrow$1, - UpEquilibrium: UpEquilibrium$1, - UpTee: UpTee$1, - UpTeeArrow: UpTeeArrow$1, - Uparrow: Uparrow$1, - Updownarrow: Updownarrow$1, - UpperLeftArrow: UpperLeftArrow$1, - UpperRightArrow: UpperRightArrow$1, - Upsi: Upsi$1, - Upsilon: Upsilon$1, - Uring: Uring$1, - Uscr: Uscr$1, - Utilde: Utilde$1, - Uum: Uum$1, - Uuml: Uuml$1, - VDash: VDash$1, - Vbar: Vbar$1, - Vcy: Vcy$1, - Vdash: Vdash$1, - Vdashl: Vdashl$1, - Vee: Vee$1, - Verbar: Verbar$1, - Vert: Vert$1, - VerticalBar: VerticalBar$1, - VerticalLine: VerticalLine$1, - VerticalSeparator: VerticalSeparator$1, - VerticalTilde: VerticalTilde$1, - VeryThinSpace: VeryThinSpace$1, - Vfr: Vfr$1, - Vopf: Vopf$1, - Vscr: Vscr$1, - Vvdash: Vvdash$1, - Wcirc: Wcirc$1, - Wedge: Wedge$1, - Wfr: Wfr$1, - Wopf: Wopf$1, - Wscr: Wscr$1, - Xfr: Xfr$1, - Xi: Xi$1, - Xopf: Xopf$1, - Xscr: Xscr$1, - YAcy: YAcy$1, - YIcy: YIcy$1, - YUcy: YUcy$1, - Yacut: Yacut$1, - Yacute: Yacute$1, - Ycirc: Ycirc$1, - Ycy: Ycy$1, - Yfr: Yfr$1, - Yopf: Yopf$1, - Yscr: Yscr$1, - Yuml: Yuml$1, - ZHcy: ZHcy$1, - Zacute: Zacute$1, - Zcaron: Zcaron$1, - Zcy: Zcy$1, - Zdot: Zdot$1, - ZeroWidthSpace: ZeroWidthSpace$1, - Zeta: Zeta$1, - Zfr: Zfr$1, - Zopf: Zopf$1, - Zscr: Zscr$1, - aacut: aacut$1, - aacute: aacute$1, - abreve: abreve$1, - ac: ac$1, - acE: acE$1, - acd: acd$1, - acir: acir$1, - acirc: acirc$1, - acut: acut$1, - acute: acute$1, - acy: acy$1, - aeli: aeli$1, - aelig: aelig$1, - af: af$1, - afr: afr$1, - agrav: agrav$1, - agrave: agrave$1, - alefsym: alefsym$1, - aleph: aleph$1, - alpha: alpha$1, - amacr: amacr$1, - amalg: amalg$1, - am: am$1, - amp: amp$1, - and: and$1, - andand: andand$1, - andd: andd$1, - andslope: andslope$1, - andv: andv$1, - ang: ang$1, - ange: ange$1, - angle: angle$1, - angmsd: angmsd$1, - angmsdaa: angmsdaa$1, - angmsdab: angmsdab$1, - angmsdac: angmsdac$1, - angmsdad: angmsdad$1, - angmsdae: angmsdae$1, - angmsdaf: angmsdaf$1, - angmsdag: angmsdag$1, - angmsdah: angmsdah$1, - angrt: angrt$1, - angrtvb: angrtvb$1, - angrtvbd: angrtvbd$1, - angsph: angsph$1, - angst: angst$1, - angzarr: angzarr$1, - aogon: aogon$1, - aopf: aopf$1, - ap: ap$1, - apE: apE$1, - apacir: apacir$1, - ape: ape$1, - apid: apid$1, - apos: apos$1, - approx: approx$1, - approxeq: approxeq$1, - arin: arin$1, - aring: aring$1, - ascr: ascr$1, - ast: ast$1, - asymp: asymp$1, - asympeq: asympeq$1, - atild: atild$1, - atilde: atilde$1, - aum: aum$1, - auml: auml$1, - awconint: awconint$1, - awint: awint$1, - bNot: bNot$1, - backcong: backcong$1, - backepsilon: backepsilon$1, - backprime: backprime$1, - backsim: backsim$1, - backsimeq: backsimeq$1, - barvee: barvee$1, - barwed: barwed$1, - barwedge: barwedge$1, - bbrk: bbrk$1, - bbrktbrk: bbrktbrk$1, - bcong: bcong$1, - bcy: bcy$1, - bdquo: bdquo$1, - becaus: becaus$1, - because: because$1, - bemptyv: bemptyv$1, - bepsi: bepsi$1, - bernou: bernou$1, - beta: beta$1, - beth: beth$1, - between: between$1, - bfr: bfr$1, - bigcap: bigcap$1, - bigcirc: bigcirc$1, - bigcup: bigcup$1, - bigodot: bigodot$1, - bigoplus: bigoplus$1, - bigotimes: bigotimes$1, - bigsqcup: bigsqcup$1, - bigstar: bigstar$1, - bigtriangledown: bigtriangledown$1, - bigtriangleup: bigtriangleup$1, - biguplus: biguplus$1, - bigvee: bigvee$1, - bigwedge: bigwedge$1, - bkarow: bkarow$1, - blacklozenge: blacklozenge$1, - blacksquare: blacksquare$1, - blacktriangle: blacktriangle$1, - blacktriangledown: blacktriangledown$1, - blacktriangleleft: blacktriangleleft$1, - blacktriangleright: blacktriangleright$1, - blank: blank$1, - blk12: blk12$1, - blk14: blk14$1, - blk34: blk34$1, - block: block$1, - bne: bne$1, - bnequiv: bnequiv$1, - bnot: bnot$1, - bopf: bopf$1, - bot: bot$1, - bottom: bottom$1, - bowtie: bowtie$1, - boxDL: boxDL$1, - boxDR: boxDR$1, - boxDl: boxDl$1, - boxDr: boxDr$1, - boxH: boxH$1, - boxHD: boxHD$1, - boxHU: boxHU$1, - boxHd: boxHd$1, - boxHu: boxHu$1, - boxUL: boxUL$1, - boxUR: boxUR$1, - boxUl: boxUl$1, - boxUr: boxUr$1, - boxV: boxV$1, - boxVH: boxVH$1, - boxVL: boxVL$1, - boxVR: boxVR$1, - boxVh: boxVh$1, - boxVl: boxVl$1, - boxVr: boxVr$1, - boxbox: boxbox$1, - boxdL: boxdL$1, - boxdR: boxdR$1, - boxdl: boxdl$1, - boxdr: boxdr$1, - boxh: boxh$1, - boxhD: boxhD$1, - boxhU: boxhU$1, - boxhd: boxhd$1, - boxhu: boxhu$1, - boxminus: boxminus$1, - boxplus: boxplus$1, - boxtimes: boxtimes$1, - boxuL: boxuL$1, - boxuR: boxuR$1, - boxul: boxul$1, - boxur: boxur$1, - boxv: boxv$1, - boxvH: boxvH$1, - boxvL: boxvL$1, - boxvR: boxvR$1, - boxvh: boxvh$1, - boxvl: boxvl$1, - boxvr: boxvr$1, - bprime: bprime$1, - breve: breve$1, - brvba: brvba$1, - brvbar: brvbar$1, - bscr: bscr$1, - bsemi: bsemi$1, - bsim: bsim$1, - bsime: bsime$1, - bsol: bsol$1, - bsolb: bsolb$1, - bsolhsub: bsolhsub$1, - bull: bull$1, - bullet: bullet$1, - bump: bump$1, - bumpE: bumpE$1, - bumpe: bumpe$1, - bumpeq: bumpeq$1, - cacute: cacute$1, - cap: cap$1, - capand: capand$1, - capbrcup: capbrcup$1, - capcap: capcap$1, - capcup: capcup$1, - capdot: capdot$1, - caps: caps$1, - caret: caret$1, - caron: caron$1, - ccaps: ccaps$1, - ccaron: ccaron$1, - ccedi: ccedi$1, - ccedil: ccedil$1, - ccirc: ccirc$1, - ccups: ccups$1, - ccupssm: ccupssm$1, - cdot: cdot$1, - cedi: cedi$1, - cedil: cedil$1, - cemptyv: cemptyv$1, - cen: cen$1, - cent: cent$1, - centerdot: centerdot$1, - cfr: cfr$1, - chcy: chcy$1, - check: check$2, - checkmark: checkmark$1, - chi: chi$1, - cir: cir$1, - cirE: cirE$1, - circ: circ$1, - circeq: circeq$1, - circlearrowleft: circlearrowleft$1, - circlearrowright: circlearrowright$1, - circledR: circledR$1, - circledS: circledS$1, - circledast: circledast$1, - circledcirc: circledcirc$1, - circleddash: circleddash$1, - cire: cire$1, - cirfnint: cirfnint$1, - cirmid: cirmid$1, - cirscir: cirscir$1, - clubs: clubs$1, - clubsuit: clubsuit$1, - colon: colon$1, - colone: colone$1, - coloneq: coloneq$1, - comma: comma$1, - commat: commat$1, - comp: comp$1, - compfn: compfn$1, - complement: complement$1, - complexes: complexes$1, - cong: cong$1, - congdot: congdot$1, - conint: conint$1, - copf: copf$1, - coprod: coprod$1, - cop: cop$1, - copy: copy$1, - copysr: copysr$1, - crarr: crarr$1, - cross: cross$1, - cscr: cscr$1, - csub: csub$1, - csube: csube$1, - csup: csup$1, - csupe: csupe$1, - ctdot: ctdot$1, - cudarrl: cudarrl$1, - cudarrr: cudarrr$1, - cuepr: cuepr$1, - cuesc: cuesc$1, - cularr: cularr$1, - cularrp: cularrp$1, - cup: cup$1, - cupbrcap: cupbrcap$1, - cupcap: cupcap$1, - cupcup: cupcup$1, - cupdot: cupdot$1, - cupor: cupor$1, - cups: cups$1, - curarr: curarr$1, - curarrm: curarrm$1, - curlyeqprec: curlyeqprec$1, - curlyeqsucc: curlyeqsucc$1, - curlyvee: curlyvee$1, - curlywedge: curlywedge$1, - curre: curre$1, - curren: curren$1, - curvearrowleft: curvearrowleft$1, - curvearrowright: curvearrowright$1, - cuvee: cuvee$1, - cuwed: cuwed$1, - cwconint: cwconint$1, - cwint: cwint$1, - cylcty: cylcty$1, - dArr: dArr$1, - dHar: dHar$1, - dagger: dagger$1, - daleth: daleth$1, - darr: darr$1, - dash: dash$1, - dashv: dashv$1, - dbkarow: dbkarow$1, - dblac: dblac$1, - dcaron: dcaron$1, - dcy: dcy$1, - dd: dd$1, - ddagger: ddagger$1, - ddarr: ddarr$1, - ddotseq: ddotseq$1, - de: de$1, - deg: deg$1, - delta: delta$1, - demptyv: demptyv$1, - dfisht: dfisht$1, - dfr: dfr$1, - dharl: dharl$1, - dharr: dharr$1, - diam: diam$1, - diamond: diamond$1, - diamondsuit: diamondsuit$1, - diams: diams$1, - die: die$1, - digamma: digamma$1, - disin: disin$1, - div: div$1, - divid: divid$1, - divide: divide$1, - divideontimes: divideontimes$1, - divonx: divonx$1, - djcy: djcy$1, - dlcorn: dlcorn$1, - dlcrop: dlcrop$1, - dollar: dollar$1, - dopf: dopf$1, - dot: dot$1, - doteq: doteq$1, - doteqdot: doteqdot$1, - dotminus: dotminus$1, - dotplus: dotplus$1, - dotsquare: dotsquare$1, - doublebarwedge: doublebarwedge$1, - downarrow: downarrow$1, - downdownarrows: downdownarrows$1, - downharpoonleft: downharpoonleft$1, - downharpoonright: downharpoonright$1, - drbkarow: drbkarow$1, - drcorn: drcorn$1, - drcrop: drcrop$1, - dscr: dscr$1, - dscy: dscy$1, - dsol: dsol$1, - dstrok: dstrok$1, - dtdot: dtdot$1, - dtri: dtri$1, - dtrif: dtrif$1, - duarr: duarr$1, - duhar: duhar$1, - dwangle: dwangle$1, - dzcy: dzcy$1, - dzigrarr: dzigrarr$1, - eDDot: eDDot$1, - eDot: eDot$1, - eacut: eacut$1, - eacute: eacute$1, - easter: easter$1, - ecaron: ecaron$1, - ecir: ecir$1, - ecirc: ecirc$1, - ecolon: ecolon$1, - ecy: ecy$1, - edot: edot$1, - ee: ee$1, - efDot: efDot$1, - efr: efr$1, - eg: eg$1, - egrav: egrav$1, - egrave: egrave$1, - egs: egs$1, - egsdot: egsdot$1, - el: el$1, - elinters: elinters$1, - ell: ell$1, - els: els$1, - elsdot: elsdot$1, - emacr: emacr$1, - empty: empty$1, - emptyset: emptyset$1, - emptyv: emptyv$1, - emsp13: emsp13$1, - emsp14: emsp14$1, - emsp: emsp$1, - eng: eng$1, - ensp: ensp$1, - eogon: eogon$1, - eopf: eopf$1, - epar: epar$1, - eparsl: eparsl$1, - eplus: eplus$1, - epsi: epsi$1, - epsilon: epsilon$1, - epsiv: epsiv$1, - eqcirc: eqcirc$1, - eqcolon: eqcolon$1, - eqsim: eqsim$1, - eqslantgtr: eqslantgtr$1, - eqslantless: eqslantless$1, - equals: equals$1, - equest: equest$1, - equiv: equiv$1, - equivDD: equivDD$1, - eqvparsl: eqvparsl$1, - erDot: erDot$1, - erarr: erarr$1, - escr: escr$1, - esdot: esdot$1, - esim: esim$1, - eta: eta$1, - et: et$1, - eth: eth$1, - eum: eum$1, - euml: euml$1, - euro: euro$1, - excl: excl$1, - exist: exist$1, - expectation: expectation$1, - exponentiale: exponentiale$1, - fallingdotseq: fallingdotseq$1, - fcy: fcy$1, - female: female$1, - ffilig: ffilig$1, - fflig: fflig$1, - ffllig: ffllig$1, - ffr: ffr$1, - filig: filig$1, - fjlig: fjlig$1, - flat: flat$1, - fllig: fllig$1, - fltns: fltns$1, - fnof: fnof$1, - fopf: fopf$1, - forall: forall$1, - fork: fork$1, - forkv: forkv$1, - fpartint: fpartint$1, - frac1: frac1$1, - frac12: frac12$1, - frac13: frac13$1, - frac14: frac14$1, - frac15: frac15$1, - frac16: frac16$1, - frac18: frac18$1, - frac23: frac23$1, - frac25: frac25$1, - frac3: frac3$1, - frac34: frac34$1, - frac35: frac35$1, - frac38: frac38$1, - frac45: frac45$1, - frac56: frac56$1, - frac58: frac58$1, - frac78: frac78$1, - frasl: frasl$1, - frown: frown$1, - fscr: fscr$1, - gE: gE$1, - gEl: gEl$1, - gacute: gacute$1, - gamma: gamma$1, - gammad: gammad$1, - gap: gap$1, - gbreve: gbreve$1, - gcirc: gcirc$1, - gcy: gcy$1, - gdot: gdot$1, - ge: ge$1, - gel: gel$1, - geq: geq$1, - geqq: geqq$1, - geqslant: geqslant$1, - ges: ges$1, - gescc: gescc$1, - gesdot: gesdot$1, - gesdoto: gesdoto$1, - gesdotol: gesdotol$1, - gesl: gesl$1, - gesles: gesles$1, - gfr: gfr$1, - gg: gg$1, - ggg: ggg$1, - gimel: gimel$1, - gjcy: gjcy$1, - gl: gl$1, - glE: glE$1, - gla: gla$1, - glj: glj$1, - gnE: gnE$1, - gnap: gnap$1, - gnapprox: gnapprox$1, - gne: gne$1, - gneq: gneq$1, - gneqq: gneqq$1, - gnsim: gnsim$1, - gopf: gopf$1, - grave: grave$1, - gscr: gscr$1, - gsim: gsim$1, - gsime: gsime$1, - gsiml: gsiml$1, - g: g$1, - gt: gt$1, - gtcc: gtcc$1, - gtcir: gtcir$1, - gtdot: gtdot$1, - gtlPar: gtlPar$1, - gtquest: gtquest$1, - gtrapprox: gtrapprox$1, - gtrarr: gtrarr$1, - gtrdot: gtrdot$1, - gtreqless: gtreqless$1, - gtreqqless: gtreqqless$1, - gtrless: gtrless$1, - gtrsim: gtrsim$1, - gvertneqq: gvertneqq$1, - gvnE: gvnE$1, - hArr: hArr$1, - hairsp: hairsp$1, - half: half$1, - hamilt: hamilt$1, - hardcy: hardcy$1, - harr: harr$1, - harrcir: harrcir$1, - harrw: harrw$1, - hbar: hbar$1, - hcirc: hcirc$1, - hearts: hearts$1, - heartsuit: heartsuit$1, - hellip: hellip$1, - hercon: hercon$1, - hfr: hfr$1, - hksearow: hksearow$1, - hkswarow: hkswarow$1, - hoarr: hoarr$1, - homtht: homtht$1, - hookleftarrow: hookleftarrow$1, - hookrightarrow: hookrightarrow$1, - hopf: hopf$1, - horbar: horbar$1, - hscr: hscr$1, - hslash: hslash$1, - hstrok: hstrok$1, - hybull: hybull$1, - hyphen: hyphen$1, - iacut: iacut$1, - iacute: iacute$1, - ic: ic$1, - icir: icir$1, - icirc: icirc$1, - icy: icy$1, - iecy: iecy$1, - iexc: iexc$1, - iexcl: iexcl$1, - iff: iff$1, - ifr: ifr$1, - igrav: igrav$1, - igrave: igrave$1, - ii: ii$1, - iiiint: iiiint$1, - iiint: iiint$1, - iinfin: iinfin$1, - iiota: iiota$1, - ijlig: ijlig$1, - imacr: imacr$1, - image: image$2, - imagline: imagline$1, - imagpart: imagpart$1, - imath: imath$1, - imof: imof$1, - imped: imped$1, - "in": "∈", - incare: incare$1, - infin: infin$1, - infintie: infintie$1, - inodot: inodot$1, - int: int$2, - intcal: intcal$1, - integers: integers$1, - intercal: intercal$1, - intlarhk: intlarhk$1, - intprod: intprod$1, - iocy: iocy$1, - iogon: iogon$1, - iopf: iopf$1, - iota: iota$1, - iprod: iprod$1, - iques: iques$1, - iquest: iquest$1, - iscr: iscr$1, - isin: isin$1, - isinE: isinE$1, - isindot: isindot$1, - isins: isins$1, - isinsv: isinsv$1, - isinv: isinv$1, - it: it$1, - itilde: itilde$1, - iukcy: iukcy$1, - ium: ium$1, - iuml: iuml$1, - jcirc: jcirc$1, - jcy: jcy$1, - jfr: jfr$1, - jmath: jmath$1, - jopf: jopf$1, - jscr: jscr$1, - jsercy: jsercy$1, - jukcy: jukcy$1, - kappa: kappa$1, - kappav: kappav$1, - kcedil: kcedil$1, - kcy: kcy$1, - kfr: kfr$1, - kgreen: kgreen$1, - khcy: khcy$1, - kjcy: kjcy$1, - kopf: kopf$1, - kscr: kscr$1, - lAarr: lAarr$1, - lArr: lArr$1, - lAtail: lAtail$1, - lBarr: lBarr$1, - lE: lE$1, - lEg: lEg$1, - lHar: lHar$1, - lacute: lacute$1, - laemptyv: laemptyv$1, - lagran: lagran$1, - lambda: lambda$1, - lang: lang$1, - langd: langd$1, - langle: langle$1, - lap: lap$1, - laqu: laqu$1, - laquo: laquo$1, - larr: larr$1, - larrb: larrb$1, - larrbfs: larrbfs$1, - larrfs: larrfs$1, - larrhk: larrhk$1, - larrlp: larrlp$1, - larrpl: larrpl$1, - larrsim: larrsim$1, - larrtl: larrtl$1, - lat: lat$1, - latail: latail$1, - late: late$1, - lates: lates$1, - lbarr: lbarr$1, - lbbrk: lbbrk$1, - lbrace: lbrace$1, - lbrack: lbrack$1, - lbrke: lbrke$1, - lbrksld: lbrksld$1, - lbrkslu: lbrkslu$1, - lcaron: lcaron$1, - lcedil: lcedil$1, - lceil: lceil$1, - lcub: lcub$1, - lcy: lcy$1, - ldca: ldca$1, - ldquo: ldquo$1, - ldquor: ldquor$1, - ldrdhar: ldrdhar$1, - ldrushar: ldrushar$1, - ldsh: ldsh$1, - le: le$1, - leftarrow: leftarrow$1, - leftarrowtail: leftarrowtail$1, - leftharpoondown: leftharpoondown$1, - leftharpoonup: leftharpoonup$1, - leftleftarrows: leftleftarrows$1, - leftrightarrow: leftrightarrow$1, - leftrightarrows: leftrightarrows$1, - leftrightharpoons: leftrightharpoons$1, - leftrightsquigarrow: leftrightsquigarrow$1, - leftthreetimes: leftthreetimes$1, - leg: leg$1, - leq: leq$1, - leqq: leqq$1, - leqslant: leqslant$1, - les: les$1, - lescc: lescc$1, - lesdot: lesdot$1, - lesdoto: lesdoto$1, - lesdotor: lesdotor$1, - lesg: lesg$1, - lesges: lesges$1, - lessapprox: lessapprox$1, - lessdot: lessdot$1, - lesseqgtr: lesseqgtr$1, - lesseqqgtr: lesseqqgtr$1, - lessgtr: lessgtr$1, - lesssim: lesssim$1, - lfisht: lfisht$1, - lfloor: lfloor$1, - lfr: lfr$1, - lg: lg$1, - lgE: lgE$1, - lhard: lhard$1, - lharu: lharu$1, - lharul: lharul$1, - lhblk: lhblk$1, - ljcy: ljcy$1, - ll: ll$1, - llarr: llarr$1, - llcorner: llcorner$1, - llhard: llhard$1, - lltri: lltri$1, - lmidot: lmidot$1, - lmoust: lmoust$1, - lmoustache: lmoustache$1, - lnE: lnE$1, - lnap: lnap$1, - lnapprox: lnapprox$1, - lne: lne$1, - lneq: lneq$1, - lneqq: lneqq$1, - lnsim: lnsim$1, - loang: loang$1, - loarr: loarr$1, - lobrk: lobrk$1, - longleftarrow: longleftarrow$1, - longleftrightarrow: longleftrightarrow$1, - longmapsto: longmapsto$1, - longrightarrow: longrightarrow$1, - looparrowleft: looparrowleft$1, - looparrowright: looparrowright$1, - lopar: lopar$1, - lopf: lopf$1, - loplus: loplus$1, - lotimes: lotimes$1, - lowast: lowast$1, - lowbar: lowbar$1, - loz: loz$1, - lozenge: lozenge$1, - lozf: lozf$1, - lpar: lpar$1, - lparlt: lparlt$1, - lrarr: lrarr$1, - lrcorner: lrcorner$1, - lrhar: lrhar$1, - lrhard: lrhard$1, - lrm: lrm$1, - lrtri: lrtri$1, - lsaquo: lsaquo$1, - lscr: lscr$1, - lsh: lsh$1, - lsim: lsim$1, - lsime: lsime$1, - lsimg: lsimg$1, - lsqb: lsqb$1, - lsquo: lsquo$1, - lsquor: lsquor$1, - lstrok: lstrok$1, - l: l$1, - lt: lt$2, - ltcc: ltcc$1, - ltcir: ltcir$1, - ltdot: ltdot$1, - lthree: lthree$1, - ltimes: ltimes$1, - ltlarr: ltlarr$1, - ltquest: ltquest$1, - ltrPar: ltrPar$1, - ltri: ltri$1, - ltrie: ltrie$1, - ltrif: ltrif$1, - lurdshar: lurdshar$1, - luruhar: luruhar$1, - lvertneqq: lvertneqq$1, - lvnE: lvnE$1, - mDDot: mDDot$1, - mac: mac$1, - macr: macr$1, - male: male$1, - malt: malt$1, - maltese: maltese$1, - map: map$4, - mapsto: mapsto$1, - mapstodown: mapstodown$1, - mapstoleft: mapstoleft$1, - mapstoup: mapstoup$1, - marker: marker$1, - mcomma: mcomma$1, - mcy: mcy$1, - mdash: mdash$1, - measuredangle: measuredangle$1, - mfr: mfr$1, - mho: mho$1, - micr: micr$1, - micro: micro$1, - mid: mid$1, - midast: midast$1, - midcir: midcir$1, - middo: middo$1, - middot: middot$1, - minus: minus$1, - minusb: minusb$1, - minusd: minusd$1, - minusdu: minusdu$1, - mlcp: mlcp$1, - mldr: mldr$1, - mnplus: mnplus$1, - models: models$1, - mopf: mopf$1, - mp: mp$1, - mscr: mscr$1, - mstpos: mstpos$1, - mu: mu$1, - multimap: multimap$1, - mumap: mumap$1, - nGg: nGg$1, - nGt: nGt$1, - nGtv: nGtv$1, - nLeftarrow: nLeftarrow$1, - nLeftrightarrow: nLeftrightarrow$1, - nLl: nLl$1, - nLt: nLt$1, - nLtv: nLtv$1, - nRightarrow: nRightarrow$1, - nVDash: nVDash$1, - nVdash: nVdash$1, - nabla: nabla$1, - nacute: nacute$1, - nang: nang$1, - nap: nap$1, - napE: napE$1, - napid: napid$1, - napos: napos$1, - napprox: napprox$1, - natur: natur$1, - natural: natural$1, - naturals: naturals$1, - nbs: nbs$1, - nbsp: nbsp$1, - nbump: nbump$1, - nbumpe: nbumpe$1, - ncap: ncap$1, - ncaron: ncaron$1, - ncedil: ncedil$1, - ncong: ncong$1, - ncongdot: ncongdot$1, - ncup: ncup$1, - ncy: ncy$1, - ndash: ndash$1, - ne: ne$1, - neArr: neArr$1, - nearhk: nearhk$1, - nearr: nearr$1, - nearrow: nearrow$1, - nedot: nedot$1, - nequiv: nequiv$1, - nesear: nesear$1, - nesim: nesim$1, - nexist: nexist$1, - nexists: nexists$1, - nfr: nfr$1, - ngE: ngE$1, - nge: nge$1, - ngeq: ngeq$1, - ngeqq: ngeqq$1, - ngeqslant: ngeqslant$1, - nges: nges$1, - ngsim: ngsim$1, - ngt: ngt$1, - ngtr: ngtr$1, - nhArr: nhArr$1, - nharr: nharr$1, - nhpar: nhpar$1, - ni: ni$1, - nis: nis$1, - nisd: nisd$1, - niv: niv$1, - njcy: njcy$1, - nlArr: nlArr$1, - nlE: nlE$1, - nlarr: nlarr$1, - nldr: nldr$1, - nle: nle$1, - nleftarrow: nleftarrow$1, - nleftrightarrow: nleftrightarrow$1, - nleq: nleq$1, - nleqq: nleqq$1, - nleqslant: nleqslant$1, - nles: nles$1, - nless: nless$1, - nlsim: nlsim$1, - nlt: nlt$1, - nltri: nltri$1, - nltrie: nltrie$1, - nmid: nmid$1, - nopf: nopf$1, - no: no$1, - not: not$1, - notin: notin$1, - notinE: notinE$1, - notindot: notindot$1, - notinva: notinva$1, - notinvb: notinvb$1, - notinvc: notinvc$1, - notni: notni$1, - notniva: notniva$1, - notnivb: notnivb$1, - notnivc: notnivc$1, - npar: npar$1, - nparallel: nparallel$1, - nparsl: nparsl$1, - npart: npart$1, - npolint: npolint$1, - npr: npr$1, - nprcue: nprcue$1, - npre: npre$1, - nprec: nprec$1, - npreceq: npreceq$1, - nrArr: nrArr$1, - nrarr: nrarr$1, - nrarrc: nrarrc$1, - nrarrw: nrarrw$1, - nrightarrow: nrightarrow$1, - nrtri: nrtri$1, - nrtrie: nrtrie$1, - nsc: nsc$1, - nsccue: nsccue$1, - nsce: nsce$1, - nscr: nscr$1, - nshortmid: nshortmid$1, - nshortparallel: nshortparallel$1, - nsim: nsim$1, - nsime: nsime$1, - nsimeq: nsimeq$1, - nsmid: nsmid$1, - nspar: nspar$1, - nsqsube: nsqsube$1, - nsqsupe: nsqsupe$1, - nsub: nsub$1, - nsubE: nsubE$1, - nsube: nsube$1, - nsubset: nsubset$1, - nsubseteq: nsubseteq$1, - nsubseteqq: nsubseteqq$1, - nsucc: nsucc$1, - nsucceq: nsucceq$1, - nsup: nsup$1, - nsupE: nsupE$1, - nsupe: nsupe$1, - nsupset: nsupset$1, - nsupseteq: nsupseteq$1, - nsupseteqq: nsupseteqq$1, - ntgl: ntgl$1, - ntild: ntild$1, - ntilde: ntilde$1, - ntlg: ntlg$1, - ntriangleleft: ntriangleleft$1, - ntrianglelefteq: ntrianglelefteq$1, - ntriangleright: ntriangleright$1, - ntrianglerighteq: ntrianglerighteq$1, - nu: nu$1, - num: num$1, - numero: numero$1, - numsp: numsp$1, - nvDash: nvDash$1, - nvHarr: nvHarr$1, - nvap: nvap$1, - nvdash: nvdash$1, - nvge: nvge$1, - nvgt: nvgt$1, - nvinfin: nvinfin$1, - nvlArr: nvlArr$1, - nvle: nvle$1, - nvlt: nvlt$1, - nvltrie: nvltrie$1, - nvrArr: nvrArr$1, - nvrtrie: nvrtrie$1, - nvsim: nvsim$1, - nwArr: nwArr$1, - nwarhk: nwarhk$1, - nwarr: nwarr$1, - nwarrow: nwarrow$1, - nwnear: nwnear$1, - oS: oS$1, - oacut: oacut$1, - oacute: oacute$1, - oast: oast$1, - ocir: ocir$1, - ocirc: ocirc$1, - ocy: ocy$1, - odash: odash$1, - odblac: odblac$1, - odiv: odiv$1, - odot: odot$1, - odsold: odsold$1, - oelig: oelig$1, - ofcir: ofcir$1, - ofr: ofr$1, - ogon: ogon$1, - ograv: ograv$1, - ograve: ograve$1, - ogt: ogt$1, - ohbar: ohbar$1, - ohm: ohm$1, - oint: oint$1, - olarr: olarr$1, - olcir: olcir$1, - olcross: olcross$1, - oline: oline$1, - olt: olt$1, - omacr: omacr$1, - omega: omega$1, - omicron: omicron$1, - omid: omid$1, - ominus: ominus$1, - oopf: oopf$1, - opar: opar$1, - operp: operp$1, - oplus: oplus$1, - or: or$1, - orarr: orarr$1, - ord: ord$1, - order: order$1, - orderof: orderof$1, - ordf: ordf$1, - ordm: ordm$1, - origof: origof$1, - oror: oror$1, - orslope: orslope$1, - orv: orv$1, - oscr: oscr$1, - oslas: oslas$1, - oslash: oslash$1, - osol: osol$1, - otild: otild$1, - otilde: otilde$1, - otimes: otimes$1, - otimesas: otimesas$1, - oum: oum$1, - ouml: ouml$1, - ovbar: ovbar$1, - par: par$1, - para: para$1, - parallel: parallel$1, - parsim: parsim$1, - parsl: parsl$1, - part: part$1, - pcy: pcy$1, - percnt: percnt$1, - period: period$1, - permil: permil$1, - perp: perp$1, - pertenk: pertenk$1, - pfr: pfr$1, - phi: phi$1, - phiv: phiv$1, - phmmat: phmmat$1, - phone: phone$1, - pi: pi$1, - pitchfork: pitchfork$1, - piv: piv$1, - planck: planck$1, - planckh: planckh$1, - plankv: plankv$1, - plus: plus$1, - plusacir: plusacir$1, - plusb: plusb$1, - pluscir: pluscir$1, - plusdo: plusdo$1, - plusdu: plusdu$1, - pluse: pluse$1, - plusm: plusm$1, - plusmn: plusmn$1, - plussim: plussim$1, - plustwo: plustwo$1, - pm: pm$1, - pointint: pointint$1, - popf: popf$1, - poun: poun$1, - pound: pound$1, - pr: pr$1, - prE: prE$1, - prap: prap$1, - prcue: prcue$1, - pre: pre$1, - prec: prec$1, - precapprox: precapprox$1, - preccurlyeq: preccurlyeq$1, - preceq: preceq$1, - precnapprox: precnapprox$1, - precneqq: precneqq$1, - precnsim: precnsim$1, - precsim: precsim$1, - prime: prime$1, - primes: primes$1, - prnE: prnE$1, - prnap: prnap$1, - prnsim: prnsim$1, - prod: prod$1, - profalar: profalar$1, - profline: profline$1, - profsurf: profsurf$1, - prop: prop$1, - propto: propto$1, - prsim: prsim$1, - prurel: prurel$1, - pscr: pscr$1, - psi: psi$1, - puncsp: puncsp$1, - qfr: qfr$1, - qint: qint$1, - qopf: qopf$1, - qprime: qprime$1, - qscr: qscr$1, - quaternions: quaternions$1, - quatint: quatint$1, - quest: quest$1, - questeq: questeq$1, - quo: quo$1, - quot: quot$1, - rAarr: rAarr$1, - rArr: rArr$1, - rAtail: rAtail$1, - rBarr: rBarr$1, - rHar: rHar$1, - race: race$1, - racute: racute$1, - radic: radic$1, - raemptyv: raemptyv$1, - rang: rang$1, - rangd: rangd$1, - range: range$1, - rangle: rangle$1, - raqu: raqu$1, - raquo: raquo$1, - rarr: rarr$1, - rarrap: rarrap$1, - rarrb: rarrb$1, - rarrbfs: rarrbfs$1, - rarrc: rarrc$1, - rarrfs: rarrfs$1, - rarrhk: rarrhk$1, - rarrlp: rarrlp$1, - rarrpl: rarrpl$1, - rarrsim: rarrsim$1, - rarrtl: rarrtl$1, - rarrw: rarrw$1, - ratail: ratail$1, - ratio: ratio$1, - rationals: rationals$1, - rbarr: rbarr$1, - rbbrk: rbbrk$1, - rbrace: rbrace$1, - rbrack: rbrack$1, - rbrke: rbrke$1, - rbrksld: rbrksld$1, - rbrkslu: rbrkslu$1, - rcaron: rcaron$1, - rcedil: rcedil$1, - rceil: rceil$1, - rcub: rcub$1, - rcy: rcy$1, - rdca: rdca$1, - rdldhar: rdldhar$1, - rdquo: rdquo$1, - rdquor: rdquor$1, - rdsh: rdsh$1, - real: real$1, - realine: realine$1, - realpart: realpart$1, - reals: reals$1, - rect: rect$1, - re: re$5, - reg: reg$1, - rfisht: rfisht$1, - rfloor: rfloor$1, - rfr: rfr$1, - rhard: rhard$1, - rharu: rharu$1, - rharul: rharul$1, - rho: rho$1, - rhov: rhov$1, - rightarrow: rightarrow$1, - rightarrowtail: rightarrowtail$1, - rightharpoondown: rightharpoondown$1, - rightharpoonup: rightharpoonup$1, - rightleftarrows: rightleftarrows$1, - rightleftharpoons: rightleftharpoons$1, - rightrightarrows: rightrightarrows$1, - rightsquigarrow: rightsquigarrow$1, - rightthreetimes: rightthreetimes$1, - ring: ring$1, - risingdotseq: risingdotseq$1, - rlarr: rlarr$1, - rlhar: rlhar$1, - rlm: rlm$1, - rmoust: rmoust$1, - rmoustache: rmoustache$1, - rnmid: rnmid$1, - roang: roang$1, - roarr: roarr$1, - robrk: robrk$1, - ropar: ropar$1, - ropf: ropf$1, - roplus: roplus$1, - rotimes: rotimes$1, - rpar: rpar$1, - rpargt: rpargt$1, - rppolint: rppolint$1, - rrarr: rrarr$1, - rsaquo: rsaquo$1, - rscr: rscr$1, - rsh: rsh$1, - rsqb: rsqb$1, - rsquo: rsquo$1, - rsquor: rsquor$1, - rthree: rthree$1, - rtimes: rtimes$1, - rtri: rtri$1, - rtrie: rtrie$1, - rtrif: rtrif$1, - rtriltri: rtriltri$1, - ruluhar: ruluhar$1, - rx: rx$1, - sacute: sacute$1, - sbquo: sbquo$1, - sc: sc$1, - scE: scE$1, - scap: scap$1, - scaron: scaron$1, - sccue: sccue$1, - sce: sce$1, - scedil: scedil$1, - scirc: scirc$1, - scnE: scnE$1, - scnap: scnap$1, - scnsim: scnsim$1, - scpolint: scpolint$1, - scsim: scsim$1, - scy: scy$1, - sdot: sdot$1, - sdotb: sdotb$1, - sdote: sdote$1, - seArr: seArr$1, - searhk: searhk$1, - searr: searr$1, - searrow: searrow$1, - sec: sec$1, - sect: sect$1, - semi: semi$1, - seswar: seswar$1, - setminus: setminus$1, - setmn: setmn$1, - sext: sext$1, - sfr: sfr$1, - sfrown: sfrown$1, - sharp: sharp$1, - shchcy: shchcy$1, - shcy: shcy$1, - shortmid: shortmid$1, - shortparallel: shortparallel$1, - sh: sh$1, - shy: shy$1, - sigma: sigma$1, - sigmaf: sigmaf$1, - sigmav: sigmav$1, - sim: sim$1, - simdot: simdot$1, - sime: sime$1, - simeq: simeq$1, - simg: simg$1, - simgE: simgE$1, - siml: siml$1, - simlE: simlE$1, - simne: simne$1, - simplus: simplus$1, - simrarr: simrarr$1, - slarr: slarr$1, - smallsetminus: smallsetminus$1, - smashp: smashp$1, - smeparsl: smeparsl$1, - smid: smid$1, - smile: smile$1, - smt: smt$1, - smte: smte$1, - smtes: smtes$1, - softcy: softcy$1, - sol: sol$1, - solb: solb$1, - solbar: solbar$1, - sopf: sopf$1, - spades: spades$1, - spadesuit: spadesuit$1, - spar: spar$1, - sqcap: sqcap$1, - sqcaps: sqcaps$1, - sqcup: sqcup$1, - sqcups: sqcups$1, - sqsub: sqsub$1, - sqsube: sqsube$1, - sqsubset: sqsubset$1, - sqsubseteq: sqsubseteq$1, - sqsup: sqsup$1, - sqsupe: sqsupe$1, - sqsupset: sqsupset$1, - sqsupseteq: sqsupseteq$1, - squ: squ$1, - square: square$1, - squarf: squarf$1, - squf: squf$1, - srarr: srarr$1, - sscr: sscr$1, - ssetmn: ssetmn$1, - ssmile: ssmile$1, - sstarf: sstarf$1, - star: star$1, - starf: starf$1, - straightepsilon: straightepsilon$1, - straightphi: straightphi$1, - strns: strns$1, - sub: sub$1, - subE: subE$1, - subdot: subdot$1, - sube: sube$1, - subedot: subedot$1, - submult: submult$1, - subnE: subnE$1, - subne: subne$1, - subplus: subplus$1, - subrarr: subrarr$1, - subset: subset$1, - subseteq: subseteq$1, - subseteqq: subseteqq$1, - subsetneq: subsetneq$1, - subsetneqq: subsetneqq$1, - subsim: subsim$1, - subsub: subsub$1, - subsup: subsup$1, - succ: succ$1, - succapprox: succapprox$1, - succcurlyeq: succcurlyeq$1, - succeq: succeq$1, - succnapprox: succnapprox$1, - succneqq: succneqq$1, - succnsim: succnsim$1, - succsim: succsim$1, - sum: sum$1, - sung: sung$1, - sup: sup$1, - sup1: sup1$1, - sup2: sup2$1, - sup3: sup3$1, - supE: supE$1, - supdot: supdot$1, - supdsub: supdsub$1, - supe: supe$1, - supedot: supedot$1, - suphsol: suphsol$1, - suphsub: suphsub$1, - suplarr: suplarr$1, - supmult: supmult$1, - supnE: supnE$1, - supne: supne$1, - supplus: supplus$1, - supset: supset$1, - supseteq: supseteq$1, - supseteqq: supseteqq$1, - supsetneq: supsetneq$1, - supsetneqq: supsetneqq$1, - supsim: supsim$1, - supsub: supsub$1, - supsup: supsup$1, - swArr: swArr$1, - swarhk: swarhk$1, - swarr: swarr$1, - swarrow: swarrow$1, - swnwar: swnwar$1, - szli: szli$1, - szlig: szlig$1, - target: target$1, - tau: tau$1, - tbrk: tbrk$1, - tcaron: tcaron$1, - tcedil: tcedil$1, - tcy: tcy$1, - tdot: tdot$1, - telrec: telrec$1, - tfr: tfr$1, - there4: there4$1, - therefore: therefore$1, - theta: theta$1, - thetasym: thetasym$1, - thetav: thetav$1, - thickapprox: thickapprox$1, - thicksim: thicksim$1, - thinsp: thinsp$1, - thkap: thkap$1, - thksim: thksim$1, - thor: thor$1, - thorn: thorn$1, - tilde: tilde$1, - time: time$1, - times: times$1, - timesb: timesb$1, - timesbar: timesbar$1, - timesd: timesd$1, - tint: tint$1, - toea: toea$1, - top: top$1, - topbot: topbot$1, - topcir: topcir$1, - topf: topf$1, - topfork: topfork$1, - tosa: tosa$1, - tprime: tprime$1, - trade: trade$1, - triangle: triangle$1, - triangledown: triangledown$1, - triangleleft: triangleleft$1, - trianglelefteq: trianglelefteq$1, - triangleq: triangleq$1, - triangleright: triangleright$1, - trianglerighteq: trianglerighteq$1, - tridot: tridot$1, - trie: trie$1, - triminus: triminus$1, - triplus: triplus$1, - trisb: trisb$1, - tritime: tritime$1, - trpezium: trpezium$1, - tscr: tscr$1, - tscy: tscy$1, - tshcy: tshcy$1, - tstrok: tstrok$1, - twixt: twixt$1, - twoheadleftarrow: twoheadleftarrow$1, - twoheadrightarrow: twoheadrightarrow$1, - uArr: uArr$1, - uHar: uHar$1, - uacut: uacut$1, - uacute: uacute$1, - uarr: uarr$1, - ubrcy: ubrcy$1, - ubreve: ubreve$1, - ucir: ucir$1, - ucirc: ucirc$1, - ucy: ucy$1, - udarr: udarr$1, - udblac: udblac$1, - udhar: udhar$1, - ufisht: ufisht$1, - ufr: ufr$1, - ugrav: ugrav$1, - ugrave: ugrave$1, - uharl: uharl$1, - uharr: uharr$1, - uhblk: uhblk$1, - ulcorn: ulcorn$1, - ulcorner: ulcorner$1, - ulcrop: ulcrop$1, - ultri: ultri$1, - umacr: umacr$1, - um: um$1, - uml: uml$1, - uogon: uogon$1, - uopf: uopf$1, - uparrow: uparrow$1, - updownarrow: updownarrow$1, - upharpoonleft: upharpoonleft$1, - upharpoonright: upharpoonright$1, - uplus: uplus$1, - upsi: upsi$1, - upsih: upsih$1, - upsilon: upsilon$1, - upuparrows: upuparrows$1, - urcorn: urcorn$1, - urcorner: urcorner$1, - urcrop: urcrop$1, - uring: uring$1, - urtri: urtri$1, - uscr: uscr$1, - utdot: utdot$1, - utilde: utilde$1, - utri: utri$1, - utrif: utrif$1, - uuarr: uuarr$1, - uum: uum$1, - uuml: uuml$1, - uwangle: uwangle$1, - vArr: vArr$1, - vBar: vBar$1, - vBarv: vBarv$1, - vDash: vDash$1, - vangrt: vangrt$1, - varepsilon: varepsilon$1, - varkappa: varkappa$1, - varnothing: varnothing$1, - varphi: varphi$1, - varpi: varpi$1, - varpropto: varpropto$1, - varr: varr$1, - varrho: varrho$1, - varsigma: varsigma$1, - varsubsetneq: varsubsetneq$1, - varsubsetneqq: varsubsetneqq$1, - varsupsetneq: varsupsetneq$1, - varsupsetneqq: varsupsetneqq$1, - vartheta: vartheta$1, - vartriangleleft: vartriangleleft$1, - vartriangleright: vartriangleright$1, - vcy: vcy$1, - vdash: vdash$1, - vee: vee$1, - veebar: veebar$1, - veeeq: veeeq$1, - vellip: vellip$1, - verbar: verbar$1, - vert: vert$1, - vfr: vfr$1, - vltri: vltri$1, - vnsub: vnsub$1, - vnsup: vnsup$1, - vopf: vopf$1, - vprop: vprop$1, - vrtri: vrtri$1, - vscr: vscr$1, - vsubnE: vsubnE$1, - vsubne: vsubne$1, - vsupnE: vsupnE$1, - vsupne: vsupne$1, - vzigzag: vzigzag$1, - wcirc: wcirc$1, - wedbar: wedbar$1, - wedge: wedge$1, - wedgeq: wedgeq$1, - weierp: weierp$1, - wfr: wfr$1, - wopf: wopf$1, - wp: wp$1, - wr: wr$1, - wreath: wreath$1, - wscr: wscr$1, - xcap: xcap$1, - xcirc: xcirc$1, - xcup: xcup$1, - xdtri: xdtri$1, - xfr: xfr$1, - xhArr: xhArr$1, - xharr: xharr$1, - xi: xi$1, - xlArr: xlArr$1, - xlarr: xlarr$1, - xmap: xmap$1, - xnis: xnis$1, - xodot: xodot$1, - xopf: xopf$1, - xoplus: xoplus$1, - xotime: xotime$1, - xrArr: xrArr$1, - xrarr: xrarr$1, - xscr: xscr$1, - xsqcup: xsqcup$1, - xuplus: xuplus$1, - xutri: xutri$1, - xvee: xvee$1, - xwedge: xwedge$1, - yacut: yacut$1, - yacute: yacute$1, - yacy: yacy$1, - ycirc: ycirc$1, - ycy: ycy$1, - ye: ye$1, - yen: yen$1, - yfr: yfr$1, - yicy: yicy$1, - yopf: yopf$1, - yscr: yscr$1, - yucy: yucy$1, - yum: yum$1, - yuml: yuml$1, - zacute: zacute$1, - zcaron: zcaron$1, - zcy: zcy$1, - zdot: zdot$1, - zeetrf: zeetrf$1, - zeta: zeta$1, - zfr: zfr$1, - zhcy: zhcy$1, - zigrarr: zigrarr$1, - zopf: zopf$1, - zscr: zscr$1, - zwj: zwj$1, - zwnj: zwnj$1 -}; + function closingSequenceStart(code) { + effects.enter('codeFencedFence'); + effects.enter('codeFencedFenceSequence'); + return closingSequence(code) + } + /** @type {State} */ -var characterEntities$1 = require$$0$1; + function closingSequence(code) { + if (code === marker) { + effects.consume(code); + size++; + return closingSequence + } -var decodeEntity_1$1 = decodeEntity$1; + if (size < sizeOpen) return nok(code) + effects.exit('codeFencedFenceSequence'); + return factorySpace(effects, closingSequenceEnd, 'whitespace')(code) + } + /** @type {State} */ -var own$8 = {}.hasOwnProperty; + function closingSequenceEnd(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFencedFence'); + return ok(code) + } -function decodeEntity$1(characters) { - return own$8.call(characterEntities$1, characters) - ? characterEntities$1[characters] - : false + return nok(code) + } + } } -var dist = fromMarkdown$1; +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').State} State + */ + +/** @type {Construct} */ +const codeIndented = { + name: 'codeIndented', + tokenize: tokenizeCodeIndented +}; +/** @type {Construct} */ -// These three are compiled away in the `dist/` +const indentedContent = { + tokenize: tokenizeIndentedContent, + partial: true +}; +/** @type {Tokenizer} */ -var toString$4 = mdastUtilToString$1; -var assign = assign_1; -var own$7 = hasOwnProperty$2; -var normalizeIdentifier$1 = normalizeIdentifier_1; -var safeFromInt = safeFromInt_1; -var parser = parse_1$1; -var preprocessor = preprocess_1; -var postprocess = postprocess_1; -var decode$1 = decodeEntity_1$1; -var stringifyPosition$2 = unistUtilStringifyPosition; +function tokenizeCodeIndented(effects, ok, nok) { + const self = this; + return start + /** @type {State} */ -function fromMarkdown$1(value, encoding, options) { - if (typeof encoding !== 'string') { - options = encoding; - encoding = undefined; + function start(code) { + effects.enter('codeIndented'); + return factorySpace(effects, afterStartPrefix, 'linePrefix', 4 + 1)(code) } + /** @type {State} */ - return compiler(options)( - postprocess( - parser(options).document().write(preprocessor()(value, encoding, true)) - ) - ) -} + function afterStartPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ? afterPrefix(code) + : nok(code) + } + /** @type {State} */ -// Note this compiler only understand complete buffering, not streaming. -function compiler(options) { - var settings = options || {}; - var config = configure$2( - { - transforms: [], - canContainEols: [ - 'emphasis', - 'fragment', - 'heading', - 'paragraph', - 'strong' - ], - - enter: { - autolink: opener(link), - autolinkProtocol: onenterdata, - autolinkEmail: onenterdata, - atxHeading: opener(heading), - blockQuote: opener(blockQuote), - characterEscape: onenterdata, - characterReference: onenterdata, - codeFenced: opener(codeFlow), - codeFencedFenceInfo: buffer, - codeFencedFenceMeta: buffer, - codeIndented: opener(codeFlow, buffer), - codeText: opener(codeText, buffer), - codeTextData: onenterdata, - data: onenterdata, - codeFlowValue: onenterdata, - definition: opener(definition), - definitionDestinationString: buffer, - definitionLabelString: buffer, - definitionTitleString: buffer, - emphasis: opener(emphasis), - hardBreakEscape: opener(hardBreak), - hardBreakTrailing: opener(hardBreak), - htmlFlow: opener(html, buffer), - htmlFlowData: onenterdata, - htmlText: opener(html, buffer), - htmlTextData: onenterdata, - image: opener(image), - label: buffer, - link: opener(link), - listItem: opener(listItem), - listItemValue: onenterlistitemvalue, - listOrdered: opener(list, onenterlistordered), - listUnordered: opener(list), - paragraph: opener(paragraph), - reference: onenterreference, - referenceString: buffer, - resourceDestinationString: buffer, - resourceTitleString: buffer, - setextHeading: opener(heading), - strong: opener(strong), - thematicBreak: opener(thematicBreak) - }, - - exit: { - atxHeading: closer(), - atxHeadingSequence: onexitatxheadingsequence, - autolink: closer(), - autolinkEmail: onexitautolinkemail, - autolinkProtocol: onexitautolinkprotocol, - blockQuote: closer(), - characterEscapeValue: onexitdata, - characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, - characterReferenceMarkerNumeric: onexitcharacterreferencemarker, - characterReferenceValue: onexitcharacterreferencevalue, - codeFenced: closer(onexitcodefenced), - codeFencedFence: onexitcodefencedfence, - codeFencedFenceInfo: onexitcodefencedfenceinfo, - codeFencedFenceMeta: onexitcodefencedfencemeta, - codeFlowValue: onexitdata, - codeIndented: closer(onexitcodeindented), - codeText: closer(onexitcodetext), - codeTextData: onexitdata, - data: onexitdata, - definition: closer(), - definitionDestinationString: onexitdefinitiondestinationstring, - definitionLabelString: onexitdefinitionlabelstring, - definitionTitleString: onexitdefinitiontitlestring, - emphasis: closer(), - hardBreakEscape: closer(onexithardbreak), - hardBreakTrailing: closer(onexithardbreak), - htmlFlow: closer(onexithtmlflow), - htmlFlowData: onexitdata, - htmlText: closer(onexithtmltext), - htmlTextData: onexitdata, - image: closer(onexitimage), - label: onexitlabel, - labelText: onexitlabeltext, - lineEnding: onexitlineending, - link: closer(onexitlink), - listItem: closer(), - listOrdered: closer(), - listUnordered: closer(), - paragraph: closer(), - referenceString: onexitreferencestring, - resourceDestinationString: onexitresourcedestinationstring, - resourceTitleString: onexitresourcetitlestring, - resource: onexitresource, - setextHeading: closer(onexitsetextheading), - setextHeadingLineSequence: onexitsetextheadinglinesequence, - setextHeadingText: onexitsetextheadingtext, - strong: closer(), - thematicBreak: closer() - } - }, - - settings.mdastExtensions || [] - ); - - var data = {}; + function afterPrefix(code) { + if (code === null) { + return after(code) + } - return compile + if (markdownLineEnding(code)) { + return effects.attempt(indentedContent, afterPrefix, after)(code) + } - function compile(events) { - var tree = {type: 'root', children: []}; - var stack = [tree]; - var tokenStack = []; - var listStack = []; - var index = -1; - var handler; - var listStart; - - var context = { - stack: stack, - tokenStack: tokenStack, - config: config, - enter: enter, - exit: exit, - buffer: buffer, - resume: resume, - setData: setData, - getData: getData - }; + effects.enter('codeFlowValue'); + return content(code) + } + /** @type {State} */ - while (++index < events.length) { - // We preprocess lists to add `listItem` tokens, and to infer whether - // items the list itself are spread out. - if ( - events[index][1].type === 'listOrdered' || - events[index][1].type === 'listUnordered' - ) { - if (events[index][0] === 'enter') { - listStack.push(index); - } else { - listStart = listStack.pop(index); - index = prepareList(events, listStart, index); - } - } + function content(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFlowValue'); + return afterPrefix(code) } - index = -1; + effects.consume(code); + return content + } + /** @type {State} */ - while (++index < events.length) { - handler = config[events[index][0]]; + function after(code) { + effects.exit('codeIndented'); + return ok(code) + } +} +/** @type {Tokenizer} */ - if (own$7.call(handler, events[index][1].type)) { - handler[events[index][1].type].call( - assign({sliceSerialize: events[index][2].sliceSerialize}, context), - events[index][1] - ); - } +function tokenizeIndentedContent(effects, ok, nok) { + const self = this; + return start + /** @type {State} */ + + function start(code) { + // If this is a lazy line, it can’t be code. + if (self.parser.lazy[self.now().line]) { + return nok(code) } - if (tokenStack.length) { - throw new Error( - 'Cannot close document, a token (`' + - tokenStack[tokenStack.length - 1].type + - '`, ' + - stringifyPosition$2({ - start: tokenStack[tokenStack.length - 1].start, - end: tokenStack[tokenStack.length - 1].end - }) + - ') is still open' - ) + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return start } - // Figure out `root` position. - tree.position = { - start: point( - events.length ? events[0][1].start : {line: 1, column: 1, offset: 0} - ), + return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) + } + /** @type {State} */ - end: point( - events.length - ? events[events.length - 2][1].end - : {line: 1, column: 1, offset: 0} - ) - }; + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ? ok(code) + : markdownLineEnding(code) + ? start(code) + : nok(code) + } +} - index = -1; - while (++index < config.transforms.length) { - tree = config.transforms[index](tree) || tree; - } +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Previous} Previous + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').State} State + */ - return tree - } +/** @type {Construct} */ +const codeText = { + name: 'codeText', + tokenize: tokenizeCodeText, + resolve: resolveCodeText, + previous: previous$1 +}; +/** @type {Resolver} */ - function prepareList(events, start, length) { - var index = start - 1; - var containerBalance = -1; - var listSpread = false; - var listItem; - var tailIndex; - var lineIndex; - var tailEvent; - var event; - var firstBlankLineIndex; - var atMarker; +function resolveCodeText(events) { + let tailExitIndex = events.length - 4; + let headEnterIndex = 3; + /** @type {number} */ - while (++index <= length) { - event = events[index]; + let index; + /** @type {number|undefined} */ - if ( - event[1].type === 'listUnordered' || - event[1].type === 'listOrdered' || - event[1].type === 'blockQuote' - ) { - if (event[0] === 'enter') { - containerBalance++; - } else { - containerBalance--; - } + let enter; // If we start and end with an EOL or a space. - atMarker = undefined; - } else if (event[1].type === 'lineEndingBlank') { - if (event[0] === 'enter') { - if ( - listItem && - !atMarker && - !containerBalance && - !firstBlankLineIndex - ) { - firstBlankLineIndex = index; - } + if ( + (events[headEnterIndex][1].type === 'lineEnding' || + events[headEnterIndex][1].type === 'space') && + (events[tailExitIndex][1].type === 'lineEnding' || + events[tailExitIndex][1].type === 'space') + ) { + index = headEnterIndex; // And we have data. - atMarker = undefined; - } - } else if ( - event[1].type === 'linePrefix' || - event[1].type === 'listItemValue' || - event[1].type === 'listItemMarker' || - event[1].type === 'listItemPrefix' || - event[1].type === 'listItemPrefixWhitespace' - ) ; else { - atMarker = undefined; + while (++index < tailExitIndex) { + if (events[index][1].type === 'codeTextData') { + // Then we have padding. + events[headEnterIndex][1].type = 'codeTextPadding'; + events[tailExitIndex][1].type = 'codeTextPadding'; + headEnterIndex += 2; + tailExitIndex -= 2; + break } + } + } // Merge adjacent spaces and data. - if ( - (!containerBalance && - event[0] === 'enter' && - event[1].type === 'listItemPrefix') || - (containerBalance === -1 && - event[0] === 'exit' && - (event[1].type === 'listUnordered' || - event[1].type === 'listOrdered')) - ) { - if (listItem) { - tailIndex = index; - lineIndex = undefined; - - while (tailIndex--) { - tailEvent = events[tailIndex]; + index = headEnterIndex - 1; + tailExitIndex++; - if ( - tailEvent[1].type === 'lineEnding' || - tailEvent[1].type === 'lineEndingBlank' - ) { - if (tailEvent[0] === 'exit') continue + while (++index <= tailExitIndex) { + if (enter === undefined) { + if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') { + enter = index; + } + } else if ( + index === tailExitIndex || + events[index][1].type === 'lineEnding' + ) { + events[enter][1].type = 'codeTextData'; - if (lineIndex) { - events[lineIndex][1].type = 'lineEndingBlank'; - listSpread = true; - } + if (index !== enter + 2) { + events[enter][1].end = events[index - 1][1].end; + events.splice(enter + 2, index - enter - 2); + tailExitIndex -= index - enter - 2; + index = enter + 2; + } - tailEvent[1].type = 'lineEnding'; - lineIndex = tailIndex; - } else if ( - tailEvent[1].type === 'linePrefix' || - tailEvent[1].type === 'blockQuotePrefix' || - tailEvent[1].type === 'blockQuotePrefixWhitespace' || - tailEvent[1].type === 'blockQuoteMarker' || - tailEvent[1].type === 'listItemIndent' - ) ; else { - break - } - } + enter = undefined; + } + } - if ( - firstBlankLineIndex && - (!lineIndex || firstBlankLineIndex < lineIndex) - ) { - listItem._spread = true; - } + return events +} +/** @type {Previous} */ - // Fix position. - listItem.end = point( - lineIndex ? events[lineIndex][1].start : event[1].end - ); +function previous$1(code) { + // If there is a previous code, there will always be a tail. + return ( + code !== 96 || + this.events[this.events.length - 1][1].type === 'characterEscape' + ) +} +/** @type {Tokenizer} */ - events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]); - index++; - length++; - } +function tokenizeCodeText(effects, ok, nok) { + let sizeOpen = 0; + /** @type {number} */ - // Create a new list item. - if (event[1].type === 'listItemPrefix') { - listItem = { - type: 'listItem', - _spread: false, - start: point(event[1].start) - }; + let size; + /** @type {Token} */ - events.splice(index, 0, ['enter', listItem, event[2]]); - index++; - length++; - firstBlankLineIndex = undefined; - atMarker = true; - } - } - } + let token; + return start + /** @type {State} */ - events[start][1]._spread = listSpread; - return length + function start(code) { + effects.enter('codeText'); + effects.enter('codeTextSequence'); + return openingSequence(code) } + /** @type {State} */ - function setData(key, value) { - data[key] = value; - } + function openingSequence(code) { + if (code === 96) { + effects.consume(code); + sizeOpen++; + return openingSequence + } - function getData(key) { - return data[key] + effects.exit('codeTextSequence'); + return gap(code) } + /** @type {State} */ - function point(d) { - return {line: d.line, column: d.column, offset: d.offset} - } + function gap(code) { + // EOF. + if (code === null) { + return nok(code) + } // Closing fence? + // Could also be data. - function opener(create, and) { - return open + if (code === 96) { + token = effects.enter('codeTextSequence'); + size = 0; + return closingSequence(code) + } // Tabs don’t work, and virtual spaces don’t make sense. - function open(token) { - enter.call(this, create(token), token); - if (and) and.call(this, token); + if (code === 32) { + effects.enter('space'); + effects.consume(code); + effects.exit('space'); + return gap } - } - function buffer() { - this.stack.push({type: 'fragment', children: []}); - } + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return gap + } // Data. - function enter(node, token) { - this.stack[this.stack.length - 1].children.push(node); - this.stack.push(node); - this.tokenStack.push(token); - node.position = {start: point(token.start)}; - return node - } + effects.enter('codeTextData'); + return data(code) + } // In code. - function closer(and) { - return close + /** @type {State} */ - function close(token) { - if (and) and.call(this, token); - exit.call(this, token); + function data(code) { + if ( + code === null || + code === 32 || + code === 96 || + markdownLineEnding(code) + ) { + effects.exit('codeTextData'); + return gap(code) } - } - function exit(token) { - var node = this.stack.pop(); - var open = this.tokenStack.pop(); + effects.consume(code); + return data + } // Closing fence. - if (!open) { - throw new Error( - 'Cannot close `' + - token.type + - '` (' + - stringifyPosition$2({start: token.start, end: token.end}) + - '): it’s not open' - ) - } else if (open.type !== token.type) { - throw new Error( - 'Cannot close `' + - token.type + - '` (' + - stringifyPosition$2({start: token.start, end: token.end}) + - '): a different token (`' + - open.type + - '`, ' + - stringifyPosition$2({start: open.start, end: open.end}) + - ') is open' - ) - } + /** @type {State} */ - node.position.end = point(token.end); - return node - } + function closingSequence(code) { + // More. + if (code === 96) { + effects.consume(code); + size++; + return closingSequence + } // Done! - function resume() { - return toString$4(this.stack.pop()) + if (size === sizeOpen) { + effects.exit('codeTextSequence'); + effects.exit('codeText'); + return ok(code) + } // More or less accents: mark as data. + + token.type = 'codeTextData'; + return data(code) } +} - // - // Handlers. - // +/** + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Event} Event + */ - function onenterlistordered() { - setData('expectingFirstListItemValue', true); - } +/** + * Tokenize subcontent. + * + * @param {Event[]} events + * @returns {boolean} + */ +function subtokenize(events) { + /** @type {Record} */ + const jumps = {}; + let index = -1; + /** @type {Event} */ - function onenterlistitemvalue(token) { - if (getData('expectingFirstListItemValue')) { - this.stack[this.stack.length - 2].start = parseInt( - this.sliceSerialize(token), - 10 - ); + let event; + /** @type {number|undefined} */ - setData('expectingFirstListItemValue'); - } - } + let lineIndex; + /** @type {number} */ - function onexitcodefencedfenceinfo() { - var data = this.resume(); - this.stack[this.stack.length - 1].lang = data; - } + let otherIndex; + /** @type {Event} */ - function onexitcodefencedfencemeta() { - var data = this.resume(); - this.stack[this.stack.length - 1].meta = data; - } + let otherEvent; + /** @type {Event[]} */ - function onexitcodefencedfence() { - // Exit if this is the closing fence. - if (getData('flowCodeInside')) return - this.buffer(); - setData('flowCodeInside', true); - } + let parameters; + /** @type {Event[]} */ - function onexitcodefenced() { - var data = this.resume(); - this.stack[this.stack.length - 1].value = data.replace( - /^(\r?\n|\r)|(\r?\n|\r)$/g, - '' - ); - - setData('flowCodeInside'); - } - - function onexitcodeindented() { - var data = this.resume(); - this.stack[this.stack.length - 1].value = data; - } - - function onexitdefinitionlabelstring(token) { - // Discard label, use the source content instead. - var label = this.resume(); - this.stack[this.stack.length - 1].label = label; - this.stack[this.stack.length - 1].identifier = normalizeIdentifier$1( - this.sliceSerialize(token) - ).toLowerCase(); - } - - function onexitdefinitiontitlestring() { - var data = this.resume(); - this.stack[this.stack.length - 1].title = data; - } + let subevents; + /** @type {boolean|undefined} */ - function onexitdefinitiondestinationstring() { - var data = this.resume(); - this.stack[this.stack.length - 1].url = data; - } + let more; - function onexitatxheadingsequence(token) { - if (!this.stack[this.stack.length - 1].depth) { - this.stack[this.stack.length - 1].depth = this.sliceSerialize( - token - ).length; + while (++index < events.length) { + while (index in jumps) { + index = jumps[index]; } - } - function onexitsetextheadingtext() { - setData('setextHeadingSlurpLineEnding', true); - } + event = events[index]; // Add a hook for the GFM tasklist extension, which needs to know if text + // is in the first content of a list item. - function onexitsetextheadinglinesequence(token) { - this.stack[this.stack.length - 1].depth = - this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2; - } + if ( + index && + event[1].type === 'chunkFlow' && + events[index - 1][1].type === 'listItemPrefix' + ) { + subevents = event[1]._tokenizer.events; + otherIndex = 0; - function onexitsetextheading() { - setData('setextHeadingSlurpLineEnding'); - } + if ( + otherIndex < subevents.length && + subevents[otherIndex][1].type === 'lineEndingBlank' + ) { + otherIndex += 2; + } - function onenterdata(token) { - var siblings = this.stack[this.stack.length - 1].children; - var tail = siblings[siblings.length - 1]; + if ( + otherIndex < subevents.length && + subevents[otherIndex][1].type === 'content' + ) { + while (++otherIndex < subevents.length) { + if (subevents[otherIndex][1].type === 'content') { + break + } - if (!tail || tail.type !== 'text') { - // Add a new text node. - tail = text(); - tail.position = {start: point(token.start)}; - this.stack[this.stack.length - 1].children.push(tail); - } + if (subevents[otherIndex][1].type === 'chunkText') { + subevents[otherIndex][1]._isInFirstContentOfListItem = true; + otherIndex++; + } + } + } + } // Enter. - this.stack.push(tail); - } + if (event[0] === 'enter') { + if (event[1].contentType) { + Object.assign(jumps, subcontent(events, index)); + index = jumps[index]; + more = true; + } + } // Exit. + else if (event[1]._container) { + otherIndex = index; + lineIndex = undefined; - function onexitdata(token) { - var tail = this.stack.pop(); - tail.value += this.sliceSerialize(token); - tail.position.end = point(token.end); - } + while (otherIndex--) { + otherEvent = events[otherIndex]; - function onexitlineending(token) { - var context = this.stack[this.stack.length - 1]; + if ( + otherEvent[1].type === 'lineEnding' || + otherEvent[1].type === 'lineEndingBlank' + ) { + if (otherEvent[0] === 'enter') { + if (lineIndex) { + events[lineIndex][1].type = 'lineEndingBlank'; + } - // If we’re at a hard break, include the line ending in there. - if (getData('atHardBreak')) { - context.children[context.children.length - 1].position.end = point( - token.end - ); + otherEvent[1].type = 'lineEnding'; + lineIndex = otherIndex; + } + } else { + break + } + } - setData('atHardBreak'); - return - } + if (lineIndex) { + // Fix position. + event[1].end = Object.assign({}, events[lineIndex][1].start); // Switch container exit w/ line endings. - if ( - !getData('setextHeadingSlurpLineEnding') && - config.canContainEols.indexOf(context.type) > -1 - ) { - onenterdata.call(this, token); - onexitdata.call(this, token); + parameters = events.slice(lineIndex, index); + parameters.unshift(event); + splice(events, lineIndex, index - lineIndex + 1, parameters); + } } } - function onexithardbreak() { - setData('atHardBreak', true); - } + return !more +} +/** + * Tokenize embedded tokens. + * + * @param {Event[]} events + * @param {number} eventIndex + * @returns {Record} + */ - function onexithtmlflow() { - var data = this.resume(); - this.stack[this.stack.length - 1].value = data; - } +function subcontent(events, eventIndex) { + const token = events[eventIndex][1]; + const context = events[eventIndex][2]; + let startPosition = eventIndex - 1; + /** @type {number[]} */ - function onexithtmltext() { - var data = this.resume(); - this.stack[this.stack.length - 1].value = data; - } + const startPositions = []; + const tokenizer = + token._tokenizer || context.parser[token.contentType](token.start); + const childEvents = tokenizer.events; + /** @type {[number, number][]} */ - function onexitcodetext() { - var data = this.resume(); - this.stack[this.stack.length - 1].value = data; - } + const jumps = []; + /** @type {Record} */ - function onexitlink() { - var context = this.stack[this.stack.length - 1]; + const gaps = {}; + /** @type {Chunk[]} */ - // To do: clean. - if (getData('inReference')) { - context.type += 'Reference'; - context.referenceType = getData('referenceType') || 'shortcut'; - delete context.url; - delete context.title; - } else { - delete context.identifier; - delete context.label; - delete context.referenceType; - } + let stream; + /** @type {Token|undefined} */ - setData('referenceType'); - } + let previous; + let index = -1; + /** @type {Token|undefined} */ - function onexitimage() { - var context = this.stack[this.stack.length - 1]; + let current = token; + let adjust = 0; + let start = 0; + const breaks = [start]; // Loop forward through the linked tokens to pass them in order to the + // subtokenizer. - // To do: clean. - if (getData('inReference')) { - context.type += 'Reference'; - context.referenceType = getData('referenceType') || 'shortcut'; - delete context.url; - delete context.title; - } else { - delete context.identifier; - delete context.label; - delete context.referenceType; + while (current) { + // Find the position of the event for this token. + while (events[++startPosition][1] !== current) { + // Empty. } - setData('referenceType'); - } - - function onexitlabeltext(token) { - this.stack[this.stack.length - 2].identifier = normalizeIdentifier$1( - this.sliceSerialize(token) - ).toLowerCase(); - } - - function onexitlabel() { - var fragment = this.stack[this.stack.length - 1]; - var value = this.resume(); - - this.stack[this.stack.length - 1].label = value; - - // Assume a reference. - setData('inReference', true); + startPositions.push(startPosition); - if (this.stack[this.stack.length - 1].type === 'link') { - this.stack[this.stack.length - 1].children = fragment.children; - } else { - this.stack[this.stack.length - 1].alt = value; - } - } + if (!current._tokenizer) { + stream = context.sliceStream(current); - function onexitresourcedestinationstring() { - var data = this.resume(); - this.stack[this.stack.length - 1].url = data; - } + if (!current.next) { + stream.push(null); + } - function onexitresourcetitlestring() { - var data = this.resume(); - this.stack[this.stack.length - 1].title = data; - } + if (previous) { + tokenizer.defineSkip(current.start); + } - function onexitresource() { - setData('inReference'); - } + if (current._isInFirstContentOfListItem) { + tokenizer._gfmTasklistFirstContentOfListItem = true; + } - function onenterreference() { - setData('referenceType', 'collapsed'); - } + tokenizer.write(stream); - function onexitreferencestring(token) { - var label = this.resume(); - this.stack[this.stack.length - 1].label = label; - this.stack[this.stack.length - 1].identifier = normalizeIdentifier$1( - this.sliceSerialize(token) - ).toLowerCase(); - setData('referenceType', 'full'); - } + if (current._isInFirstContentOfListItem) { + tokenizer._gfmTasklistFirstContentOfListItem = undefined; + } + } // Unravel the next token. - function onexitcharacterreferencemarker(token) { - setData('characterReferenceType', token.type); - } + previous = current; + current = current.next; + } // Now, loop back through all events (and linked tokens), to figure out which + // parts belong where. - function onexitcharacterreferencevalue(token) { - var data = this.sliceSerialize(token); - var type = getData('characterReferenceType'); - var value; - var tail; + current = token; - if (type) { - value = safeFromInt( - data, - type === 'characterReferenceMarkerNumeric' ? 10 : 16 - ); + while (++index < childEvents.length) { + if ( + // Find a void token that includes a break. + childEvents[index][0] === 'exit' && + childEvents[index - 1][0] === 'enter' && + childEvents[index][1].type === childEvents[index - 1][1].type && + childEvents[index][1].start.line !== childEvents[index][1].end.line + ) { + start = index + 1; + breaks.push(start); // Help GC. - setData('characterReferenceType'); - } else { - value = decode$1(data); + current._tokenizer = undefined; + current.previous = undefined; + current = current.next; } + } // Help GC. - tail = this.stack.pop(); - tail.value += value; - tail.position.end = point(token.end); - } - - function onexitautolinkprotocol(token) { - onexitdata.call(this, token); - this.stack[this.stack.length - 1].url = this.sliceSerialize(token); - } - - function onexitautolinkemail(token) { - onexitdata.call(this, token); - this.stack[this.stack.length - 1].url = - 'mailto:' + this.sliceSerialize(token); - } + tokenizer.events = []; // If there’s one more token (which is the cases for lines that end in an + // EOF), that’s perfect: the last point we found starts it. + // If there isn’t then make sure any remaining content is added to it. - // - // Creaters. - // + if (current) { + // Help GC. + current._tokenizer = undefined; + current.previous = undefined; + } else { + breaks.pop(); + } // Now splice the events from the subtokenizer into the current events, + // moving back to front so that splice indices aren’t affected. - function blockQuote() { - return {type: 'blockquote', children: []} - } + index = breaks.length; - function codeFlow() { - return {type: 'code', lang: null, meta: null, value: ''} + while (index--) { + const slice = childEvents.slice(breaks[index], breaks[index + 1]); + const start = startPositions.pop(); + jumps.unshift([start, start + slice.length - 1]); + splice(events, start, 2, slice); } - function codeText() { - return {type: 'inlineCode', value: ''} - } + index = -1; - function definition() { - return { - type: 'definition', - identifier: '', - label: null, - title: null, - url: '' - } + while (++index < jumps.length) { + gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; + adjust += jumps[index][1] - jumps[index][0] - 1; } - function emphasis() { - return {type: 'emphasis', children: []} - } + return gaps +} - function heading() { - return {type: 'heading', depth: undefined, children: []} - } +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').State} State + */ - function hardBreak() { - return {type: 'break'} - } +/** + * No name because it must not be turned off. + * @type {Construct} + */ +const content = { + tokenize: tokenizeContent, + resolve: resolveContent +}; +/** @type {Construct} */ - function html() { - return {type: 'html', value: ''} - } +const continuationConstruct = { + tokenize: tokenizeContinuation, + partial: true +}; +/** + * Content is transparent: it’s parsed right now. That way, definitions are also + * parsed right now: before text in paragraphs (specifically, media) are parsed. + * + * @type {Resolver} + */ - function image() { - return {type: 'image', title: null, url: '', alt: null} - } +function resolveContent(events) { + subtokenize(events); + return events +} +/** @type {Tokenizer} */ - function link() { - return {type: 'link', title: null, url: '', children: []} - } +function tokenizeContent(effects, ok) { + /** @type {Token} */ + let previous; + return start + /** @type {State} */ - function list(token) { - return { - type: 'list', - ordered: token.type === 'listOrdered', - start: null, - spread: token._spread, - children: [] - } + function start(code) { + effects.enter('content'); + previous = effects.enter('chunkContent', { + contentType: 'content' + }); + return data(code) } + /** @type {State} */ - function listItem(token) { - return { - type: 'listItem', - spread: token._spread, - checked: null, - children: [] + function data(code) { + if (code === null) { + return contentEnd(code) } - } - function paragraph() { - return {type: 'paragraph', children: []} - } + if (markdownLineEnding(code)) { + return effects.check( + continuationConstruct, + contentContinue, + contentEnd + )(code) + } // Data. - function strong() { - return {type: 'strong', children: []} + effects.consume(code); + return data } + /** @type {State} */ - function text() { - return {type: 'text', value: ''} + function contentEnd(code) { + effects.exit('chunkContent'); + effects.exit('content'); + return ok(code) } + /** @type {State} */ - function thematicBreak() { - return {type: 'thematicBreak'} + function contentContinue(code) { + effects.consume(code); + effects.exit('chunkContent'); + previous.next = effects.enter('chunkContent', { + contentType: 'content', + previous + }); + previous = previous.next; + return data } } +/** @type {Tokenizer} */ -function configure$2(config, extensions) { - var index = -1; +function tokenizeContinuation(effects, ok, nok) { + const self = this; + return startLookahead + /** @type {State} */ - while (++index < extensions.length) { - extension(config, extensions[index]); + function startLookahead(code) { + effects.exit('chunkContent'); + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, prefixed, 'linePrefix') } + /** @type {State} */ - return config -} - -function extension(config, extension) { - var key; - var left; + function prefixed(code) { + if (code === null || markdownLineEnding(code)) { + return nok(code) + } - for (key in extension) { - left = own$7.call(config, key) ? config[key] : (config[key] = {}); + const tail = self.events[self.events.length - 1]; - if (key === 'canContainEols' || key === 'transforms') { - config[key] = [].concat(left, extension[key]); - } else { - Object.assign(left, extension[key]); + if ( + !self.parser.constructs.disable.null.includes('codeIndented') && + tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ) { + return ok(code) } + + return effects.interrupt(self.parser.constructs.flow, nok, ok)(code) } } -var mdastUtilFromMarkdown = dist; - -var remarkParse = parse$2; +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + */ -var fromMarkdown = mdastUtilFromMarkdown; +/** + * @param {Effects} effects + * @param {State} ok + * @param {State} nok + * @param {string} type + * @param {string} literalType + * @param {string} literalMarkerType + * @param {string} rawType + * @param {string} stringType + * @param {number} [max=Infinity] + * @returns {State} + */ +// eslint-disable-next-line max-params +function factoryDestination( + effects, + ok, + nok, + type, + literalType, + literalMarkerType, + rawType, + stringType, + max +) { + const limit = max || Number.POSITIVE_INFINITY; + let balance = 0; + return start + /** @type {State} */ -function parse$2(options) { - var self = this; + function start(code) { + if (code === 60) { + effects.enter(type); + effects.enter(literalType); + effects.enter(literalMarkerType); + effects.consume(code); + effects.exit(literalMarkerType); + return destinationEnclosedBefore + } - this.Parser = parse; + if (code === null || code === 41 || asciiControl(code)) { + return nok(code) + } - function parse(doc) { - return fromMarkdown( - doc, - Object.assign({}, self.data('settings'), options, { - // Note: these options are not in the readme. - // The goal is for them to be set by plugins on `data` instead of being - // passed by users. - extensions: self.data('micromarkExtensions') || [], - mdastExtensions: self.data('fromMarkdownExtensions') || [] - }) - ) + effects.enter(type); + effects.enter(rawType); + effects.enter(stringType); + effects.enter('chunkString', { + contentType: 'string' + }); + return destinationRaw(code) } -} - -var zwitch$1 = factory$4; + /** @type {State} */ -var noop$1 = Function.prototype; -var own$6 = {}.hasOwnProperty; + function destinationEnclosedBefore(code) { + if (code === 62) { + effects.enter(literalMarkerType); + effects.consume(code); + effects.exit(literalMarkerType); + effects.exit(literalType); + effects.exit(type); + return ok + } -// Handle values based on a property. -function factory$4(key, options) { - var settings = options || {}; + effects.enter(stringType); + effects.enter('chunkString', { + contentType: 'string' + }); + return destinationEnclosed(code) + } + /** @type {State} */ - function one(value) { - var fn = one.invalid; - var handlers = one.handlers; + function destinationEnclosed(code) { + if (code === 62) { + effects.exit('chunkString'); + effects.exit(stringType); + return destinationEnclosedBefore(code) + } - if (value && own$6.call(value, key)) { - fn = own$6.call(handlers, value[key]) ? handlers[value[key]] : one.unknown; + if (code === null || code === 60 || markdownLineEnding(code)) { + return nok(code) } - return (fn || noop$1).apply(this, arguments) + effects.consume(code); + return code === 92 ? destinationEnclosedEscape : destinationEnclosed } + /** @type {State} */ - one.handlers = settings.handlers || {}; - one.invalid = settings.invalid; - one.unknown = settings.unknown; + function destinationEnclosedEscape(code) { + if (code === 60 || code === 62 || code === 92) { + effects.consume(code); + return destinationEnclosed + } - return one -} + return destinationEnclosed(code) + } + /** @type {State} */ -var configure_1 = configure$1; + function destinationRaw(code) { + if (code === 40) { + if (++balance > limit) return nok(code) + effects.consume(code); + return destinationRaw + } -function configure$1(base, extension) { - var index = -1; - var key; + if (code === 41) { + if (!balance--) { + effects.exit('chunkString'); + effects.exit(stringType); + effects.exit(rawType); + effects.exit(type); + return ok(code) + } - // First do subextensions. - if (extension.extensions) { - while (++index < extension.extensions.length) { - configure$1(base, extension.extensions[index]); + effects.consume(code); + return destinationRaw } - } - for (key in extension) { - if (key === 'extensions') ; else if (key === 'unsafe' || key === 'join') { - base[key] = base[key].concat(extension[key] || []); - } else if (key === 'handlers') { - base[key] = Object.assign(base[key], extension[key] || {}); - } else { - base.options[key] = extension[key]; + if (code === null || markdownLineEndingOrSpace(code)) { + if (balance) return nok(code) + effects.exit('chunkString'); + effects.exit(stringType); + effects.exit(rawType); + effects.exit(type); + return ok(code) } + + if (asciiControl(code)) return nok(code) + effects.consume(code); + return code === 92 ? destinationRawEscape : destinationRaw } + /** @type {State} */ - return base -} + function destinationRawEscape(code) { + if (code === 40 || code === 41 || code === 92) { + effects.consume(code); + return destinationRaw + } -var handle = {}; + return destinationRaw(code) + } +} -var containerFlow$1 = flow$4; +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').State} State + */ -var repeat$5 = repeatString; +/** + * @this {TokenizeContext} + * @param {Effects} effects + * @param {State} ok + * @param {State} nok + * @param {string} type + * @param {string} markerType + * @param {string} stringType + * @returns {State} + */ +// eslint-disable-next-line max-params +function factoryLabel(effects, ok, nok, type, markerType, stringType) { + const self = this; + let size = 0; + /** @type {boolean} */ -function flow$4(parent, context) { - var children = parent.children || []; - var results = []; - var index = -1; - var child; + let data; + return start + /** @type {State} */ - while (++index < children.length) { - child = children[index]; + function start(code) { + effects.enter(type); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.enter(stringType); + return atBreak + } + /** @type {State} */ - results.push( - context.handle(child, parent, context, {before: '\n', after: '\n'}) - ); + function atBreak(code) { + if ( + code === null || + code === 91 || + (code === 93 && !data) || + /* Hidden footnotes hook */ - if (index + 1 < children.length) { - results.push(between(child, children[index + 1])); + /* c8 ignore next 3 */ + (code === 94 && + !size && + '_hiddenFootnoteSupport' in self.parser.constructs) || + size > 999 + ) { + return nok(code) } - } - return results.join('') + if (code === 93) { + effects.exit(stringType); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.exit(type); + return ok + } - function between(left, right) { - var index = -1; - var result; + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return atBreak + } - while (++index < context.join.length) { - result = context.join[index](left, right, parent, context); + effects.enter('chunkString', { + contentType: 'string' + }); + return label(code) + } + /** @type {State} */ - if (result === true || result === 1) { - break - } + function label(code) { + if ( + code === null || + code === 91 || + code === 93 || + markdownLineEnding(code) || + size++ > 999 + ) { + effects.exit('chunkString'); + return atBreak(code) + } - if (typeof result === 'number') { - return repeat$5('\n', 1 + Number(result)) - } + effects.consume(code); + data = data || !markdownSpace(code); + return code === 92 ? labelEscape : label + } + /** @type {State} */ - if (result === false) { - return '\n\n\n\n' - } + function labelEscape(code) { + if (code === 91 || code === 92 || code === 93) { + effects.consume(code); + size++; + return label } - return '\n\n' + return label(code) } } -var indentLines_1 = indentLines$4; - -var eol$1 = /\r?\n|\r/g; +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code + */ -function indentLines$4(value, map) { - var result = []; - var start = 0; - var line = 0; - var match; +/** + * @param {Effects} effects + * @param {State} ok + * @param {State} nok + * @param {string} type + * @param {string} markerType + * @param {string} stringType + * @returns {State} + */ +// eslint-disable-next-line max-params +function factoryTitle(effects, ok, nok, type, markerType, stringType) { + /** @type {NonNullable} */ + let marker; + return start + /** @type {State} */ - while ((match = eol$1.exec(value))) { - one(value.slice(start, match.index)); - result.push(match[0]); - start = match.index + match[0].length; - line++; + function start(code) { + effects.enter(type); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + marker = code === 40 ? 41 : code; + return atFirstTitleBreak } + /** @type {State} */ - one(value.slice(start)); - - return result.join('') + function atFirstTitleBreak(code) { + if (code === marker) { + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.exit(type); + return ok + } - function one(value) { - result.push(map(value, line, !value)); + effects.enter(stringType); + return atTitleBreak(code) } -} + /** @type {State} */ -var blockquote_1 = blockquote; + function atTitleBreak(code) { + if (code === marker) { + effects.exit(stringType); + return atFirstTitleBreak(marker) + } -var flow$3 = containerFlow$1; -var indentLines$3 = indentLines_1; + if (code === null) { + return nok(code) + } // Note: blank lines can’t exist in content. -function blockquote(node, _, context) { - var exit = context.enter('blockquote'); - var value = indentLines$3(flow$3(node, context), map$3); - exit(); - return value -} + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, atTitleBreak, 'linePrefix') + } -function map$3(line, index, blank) { - return '>' + (blank ? '' : ' ') + line -} + effects.enter('chunkString', { + contentType: 'string' + }); + return title(code) + } + /** @type {State} */ -var patternInScope_1 = patternInScope$2; + function title(code) { + if (code === marker || code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + return atTitleBreak(code) + } -function patternInScope$2(stack, pattern) { - return ( - listInScope(stack, pattern.inConstruct, true) && - !listInScope(stack, pattern.notInConstruct) - ) -} + effects.consume(code); + return code === 92 ? titleEscape : title + } + /** @type {State} */ -function listInScope(stack, list, none) { - var index; + function titleEscape(code) { + if (code === marker || code === 92) { + effects.consume(code); + return title + } - if (!list) { - return none + return title(code) } +} - if (typeof list === 'string') { - list = [list]; - } +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + */ - index = -1; +/** + * @param {Effects} effects + * @param {State} ok + */ +function factoryWhitespace(effects, ok) { + /** @type {boolean} */ + let seen; + return start + /** @type {State} */ - while (++index < list.length) { - if (stack.indexOf(list[index]) !== -1) { - return true + function start(code) { + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + seen = true; + return start + } + + if (markdownSpace(code)) { + return factorySpace( + effects, + start, + seen ? 'linePrefix' : 'lineSuffix' + )(code) } + + return ok(code) } +} - return false +/** + * Normalize an identifier (such as used in definitions). + * + * @param {string} value + * @returns {string} + */ +function normalizeIdentifier(value) { + return ( + value // Collapse Markdown whitespace. + .replace(/[\t\n\r ]+/g, ' ') // Trim. + .replace(/^ | $/g, '') // Some characters are considered “uppercase”, but if their lowercase + // counterpart is uppercased will result in a different uppercase + // character. + // Hence, to get that form, we perform both lower- and uppercase. + // Upper case makes sure keys will not interact with default prototypal + // methods: no method is uppercase. + .toLowerCase() + .toUpperCase() + ) } -var _break = hardBreak; +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + */ -var patternInScope$1 = patternInScope_1; +/** @type {Construct} */ +const definition$1 = { + name: 'definition', + tokenize: tokenizeDefinition +}; +/** @type {Construct} */ -function hardBreak(node, _, context, safe) { - var index = -1; +const titleConstruct = { + tokenize: tokenizeTitle, + partial: true +}; +/** @type {Tokenizer} */ - while (++index < context.unsafe.length) { - // If we can’t put eols in this construct (setext headings, tables), use a - // space instead. - if ( - context.unsafe[index].character === '\n' && - patternInScope$1(context.stack, context.unsafe[index]) - ) { - return /[ \t]/.test(safe.before) ? '' : ' ' - } +function tokenizeDefinition(effects, ok, nok) { + const self = this; + /** @type {string} */ + + let identifier; + return start + /** @type {State} */ + + function start(code) { + effects.enter('definition'); + return factoryLabel.call( + self, + effects, + labelAfter, + nok, + 'definitionLabel', + 'definitionLabelMarker', + 'definitionLabelString' + )(code) } + /** @type {State} */ - return '\\\n' -} + function labelAfter(code) { + identifier = normalizeIdentifier( + self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + ); -var longestStreak_1 = longestStreak; + if (code === 58) { + effects.enter('definitionMarker'); + effects.consume(code); + effects.exit('definitionMarker'); // Note: blank lines can’t exist in content. -// Get the count of the longest repeating streak of `character` in `value`. -function longestStreak(value, character) { - var count = 0; - var maximum = 0; - var expected; - var index; + return factoryWhitespace( + effects, + factoryDestination( + effects, + effects.attempt( + titleConstruct, + factorySpace(effects, after, 'whitespace'), + factorySpace(effects, after, 'whitespace') + ), + nok, + 'definitionDestination', + 'definitionDestinationLiteral', + 'definitionDestinationLiteralMarker', + 'definitionDestinationRaw', + 'definitionDestinationString' + ) + ) + } - if (typeof character !== 'string' || character.length !== 1) { - throw new Error('Expected character') + return nok(code) } + /** @type {State} */ - value = String(value); - index = value.indexOf(character); - expected = index; - - while (index !== -1) { - count++; + function after(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('definition'); - if (index === expected) { - if (count > maximum) { - maximum = count; + if (!self.parser.defined.includes(identifier)) { + self.parser.defined.push(identifier); } - } else { - count = 1; + + return ok(code) } - expected = index + 1; - index = value.indexOf(character, expected); + return nok(code) } - - return maximum } +/** @type {Tokenizer} */ -var formatCodeAsIndented_1 = formatCodeAsIndented$2; - -function formatCodeAsIndented$2(node, context) { - return ( - !context.options.fences && - node.value && - // If there’s no info… - !node.lang && - // And there’s a non-whitespace character… - /[^ \r\n]/.test(node.value) && - // And the value doesn’t start or end in a blank… - !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node.value) - ) -} +function tokenizeTitle(effects, ok, nok) { + return start + /** @type {State} */ -var checkFence_1 = checkFence$1; + function start(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, before)(code) + : nok(code) + } + /** @type {State} */ -function checkFence$1(context) { - var marker = context.options.fence || '`'; + function before(code) { + if (code === 34 || code === 39 || code === 40) { + return factoryTitle( + effects, + factorySpace(effects, after, 'whitespace'), + nok, + 'definitionTitle', + 'definitionTitleMarker', + 'definitionTitleString' + )(code) + } - if (marker !== '`' && marker !== '~') { - throw new Error( - 'Cannot serialize code with `' + - marker + - '` for `options.fence`, expected `` ` `` or `~`' - ) + return nok(code) } + /** @type {State} */ - return marker + function after(code) { + return code === null || markdownLineEnding(code) ? ok(code) : nok(code) + } } -var patternCompile_1 = patternCompile$3; +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + */ -function patternCompile$3(pattern) { - var before; - var after; +/** @type {Construct} */ +const hardBreakEscape = { + name: 'hardBreakEscape', + tokenize: tokenizeHardBreakEscape +}; +/** @type {Tokenizer} */ - if (!pattern._compiled) { - before = pattern.before ? '(?:' + pattern.before + ')' : ''; - after = pattern.after ? '(?:' + pattern.after + ')' : ''; +function tokenizeHardBreakEscape(effects, ok, nok) { + return start + /** @type {State} */ + + function start(code) { + effects.enter('hardBreakEscape'); + effects.enter('escapeMarker'); + effects.consume(code); + return open + } + /** @type {State} */ - if (pattern.atBreak) { - before = '[\\r\\n][\\t ]*' + before; + function open(code) { + if (markdownLineEnding(code)) { + effects.exit('escapeMarker'); + effects.exit('hardBreakEscape'); + return ok(code) } - pattern._compiled = new RegExp( - (before ? '(' + before + ')' : '') + - (/[|\\{}()[\]^$+*?.-]/.test(pattern.character) ? '\\' : '') + - pattern.character + - (after || ''), - 'g' - ); + return nok(code) } - - return pattern._compiled } -var safe_1 = safe$7; - -var patternCompile$2 = patternCompile_1; -var patternInScope = patternInScope_1; +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').State} State + */ -function safe$7(context, input, config) { - var value = (config.before || '') + (input || '') + (config.after || ''); - var positions = []; - var result = []; - var infos = {}; - var index = -1; - var before; - var after; - var position; - var pattern; - var expression; - var match; - var start; - var end; +/** @type {Construct} */ +const headingAtx = { + name: 'headingAtx', + tokenize: tokenizeHeadingAtx, + resolve: resolveHeadingAtx +}; +/** @type {Resolver} */ - while (++index < context.unsafe.length) { - pattern = context.unsafe[index]; +function resolveHeadingAtx(events, context) { + let contentEnd = events.length - 2; + let contentStart = 3; + /** @type {Token} */ - if (!patternInScope(context.stack, pattern)) { - continue - } + let content; + /** @type {Token} */ - expression = patternCompile$2(pattern); + let text; // Prefix whitespace, part of the opening. - while ((match = expression.exec(value))) { - before = 'before' in pattern || pattern.atBreak; - after = 'after' in pattern; + if (events[contentStart][1].type === 'whitespace') { + contentStart += 2; + } // Suffix whitespace, part of the closing. - position = match.index + (before ? match[1].length : 0); + if ( + contentEnd - 2 > contentStart && + events[contentEnd][1].type === 'whitespace' + ) { + contentEnd -= 2; + } - if (positions.indexOf(position) === -1) { - positions.push(position); - infos[position] = {before: before, after: after}; - } else { - if (infos[position].before && !before) { - infos[position].before = false; - } + if ( + events[contentEnd][1].type === 'atxHeadingSequence' && + (contentStart === contentEnd - 1 || + (contentEnd - 4 > contentStart && + events[contentEnd - 2][1].type === 'whitespace')) + ) { + contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; + } - if (infos[position].after && !after) { - infos[position].after = false; - } - } - } + if (contentEnd > contentStart) { + content = { + type: 'atxHeadingText', + start: events[contentStart][1].start, + end: events[contentEnd][1].end + }; + text = { + type: 'chunkText', + start: events[contentStart][1].start, + end: events[contentEnd][1].end, + // @ts-expect-error Constants are fine to assign. + contentType: 'text' + }; + splice(events, contentStart, contentEnd - contentStart + 1, [ + ['enter', content, context], + ['enter', text, context], + ['exit', text, context], + ['exit', content, context] + ]); } - positions.sort(numerical); + return events +} +/** @type {Tokenizer} */ - start = config.before ? config.before.length : 0; - end = value.length - (config.after ? config.after.length : 0); - index = -1; +function tokenizeHeadingAtx(effects, ok, nok) { + const self = this; + let size = 0; + return start + /** @type {State} */ - while (++index < positions.length) { - position = positions[index]; + function start(code) { + effects.enter('atxHeading'); + effects.enter('atxHeadingSequence'); + return fenceOpenInside(code) + } + /** @type {State} */ - if ( - // Character before or after matched: - position < start || - position >= end - ) { - continue - } - - // If this character is supposed to be escaped because it has a condition on - // the next character, and the next character is definitly being escaped, - // then skip this escape. - if ( - position + 1 < end && - positions[index + 1] === position + 1 && - infos[position].after && - !infos[position + 1].before && - !infos[position + 1].after - ) { - continue + function fenceOpenInside(code) { + if (code === 35 && size++ < 6) { + effects.consume(code); + return fenceOpenInside } - if (start !== position) { - // If we have to use a character reference, an ampersand would be more - // correct, but as backslashes only care about punctuation, either will - // do the trick - result.push(escapeBackslashes(value.slice(start, position), '\\')); + if (code === null || markdownLineEndingOrSpace(code)) { + effects.exit('atxHeadingSequence'); + return self.interrupt ? ok(code) : headingBreak(code) } - start = position; - - if ( - /[!-/:-@[-`{-~]/.test(value.charAt(position)) && - (!config.encode || config.encode.indexOf(value.charAt(position)) === -1) - ) { - // Character escape. - result.push('\\'); - } else { - // Character reference. - result.push( - '&#x' + value.charCodeAt(position).toString(16).toUpperCase() + ';' - ); - start++; - } + return nok(code) } + /** @type {State} */ - result.push(escapeBackslashes(value.slice(start, end), config.after)); - - return result.join('') -} + function headingBreak(code) { + if (code === 35) { + effects.enter('atxHeadingSequence'); + return sequence(code) + } -function numerical(a, b) { - return a - b -} + if (code === null || markdownLineEnding(code)) { + effects.exit('atxHeading'); + return ok(code) + } -function escapeBackslashes(value, after) { - var expression = /\\(?=[!-/:-@[-`{-~])/g; - var positions = []; - var results = []; - var index = -1; - var start = 0; - var whole = value + after; - var match; + if (markdownSpace(code)) { + return factorySpace(effects, headingBreak, 'whitespace')(code) + } - while ((match = expression.exec(whole))) { - positions.push(match.index); + effects.enter('atxHeadingText'); + return data(code) } + /** @type {State} */ - while (++index < positions.length) { - if (start !== positions[index]) { - results.push(value.slice(start, positions[index])); + function sequence(code) { + if (code === 35) { + effects.consume(code); + return sequence } - results.push('\\'); - start = positions[index]; + effects.exit('atxHeadingSequence'); + return headingBreak(code) } + /** @type {State} */ - results.push(value.slice(start)); + function data(code) { + if (code === null || code === 35 || markdownLineEndingOrSpace(code)) { + effects.exit('atxHeadingText'); + return headingBreak(code) + } - return results.join('') + effects.consume(code); + return data + } } -var code_1 = code$1; +/** + * List of lowercase HTML tag names which when parsing HTML (flow), result + * in more relaxed rules (condition 6): because they are known blocks, the + * HTML-like syntax doesn’t have to be strictly parsed. + * For tag names not in this list, a more strict algorithm (condition 7) is used + * to detect whether the HTML-like syntax is seen as HTML (flow) or not. + * + * This is copied from: + * . + */ +const htmlBlockNames = [ + 'address', + 'article', + 'aside', + 'base', + 'basefont', + 'blockquote', + 'body', + 'caption', + 'center', + 'col', + 'colgroup', + 'dd', + 'details', + 'dialog', + 'dir', + 'div', + 'dl', + 'dt', + 'fieldset', + 'figcaption', + 'figure', + 'footer', + 'form', + 'frame', + 'frameset', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'header', + 'hr', + 'html', + 'iframe', + 'legend', + 'li', + 'link', + 'main', + 'menu', + 'menuitem', + 'nav', + 'noframes', + 'ol', + 'optgroup', + 'option', + 'p', + 'param', + 'section', + 'source', + 'summary', + 'table', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'title', + 'tr', + 'track', + 'ul' +]; -var repeat$4 = repeatString; -var streak = longestStreak_1; -var formatCodeAsIndented$1 = formatCodeAsIndented_1; -var checkFence = checkFence_1; -var indentLines$2 = indentLines_1; -var safe$6 = safe_1; +/** + * List of lowercase HTML tag names which when parsing HTML (flow), result in + * HTML that can include lines w/o exiting, until a closing tag also in this + * list is found (condition 1). + * + * This module is copied from: + * . + * + * Note that `textarea` is not available in `CommonMark@0.29` but has been + * merged to the primary branch and is slated to be released in the next release + * of CommonMark. + */ +const htmlRawNames = ['pre', 'script', 'style', 'textarea']; -function code$1(node, _, context) { - var marker = checkFence(context); - var raw = node.value || ''; - var suffix = marker === '`' ? 'GraveAccent' : 'Tilde'; - var value; - var sequence; - var exit; - var subexit; - - if (formatCodeAsIndented$1(node, context)) { - exit = context.enter('codeIndented'); - value = indentLines$2(raw, map$2); - } else { - sequence = repeat$4(marker, Math.max(streak(raw, marker) + 1, 3)); - exit = context.enter('codeFenced'); - value = sequence; +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code + */ +/** @type {Construct} */ - if (node.lang) { - subexit = context.enter('codeFencedLang' + suffix); - value += safe$6(context, node.lang, { - before: '`', - after: ' ', - encode: ['`'] - }); - subexit(); - } +const htmlFlow = { + name: 'htmlFlow', + tokenize: tokenizeHtmlFlow, + resolveTo: resolveToHtmlFlow, + concrete: true +}; +/** @type {Construct} */ - if (node.lang && node.meta) { - subexit = context.enter('codeFencedMeta' + suffix); - value += - ' ' + - safe$6(context, node.meta, { - before: ' ', - after: '\n', - encode: ['`'] - }); - subexit(); - } +const nextBlankConstruct = { + tokenize: tokenizeNextBlank, + partial: true +}; +/** @type {Resolver} */ - value += '\n'; +function resolveToHtmlFlow(events) { + let index = events.length; - if (raw) { - value += raw + '\n'; + while (index--) { + if (events[index][0] === 'enter' && events[index][1].type === 'htmlFlow') { + break } - - value += sequence; } - exit(); - return value -} + if (index > 1 && events[index - 2][1].type === 'linePrefix') { + // Add the prefix start to the HTML token. + events[index][1].start = events[index - 2][1].start; // Add the prefix start to the HTML line token. -function map$2(line, _, blank) { - return (blank ? '' : ' ') + line -} + events[index + 1][1].start = events[index - 2][1].start; // Remove the line prefix. -const AEli = "Æ"; -const AElig = "Æ"; -const AM = "&"; -const AMP = "&"; -const Aacut = "Á"; -const Aacute = "Á"; -const Abreve = "Ă"; -const Acir = "Â"; -const Acirc = "Â"; -const Acy = "А"; -const Afr = "𝔄"; -const Agrav = "À"; -const Agrave = "À"; -const Alpha = "Α"; -const Amacr = "Ā"; -const And = "⩓"; -const Aogon = "Ą"; -const Aopf = "𝔸"; -const ApplyFunction = "⁡"; -const Arin = "Å"; -const Aring = "Å"; -const Ascr = "𝒜"; -const Assign = "≔"; -const Atild = "Ã"; -const Atilde = "Ã"; -const Aum = "Ä"; -const Auml = "Ä"; -const Backslash = "∖"; -const Barv = "⫧"; -const Barwed = "⌆"; -const Bcy = "Б"; -const Because = "∵"; -const Bernoullis = "ℬ"; -const Beta = "Β"; -const Bfr = "𝔅"; -const Bopf = "𝔹"; -const Breve = "˘"; -const Bscr = "ℬ"; -const Bumpeq = "≎"; -const CHcy = "Ч"; -const COP = "©"; -const COPY = "©"; -const Cacute = "Ć"; -const Cap = "⋒"; -const CapitalDifferentialD = "ⅅ"; -const Cayleys = "ℭ"; -const Ccaron = "Č"; -const Ccedi = "Ç"; -const Ccedil = "Ç"; -const Ccirc = "Ĉ"; -const Cconint = "∰"; -const Cdot = "Ċ"; -const Cedilla = "¸"; -const CenterDot = "·"; -const Cfr = "ℭ"; -const Chi = "Χ"; -const CircleDot = "⊙"; -const CircleMinus = "⊖"; -const CirclePlus = "⊕"; -const CircleTimes = "⊗"; -const ClockwiseContourIntegral = "∲"; -const CloseCurlyDoubleQuote = "”"; -const CloseCurlyQuote = "’"; -const Colon = "∷"; -const Colone = "⩴"; -const Congruent = "≡"; -const Conint = "∯"; -const ContourIntegral = "∮"; -const Copf = "ℂ"; -const Coproduct = "∐"; -const CounterClockwiseContourIntegral = "∳"; -const Cross = "⨯"; -const Cscr = "𝒞"; -const Cup = "⋓"; -const CupCap = "≍"; -const DD = "ⅅ"; -const DDotrahd = "⤑"; -const DJcy = "Ђ"; -const DScy = "Ѕ"; -const DZcy = "Џ"; -const Dagger = "‡"; -const Darr = "↡"; -const Dashv = "⫤"; -const Dcaron = "Ď"; -const Dcy = "Д"; -const Del = "∇"; -const Delta = "Δ"; -const Dfr = "𝔇"; -const DiacriticalAcute = "´"; -const DiacriticalDot = "˙"; -const DiacriticalDoubleAcute = "˝"; -const DiacriticalGrave = "`"; -const DiacriticalTilde = "˜"; -const Diamond = "⋄"; -const DifferentialD = "ⅆ"; -const Dopf = "𝔻"; -const Dot = "¨"; -const DotDot = "⃜"; -const DotEqual = "≐"; -const DoubleContourIntegral = "∯"; -const DoubleDot = "¨"; -const DoubleDownArrow = "⇓"; -const DoubleLeftArrow = "⇐"; -const DoubleLeftRightArrow = "⇔"; -const DoubleLeftTee = "⫤"; -const DoubleLongLeftArrow = "⟸"; -const DoubleLongLeftRightArrow = "⟺"; -const DoubleLongRightArrow = "⟹"; -const DoubleRightArrow = "⇒"; -const DoubleRightTee = "⊨"; -const DoubleUpArrow = "⇑"; -const DoubleUpDownArrow = "⇕"; -const DoubleVerticalBar = "∥"; -const DownArrow = "↓"; -const DownArrowBar = "⤓"; -const DownArrowUpArrow = "⇵"; -const DownBreve = "̑"; -const DownLeftRightVector = "⥐"; -const DownLeftTeeVector = "⥞"; -const DownLeftVector = "↽"; -const DownLeftVectorBar = "⥖"; -const DownRightTeeVector = "⥟"; -const DownRightVector = "⇁"; -const DownRightVectorBar = "⥗"; -const DownTee = "⊤"; -const DownTeeArrow = "↧"; -const Downarrow = "⇓"; -const Dscr = "𝒟"; -const Dstrok = "Đ"; -const ENG = "Ŋ"; -const ET = "Ð"; -const ETH = "Ð"; -const Eacut = "É"; -const Eacute = "É"; -const Ecaron = "Ě"; -const Ecir = "Ê"; -const Ecirc = "Ê"; -const Ecy = "Э"; -const Edot = "Ė"; -const Efr = "𝔈"; -const Egrav = "È"; -const Egrave = "È"; -const Element = "∈"; -const Emacr = "Ē"; -const EmptySmallSquare = "◻"; -const EmptyVerySmallSquare = "▫"; -const Eogon = "Ę"; -const Eopf = "𝔼"; -const Epsilon = "Ε"; -const Equal = "⩵"; -const EqualTilde = "≂"; -const Equilibrium = "⇌"; -const Escr = "ℰ"; -const Esim = "⩳"; -const Eta = "Η"; -const Eum = "Ë"; -const Euml = "Ë"; -const Exists = "∃"; -const ExponentialE = "ⅇ"; -const Fcy = "Ф"; -const Ffr = "𝔉"; -const FilledSmallSquare = "◼"; -const FilledVerySmallSquare = "▪"; -const Fopf = "𝔽"; -const ForAll = "∀"; -const Fouriertrf = "ℱ"; -const Fscr = "ℱ"; -const GJcy = "Ѓ"; -const G = ">"; -const GT = ">"; -const Gamma = "Γ"; -const Gammad = "Ϝ"; -const Gbreve = "Ğ"; -const Gcedil = "Ģ"; -const Gcirc = "Ĝ"; -const Gcy = "Г"; -const Gdot = "Ġ"; -const Gfr = "𝔊"; -const Gg = "⋙"; -const Gopf = "𝔾"; -const GreaterEqual = "≥"; -const GreaterEqualLess = "⋛"; -const GreaterFullEqual = "≧"; -const GreaterGreater = "⪢"; -const GreaterLess = "≷"; -const GreaterSlantEqual = "⩾"; -const GreaterTilde = "≳"; -const Gscr = "𝒢"; -const Gt = "≫"; -const HARDcy = "Ъ"; -const Hacek = "ˇ"; -const Hat = "^"; -const Hcirc = "Ĥ"; -const Hfr = "ℌ"; -const HilbertSpace = "ℋ"; -const Hopf = "ℍ"; -const HorizontalLine = "─"; -const Hscr = "ℋ"; -const Hstrok = "Ħ"; -const HumpDownHump = "≎"; -const HumpEqual = "≏"; -const IEcy = "Е"; -const IJlig = "IJ"; -const IOcy = "Ё"; -const Iacut = "Í"; -const Iacute = "Í"; -const Icir = "Î"; -const Icirc = "Î"; -const Icy = "И"; -const Idot = "İ"; -const Ifr = "ℑ"; -const Igrav = "Ì"; -const Igrave = "Ì"; -const Im = "ℑ"; -const Imacr = "Ī"; -const ImaginaryI = "ⅈ"; -const Implies = "⇒"; -const Int = "∬"; -const Integral = "∫"; -const Intersection = "⋂"; -const InvisibleComma = "⁣"; -const InvisibleTimes = "⁢"; -const Iogon = "Į"; -const Iopf = "𝕀"; -const Iota = "Ι"; -const Iscr = "ℐ"; -const Itilde = "Ĩ"; -const Iukcy = "І"; -const Ium = "Ï"; -const Iuml = "Ï"; -const Jcirc = "Ĵ"; -const Jcy = "Й"; -const Jfr = "𝔍"; -const Jopf = "𝕁"; -const Jscr = "𝒥"; -const Jsercy = "Ј"; -const Jukcy = "Є"; -const KHcy = "Х"; -const KJcy = "Ќ"; -const Kappa = "Κ"; -const Kcedil = "Ķ"; -const Kcy = "К"; -const Kfr = "𝔎"; -const Kopf = "𝕂"; -const Kscr = "𝒦"; -const LJcy = "Љ"; -const L = "<"; -const LT = "<"; -const Lacute = "Ĺ"; -const Lambda = "Λ"; -const Lang = "⟪"; -const Laplacetrf = "ℒ"; -const Larr = "↞"; -const Lcaron = "Ľ"; -const Lcedil = "Ļ"; -const Lcy = "Л"; -const LeftAngleBracket = "⟨"; -const LeftArrow = "←"; -const LeftArrowBar = "⇤"; -const LeftArrowRightArrow = "⇆"; -const LeftCeiling = "⌈"; -const LeftDoubleBracket = "⟦"; -const LeftDownTeeVector = "⥡"; -const LeftDownVector = "⇃"; -const LeftDownVectorBar = "⥙"; -const LeftFloor = "⌊"; -const LeftRightArrow = "↔"; -const LeftRightVector = "⥎"; -const LeftTee = "⊣"; -const LeftTeeArrow = "↤"; -const LeftTeeVector = "⥚"; -const LeftTriangle = "⊲"; -const LeftTriangleBar = "⧏"; -const LeftTriangleEqual = "⊴"; -const LeftUpDownVector = "⥑"; -const LeftUpTeeVector = "⥠"; -const LeftUpVector = "↿"; -const LeftUpVectorBar = "⥘"; -const LeftVector = "↼"; -const LeftVectorBar = "⥒"; -const Leftarrow = "⇐"; -const Leftrightarrow = "⇔"; -const LessEqualGreater = "⋚"; -const LessFullEqual = "≦"; -const LessGreater = "≶"; -const LessLess = "⪡"; -const LessSlantEqual = "⩽"; -const LessTilde = "≲"; -const Lfr = "𝔏"; -const Ll = "⋘"; -const Lleftarrow = "⇚"; -const Lmidot = "Ŀ"; -const LongLeftArrow = "⟵"; -const LongLeftRightArrow = "⟷"; -const LongRightArrow = "⟶"; -const Longleftarrow = "⟸"; -const Longleftrightarrow = "⟺"; -const Longrightarrow = "⟹"; -const Lopf = "𝕃"; -const LowerLeftArrow = "↙"; -const LowerRightArrow = "↘"; -const Lscr = "ℒ"; -const Lsh = "↰"; -const Lstrok = "Ł"; -const Lt = "≪"; -const Mcy = "М"; -const MediumSpace = " "; -const Mellintrf = "ℳ"; -const Mfr = "𝔐"; -const MinusPlus = "∓"; -const Mopf = "𝕄"; -const Mscr = "ℳ"; -const Mu = "Μ"; -const NJcy = "Њ"; -const Nacute = "Ń"; -const Ncaron = "Ň"; -const Ncedil = "Ņ"; -const Ncy = "Н"; -const NegativeMediumSpace = "​"; -const NegativeThickSpace = "​"; -const NegativeThinSpace = "​"; -const NegativeVeryThinSpace = "​"; -const NestedGreaterGreater = "≫"; -const NestedLessLess = "≪"; -const NewLine = "\n"; -const Nfr = "𝔑"; -const NoBreak = "⁠"; -const NonBreakingSpace = " "; -const Nopf = "ℕ"; -const Not = "⫬"; -const NotCongruent = "≢"; -const NotCupCap = "≭"; -const NotDoubleVerticalBar = "∦"; -const NotElement = "∉"; -const NotEqual = "≠"; -const NotEqualTilde = "≂̸"; -const NotExists = "∄"; -const NotGreater = "≯"; -const NotGreaterEqual = "≱"; -const NotGreaterFullEqual = "≧̸"; -const NotGreaterGreater = "≫̸"; -const NotGreaterLess = "≹"; -const NotGreaterSlantEqual = "⩾̸"; -const NotGreaterTilde = "≵"; -const NotHumpDownHump = "≎̸"; -const NotHumpEqual = "≏̸"; -const NotLeftTriangle = "⋪"; -const NotLeftTriangleBar = "⧏̸"; -const NotLeftTriangleEqual = "⋬"; -const NotLess = "≮"; -const NotLessEqual = "≰"; -const NotLessGreater = "≸"; -const NotLessLess = "≪̸"; -const NotLessSlantEqual = "⩽̸"; -const NotLessTilde = "≴"; -const NotNestedGreaterGreater = "⪢̸"; -const NotNestedLessLess = "⪡̸"; -const NotPrecedes = "⊀"; -const NotPrecedesEqual = "⪯̸"; -const NotPrecedesSlantEqual = "⋠"; -const NotReverseElement = "∌"; -const NotRightTriangle = "⋫"; -const NotRightTriangleBar = "⧐̸"; -const NotRightTriangleEqual = "⋭"; -const NotSquareSubset = "⊏̸"; -const NotSquareSubsetEqual = "⋢"; -const NotSquareSuperset = "⊐̸"; -const NotSquareSupersetEqual = "⋣"; -const NotSubset = "⊂⃒"; -const NotSubsetEqual = "⊈"; -const NotSucceeds = "⊁"; -const NotSucceedsEqual = "⪰̸"; -const NotSucceedsSlantEqual = "⋡"; -const NotSucceedsTilde = "≿̸"; -const NotSuperset = "⊃⃒"; -const NotSupersetEqual = "⊉"; -const NotTilde = "≁"; -const NotTildeEqual = "≄"; -const NotTildeFullEqual = "≇"; -const NotTildeTilde = "≉"; -const NotVerticalBar = "∤"; -const Nscr = "𝒩"; -const Ntild = "Ñ"; -const Ntilde = "Ñ"; -const Nu = "Ν"; -const OElig = "Œ"; -const Oacut = "Ó"; -const Oacute = "Ó"; -const Ocir = "Ô"; -const Ocirc = "Ô"; -const Ocy = "О"; -const Odblac = "Ő"; -const Ofr = "𝔒"; -const Ograv = "Ò"; -const Ograve = "Ò"; -const Omacr = "Ō"; -const Omega = "Ω"; -const Omicron = "Ο"; -const Oopf = "𝕆"; -const OpenCurlyDoubleQuote = "“"; -const OpenCurlyQuote = "‘"; -const Or = "⩔"; -const Oscr = "𝒪"; -const Oslas = "Ø"; -const Oslash = "Ø"; -const Otild = "Õ"; -const Otilde = "Õ"; -const Otimes = "⨷"; -const Oum = "Ö"; -const Ouml = "Ö"; -const OverBar = "‾"; -const OverBrace = "⏞"; -const OverBracket = "⎴"; -const OverParenthesis = "⏜"; -const PartialD = "∂"; -const Pcy = "П"; -const Pfr = "𝔓"; -const Phi = "Φ"; -const Pi = "Π"; -const PlusMinus = "±"; -const Poincareplane = "ℌ"; -const Popf = "ℙ"; -const Pr = "⪻"; -const Precedes = "≺"; -const PrecedesEqual = "⪯"; -const PrecedesSlantEqual = "≼"; -const PrecedesTilde = "≾"; -const Prime = "″"; -const Product = "∏"; -const Proportion = "∷"; -const Proportional = "∝"; -const Pscr = "𝒫"; -const Psi = "Ψ"; -const QUO = "\""; -const QUOT = "\""; -const Qfr = "𝔔"; -const Qopf = "ℚ"; -const Qscr = "𝒬"; -const RBarr = "⤐"; -const RE = "®"; -const REG = "®"; -const Racute = "Ŕ"; -const Rang = "⟫"; -const Rarr = "↠"; -const Rarrtl = "⤖"; -const Rcaron = "Ř"; -const Rcedil = "Ŗ"; -const Rcy = "Р"; -const Re = "ℜ"; -const ReverseElement = "∋"; -const ReverseEquilibrium = "⇋"; -const ReverseUpEquilibrium = "⥯"; -const Rfr = "ℜ"; -const Rho = "Ρ"; -const RightAngleBracket = "⟩"; -const RightArrow = "→"; -const RightArrowBar = "⇥"; -const RightArrowLeftArrow = "⇄"; -const RightCeiling = "⌉"; -const RightDoubleBracket = "⟧"; -const RightDownTeeVector = "⥝"; -const RightDownVector = "⇂"; -const RightDownVectorBar = "⥕"; -const RightFloor = "⌋"; -const RightTee = "⊢"; -const RightTeeArrow = "↦"; -const RightTeeVector = "⥛"; -const RightTriangle = "⊳"; -const RightTriangleBar = "⧐"; -const RightTriangleEqual = "⊵"; -const RightUpDownVector = "⥏"; -const RightUpTeeVector = "⥜"; -const RightUpVector = "↾"; -const RightUpVectorBar = "⥔"; -const RightVector = "⇀"; -const RightVectorBar = "⥓"; -const Rightarrow = "⇒"; -const Ropf = "ℝ"; -const RoundImplies = "⥰"; -const Rrightarrow = "⇛"; -const Rscr = "ℛ"; -const Rsh = "↱"; -const RuleDelayed = "⧴"; -const SHCHcy = "Щ"; -const SHcy = "Ш"; -const SOFTcy = "Ь"; -const Sacute = "Ś"; -const Sc = "⪼"; -const Scaron = "Š"; -const Scedil = "Ş"; -const Scirc = "Ŝ"; -const Scy = "С"; -const Sfr = "𝔖"; -const ShortDownArrow = "↓"; -const ShortLeftArrow = "←"; -const ShortRightArrow = "→"; -const ShortUpArrow = "↑"; -const Sigma = "Σ"; -const SmallCircle = "∘"; -const Sopf = "𝕊"; -const Sqrt = "√"; -const Square = "□"; -const SquareIntersection = "⊓"; -const SquareSubset = "⊏"; -const SquareSubsetEqual = "⊑"; -const SquareSuperset = "⊐"; -const SquareSupersetEqual = "⊒"; -const SquareUnion = "⊔"; -const Sscr = "𝒮"; -const Star = "⋆"; -const Sub = "⋐"; -const Subset = "⋐"; -const SubsetEqual = "⊆"; -const Succeeds = "≻"; -const SucceedsEqual = "⪰"; -const SucceedsSlantEqual = "≽"; -const SucceedsTilde = "≿"; -const SuchThat = "∋"; -const Sum = "∑"; -const Sup = "⋑"; -const Superset = "⊃"; -const SupersetEqual = "⊇"; -const Supset = "⋑"; -const THOR = "Þ"; -const THORN = "Þ"; -const TRADE = "™"; -const TSHcy = "Ћ"; -const TScy = "Ц"; -const Tab = "\t"; -const Tau = "Τ"; -const Tcaron = "Ť"; -const Tcedil = "Ţ"; -const Tcy = "Т"; -const Tfr = "𝔗"; -const Therefore = "∴"; -const Theta = "Θ"; -const ThickSpace = "  "; -const ThinSpace = " "; -const Tilde = "∼"; -const TildeEqual = "≃"; -const TildeFullEqual = "≅"; -const TildeTilde = "≈"; -const Topf = "𝕋"; -const TripleDot = "⃛"; -const Tscr = "𝒯"; -const Tstrok = "Ŧ"; -const Uacut = "Ú"; -const Uacute = "Ú"; -const Uarr = "↟"; -const Uarrocir = "⥉"; -const Ubrcy = "Ў"; -const Ubreve = "Ŭ"; -const Ucir = "Û"; -const Ucirc = "Û"; -const Ucy = "У"; -const Udblac = "Ű"; -const Ufr = "𝔘"; -const Ugrav = "Ù"; -const Ugrave = "Ù"; -const Umacr = "Ū"; -const UnderBar = "_"; -const UnderBrace = "⏟"; -const UnderBracket = "⎵"; -const UnderParenthesis = "⏝"; -const Union = "⋃"; -const UnionPlus = "⊎"; -const Uogon = "Ų"; -const Uopf = "𝕌"; -const UpArrow = "↑"; -const UpArrowBar = "⤒"; -const UpArrowDownArrow = "⇅"; -const UpDownArrow = "↕"; -const UpEquilibrium = "⥮"; -const UpTee = "⊥"; -const UpTeeArrow = "↥"; -const Uparrow = "⇑"; -const Updownarrow = "⇕"; -const UpperLeftArrow = "↖"; -const UpperRightArrow = "↗"; -const Upsi = "ϒ"; -const Upsilon = "Υ"; -const Uring = "Ů"; -const Uscr = "𝒰"; -const Utilde = "Ũ"; -const Uum = "Ü"; -const Uuml = "Ü"; -const VDash = "⊫"; -const Vbar = "⫫"; -const Vcy = "В"; -const Vdash = "⊩"; -const Vdashl = "⫦"; -const Vee = "⋁"; -const Verbar = "‖"; -const Vert = "‖"; -const VerticalBar = "∣"; -const VerticalLine = "|"; -const VerticalSeparator = "❘"; -const VerticalTilde = "≀"; -const VeryThinSpace = " "; -const Vfr = "𝔙"; -const Vopf = "𝕍"; -const Vscr = "𝒱"; -const Vvdash = "⊪"; -const Wcirc = "Ŵ"; -const Wedge = "⋀"; -const Wfr = "𝔚"; -const Wopf = "𝕎"; -const Wscr = "𝒲"; -const Xfr = "𝔛"; -const Xi = "Ξ"; -const Xopf = "𝕏"; -const Xscr = "𝒳"; -const YAcy = "Я"; -const YIcy = "Ї"; -const YUcy = "Ю"; -const Yacut = "Ý"; -const Yacute = "Ý"; -const Ycirc = "Ŷ"; -const Ycy = "Ы"; -const Yfr = "𝔜"; -const Yopf = "𝕐"; -const Yscr = "𝒴"; -const Yuml = "Ÿ"; -const ZHcy = "Ж"; -const Zacute = "Ź"; -const Zcaron = "Ž"; -const Zcy = "З"; -const Zdot = "Ż"; -const ZeroWidthSpace = "​"; -const Zeta = "Ζ"; -const Zfr = "ℨ"; -const Zopf = "ℤ"; -const Zscr = "𝒵"; -const aacut = "á"; -const aacute = "á"; -const abreve = "ă"; -const ac = "∾"; -const acE = "∾̳"; -const acd = "∿"; -const acir = "â"; -const acirc = "â"; -const acut = "´"; -const acute = "´"; -const acy = "а"; -const aeli = "æ"; -const aelig = "æ"; -const af = "⁡"; -const afr = "𝔞"; -const agrav = "à"; -const agrave = "à"; -const alefsym = "ℵ"; -const aleph = "ℵ"; -const alpha = "α"; -const amacr = "ā"; -const amalg = "⨿"; -const am = "&"; -const amp = "&"; -const and = "∧"; -const andand = "⩕"; -const andd = "⩜"; -const andslope = "⩘"; -const andv = "⩚"; -const ang = "∠"; -const ange = "⦤"; -const angle = "∠"; -const angmsd = "∡"; -const angmsdaa = "⦨"; -const angmsdab = "⦩"; -const angmsdac = "⦪"; -const angmsdad = "⦫"; -const angmsdae = "⦬"; -const angmsdaf = "⦭"; -const angmsdag = "⦮"; -const angmsdah = "⦯"; -const angrt = "∟"; -const angrtvb = "⊾"; -const angrtvbd = "⦝"; -const angsph = "∢"; -const angst = "Å"; -const angzarr = "⍼"; -const aogon = "ą"; -const aopf = "𝕒"; -const ap = "≈"; -const apE = "⩰"; -const apacir = "⩯"; -const ape = "≊"; -const apid = "≋"; -const apos = "'"; -const approx = "≈"; -const approxeq = "≊"; -const arin = "å"; -const aring = "å"; -const ascr = "𝒶"; -const ast = "*"; -const asymp = "≈"; -const asympeq = "≍"; -const atild = "ã"; -const atilde = "ã"; -const aum = "ä"; -const auml = "ä"; -const awconint = "∳"; -const awint = "⨑"; -const bNot = "⫭"; -const backcong = "≌"; -const backepsilon = "϶"; -const backprime = "‵"; -const backsim = "∽"; -const backsimeq = "⋍"; -const barvee = "⊽"; -const barwed = "⌅"; -const barwedge = "⌅"; -const bbrk = "⎵"; -const bbrktbrk = "⎶"; -const bcong = "≌"; -const bcy = "б"; -const bdquo = "„"; -const becaus = "∵"; -const because = "∵"; -const bemptyv = "⦰"; -const bepsi = "϶"; -const bernou = "ℬ"; -const beta = "β"; -const beth = "ℶ"; -const between = "≬"; -const bfr = "𝔟"; -const bigcap = "⋂"; -const bigcirc = "◯"; -const bigcup = "⋃"; -const bigodot = "⨀"; -const bigoplus = "⨁"; -const bigotimes = "⨂"; -const bigsqcup = "⨆"; -const bigstar = "★"; -const bigtriangledown = "▽"; -const bigtriangleup = "△"; -const biguplus = "⨄"; -const bigvee = "⋁"; -const bigwedge = "⋀"; -const bkarow = "⤍"; -const blacklozenge = "⧫"; -const blacksquare = "▪"; -const blacktriangle = "▴"; -const blacktriangledown = "▾"; -const blacktriangleleft = "◂"; -const blacktriangleright = "▸"; -const blank = "␣"; -const blk12 = "▒"; -const blk14 = "░"; -const blk34 = "▓"; -const block = "█"; -const bne = "=⃥"; -const bnequiv = "≡⃥"; -const bnot = "⌐"; -const bopf = "𝕓"; -const bot = "⊥"; -const bottom = "⊥"; -const bowtie = "⋈"; -const boxDL = "╗"; -const boxDR = "╔"; -const boxDl = "╖"; -const boxDr = "╓"; -const boxH = "═"; -const boxHD = "╦"; -const boxHU = "╩"; -const boxHd = "╤"; -const boxHu = "╧"; -const boxUL = "╝"; -const boxUR = "╚"; -const boxUl = "╜"; -const boxUr = "╙"; -const boxV = "║"; -const boxVH = "╬"; -const boxVL = "╣"; -const boxVR = "╠"; -const boxVh = "╫"; -const boxVl = "╢"; -const boxVr = "╟"; -const boxbox = "⧉"; -const boxdL = "╕"; -const boxdR = "╒"; -const boxdl = "┐"; -const boxdr = "┌"; -const boxh = "─"; -const boxhD = "╥"; -const boxhU = "╨"; -const boxhd = "┬"; -const boxhu = "┴"; -const boxminus = "⊟"; -const boxplus = "⊞"; -const boxtimes = "⊠"; -const boxuL = "╛"; -const boxuR = "╘"; -const boxul = "┘"; -const boxur = "└"; -const boxv = "│"; -const boxvH = "╪"; -const boxvL = "╡"; -const boxvR = "╞"; -const boxvh = "┼"; -const boxvl = "┤"; -const boxvr = "├"; -const bprime = "‵"; -const breve = "˘"; -const brvba = "¦"; -const brvbar = "¦"; -const bscr = "𝒷"; -const bsemi = "⁏"; -const bsim = "∽"; -const bsime = "⋍"; -const bsol = "\\"; -const bsolb = "⧅"; -const bsolhsub = "⟈"; -const bull = "•"; -const bullet = "•"; -const bump = "≎"; -const bumpE = "⪮"; -const bumpe = "≏"; -const bumpeq = "≏"; -const cacute = "ć"; -const cap = "∩"; -const capand = "⩄"; -const capbrcup = "⩉"; -const capcap = "⩋"; -const capcup = "⩇"; -const capdot = "⩀"; -const caps = "∩︀"; -const caret = "⁁"; -const caron = "ˇ"; -const ccaps = "⩍"; -const ccaron = "č"; -const ccedi = "ç"; -const ccedil = "ç"; -const ccirc = "ĉ"; -const ccups = "⩌"; -const ccupssm = "⩐"; -const cdot = "ċ"; -const cedi = "¸"; -const cedil = "¸"; -const cemptyv = "⦲"; -const cen = "¢"; -const cent = "¢"; -const centerdot = "·"; -const cfr = "𝔠"; -const chcy = "ч"; -const check$1 = "✓"; -const checkmark = "✓"; -const chi = "χ"; -const cir = "○"; -const cirE = "⧃"; -const circ = "ˆ"; -const circeq = "≗"; -const circlearrowleft = "↺"; -const circlearrowright = "↻"; -const circledR = "®"; -const circledS = "Ⓢ"; -const circledast = "⊛"; -const circledcirc = "⊚"; -const circleddash = "⊝"; -const cire = "≗"; -const cirfnint = "⨐"; -const cirmid = "⫯"; -const cirscir = "⧂"; -const clubs = "♣"; -const clubsuit = "♣"; -const colon = ":"; -const colone = "≔"; -const coloneq = "≔"; -const comma = ","; -const commat = "@"; -const comp = "∁"; -const compfn = "∘"; -const complement = "∁"; -const complexes = "ℂ"; -const cong = "≅"; -const congdot = "⩭"; -const conint = "∮"; -const copf = "𝕔"; -const coprod = "∐"; -const cop = "©"; -const copy = "©"; -const copysr = "℗"; -const crarr = "↵"; -const cross = "✗"; -const cscr = "𝒸"; -const csub = "⫏"; -const csube = "⫑"; -const csup = "⫐"; -const csupe = "⫒"; -const ctdot = "⋯"; -const cudarrl = "⤸"; -const cudarrr = "⤵"; -const cuepr = "⋞"; -const cuesc = "⋟"; -const cularr = "↶"; -const cularrp = "⤽"; -const cup = "∪"; -const cupbrcap = "⩈"; -const cupcap = "⩆"; -const cupcup = "⩊"; -const cupdot = "⊍"; -const cupor = "⩅"; -const cups = "∪︀"; -const curarr = "↷"; -const curarrm = "⤼"; -const curlyeqprec = "⋞"; -const curlyeqsucc = "⋟"; -const curlyvee = "⋎"; -const curlywedge = "⋏"; -const curre = "¤"; -const curren = "¤"; -const curvearrowleft = "↶"; -const curvearrowright = "↷"; -const cuvee = "⋎"; -const cuwed = "⋏"; -const cwconint = "∲"; -const cwint = "∱"; -const cylcty = "⌭"; -const dArr = "⇓"; -const dHar = "⥥"; -const dagger = "†"; -const daleth = "ℸ"; -const darr = "↓"; -const dash = "‐"; -const dashv = "⊣"; -const dbkarow = "⤏"; -const dblac = "˝"; -const dcaron = "ď"; -const dcy = "д"; -const dd = "ⅆ"; -const ddagger = "‡"; -const ddarr = "⇊"; -const ddotseq = "⩷"; -const de = "°"; -const deg = "°"; -const delta = "δ"; -const demptyv = "⦱"; -const dfisht = "⥿"; -const dfr = "𝔡"; -const dharl = "⇃"; -const dharr = "⇂"; -const diam = "⋄"; -const diamond = "⋄"; -const diamondsuit = "♦"; -const diams = "♦"; -const die = "¨"; -const digamma = "ϝ"; -const disin = "⋲"; -const div = "÷"; -const divid = "÷"; -const divide = "÷"; -const divideontimes = "⋇"; -const divonx = "⋇"; -const djcy = "ђ"; -const dlcorn = "⌞"; -const dlcrop = "⌍"; -const dollar = "$"; -const dopf = "𝕕"; -const dot = "˙"; -const doteq = "≐"; -const doteqdot = "≑"; -const dotminus = "∸"; -const dotplus = "∔"; -const dotsquare = "⊡"; -const doublebarwedge = "⌆"; -const downarrow = "↓"; -const downdownarrows = "⇊"; -const downharpoonleft = "⇃"; -const downharpoonright = "⇂"; -const drbkarow = "⤐"; -const drcorn = "⌟"; -const drcrop = "⌌"; -const dscr = "𝒹"; -const dscy = "ѕ"; -const dsol = "⧶"; -const dstrok = "đ"; -const dtdot = "⋱"; -const dtri = "▿"; -const dtrif = "▾"; -const duarr = "⇵"; -const duhar = "⥯"; -const dwangle = "⦦"; -const dzcy = "џ"; -const dzigrarr = "⟿"; -const eDDot = "⩷"; -const eDot = "≑"; -const eacut = "é"; -const eacute = "é"; -const easter = "⩮"; -const ecaron = "ě"; -const ecir = "ê"; -const ecirc = "ê"; -const ecolon = "≕"; -const ecy = "э"; -const edot = "ė"; -const ee = "ⅇ"; -const efDot = "≒"; -const efr = "𝔢"; -const eg = "⪚"; -const egrav = "è"; -const egrave = "è"; -const egs = "⪖"; -const egsdot = "⪘"; -const el = "⪙"; -const elinters = "⏧"; -const ell = "ℓ"; -const els = "⪕"; -const elsdot = "⪗"; -const emacr = "ē"; -const empty = "∅"; -const emptyset = "∅"; -const emptyv = "∅"; -const emsp13 = " "; -const emsp14 = " "; -const emsp = " "; -const eng = "ŋ"; -const ensp = " "; -const eogon = "ę"; -const eopf = "𝕖"; -const epar = "⋕"; -const eparsl = "⧣"; -const eplus = "⩱"; -const epsi = "ε"; -const epsilon = "ε"; -const epsiv = "ϵ"; -const eqcirc = "≖"; -const eqcolon = "≕"; -const eqsim = "≂"; -const eqslantgtr = "⪖"; -const eqslantless = "⪕"; -const equals = "="; -const equest = "≟"; -const equiv = "≡"; -const equivDD = "⩸"; -const eqvparsl = "⧥"; -const erDot = "≓"; -const erarr = "⥱"; -const escr = "ℯ"; -const esdot = "≐"; -const esim = "≂"; -const eta = "η"; -const et = "ð"; -const eth = "ð"; -const eum = "ë"; -const euml = "ë"; -const euro = "€"; -const excl = "!"; -const exist = "∃"; -const expectation = "ℰ"; -const exponentiale = "ⅇ"; -const fallingdotseq = "≒"; -const fcy = "ф"; -const female = "♀"; -const ffilig = "ffi"; -const fflig = "ff"; -const ffllig = "ffl"; -const ffr = "𝔣"; -const filig = "fi"; -const fjlig = "fj"; -const flat = "♭"; -const fllig = "fl"; -const fltns = "▱"; -const fnof = "ƒ"; -const fopf = "𝕗"; -const forall = "∀"; -const fork = "⋔"; -const forkv = "⫙"; -const fpartint = "⨍"; -const frac1 = "¼"; -const frac12 = "½"; -const frac13 = "⅓"; -const frac14 = "¼"; -const frac15 = "⅕"; -const frac16 = "⅙"; -const frac18 = "⅛"; -const frac23 = "⅔"; -const frac25 = "⅖"; -const frac3 = "¾"; -const frac34 = "¾"; -const frac35 = "⅗"; -const frac38 = "⅜"; -const frac45 = "⅘"; -const frac56 = "⅚"; -const frac58 = "⅝"; -const frac78 = "⅞"; -const frasl = "⁄"; -const frown = "⌢"; -const fscr = "𝒻"; -const gE = "≧"; -const gEl = "⪌"; -const gacute = "ǵ"; -const gamma = "γ"; -const gammad = "ϝ"; -const gap = "⪆"; -const gbreve = "ğ"; -const gcirc = "ĝ"; -const gcy = "г"; -const gdot = "ġ"; -const ge = "≥"; -const gel = "⋛"; -const geq = "≥"; -const geqq = "≧"; -const geqslant = "⩾"; -const ges = "⩾"; -const gescc = "⪩"; -const gesdot = "⪀"; -const gesdoto = "⪂"; -const gesdotol = "⪄"; -const gesl = "⋛︀"; -const gesles = "⪔"; -const gfr = "𝔤"; -const gg = "≫"; -const ggg = "⋙"; -const gimel = "ℷ"; -const gjcy = "ѓ"; -const gl = "≷"; -const glE = "⪒"; -const gla = "⪥"; -const glj = "⪤"; -const gnE = "≩"; -const gnap = "⪊"; -const gnapprox = "⪊"; -const gne = "⪈"; -const gneq = "⪈"; -const gneqq = "≩"; -const gnsim = "⋧"; -const gopf = "𝕘"; -const grave = "`"; -const gscr = "ℊ"; -const gsim = "≳"; -const gsime = "⪎"; -const gsiml = "⪐"; -const g = ">"; -const gt = ">"; -const gtcc = "⪧"; -const gtcir = "⩺"; -const gtdot = "⋗"; -const gtlPar = "⦕"; -const gtquest = "⩼"; -const gtrapprox = "⪆"; -const gtrarr = "⥸"; -const gtrdot = "⋗"; -const gtreqless = "⋛"; -const gtreqqless = "⪌"; -const gtrless = "≷"; -const gtrsim = "≳"; -const gvertneqq = "≩︀"; -const gvnE = "≩︀"; -const hArr = "⇔"; -const hairsp = " "; -const half = "½"; -const hamilt = "ℋ"; -const hardcy = "ъ"; -const harr = "↔"; -const harrcir = "⥈"; -const harrw = "↭"; -const hbar = "ℏ"; -const hcirc = "ĥ"; -const hearts = "♥"; -const heartsuit = "♥"; -const hellip = "…"; -const hercon = "⊹"; -const hfr = "𝔥"; -const hksearow = "⤥"; -const hkswarow = "⤦"; -const hoarr = "⇿"; -const homtht = "∻"; -const hookleftarrow = "↩"; -const hookrightarrow = "↪"; -const hopf = "𝕙"; -const horbar = "―"; -const hscr = "𝒽"; -const hslash = "ℏ"; -const hstrok = "ħ"; -const hybull = "⁃"; -const hyphen = "‐"; -const iacut = "í"; -const iacute = "í"; -const ic = "⁣"; -const icir = "î"; -const icirc = "î"; -const icy = "и"; -const iecy = "е"; -const iexc = "¡"; -const iexcl = "¡"; -const iff = "⇔"; -const ifr = "𝔦"; -const igrav = "ì"; -const igrave = "ì"; -const ii = "ⅈ"; -const iiiint = "⨌"; -const iiint = "∭"; -const iinfin = "⧜"; -const iiota = "℩"; -const ijlig = "ij"; -const imacr = "ī"; -const image$1 = "ℑ"; -const imagline = "ℐ"; -const imagpart = "ℑ"; -const imath = "ı"; -const imof = "⊷"; -const imped = "Ƶ"; -const incare = "℅"; -const infin = "∞"; -const infintie = "⧝"; -const inodot = "ı"; -const int$1 = "∫"; -const intcal = "⊺"; -const integers = "ℤ"; -const intercal = "⊺"; -const intlarhk = "⨗"; -const intprod = "⨼"; -const iocy = "ё"; -const iogon = "į"; -const iopf = "𝕚"; -const iota = "ι"; -const iprod = "⨼"; -const iques = "¿"; -const iquest = "¿"; -const iscr = "𝒾"; -const isin = "∈"; -const isinE = "⋹"; -const isindot = "⋵"; -const isins = "⋴"; -const isinsv = "⋳"; -const isinv = "∈"; -const it = "⁢"; -const itilde = "ĩ"; -const iukcy = "і"; -const ium = "ï"; -const iuml = "ï"; -const jcirc = "ĵ"; -const jcy = "й"; -const jfr = "𝔧"; -const jmath = "ȷ"; -const jopf = "𝕛"; -const jscr = "𝒿"; -const jsercy = "ј"; -const jukcy = "є"; -const kappa = "κ"; -const kappav = "ϰ"; -const kcedil = "ķ"; -const kcy = "к"; -const kfr = "𝔨"; -const kgreen = "ĸ"; -const khcy = "х"; -const kjcy = "ќ"; -const kopf = "𝕜"; -const kscr = "𝓀"; -const lAarr = "⇚"; -const lArr = "⇐"; -const lAtail = "⤛"; -const lBarr = "⤎"; -const lE = "≦"; -const lEg = "⪋"; -const lHar = "⥢"; -const lacute = "ĺ"; -const laemptyv = "⦴"; -const lagran = "ℒ"; -const lambda = "λ"; -const lang = "⟨"; -const langd = "⦑"; -const langle = "⟨"; -const lap = "⪅"; -const laqu = "«"; -const laquo = "«"; -const larr = "←"; -const larrb = "⇤"; -const larrbfs = "⤟"; -const larrfs = "⤝"; -const larrhk = "↩"; -const larrlp = "↫"; -const larrpl = "⤹"; -const larrsim = "⥳"; -const larrtl = "↢"; -const lat = "⪫"; -const latail = "⤙"; -const late = "⪭"; -const lates = "⪭︀"; -const lbarr = "⤌"; -const lbbrk = "❲"; -const lbrace = "{"; -const lbrack = "["; -const lbrke = "⦋"; -const lbrksld = "⦏"; -const lbrkslu = "⦍"; -const lcaron = "ľ"; -const lcedil = "ļ"; -const lceil = "⌈"; -const lcub = "{"; -const lcy = "л"; -const ldca = "⤶"; -const ldquo = "“"; -const ldquor = "„"; -const ldrdhar = "⥧"; -const ldrushar = "⥋"; -const ldsh = "↲"; -const le = "≤"; -const leftarrow = "←"; -const leftarrowtail = "↢"; -const leftharpoondown = "↽"; -const leftharpoonup = "↼"; -const leftleftarrows = "⇇"; -const leftrightarrow = "↔"; -const leftrightarrows = "⇆"; -const leftrightharpoons = "⇋"; -const leftrightsquigarrow = "↭"; -const leftthreetimes = "⋋"; -const leg = "⋚"; -const leq = "≤"; -const leqq = "≦"; -const leqslant = "⩽"; -const les = "⩽"; -const lescc = "⪨"; -const lesdot = "⩿"; -const lesdoto = "⪁"; -const lesdotor = "⪃"; -const lesg = "⋚︀"; -const lesges = "⪓"; -const lessapprox = "⪅"; -const lessdot = "⋖"; -const lesseqgtr = "⋚"; -const lesseqqgtr = "⪋"; -const lessgtr = "≶"; -const lesssim = "≲"; -const lfisht = "⥼"; -const lfloor = "⌊"; -const lfr = "𝔩"; -const lg = "≶"; -const lgE = "⪑"; -const lhard = "↽"; -const lharu = "↼"; -const lharul = "⥪"; -const lhblk = "▄"; -const ljcy = "љ"; -const ll = "≪"; -const llarr = "⇇"; -const llcorner = "⌞"; -const llhard = "⥫"; -const lltri = "◺"; -const lmidot = "ŀ"; -const lmoust = "⎰"; -const lmoustache = "⎰"; -const lnE = "≨"; -const lnap = "⪉"; -const lnapprox = "⪉"; -const lne = "⪇"; -const lneq = "⪇"; -const lneqq = "≨"; -const lnsim = "⋦"; -const loang = "⟬"; -const loarr = "⇽"; -const lobrk = "⟦"; -const longleftarrow = "⟵"; -const longleftrightarrow = "⟷"; -const longmapsto = "⟼"; -const longrightarrow = "⟶"; -const looparrowleft = "↫"; -const looparrowright = "↬"; -const lopar = "⦅"; -const lopf = "𝕝"; -const loplus = "⨭"; -const lotimes = "⨴"; -const lowast = "∗"; -const lowbar = "_"; -const loz = "◊"; -const lozenge = "◊"; -const lozf = "⧫"; -const lpar = "("; -const lparlt = "⦓"; -const lrarr = "⇆"; -const lrcorner = "⌟"; -const lrhar = "⇋"; -const lrhard = "⥭"; -const lrm = "‎"; -const lrtri = "⊿"; -const lsaquo = "‹"; -const lscr = "𝓁"; -const lsh = "↰"; -const lsim = "≲"; -const lsime = "⪍"; -const lsimg = "⪏"; -const lsqb = "["; -const lsquo = "‘"; -const lsquor = "‚"; -const lstrok = "ł"; -const l = "<"; -const lt$1 = "<"; -const ltcc = "⪦"; -const ltcir = "⩹"; -const ltdot = "⋖"; -const lthree = "⋋"; -const ltimes = "⋉"; -const ltlarr = "⥶"; -const ltquest = "⩻"; -const ltrPar = "⦖"; -const ltri = "◃"; -const ltrie = "⊴"; -const ltrif = "◂"; -const lurdshar = "⥊"; -const luruhar = "⥦"; -const lvertneqq = "≨︀"; -const lvnE = "≨︀"; -const mDDot = "∺"; -const mac = "¯"; -const macr = "¯"; -const male = "♂"; -const malt = "✠"; -const maltese = "✠"; -const map$1 = "↦"; -const mapsto = "↦"; -const mapstodown = "↧"; -const mapstoleft = "↤"; -const mapstoup = "↥"; -const marker = "▮"; -const mcomma = "⨩"; -const mcy = "м"; -const mdash = "—"; -const measuredangle = "∡"; -const mfr = "𝔪"; -const mho = "℧"; -const micr = "µ"; -const micro = "µ"; -const mid = "∣"; -const midast = "*"; -const midcir = "⫰"; -const middo = "·"; -const middot = "·"; -const minus = "−"; -const minusb = "⊟"; -const minusd = "∸"; -const minusdu = "⨪"; -const mlcp = "⫛"; -const mldr = "…"; -const mnplus = "∓"; -const models = "⊧"; -const mopf = "𝕞"; -const mp = "∓"; -const mscr = "𝓂"; -const mstpos = "∾"; -const mu = "μ"; -const multimap = "⊸"; -const mumap = "⊸"; -const nGg = "⋙̸"; -const nGt = "≫⃒"; -const nGtv = "≫̸"; -const nLeftarrow = "⇍"; -const nLeftrightarrow = "⇎"; -const nLl = "⋘̸"; -const nLt = "≪⃒"; -const nLtv = "≪̸"; -const nRightarrow = "⇏"; -const nVDash = "⊯"; -const nVdash = "⊮"; -const nabla = "∇"; -const nacute = "ń"; -const nang = "∠⃒"; -const nap = "≉"; -const napE = "⩰̸"; -const napid = "≋̸"; -const napos = "ʼn"; -const napprox = "≉"; -const natur = "♮"; -const natural = "♮"; -const naturals = "ℕ"; -const nbs = " "; -const nbsp = " "; -const nbump = "≎̸"; -const nbumpe = "≏̸"; -const ncap = "⩃"; -const ncaron = "ň"; -const ncedil = "ņ"; -const ncong = "≇"; -const ncongdot = "⩭̸"; -const ncup = "⩂"; -const ncy = "н"; -const ndash = "–"; -const ne = "≠"; -const neArr = "⇗"; -const nearhk = "⤤"; -const nearr = "↗"; -const nearrow = "↗"; -const nedot = "≐̸"; -const nequiv = "≢"; -const nesear = "⤨"; -const nesim = "≂̸"; -const nexist = "∄"; -const nexists = "∄"; -const nfr = "𝔫"; -const ngE = "≧̸"; -const nge = "≱"; -const ngeq = "≱"; -const ngeqq = "≧̸"; -const ngeqslant = "⩾̸"; -const nges = "⩾̸"; -const ngsim = "≵"; -const ngt = "≯"; -const ngtr = "≯"; -const nhArr = "⇎"; -const nharr = "↮"; -const nhpar = "⫲"; -const ni = "∋"; -const nis = "⋼"; -const nisd = "⋺"; -const niv = "∋"; -const njcy = "њ"; -const nlArr = "⇍"; -const nlE = "≦̸"; -const nlarr = "↚"; -const nldr = "‥"; -const nle = "≰"; -const nleftarrow = "↚"; -const nleftrightarrow = "↮"; -const nleq = "≰"; -const nleqq = "≦̸"; -const nleqslant = "⩽̸"; -const nles = "⩽̸"; -const nless = "≮"; -const nlsim = "≴"; -const nlt = "≮"; -const nltri = "⋪"; -const nltrie = "⋬"; -const nmid = "∤"; -const nopf = "𝕟"; -const no = "¬"; -const not = "¬"; -const notin = "∉"; -const notinE = "⋹̸"; -const notindot = "⋵̸"; -const notinva = "∉"; -const notinvb = "⋷"; -const notinvc = "⋶"; -const notni = "∌"; -const notniva = "∌"; -const notnivb = "⋾"; -const notnivc = "⋽"; -const npar = "∦"; -const nparallel = "∦"; -const nparsl = "⫽⃥"; -const npart = "∂̸"; -const npolint = "⨔"; -const npr = "⊀"; -const nprcue = "⋠"; -const npre = "⪯̸"; -const nprec = "⊀"; -const npreceq = "⪯̸"; -const nrArr = "⇏"; -const nrarr = "↛"; -const nrarrc = "⤳̸"; -const nrarrw = "↝̸"; -const nrightarrow = "↛"; -const nrtri = "⋫"; -const nrtrie = "⋭"; -const nsc = "⊁"; -const nsccue = "⋡"; -const nsce = "⪰̸"; -const nscr = "𝓃"; -const nshortmid = "∤"; -const nshortparallel = "∦"; -const nsim = "≁"; -const nsime = "≄"; -const nsimeq = "≄"; -const nsmid = "∤"; -const nspar = "∦"; -const nsqsube = "⋢"; -const nsqsupe = "⋣"; -const nsub = "⊄"; -const nsubE = "⫅̸"; -const nsube = "⊈"; -const nsubset = "⊂⃒"; -const nsubseteq = "⊈"; -const nsubseteqq = "⫅̸"; -const nsucc = "⊁"; -const nsucceq = "⪰̸"; -const nsup = "⊅"; -const nsupE = "⫆̸"; -const nsupe = "⊉"; -const nsupset = "⊃⃒"; -const nsupseteq = "⊉"; -const nsupseteqq = "⫆̸"; -const ntgl = "≹"; -const ntild = "ñ"; -const ntilde = "ñ"; -const ntlg = "≸"; -const ntriangleleft = "⋪"; -const ntrianglelefteq = "⋬"; -const ntriangleright = "⋫"; -const ntrianglerighteq = "⋭"; -const nu = "ν"; -const num = "#"; -const numero = "№"; -const numsp = " "; -const nvDash = "⊭"; -const nvHarr = "⤄"; -const nvap = "≍⃒"; -const nvdash = "⊬"; -const nvge = "≥⃒"; -const nvgt = ">⃒"; -const nvinfin = "⧞"; -const nvlArr = "⤂"; -const nvle = "≤⃒"; -const nvlt = "<⃒"; -const nvltrie = "⊴⃒"; -const nvrArr = "⤃"; -const nvrtrie = "⊵⃒"; -const nvsim = "∼⃒"; -const nwArr = "⇖"; -const nwarhk = "⤣"; -const nwarr = "↖"; -const nwarrow = "↖"; -const nwnear = "⤧"; -const oS = "Ⓢ"; -const oacut = "ó"; -const oacute = "ó"; -const oast = "⊛"; -const ocir = "ô"; -const ocirc = "ô"; -const ocy = "о"; -const odash = "⊝"; -const odblac = "ő"; -const odiv = "⨸"; -const odot = "⊙"; -const odsold = "⦼"; -const oelig = "œ"; -const ofcir = "⦿"; -const ofr = "𝔬"; -const ogon = "˛"; -const ograv = "ò"; -const ograve = "ò"; -const ogt = "⧁"; -const ohbar = "⦵"; -const ohm = "Ω"; -const oint = "∮"; -const olarr = "↺"; -const olcir = "⦾"; -const olcross = "⦻"; -const oline = "‾"; -const olt = "⧀"; -const omacr = "ō"; -const omega = "ω"; -const omicron = "ο"; -const omid = "⦶"; -const ominus = "⊖"; -const oopf = "𝕠"; -const opar = "⦷"; -const operp = "⦹"; -const oplus = "⊕"; -const or = "∨"; -const orarr = "↻"; -const ord = "º"; -const order = "ℴ"; -const orderof = "ℴ"; -const ordf = "ª"; -const ordm = "º"; -const origof = "⊶"; -const oror = "⩖"; -const orslope = "⩗"; -const orv = "⩛"; -const oscr = "ℴ"; -const oslas = "ø"; -const oslash = "ø"; -const osol = "⊘"; -const otild = "õ"; -const otilde = "õ"; -const otimes = "⊗"; -const otimesas = "⨶"; -const oum = "ö"; -const ouml = "ö"; -const ovbar = "⌽"; -const par = "¶"; -const para = "¶"; -const parallel = "∥"; -const parsim = "⫳"; -const parsl = "⫽"; -const part = "∂"; -const pcy = "п"; -const percnt = "%"; -const period = "."; -const permil = "‰"; -const perp = "⊥"; -const pertenk = "‱"; -const pfr = "𝔭"; -const phi = "φ"; -const phiv = "ϕ"; -const phmmat = "ℳ"; -const phone = "☎"; -const pi = "π"; -const pitchfork = "⋔"; -const piv = "ϖ"; -const planck = "ℏ"; -const planckh = "ℎ"; -const plankv = "ℏ"; -const plus = "+"; -const plusacir = "⨣"; -const plusb = "⊞"; -const pluscir = "⨢"; -const plusdo = "∔"; -const plusdu = "⨥"; -const pluse = "⩲"; -const plusm = "±"; -const plusmn = "±"; -const plussim = "⨦"; -const plustwo = "⨧"; -const pm = "±"; -const pointint = "⨕"; -const popf = "𝕡"; -const poun = "£"; -const pound = "£"; -const pr = "≺"; -const prE = "⪳"; -const prap = "⪷"; -const prcue = "≼"; -const pre = "⪯"; -const prec = "≺"; -const precapprox = "⪷"; -const preccurlyeq = "≼"; -const preceq = "⪯"; -const precnapprox = "⪹"; -const precneqq = "⪵"; -const precnsim = "⋨"; -const precsim = "≾"; -const prime = "′"; -const primes = "ℙ"; -const prnE = "⪵"; -const prnap = "⪹"; -const prnsim = "⋨"; -const prod = "∏"; -const profalar = "⌮"; -const profline = "⌒"; -const profsurf = "⌓"; -const prop = "∝"; -const propto = "∝"; -const prsim = "≾"; -const prurel = "⊰"; -const pscr = "𝓅"; -const psi = "ψ"; -const puncsp = " "; -const qfr = "𝔮"; -const qint = "⨌"; -const qopf = "𝕢"; -const qprime = "⁗"; -const qscr = "𝓆"; -const quaternions = "ℍ"; -const quatint = "⨖"; -const quest = "?"; -const questeq = "≟"; -const quo = "\""; -const quot = "\""; -const rAarr = "⇛"; -const rArr = "⇒"; -const rAtail = "⤜"; -const rBarr = "⤏"; -const rHar = "⥤"; -const race = "∽̱"; -const racute = "ŕ"; -const radic = "√"; -const raemptyv = "⦳"; -const rang = "⟩"; -const rangd = "⦒"; -const range = "⦥"; -const rangle = "⟩"; -const raqu = "»"; -const raquo = "»"; -const rarr = "→"; -const rarrap = "⥵"; -const rarrb = "⇥"; -const rarrbfs = "⤠"; -const rarrc = "⤳"; -const rarrfs = "⤞"; -const rarrhk = "↪"; -const rarrlp = "↬"; -const rarrpl = "⥅"; -const rarrsim = "⥴"; -const rarrtl = "↣"; -const rarrw = "↝"; -const ratail = "⤚"; -const ratio = "∶"; -const rationals = "ℚ"; -const rbarr = "⤍"; -const rbbrk = "❳"; -const rbrace = "}"; -const rbrack = "]"; -const rbrke = "⦌"; -const rbrksld = "⦎"; -const rbrkslu = "⦐"; -const rcaron = "ř"; -const rcedil = "ŗ"; -const rceil = "⌉"; -const rcub = "}"; -const rcy = "р"; -const rdca = "⤷"; -const rdldhar = "⥩"; -const rdquo = "”"; -const rdquor = "”"; -const rdsh = "↳"; -const real = "ℜ"; -const realine = "ℛ"; -const realpart = "ℜ"; -const reals = "ℝ"; -const rect = "▭"; -const re$4 = "®"; -const reg = "®"; -const rfisht = "⥽"; -const rfloor = "⌋"; -const rfr = "𝔯"; -const rhard = "⇁"; -const rharu = "⇀"; -const rharul = "⥬"; -const rho = "ρ"; -const rhov = "ϱ"; -const rightarrow = "→"; -const rightarrowtail = "↣"; -const rightharpoondown = "⇁"; -const rightharpoonup = "⇀"; -const rightleftarrows = "⇄"; -const rightleftharpoons = "⇌"; -const rightrightarrows = "⇉"; -const rightsquigarrow = "↝"; -const rightthreetimes = "⋌"; -const ring = "˚"; -const risingdotseq = "≓"; -const rlarr = "⇄"; -const rlhar = "⇌"; -const rlm = "‏"; -const rmoust = "⎱"; -const rmoustache = "⎱"; -const rnmid = "⫮"; -const roang = "⟭"; -const roarr = "⇾"; -const robrk = "⟧"; -const ropar = "⦆"; -const ropf = "𝕣"; -const roplus = "⨮"; -const rotimes = "⨵"; -const rpar = ")"; -const rpargt = "⦔"; -const rppolint = "⨒"; -const rrarr = "⇉"; -const rsaquo = "›"; -const rscr = "𝓇"; -const rsh = "↱"; -const rsqb = "]"; -const rsquo = "’"; -const rsquor = "’"; -const rthree = "⋌"; -const rtimes = "⋊"; -const rtri = "▹"; -const rtrie = "⊵"; -const rtrif = "▸"; -const rtriltri = "⧎"; -const ruluhar = "⥨"; -const rx = "℞"; -const sacute = "ś"; -const sbquo = "‚"; -const sc = "≻"; -const scE = "⪴"; -const scap = "⪸"; -const scaron = "š"; -const sccue = "≽"; -const sce = "⪰"; -const scedil = "ş"; -const scirc = "ŝ"; -const scnE = "⪶"; -const scnap = "⪺"; -const scnsim = "⋩"; -const scpolint = "⨓"; -const scsim = "≿"; -const scy = "с"; -const sdot = "⋅"; -const sdotb = "⊡"; -const sdote = "⩦"; -const seArr = "⇘"; -const searhk = "⤥"; -const searr = "↘"; -const searrow = "↘"; -const sec = "§"; -const sect = "§"; -const semi = ";"; -const seswar = "⤩"; -const setminus = "∖"; -const setmn = "∖"; -const sext = "✶"; -const sfr = "𝔰"; -const sfrown = "⌢"; -const sharp = "♯"; -const shchcy = "щ"; -const shcy = "ш"; -const shortmid = "∣"; -const shortparallel = "∥"; -const sh = "­"; -const shy = "­"; -const sigma = "σ"; -const sigmaf = "ς"; -const sigmav = "ς"; -const sim = "∼"; -const simdot = "⩪"; -const sime = "≃"; -const simeq = "≃"; -const simg = "⪞"; -const simgE = "⪠"; -const siml = "⪝"; -const simlE = "⪟"; -const simne = "≆"; -const simplus = "⨤"; -const simrarr = "⥲"; -const slarr = "←"; -const smallsetminus = "∖"; -const smashp = "⨳"; -const smeparsl = "⧤"; -const smid = "∣"; -const smile = "⌣"; -const smt = "⪪"; -const smte = "⪬"; -const smtes = "⪬︀"; -const softcy = "ь"; -const sol = "/"; -const solb = "⧄"; -const solbar = "⌿"; -const sopf = "𝕤"; -const spades = "♠"; -const spadesuit = "♠"; -const spar = "∥"; -const sqcap = "⊓"; -const sqcaps = "⊓︀"; -const sqcup = "⊔"; -const sqcups = "⊔︀"; -const sqsub = "⊏"; -const sqsube = "⊑"; -const sqsubset = "⊏"; -const sqsubseteq = "⊑"; -const sqsup = "⊐"; -const sqsupe = "⊒"; -const sqsupset = "⊐"; -const sqsupseteq = "⊒"; -const squ = "□"; -const square = "□"; -const squarf = "▪"; -const squf = "▪"; -const srarr = "→"; -const sscr = "𝓈"; -const ssetmn = "∖"; -const ssmile = "⌣"; -const sstarf = "⋆"; -const star = "☆"; -const starf = "★"; -const straightepsilon = "ϵ"; -const straightphi = "ϕ"; -const strns = "¯"; -const sub = "⊂"; -const subE = "⫅"; -const subdot = "⪽"; -const sube = "⊆"; -const subedot = "⫃"; -const submult = "⫁"; -const subnE = "⫋"; -const subne = "⊊"; -const subplus = "⪿"; -const subrarr = "⥹"; -const subset = "⊂"; -const subseteq = "⊆"; -const subseteqq = "⫅"; -const subsetneq = "⊊"; -const subsetneqq = "⫋"; -const subsim = "⫇"; -const subsub = "⫕"; -const subsup = "⫓"; -const succ = "≻"; -const succapprox = "⪸"; -const succcurlyeq = "≽"; -const succeq = "⪰"; -const succnapprox = "⪺"; -const succneqq = "⪶"; -const succnsim = "⋩"; -const succsim = "≿"; -const sum = "∑"; -const sung = "♪"; -const sup = "⊃"; -const sup1 = "¹"; -const sup2 = "²"; -const sup3 = "³"; -const supE = "⫆"; -const supdot = "⪾"; -const supdsub = "⫘"; -const supe = "⊇"; -const supedot = "⫄"; -const suphsol = "⟉"; -const suphsub = "⫗"; -const suplarr = "⥻"; -const supmult = "⫂"; -const supnE = "⫌"; -const supne = "⊋"; -const supplus = "⫀"; -const supset = "⊃"; -const supseteq = "⊇"; -const supseteqq = "⫆"; -const supsetneq = "⊋"; -const supsetneqq = "⫌"; -const supsim = "⫈"; -const supsub = "⫔"; -const supsup = "⫖"; -const swArr = "⇙"; -const swarhk = "⤦"; -const swarr = "↙"; -const swarrow = "↙"; -const swnwar = "⤪"; -const szli = "ß"; -const szlig = "ß"; -const target = "⌖"; -const tau = "τ"; -const tbrk = "⎴"; -const tcaron = "ť"; -const tcedil = "ţ"; -const tcy = "т"; -const tdot = "⃛"; -const telrec = "⌕"; -const tfr = "𝔱"; -const there4 = "∴"; -const therefore = "∴"; -const theta = "θ"; -const thetasym = "ϑ"; -const thetav = "ϑ"; -const thickapprox = "≈"; -const thicksim = "∼"; -const thinsp = " "; -const thkap = "≈"; -const thksim = "∼"; -const thor = "þ"; -const thorn = "þ"; -const tilde = "˜"; -const time = "×"; -const times = "×"; -const timesb = "⊠"; -const timesbar = "⨱"; -const timesd = "⨰"; -const tint = "∭"; -const toea = "⤨"; -const top = "⊤"; -const topbot = "⌶"; -const topcir = "⫱"; -const topf = "𝕥"; -const topfork = "⫚"; -const tosa = "⤩"; -const tprime = "‴"; -const trade = "™"; -const triangle = "▵"; -const triangledown = "▿"; -const triangleleft = "◃"; -const trianglelefteq = "⊴"; -const triangleq = "≜"; -const triangleright = "▹"; -const trianglerighteq = "⊵"; -const tridot = "◬"; -const trie = "≜"; -const triminus = "⨺"; -const triplus = "⨹"; -const trisb = "⧍"; -const tritime = "⨻"; -const trpezium = "⏢"; -const tscr = "𝓉"; -const tscy = "ц"; -const tshcy = "ћ"; -const tstrok = "ŧ"; -const twixt = "≬"; -const twoheadleftarrow = "↞"; -const twoheadrightarrow = "↠"; -const uArr = "⇑"; -const uHar = "⥣"; -const uacut = "ú"; -const uacute = "ú"; -const uarr = "↑"; -const ubrcy = "ў"; -const ubreve = "ŭ"; -const ucir = "û"; -const ucirc = "û"; -const ucy = "у"; -const udarr = "⇅"; -const udblac = "ű"; -const udhar = "⥮"; -const ufisht = "⥾"; -const ufr = "𝔲"; -const ugrav = "ù"; -const ugrave = "ù"; -const uharl = "↿"; -const uharr = "↾"; -const uhblk = "▀"; -const ulcorn = "⌜"; -const ulcorner = "⌜"; -const ulcrop = "⌏"; -const ultri = "◸"; -const umacr = "ū"; -const um = "¨"; -const uml = "¨"; -const uogon = "ų"; -const uopf = "𝕦"; -const uparrow = "↑"; -const updownarrow = "↕"; -const upharpoonleft = "↿"; -const upharpoonright = "↾"; -const uplus = "⊎"; -const upsi = "υ"; -const upsih = "ϒ"; -const upsilon = "υ"; -const upuparrows = "⇈"; -const urcorn = "⌝"; -const urcorner = "⌝"; -const urcrop = "⌎"; -const uring = "ů"; -const urtri = "◹"; -const uscr = "𝓊"; -const utdot = "⋰"; -const utilde = "ũ"; -const utri = "▵"; -const utrif = "▴"; -const uuarr = "⇈"; -const uum = "ü"; -const uuml = "ü"; -const uwangle = "⦧"; -const vArr = "⇕"; -const vBar = "⫨"; -const vBarv = "⫩"; -const vDash = "⊨"; -const vangrt = "⦜"; -const varepsilon = "ϵ"; -const varkappa = "ϰ"; -const varnothing = "∅"; -const varphi = "ϕ"; -const varpi = "ϖ"; -const varpropto = "∝"; -const varr = "↕"; -const varrho = "ϱ"; -const varsigma = "ς"; -const varsubsetneq = "⊊︀"; -const varsubsetneqq = "⫋︀"; -const varsupsetneq = "⊋︀"; -const varsupsetneqq = "⫌︀"; -const vartheta = "ϑ"; -const vartriangleleft = "⊲"; -const vartriangleright = "⊳"; -const vcy = "в"; -const vdash = "⊢"; -const vee = "∨"; -const veebar = "⊻"; -const veeeq = "≚"; -const vellip = "⋮"; -const verbar = "|"; -const vert = "|"; -const vfr = "𝔳"; -const vltri = "⊲"; -const vnsub = "⊂⃒"; -const vnsup = "⊃⃒"; -const vopf = "𝕧"; -const vprop = "∝"; -const vrtri = "⊳"; -const vscr = "𝓋"; -const vsubnE = "⫋︀"; -const vsubne = "⊊︀"; -const vsupnE = "⫌︀"; -const vsupne = "⊋︀"; -const vzigzag = "⦚"; -const wcirc = "ŵ"; -const wedbar = "⩟"; -const wedge = "∧"; -const wedgeq = "≙"; -const weierp = "℘"; -const wfr = "𝔴"; -const wopf = "𝕨"; -const wp = "℘"; -const wr = "≀"; -const wreath = "≀"; -const wscr = "𝓌"; -const xcap = "⋂"; -const xcirc = "◯"; -const xcup = "⋃"; -const xdtri = "▽"; -const xfr = "𝔵"; -const xhArr = "⟺"; -const xharr = "⟷"; -const xi = "ξ"; -const xlArr = "⟸"; -const xlarr = "⟵"; -const xmap = "⟼"; -const xnis = "⋻"; -const xodot = "⨀"; -const xopf = "𝕩"; -const xoplus = "⨁"; -const xotime = "⨂"; -const xrArr = "⟹"; -const xrarr = "⟶"; -const xscr = "𝓍"; -const xsqcup = "⨆"; -const xuplus = "⨄"; -const xutri = "△"; -const xvee = "⋁"; -const xwedge = "⋀"; -const yacut = "ý"; -const yacute = "ý"; -const yacy = "я"; -const ycirc = "ŷ"; -const ycy = "ы"; -const ye = "¥"; -const yen = "¥"; -const yfr = "𝔶"; -const yicy = "ї"; -const yopf = "𝕪"; -const yscr = "𝓎"; -const yucy = "ю"; -const yum = "ÿ"; -const yuml = "ÿ"; -const zacute = "ź"; -const zcaron = "ž"; -const zcy = "з"; -const zdot = "ż"; -const zeetrf = "ℨ"; -const zeta = "ζ"; -const zfr = "𝔷"; -const zhcy = "ж"; -const zigrarr = "⇝"; -const zopf = "𝕫"; -const zscr = "𝓏"; -const zwj = "‍"; -const zwnj = "‌"; -var require$$0 = { - AEli: AEli, - AElig: AElig, - AM: AM, - AMP: AMP, - Aacut: Aacut, - Aacute: Aacute, - Abreve: Abreve, - Acir: Acir, - Acirc: Acirc, - Acy: Acy, - Afr: Afr, - Agrav: Agrav, - Agrave: Agrave, - Alpha: Alpha, - Amacr: Amacr, - And: And, - Aogon: Aogon, - Aopf: Aopf, - ApplyFunction: ApplyFunction, - Arin: Arin, - Aring: Aring, - Ascr: Ascr, - Assign: Assign, - Atild: Atild, - Atilde: Atilde, - Aum: Aum, - Auml: Auml, - Backslash: Backslash, - Barv: Barv, - Barwed: Barwed, - Bcy: Bcy, - Because: Because, - Bernoullis: Bernoullis, - Beta: Beta, - Bfr: Bfr, - Bopf: Bopf, - Breve: Breve, - Bscr: Bscr, - Bumpeq: Bumpeq, - CHcy: CHcy, - COP: COP, - COPY: COPY, - Cacute: Cacute, - Cap: Cap, - CapitalDifferentialD: CapitalDifferentialD, - Cayleys: Cayleys, - Ccaron: Ccaron, - Ccedi: Ccedi, - Ccedil: Ccedil, - Ccirc: Ccirc, - Cconint: Cconint, - Cdot: Cdot, - Cedilla: Cedilla, - CenterDot: CenterDot, - Cfr: Cfr, - Chi: Chi, - CircleDot: CircleDot, - CircleMinus: CircleMinus, - CirclePlus: CirclePlus, - CircleTimes: CircleTimes, - ClockwiseContourIntegral: ClockwiseContourIntegral, - CloseCurlyDoubleQuote: CloseCurlyDoubleQuote, - CloseCurlyQuote: CloseCurlyQuote, - Colon: Colon, - Colone: Colone, - Congruent: Congruent, - Conint: Conint, - ContourIntegral: ContourIntegral, - Copf: Copf, - Coproduct: Coproduct, - CounterClockwiseContourIntegral: CounterClockwiseContourIntegral, - Cross: Cross, - Cscr: Cscr, - Cup: Cup, - CupCap: CupCap, - DD: DD, - DDotrahd: DDotrahd, - DJcy: DJcy, - DScy: DScy, - DZcy: DZcy, - Dagger: Dagger, - Darr: Darr, - Dashv: Dashv, - Dcaron: Dcaron, - Dcy: Dcy, - Del: Del, - Delta: Delta, - Dfr: Dfr, - DiacriticalAcute: DiacriticalAcute, - DiacriticalDot: DiacriticalDot, - DiacriticalDoubleAcute: DiacriticalDoubleAcute, - DiacriticalGrave: DiacriticalGrave, - DiacriticalTilde: DiacriticalTilde, - Diamond: Diamond, - DifferentialD: DifferentialD, - Dopf: Dopf, - Dot: Dot, - DotDot: DotDot, - DotEqual: DotEqual, - DoubleContourIntegral: DoubleContourIntegral, - DoubleDot: DoubleDot, - DoubleDownArrow: DoubleDownArrow, - DoubleLeftArrow: DoubleLeftArrow, - DoubleLeftRightArrow: DoubleLeftRightArrow, - DoubleLeftTee: DoubleLeftTee, - DoubleLongLeftArrow: DoubleLongLeftArrow, - DoubleLongLeftRightArrow: DoubleLongLeftRightArrow, - DoubleLongRightArrow: DoubleLongRightArrow, - DoubleRightArrow: DoubleRightArrow, - DoubleRightTee: DoubleRightTee, - DoubleUpArrow: DoubleUpArrow, - DoubleUpDownArrow: DoubleUpDownArrow, - DoubleVerticalBar: DoubleVerticalBar, - DownArrow: DownArrow, - DownArrowBar: DownArrowBar, - DownArrowUpArrow: DownArrowUpArrow, - DownBreve: DownBreve, - DownLeftRightVector: DownLeftRightVector, - DownLeftTeeVector: DownLeftTeeVector, - DownLeftVector: DownLeftVector, - DownLeftVectorBar: DownLeftVectorBar, - DownRightTeeVector: DownRightTeeVector, - DownRightVector: DownRightVector, - DownRightVectorBar: DownRightVectorBar, - DownTee: DownTee, - DownTeeArrow: DownTeeArrow, - Downarrow: Downarrow, - Dscr: Dscr, - Dstrok: Dstrok, - ENG: ENG, - ET: ET, - ETH: ETH, - Eacut: Eacut, - Eacute: Eacute, - Ecaron: Ecaron, - Ecir: Ecir, - Ecirc: Ecirc, - Ecy: Ecy, - Edot: Edot, - Efr: Efr, - Egrav: Egrav, - Egrave: Egrave, - Element: Element, - Emacr: Emacr, - EmptySmallSquare: EmptySmallSquare, - EmptyVerySmallSquare: EmptyVerySmallSquare, - Eogon: Eogon, - Eopf: Eopf, - Epsilon: Epsilon, - Equal: Equal, - EqualTilde: EqualTilde, - Equilibrium: Equilibrium, - Escr: Escr, - Esim: Esim, - Eta: Eta, - Eum: Eum, - Euml: Euml, - Exists: Exists, - ExponentialE: ExponentialE, - Fcy: Fcy, - Ffr: Ffr, - FilledSmallSquare: FilledSmallSquare, - FilledVerySmallSquare: FilledVerySmallSquare, - Fopf: Fopf, - ForAll: ForAll, - Fouriertrf: Fouriertrf, - Fscr: Fscr, - GJcy: GJcy, - G: G, - GT: GT, - Gamma: Gamma, - Gammad: Gammad, - Gbreve: Gbreve, - Gcedil: Gcedil, - Gcirc: Gcirc, - Gcy: Gcy, - Gdot: Gdot, - Gfr: Gfr, - Gg: Gg, - Gopf: Gopf, - GreaterEqual: GreaterEqual, - GreaterEqualLess: GreaterEqualLess, - GreaterFullEqual: GreaterFullEqual, - GreaterGreater: GreaterGreater, - GreaterLess: GreaterLess, - GreaterSlantEqual: GreaterSlantEqual, - GreaterTilde: GreaterTilde, - Gscr: Gscr, - Gt: Gt, - HARDcy: HARDcy, - Hacek: Hacek, - Hat: Hat, - Hcirc: Hcirc, - Hfr: Hfr, - HilbertSpace: HilbertSpace, - Hopf: Hopf, - HorizontalLine: HorizontalLine, - Hscr: Hscr, - Hstrok: Hstrok, - HumpDownHump: HumpDownHump, - HumpEqual: HumpEqual, - IEcy: IEcy, - IJlig: IJlig, - IOcy: IOcy, - Iacut: Iacut, - Iacute: Iacute, - Icir: Icir, - Icirc: Icirc, - Icy: Icy, - Idot: Idot, - Ifr: Ifr, - Igrav: Igrav, - Igrave: Igrave, - Im: Im, - Imacr: Imacr, - ImaginaryI: ImaginaryI, - Implies: Implies, - Int: Int, - Integral: Integral, - Intersection: Intersection, - InvisibleComma: InvisibleComma, - InvisibleTimes: InvisibleTimes, - Iogon: Iogon, - Iopf: Iopf, - Iota: Iota, - Iscr: Iscr, - Itilde: Itilde, - Iukcy: Iukcy, - Ium: Ium, - Iuml: Iuml, - Jcirc: Jcirc, - Jcy: Jcy, - Jfr: Jfr, - Jopf: Jopf, - Jscr: Jscr, - Jsercy: Jsercy, - Jukcy: Jukcy, - KHcy: KHcy, - KJcy: KJcy, - Kappa: Kappa, - Kcedil: Kcedil, - Kcy: Kcy, - Kfr: Kfr, - Kopf: Kopf, - Kscr: Kscr, - LJcy: LJcy, - L: L, - LT: LT, - Lacute: Lacute, - Lambda: Lambda, - Lang: Lang, - Laplacetrf: Laplacetrf, - Larr: Larr, - Lcaron: Lcaron, - Lcedil: Lcedil, - Lcy: Lcy, - LeftAngleBracket: LeftAngleBracket, - LeftArrow: LeftArrow, - LeftArrowBar: LeftArrowBar, - LeftArrowRightArrow: LeftArrowRightArrow, - LeftCeiling: LeftCeiling, - LeftDoubleBracket: LeftDoubleBracket, - LeftDownTeeVector: LeftDownTeeVector, - LeftDownVector: LeftDownVector, - LeftDownVectorBar: LeftDownVectorBar, - LeftFloor: LeftFloor, - LeftRightArrow: LeftRightArrow, - LeftRightVector: LeftRightVector, - LeftTee: LeftTee, - LeftTeeArrow: LeftTeeArrow, - LeftTeeVector: LeftTeeVector, - LeftTriangle: LeftTriangle, - LeftTriangleBar: LeftTriangleBar, - LeftTriangleEqual: LeftTriangleEqual, - LeftUpDownVector: LeftUpDownVector, - LeftUpTeeVector: LeftUpTeeVector, - LeftUpVector: LeftUpVector, - LeftUpVectorBar: LeftUpVectorBar, - LeftVector: LeftVector, - LeftVectorBar: LeftVectorBar, - Leftarrow: Leftarrow, - Leftrightarrow: Leftrightarrow, - LessEqualGreater: LessEqualGreater, - LessFullEqual: LessFullEqual, - LessGreater: LessGreater, - LessLess: LessLess, - LessSlantEqual: LessSlantEqual, - LessTilde: LessTilde, - Lfr: Lfr, - Ll: Ll, - Lleftarrow: Lleftarrow, - Lmidot: Lmidot, - LongLeftArrow: LongLeftArrow, - LongLeftRightArrow: LongLeftRightArrow, - LongRightArrow: LongRightArrow, - Longleftarrow: Longleftarrow, - Longleftrightarrow: Longleftrightarrow, - Longrightarrow: Longrightarrow, - Lopf: Lopf, - LowerLeftArrow: LowerLeftArrow, - LowerRightArrow: LowerRightArrow, - Lscr: Lscr, - Lsh: Lsh, - Lstrok: Lstrok, - Lt: Lt, - "Map": "⤅", - Mcy: Mcy, - MediumSpace: MediumSpace, - Mellintrf: Mellintrf, - Mfr: Mfr, - MinusPlus: MinusPlus, - Mopf: Mopf, - Mscr: Mscr, - Mu: Mu, - NJcy: NJcy, - Nacute: Nacute, - Ncaron: Ncaron, - Ncedil: Ncedil, - Ncy: Ncy, - NegativeMediumSpace: NegativeMediumSpace, - NegativeThickSpace: NegativeThickSpace, - NegativeThinSpace: NegativeThinSpace, - NegativeVeryThinSpace: NegativeVeryThinSpace, - NestedGreaterGreater: NestedGreaterGreater, - NestedLessLess: NestedLessLess, - NewLine: NewLine, - Nfr: Nfr, - NoBreak: NoBreak, - NonBreakingSpace: NonBreakingSpace, - Nopf: Nopf, - Not: Not, - NotCongruent: NotCongruent, - NotCupCap: NotCupCap, - NotDoubleVerticalBar: NotDoubleVerticalBar, - NotElement: NotElement, - NotEqual: NotEqual, - NotEqualTilde: NotEqualTilde, - NotExists: NotExists, - NotGreater: NotGreater, - NotGreaterEqual: NotGreaterEqual, - NotGreaterFullEqual: NotGreaterFullEqual, - NotGreaterGreater: NotGreaterGreater, - NotGreaterLess: NotGreaterLess, - NotGreaterSlantEqual: NotGreaterSlantEqual, - NotGreaterTilde: NotGreaterTilde, - NotHumpDownHump: NotHumpDownHump, - NotHumpEqual: NotHumpEqual, - NotLeftTriangle: NotLeftTriangle, - NotLeftTriangleBar: NotLeftTriangleBar, - NotLeftTriangleEqual: NotLeftTriangleEqual, - NotLess: NotLess, - NotLessEqual: NotLessEqual, - NotLessGreater: NotLessGreater, - NotLessLess: NotLessLess, - NotLessSlantEqual: NotLessSlantEqual, - NotLessTilde: NotLessTilde, - NotNestedGreaterGreater: NotNestedGreaterGreater, - NotNestedLessLess: NotNestedLessLess, - NotPrecedes: NotPrecedes, - NotPrecedesEqual: NotPrecedesEqual, - NotPrecedesSlantEqual: NotPrecedesSlantEqual, - NotReverseElement: NotReverseElement, - NotRightTriangle: NotRightTriangle, - NotRightTriangleBar: NotRightTriangleBar, - NotRightTriangleEqual: NotRightTriangleEqual, - NotSquareSubset: NotSquareSubset, - NotSquareSubsetEqual: NotSquareSubsetEqual, - NotSquareSuperset: NotSquareSuperset, - NotSquareSupersetEqual: NotSquareSupersetEqual, - NotSubset: NotSubset, - NotSubsetEqual: NotSubsetEqual, - NotSucceeds: NotSucceeds, - NotSucceedsEqual: NotSucceedsEqual, - NotSucceedsSlantEqual: NotSucceedsSlantEqual, - NotSucceedsTilde: NotSucceedsTilde, - NotSuperset: NotSuperset, - NotSupersetEqual: NotSupersetEqual, - NotTilde: NotTilde, - NotTildeEqual: NotTildeEqual, - NotTildeFullEqual: NotTildeFullEqual, - NotTildeTilde: NotTildeTilde, - NotVerticalBar: NotVerticalBar, - Nscr: Nscr, - Ntild: Ntild, - Ntilde: Ntilde, - Nu: Nu, - OElig: OElig, - Oacut: Oacut, - Oacute: Oacute, - Ocir: Ocir, - Ocirc: Ocirc, - Ocy: Ocy, - Odblac: Odblac, - Ofr: Ofr, - Ograv: Ograv, - Ograve: Ograve, - Omacr: Omacr, - Omega: Omega, - Omicron: Omicron, - Oopf: Oopf, - OpenCurlyDoubleQuote: OpenCurlyDoubleQuote, - OpenCurlyQuote: OpenCurlyQuote, - Or: Or, - Oscr: Oscr, - Oslas: Oslas, - Oslash: Oslash, - Otild: Otild, - Otilde: Otilde, - Otimes: Otimes, - Oum: Oum, - Ouml: Ouml, - OverBar: OverBar, - OverBrace: OverBrace, - OverBracket: OverBracket, - OverParenthesis: OverParenthesis, - PartialD: PartialD, - Pcy: Pcy, - Pfr: Pfr, - Phi: Phi, - Pi: Pi, - PlusMinus: PlusMinus, - Poincareplane: Poincareplane, - Popf: Popf, - Pr: Pr, - Precedes: Precedes, - PrecedesEqual: PrecedesEqual, - PrecedesSlantEqual: PrecedesSlantEqual, - PrecedesTilde: PrecedesTilde, - Prime: Prime, - Product: Product, - Proportion: Proportion, - Proportional: Proportional, - Pscr: Pscr, - Psi: Psi, - QUO: QUO, - QUOT: QUOT, - Qfr: Qfr, - Qopf: Qopf, - Qscr: Qscr, - RBarr: RBarr, - RE: RE, - REG: REG, - Racute: Racute, - Rang: Rang, - Rarr: Rarr, - Rarrtl: Rarrtl, - Rcaron: Rcaron, - Rcedil: Rcedil, - Rcy: Rcy, - Re: Re, - ReverseElement: ReverseElement, - ReverseEquilibrium: ReverseEquilibrium, - ReverseUpEquilibrium: ReverseUpEquilibrium, - Rfr: Rfr, - Rho: Rho, - RightAngleBracket: RightAngleBracket, - RightArrow: RightArrow, - RightArrowBar: RightArrowBar, - RightArrowLeftArrow: RightArrowLeftArrow, - RightCeiling: RightCeiling, - RightDoubleBracket: RightDoubleBracket, - RightDownTeeVector: RightDownTeeVector, - RightDownVector: RightDownVector, - RightDownVectorBar: RightDownVectorBar, - RightFloor: RightFloor, - RightTee: RightTee, - RightTeeArrow: RightTeeArrow, - RightTeeVector: RightTeeVector, - RightTriangle: RightTriangle, - RightTriangleBar: RightTriangleBar, - RightTriangleEqual: RightTriangleEqual, - RightUpDownVector: RightUpDownVector, - RightUpTeeVector: RightUpTeeVector, - RightUpVector: RightUpVector, - RightUpVectorBar: RightUpVectorBar, - RightVector: RightVector, - RightVectorBar: RightVectorBar, - Rightarrow: Rightarrow, - Ropf: Ropf, - RoundImplies: RoundImplies, - Rrightarrow: Rrightarrow, - Rscr: Rscr, - Rsh: Rsh, - RuleDelayed: RuleDelayed, - SHCHcy: SHCHcy, - SHcy: SHcy, - SOFTcy: SOFTcy, - Sacute: Sacute, - Sc: Sc, - Scaron: Scaron, - Scedil: Scedil, - Scirc: Scirc, - Scy: Scy, - Sfr: Sfr, - ShortDownArrow: ShortDownArrow, - ShortLeftArrow: ShortLeftArrow, - ShortRightArrow: ShortRightArrow, - ShortUpArrow: ShortUpArrow, - Sigma: Sigma, - SmallCircle: SmallCircle, - Sopf: Sopf, - Sqrt: Sqrt, - Square: Square, - SquareIntersection: SquareIntersection, - SquareSubset: SquareSubset, - SquareSubsetEqual: SquareSubsetEqual, - SquareSuperset: SquareSuperset, - SquareSupersetEqual: SquareSupersetEqual, - SquareUnion: SquareUnion, - Sscr: Sscr, - Star: Star, - Sub: Sub, - Subset: Subset, - SubsetEqual: SubsetEqual, - Succeeds: Succeeds, - SucceedsEqual: SucceedsEqual, - SucceedsSlantEqual: SucceedsSlantEqual, - SucceedsTilde: SucceedsTilde, - SuchThat: SuchThat, - Sum: Sum, - Sup: Sup, - Superset: Superset, - SupersetEqual: SupersetEqual, - Supset: Supset, - THOR: THOR, - THORN: THORN, - TRADE: TRADE, - TSHcy: TSHcy, - TScy: TScy, - Tab: Tab, - Tau: Tau, - Tcaron: Tcaron, - Tcedil: Tcedil, - Tcy: Tcy, - Tfr: Tfr, - Therefore: Therefore, - Theta: Theta, - ThickSpace: ThickSpace, - ThinSpace: ThinSpace, - Tilde: Tilde, - TildeEqual: TildeEqual, - TildeFullEqual: TildeFullEqual, - TildeTilde: TildeTilde, - Topf: Topf, - TripleDot: TripleDot, - Tscr: Tscr, - Tstrok: Tstrok, - Uacut: Uacut, - Uacute: Uacute, - Uarr: Uarr, - Uarrocir: Uarrocir, - Ubrcy: Ubrcy, - Ubreve: Ubreve, - Ucir: Ucir, - Ucirc: Ucirc, - Ucy: Ucy, - Udblac: Udblac, - Ufr: Ufr, - Ugrav: Ugrav, - Ugrave: Ugrave, - Umacr: Umacr, - UnderBar: UnderBar, - UnderBrace: UnderBrace, - UnderBracket: UnderBracket, - UnderParenthesis: UnderParenthesis, - Union: Union, - UnionPlus: UnionPlus, - Uogon: Uogon, - Uopf: Uopf, - UpArrow: UpArrow, - UpArrowBar: UpArrowBar, - UpArrowDownArrow: UpArrowDownArrow, - UpDownArrow: UpDownArrow, - UpEquilibrium: UpEquilibrium, - UpTee: UpTee, - UpTeeArrow: UpTeeArrow, - Uparrow: Uparrow, - Updownarrow: Updownarrow, - UpperLeftArrow: UpperLeftArrow, - UpperRightArrow: UpperRightArrow, - Upsi: Upsi, - Upsilon: Upsilon, - Uring: Uring, - Uscr: Uscr, - Utilde: Utilde, - Uum: Uum, - Uuml: Uuml, - VDash: VDash, - Vbar: Vbar, - Vcy: Vcy, - Vdash: Vdash, - Vdashl: Vdashl, - Vee: Vee, - Verbar: Verbar, - Vert: Vert, - VerticalBar: VerticalBar, - VerticalLine: VerticalLine, - VerticalSeparator: VerticalSeparator, - VerticalTilde: VerticalTilde, - VeryThinSpace: VeryThinSpace, - Vfr: Vfr, - Vopf: Vopf, - Vscr: Vscr, - Vvdash: Vvdash, - Wcirc: Wcirc, - Wedge: Wedge, - Wfr: Wfr, - Wopf: Wopf, - Wscr: Wscr, - Xfr: Xfr, - Xi: Xi, - Xopf: Xopf, - Xscr: Xscr, - YAcy: YAcy, - YIcy: YIcy, - YUcy: YUcy, - Yacut: Yacut, - Yacute: Yacute, - Ycirc: Ycirc, - Ycy: Ycy, - Yfr: Yfr, - Yopf: Yopf, - Yscr: Yscr, - Yuml: Yuml, - ZHcy: ZHcy, - Zacute: Zacute, - Zcaron: Zcaron, - Zcy: Zcy, - Zdot: Zdot, - ZeroWidthSpace: ZeroWidthSpace, - Zeta: Zeta, - Zfr: Zfr, - Zopf: Zopf, - Zscr: Zscr, - aacut: aacut, - aacute: aacute, - abreve: abreve, - ac: ac, - acE: acE, - acd: acd, - acir: acir, - acirc: acirc, - acut: acut, - acute: acute, - acy: acy, - aeli: aeli, - aelig: aelig, - af: af, - afr: afr, - agrav: agrav, - agrave: agrave, - alefsym: alefsym, - aleph: aleph, - alpha: alpha, - amacr: amacr, - amalg: amalg, - am: am, - amp: amp, - and: and, - andand: andand, - andd: andd, - andslope: andslope, - andv: andv, - ang: ang, - ange: ange, - angle: angle, - angmsd: angmsd, - angmsdaa: angmsdaa, - angmsdab: angmsdab, - angmsdac: angmsdac, - angmsdad: angmsdad, - angmsdae: angmsdae, - angmsdaf: angmsdaf, - angmsdag: angmsdag, - angmsdah: angmsdah, - angrt: angrt, - angrtvb: angrtvb, - angrtvbd: angrtvbd, - angsph: angsph, - angst: angst, - angzarr: angzarr, - aogon: aogon, - aopf: aopf, - ap: ap, - apE: apE, - apacir: apacir, - ape: ape, - apid: apid, - apos: apos, - approx: approx, - approxeq: approxeq, - arin: arin, - aring: aring, - ascr: ascr, - ast: ast, - asymp: asymp, - asympeq: asympeq, - atild: atild, - atilde: atilde, - aum: aum, - auml: auml, - awconint: awconint, - awint: awint, - bNot: bNot, - backcong: backcong, - backepsilon: backepsilon, - backprime: backprime, - backsim: backsim, - backsimeq: backsimeq, - barvee: barvee, - barwed: barwed, - barwedge: barwedge, - bbrk: bbrk, - bbrktbrk: bbrktbrk, - bcong: bcong, - bcy: bcy, - bdquo: bdquo, - becaus: becaus, - because: because, - bemptyv: bemptyv, - bepsi: bepsi, - bernou: bernou, - beta: beta, - beth: beth, - between: between, - bfr: bfr, - bigcap: bigcap, - bigcirc: bigcirc, - bigcup: bigcup, - bigodot: bigodot, - bigoplus: bigoplus, - bigotimes: bigotimes, - bigsqcup: bigsqcup, - bigstar: bigstar, - bigtriangledown: bigtriangledown, - bigtriangleup: bigtriangleup, - biguplus: biguplus, - bigvee: bigvee, - bigwedge: bigwedge, - bkarow: bkarow, - blacklozenge: blacklozenge, - blacksquare: blacksquare, - blacktriangle: blacktriangle, - blacktriangledown: blacktriangledown, - blacktriangleleft: blacktriangleleft, - blacktriangleright: blacktriangleright, - blank: blank, - blk12: blk12, - blk14: blk14, - blk34: blk34, - block: block, - bne: bne, - bnequiv: bnequiv, - bnot: bnot, - bopf: bopf, - bot: bot, - bottom: bottom, - bowtie: bowtie, - boxDL: boxDL, - boxDR: boxDR, - boxDl: boxDl, - boxDr: boxDr, - boxH: boxH, - boxHD: boxHD, - boxHU: boxHU, - boxHd: boxHd, - boxHu: boxHu, - boxUL: boxUL, - boxUR: boxUR, - boxUl: boxUl, - boxUr: boxUr, - boxV: boxV, - boxVH: boxVH, - boxVL: boxVL, - boxVR: boxVR, - boxVh: boxVh, - boxVl: boxVl, - boxVr: boxVr, - boxbox: boxbox, - boxdL: boxdL, - boxdR: boxdR, - boxdl: boxdl, - boxdr: boxdr, - boxh: boxh, - boxhD: boxhD, - boxhU: boxhU, - boxhd: boxhd, - boxhu: boxhu, - boxminus: boxminus, - boxplus: boxplus, - boxtimes: boxtimes, - boxuL: boxuL, - boxuR: boxuR, - boxul: boxul, - boxur: boxur, - boxv: boxv, - boxvH: boxvH, - boxvL: boxvL, - boxvR: boxvR, - boxvh: boxvh, - boxvl: boxvl, - boxvr: boxvr, - bprime: bprime, - breve: breve, - brvba: brvba, - brvbar: brvbar, - bscr: bscr, - bsemi: bsemi, - bsim: bsim, - bsime: bsime, - bsol: bsol, - bsolb: bsolb, - bsolhsub: bsolhsub, - bull: bull, - bullet: bullet, - bump: bump, - bumpE: bumpE, - bumpe: bumpe, - bumpeq: bumpeq, - cacute: cacute, - cap: cap, - capand: capand, - capbrcup: capbrcup, - capcap: capcap, - capcup: capcup, - capdot: capdot, - caps: caps, - caret: caret, - caron: caron, - ccaps: ccaps, - ccaron: ccaron, - ccedi: ccedi, - ccedil: ccedil, - ccirc: ccirc, - ccups: ccups, - ccupssm: ccupssm, - cdot: cdot, - cedi: cedi, - cedil: cedil, - cemptyv: cemptyv, - cen: cen, - cent: cent, - centerdot: centerdot, - cfr: cfr, - chcy: chcy, - check: check$1, - checkmark: checkmark, - chi: chi, - cir: cir, - cirE: cirE, - circ: circ, - circeq: circeq, - circlearrowleft: circlearrowleft, - circlearrowright: circlearrowright, - circledR: circledR, - circledS: circledS, - circledast: circledast, - circledcirc: circledcirc, - circleddash: circleddash, - cire: cire, - cirfnint: cirfnint, - cirmid: cirmid, - cirscir: cirscir, - clubs: clubs, - clubsuit: clubsuit, - colon: colon, - colone: colone, - coloneq: coloneq, - comma: comma, - commat: commat, - comp: comp, - compfn: compfn, - complement: complement, - complexes: complexes, - cong: cong, - congdot: congdot, - conint: conint, - copf: copf, - coprod: coprod, - cop: cop, - copy: copy, - copysr: copysr, - crarr: crarr, - cross: cross, - cscr: cscr, - csub: csub, - csube: csube, - csup: csup, - csupe: csupe, - ctdot: ctdot, - cudarrl: cudarrl, - cudarrr: cudarrr, - cuepr: cuepr, - cuesc: cuesc, - cularr: cularr, - cularrp: cularrp, - cup: cup, - cupbrcap: cupbrcap, - cupcap: cupcap, - cupcup: cupcup, - cupdot: cupdot, - cupor: cupor, - cups: cups, - curarr: curarr, - curarrm: curarrm, - curlyeqprec: curlyeqprec, - curlyeqsucc: curlyeqsucc, - curlyvee: curlyvee, - curlywedge: curlywedge, - curre: curre, - curren: curren, - curvearrowleft: curvearrowleft, - curvearrowright: curvearrowright, - cuvee: cuvee, - cuwed: cuwed, - cwconint: cwconint, - cwint: cwint, - cylcty: cylcty, - dArr: dArr, - dHar: dHar, - dagger: dagger, - daleth: daleth, - darr: darr, - dash: dash, - dashv: dashv, - dbkarow: dbkarow, - dblac: dblac, - dcaron: dcaron, - dcy: dcy, - dd: dd, - ddagger: ddagger, - ddarr: ddarr, - ddotseq: ddotseq, - de: de, - deg: deg, - delta: delta, - demptyv: demptyv, - dfisht: dfisht, - dfr: dfr, - dharl: dharl, - dharr: dharr, - diam: diam, - diamond: diamond, - diamondsuit: diamondsuit, - diams: diams, - die: die, - digamma: digamma, - disin: disin, - div: div, - divid: divid, - divide: divide, - divideontimes: divideontimes, - divonx: divonx, - djcy: djcy, - dlcorn: dlcorn, - dlcrop: dlcrop, - dollar: dollar, - dopf: dopf, - dot: dot, - doteq: doteq, - doteqdot: doteqdot, - dotminus: dotminus, - dotplus: dotplus, - dotsquare: dotsquare, - doublebarwedge: doublebarwedge, - downarrow: downarrow, - downdownarrows: downdownarrows, - downharpoonleft: downharpoonleft, - downharpoonright: downharpoonright, - drbkarow: drbkarow, - drcorn: drcorn, - drcrop: drcrop, - dscr: dscr, - dscy: dscy, - dsol: dsol, - dstrok: dstrok, - dtdot: dtdot, - dtri: dtri, - dtrif: dtrif, - duarr: duarr, - duhar: duhar, - dwangle: dwangle, - dzcy: dzcy, - dzigrarr: dzigrarr, - eDDot: eDDot, - eDot: eDot, - eacut: eacut, - eacute: eacute, - easter: easter, - ecaron: ecaron, - ecir: ecir, - ecirc: ecirc, - ecolon: ecolon, - ecy: ecy, - edot: edot, - ee: ee, - efDot: efDot, - efr: efr, - eg: eg, - egrav: egrav, - egrave: egrave, - egs: egs, - egsdot: egsdot, - el: el, - elinters: elinters, - ell: ell, - els: els, - elsdot: elsdot, - emacr: emacr, - empty: empty, - emptyset: emptyset, - emptyv: emptyv, - emsp13: emsp13, - emsp14: emsp14, - emsp: emsp, - eng: eng, - ensp: ensp, - eogon: eogon, - eopf: eopf, - epar: epar, - eparsl: eparsl, - eplus: eplus, - epsi: epsi, - epsilon: epsilon, - epsiv: epsiv, - eqcirc: eqcirc, - eqcolon: eqcolon, - eqsim: eqsim, - eqslantgtr: eqslantgtr, - eqslantless: eqslantless, - equals: equals, - equest: equest, - equiv: equiv, - equivDD: equivDD, - eqvparsl: eqvparsl, - erDot: erDot, - erarr: erarr, - escr: escr, - esdot: esdot, - esim: esim, - eta: eta, - et: et, - eth: eth, - eum: eum, - euml: euml, - euro: euro, - excl: excl, - exist: exist, - expectation: expectation, - exponentiale: exponentiale, - fallingdotseq: fallingdotseq, - fcy: fcy, - female: female, - ffilig: ffilig, - fflig: fflig, - ffllig: ffllig, - ffr: ffr, - filig: filig, - fjlig: fjlig, - flat: flat, - fllig: fllig, - fltns: fltns, - fnof: fnof, - fopf: fopf, - forall: forall, - fork: fork, - forkv: forkv, - fpartint: fpartint, - frac1: frac1, - frac12: frac12, - frac13: frac13, - frac14: frac14, - frac15: frac15, - frac16: frac16, - frac18: frac18, - frac23: frac23, - frac25: frac25, - frac3: frac3, - frac34: frac34, - frac35: frac35, - frac38: frac38, - frac45: frac45, - frac56: frac56, - frac58: frac58, - frac78: frac78, - frasl: frasl, - frown: frown, - fscr: fscr, - gE: gE, - gEl: gEl, - gacute: gacute, - gamma: gamma, - gammad: gammad, - gap: gap, - gbreve: gbreve, - gcirc: gcirc, - gcy: gcy, - gdot: gdot, - ge: ge, - gel: gel, - geq: geq, - geqq: geqq, - geqslant: geqslant, - ges: ges, - gescc: gescc, - gesdot: gesdot, - gesdoto: gesdoto, - gesdotol: gesdotol, - gesl: gesl, - gesles: gesles, - gfr: gfr, - gg: gg, - ggg: ggg, - gimel: gimel, - gjcy: gjcy, - gl: gl, - glE: glE, - gla: gla, - glj: glj, - gnE: gnE, - gnap: gnap, - gnapprox: gnapprox, - gne: gne, - gneq: gneq, - gneqq: gneqq, - gnsim: gnsim, - gopf: gopf, - grave: grave, - gscr: gscr, - gsim: gsim, - gsime: gsime, - gsiml: gsiml, - g: g, - gt: gt, - gtcc: gtcc, - gtcir: gtcir, - gtdot: gtdot, - gtlPar: gtlPar, - gtquest: gtquest, - gtrapprox: gtrapprox, - gtrarr: gtrarr, - gtrdot: gtrdot, - gtreqless: gtreqless, - gtreqqless: gtreqqless, - gtrless: gtrless, - gtrsim: gtrsim, - gvertneqq: gvertneqq, - gvnE: gvnE, - hArr: hArr, - hairsp: hairsp, - half: half, - hamilt: hamilt, - hardcy: hardcy, - harr: harr, - harrcir: harrcir, - harrw: harrw, - hbar: hbar, - hcirc: hcirc, - hearts: hearts, - heartsuit: heartsuit, - hellip: hellip, - hercon: hercon, - hfr: hfr, - hksearow: hksearow, - hkswarow: hkswarow, - hoarr: hoarr, - homtht: homtht, - hookleftarrow: hookleftarrow, - hookrightarrow: hookrightarrow, - hopf: hopf, - horbar: horbar, - hscr: hscr, - hslash: hslash, - hstrok: hstrok, - hybull: hybull, - hyphen: hyphen, - iacut: iacut, - iacute: iacute, - ic: ic, - icir: icir, - icirc: icirc, - icy: icy, - iecy: iecy, - iexc: iexc, - iexcl: iexcl, - iff: iff, - ifr: ifr, - igrav: igrav, - igrave: igrave, - ii: ii, - iiiint: iiiint, - iiint: iiint, - iinfin: iinfin, - iiota: iiota, - ijlig: ijlig, - imacr: imacr, - image: image$1, - imagline: imagline, - imagpart: imagpart, - imath: imath, - imof: imof, - imped: imped, - "in": "∈", - incare: incare, - infin: infin, - infintie: infintie, - inodot: inodot, - int: int$1, - intcal: intcal, - integers: integers, - intercal: intercal, - intlarhk: intlarhk, - intprod: intprod, - iocy: iocy, - iogon: iogon, - iopf: iopf, - iota: iota, - iprod: iprod, - iques: iques, - iquest: iquest, - iscr: iscr, - isin: isin, - isinE: isinE, - isindot: isindot, - isins: isins, - isinsv: isinsv, - isinv: isinv, - it: it, - itilde: itilde, - iukcy: iukcy, - ium: ium, - iuml: iuml, - jcirc: jcirc, - jcy: jcy, - jfr: jfr, - jmath: jmath, - jopf: jopf, - jscr: jscr, - jsercy: jsercy, - jukcy: jukcy, - kappa: kappa, - kappav: kappav, - kcedil: kcedil, - kcy: kcy, - kfr: kfr, - kgreen: kgreen, - khcy: khcy, - kjcy: kjcy, - kopf: kopf, - kscr: kscr, - lAarr: lAarr, - lArr: lArr, - lAtail: lAtail, - lBarr: lBarr, - lE: lE, - lEg: lEg, - lHar: lHar, - lacute: lacute, - laemptyv: laemptyv, - lagran: lagran, - lambda: lambda, - lang: lang, - langd: langd, - langle: langle, - lap: lap, - laqu: laqu, - laquo: laquo, - larr: larr, - larrb: larrb, - larrbfs: larrbfs, - larrfs: larrfs, - larrhk: larrhk, - larrlp: larrlp, - larrpl: larrpl, - larrsim: larrsim, - larrtl: larrtl, - lat: lat, - latail: latail, - late: late, - lates: lates, - lbarr: lbarr, - lbbrk: lbbrk, - lbrace: lbrace, - lbrack: lbrack, - lbrke: lbrke, - lbrksld: lbrksld, - lbrkslu: lbrkslu, - lcaron: lcaron, - lcedil: lcedil, - lceil: lceil, - lcub: lcub, - lcy: lcy, - ldca: ldca, - ldquo: ldquo, - ldquor: ldquor, - ldrdhar: ldrdhar, - ldrushar: ldrushar, - ldsh: ldsh, - le: le, - leftarrow: leftarrow, - leftarrowtail: leftarrowtail, - leftharpoondown: leftharpoondown, - leftharpoonup: leftharpoonup, - leftleftarrows: leftleftarrows, - leftrightarrow: leftrightarrow, - leftrightarrows: leftrightarrows, - leftrightharpoons: leftrightharpoons, - leftrightsquigarrow: leftrightsquigarrow, - leftthreetimes: leftthreetimes, - leg: leg, - leq: leq, - leqq: leqq, - leqslant: leqslant, - les: les, - lescc: lescc, - lesdot: lesdot, - lesdoto: lesdoto, - lesdotor: lesdotor, - lesg: lesg, - lesges: lesges, - lessapprox: lessapprox, - lessdot: lessdot, - lesseqgtr: lesseqgtr, - lesseqqgtr: lesseqqgtr, - lessgtr: lessgtr, - lesssim: lesssim, - lfisht: lfisht, - lfloor: lfloor, - lfr: lfr, - lg: lg, - lgE: lgE, - lhard: lhard, - lharu: lharu, - lharul: lharul, - lhblk: lhblk, - ljcy: ljcy, - ll: ll, - llarr: llarr, - llcorner: llcorner, - llhard: llhard, - lltri: lltri, - lmidot: lmidot, - lmoust: lmoust, - lmoustache: lmoustache, - lnE: lnE, - lnap: lnap, - lnapprox: lnapprox, - lne: lne, - lneq: lneq, - lneqq: lneqq, - lnsim: lnsim, - loang: loang, - loarr: loarr, - lobrk: lobrk, - longleftarrow: longleftarrow, - longleftrightarrow: longleftrightarrow, - longmapsto: longmapsto, - longrightarrow: longrightarrow, - looparrowleft: looparrowleft, - looparrowright: looparrowright, - lopar: lopar, - lopf: lopf, - loplus: loplus, - lotimes: lotimes, - lowast: lowast, - lowbar: lowbar, - loz: loz, - lozenge: lozenge, - lozf: lozf, - lpar: lpar, - lparlt: lparlt, - lrarr: lrarr, - lrcorner: lrcorner, - lrhar: lrhar, - lrhard: lrhard, - lrm: lrm, - lrtri: lrtri, - lsaquo: lsaquo, - lscr: lscr, - lsh: lsh, - lsim: lsim, - lsime: lsime, - lsimg: lsimg, - lsqb: lsqb, - lsquo: lsquo, - lsquor: lsquor, - lstrok: lstrok, - l: l, - lt: lt$1, - ltcc: ltcc, - ltcir: ltcir, - ltdot: ltdot, - lthree: lthree, - ltimes: ltimes, - ltlarr: ltlarr, - ltquest: ltquest, - ltrPar: ltrPar, - ltri: ltri, - ltrie: ltrie, - ltrif: ltrif, - lurdshar: lurdshar, - luruhar: luruhar, - lvertneqq: lvertneqq, - lvnE: lvnE, - mDDot: mDDot, - mac: mac, - macr: macr, - male: male, - malt: malt, - maltese: maltese, - map: map$1, - mapsto: mapsto, - mapstodown: mapstodown, - mapstoleft: mapstoleft, - mapstoup: mapstoup, - marker: marker, - mcomma: mcomma, - mcy: mcy, - mdash: mdash, - measuredangle: measuredangle, - mfr: mfr, - mho: mho, - micr: micr, - micro: micro, - mid: mid, - midast: midast, - midcir: midcir, - middo: middo, - middot: middot, - minus: minus, - minusb: minusb, - minusd: minusd, - minusdu: minusdu, - mlcp: mlcp, - mldr: mldr, - mnplus: mnplus, - models: models, - mopf: mopf, - mp: mp, - mscr: mscr, - mstpos: mstpos, - mu: mu, - multimap: multimap, - mumap: mumap, - nGg: nGg, - nGt: nGt, - nGtv: nGtv, - nLeftarrow: nLeftarrow, - nLeftrightarrow: nLeftrightarrow, - nLl: nLl, - nLt: nLt, - nLtv: nLtv, - nRightarrow: nRightarrow, - nVDash: nVDash, - nVdash: nVdash, - nabla: nabla, - nacute: nacute, - nang: nang, - nap: nap, - napE: napE, - napid: napid, - napos: napos, - napprox: napprox, - natur: natur, - natural: natural, - naturals: naturals, - nbs: nbs, - nbsp: nbsp, - nbump: nbump, - nbumpe: nbumpe, - ncap: ncap, - ncaron: ncaron, - ncedil: ncedil, - ncong: ncong, - ncongdot: ncongdot, - ncup: ncup, - ncy: ncy, - ndash: ndash, - ne: ne, - neArr: neArr, - nearhk: nearhk, - nearr: nearr, - nearrow: nearrow, - nedot: nedot, - nequiv: nequiv, - nesear: nesear, - nesim: nesim, - nexist: nexist, - nexists: nexists, - nfr: nfr, - ngE: ngE, - nge: nge, - ngeq: ngeq, - ngeqq: ngeqq, - ngeqslant: ngeqslant, - nges: nges, - ngsim: ngsim, - ngt: ngt, - ngtr: ngtr, - nhArr: nhArr, - nharr: nharr, - nhpar: nhpar, - ni: ni, - nis: nis, - nisd: nisd, - niv: niv, - njcy: njcy, - nlArr: nlArr, - nlE: nlE, - nlarr: nlarr, - nldr: nldr, - nle: nle, - nleftarrow: nleftarrow, - nleftrightarrow: nleftrightarrow, - nleq: nleq, - nleqq: nleqq, - nleqslant: nleqslant, - nles: nles, - nless: nless, - nlsim: nlsim, - nlt: nlt, - nltri: nltri, - nltrie: nltrie, - nmid: nmid, - nopf: nopf, - no: no, - not: not, - notin: notin, - notinE: notinE, - notindot: notindot, - notinva: notinva, - notinvb: notinvb, - notinvc: notinvc, - notni: notni, - notniva: notniva, - notnivb: notnivb, - notnivc: notnivc, - npar: npar, - nparallel: nparallel, - nparsl: nparsl, - npart: npart, - npolint: npolint, - npr: npr, - nprcue: nprcue, - npre: npre, - nprec: nprec, - npreceq: npreceq, - nrArr: nrArr, - nrarr: nrarr, - nrarrc: nrarrc, - nrarrw: nrarrw, - nrightarrow: nrightarrow, - nrtri: nrtri, - nrtrie: nrtrie, - nsc: nsc, - nsccue: nsccue, - nsce: nsce, - nscr: nscr, - nshortmid: nshortmid, - nshortparallel: nshortparallel, - nsim: nsim, - nsime: nsime, - nsimeq: nsimeq, - nsmid: nsmid, - nspar: nspar, - nsqsube: nsqsube, - nsqsupe: nsqsupe, - nsub: nsub, - nsubE: nsubE, - nsube: nsube, - nsubset: nsubset, - nsubseteq: nsubseteq, - nsubseteqq: nsubseteqq, - nsucc: nsucc, - nsucceq: nsucceq, - nsup: nsup, - nsupE: nsupE, - nsupe: nsupe, - nsupset: nsupset, - nsupseteq: nsupseteq, - nsupseteqq: nsupseteqq, - ntgl: ntgl, - ntild: ntild, - ntilde: ntilde, - ntlg: ntlg, - ntriangleleft: ntriangleleft, - ntrianglelefteq: ntrianglelefteq, - ntriangleright: ntriangleright, - ntrianglerighteq: ntrianglerighteq, - nu: nu, - num: num, - numero: numero, - numsp: numsp, - nvDash: nvDash, - nvHarr: nvHarr, - nvap: nvap, - nvdash: nvdash, - nvge: nvge, - nvgt: nvgt, - nvinfin: nvinfin, - nvlArr: nvlArr, - nvle: nvle, - nvlt: nvlt, - nvltrie: nvltrie, - nvrArr: nvrArr, - nvrtrie: nvrtrie, - nvsim: nvsim, - nwArr: nwArr, - nwarhk: nwarhk, - nwarr: nwarr, - nwarrow: nwarrow, - nwnear: nwnear, - oS: oS, - oacut: oacut, - oacute: oacute, - oast: oast, - ocir: ocir, - ocirc: ocirc, - ocy: ocy, - odash: odash, - odblac: odblac, - odiv: odiv, - odot: odot, - odsold: odsold, - oelig: oelig, - ofcir: ofcir, - ofr: ofr, - ogon: ogon, - ograv: ograv, - ograve: ograve, - ogt: ogt, - ohbar: ohbar, - ohm: ohm, - oint: oint, - olarr: olarr, - olcir: olcir, - olcross: olcross, - oline: oline, - olt: olt, - omacr: omacr, - omega: omega, - omicron: omicron, - omid: omid, - ominus: ominus, - oopf: oopf, - opar: opar, - operp: operp, - oplus: oplus, - or: or, - orarr: orarr, - ord: ord, - order: order, - orderof: orderof, - ordf: ordf, - ordm: ordm, - origof: origof, - oror: oror, - orslope: orslope, - orv: orv, - oscr: oscr, - oslas: oslas, - oslash: oslash, - osol: osol, - otild: otild, - otilde: otilde, - otimes: otimes, - otimesas: otimesas, - oum: oum, - ouml: ouml, - ovbar: ovbar, - par: par, - para: para, - parallel: parallel, - parsim: parsim, - parsl: parsl, - part: part, - pcy: pcy, - percnt: percnt, - period: period, - permil: permil, - perp: perp, - pertenk: pertenk, - pfr: pfr, - phi: phi, - phiv: phiv, - phmmat: phmmat, - phone: phone, - pi: pi, - pitchfork: pitchfork, - piv: piv, - planck: planck, - planckh: planckh, - plankv: plankv, - plus: plus, - plusacir: plusacir, - plusb: plusb, - pluscir: pluscir, - plusdo: plusdo, - plusdu: plusdu, - pluse: pluse, - plusm: plusm, - plusmn: plusmn, - plussim: plussim, - plustwo: plustwo, - pm: pm, - pointint: pointint, - popf: popf, - poun: poun, - pound: pound, - pr: pr, - prE: prE, - prap: prap, - prcue: prcue, - pre: pre, - prec: prec, - precapprox: precapprox, - preccurlyeq: preccurlyeq, - preceq: preceq, - precnapprox: precnapprox, - precneqq: precneqq, - precnsim: precnsim, - precsim: precsim, - prime: prime, - primes: primes, - prnE: prnE, - prnap: prnap, - prnsim: prnsim, - prod: prod, - profalar: profalar, - profline: profline, - profsurf: profsurf, - prop: prop, - propto: propto, - prsim: prsim, - prurel: prurel, - pscr: pscr, - psi: psi, - puncsp: puncsp, - qfr: qfr, - qint: qint, - qopf: qopf, - qprime: qprime, - qscr: qscr, - quaternions: quaternions, - quatint: quatint, - quest: quest, - questeq: questeq, - quo: quo, - quot: quot, - rAarr: rAarr, - rArr: rArr, - rAtail: rAtail, - rBarr: rBarr, - rHar: rHar, - race: race, - racute: racute, - radic: radic, - raemptyv: raemptyv, - rang: rang, - rangd: rangd, - range: range, - rangle: rangle, - raqu: raqu, - raquo: raquo, - rarr: rarr, - rarrap: rarrap, - rarrb: rarrb, - rarrbfs: rarrbfs, - rarrc: rarrc, - rarrfs: rarrfs, - rarrhk: rarrhk, - rarrlp: rarrlp, - rarrpl: rarrpl, - rarrsim: rarrsim, - rarrtl: rarrtl, - rarrw: rarrw, - ratail: ratail, - ratio: ratio, - rationals: rationals, - rbarr: rbarr, - rbbrk: rbbrk, - rbrace: rbrace, - rbrack: rbrack, - rbrke: rbrke, - rbrksld: rbrksld, - rbrkslu: rbrkslu, - rcaron: rcaron, - rcedil: rcedil, - rceil: rceil, - rcub: rcub, - rcy: rcy, - rdca: rdca, - rdldhar: rdldhar, - rdquo: rdquo, - rdquor: rdquor, - rdsh: rdsh, - real: real, - realine: realine, - realpart: realpart, - reals: reals, - rect: rect, - re: re$4, - reg: reg, - rfisht: rfisht, - rfloor: rfloor, - rfr: rfr, - rhard: rhard, - rharu: rharu, - rharul: rharul, - rho: rho, - rhov: rhov, - rightarrow: rightarrow, - rightarrowtail: rightarrowtail, - rightharpoondown: rightharpoondown, - rightharpoonup: rightharpoonup, - rightleftarrows: rightleftarrows, - rightleftharpoons: rightleftharpoons, - rightrightarrows: rightrightarrows, - rightsquigarrow: rightsquigarrow, - rightthreetimes: rightthreetimes, - ring: ring, - risingdotseq: risingdotseq, - rlarr: rlarr, - rlhar: rlhar, - rlm: rlm, - rmoust: rmoust, - rmoustache: rmoustache, - rnmid: rnmid, - roang: roang, - roarr: roarr, - robrk: robrk, - ropar: ropar, - ropf: ropf, - roplus: roplus, - rotimes: rotimes, - rpar: rpar, - rpargt: rpargt, - rppolint: rppolint, - rrarr: rrarr, - rsaquo: rsaquo, - rscr: rscr, - rsh: rsh, - rsqb: rsqb, - rsquo: rsquo, - rsquor: rsquor, - rthree: rthree, - rtimes: rtimes, - rtri: rtri, - rtrie: rtrie, - rtrif: rtrif, - rtriltri: rtriltri, - ruluhar: ruluhar, - rx: rx, - sacute: sacute, - sbquo: sbquo, - sc: sc, - scE: scE, - scap: scap, - scaron: scaron, - sccue: sccue, - sce: sce, - scedil: scedil, - scirc: scirc, - scnE: scnE, - scnap: scnap, - scnsim: scnsim, - scpolint: scpolint, - scsim: scsim, - scy: scy, - sdot: sdot, - sdotb: sdotb, - sdote: sdote, - seArr: seArr, - searhk: searhk, - searr: searr, - searrow: searrow, - sec: sec, - sect: sect, - semi: semi, - seswar: seswar, - setminus: setminus, - setmn: setmn, - sext: sext, - sfr: sfr, - sfrown: sfrown, - sharp: sharp, - shchcy: shchcy, - shcy: shcy, - shortmid: shortmid, - shortparallel: shortparallel, - sh: sh, - shy: shy, - sigma: sigma, - sigmaf: sigmaf, - sigmav: sigmav, - sim: sim, - simdot: simdot, - sime: sime, - simeq: simeq, - simg: simg, - simgE: simgE, - siml: siml, - simlE: simlE, - simne: simne, - simplus: simplus, - simrarr: simrarr, - slarr: slarr, - smallsetminus: smallsetminus, - smashp: smashp, - smeparsl: smeparsl, - smid: smid, - smile: smile, - smt: smt, - smte: smte, - smtes: smtes, - softcy: softcy, - sol: sol, - solb: solb, - solbar: solbar, - sopf: sopf, - spades: spades, - spadesuit: spadesuit, - spar: spar, - sqcap: sqcap, - sqcaps: sqcaps, - sqcup: sqcup, - sqcups: sqcups, - sqsub: sqsub, - sqsube: sqsube, - sqsubset: sqsubset, - sqsubseteq: sqsubseteq, - sqsup: sqsup, - sqsupe: sqsupe, - sqsupset: sqsupset, - sqsupseteq: sqsupseteq, - squ: squ, - square: square, - squarf: squarf, - squf: squf, - srarr: srarr, - sscr: sscr, - ssetmn: ssetmn, - ssmile: ssmile, - sstarf: sstarf, - star: star, - starf: starf, - straightepsilon: straightepsilon, - straightphi: straightphi, - strns: strns, - sub: sub, - subE: subE, - subdot: subdot, - sube: sube, - subedot: subedot, - submult: submult, - subnE: subnE, - subne: subne, - subplus: subplus, - subrarr: subrarr, - subset: subset, - subseteq: subseteq, - subseteqq: subseteqq, - subsetneq: subsetneq, - subsetneqq: subsetneqq, - subsim: subsim, - subsub: subsub, - subsup: subsup, - succ: succ, - succapprox: succapprox, - succcurlyeq: succcurlyeq, - succeq: succeq, - succnapprox: succnapprox, - succneqq: succneqq, - succnsim: succnsim, - succsim: succsim, - sum: sum, - sung: sung, - sup: sup, - sup1: sup1, - sup2: sup2, - sup3: sup3, - supE: supE, - supdot: supdot, - supdsub: supdsub, - supe: supe, - supedot: supedot, - suphsol: suphsol, - suphsub: suphsub, - suplarr: suplarr, - supmult: supmult, - supnE: supnE, - supne: supne, - supplus: supplus, - supset: supset, - supseteq: supseteq, - supseteqq: supseteqq, - supsetneq: supsetneq, - supsetneqq: supsetneqq, - supsim: supsim, - supsub: supsub, - supsup: supsup, - swArr: swArr, - swarhk: swarhk, - swarr: swarr, - swarrow: swarrow, - swnwar: swnwar, - szli: szli, - szlig: szlig, - target: target, - tau: tau, - tbrk: tbrk, - tcaron: tcaron, - tcedil: tcedil, - tcy: tcy, - tdot: tdot, - telrec: telrec, - tfr: tfr, - there4: there4, - therefore: therefore, - theta: theta, - thetasym: thetasym, - thetav: thetav, - thickapprox: thickapprox, - thicksim: thicksim, - thinsp: thinsp, - thkap: thkap, - thksim: thksim, - thor: thor, - thorn: thorn, - tilde: tilde, - time: time, - times: times, - timesb: timesb, - timesbar: timesbar, - timesd: timesd, - tint: tint, - toea: toea, - top: top, - topbot: topbot, - topcir: topcir, - topf: topf, - topfork: topfork, - tosa: tosa, - tprime: tprime, - trade: trade, - triangle: triangle, - triangledown: triangledown, - triangleleft: triangleleft, - trianglelefteq: trianglelefteq, - triangleq: triangleq, - triangleright: triangleright, - trianglerighteq: trianglerighteq, - tridot: tridot, - trie: trie, - triminus: triminus, - triplus: triplus, - trisb: trisb, - tritime: tritime, - trpezium: trpezium, - tscr: tscr, - tscy: tscy, - tshcy: tshcy, - tstrok: tstrok, - twixt: twixt, - twoheadleftarrow: twoheadleftarrow, - twoheadrightarrow: twoheadrightarrow, - uArr: uArr, - uHar: uHar, - uacut: uacut, - uacute: uacute, - uarr: uarr, - ubrcy: ubrcy, - ubreve: ubreve, - ucir: ucir, - ucirc: ucirc, - ucy: ucy, - udarr: udarr, - udblac: udblac, - udhar: udhar, - ufisht: ufisht, - ufr: ufr, - ugrav: ugrav, - ugrave: ugrave, - uharl: uharl, - uharr: uharr, - uhblk: uhblk, - ulcorn: ulcorn, - ulcorner: ulcorner, - ulcrop: ulcrop, - ultri: ultri, - umacr: umacr, - um: um, - uml: uml, - uogon: uogon, - uopf: uopf, - uparrow: uparrow, - updownarrow: updownarrow, - upharpoonleft: upharpoonleft, - upharpoonright: upharpoonright, - uplus: uplus, - upsi: upsi, - upsih: upsih, - upsilon: upsilon, - upuparrows: upuparrows, - urcorn: urcorn, - urcorner: urcorner, - urcrop: urcrop, - uring: uring, - urtri: urtri, - uscr: uscr, - utdot: utdot, - utilde: utilde, - utri: utri, - utrif: utrif, - uuarr: uuarr, - uum: uum, - uuml: uuml, - uwangle: uwangle, - vArr: vArr, - vBar: vBar, - vBarv: vBarv, - vDash: vDash, - vangrt: vangrt, - varepsilon: varepsilon, - varkappa: varkappa, - varnothing: varnothing, - varphi: varphi, - varpi: varpi, - varpropto: varpropto, - varr: varr, - varrho: varrho, - varsigma: varsigma, - varsubsetneq: varsubsetneq, - varsubsetneqq: varsubsetneqq, - varsupsetneq: varsupsetneq, - varsupsetneqq: varsupsetneqq, - vartheta: vartheta, - vartriangleleft: vartriangleleft, - vartriangleright: vartriangleright, - vcy: vcy, - vdash: vdash, - vee: vee, - veebar: veebar, - veeeq: veeeq, - vellip: vellip, - verbar: verbar, - vert: vert, - vfr: vfr, - vltri: vltri, - vnsub: vnsub, - vnsup: vnsup, - vopf: vopf, - vprop: vprop, - vrtri: vrtri, - vscr: vscr, - vsubnE: vsubnE, - vsubne: vsubne, - vsupnE: vsupnE, - vsupne: vsupne, - vzigzag: vzigzag, - wcirc: wcirc, - wedbar: wedbar, - wedge: wedge, - wedgeq: wedgeq, - weierp: weierp, - wfr: wfr, - wopf: wopf, - wp: wp, - wr: wr, - wreath: wreath, - wscr: wscr, - xcap: xcap, - xcirc: xcirc, - xcup: xcup, - xdtri: xdtri, - xfr: xfr, - xhArr: xhArr, - xharr: xharr, - xi: xi, - xlArr: xlArr, - xlarr: xlarr, - xmap: xmap, - xnis: xnis, - xodot: xodot, - xopf: xopf, - xoplus: xoplus, - xotime: xotime, - xrArr: xrArr, - xrarr: xrarr, - xscr: xscr, - xsqcup: xsqcup, - xuplus: xuplus, - xutri: xutri, - xvee: xvee, - xwedge: xwedge, - yacut: yacut, - yacute: yacute, - yacy: yacy, - ycirc: ycirc, - ycy: ycy, - ye: ye, - yen: yen, - yfr: yfr, - yicy: yicy, - yopf: yopf, - yscr: yscr, - yucy: yucy, - yum: yum, - yuml: yuml, - zacute: zacute, - zcaron: zcaron, - zcy: zcy, - zdot: zdot, - zeetrf: zeetrf, - zeta: zeta, - zfr: zfr, - zhcy: zhcy, - zigrarr: zigrarr, - zopf: zopf, - zscr: zscr, - zwj: zwj, - zwnj: zwnj -}; + events.splice(index - 2, 2); + } -var characterEntities = require$$0; + return events +} +/** @type {Tokenizer} */ -var decodeEntity_1 = decodeEntity; +function tokenizeHtmlFlow(effects, ok, nok) { + const self = this; + /** @type {number} */ -var own$5 = {}.hasOwnProperty; + let kind; + /** @type {boolean} */ -function decodeEntity(characters) { - return own$5.call(characterEntities, characters) - ? characterEntities[characters] - : false -} + let startTag; + /** @type {string} */ -var association_1 = association$3; + let buffer; + /** @type {number} */ -var decode = decodeEntity_1; + let index; + /** @type {Code} */ -var characterEscape = /\\([!-/:-@[-`{-~])/g; -var characterReference = /&(#(\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; + let marker; + return start + /** @type {State} */ -// The `label` of an association is the string value: character escapes and -// references work, and casing is intact. -// The `identifier` is used to match one association to another: controversially, -// character escapes and references don’t work in this matching: `©` does -// not match `©`, and `\+` does not match `+`. -// But casing is ignored (and whitespace) is trimmed and collapsed: ` A\nb` -// matches `a b`. -// So, we do prefer the label when figuring out how we’re going to serialize: -// it has whitespace, casing, and we can ignore most useless character escapes -// and all character references. -function association$3(node) { - if (node.label || !node.identifier) { - return node.label || '' + function start(code) { + effects.enter('htmlFlow'); + effects.enter('htmlFlowData'); + effects.consume(code); + return open } + /** @type {State} */ - return node.identifier - .replace(characterEscape, '$1') - .replace(characterReference, decodeIfPossible) -} - -function decodeIfPossible($0, $1) { - return decode($1) || $0 -} + function open(code) { + if (code === 33) { + effects.consume(code); + return declarationStart + } -var checkQuote_1 = checkQuote$3; + if (code === 47) { + effects.consume(code); + return tagCloseStart + } -function checkQuote$3(context) { - var marker = context.options.quote || '"'; + if (code === 63) { + effects.consume(code); + kind = 3; // While we’re in an instruction instead of a declaration, we’re on a `?` + // right now, so we do need to search for `>`, similar to declarations. - if (marker !== '"' && marker !== "'") { - throw new Error( - 'Cannot serialize title with `' + - marker + - '` for `options.quote`, expected `"`, or `\'`' - ) - } + return self.interrupt ? ok : continuationDeclarationInside + } - return marker -} + if (asciiAlpha(code)) { + effects.consume(code); + buffer = String.fromCharCode(code); + startTag = true; + return tagName + } -var definition_1 = definition; + return nok(code) + } + /** @type {State} */ -var association$2 = association_1; -var checkQuote$2 = checkQuote_1; -var safe$5 = safe_1; + function declarationStart(code) { + if (code === 45) { + effects.consume(code); + kind = 2; + return commentOpenInside + } -function definition(node, _, context) { - var marker = checkQuote$2(context); - var suffix = marker === '"' ? 'Quote' : 'Apostrophe'; - var exit = context.enter('definition'); - var subexit = context.enter('label'); - var value = - '[' + safe$5(context, association$2(node), {before: '[', after: ']'}) + ']: '; + if (code === 91) { + effects.consume(code); + kind = 5; + buffer = 'CDATA['; + index = 0; + return cdataOpenInside + } - subexit(); + if (asciiAlpha(code)) { + effects.consume(code); + kind = 4; + return self.interrupt ? ok : continuationDeclarationInside + } - if ( - // If there’s no url, or… - !node.url || - // If there’s whitespace, enclosed is prettier. - /[ \t\r\n]/.test(node.url) - ) { - subexit = context.enter('destinationLiteral'); - value += '<' + safe$5(context, node.url, {before: '<', after: '>'}) + '>'; - } else { - // No whitespace, raw is prettier. - subexit = context.enter('destinationRaw'); - value += safe$5(context, node.url, {before: ' ', after: ' '}); + return nok(code) } + /** @type {State} */ - subexit(); + function commentOpenInside(code) { + if (code === 45) { + effects.consume(code); + return self.interrupt ? ok : continuationDeclarationInside + } - if (node.title) { - subexit = context.enter('title' + suffix); - value += - ' ' + - marker + - safe$5(context, node.title, {before: marker, after: marker}) + - marker; - subexit(); + return nok(code) } + /** @type {State} */ - exit(); - - return value -} + function cdataOpenInside(code) { + if (code === buffer.charCodeAt(index++)) { + effects.consume(code); + return index === buffer.length + ? self.interrupt + ? ok + : continuation + : cdataOpenInside + } -var checkEmphasis_1 = checkEmphasis$1; + return nok(code) + } + /** @type {State} */ -function checkEmphasis$1(context) { - var marker = context.options.emphasis || '*'; + function tagCloseStart(code) { + if (asciiAlpha(code)) { + effects.consume(code); + buffer = String.fromCharCode(code); + return tagName + } - if (marker !== '*' && marker !== '_') { - throw new Error( - 'Cannot serialize emphasis with `' + - marker + - '` for `options.emphasis`, expected `*`, or `_`' - ) + return nok(code) } + /** @type {State} */ - return marker -} + function tagName(code) { + if ( + code === null || + code === 47 || + code === 62 || + markdownLineEndingOrSpace(code) + ) { + if ( + code !== 47 && + startTag && + htmlRawNames.includes(buffer.toLowerCase()) + ) { + kind = 1; + return self.interrupt ? ok(code) : continuation(code) + } -var containerPhrasing$1 = phrasing$6; + if (htmlBlockNames.includes(buffer.toLowerCase())) { + kind = 6; -function phrasing$6(parent, context, safeOptions) { - var children = parent.children || []; - var results = []; - var index = -1; - var before = safeOptions.before; - var after; - var handle; - var child; + if (code === 47) { + effects.consume(code); + return basicSelfClosing + } - while (++index < children.length) { - child = children[index]; + return self.interrupt ? ok(code) : continuation(code) + } - if (index + 1 < children.length) { - handle = context.handle.handlers[children[index + 1].type]; - if (handle && handle.peek) handle = handle.peek; - after = handle - ? handle(children[index + 1], parent, context, { - before: '', - after: '' - }).charAt(0) - : ''; - } else { - after = safeOptions.after; - } + kind = 7; // Do not support complete HTML when interrupting - // In some cases, html (text) can be found in phrasing right after an eol. - // When we’d serialize that, in most cases that would be seen as html - // (flow). - // As we can’t escape or so to prevent it from happening, we take a somewhat - // reasonable approach: replace that eol with a space. - // See: - if ( - results.length > 0 && - (before === '\r' || before === '\n') && - child.type === 'html' - ) { - results[results.length - 1] = results[results.length - 1].replace( - /(\r?\n|\r)$/, - ' ' - ); - before = ' '; + return self.interrupt && !self.parser.lazy[self.now().line] + ? nok(code) + : startTag + ? completeAttributeNameBefore(code) + : completeClosingTagAfter(code) } - results.push( - context.handle(child, parent, context, { - before: before, - after: after - }) - ); + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + buffer += String.fromCharCode(code); + return tagName + } - before = results[results.length - 1].slice(-1); + return nok(code) } + /** @type {State} */ - return results.join('') -} - -var emphasis_1 = emphasis; -emphasis.peek = emphasisPeek; + function basicSelfClosing(code) { + if (code === 62) { + effects.consume(code); + return self.interrupt ? ok : continuation + } -var checkEmphasis = checkEmphasis_1; -var phrasing$5 = containerPhrasing$1; + return nok(code) + } + /** @type {State} */ -// To do: there are cases where emphasis cannot “form” depending on the -// previous or next character of sequences. -// There’s no way around that though, except for injecting zero-width stuff. -// Do we need to safeguard against that? -function emphasis(node, _, context) { - var marker = checkEmphasis(context); - var exit = context.enter('emphasis'); - var value = phrasing$5(node, context, {before: marker, after: marker}); - exit(); - return marker + value + marker -} + function completeClosingTagAfter(code) { + if (markdownSpace(code)) { + effects.consume(code); + return completeClosingTagAfter + } -function emphasisPeek(node, _, context) { - return context.options.emphasis || '*' -} + return completeEnd(code) + } + /** @type {State} */ -var mdastUtilToString = toString$3; + function completeAttributeNameBefore(code) { + if (code === 47) { + effects.consume(code); + return completeEnd + } -// Get the text content of a node. -// Prefer the node’s plain-text fields, otherwise serialize its children, -// and if the given value is an array, serialize the nodes in it. -function toString$3(node) { - return ( - (node && - (node.value || - node.alt || - node.title || - ('children' in node && all$1(node.children)) || - ('length' in node && all$1(node)))) || - '' - ) -} + if (code === 58 || code === 95 || asciiAlpha(code)) { + effects.consume(code); + return completeAttributeName + } -function all$1(values) { - var result = []; - var index = -1; + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeNameBefore + } - while (++index < values.length) { - result[index] = toString$3(values[index]); + return completeEnd(code) } + /** @type {State} */ - return result.join('') -} - -var formatHeadingAsSetext_1 = formatHeadingAsSetext$2; - -var toString$2 = mdastUtilToString; + function completeAttributeName(code) { + if ( + code === 45 || + code === 46 || + code === 58 || + code === 95 || + asciiAlphanumeric(code) + ) { + effects.consume(code); + return completeAttributeName + } -function formatHeadingAsSetext$2(node, context) { - return ( - context.options.setext && (!node.depth || node.depth < 3) && toString$2(node) - ) -} + return completeAttributeNameAfter(code) + } + /** @type {State} */ -var heading_1 = heading; + function completeAttributeNameAfter(code) { + if (code === 61) { + effects.consume(code); + return completeAttributeValueBefore + } -var repeat$3 = repeatString; -var formatHeadingAsSetext$1 = formatHeadingAsSetext_1; -var phrasing$4 = containerPhrasing$1; + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeNameAfter + } -function heading(node, _, context) { - var rank = Math.max(Math.min(6, node.depth || 1), 1); - var exit; - var subexit; - var value; - var sequence; + return completeAttributeNameBefore(code) + } + /** @type {State} */ - if (formatHeadingAsSetext$1(node, context)) { - exit = context.enter('headingSetext'); - subexit = context.enter('phrasing'); - value = phrasing$4(node, context, {before: '\n', after: '\n'}); - subexit(); - exit(); - - return ( - value + - '\n' + - repeat$3( - rank === 1 ? '=' : '-', - // The whole size… - value.length - - // Minus the position of the character after the last EOL (or - // 0 if there is none)… - (Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1) - ) - ) - } - - sequence = repeat$3('#', rank); - exit = context.enter('headingAtx'); - subexit = context.enter('phrasing'); - value = phrasing$4(node, context, {before: '# ', after: '\n'}); - value = value ? sequence + ' ' + value : sequence; - if (context.options.closeAtx) { - value += ' ' + sequence; - } - - subexit(); - exit(); - - return value -} - -var html_1 = html; -html.peek = htmlPeek; - -function html(node) { - return node.value || '' -} + function completeAttributeValueBefore(code) { + if ( + code === null || + code === 60 || + code === 61 || + code === 62 || + code === 96 + ) { + return nok(code) + } -function htmlPeek() { - return '<' -} + if (code === 34 || code === 39) { + effects.consume(code); + marker = code; + return completeAttributeValueQuoted + } -var image_1 = image; -image.peek = imagePeek; + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeValueBefore + } -var checkQuote$1 = checkQuote_1; -var safe$4 = safe_1; + marker = null; + return completeAttributeValueUnquoted(code) + } + /** @type {State} */ -function image(node, _, context) { - var quote = checkQuote$1(context); - var suffix = quote === '"' ? 'Quote' : 'Apostrophe'; - var exit = context.enter('image'); - var subexit = context.enter('label'); - var value = '![' + safe$4(context, node.alt, {before: '[', after: ']'}) + ']('; + function completeAttributeValueQuoted(code) { + if (code === null || markdownLineEnding(code)) { + return nok(code) + } - subexit(); + if (code === marker) { + effects.consume(code); + return completeAttributeValueQuotedAfter + } - if ( - // If there’s no url but there is a title… - (!node.url && node.title) || - // Or if there’s markdown whitespace or an eol, enclose. - /[ \t\r\n]/.test(node.url) - ) { - subexit = context.enter('destinationLiteral'); - value += '<' + safe$4(context, node.url, {before: '<', after: '>'}) + '>'; - } else { - // No whitespace, raw is prettier. - subexit = context.enter('destinationRaw'); - value += safe$4(context, node.url, { - before: '(', - after: node.title ? ' ' : ')' - }); + effects.consume(code); + return completeAttributeValueQuoted } + /** @type {State} */ - subexit(); + function completeAttributeValueUnquoted(code) { + if ( + code === null || + code === 34 || + code === 39 || + code === 60 || + code === 61 || + code === 62 || + code === 96 || + markdownLineEndingOrSpace(code) + ) { + return completeAttributeNameAfter(code) + } - if (node.title) { - subexit = context.enter('title' + suffix); - value += - ' ' + - quote + - safe$4(context, node.title, {before: quote, after: quote}) + - quote; - subexit(); + effects.consume(code); + return completeAttributeValueUnquoted } + /** @type {State} */ - value += ')'; - exit(); + function completeAttributeValueQuotedAfter(code) { + if (code === 47 || code === 62 || markdownSpace(code)) { + return completeAttributeNameBefore(code) + } - return value -} + return nok(code) + } + /** @type {State} */ -function imagePeek() { - return '!' -} + function completeEnd(code) { + if (code === 62) { + effects.consume(code); + return completeAfter + } -var imageReference_1 = imageReference; -imageReference.peek = imageReferencePeek; + return nok(code) + } + /** @type {State} */ -var association$1 = association_1; -var safe$3 = safe_1; + function completeAfter(code) { + if (markdownSpace(code)) { + effects.consume(code); + return completeAfter + } -function imageReference(node, _, context) { - var type = node.referenceType; - var exit = context.enter('imageReference'); - var subexit = context.enter('label'); - var alt = safe$3(context, node.alt, {before: '[', after: ']'}); - var value = '![' + alt + ']'; - var reference; - var stack; + return code === null || markdownLineEnding(code) + ? continuation(code) + : nok(code) + } + /** @type {State} */ - subexit(); - // Hide the fact that we’re in phrasing, because escapes don’t work. - stack = context.stack; - context.stack = []; - subexit = context.enter('reference'); - reference = safe$3(context, association$1(node), {before: '[', after: ']'}); - subexit(); - context.stack = stack; - exit(); + function continuation(code) { + if (code === 45 && kind === 2) { + effects.consume(code); + return continuationCommentInside + } - if (type === 'full' || !alt || alt !== reference) { - value += '[' + reference + ']'; - } else if (type !== 'shortcut') { - value += '[]'; - } + if (code === 60 && kind === 1) { + effects.consume(code); + return continuationRawTagOpen + } - return value -} + if (code === 62 && kind === 4) { + effects.consume(code); + return continuationClose + } -function imageReferencePeek() { - return '!' -} + if (code === 63 && kind === 3) { + effects.consume(code); + return continuationDeclarationInside + } -var inlineCode_1 = inlineCode$1; -inlineCode$1.peek = inlineCodePeek$1; + if (code === 93 && kind === 5) { + effects.consume(code); + return continuationCharacterDataInside + } -var patternCompile$1 = patternCompile_1; + if (markdownLineEnding(code) && (kind === 6 || kind === 7)) { + return effects.check( + nextBlankConstruct, + continuationClose, + continuationAtLineEnding + )(code) + } -function inlineCode$1(node, parent, context) { - var value = node.value || ''; - var sequence = '`'; - var index = -1; - var pattern; - var expression; - var match; - var position; + if (code === null || markdownLineEnding(code)) { + return continuationAtLineEnding(code) + } - // If there is a single grave accent on its own in the code, use a fence of - // two. - // If there are two in a row, use one. - while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) { - sequence += '`'; + effects.consume(code); + return continuation } + /** @type {State} */ - // If this is not just spaces or eols (tabs don’t count), and either the - // first or last character are a space, eol, or tick, then pad with spaces. - if ( - /[^ \r\n]/.test(value) && - (/[ \r\n`]/.test(value.charAt(0)) || - /[ \r\n`]/.test(value.charAt(value.length - 1))) - ) { - value = ' ' + value + ' '; + function continuationAtLineEnding(code) { + effects.exit('htmlFlowData'); + return htmlContinueStart(code) } + /** @type {State} */ - // We have a potential problem: certain characters after eols could result in - // blocks being seen. - // For example, if someone injected the string `'\n# b'`, then that would - // result in an ATX heading. - // We can’t escape characters in `inlineCode`, but because eols are - // transformed to spaces when going from markdown to HTML anyway, we can swap - // them out. - while (++index < context.unsafe.length) { - pattern = context.unsafe[index]; + function htmlContinueStart(code) { + if (code === null) { + return done(code) + } - // Only look for `atBreak`s. - // Btw: note that `atBreak` patterns will always start the regex at LF or - // CR. - if (!pattern.atBreak) continue + if (markdownLineEnding(code)) { + return effects.attempt( + { + tokenize: htmlLineEnd, + partial: true + }, + htmlContinueStart, + done + )(code) + } - expression = patternCompile$1(pattern); + effects.enter('htmlFlowData'); + return continuation(code) + } + /** @type {Tokenizer} */ - while ((match = expression.exec(value))) { - position = match.index; + function htmlLineEnd(effects, ok, nok) { + return start + /** @type {State} */ - // Support CRLF (patterns only look for one of the characters). - if ( - value.charCodeAt(position) === 10 /* `\n` */ && - value.charCodeAt(position - 1) === 13 /* `\r` */ - ) { - position--; - } + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return lineStart + } + /** @type {State} */ - value = value.slice(0, position) + ' ' + value.slice(match.index + 1); + function lineStart(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code) } } + /** @type {State} */ - return sequence + value + sequence -} - -function inlineCodePeek$1() { - return '`' -} - -var formatLinkAsAutolink_1 = formatLinkAsAutolink$1; - -var toString$1 = mdastUtilToString; + function continuationCommentInside(code) { + if (code === 45) { + effects.consume(code); + return continuationDeclarationInside + } -function formatLinkAsAutolink$1(node, context) { - var raw = toString$1(node); + return continuation(code) + } + /** @type {State} */ - return ( - !context.options.resourceLink && - // If there’s a url… - node.url && - // And there’s a no title… - !node.title && - // And the content of `node` is a single text node… - node.children && - node.children.length === 1 && - node.children[0].type === 'text' && - // And if the url is the same as the content… - (raw === node.url || 'mailto:' + raw === node.url) && - // And that starts w/ a protocol… - /^[a-z][a-z+.-]+:/i.test(node.url) && - // And that doesn’t contain ASCII control codes (character escapes and - // references don’t work) or angle brackets… - !/[\0- <>\u007F]/.test(node.url) - ) -} + function continuationRawTagOpen(code) { + if (code === 47) { + effects.consume(code); + buffer = ''; + return continuationRawEndTag + } -var link_1 = link; -link.peek = linkPeek; + return continuation(code) + } + /** @type {State} */ -var checkQuote = checkQuote_1; -var formatLinkAsAutolink = formatLinkAsAutolink_1; -var phrasing$3 = containerPhrasing$1; -var safe$2 = safe_1; + function continuationRawEndTag(code) { + if (code === 62 && htmlRawNames.includes(buffer.toLowerCase())) { + effects.consume(code); + return continuationClose + } -function link(node, _, context) { - var quote = checkQuote(context); - var suffix = quote === '"' ? 'Quote' : 'Apostrophe'; - var exit; - var subexit; - var value; - var stack; + if (asciiAlpha(code) && buffer.length < 8) { + effects.consume(code); + buffer += String.fromCharCode(code); + return continuationRawEndTag + } - if (formatLinkAsAutolink(node, context)) { - // Hide the fact that we’re in phrasing, because escapes don’t work. - stack = context.stack; - context.stack = []; - exit = context.enter('autolink'); - value = '<' + phrasing$3(node, context, {before: '<', after: '>'}) + '>'; - exit(); - context.stack = stack; - return value + return continuation(code) } + /** @type {State} */ - exit = context.enter('link'); - subexit = context.enter('label'); - value = '[' + phrasing$3(node, context, {before: '[', after: ']'}) + ']('; - subexit(); + function continuationCharacterDataInside(code) { + if (code === 93) { + effects.consume(code); + return continuationDeclarationInside + } - if ( - // If there’s no url but there is a title… - (!node.url && node.title) || - // Or if there’s markdown whitespace or an eol, enclose. - /[ \t\r\n]/.test(node.url) - ) { - subexit = context.enter('destinationLiteral'); - value += '<' + safe$2(context, node.url, {before: '<', after: '>'}) + '>'; - } else { - // No whitespace, raw is prettier. - subexit = context.enter('destinationRaw'); - value += safe$2(context, node.url, { - before: '(', - after: node.title ? ' ' : ')' - }); + return continuation(code) } + /** @type {State} */ - subexit(); + function continuationDeclarationInside(code) { + if (code === 62) { + effects.consume(code); + return continuationClose + } - if (node.title) { - subexit = context.enter('title' + suffix); - value += - ' ' + - quote + - safe$2(context, node.title, {before: quote, after: quote}) + - quote; - subexit(); + return continuation(code) } + /** @type {State} */ - value += ')'; + function continuationClose(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('htmlFlowData'); + return done(code) + } - exit(); - return value -} + effects.consume(code); + return continuationClose + } + /** @type {State} */ -function linkPeek(node, _, context) { - return formatLinkAsAutolink(node, context) ? '<' : '[' + function done(code) { + effects.exit('htmlFlow'); + return ok(code) + } } +/** @type {Tokenizer} */ -var linkReference_1 = linkReference; -linkReference.peek = linkReferencePeek; - -var association = association_1; -var phrasing$2 = containerPhrasing$1; -var safe$1 = safe_1; - -function linkReference(node, _, context) { - var type = node.referenceType; - var exit = context.enter('linkReference'); - var subexit = context.enter('label'); - var text = phrasing$2(node, context, {before: '[', after: ']'}); - var value = '[' + text + ']'; - var reference; - var stack; - - subexit(); - // Hide the fact that we’re in phrasing, because escapes don’t work. - stack = context.stack; - context.stack = []; - subexit = context.enter('reference'); - reference = safe$1(context, association(node), {before: '[', after: ']'}); - subexit(); - context.stack = stack; - exit(); +function tokenizeNextBlank(effects, ok, nok) { + return start + /** @type {State} */ - if (type === 'full' || !text || text !== reference) { - value += '[' + reference + ']'; - } else if (type !== 'shortcut') { - value += '[]'; + function start(code) { + effects.exit('htmlFlowData'); + effects.enter('lineEndingBlank'); + effects.consume(code); + effects.exit('lineEndingBlank'); + return effects.attempt(blankLine, ok, nok) } - - return value } -function linkReferencePeek() { - return '[' -} +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code + */ -var list_1 = list; +/** @type {Construct} */ +const htmlText = { + name: 'htmlText', + tokenize: tokenizeHtmlText +}; +/** @type {Tokenizer} */ -var flow$2 = containerFlow$1; +function tokenizeHtmlText(effects, ok, nok) { + const self = this; + /** @type {NonNullable|undefined} */ -function list(node, _, context) { - var exit = context.enter('list'); - var value = flow$2(node, context); - exit(); - return value -} + let marker; + /** @type {string} */ -var checkBullet_1 = checkBullet$2; + let buffer; + /** @type {number} */ -function checkBullet$2(context) { - var marker = context.options.bullet || '*'; + let index; + /** @type {State} */ - if (marker !== '*' && marker !== '+' && marker !== '-') { - throw new Error( - 'Cannot serialize items with `' + - marker + - '` for `options.bullet`, expected `*`, `+`, or `-`' - ) + let returnState; + return start + /** @type {State} */ + + function start(code) { + effects.enter('htmlText'); + effects.enter('htmlTextData'); + effects.consume(code); + return open } + /** @type {State} */ - return marker -} + function open(code) { + if (code === 33) { + effects.consume(code); + return declarationOpen + } -var checkListItemIndent_1 = checkListItemIndent$2; + if (code === 47) { + effects.consume(code); + return tagCloseStart + } -function checkListItemIndent$2(context) { - var style = context.options.listItemIndent || 'tab'; + if (code === 63) { + effects.consume(code); + return instruction + } - if (style === 1 || style === '1') { - return 'one' - } + if (asciiAlpha(code)) { + effects.consume(code); + return tagOpen + } - if (style !== 'tab' && style !== 'one' && style !== 'mixed') { - throw new Error( - 'Cannot serialize items with `' + - style + - '` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`' - ) + return nok(code) } + /** @type {State} */ - return style -} - -var listItem_1 = listItem$1; + function declarationOpen(code) { + if (code === 45) { + effects.consume(code); + return commentOpen + } -var repeat$2 = repeatString; -var checkBullet$1 = checkBullet_1; -var checkListItemIndent$1 = checkListItemIndent_1; -var flow$1 = containerFlow$1; -var indentLines$1 = indentLines_1; + if (code === 91) { + effects.consume(code); + buffer = 'CDATA['; + index = 0; + return cdataOpen + } -function listItem$1(node, parent, context) { - var bullet = checkBullet$1(context); - var listItemIndent = checkListItemIndent$1(context); - var size; - var value; - var exit; + if (asciiAlpha(code)) { + effects.consume(code); + return declaration + } - if (parent && parent.ordered) { - bullet = - (parent.start > -1 ? parent.start : 1) + - (context.options.incrementListMarker === false - ? 0 - : parent.children.indexOf(node)) + - '.'; + return nok(code) } + /** @type {State} */ - size = bullet.length + 1; + function commentOpen(code) { + if (code === 45) { + effects.consume(code); + return commentStart + } - if ( - listItemIndent === 'tab' || - (listItemIndent === 'mixed' && ((parent && parent.spread) || node.spread)) - ) { - size = Math.ceil(size / 4) * 4; + return nok(code) } + /** @type {State} */ - exit = context.enter('listItem'); - value = indentLines$1(flow$1(node, context), map); - exit(); - - return value + function commentStart(code) { + if (code === null || code === 62) { + return nok(code) + } - function map(line, index, blank) { - if (index) { - return (blank ? '' : repeat$2(' ', size)) + line + if (code === 45) { + effects.consume(code); + return commentStartDash } - return (blank ? bullet : bullet + repeat$2(' ', size - bullet.length)) + line + return comment(code) } -} + /** @type {State} */ -var paragraph_1 = paragraph; + function commentStartDash(code) { + if (code === null || code === 62) { + return nok(code) + } -var phrasing$1 = containerPhrasing$1; + return comment(code) + } + /** @type {State} */ -function paragraph(node, _, context) { - var exit = context.enter('paragraph'); - var subexit = context.enter('phrasing'); - var value = phrasing$1(node, context, {before: '\n', after: '\n'}); - subexit(); - exit(); - return value -} + function comment(code) { + if (code === null) { + return nok(code) + } -var root_1 = root; + if (code === 45) { + effects.consume(code); + return commentClose + } -var flow = containerFlow$1; + if (markdownLineEnding(code)) { + returnState = comment; + return atLineEnding(code) + } -function root(node, _, context) { - return flow(node, context) -} + effects.consume(code); + return comment + } + /** @type {State} */ -var checkStrong_1 = checkStrong$1; + function commentClose(code) { + if (code === 45) { + effects.consume(code); + return end + } -function checkStrong$1(context) { - var marker = context.options.strong || '*'; + return comment(code) + } + /** @type {State} */ - if (marker !== '*' && marker !== '_') { - throw new Error( - 'Cannot serialize strong with `' + - marker + - '` for `options.strong`, expected `*`, or `_`' - ) + function cdataOpen(code) { + if (code === buffer.charCodeAt(index++)) { + effects.consume(code); + return index === buffer.length ? cdata : cdataOpen + } + + return nok(code) } + /** @type {State} */ - return marker -} + function cdata(code) { + if (code === null) { + return nok(code) + } -var strong_1 = strong; -strong.peek = strongPeek; + if (code === 93) { + effects.consume(code); + return cdataClose + } -var checkStrong = checkStrong_1; -var phrasing = containerPhrasing$1; + if (markdownLineEnding(code)) { + returnState = cdata; + return atLineEnding(code) + } -// To do: there are cases where emphasis cannot “form” depending on the -// previous or next character of sequences. -// There’s no way around that though, except for injecting zero-width stuff. -// Do we need to safeguard against that? -function strong(node, _, context) { - var marker = checkStrong(context); - var exit = context.enter('strong'); - var value = phrasing(node, context, {before: marker, after: marker}); - exit(); - return marker + marker + value + marker + marker -} + effects.consume(code); + return cdata + } + /** @type {State} */ -function strongPeek(node, _, context) { - return context.options.strong || '*' -} + function cdataClose(code) { + if (code === 93) { + effects.consume(code); + return cdataEnd + } -var text_1 = text$1; + return cdata(code) + } + /** @type {State} */ -var safe = safe_1; + function cdataEnd(code) { + if (code === 62) { + return end(code) + } -function text$1(node, parent, context, safeOptions) { - return safe(context, node.value, safeOptions) -} + if (code === 93) { + effects.consume(code); + return cdataEnd + } -var checkRuleRepeat = checkRule$2; + return cdata(code) + } + /** @type {State} */ -function checkRule$2(context) { - var repetition = context.options.ruleRepetition || 3; + function declaration(code) { + if (code === null || code === 62) { + return end(code) + } - if (repetition < 3) { - throw new Error( - 'Cannot serialize rules with repetition `' + - repetition + - '` for `options.ruleRepetition`, expected `3` or more' - ) + if (markdownLineEnding(code)) { + returnState = declaration; + return atLineEnding(code) + } + + effects.consume(code); + return declaration } + /** @type {State} */ - return repetition -} + function instruction(code) { + if (code === null) { + return nok(code) + } -var checkRule_1 = checkRule$1; + if (code === 63) { + effects.consume(code); + return instructionClose + } -function checkRule$1(context) { - var marker = context.options.rule || '*'; + if (markdownLineEnding(code)) { + returnState = instruction; + return atLineEnding(code) + } - if (marker !== '*' && marker !== '-' && marker !== '_') { - throw new Error( - 'Cannot serialize rules with `' + - marker + - '` for `options.rule`, expected `*`, `-`, or `_`' - ) + effects.consume(code); + return instruction } + /** @type {State} */ - return marker -} + function instructionClose(code) { + return code === 62 ? end(code) : instruction(code) + } + /** @type {State} */ -var thematicBreak_1 = thematicBreak; + function tagCloseStart(code) { + if (asciiAlpha(code)) { + effects.consume(code); + return tagClose + } -var repeat$1 = repeatString; -var checkRepeat = checkRuleRepeat; -var checkRule = checkRule_1; + return nok(code) + } + /** @type {State} */ -function thematicBreak(node, parent, context) { - var value = repeat$1( - checkRule(context) + (context.options.ruleSpaces ? ' ' : ''), - checkRepeat(context) - ); + function tagClose(code) { + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + return tagClose + } - return context.options.ruleSpaces ? value.slice(0, -1) : value -} + return tagCloseBetween(code) + } + /** @type {State} */ -handle.blockquote = blockquote_1; -handle.break = _break; -handle.code = code_1; -handle.definition = definition_1; -handle.emphasis = emphasis_1; -handle.hardBreak = _break; -handle.heading = heading_1; -handle.html = html_1; -handle.image = image_1; -handle.imageReference = imageReference_1; -handle.inlineCode = inlineCode_1; -handle.link = link_1; -handle.linkReference = linkReference_1; -handle.list = list_1; -handle.listItem = listItem_1; -handle.paragraph = paragraph_1; -handle.root = root_1; -handle.strong = strong_1; -handle.text = text_1; -handle.thematicBreak = thematicBreak_1; - -var join = [joinDefaults]; - -var formatCodeAsIndented = formatCodeAsIndented_1; -var formatHeadingAsSetext = formatHeadingAsSetext_1; + function tagCloseBetween(code) { + if (markdownLineEnding(code)) { + returnState = tagCloseBetween; + return atLineEnding(code) + } -function joinDefaults(left, right, parent, context) { - if ( - // Two lists with the same marker. - (right.type === 'list' && - right.type === left.type && - Boolean(left.ordered) === Boolean(right.ordered)) || - // Indented code after list or another indented code. - (right.type === 'code' && - formatCodeAsIndented(right, context) && - (left.type === 'list' || - (left.type === right.type && formatCodeAsIndented(left, context)))) - ) { - return false + if (markdownSpace(code)) { + effects.consume(code); + return tagCloseBetween + } + + return end(code) } + /** @type {State} */ - // Join children of a list or an item. - // In which case, `parent` has a `spread` field. - if (typeof parent.spread === 'boolean') { - if ( - left.type === 'paragraph' && - // Two paragraphs. - (left.type === right.type || - right.type === 'definition' || - // Paragraph followed by a setext heading. - (right.type === 'heading' && formatHeadingAsSetext(right, context))) - ) { - return + function tagOpen(code) { + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + return tagOpen } - return parent.spread ? 1 : 0 + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + + return nok(code) } -} + /** @type {State} */ -var unsafe = [ - { - character: '\t', - inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde'] - }, - { - character: '\r', - inConstruct: [ - 'codeFencedLangGraveAccent', - 'codeFencedLangTilde', - 'codeFencedMetaGraveAccent', - 'codeFencedMetaTilde', - 'destinationLiteral', - 'headingAtx' - ] - }, - { - character: '\n', - inConstruct: [ - 'codeFencedLangGraveAccent', - 'codeFencedLangTilde', - 'codeFencedMetaGraveAccent', - 'codeFencedMetaTilde', - 'destinationLiteral', - 'headingAtx' - ] - }, - { - character: ' ', - inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde'] - }, - // An exclamation mark can start an image, if it is followed by a link or - // a link reference. - {character: '!', after: '\\[', inConstruct: 'phrasing'}, - // A quote can break out of a title. - {character: '"', inConstruct: 'titleQuote'}, - // A number sign could start an ATX heading if it starts a line. - {atBreak: true, character: '#'}, - {character: '#', inConstruct: 'headingAtx', after: '(?:[\r\n]|$)'}, - // Dollar sign and percentage are not used in markdown. - // An ampersand could start a character reference. - {character: '&', after: '[#A-Za-z]', inConstruct: 'phrasing'}, - // An apostrophe can break out of a title. - {character: "'", inConstruct: 'titleApostrophe'}, - // A left paren could break out of a destination raw. - {character: '(', inConstruct: 'destinationRaw'}, - {before: '\\]', character: '(', inConstruct: 'phrasing'}, - // A right paren could start a list item or break out of a destination - // raw. - {atBreak: true, before: '\\d+', character: ')'}, - {character: ')', inConstruct: 'destinationRaw'}, - // An asterisk can start thematic breaks, list items, emphasis, strong. - {atBreak: true, character: '*'}, - {character: '*', inConstruct: 'phrasing'}, - // A plus sign could start a list item. - {atBreak: true, character: '+'}, - // A dash can start thematic breaks, list items, and setext heading - // underlines. - {atBreak: true, character: '-'}, - // A dot could start a list item. - {atBreak: true, before: '\\d+', character: '.', after: '(?:[ \t\r\n]|$)'}, - // Slash, colon, and semicolon are not used in markdown for constructs. - // A less than can start html (flow or text) or an autolink. - // HTML could start with an exclamation mark (declaration, cdata, comment), - // slash (closing tag), question mark (instruction), or a letter (tag). - // An autolink also starts with a letter. - // Finally, it could break out of a destination literal. - {atBreak: true, character: '<', after: '[!/?A-Za-z]'}, - {character: '<', after: '[!/?A-Za-z]', inConstruct: 'phrasing'}, - {character: '<', inConstruct: 'destinationLiteral'}, - // An equals to can start setext heading underlines. - {atBreak: true, character: '='}, - // A greater than can start block quotes and it can break out of a - // destination literal. - {atBreak: true, character: '>'}, - {character: '>', inConstruct: 'destinationLiteral'}, - // Question mark and at sign are not used in markdown for constructs. - // A left bracket can start definitions, references, labels, - {atBreak: true, character: '['}, - {character: '[', inConstruct: ['phrasing', 'label', 'reference']}, - // A backslash can start an escape (when followed by punctuation) or a - // hard break (when followed by an eol). - // Note: typical escapes are handled in `safe`! - {character: '\\', after: '[\\r\\n]', inConstruct: 'phrasing'}, - // A right bracket can exit labels. - { - character: ']', - inConstruct: ['label', 'reference'] - }, - // Caret is not used in markdown for constructs. - // An underscore can start emphasis, strong, or a thematic break. - {atBreak: true, character: '_'}, - {before: '[^A-Za-z]', character: '_', inConstruct: 'phrasing'}, - {character: '_', after: '[^A-Za-z]', inConstruct: 'phrasing'}, - // A grave accent can start code (fenced or text), or it can break out of - // a grave accent code fence. - {atBreak: true, character: '`'}, - { - character: '`', - inConstruct: [ - 'codeFencedLangGraveAccent', - 'codeFencedMetaGraveAccent', - 'phrasing' - ] - }, - // Left brace, vertical bar, right brace are not used in markdown for - // constructs. - // A tilde can start code (fenced). - {atBreak: true, character: '~'} -]; + function tagOpenBetween(code) { + if (code === 47) { + effects.consume(code); + return end + } -var lib = toMarkdown$1; + if (code === 58 || code === 95 || asciiAlpha(code)) { + effects.consume(code); + return tagOpenAttributeName + } -var zwitch = zwitch$1; -var configure = configure_1; -var defaultHandlers = handle; -var defaultJoin = join; -var defaultUnsafe = unsafe; + if (markdownLineEnding(code)) { + returnState = tagOpenBetween; + return atLineEnding(code) + } -function toMarkdown$1(tree, options) { - var settings = options || {}; - var context = { - enter: enter, - stack: [], - unsafe: [], - join: [], - handlers: {}, - options: {} - }; - var result; + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenBetween + } - configure(context, { - unsafe: defaultUnsafe, - join: defaultJoin, - handlers: defaultHandlers - }); - configure(context, settings); + return end(code) + } + /** @type {State} */ - if (context.options.tightDefinitions) { - context.join = [joinDefinition].concat(context.join); + function tagOpenAttributeName(code) { + if ( + code === 45 || + code === 46 || + code === 58 || + code === 95 || + asciiAlphanumeric(code) + ) { + effects.consume(code); + return tagOpenAttributeName + } + + return tagOpenAttributeNameAfter(code) } + /** @type {State} */ - context.handle = zwitch('type', { - invalid: invalid, - unknown: unknown, - handlers: context.handlers - }); + function tagOpenAttributeNameAfter(code) { + if (code === 61) { + effects.consume(code); + return tagOpenAttributeValueBefore + } - result = context.handle(tree, null, context, {before: '\n', after: '\n'}); + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeNameAfter; + return atLineEnding(code) + } - if ( - result && - result.charCodeAt(result.length - 1) !== 10 && - result.charCodeAt(result.length - 1) !== 13 - ) { - result += '\n'; + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenAttributeNameAfter + } + + return tagOpenBetween(code) } + /** @type {State} */ - return result + function tagOpenAttributeValueBefore(code) { + if ( + code === null || + code === 60 || + code === 61 || + code === 62 || + code === 96 + ) { + return nok(code) + } - function enter(name) { - context.stack.push(name); - return exit + if (code === 34 || code === 39) { + effects.consume(code); + marker = code; + return tagOpenAttributeValueQuoted + } - function exit() { - context.stack.pop(); + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeValueBefore; + return atLineEnding(code) + } + + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenAttributeValueBefore } + + effects.consume(code); + marker = undefined; + return tagOpenAttributeValueUnquoted } -} + /** @type {State} */ -function invalid(value) { - throw new Error('Cannot handle value `' + value + '`, expected node') -} + function tagOpenAttributeValueQuoted(code) { + if (code === marker) { + effects.consume(code); + return tagOpenAttributeValueQuotedAfter + } -function unknown(node) { - throw new Error('Cannot handle unknown node `' + node.type + '`') -} + if (code === null) { + return nok(code) + } -function joinDefinition(left, right) { - // No blank line between adjacent definitions. - if (left.type === 'definition' && left.type === right.type) { - return 0 + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeValueQuoted; + return atLineEnding(code) + } + + effects.consume(code); + return tagOpenAttributeValueQuoted } -} + /** @type {State} */ -var mdastUtilToMarkdown = lib; + function tagOpenAttributeValueQuotedAfter(code) { + if (code === 62 || code === 47 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + + return nok(code) + } + /** @type {State} */ -var remarkStringify = stringify$1; + function tagOpenAttributeValueUnquoted(code) { + if ( + code === null || + code === 34 || + code === 39 || + code === 60 || + code === 61 || + code === 96 + ) { + return nok(code) + } -var toMarkdown = mdastUtilToMarkdown; + if (code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } -function stringify$1(options) { - var self = this; + effects.consume(code); + return tagOpenAttributeValueUnquoted + } // We can’t have blank lines in content, so no need to worry about empty + // tokens. - this.Compiler = compile; + /** @type {State} */ - function compile(tree) { - return toMarkdown( - tree, - Object.assign({}, self.data('settings'), options, { - // Note: this option is not in the readme. - // The goal is for it to be set by plugins on `data` instead of being - // passed by users. - extensions: self.data('toMarkdownExtensions') || [] - }) + function atLineEnding(code) { + effects.exit('htmlTextData'); + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace( + effects, + afterPrefix, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 ) } + /** @type {State} */ + + function afterPrefix(code) { + effects.enter('htmlTextData'); + return returnState(code) + } + /** @type {State} */ + + function end(code) { + if (code === 62) { + effects.consume(code); + effects.exit('htmlTextData'); + effects.exit('htmlText'); + return ok + } + + return nok(code) + } } -var unified = unified_1; -var parse$1 = remarkParse; -var stringify = remarkStringify; +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code + */ -var remark = unified().use(parse$1).use(stringify).freeze(); +/** @type {Construct} */ +const labelEnd = { + name: 'labelEnd', + tokenize: tokenizeLabelEnd, + resolveTo: resolveToLabelEnd, + resolveAll: resolveAllLabelEnd +}; +/** @type {Construct} */ -const name$1 = "remark"; -const version$1 = "13.0.0"; -const description$1 = "Markdown processor powered by plugins part of the unified collective"; -const license = "MIT"; -const keywords = [ - "unified", - "remark", - "markdown", - "mdast", - "abstract", - "syntax", - "tree", - "ast", - "parse", - "stringify", - "serialize", - "compile", - "process" -]; -const homepage = "https://remark.js.org"; -const repository = "https://github.com/remarkjs/remark/tree/main/packages/remark"; -const bugs = "https://github.com/remarkjs/remark/issues"; -const funding = { - type: "opencollective", - url: "https://opencollective.com/unified" -}; -const author = "Titus Wormer (https://wooorm.com)"; -const contributors = [ - "Titus Wormer (https://wooorm.com)" -]; -const files = [ - "index.js", - "types/index.d.ts" -]; -const types$1 = "types/index.d.ts"; -const dependencies$1 = { - "remark-parse": "^9.0.0", - "remark-stringify": "^9.0.0", - unified: "^9.1.0" -}; -const scripts$1 = { - test: "tape test.js" -}; -const xo = false; -var require$$3 = { - name: name$1, - version: version$1, - description: description$1, - license: license, - keywords: keywords, - homepage: homepage, - repository: repository, - bugs: bugs, - funding: funding, - author: author, - contributors: contributors, - files: files, - types: types$1, - dependencies: dependencies$1, - scripts: scripts$1, - xo: xo +const resourceConstruct = { + tokenize: tokenizeResource }; +/** @type {Construct} */ -const name = "node-lint-md-cli-rollup"; -const description = "remark packaged for Node.js Markdown linting"; -const version = "2.0.2"; -const devDependencies = { - "@rollup/plugin-commonjs": "^20.0.0", - "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^13.0.4", - rollup: "^2.52.7", - shx: "^0.3.3" -}; -const dependencies = { - "markdown-extensions": "^1.1.1", - remark: "^13.0.0", - "remark-gfm": "^2.0.0", - "remark-preset-lint-node": "^3.0.0", - "unified-args": "^8.1.0" -}; -const main = "dist/index.js"; -const scripts = { - build: "npx rollup -c", - "build-node": "npm run build && npx shx cp dist/index.js ../lint-md.js" +const fullReferenceConstruct = { + tokenize: tokenizeFullReference }; -var require$$4 = { - name: name, - description: description, - version: version, - devDependencies: devDependencies, - dependencies: dependencies, - main: main, - scripts: scripts +/** @type {Construct} */ + +const collapsedReferenceConstruct = { + tokenize: tokenizeCollapsedReference }; +/** @type {Resolver} */ -/** - * @typedef {import('unist').Point} Point - * @typedef {import('vfile').VFile} VFile - * - * @typedef {Pick} PositionalPoint - * @typedef {Required} FullPoint - * @typedef {NonNullable} Offset - */ +function resolveAllLabelEnd(events) { + let index = -1; + /** @type {Token} */ -/** - * Get transform functions for the given `document`. - * - * @param {string|Uint8Array|VFile} file - */ -function location(file) { - var value = String(file); - /** @type {Array.} */ - var indices = []; - var search = /\r?\n|\r/g; + let token; - while (search.test(value)) { - indices.push(search.lastIndex); + while (++index < events.length) { + token = events[index][1]; + + if ( + token.type === 'labelImage' || + token.type === 'labelLink' || + token.type === 'labelEnd' + ) { + // Remove the marker. + events.splice(index + 1, token.type === 'labelImage' ? 4 : 2); + token.type = 'data'; + index++; + } } - indices.push(value.length + 1); + return events +} +/** @type {Resolver} */ - return {toPoint, toOffset} +function resolveToLabelEnd(events, context) { + let index = events.length; + let offset = 0; + /** @type {Token} */ - /** - * Get the line and column-based `point` for `offset` in the bound indices. - * Returns a point with `undefined` values when given invalid or out of bounds - * input. - * - * @param {Offset} offset - * @returns {FullPoint} - */ - function toPoint(offset) { - var index = -1; + let token; + /** @type {number|undefined} */ - if (offset > -1 && offset < indices[indices.length - 1]) { - while (++index < indices.length) { - if (indices[index] > offset) { - return { - line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, - offset - } + let open; + /** @type {number|undefined} */ + + let close; + /** @type {Event[]} */ + + let media; // Find an opening. + + while (index--) { + token = events[index][1]; + + if (open) { + // If we see another link, or inactive link label, we’ve been here before. + if ( + token.type === 'link' || + (token.type === 'labelLink' && token._inactive) + ) { + break + } // Mark other link openings as inactive, as we can’t have links in + // links. + + if (events[index][0] === 'enter' && token.type === 'labelLink') { + token._inactive = true; + } + } else if (close) { + if ( + events[index][0] === 'enter' && + (token.type === 'labelImage' || token.type === 'labelLink') && + !token._balanced + ) { + open = index; + + if (token.type !== 'labelLink') { + offset = 2; + break } } + } else if (token.type === 'labelEnd') { + close = index; } - - return {line: undefined, column: undefined, offset: undefined} } - /** - * Get the `offset` for a line and column-based `point` in the bound indices. - * Returns `-1` when given invalid or out of bounds input. - * - * @param {PositionalPoint} point - * @returns {Offset} - */ - function toOffset(point) { - var line = point && point.line; - var column = point && point.column; - /** @type {number} */ - var offset; + const group = { + type: events[open][1].type === 'labelLink' ? 'link' : 'image', + start: Object.assign({}, events[open][1].start), + end: Object.assign({}, events[events.length - 1][1].end) + }; + const label = { + type: 'label', + start: Object.assign({}, events[open][1].start), + end: Object.assign({}, events[close][1].end) + }; + const text = { + type: 'labelText', + start: Object.assign({}, events[open + offset + 2][1].end), + end: Object.assign({}, events[close - 2][1].start) + }; + media = [ + ['enter', group, context], + ['enter', label, context] + ]; // Opening marker. + + media = push(media, events.slice(open + 1, open + offset + 3)); // Text open. + + media = push(media, [['enter', text, context]]); // Between. + + media = push( + media, + resolveAll( + context.parser.constructs.insideSpan.null, + events.slice(open + offset + 4, close - 3), + context + ) + ); // Text close, marker close, label close. + + media = push(media, [ + ['exit', text, context], + events[close - 2], + events[close - 1], + ['exit', label, context] + ]); // Reference, resource, or so. + + media = push(media, events.slice(close + 1)); // Media close. + + media = push(media, [['exit', group, context]]); + splice(events, open, events.length, media); + return events +} +/** @type {Tokenizer} */ +function tokenizeLabelEnd(effects, ok, nok) { + const self = this; + let index = self.events.length; + /** @type {Token} */ + + let labelStart; + /** @type {boolean} */ + + let defined; // Find an opening. + + while (index--) { if ( - typeof line === 'number' && - typeof column === 'number' && - !Number.isNaN(line) && - !Number.isNaN(column) && - line - 1 in indices + (self.events[index][1].type === 'labelImage' || + self.events[index][1].type === 'labelLink') && + !self.events[index][1]._balanced ) { - offset = (indices[line - 2] || 0) + column - 1 || 0; + labelStart = self.events[index][1]; + break } - - return offset > -1 && offset < indices[indices.length - 1] ? offset : -1 } -} -/** - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Parent} Parent - * - * @typedef {string} Type - * @typedef {Object} Props - * - * @typedef {null|undefined|Type|Props|TestFunctionAnything|Array.} Test - */ + return start + /** @type {State} */ -const convert$2 = - /** - * @type {( - * ((test: T['type']|Partial|TestFunctionPredicate) => AssertPredicate) & - * ((test?: Test) => AssertAnything) - * )} - */ - ( - /** - * Generate an assertion from a check. - * @param {Test} [test] - * When nullish, checks if `node` is a `Node`. - * When `string`, works like passing `function (node) {return node.type === test}`. - * When `function` checks if function passed the node is true. - * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values. - * When `array`, checks any one of the subtests pass. - * @returns {AssertAnything} - */ - function (test) { - if (test === undefined || test === null) { - return ok$1 - } + function start(code) { + if (!labelStart) { + return nok(code) + } // It’s a balanced bracket, but contains a link. - if (typeof test === 'string') { - return typeFactory$1(test) - } + if (labelStart._inactive) return balanced(code) + defined = self.parser.defined.includes( + normalizeIdentifier( + self.sliceSerialize({ + start: labelStart.end, + end: self.now() + }) + ) + ); + effects.enter('labelEnd'); + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelEnd'); + return afterLabelEnd + } + /** @type {State} */ - if (typeof test === 'object') { - return Array.isArray(test) ? anyFactory$1(test) : propsFactory(test) - } + function afterLabelEnd(code) { + // Resource: `[asd](fgh)`. + if (code === 40) { + return effects.attempt( + resourceConstruct, + ok, + defined ? ok : balanced + )(code) + } // Collapsed (`[asd][]`) or full (`[asd][fgh]`) reference? - if (typeof test === 'function') { - return castFactory(test) - } + if (code === 91) { + return effects.attempt( + fullReferenceConstruct, + ok, + defined + ? effects.attempt(collapsedReferenceConstruct, ok, balanced) + : balanced + )(code) + } // Shortcut reference: `[asd]`? - throw new Error('Expected function, string, or object as test') - } - ); -/** - * @param {Array.} tests - * @returns {AssertAnything} - */ -function anyFactory$1(tests) { - /** @type {Array.} */ - const checks = []; - let index = -1; + return defined ? ok(code) : balanced(code) + } + /** @type {State} */ - while (++index < tests.length) { - checks[index] = convert$2(tests[index]); + function balanced(code) { + labelStart._balanced = true; + return nok(code) } +} +/** @type {Tokenizer} */ - return castFactory(any) +function tokenizeResource(effects, ok, nok) { + return start + /** @type {State} */ - /** - * @this {unknown} - * @param {unknown[]} parameters - * @returns {boolean} - */ - function any(...parameters) { - let index = -1; + function start(code) { + effects.enter('resource'); + effects.enter('resourceMarker'); + effects.consume(code); + effects.exit('resourceMarker'); + return factoryWhitespace(effects, open) + } + /** @type {State} */ - while (++index < checks.length) { - if (checks[index].call(this, ...parameters)) return true + function open(code) { + if (code === 41) { + return end(code) } - return false + return factoryDestination( + effects, + destinationAfter, + nok, + 'resourceDestination', + 'resourceDestinationLiteral', + 'resourceDestinationLiteralMarker', + 'resourceDestinationRaw', + 'resourceDestinationString', + 3 + )(code) } -} + /** @type {State} */ -/** - * Utility to assert each property in `test` is represented in `node`, and each - * values are strictly equal. - * - * @param {Props} check - * @returns {AssertAnything} - */ -function propsFactory(check) { - return castFactory(all) + function destinationAfter(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, between)(code) + : end(code) + } + /** @type {State} */ - /** - * @param {Node} node - * @returns {boolean} - */ - function all(node) { - /** @type {string} */ - let key; + function between(code) { + if (code === 34 || code === 39 || code === 40) { + return factoryTitle( + effects, + factoryWhitespace(effects, end), + nok, + 'resourceTitle', + 'resourceTitleMarker', + 'resourceTitleString' + )(code) + } - for (key in check) { - // @ts-expect-error: hush, it sure works as an index. - if (node[key] !== check[key]) return false + return end(code) + } + /** @type {State} */ + + function end(code) { + if (code === 41) { + effects.enter('resourceMarker'); + effects.consume(code); + effects.exit('resourceMarker'); + effects.exit('resource'); + return ok } - return true + return nok(code) } } +/** @type {Tokenizer} */ -/** - * Utility to convert a string into a function which checks a given node’s type - * for said string. - * - * @param {Type} check - * @returns {AssertAnything} - */ -function typeFactory$1(check) { - return castFactory(type) +function tokenizeFullReference(effects, ok, nok) { + const self = this; + return start + /** @type {State} */ - /** - * @param {Node} node - */ - function type(node) { - return node && node.type === check + function start(code) { + return factoryLabel.call( + self, + effects, + afterLabel, + nok, + 'reference', + 'referenceMarker', + 'referenceString' + )(code) + } + /** @type {State} */ + + function afterLabel(code) { + return self.parser.defined.includes( + normalizeIdentifier( + self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + ) + ) + ? ok(code) + : nok(code) } } +/** @type {Tokenizer} */ -/** - * Utility to convert a string into a function which checks a given node’s type - * for said string. - * @param {TestFunctionAnything} check - * @returns {AssertAnything} - */ -function castFactory(check) { - return assertion +function tokenizeCollapsedReference(effects, ok, nok) { + return start + /** @type {State} */ - /** - * @this {unknown} - * @param {Array.} parameters - * @returns {boolean} - */ - function assertion(...parameters) { - // @ts-expect-error: spreading is fine. - return Boolean(check.call(this, ...parameters)) + function start(code) { + effects.enter('reference'); + effects.enter('referenceMarker'); + effects.consume(code); + effects.exit('referenceMarker'); + return open } -} + /** @type {State} */ -// Utility to return true. -function ok$1() { - return true -} + function open(code) { + if (code === 93) { + effects.enter('referenceMarker'); + effects.consume(code); + effects.exit('referenceMarker'); + effects.exit('reference'); + return ok + } -/** - * @param {string} d - * @returns {string} - */ -function color$3(d) { - return '\u001B[33m' + d + '\u001B[39m' + return nok(code) + } } /** - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Parent} Parent - * @typedef {import('unist-util-is').Test} Test + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State */ +/** @type {Construct} */ -/** - * Continue traversing as normal - */ -const CONTINUE$3 = true; -/** - * Do not traverse this node’s children - */ -const SKIP$3 = 'skip'; -/** - * Stop traversing immediately - */ -const EXIT$3 = false; - -const visitParents$3 = - /** - * @type {( - * ((tree: Node, test: T['type']|Partial|import('unist-util-is').TestFunctionPredicate|Array.|import('unist-util-is').TestFunctionPredicate>, visitor: Visitor, reverse?: boolean) => void) & - * ((tree: Node, test: Test, visitor: Visitor, reverse?: boolean) => void) & - * ((tree: Node, visitor: Visitor, reverse?: boolean) => void) - * )} - */ - ( - /** - * Visit children of tree which pass a test - * - * @param {Node} tree Abstract syntax tree to walk - * @param {Test} test test Test node - * @param {Visitor} visitor Function to run for each node - * @param {boolean} [reverse] Fisit the tree in reverse, defaults to false - */ - function (tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - // @ts-ignore no visitor given, so `visitor` is test. - visitor = test; - test = null; - } - - var is = convert$2(test); - var step = reverse ? -1 : 1; - - factory(tree, null, [])(); - - /** - * @param {Node} node - * @param {number?} index - * @param {Array.} parents - */ - function factory(node, index, parents) { - /** @type {Object.} */ - var value = typeof node === 'object' && node !== null ? node : {}; - /** @type {string} */ - var name; - - if (typeof value.type === 'string') { - name = - typeof value.tagName === 'string' - ? value.tagName - : typeof value.name === 'string' - ? value.name - : undefined; - - Object.defineProperty(visit, 'name', { - value: - 'node (' + - color$3(value.type + (name ? '<' + name + '>' : '')) + - ')' - }); - } +const labelStartImage = { + name: 'labelStartImage', + tokenize: tokenizeLabelStartImage, + resolveAll: labelEnd.resolveAll +}; +/** @type {Tokenizer} */ - return visit +function tokenizeLabelStartImage(effects, ok, nok) { + const self = this; + return start + /** @type {State} */ - function visit() { - /** @type {ActionTuple} */ - var result = []; - /** @type {ActionTuple} */ - var subresult; - /** @type {number} */ - var offset; - /** @type {Array.} */ - var grandparents; + function start(code) { + effects.enter('labelImage'); + effects.enter('labelImageMarker'); + effects.consume(code); + effects.exit('labelImageMarker'); + return open + } + /** @type {State} */ - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$2(visitor(node, parents)); + function open(code) { + if (code === 91) { + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelImage'); + return after + } - if (result[0] === EXIT$3) { - return result - } - } + return nok(code) + } + /** @type {State} */ - if (node.children && result[0] !== SKIP$3) { - // @ts-ignore looks like a parent. - offset = (reverse ? node.children.length : -1) + step; - // @ts-ignore looks like a parent. - grandparents = parents.concat(node); + function after(code) { + /* Hidden footnotes hook */ - // @ts-ignore looks like a parent. - while (offset > -1 && offset < node.children.length) { - subresult = factory(node.children[offset], offset, grandparents)(); + /* c8 ignore next 3 */ + return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs + ? nok(code) + : ok(code) + } +} - if (subresult[0] === EXIT$3) { - return subresult - } +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + */ +/** @type {Construct} */ - offset = - typeof subresult[1] === 'number' ? subresult[1] : offset + step; - } - } +const labelStartLink = { + name: 'labelStartLink', + tokenize: tokenizeLabelStartLink, + resolveAll: labelEnd.resolveAll +}; +/** @type {Tokenizer} */ - return result - } - } - } - ); +function tokenizeLabelStartLink(effects, ok, nok) { + const self = this; + return start + /** @type {State} */ -/** - * @param {VisitorResult} value - * @returns {ActionTuple} - */ -function toResult$2(value) { - if (Array.isArray(value)) { - return value + function start(code) { + effects.enter('labelLink'); + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelLink'); + return after } + /** @type {State} */ - if (typeof value === 'number') { - return [CONTINUE$3, value] - } + function after(code) { + /* Hidden footnotes hook. */ - return [value] + /* c8 ignore next 3 */ + return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs + ? nok(code) + : ok(code) + } } /** - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Parent} Parent - * @typedef {import('unist-util-is').Test} Test - * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State */ -const visit$3 = - /** - * @type {( - * ((tree: Node, test: T['type']|Partial|import('unist-util-is').TestFunctionPredicate|Array.|import('unist-util-is').TestFunctionPredicate>, visitor: Visitor, reverse?: boolean) => void) & - * ((tree: Node, test: Test, visitor: Visitor, reverse?: boolean) => void) & - * ((tree: Node, visitor: Visitor, reverse?: boolean) => void) - * )} - */ - ( - /** - * Visit children of tree which pass a test - * - * @param {Node} tree Abstract syntax tree to walk - * @param {Test} test test Test node - * @param {Visitor} visitor Function to run for each node - * @param {boolean} [reverse] Fisit the tree in reverse, defaults to false - */ - function (tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } +/** @type {Construct} */ +const lineEnding = { + name: 'lineEnding', + tokenize: tokenizeLineEnding +}; +/** @type {Tokenizer} */ - visitParents$3(tree, test, overload, reverse); +function tokenizeLineEnding(effects, ok) { + return start + /** @type {State} */ - /** - * @param {Node} node - * @param {Array.} parents - */ - function overload(node, parents) { - var parent = parents[parents.length - 1]; - return visitor( - node, - parent ? parent.children.indexOf(node) : null, - parent - ) - } - } - ); + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, ok, 'linePrefix') + } +} /** - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Parent} Parent - * @typedef {import('unist').Point} Point - * @typedef {import('unist-util-is').Test} Test - * @typedef {import('vfile').VFile} VFile - * @typedef {import('vfile-message').VFileMessage} VFileMessage - * - * @typedef {OptionsWithoutReset|OptionsWithReset} Options - * @typedef {OptionsBaseFields & OptionsWithoutResetFields} OptionsWithoutReset - * @typedef {OptionsBaseFields & OptionsWithResetFields} OptionsWithReset - * - * @typedef OptionsWithoutResetFields - * @property {false} [reset] - * Whether to treat all messages as turned off initially. - * @property {string[]} [disable] - * List of `ruleId`s to turn off. - * - * @typedef OptionsWithResetFields - * @property {true} reset - * Whether to treat all messages as turned off initially. - * @property {string[]} [enable] - * List of `ruleId`s to initially turn on. - * - * @typedef OptionsBaseFields - * @property {string} name - * Name of markers that can control the message sources. - * - * For example, `{name: 'alpha'}` controls `alpha` markers: - * - * ```html - * - * ``` - * @property {MarkerParser} marker - * Parse a possible marker to a comment marker object (Marker). - * If the marker isn't a marker, should return `null`. - * @property {Test} [test] - * Test for possible markers - * @property {string[]} [known] - * List of allowed `ruleId`s. When given a warning is shown - * when someone tries to control an unknown rule. - * - * For example, `{name: 'alpha', known: ['bravo']}` results in a warning if - * `charlie` is configured: - * - * ```html - * - * ``` - * @property {string|string[]} [source] - * Sources that can be controlled with `name` markers. - * Defaults to `name`. - * - * @callback MarkerParser - * Parse a possible comment marker node to a Marker. - * @param {Node} node - * Node to parse - * - * @typedef Marker - * A comment marker. - * @property {string} name - * Name of marker. - * @property {string} attributes - * Value after name. - * @property {Record} parameters - * Parsed attributes. - * @property {Node} node - * Reference to given node. - * - * @typedef Mark - * @property {Point|undefined} point - * @property {boolean} state + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code */ -const own$4 = {}.hasOwnProperty; - -/** - * @type {import('unified').Plugin<[Options]>} - * @returns {(tree: Node, file: VFile) => void} - */ -function messageControl(options) { - if (!options || typeof options !== 'object' || !options.name) { - throw new Error( - 'Expected `name` in `options`, got `' + (options || {}).name + '`' - ) - } +/** @type {Construct} */ +const thematicBreak$1 = { + name: 'thematicBreak', + tokenize: tokenizeThematicBreak +}; +/** @type {Tokenizer} */ - if (!options.marker) { - throw new Error( - 'Expected `marker` in `options`, got `' + options.marker + '`' - ) - } +function tokenizeThematicBreak(effects, ok, nok) { + let size = 0; + /** @type {NonNullable} */ - const enable = 'enable' in options && options.enable ? options.enable : []; - const disable = 'disable' in options && options.disable ? options.disable : []; - let reset = options.reset; - const sources = - typeof options.source === 'string' - ? [options.source] - : options.source || [options.name]; + let marker; + return start + /** @type {State} */ - return transformer + function start(code) { + effects.enter('thematicBreak'); + marker = code; + return atBreak(code) + } + /** @type {State} */ - /** - * @param {Node} tree - * @param {VFile} file - */ - function transformer(tree, file) { - const toOffset = location(file).toOffset; - const initial = !reset; - const gaps = detectGaps(tree, file); - /** @type {Record} */ - const scope = {}; - /** @type {Mark[]} */ - const globals = []; + function atBreak(code) { + if (code === marker) { + effects.enter('thematicBreakSequence'); + return sequence(code) + } - visit$3(tree, options.test, visitor); + if (markdownSpace(code)) { + return factorySpace(effects, atBreak, 'whitespace')(code) + } - file.messages = file.messages.filter((m) => filter(m)); + if (size < 3 || (code !== null && !markdownLineEnding(code))) { + return nok(code) + } - /** - * @param {Node} node - * @param {number|null} position - * @param {Parent|null} parent - */ - function visitor(node, position, parent) { - /** @type {Marker|null} */ - const mark = options.marker(node); + effects.exit('thematicBreak'); + return ok(code) + } + /** @type {State} */ - if (!mark || mark.name !== options.name) { - return - } + function sequence(code) { + if (code === marker) { + effects.consume(code); + size++; + return sequence + } - const ruleIds = mark.attributes.split(/\s/g); - const point = mark.node.position && mark.node.position.start; - const next = - (parent && position !== null && parent.children[position + 1]) || - undefined; - const tail = (next && next.position && next.position.end) || undefined; - let index = -1; + effects.exit('thematicBreakSequence'); + return atBreak(code) + } +} - /** @type {string} */ - // @ts-expect-error: we’ll check for unknown values next. - const verb = ruleIds.shift(); +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Exiter} Exiter + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code + */ +/** @type {Construct} */ - if (verb !== 'enable' && verb !== 'disable' && verb !== 'ignore') { - file.fail( - 'Unknown keyword `' + - verb + - '`: expected ' + - "`'enable'`, `'disable'`, or `'ignore'`", - mark.node - ); - } +const list$1 = { + name: 'list', + tokenize: tokenizeListStart, + continuation: { + tokenize: tokenizeListContinuation + }, + exit: tokenizeListEnd +}; +/** @type {Construct} */ - // Apply to all rules. - if (ruleIds.length > 0) { - while (++index < ruleIds.length) { - const ruleId = ruleIds[index]; +const listItemPrefixWhitespaceConstruct = { + tokenize: tokenizeListItemPrefixWhitespace, + partial: true +}; +/** @type {Construct} */ - if (isKnown(ruleId, verb, mark.node)) { - toggle(point, verb === 'enable', ruleId); +const indentConstruct = { + tokenize: tokenizeIndent, + partial: true +}; +/** + * @type {Tokenizer} + * @this {TokenizeContextWithState} + */ - if (verb === 'ignore') { - toggle(tail, true, ruleId); - } - } - } - } else if (verb === 'ignore') { - toggle(point, false); - toggle(tail, true); - } else { - toggle(point, verb === 'enable'); - reset = verb !== 'enable'; - } - } +function tokenizeListStart(effects, ok, nok) { + const self = this; + const tail = self.events[self.events.length - 1]; + let initialSize = + tail && tail[1].type === 'linePrefix' + ? tail[2].sliceSerialize(tail[1], true).length + : 0; + let size = 0; + return start + /** @type {State} */ - /** - * @param {VFileMessage} message - * @returns {boolean} - */ - function filter(message) { - let gapIndex = gaps.length; + function start(code) { + const kind = + self.containerState.type || + (code === 42 || code === 43 || code === 45 + ? 'listUnordered' + : 'listOrdered'); - // Keep messages from a different source. - if (!message.source || !sources.includes(message.source)) { - return true + if ( + kind === 'listUnordered' + ? !self.containerState.marker || code === self.containerState.marker + : asciiDigit(code) + ) { + if (!self.containerState.type) { + self.containerState.type = kind; + effects.enter(kind, { + _container: true + }); } - // We only ignore messages if they‘re disabled, *not* when they’re not in - // the document. - if (!message.line) { - message.line = 1; + if (kind === 'listUnordered') { + effects.enter('listItemPrefix'); + return code === 42 || code === 45 + ? effects.check(thematicBreak$1, nok, atMarker)(code) + : atMarker(code) } - if (!message.column) { - message.column = 1; + if (!self.interrupt || code === 49) { + effects.enter('listItemPrefix'); + effects.enter('listItemValue'); + return inside(code) } + } - // Check whether the warning is inside a gap. - // @ts-expect-error: we just normalized `null` to `number`s. - const offset = toOffset(message); + return nok(code) + } + /** @type {State} */ - while (gapIndex--) { - if (gaps[gapIndex][0] <= offset && gaps[gapIndex][1] > offset) { - return false - } - } + function inside(code) { + if (asciiDigit(code) && ++size < 10) { + effects.consume(code); + return inside + } - // Check whether allowed by specific and global states. - return ( - (!message.ruleId || - check(message, scope[message.ruleId], message.ruleId)) && - check(message, globals) - ) + if ( + (!self.interrupt || size < 2) && + (self.containerState.marker + ? code === self.containerState.marker + : code === 41 || code === 46) + ) { + effects.exit('listItemValue'); + return atMarker(code) } - /** - * Helper to check (and possibly warn) if a `ruleId` is unknown. - * - * @param {string} ruleId - * @param {string} verb - * @param {Node} node - * @returns {boolean} - */ - function isKnown(ruleId, verb, node) { - const result = options.known ? options.known.includes(ruleId) : true; + return nok(code) + } + /** + * @type {State} + **/ - if (!result) { - file.message( - 'Unknown rule: cannot ' + verb + " `'" + ruleId + "'`", - node - ); - } + function atMarker(code) { + effects.enter('listItemMarker'); + effects.consume(code); + effects.exit('listItemMarker'); + self.containerState.marker = self.containerState.marker || code; + return effects.check( + blankLine, // Can’t be empty when interrupting. + self.interrupt ? nok : onBlank, + effects.attempt( + listItemPrefixWhitespaceConstruct, + endOfPrefix, + otherPrefix + ) + ) + } + /** @type {State} */ - return result + function onBlank(code) { + self.containerState.initialBlankLine = true; + initialSize++; + return endOfPrefix(code) + } + /** @type {State} */ + + function otherPrefix(code) { + if (markdownSpace(code)) { + effects.enter('listItemPrefixWhitespace'); + effects.consume(code); + effects.exit('listItemPrefixWhitespace'); + return endOfPrefix } - /** - * Get the latest state of a rule. - * When without `ruleId`, gets global state. - * - * @param {string|undefined} ruleId - * @returns {boolean} - */ - function getState(ruleId) { - const ranges = ruleId ? scope[ruleId] : globals; + return nok(code) + } + /** @type {State} */ - if (ranges && ranges.length > 0) { - return ranges[ranges.length - 1].state - } + function endOfPrefix(code) { + self.containerState.size = + initialSize + + self.sliceSerialize(effects.exit('listItemPrefix'), true).length; + return ok(code) + } +} +/** + * @type {Tokenizer} + * @this {TokenizeContextWithState} + */ - if (!ruleId) { - return !reset - } +function tokenizeListContinuation(effects, ok, nok) { + const self = this; + self.containerState._closeFlow = undefined; + return effects.check(blankLine, onBlank, notBlank) + /** @type {State} */ - return reset ? enable.includes(ruleId) : !disable.includes(ruleId) - } + function onBlank(code) { + self.containerState.furtherBlankLines = + self.containerState.furtherBlankLines || + self.containerState.initialBlankLine; // We have a blank line. + // Still, try to consume at most the items size. - /** - * Handle a rule. - * - * @param {Point|undefined} point - * @param {boolean} state - * @param {string|undefined} [ruleId] - * @returns {void} - */ - function toggle(point, state, ruleId) { - let markers = ruleId ? scope[ruleId] : globals; + return factorySpace( + effects, + ok, + 'listItemIndent', + self.containerState.size + 1 + )(code) + } + /** @type {State} */ - if (!markers) { - markers = []; - scope[String(ruleId)] = markers; - } + function notBlank(code) { + if (self.containerState.furtherBlankLines || !markdownSpace(code)) { + self.containerState.furtherBlankLines = undefined; + self.containerState.initialBlankLine = undefined; + return notInCurrentItem(code) + } - const previousState = getState(ruleId); + self.containerState.furtherBlankLines = undefined; + self.containerState.initialBlankLine = undefined; + return effects.attempt(indentConstruct, ok, notInCurrentItem)(code) + } + /** @type {State} */ - if (state !== previousState) { - markers.push({state, point}); - } + function notInCurrentItem(code) { + // While we do continue, we signal that the flow should be closed. + self.containerState._closeFlow = true; // As we’re closing flow, we’re no longer interrupting. - // Toggle all known rules. - if (!ruleId) { - for (ruleId in scope) { - if (own$4.call(scope, ruleId)) { - toggle(point, state, ruleId); - } - } - } - } + self.interrupt = undefined; + return factorySpace( + effects, + effects.attempt(list$1, ok, nok), + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + } +} +/** + * @type {Tokenizer} + * @this {TokenizeContextWithState} + */ - /** - * Check all `ranges` for `message`. - * - * @param {VFileMessage} message - * @param {Mark[]|undefined} ranges - * @param {string|undefined} [ruleId] - * @returns {boolean} - */ - function check(message, ranges, ruleId) { - if (ranges && ranges.length > 0) { - // Check the state at the message’s position. - let index = ranges.length; +function tokenizeIndent(effects, ok, nok) { + const self = this; + return factorySpace( + effects, + afterPrefix, + 'listItemIndent', + self.containerState.size + 1 + ) + /** @type {State} */ - while (index--) { - const range = ranges[index]; + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'listItemIndent' && + tail[2].sliceSerialize(tail[1], true).length === self.containerState.size + ? ok(code) + : nok(code) + } +} +/** + * @type {Exiter} + * @this {TokenizeContextWithState} + */ - if ( - message.line && - message.column && - range.point && - range.point.line && - range.point.column && - (range.point.line < message.line || - (range.point.line === message.line && - range.point.column <= message.column)) - ) { - return range.state === true - } - } - } +function tokenizeListEnd(effects) { + effects.exit(this.containerState.type); +} +/** + * @type {Tokenizer} + * @this {TokenizeContextWithState} + */ - // The first marker ocurred after the first message, so we check the - // initial state. - if (!ruleId) { - return Boolean(initial || reset) - } +function tokenizeListItemPrefixWhitespace(effects, ok, nok) { + const self = this; + return factorySpace( + effects, + afterPrefix, + 'listItemPrefixWhitespace', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + 1 + ) + /** @type {State} */ - return reset ? enable.includes(ruleId) : !disable.includes(ruleId) - } + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return !markdownSpace(code) && + tail && + tail[1].type === 'listItemPrefixWhitespace' + ? ok(code) + : nok(code) } } /** - * Detect gaps in `tree`. - * - * @param {Node} tree - * @param {VFile} file + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code */ -function detectGaps(tree, file) { - /** @type {Node[]} */ - // @ts-expect-error: fine. - const children = tree.children || []; - const lastNode = children[children.length - 1]; - /** @type {[number, number][]} */ - const gaps = []; - let offset = 0; - /** @type {boolean|undefined} */ - let gap; - // Find all gaps. - visit$3(tree, one); +/** @type {Construct} */ +const setextUnderline = { + name: 'setextUnderline', + tokenize: tokenizeSetextUnderline, + resolveTo: resolveToSetextUnderline +}; +/** @type {Resolver} */ - // Get the end of the document. - // This detects if the last node was the last node. - // If not, there’s an extra gap between the last node and the end of the - // document. - if ( - lastNode && - lastNode.position && - lastNode.position.end && - offset === lastNode.position.end.offset && - file.toString().slice(offset).trim() !== '' - ) { - update(); +function resolveToSetextUnderline(events, context) { + let index = events.length; + /** @type {number|undefined} */ - update( - tree && - tree.position && - tree.position.end && - tree.position.end.offset && - tree.position.end.offset - 1 - ); - } + let content; + /** @type {number|undefined} */ - return gaps + let text; + /** @type {number|undefined} */ - /** - * @param {Node} node - */ - function one(node) { - update(node.position && node.position.start && node.position.start.offset); + let definition; // Find the opening of the content. + // It’ll always exist: we don’t tokenize if it isn’t there. - if (!('children' in node)) { - update(node.position && node.position.end && node.position.end.offset); - } - } + while (index--) { + if (events[index][0] === 'enter') { + if (events[index][1].type === 'content') { + content = index; + break + } - /** - * Detect a new position. - * - * @param {number|undefined} [latest] - * @returns {void} - */ - function update(latest) { - if (latest === null || latest === undefined) { - gap = true; - } else if (offset < latest) { - if (gap) { - gaps.push([offset, latest]); - gap = undefined; + if (events[index][1].type === 'paragraph') { + text = index; + } + } // Exit + else { + if (events[index][1].type === 'content') { + // Remove the content end (if needed we’ll add it later) + events.splice(index, 1); } - offset = latest; + if (!definition && events[index][1].type === 'definition') { + definition = index; + } } } + + const heading = { + type: 'setextHeading', + start: Object.assign({}, events[text][1].start), + end: Object.assign({}, events[events.length - 1][1].end) + }; // Change the paragraph to setext heading text. + + events[text][1].type = 'setextHeadingText'; // If we have definitions in the content, we’ll keep on having content, + // but we need move it. + + if (definition) { + events.splice(text, 0, ['enter', heading, context]); + events.splice(definition + 1, 0, ['exit', events[content][1], context]); + events[content][1].end = Object.assign({}, events[definition][1].end); + } else { + events[content][1] = heading; + } // Add the heading exit at the end. + + events.push(['exit', heading, context]); + return events } +/** @type {Tokenizer} */ -/** - * @typedef {string|number|boolean} MarkerParameterValue - * @typedef {Object.} MarkerParameters - * - * @typedef HtmlNode - * @property {'html'} type - * @property {string} value - * - * @typedef CommentNode - * @property {'comment'} type - * @property {string} value - * - * @typedef Marker - * @property {string} name - * @property {string} attributes - * @property {MarkerParameters|null} parameters - * @property {HtmlNode|CommentNode} node - */ +function tokenizeSetextUnderline(effects, ok, nok) { + const self = this; + let index = self.events.length; + /** @type {NonNullable} */ -var commentExpression = /\s*([a-zA-Z\d-]+)(\s+([\s\S]*))?\s*/; + let marker; + /** @type {boolean} */ -var markerExpression = new RegExp( - '(\\s*\\s*)' -); + let paragraph; // Find an opening. -/** - * Parse a comment marker. - * @param {unknown} node - * @returns {Marker|null} - */ -function commentMarker(node) { - /** @type {RegExpMatchArray} */ - var match; - /** @type {number} */ - var offset; - /** @type {MarkerParameters} */ - var parameters; + while (index--) { + // Skip enter/exit of line ending, line prefix, and content. + // We can now either have a definition or a paragraph. + if ( + self.events[index][1].type !== 'lineEnding' && + self.events[index][1].type !== 'linePrefix' && + self.events[index][1].type !== 'content' + ) { + paragraph = self.events[index][1].type === 'paragraph'; + break + } + } - if ( - node && - typeof node === 'object' && - // @ts-ignore hush - (node.type === 'html' || node.type === 'comment') - ) { - // @ts-ignore hush - match = node.value.match( - // @ts-ignore hush - node.type === 'comment' ? commentExpression : markerExpression - ); + return start + /** @type {State} */ - // @ts-ignore hush - if (match && match[0].length === node.value.length) { - // @ts-ignore hush - offset = node.type === 'comment' ? 1 : 2; - parameters = parseParameters(match[offset + 1] || ''); + function start(code) { + if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) { + effects.enter('setextHeadingLine'); + effects.enter('setextHeadingLineSequence'); + marker = code; + return closingSequence(code) + } - if (parameters) { - return { - name: match[offset], - attributes: match[offset + 2] || '', - parameters, - // @ts-ignore hush - node - } - } + return nok(code) + } + /** @type {State} */ + + function closingSequence(code) { + if (code === marker) { + effects.consume(code); + return closingSequence } + + effects.exit('setextHeadingLineSequence'); + return factorySpace(effects, closingSequenceEnd, 'lineSuffix')(code) } + /** @type {State} */ - return null + function closingSequenceEnd(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('setextHeadingLine'); + return ok(code) + } + + return nok(code) + } } /** - * Parse `value` into an object. - * - * @param {string} value - * @returns {MarkerParameters|null} + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').State} State */ -function parseParameters(value) { - /** @type {MarkerParameters} */ - var parameters = {}; - return value - .replace( - /\s+([-\w]+)(?:=(?:"((?:\\[\s\S]|[^"])+)"|'((?:\\[\s\S]|[^'])+)'|((?:\\[\s\S]|[^"'\s])+)))?/gi, - replacer - ) - .replace(/\s+/g, '') - ? null - : parameters +/** @type {InitialConstruct} */ +const flow$1 = { + tokenize: initializeFlow +}; +/** @type {Initializer} */ - /** - * @param {string} _ - * @param {string} $1 - * @param {string} $2 - * @param {string} $3 - * @param {string} $4 - */ - // eslint-disable-next-line max-params - function replacer(_, $1, $2, $3, $4) { - /** @type {MarkerParameterValue} */ - var value = $2 || $3 || $4 || ''; +function initializeFlow(effects) { + const self = this; + const initial = effects.attempt( + // Try to parse a blank line. + blankLine, + atBlankEnding, // Try to parse initial flow (essentially, only code). + effects.attempt( + this.parser.constructs.flowInitial, + afterConstruct, + factorySpace( + effects, + effects.attempt( + this.parser.constructs.flow, + afterConstruct, + effects.attempt(content, afterConstruct) + ), + 'linePrefix' + ) + ) + ); + return initial + /** @type {State} */ - if (value === 'true' || value === '') { - value = true; - } else if (value === 'false') { - value = false; - } else if (!Number.isNaN(Number(value))) { - value = Number(value); + function atBlankEnding(code) { + if (code === null) { + effects.consume(code); + return } - parameters[$1] = value; + effects.enter('lineEndingBlank'); + effects.consume(code); + effects.exit('lineEndingBlank'); + self.currentConstruct = undefined; + return initial + } + /** @type {State} */ - return '' + function afterConstruct(code) { + if (code === null) { + effects.consume(code); + return + } + + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + self.currentConstruct = undefined; + return initial } } /** - * @typedef {import('mdast').Root} Root - * @typedef {import('vfile').VFile} VFile - * @typedef {import('unified-message-control')} MessageControl - * @typedef {Omit|Omit} Options + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Code} Code */ - -const test = [ - 'html', // Comments are `html` nodes in mdast. - 'comment' // In MDX, comments have their own node. -]; - +const resolver = { + resolveAll: createResolver() +}; +const string$1 = initializeFactory('string'); +const text$3 = initializeFactory('text'); /** - * Plugin to enable, disable, and ignore messages. - * - * @type {import('unified').Plugin<[Options], Root>} - * @returns {(node: Root, file: VFile) => void} + * @param {'string'|'text'} field + * @returns {InitialConstruct} */ -function remarkMessageControl(options) { - return messageControl( - Object.assign({marker: commentMarker, test}, options) - ) -} -/** - * @typedef {import('mdast').Root} Root - */ - -/** - * The core plugin for `remark-lint`. - * This adds support for ignoring stuff from messages (``). - * All rules are in their own packages and presets. - * - * @type {import('unified').Plugin} - */ -function remarkLint() { - this.use(lintMessageControl); -} +function initializeFactory(field) { + return { + tokenize: initializeText, + resolveAll: createResolver( + field === 'text' ? resolveAllLineSuffixes : undefined + ) + } + /** @type {Initializer} */ -/** @type {import('unified').Plugin} */ -function lintMessageControl() { - return remarkMessageControl({name: 'lint', source: 'remark-lint'}) -} + function initializeText(effects) { + const self = this; + const constructs = this.parser.constructs[field]; + const text = effects.attempt(constructs, start, notText); + return start + /** @type {State} */ -/** - * @typedef {(error?: Error|null|undefined, ...output: any[]) => void} Callback - * @typedef {(...input: any[]) => any} Middleware - * - * @typedef {(...input: any[]) => void} Run Call all middleware. - * @typedef {(fn: Middleware) => Pipeline} Use Add `fn` (middleware) to the list. - * @typedef {{run: Run, use: Use}} Pipeline - */ + function start(code) { + return atBreak(code) ? text(code) : notText(code) + } + /** @type {State} */ -/** - * Wrap `middleware`. - * Can be sync or async; return a promise, receive a callback, or return new - * values and errors. - * - * @param {Middleware} middleware - * @param {Callback} callback - */ -function wrap(middleware, callback) { - /** @type {boolean} */ - let called; + function notText(code) { + if (code === null) { + effects.consume(code); + return + } - return wrapped + effects.enter('data'); + effects.consume(code); + return data + } + /** @type {State} */ - /** - * Call `middleware`. - * @param {any[]} parameters - * @returns {void} - */ - function wrapped(...parameters) { - const fnExpectsCallback = middleware.length > parameters.length; - /** @type {any} */ - let result; + function data(code) { + if (atBreak(code)) { + effects.exit('data'); + return text(code) + } // Data. - if (fnExpectsCallback) { - parameters.push(done); + effects.consume(code); + return data } + /** + * @param {Code} code + * @returns {boolean} + */ - try { - result = middleware(...parameters); - } catch (error) { - /** @type {Error} */ - const exception = error; - - // Well, this is quite the pickle. - // `middleware` received a callback and called it synchronously, but that - // threw an error. - // The only thing left to do is to throw the thing instead. - if (fnExpectsCallback && called) { - throw exception + function atBreak(code) { + if (code === null) { + return true } - return done(exception) - } + const list = constructs[code]; + let index = -1; - if (!fnExpectsCallback) { - if (result instanceof Promise) { - result.then(then, done); - } else if (result instanceof Error) { - done(result); - } else { - then(result); + if (list) { + while (++index < list.length) { + const item = list[index]; + + if (!item.previous || item.previous.call(self, self.previous)) { + return true + } + } } - } - } - /** - * Call `callback`, only once. - * @type {Callback} - */ - function done(error, ...output) { - if (!called) { - called = true; - callback(error, ...output); + return false } } - - /** - * Call `done` with one value. - * - * @param {any} [value] - */ - function then(value) { - done(null, value); - } } - -/** - * @typedef {import('unist').Node} Node - * @typedef {import('vfile').VFile} VFile - * - * @typedef {0|1|2} Severity - * @typedef {'warn'|'on'|'off'|'error'} Label - * @typedef {[Severity, ...unknown[]]} SeverityTuple - * - * @callback Rule - * @param {Node} tree - * @param {VFile} file - * @param {unknown} options - * @returns {void} - */ - -const primitives = new Set(['string', 'number', 'boolean']); - /** - * @param {string} id - * @param {Rule} rule + * @param {Resolver} [extraResolver] + * @returns {Resolver} */ -function lintRule(id, rule) { - const parts = id.split(':'); - // Possibly useful if externalised later. - /* c8 ignore next */ - const source = parts[1] ? parts[0] : undefined; - const ruleId = parts[1]; - Object.defineProperty(plugin, 'name', {value: id}); - - return plugin - - /** @type {import('unified').Plugin<[unknown]|void[]>} */ - function plugin(raw) { - const [severity, options] = coerce$2(ruleId, raw); - - if (!severity) return - - const fatal = severity === 2; +function createResolver(extraResolver) { + return resolveAllText + /** @type {Resolver} */ - return (tree, file, next) => { - let index = file.messages.length - 1; + function resolveAllText(events, context) { + let index = -1; + /** @type {number|undefined} */ - wrap(rule, (error) => { - const messages = file.messages; + let enter; // A rather boring computation (to merge adjacent `data` events) which + // improves mm performance by 29%. - // Add the error, if not already properly added. - // Only happens for incorrect plugins. - /* c8 ignore next 6 */ - // @ts-expect-error: errors could be `messages`. - if (error && !messages.includes(error)) { - try { - file.fail(error); - } catch {} + while (++index <= events.length) { + if (enter === undefined) { + if (events[index] && events[index][1].type === 'data') { + enter = index; + index++; } - - while (++index < messages.length) { - Object.assign(messages[index], {ruleId, source, fatal}); + } else if (!events[index] || events[index][1].type !== 'data') { + // Don’t do anything if there is one data token. + if (index !== enter + 2) { + events[enter][1].end = events[index - 1][1].end; + events.splice(enter + 2, index - enter - 2); + index = enter + 2; } - next(); - })(tree, file, options); + enter = undefined; + } } + + return extraResolver ? extraResolver(events, context) : events } } - /** - * Coerce a value to a severity--options tuple. + * A rather ugly set of instructions which again looks at chunks in the input + * stream. + * The reason to do this here is that it is *much* faster to parse in reverse. + * And that we can’t hook into `null` to split the line suffix before an EOF. + * To do: figure out if we can make this into a clean utility, or even in core. + * As it will be useful for GFMs literal autolink extension (and maybe even + * tables?) * - * @param {string} name - * @param {unknown} value - * @returns {SeverityTuple} + * @type {Resolver} */ -function coerce$2(name, value) { - /** @type {unknown[]} */ - let result; - if (typeof value === 'boolean') { - result = [value]; - } else if (value === null || value === undefined) { - result = [1]; - } else if ( - Array.isArray(value) && - // `isArray(unknown)` is turned into `any[]`: - // type-coverage:ignore-next-line - primitives.has(typeof value[0]) - ) { - // `isArray(unknown)` is turned into `any[]`: - // type-coverage:ignore-next-line - result = [...value]; - } else { - result = [1, value]; - } +function resolveAllLineSuffixes(events, context) { + let eventIndex = -1; - let level = result[0]; + while (++eventIndex <= events.length) { + if ( + (eventIndex === events.length || + events[eventIndex][1].type === 'lineEnding') && + events[eventIndex - 1][1].type === 'data' + ) { + const data = events[eventIndex - 1][1]; + const chunks = context.sliceStream(data); + let index = chunks.length; + let bufferIndex = -1; + let size = 0; + /** @type {boolean|undefined} */ - if (typeof level === 'boolean') { - level = level ? 1 : 0; - } else if (typeof level === 'string') { - if (level === 'off') { - level = 0; - } else if (level === 'on' || level === 'warn') { - level = 1; - } else if (level === 'error') { - level = 2; - } else { - level = 1; - result = [level, result]; - } - } + let tabs; - if (typeof level !== 'number' || level < 0 || level > 2) { - throw new Error( - 'Incorrect severity `' + - level + - '` for `' + - name + - '`, ' + - 'expected 0, 1, or 2' - ) - } + while (index--) { + const chunk = chunks[index]; - result[0] = level; + if (typeof chunk === 'string') { + bufferIndex = chunk.length; - // @ts-expect-error: it’s now a valid tuple. - return result -} + while (chunk.charCodeAt(bufferIndex - 1) === 32) { + size++; + bufferIndex--; + } -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module final-newline - * @fileoverview - * Warn when a line feed at the end of a file is missing. - * Empty files are allowed. - * - * See [StackExchange](https://unix.stackexchange.com/questions/18743) for why. - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * always adds a final line feed to files. - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * ## Example - * - * ##### `ok.md` - * - * ###### In - * - * Note: `␊` represents LF. - * - * ```markdown - * Alpha␊ - * ``` - * - * ###### Out - * - * No messages. - * - * ##### `not-ok.md` - * - * ###### In - * - * Note: The below file does not have a final newline. - * - * ```markdown - * Bravo - * ``` - * - * ###### Out - * - * ```text - * 1:1: Missing newline character at end of file - * ``` - */ + if (bufferIndex) break + bufferIndex = -1; + } // Number + else if (chunk === -2) { + tabs = true; + size++; + } else if (chunk === -1) ; else { + // Replacement character, exit. + index++; + break + } + } -const remarkLintFinalNewline = lintRule( - 'remark-lint:final-newline', - /** @type {import('unified-lint-rule').Rule} */ - (_, file) => { - const value = String(file); - const last = value.length - 1; + if (size) { + const token = { + type: + eventIndex === events.length || tabs || size < 2 + ? 'lineSuffix' + : 'hardBreakTrailing', + start: { + line: data.end.line, + column: data.end.column - size, + offset: data.end.offset - size, + _index: data.start._index + index, + _bufferIndex: index + ? bufferIndex + : data.start._bufferIndex + bufferIndex + }, + end: Object.assign({}, data.end) + }; + data.end = Object.assign({}, token.start); - if (last > -1 && value.charAt(last) !== '\n') { - file.message('Missing newline character at end of file'); + if (data.start.offset === data.end.offset) { + Object.assign(data, token); + } else { + events.splice( + eventIndex, + 0, + ['enter', token, context], + ['exit', token, context] + ); + eventIndex += 2; + } + } + + eventIndex++; } } -); - -var remarkLintFinalNewline$1 = remarkLintFinalNewline; -var pluralize = {exports: {}}; + return events +} -/* global define */ +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').ConstructRecord} ConstructRecord + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').ParseContext} ParseContext + */ + +/** + * Create a tokenizer. + * Tokenizers deal with one type of data (e.g., containers, flow, text). + * The parser is the object dealing with it all. + * `initialize` works like other constructs, except that only its `tokenize` + * function is used, in which case it doesn’t receive an `ok` or `nok`. + * `from` can be given to set the point before the first character, although + * when further lines are indented, they must be set with `defineSkip`. + * + * @param {ParseContext} parser + * @param {InitialConstruct} initialize + * @param {Omit} [from] + * @returns {TokenizeContext} + */ +function createTokenizer(parser, initialize, from) { + /** @type {Point} */ + let point = Object.assign( + from + ? Object.assign({}, from) + : { + line: 1, + column: 1, + offset: 0 + }, + { + _index: 0, + _bufferIndex: -1 + } + ); + /** @type {Record} */ -(function (module, exports) { -(function (root, pluralize) { - /* istanbul ignore else */ - if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') { - // Node. - module.exports = pluralize(); - } else { - // Browser global. - root.pluralize = pluralize(); - } -})(commonjsGlobal, function () { - // Rule storage - pluralize and singularize need to be run sequentially, - // while other rules can be optimized using an object for instant lookups. - var pluralRules = []; - var singularRules = []; - var uncountables = {}; - var irregularPlurals = {}; - var irregularSingles = {}; + const columnStart = {}; + /** @type {Construct[]} */ - /** - * Sanitize a pluralization rule to a usable regular expression. - * - * @param {(RegExp|string)} rule - * @return {RegExp} - */ - function sanitizeRule (rule) { - if (typeof rule === 'string') { - return new RegExp('^' + rule + '$', 'i'); - } + const resolveAllConstructs = []; + /** @type {Chunk[]} */ - return rule; - } + let chunks = []; + /** @type {Token[]} */ + let stack = []; /** - * Pass in a word token to produce a function that can replicate the case on - * another word. + * Tools used for tokenizing. * - * @param {string} word - * @param {string} token - * @return {Function} + * @type {Effects} */ - function restoreCase (word, token) { - // Tokens are an exact match. - if (word === token) return token; - - // Lower cased words. E.g. "hello". - if (word === word.toLowerCase()) return token.toLowerCase(); - - // Upper cased words. E.g. "WHISKY". - if (word === word.toUpperCase()) return token.toUpperCase(); - - // Title cased words. E.g. "Title". - if (word[0] === word[0].toUpperCase()) { - return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase(); - } - - // Lower cased words. E.g. "test". - return token.toLowerCase(); - } + const effects = { + consume, + enter, + exit, + attempt: constructFactory(onsuccessfulconstruct), + check: constructFactory(onsuccessfulcheck), + interrupt: constructFactory(onsuccessfulcheck, { + interrupt: true + }) + }; /** - * Interpolate a regexp string. + * State and tools for resolving and serializing. * - * @param {string} str - * @param {Array} args - * @return {string} + * @type {TokenizeContext} */ - function interpolate (str, args) { - return str.replace(/\$(\d{1,2})/g, function (match, index) { - return args[index] || ''; - }); - } + const context = { + previous: null, + code: null, + containerState: {}, + events: [], + parser, + sliceStream, + sliceSerialize, + now, + defineSkip, + write + }; /** - * Replace a word using a rule. + * The state function. * - * @param {string} word - * @param {Array} rule - * @return {string} + * @type {State|void} */ - function replace (word, rule) { - return word.replace(rule[0], function (match, index) { - var result = interpolate(rule[1], arguments); - if (match === '') { - return restoreCase(word[index - 1], result); - } + let state = initialize.tokenize.call(context, effects); - return restoreCase(match, result); - }); + if (initialize.resolveAll) { + resolveAllConstructs.push(initialize); } - /** - * Sanitize a word by passing in the word and sanitization rules. - * - * @param {string} token - * @param {string} word - * @param {Array} rules - * @return {string} - */ - function sanitizeWord (token, word, rules) { - // Empty string or doesn't need fixing. - if (!token.length || uncountables.hasOwnProperty(token)) { - return word; + return context + /** @type {TokenizeContext['write']} */ + + function write(slice) { + chunks = push(chunks, slice); + main(); // Exit if we’re not done, resolve might change stuff. + + if (chunks[chunks.length - 1] !== null) { + return [] } - var len = rules.length; + addResult(initialize, 0); // Otherwise, resolve, and exit. - // Iterate over the sanitization rules and use the first one to match. - while (len--) { - var rule = rules[len]; + context.events = resolveAll(resolveAllConstructs, context.events, context); + return context.events + } // + // Tools. + // - if (rule[0].test(word)) return replace(word, rule); - } + /** @type {TokenizeContext['sliceSerialize']} */ - return word; + function sliceSerialize(token, expandTabs) { + return serializeChunks(sliceStream(token), expandTabs) } + /** @type {TokenizeContext['sliceStream']} */ - /** - * Replace a word with the updated word. - * - * @param {Object} replaceMap - * @param {Object} keepMap - * @param {Array} rules - * @return {Function} - */ - function replaceWord (replaceMap, keepMap, rules) { - return function (word) { - // Get the correct token and case restoration functions. - var token = word.toLowerCase(); - - // Check against the keep object map. - if (keepMap.hasOwnProperty(token)) { - return restoreCase(word, token); - } - - // Check against the replacement map for a direct word replacement. - if (replaceMap.hasOwnProperty(token)) { - return restoreCase(word, replaceMap[token]); - } + function sliceStream(token) { + return sliceChunks(chunks, token) + } + /** @type {TokenizeContext['now']} */ - // Run all the rules against the word. - return sanitizeWord(token, word, rules); - }; + function now() { + return Object.assign({}, point) } + /** @type {TokenizeContext['defineSkip']} */ + + function defineSkip(value) { + columnStart[value.line] = value.column; + accountForPotentialSkip(); + } // + // State management. + // /** - * Check if a word is part of the map. + * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by + * `consume`). + * Here is where we walk through the chunks, which either include strings of + * several characters, or numerical character codes. + * The reason to do this in a loop instead of a call is so the stack can + * drain. + * + * @returns {void} */ - function checkWord (replaceMap, keepMap, rules, bool) { - return function (word) { - var token = word.toLowerCase(); - if (keepMap.hasOwnProperty(token)) return true; - if (replaceMap.hasOwnProperty(token)) return false; + function main() { + /** @type {number} */ + let chunkIndex; - return sanitizeWord(token, token, rules) === token; - }; - } + while (point._index < chunks.length) { + const chunk = chunks[point._index]; // If we’re in a buffer chunk, loop through it. + + if (typeof chunk === 'string') { + chunkIndex = point._index; + + if (point._bufferIndex < 0) { + point._bufferIndex = 0; + } + while ( + point._index === chunkIndex && + point._bufferIndex < chunk.length + ) { + go(chunk.charCodeAt(point._bufferIndex)); + } + } else { + go(chunk); + } + } + } /** - * Pluralize or singularize a word based on the passed in count. + * Deal with one code. * - * @param {string} word The word to pluralize - * @param {number} count How many of the word exist - * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks) - * @return {string} + * @param {Code} code + * @returns {void} */ - function pluralize (word, count, inclusive) { - var pluralized = count === 1 - ? pluralize.singular(word) : pluralize.plural(word); - return (inclusive ? count + ' ' : '') + pluralized; + function go(code) { + state = state(code); } + /** @type {Effects['consume']} */ - /** - * Pluralize a word. - * - * @type {Function} - */ - pluralize.plural = replaceWord( - irregularSingles, irregularPlurals, pluralRules - ); + function consume(code) { + if (markdownLineEnding(code)) { + point.line++; + point.column = 1; + point.offset += code === -3 ? 2 : 1; + accountForPotentialSkip(); + } else if (code !== -1) { + point.column++; + point.offset++; + } // Not in a string chunk. + + if (point._bufferIndex < 0) { + point._index++; + } else { + point._bufferIndex++; // At end of string chunk. + // @ts-expect-error Points w/ non-negative `_bufferIndex` reference + // strings. + if (point._bufferIndex === chunks[point._index].length) { + point._bufferIndex = -1; + point._index++; + } + } // Expose the previous character. + + context.previous = code; // Mark as consumed. + } + /** @type {Effects['enter']} */ + + function enter(type, fields) { + /** @type {Token} */ + // @ts-expect-error Patch instead of assign required fields to help GC. + const token = fields || {}; + token.type = type; + token.start = now(); + context.events.push(['enter', token, context]); + stack.push(token); + return token + } + /** @type {Effects['exit']} */ + + function exit(type) { + const token = stack.pop(); + token.end = now(); + context.events.push(['exit', token, context]); + return token + } /** - * Check if a word is plural. + * Use results. * - * @type {Function} + * @type {ReturnHandle} */ - pluralize.isPlural = checkWord( - irregularSingles, irregularPlurals, pluralRules - ); + function onsuccessfulconstruct(construct, info) { + addResult(construct, info.from); + } /** - * Singularize a word. + * Discard results. * - * @type {Function} + * @type {ReturnHandle} */ - pluralize.singular = replaceWord( - irregularPlurals, irregularSingles, singularRules - ); + function onsuccessfulcheck(_, info) { + info.restore(); + } /** - * Check if a word is singular. + * Factory to attempt/check/interrupt. * - * @type {Function} + * @param {ReturnHandle} onreturn + * @param {Record} [fields] */ - pluralize.isSingular = checkWord( - irregularPlurals, irregularSingles, singularRules - ); + function constructFactory(onreturn, fields) { + return hook + /** + * Handle either an object mapping codes to constructs, a list of + * constructs, or a single construct. + * + * @param {Construct|Construct[]|ConstructRecord} constructs + * @param {State} returnState + * @param {State} [bogusState] + * @returns {State} + */ + + function hook(constructs, returnState, bogusState) { + /** @type {Construct[]} */ + let listOfConstructs; + /** @type {number} */ + + let constructIndex; + /** @type {Construct} */ + + let currentConstruct; + /** @type {Info} */ + + let info; + return Array.isArray(constructs) + ? /* c8 ignore next 1 */ + handleListOfConstructs(constructs) + : 'tokenize' in constructs // @ts-expect-error Looks like a construct. + ? handleListOfConstructs([constructs]) + : handleMapOfConstructs(constructs) + /** + * Handle a list of construct. + * + * @param {ConstructRecord} map + * @returns {State} + */ + + function handleMapOfConstructs(map) { + return start + /** @type {State} */ + + function start(code) { + const def = code !== null && map[code]; + const all = code !== null && map.null; + const list = [ + // To do: add more extension tests. + + /* c8 ignore next 2 */ + ...(Array.isArray(def) ? def : def ? [def] : []), + ...(Array.isArray(all) ? all : all ? [all] : []) + ]; + return handleListOfConstructs(list)(code) + } + } + /** + * Handle a list of construct. + * + * @param {Construct[]} list + * @returns {State} + */ + + function handleListOfConstructs(list) { + listOfConstructs = list; + constructIndex = 0; + + if (list.length === 0) { + return bogusState + } + + return handleConstruct(list[constructIndex]) + } + /** + * Handle a single construct. + * + * @param {Construct} construct + * @returns {State} + */ + + function handleConstruct(construct) { + return start + /** @type {State} */ + + function start(code) { + // To do: not needed to store if there is no bogus state, probably? + // Currently doesn’t work because `inspect` in document does a check + // w/o a bogus, which doesn’t make sense. But it does seem to help perf + // by not storing. + info = store(); + currentConstruct = construct; + + if (!construct.partial) { + context.currentConstruct = construct; + } + + if ( + construct.name && + context.parser.constructs.disable.null.includes(construct.name) + ) { + return nok() + } + + return construct.tokenize.call( + // If we do have fields, create an object w/ `context` as its + // prototype. + // This allows a “live binding”, which is needed for `interrupt`. + fields ? Object.assign(Object.create(context), fields) : context, + effects, + ok, + nok + )(code) + } + } + /** @type {State} */ + + function ok(code) { + onreturn(currentConstruct, info); + return returnState + } + /** @type {State} */ + + function nok(code) { + info.restore(); + + if (++constructIndex < listOfConstructs.length) { + return handleConstruct(listOfConstructs[constructIndex]) + } + + return bogusState + } + } + } /** - * Add a pluralization rule to the collection. - * - * @param {(string|RegExp)} rule - * @param {string} replacement + * @param {Construct} construct + * @param {number} from + * @returns {void} */ - pluralize.addPluralRule = function (rule, replacement) { - pluralRules.push([sanitizeRule(rule), replacement]); - }; + function addResult(construct, from) { + if (construct.resolveAll && !resolveAllConstructs.includes(construct)) { + resolveAllConstructs.push(construct); + } + + if (construct.resolve) { + splice( + context.events, + from, + context.events.length - from, + construct.resolve(context.events.slice(from), context) + ); + } + + if (construct.resolveTo) { + context.events = construct.resolveTo(context.events, context); + } + } /** - * Add a singularization rule to the collection. + * Store state. * - * @param {(string|RegExp)} rule - * @param {string} replacement + * @returns {Info} */ - pluralize.addSingularRule = function (rule, replacement) { - singularRules.push([sanitizeRule(rule), replacement]); - }; + function store() { + const startPoint = now(); + const startPrevious = context.previous; + const startCurrentConstruct = context.currentConstruct; + const startEventsIndex = context.events.length; + const startStack = Array.from(stack); + return { + restore, + from: startEventsIndex + } + /** + * Restore state. + * + * @returns {void} + */ + + function restore() { + point = startPoint; + context.previous = startPrevious; + context.currentConstruct = startCurrentConstruct; + context.events.length = startEventsIndex; + stack = startStack; + accountForPotentialSkip(); + } + } /** - * Add an uncountable word rule. + * Move the current point a bit forward in the line when it’s on a column + * skip. * - * @param {(string|RegExp)} word + * @returns {void} */ - pluralize.addUncountableRule = function (word) { - if (typeof word === 'string') { - uncountables[word.toLowerCase()] = true; - return; + + function accountForPotentialSkip() { + if (point.line in columnStart && point.column < 2) { + point.column = columnStart[point.line]; + point.offset += columnStart[point.line] - 1; } + } +} +/** + * Get the chunks from a slice of chunks in the range of a token. + * + * @param {Chunk[]} chunks + * @param {Pick} token + * @returns {Chunk[]} + */ - // Set singular and plural references for the word. - pluralize.addPluralRule(word, '$0'); - pluralize.addSingularRule(word, '$0'); - }; +function sliceChunks(chunks, token) { + const startIndex = token.start._index; + const startBufferIndex = token.start._bufferIndex; + const endIndex = token.end._index; + const endBufferIndex = token.end._bufferIndex; + /** @type {Chunk[]} */ - /** - * Add an irregular word definition. - * - * @param {string} single - * @param {string} plural - */ - pluralize.addIrregularRule = function (single, plural) { - plural = plural.toLowerCase(); - single = single.toLowerCase(); + let view; - irregularSingles[single] = plural; - irregularPlurals[plural] = single; - }; + if (startIndex === endIndex) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]; + } else { + view = chunks.slice(startIndex, endIndex); - /** - * Irregular rules. - */ - [ - // Pronouns. - ['I', 'we'], - ['me', 'us'], - ['he', 'they'], - ['she', 'they'], - ['them', 'them'], - ['myself', 'ourselves'], - ['yourself', 'yourselves'], - ['itself', 'themselves'], - ['herself', 'themselves'], - ['himself', 'themselves'], - ['themself', 'themselves'], - ['is', 'are'], - ['was', 'were'], - ['has', 'have'], - ['this', 'these'], - ['that', 'those'], - // Words ending in with a consonant and `o`. - ['echo', 'echoes'], - ['dingo', 'dingoes'], - ['volcano', 'volcanoes'], - ['tornado', 'tornadoes'], - ['torpedo', 'torpedoes'], - // Ends with `us`. - ['genus', 'genera'], - ['viscus', 'viscera'], - // Ends with `ma`. - ['stigma', 'stigmata'], - ['stoma', 'stomata'], - ['dogma', 'dogmata'], - ['lemma', 'lemmata'], - ['schema', 'schemata'], - ['anathema', 'anathemata'], - // Other irregular rules. - ['ox', 'oxen'], - ['axe', 'axes'], - ['die', 'dice'], - ['yes', 'yeses'], - ['foot', 'feet'], - ['eave', 'eaves'], - ['goose', 'geese'], - ['tooth', 'teeth'], - ['quiz', 'quizzes'], - ['human', 'humans'], - ['proof', 'proofs'], - ['carve', 'carves'], - ['valve', 'valves'], - ['looey', 'looies'], - ['thief', 'thieves'], - ['groove', 'grooves'], - ['pickaxe', 'pickaxes'], - ['passerby', 'passersby'] - ].forEach(function (rule) { - return pluralize.addIrregularRule(rule[0], rule[1]); - }); + if (startBufferIndex > -1) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view[0] = view[0].slice(startBufferIndex); + } - /** - * Pluralization rules. - */ - [ - [/s?$/i, 's'], - [/[^\u0000-\u007F]$/i, '$0'], - [/([^aeiou]ese)$/i, '$1'], - [/(ax|test)is$/i, '$1es'], - [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'], - [/(e[mn]u)s?$/i, '$1s'], - [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'], - [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'], - [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'], - [/(seraph|cherub)(?:im)?$/i, '$1im'], - [/(her|at|gr)o$/i, '$1oes'], - [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'], - [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'], - [/sis$/i, 'ses'], - [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'], - [/([^aeiouy]|qu)y$/i, '$1ies'], - [/([^ch][ieo][ln])ey$/i, '$1ies'], - [/(x|ch|ss|sh|zz)$/i, '$1es'], - [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'], - [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'], - [/(pe)(?:rson|ople)$/i, '$1ople'], - [/(child)(?:ren)?$/i, '$1ren'], - [/eaux$/i, '$0'], - [/m[ae]n$/i, 'men'], - ['thou', 'you'] - ].forEach(function (rule) { - return pluralize.addPluralRule(rule[0], rule[1]); - }); + if (endBufferIndex > 0) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view.push(chunks[endIndex].slice(0, endBufferIndex)); + } + } - /** - * Singularization rules. - */ - [ - [/s$/i, ''], - [/(ss)$/i, '$1'], - [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'], - [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'], - [/ies$/i, 'y'], - [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'], - [/\b(mon|smil)ies$/i, '$1ey'], - [/\b((?:tit)?m|l)ice$/i, '$1ouse'], - [/(seraph|cherub)im$/i, '$1'], - [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'], - [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'], - [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'], - [/(test)(?:is|es)$/i, '$1is'], - [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'], - [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'], - [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'], - [/(alumn|alg|vertebr)ae$/i, '$1a'], - [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'], - [/(matr|append)ices$/i, '$1ix'], - [/(pe)(rson|ople)$/i, '$1rson'], - [/(child)ren$/i, '$1'], - [/(eau)x?$/i, '$1'], - [/men$/i, 'man'] - ].forEach(function (rule) { - return pluralize.addSingularRule(rule[0], rule[1]); - }); + return view +} +/** + * Get the string value of a slice of chunks. + * + * @param {Chunk[]} chunks + * @param {boolean} [expandTabs=false] + * @returns {string} + */ + +function serializeChunks(chunks, expandTabs) { + let index = -1; + /** @type {string[]} */ + + const result = []; + /** @type {boolean|undefined} */ + + let atTab; + + while (++index < chunks.length) { + const chunk = chunks[index]; + /** @type {string} */ + + let value; + + if (typeof chunk === 'string') { + value = chunk; + } else + switch (chunk) { + case -5: { + value = '\r'; + break + } + + case -4: { + value = '\n'; + break + } + + case -3: { + value = '\r' + '\n'; + break + } + + case -2: { + value = expandTabs ? ' ' : '\t'; + break + } + + case -1: { + if (!expandTabs && atTab) continue + value = ' '; + break + } + + default: { + // Currently only replacement character. + value = String.fromCharCode(chunk); + } + } + + atTab = chunk === -2; + result.push(value); + } + + return result.join('') +} + +/** + * @typedef {import('micromark-util-types').Extension} Extension + */ +/** @type {Extension['document']} */ + +const document$1 = { + [42]: list$1, + [43]: list$1, + [45]: list$1, + [48]: list$1, + [49]: list$1, + [50]: list$1, + [51]: list$1, + [52]: list$1, + [53]: list$1, + [54]: list$1, + [55]: list$1, + [56]: list$1, + [57]: list$1, + [62]: blockQuote +}; +/** @type {Extension['contentInitial']} */ + +const contentInitial = { + [91]: definition$1 +}; +/** @type {Extension['flowInitial']} */ + +const flowInitial = { + [-2]: codeIndented, + [-1]: codeIndented, + [32]: codeIndented +}; +/** @type {Extension['flow']} */ + +const flow = { + [35]: headingAtx, + [42]: thematicBreak$1, + [45]: [setextUnderline, thematicBreak$1], + [60]: htmlFlow, + [61]: setextUnderline, + [95]: thematicBreak$1, + [96]: codeFenced, + [126]: codeFenced +}; +/** @type {Extension['string']} */ + +const string = { + [38]: characterReference$1, + [92]: characterEscape$1 +}; +/** @type {Extension['text']} */ + +const text$2 = { + [-5]: lineEnding, + [-4]: lineEnding, + [-3]: lineEnding, + [33]: labelStartImage, + [38]: characterReference$1, + [42]: attention, + [60]: [autolink, htmlText], + [91]: labelStartLink, + [92]: [hardBreakEscape, characterEscape$1], + [93]: labelEnd, + [95]: attention, + [96]: codeText +}; +/** @type {Extension['insideSpan']} */ + +const insideSpan = { + null: [attention, resolver] +}; +/** @type {Extension['disable']} */ + +const disable = { + null: [] +}; + +var defaultConstructs = /*#__PURE__*/Object.freeze({ + __proto__: null, + document: document$1, + contentInitial: contentInitial, + flowInitial: flowInitial, + flow: flow, + string: string, + text: text$2, + insideSpan: insideSpan, + disable: disable +}); + +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').FullNormalizedExtension} FullNormalizedExtension + * @typedef {import('micromark-util-types').ParseOptions} ParseOptions + * @typedef {import('micromark-util-types').ParseContext} ParseContext + * @typedef {import('micromark-util-types').Create} Create + */ +/** + * @param {ParseOptions} [options] + * @returns {ParseContext} + */ + +function parse(options = {}) { + /** @type {FullNormalizedExtension} */ + // @ts-expect-error `defaultConstructs` is full, so the result will be too. + const constructs = combineExtensions( + // @ts-expect-error Same as above. + [defaultConstructs].concat(options.extensions || []) + ); + /** @type {ParseContext} */ + const parser = { + defined: [], + lazy: {}, + constructs, + content: create(content$1), + document: create(document$2), + flow: create(flow$1), + string: create(string$1), + text: create(text$3) + }; + return parser /** - * Uncountable rules. + * @param {InitialConstruct} initial */ - [ - // Singular words with no plurals. - 'adulthood', - 'advice', - 'agenda', - 'aid', - 'aircraft', - 'alcohol', - 'ammo', - 'analytics', - 'anime', - 'athletics', - 'audio', - 'bison', - 'blood', - 'bream', - 'buffalo', - 'butter', - 'carp', - 'cash', - 'chassis', - 'chess', - 'clothing', - 'cod', - 'commerce', - 'cooperation', - 'corps', - 'debris', - 'diabetes', - 'digestion', - 'elk', - 'energy', - 'equipment', - 'excretion', - 'expertise', - 'firmware', - 'flounder', - 'fun', - 'gallows', - 'garbage', - 'graffiti', - 'hardware', - 'headquarters', - 'health', - 'herpes', - 'highjinks', - 'homework', - 'housework', - 'information', - 'jeans', - 'justice', - 'kudos', - 'labour', - 'literature', - 'machinery', - 'mackerel', - 'mail', - 'media', - 'mews', - 'moose', - 'music', - 'mud', - 'manga', - 'news', - 'only', - 'personnel', - 'pike', - 'plankton', - 'pliers', - 'police', - 'pollution', - 'premises', - 'rain', - 'research', - 'rice', - 'salmon', - 'scissors', - 'series', - 'sewage', - 'shambles', - 'shrimp', - 'software', - 'species', - 'staff', - 'swine', - 'tennis', - 'traffic', - 'transportation', - 'trout', - 'tuna', - 'wealth', - 'welfare', - 'whiting', - 'wildebeest', - 'wildlife', - 'you', - /pok[eé]mon$/i, - // Regexes. - /[^aeiou]ese$/i, // "chinese", "japanese" - /deer$/i, // "deer", "reindeer" - /fish$/i, // "fish", "blowfish", "angelfish" - /measles$/i, - /o[iu]s$/i, // "carnivorous" - /pox$/i, // "chickpox", "smallpox" - /sheep$/i - ].forEach(pluralize.addUncountableRule); - - return pluralize; -}); -}(pluralize)); -var plural = pluralize.exports; + function create(initial) { + return creator + /** @type {Create} */ -/** - * @param {string} d - * @returns {string} - */ -function color$2(d) { - return '\u001B[33m' + d + '\u001B[39m' + function creator(from) { + return createTokenizer(parser, initial, from) + } + } } /** - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Parent} Parent - * @typedef {import('unist-util-is').Test} Test + * @typedef {import('micromark-util-types').Encoding} Encoding + * @typedef {import('micromark-util-types').Value} Value + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Code} Code */ /** - * Continue traversing as normal - */ -const CONTINUE$2 = true; -/** - * Do not traverse this node’s children + * @callback Preprocessor + * @param {Value} value + * @param {Encoding} [encoding] + * @param {boolean} [end=false] + * @returns {Chunk[]} */ -const SKIP$2 = 'skip'; +const search = /[\0\t\n\r]/g; /** - * Stop traversing immediately + * @returns {Preprocessor} */ -const EXIT$2 = false; -/** - * Visit children of tree which pass a test - * - * @param tree Abstract syntax tree to walk - * @param test Test node, optional - * @param visitor Function to run for each node - * @param reverse Visit the tree in reverse order, defaults to false - */ -const visitParents$2 = - /** - * @type {( - * ((tree: Tree, test: Check, visitor: Visitor, Check>>, reverse?: boolean) => void) & - * ((tree: Tree, visitor: Visitor>, reverse?: boolean) => void) - * )} - */ - ( - /** - * @param {Node} tree - * @param {Test} test - * @param {Visitor} visitor - * @param {boolean} [reverse] - */ - function (tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - // @ts-expect-error no visitor given, so `visitor` is test. - visitor = test; - test = null; - } +function preprocess() { + let column = 1; + let buffer = ''; + /** @type {boolean|undefined} */ - const is = convert$2(test); - const step = reverse ? -1 : 1; + let start = true; + /** @type {boolean|undefined} */ - factory(tree, null, [])(); + let atCarriageReturn; + return preprocessor + /** @type {Preprocessor} */ - /** - * @param {Node} node - * @param {number?} index - * @param {Array.} parents - */ - function factory(node, index, parents) { - /** @type {Object.} */ - // @ts-expect-error: hush - const value = typeof node === 'object' && node !== null ? node : {}; - /** @type {string|undefined} */ - let name; + function preprocessor(value, encoding, end) { + /** @type {Chunk[]} */ + const chunks = []; + /** @type {RegExpMatchArray|null} */ - if (typeof value.type === 'string') { - name = - typeof value.tagName === 'string' - ? value.tagName - : typeof value.name === 'string' - ? value.name - : undefined; + let match; + /** @type {number} */ - Object.defineProperty(visit, 'name', { - value: - 'node (' + - color$2(value.type + (name ? '<' + name + '>' : '')) + - ')' - }); - } + let next; + /** @type {number} */ - return visit + let startPosition; + /** @type {number} */ - function visit() { - /** @type {ActionTuple} */ - let result = []; - /** @type {ActionTuple} */ - let subresult; - /** @type {number} */ - let offset; - /** @type {Array.} */ - let grandparents; + let endPosition; + /** @type {Code} */ - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$1(visitor(node, parents)); + let code; // @ts-expect-error `Buffer` does allow an encoding. - if (result[0] === EXIT$2) { - return result - } + value = buffer + value.toString(encoding); + startPosition = 0; + buffer = ''; + + if (start) { + if (value.charCodeAt(0) === 65279) { + startPosition++; + } + + start = undefined; + } + + while (startPosition < value.length) { + search.lastIndex = startPosition; + match = search.exec(value); + endPosition = + match && match.index !== undefined ? match.index : value.length; + code = value.charCodeAt(endPosition); + + if (!match) { + buffer = value.slice(startPosition); + break + } + + if (code === 10 && startPosition === endPosition && atCarriageReturn) { + chunks.push(-3); + atCarriageReturn = undefined; + } else { + if (atCarriageReturn) { + chunks.push(-5); + atCarriageReturn = undefined; + } + + if (startPosition < endPosition) { + chunks.push(value.slice(startPosition, endPosition)); + column += endPosition - startPosition; + } + + switch (code) { + case 0: { + chunks.push(65533); + column++; + break } - // @ts-expect-error looks like a parent. - if (node.children && result[0] !== SKIP$2) { - // @ts-expect-error looks like a parent. - offset = (reverse ? node.children.length : -1) + step; - // @ts-expect-error looks like a parent. - grandparents = parents.concat(node); + case 9: { + next = Math.ceil(column / 4) * 4; + chunks.push(-2); - // @ts-expect-error looks like a parent. - while (offset > -1 && offset < node.children.length) { - // @ts-expect-error looks like a parent. - subresult = factory(node.children[offset], offset, grandparents)(); + while (column++ < next) chunks.push(-1); - if (subresult[0] === EXIT$2) { - return subresult - } + break + } - offset = - typeof subresult[1] === 'number' ? subresult[1] : offset + step; - } + case 10: { + chunks.push(-4); + column = 1; + break } - return result + default: { + atCarriageReturn = true; + column = 1; + } } } + + startPosition = endPosition + 1; } - ); -/** - * @param {VisitorResult} value - * @returns {ActionTuple} - */ -function toResult$1(value) { - if (Array.isArray(value)) { - return value - } + if (end) { + if (atCarriageReturn) chunks.push(-5); + if (buffer) chunks.push(buffer); + chunks.push(null); + } - if (typeof value === 'number') { - return [CONTINUE$2, value] + return chunks } - - return [value] } /** - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Parent} Parent - * @typedef {import('unist-util-is').Test} Test - * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult + * @typedef {import('micromark-util-types').Event} Event */ - /** - * Visit children of tree which pass a test - * - * @param tree Abstract syntax tree to walk - * @param test Test, optional - * @param visitor Function to run for each node - * @param reverse Fisit the tree in reverse, defaults to false + * @param {Event[]} events + * @returns {Event[]} */ -const visit$2 = - /** - * @type {( - * ((tree: Tree, test: Check, visitor: Visitor, Check>>, reverse?: boolean) => void) & - * ((tree: Tree, visitor: Visitor>, reverse?: boolean) => void) - * )} - */ - ( - /** - * @param {Node} tree - * @param {Test} test - * @param {Visitor} visitor - * @param {boolean} [reverse] - */ - function (tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - visitParents$2(tree, test, overload, reverse); +function postprocess(events) { + while (!subtokenize(events)) { + // Empty + } - /** - * @param {Node} node - * @param {Array.} parents - */ - function overload(node, parents) { - const parent = parents[parents.length - 1]; - return visitor( - node, - parent ? parent.children.indexOf(node) : null, - parent - ) - } - } - ); + return events +} /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module list-item-bullet-indent - * @fileoverview - * Warn when list item bullets are indented. - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * removes all indentation before bullets. - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * @example - * {"name": "ok.md"} - * - * Paragraph. - * - * * List item - * * List item - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * Paragraph. - * - * ·* List item - * ·* List item - * - * @example - * {"name": "not-ok.md", "label": "output"} + * Turn the number (in string form as either hexa- or plain decimal) coming from + * a numeric character reference into a character. * - * 3:2: Incorrect indentation before bullet: remove 1 space - * 4:2: Incorrect indentation before bullet: remove 1 space + * @param {string} value + * Value to decode. + * @param {number} base + * Numeric base. + * @returns {string} */ +function decodeNumericCharacterReference(value, base) { + const code = Number.parseInt(value, base); -const remarkLintListItemBulletIndent = lintRule( - 'remark-lint:list-item-bullet-indent', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - visit$2(tree, 'list', (list, _, grandparent) => { - let index = -1; - - while (++index < list.children.length) { - const item = list.children[index]; - - if ( - grandparent && - grandparent.type === 'root' && - grandparent.position && - typeof grandparent.position.start.column === 'number' && - item.position && - typeof item.position.start.column === 'number' - ) { - const indent = - item.position.start.column - grandparent.position.start.column; - - if (indent) { - file.message( - 'Incorrect indentation before bullet: remove ' + - indent + - ' ' + - plural('space', indent), - item.position.start - ); - } - } - } - }); + if ( + // C0 except for HT, LF, FF, CR, space + code < 9 || + code === 11 || + (code > 13 && code < 32) || // Control character (DEL) of the basic block and C1 controls. + (code > 126 && code < 160) || // Lone high surrogates and low surrogates. + (code > 55295 && code < 57344) || // Noncharacters. + (code > 64975 && code < 65008) || + (code & 65535) === 65535 || + (code & 65535) === 65534 || // Out of range + code > 1114111 + ) { + return '\uFFFD' } -); -var remarkLintListItemBulletIndent$1 = remarkLintListItemBulletIndent; + return String.fromCharCode(code) +} /** - * @typedef {import('unist').Position} Position + * @typedef {import('micromark-util-types').Encoding} Encoding + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').ParseOptions} ParseOptions + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Value} Value + * @typedef {Root|Root['children'][number]} Node + * @typedef {import('unist').Parent} Parent * @typedef {import('unist').Point} Point - * - * @typedef {Partial} PointLike - * - * @typedef {Object} PositionLike - * @property {PointLike} [start] - * @property {PointLike} [end] - * - * @typedef {Object} NodeLike - * @property {PositionLike} [position] + * @typedef {import('mdast').Break} Break + * @typedef {import('mdast').Blockquote} Blockquote + * @typedef {import('mdast').Code} Code + * @typedef {import('mdast').Definition} Definition + * @typedef {import('mdast').Emphasis} Emphasis + * @typedef {import('mdast').Heading} Heading + * @typedef {import('mdast').HTML} HTML + * @typedef {import('mdast').Image} Image + * @typedef {import('mdast').InlineCode} InlineCode + * @typedef {import('mdast').Link} Link + * @typedef {import('mdast').List} List + * @typedef {import('mdast').ListItem} ListItem + * @typedef {import('mdast').Paragraph} Paragraph + * @typedef {import('mdast').Root} Root + * @typedef {import('mdast').Strong} Strong + * @typedef {import('mdast').Text} Text + * @typedef {import('mdast').ThematicBreak} ThematicBreak */ - -var pointStart = point$2('start'); -var pointEnd = point$2('end'); - +const own$4 = {}.hasOwnProperty; /** - * Get the positional info of `node`. - * - * @param {'start'|'end'} type + * @param value Markdown to parse (`string` or `Buffer`). + * @param [encoding] Character encoding to understand `value` as when it’s a `Buffer` (`string`, default: `'utf8'`). + * @param [options] Configuration */ -function point$2(type) { - return point +const fromMarkdown = /** - * Get the positional info of `node`. - * - * @param {NodeLike} [node] - * @returns {Point} + * @type {( + * ((value: Value, encoding: Encoding, options?: Options) => Root) & + * ((value: Value, options?: Options) => Root) + * )} */ - function point(node) { - /** @type {Point} */ - // @ts-ignore looks like a point - var point = (node && node.position && node.position[type]) || {}; - return { - line: point.line || null, - column: point.column || null, - offset: point.offset > -1 ? point.offset : null + /** + * @param {Value} value + * @param {Encoding} [encoding] + * @param {Options} [options] + * @returns {Root} + */ + function (value, encoding, options) { + if (typeof encoding !== 'string') { + options = encoding; + encoding = undefined; } - } -} - -/** - * @typedef {Object} PointLike - * @property {number} [line] - * @property {number} [column] - * @property {number} [offset] - * - * @typedef {Object} PositionLike - * @property {PointLike} [start] - * @property {PointLike} [end] - * - * @typedef {Object} NodeLike - * @property {PositionLike} [position] - */ + return compiler(options)( + postprocess( + parse(options).document().write(preprocess()(value, encoding, true)) + ) + ) + }; /** - * Check if `node` is *generated*. + * Note this compiler only understand complete buffering, not streaming. * - * @param {NodeLike} [node] - * @returns {boolean} + * @param {Options} [options] */ -function generated(node) { - return ( - !node || - !node.position || - !node.position.start || - !node.position.start.line || - !node.position.start.column || - !node.position.end || - !node.position.end.line || - !node.position.end.column - ) -} -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module list-item-indent - * @fileoverview - * Warn when the spacing between a list item’s bullet and its content violates - * a given style. - * - * Options: `'tab-size'`, `'mixed'`, or `'space'`, default: `'tab-size'`. - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * uses `'tab-size'` (named `'tab'` there) by default to ensure Markdown is - * seen the same way across vendors. - * This can be configured with the - * [`listItemIndent`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionslistitemindent) - * option. - * This rule’s `'space'` option is named `'1'` there. - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * @example - * {"name": "ok.md"} - * - * *···List - * ····item. - * - * Paragraph. - * - * 11.·List - * ····item. - * - * Paragraph. - * - * *···List - * ····item. - * - * *···List - * ····item. - * - * @example - * {"name": "ok.md", "setting": "mixed"} - * - * *·List item. - * - * Paragraph. - * - * 11.·List item - * - * Paragraph. - * - * *···List - * ····item. - * - * *···List - * ····item. - * - * @example - * {"name": "ok.md", "setting": "space"} - * - * *·List item. - * - * Paragraph. - * - * 11.·List item - * - * Paragraph. - * - * *·List - * ··item. - * - * *·List - * ··item. - * - * @example - * {"name": "not-ok.md", "setting": "space", "label": "input"} - * - * *···List - * ····item. - * - * @example - * {"name": "not-ok.md", "setting": "space", "label": "output"} - * - * 1:5: Incorrect list-item indent: remove 2 spaces - * - * @example - * {"name": "not-ok.md", "setting": "tab-size", "label": "input"} - * - * *·List - * ··item. - * - * @example - * {"name": "not-ok.md", "setting": "tab-size", "label": "output"} - * - * 1:3: Incorrect list-item indent: add 2 spaces - * - * @example - * {"name": "not-ok.md", "setting": "mixed", "label": "input"} +function compiler(options = {}) { + /** @type {NormalizedExtension} */ + // @ts-expect-error: our base has all required fields, so the result will too. + const config = configure$1( + { + transforms: [], + canContainEols: [ + 'emphasis', + 'fragment', + 'heading', + 'paragraph', + 'strong' + ], + enter: { + autolink: opener(link), + autolinkProtocol: onenterdata, + autolinkEmail: onenterdata, + atxHeading: opener(heading), + blockQuote: opener(blockQuote), + characterEscape: onenterdata, + characterReference: onenterdata, + codeFenced: opener(codeFlow), + codeFencedFenceInfo: buffer, + codeFencedFenceMeta: buffer, + codeIndented: opener(codeFlow, buffer), + codeText: opener(codeText, buffer), + codeTextData: onenterdata, + data: onenterdata, + codeFlowValue: onenterdata, + definition: opener(definition), + definitionDestinationString: buffer, + definitionLabelString: buffer, + definitionTitleString: buffer, + emphasis: opener(emphasis), + hardBreakEscape: opener(hardBreak), + hardBreakTrailing: opener(hardBreak), + htmlFlow: opener(html, buffer), + htmlFlowData: onenterdata, + htmlText: opener(html, buffer), + htmlTextData: onenterdata, + image: opener(image), + label: buffer, + link: opener(link), + listItem: opener(listItem), + listItemValue: onenterlistitemvalue, + listOrdered: opener(list, onenterlistordered), + listUnordered: opener(list), + paragraph: opener(paragraph), + reference: onenterreference, + referenceString: buffer, + resourceDestinationString: buffer, + resourceTitleString: buffer, + setextHeading: opener(heading), + strong: opener(strong), + thematicBreak: opener(thematicBreak) + }, + exit: { + atxHeading: closer(), + atxHeadingSequence: onexitatxheadingsequence, + autolink: closer(), + autolinkEmail: onexitautolinkemail, + autolinkProtocol: onexitautolinkprotocol, + blockQuote: closer(), + characterEscapeValue: onexitdata, + characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, + characterReferenceMarkerNumeric: onexitcharacterreferencemarker, + characterReferenceValue: onexitcharacterreferencevalue, + codeFenced: closer(onexitcodefenced), + codeFencedFence: onexitcodefencedfence, + codeFencedFenceInfo: onexitcodefencedfenceinfo, + codeFencedFenceMeta: onexitcodefencedfencemeta, + codeFlowValue: onexitdata, + codeIndented: closer(onexitcodeindented), + codeText: closer(onexitcodetext), + codeTextData: onexitdata, + data: onexitdata, + definition: closer(), + definitionDestinationString: onexitdefinitiondestinationstring, + definitionLabelString: onexitdefinitionlabelstring, + definitionTitleString: onexitdefinitiontitlestring, + emphasis: closer(), + hardBreakEscape: closer(onexithardbreak), + hardBreakTrailing: closer(onexithardbreak), + htmlFlow: closer(onexithtmlflow), + htmlFlowData: onexitdata, + htmlText: closer(onexithtmltext), + htmlTextData: onexitdata, + image: closer(onexitimage), + label: onexitlabel, + labelText: onexitlabeltext, + lineEnding: onexitlineending, + link: closer(onexitlink), + listItem: closer(), + listOrdered: closer(), + listUnordered: closer(), + paragraph: closer(), + referenceString: onexitreferencestring, + resourceDestinationString: onexitresourcedestinationstring, + resourceTitleString: onexitresourcetitlestring, + resource: onexitresource, + setextHeading: closer(onexitsetextheading), + setextHeadingLineSequence: onexitsetextheadinglinesequence, + setextHeadingText: onexitsetextheadingtext, + strong: closer(), + thematicBreak: closer() + } + }, + options.mdastExtensions || [] + ); + /** @type {CompileData} */ + + const data = {}; + return compile + /** + * @param {Array.} events + * @returns {Root} + */ + + function compile(events) { + /** @type {Root} */ + let tree = { + type: 'root', + children: [] + }; + /** @type {CompileContext['stack']} */ + + const stack = [tree]; + /** @type {CompileContext['tokenStack']} */ + + const tokenStack = []; + /** @type {Array.} */ + + const listStack = []; + /** @type {Omit} */ + + const context = { + stack, + tokenStack, + config, + enter, + exit, + buffer, + resume, + setData, + getData + }; + let index = -1; + + while (++index < events.length) { + // We preprocess lists to add `listItem` tokens, and to infer whether + // items the list itself are spread out. + if ( + events[index][1].type === 'listOrdered' || + events[index][1].type === 'listUnordered' + ) { + if (events[index][0] === 'enter') { + listStack.push(index); + } else { + const tail = listStack.pop(); + index = prepareList(events, tail, index); + } + } + } + + index = -1; + + while (++index < events.length) { + const handler = config[events[index][0]]; + + if (own$4.call(handler, events[index][1].type)) { + handler[events[index][1].type].call( + Object.assign( + { + sliceSerialize: events[index][2].sliceSerialize + }, + context + ), + events[index][1] + ); + } + } + + if (tokenStack.length > 0) { + throw new Error( + 'Cannot close document, a token (`' + + tokenStack[tokenStack.length - 1].type + + '`, ' + + stringifyPosition$1({ + start: tokenStack[tokenStack.length - 1].start, + end: tokenStack[tokenStack.length - 1].end + }) + + ') is still open' + ) + } // Figure out `root` position. + + tree.position = { + start: point( + events.length > 0 + ? events[0][1].start + : { + line: 1, + column: 1, + offset: 0 + } + ), + end: point( + events.length > 0 + ? events[events.length - 2][1].end + : { + line: 1, + column: 1, + offset: 0 + } + ) + }; + index = -1; + + while (++index < config.transforms.length) { + tree = config.transforms[index](tree) || tree; + } + + return tree + } + /** + * @param {Array.} events + * @param {number} start + * @param {number} length + * @returns {number} + */ + + function prepareList(events, start, length) { + let index = start - 1; + let containerBalance = -1; + let listSpread = false; + /** @type {Token|undefined} */ + + let listItem; + /** @type {number|undefined} */ + + let lineIndex; + /** @type {number|undefined} */ + + let firstBlankLineIndex; + /** @type {boolean|undefined} */ + + let atMarker; + + while (++index <= length) { + const event = events[index]; + + if ( + event[1].type === 'listUnordered' || + event[1].type === 'listOrdered' || + event[1].type === 'blockQuote' + ) { + if (event[0] === 'enter') { + containerBalance++; + } else { + containerBalance--; + } + + atMarker = undefined; + } else if (event[1].type === 'lineEndingBlank') { + if (event[0] === 'enter') { + if ( + listItem && + !atMarker && + !containerBalance && + !firstBlankLineIndex + ) { + firstBlankLineIndex = index; + } + + atMarker = undefined; + } + } else if ( + event[1].type === 'linePrefix' || + event[1].type === 'listItemValue' || + event[1].type === 'listItemMarker' || + event[1].type === 'listItemPrefix' || + event[1].type === 'listItemPrefixWhitespace' + ) ; else { + atMarker = undefined; + } + + if ( + (!containerBalance && + event[0] === 'enter' && + event[1].type === 'listItemPrefix') || + (containerBalance === -1 && + event[0] === 'exit' && + (event[1].type === 'listUnordered' || + event[1].type === 'listOrdered')) + ) { + if (listItem) { + let tailIndex = index; + lineIndex = undefined; + + while (tailIndex--) { + const tailEvent = events[tailIndex]; + + if ( + tailEvent[1].type === 'lineEnding' || + tailEvent[1].type === 'lineEndingBlank' + ) { + if (tailEvent[0] === 'exit') continue + + if (lineIndex) { + events[lineIndex][1].type = 'lineEndingBlank'; + listSpread = true; + } + + tailEvent[1].type = 'lineEnding'; + lineIndex = tailIndex; + } else if ( + tailEvent[1].type === 'linePrefix' || + tailEvent[1].type === 'blockQuotePrefix' || + tailEvent[1].type === 'blockQuotePrefixWhitespace' || + tailEvent[1].type === 'blockQuoteMarker' || + tailEvent[1].type === 'listItemIndent' + ) ; else { + break + } + } + + if ( + firstBlankLineIndex && + (!lineIndex || firstBlankLineIndex < lineIndex) + ) { + // @ts-expect-error Patched. + listItem._spread = true; + } // Fix position. + + listItem.end = Object.assign( + {}, + lineIndex ? events[lineIndex][1].start : event[1].end + ); + events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]); + index++; + length++; + } // Create a new list item. + + if (event[1].type === 'listItemPrefix') { + listItem = { + type: 'listItem', + // @ts-expect-error Patched + _spread: false, + start: Object.assign({}, event[1].start) + }; // @ts-expect-error: `listItem` is most definitely defined, TS... + + events.splice(index, 0, ['enter', listItem, event[2]]); + index++; + length++; + firstBlankLineIndex = undefined; + atMarker = true; + } + } + } // @ts-expect-error Patched. + + events[start][1]._spread = listSpread; + return length + } + /** + * @type {CompileContext['setData']} + * @param [value] + */ + + function setData(key, value) { + data[key] = value; + } + /** + * @type {CompileContext['getData']} + * @template {string} K + * @param {K} key + * @returns {CompileData[K]} + */ + + function getData(key) { + return data[key] + } + /** + * @param {Point} d + * @returns {Point} + */ + + function point(d) { + return { + line: d.line, + column: d.column, + offset: d.offset + } + } + /** + * @param {(token: Token) => Node} create + * @param {Handle} [and] + * @returns {Handle} + */ + + function opener(create, and) { + return open + /** + * @this {CompileContext} + * @param {Token} token + * @returns {void} + */ + + function open(token) { + enter.call(this, create(token), token); + if (and) and.call(this, token); + } + } + /** @type {CompileContext['buffer']} */ + + function buffer() { + // @ts-expect-error: Custom node type to collect text. + this.stack.push({ + type: 'fragment', + children: [] + }); + } + /** + * @type {CompileContext['enter']} + * @template {Node} N + * @this {CompileContext} + * @param {N} node + * @param {Token} token + * @returns {N} + */ + + function enter(node, token) { + /** @type {Parent} */ + // @ts-expect-error: Assume parent. + const parent = this.stack[this.stack.length - 1]; + parent.children.push(node); + this.stack.push(node); + this.tokenStack.push(token); // @ts-expect-error: `end` will be patched later. + + node.position = { + start: point(token.start) + }; + return node + } + /** + * @param {Handle} [and] + * @returns {Handle} + */ + + function closer(and) { + return close + /** + * @this {CompileContext} + * @param {Token} token + * @returns {void} + */ + + function close(token) { + if (and) and.call(this, token); + exit.call(this, token); + } + } + /** @type {CompileContext['exit']} */ + + function exit(token) { + const node = this.stack.pop(); + const open = this.tokenStack.pop(); + + if (!open) { + throw new Error( + 'Cannot close `' + + token.type + + '` (' + + stringifyPosition$1({ + start: token.start, + end: token.end + }) + + '): it’s not open' + ) + } else if (open.type !== token.type) { + throw new Error( + 'Cannot close `' + + token.type + + '` (' + + stringifyPosition$1({ + start: token.start, + end: token.end + }) + + '): a different token (`' + + open.type + + '`, ' + + stringifyPosition$1({ + start: open.start, + end: open.end + }) + + ') is open' + ) + } + + node.position.end = point(token.end); + return node + } + /** + * @this {CompileContext} + * @returns {string} + */ + + function resume() { + return toString(this.stack.pop()) + } // + // Handlers. + // + + /** @type {Handle} */ + + function onenterlistordered() { + setData('expectingFirstListItemValue', true); + } + /** @type {Handle} */ + + function onenterlistitemvalue(token) { + if (getData('expectingFirstListItemValue')) { + this.stack[this.stack.length - 2].start = Number.parseInt( + this.sliceSerialize(token), + 10 + ); + setData('expectingFirstListItemValue'); + } + } + /** @type {Handle} */ + + function onexitcodefencedfenceinfo() { + const data = this.resume(); + this.stack[this.stack.length - 1].lang = data; + } + /** @type {Handle} */ + + function onexitcodefencedfencemeta() { + const data = this.resume(); + this.stack[this.stack.length - 1].meta = data; + } + /** @type {Handle} */ + + function onexitcodefencedfence() { + // Exit if this is the closing fence. + if (getData('flowCodeInside')) return + this.buffer(); + setData('flowCodeInside', true); + } + /** @type {Handle} */ + + function onexitcodefenced() { + const data = this.resume(); + this.stack[this.stack.length - 1].value = data.replace( + /^(\r?\n|\r)|(\r?\n|\r)$/g, + '' + ); + setData('flowCodeInside'); + } + /** @type {Handle} */ + + function onexitcodeindented() { + const data = this.resume(); + this.stack[this.stack.length - 1].value = data.replace(/(\r?\n|\r)$/g, ''); + } + /** @type {Handle} */ + + function onexitdefinitionlabelstring(token) { + // Discard label, use the source content instead. + const label = this.resume(); + this.stack[this.stack.length - 1].label = label; + this.stack[this.stack.length - 1].identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + } + /** @type {Handle} */ + + function onexitdefinitiontitlestring() { + const data = this.resume(); + this.stack[this.stack.length - 1].title = data; + } + /** @type {Handle} */ + + function onexitdefinitiondestinationstring() { + const data = this.resume(); + this.stack[this.stack.length - 1].url = data; + } + /** @type {Handle} */ + + function onexitatxheadingsequence(token) { + if (!this.stack[this.stack.length - 1].depth) { + this.stack[this.stack.length - 1].depth = + this.sliceSerialize(token).length; + } + } + /** @type {Handle} */ + + function onexitsetextheadingtext() { + setData('setextHeadingSlurpLineEnding', true); + } + /** @type {Handle} */ + + function onexitsetextheadinglinesequence(token) { + this.stack[this.stack.length - 1].depth = + this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2; + } + /** @type {Handle} */ + + function onexitsetextheading() { + setData('setextHeadingSlurpLineEnding'); + } + /** @type {Handle} */ + + function onenterdata(token) { + /** @type {Parent} */ + // @ts-expect-error: assume parent. + const parent = this.stack[this.stack.length - 1]; + /** @type {Node} */ + // @ts-expect-error: assume child. + + let tail = parent.children[parent.children.length - 1]; + + if (!tail || tail.type !== 'text') { + // Add a new text node. + tail = text(); // @ts-expect-error: we’ll add `end` later. + + tail.position = { + start: point(token.start) + }; + parent.children.push(tail); + } + + this.stack.push(tail); + } + /** @type {Handle} */ + + function onexitdata(token) { + const tail = this.stack.pop(); + tail.value += this.sliceSerialize(token); + tail.position.end = point(token.end); + } + /** @type {Handle} */ + + function onexitlineending(token) { + /** @type {Parent} */ + // @ts-expect-error: supposed to be a parent. + const context = this.stack[this.stack.length - 1]; + + // If we’re at a hard break, include the line ending in there. + if (getData('atHardBreak')) { + const tail = context.children[context.children.length - 1]; + tail.position.end = point(token.end); + setData('atHardBreak'); + return + } + + if ( + !getData('setextHeadingSlurpLineEnding') && + config.canContainEols.includes(context.type) + ) { + onenterdata.call(this, token); + onexitdata.call(this, token); + } + } + /** @type {Handle} */ + + function onexithardbreak() { + setData('atHardBreak', true); + } + /** @type {Handle} */ + + function onexithtmlflow() { + const data = this.resume(); + this.stack[this.stack.length - 1].value = data; + } + /** @type {Handle} */ + + function onexithtmltext() { + const data = this.resume(); + this.stack[this.stack.length - 1].value = data; + } + /** @type {Handle} */ + + function onexitcodetext() { + const data = this.resume(); + this.stack[this.stack.length - 1].value = data; + } + /** @type {Handle} */ + + function onexitlink() { + const context = this.stack[this.stack.length - 1]; // To do: clean. + + if (getData('inReference')) { + context.type += 'Reference'; + context.referenceType = getData('referenceType') || 'shortcut'; + delete context.url; + delete context.title; + } else { + delete context.identifier; + delete context.label; + delete context.referenceType; + } + + setData('referenceType'); + } + /** @type {Handle} */ + + function onexitimage() { + const context = this.stack[this.stack.length - 1]; // To do: clean. + + if (getData('inReference')) { + context.type += 'Reference'; + context.referenceType = getData('referenceType') || 'shortcut'; + delete context.url; + delete context.title; + } else { + delete context.identifier; + delete context.label; + delete context.referenceType; + } + + setData('referenceType'); + } + /** @type {Handle} */ + + function onexitlabeltext(token) { + this.stack[this.stack.length - 2].identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + } + /** @type {Handle} */ + + function onexitlabel() { + const fragment = this.stack[this.stack.length - 1]; + const value = this.resume(); + this.stack[this.stack.length - 1].label = value; // Assume a reference. + + setData('inReference', true); + + if (this.stack[this.stack.length - 1].type === 'link') { + this.stack[this.stack.length - 1].children = fragment.children; + } else { + this.stack[this.stack.length - 1].alt = value; + } + } + /** @type {Handle} */ + + function onexitresourcedestinationstring() { + const data = this.resume(); + this.stack[this.stack.length - 1].url = data; + } + /** @type {Handle} */ + + function onexitresourcetitlestring() { + const data = this.resume(); + this.stack[this.stack.length - 1].title = data; + } + /** @type {Handle} */ + + function onexitresource() { + setData('inReference'); + } + /** @type {Handle} */ + + function onenterreference() { + setData('referenceType', 'collapsed'); + } + /** @type {Handle} */ + + function onexitreferencestring(token) { + const label = this.resume(); + this.stack[this.stack.length - 1].label = label; + this.stack[this.stack.length - 1].identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + setData('referenceType', 'full'); + } + /** @type {Handle} */ + + function onexitcharacterreferencemarker(token) { + setData('characterReferenceType', token.type); + } + /** @type {Handle} */ + + function onexitcharacterreferencevalue(token) { + const data = this.sliceSerialize(token); + const type = getData('characterReferenceType'); + /** @type {string} */ + + let value; + + if (type) { + value = decodeNumericCharacterReference( + data, + type === 'characterReferenceMarkerNumeric' ? 10 : 16 + ); + setData('characterReferenceType'); + } else { + // @ts-expect-error `decodeEntity` can return false for invalid named + // character references, but everything we’ve tokenized is valid. + value = decodeEntity(data); + } + + const tail = this.stack.pop(); + tail.value += value; + tail.position.end = point(token.end); + } + /** @type {Handle} */ + + function onexitautolinkprotocol(token) { + onexitdata.call(this, token); + this.stack[this.stack.length - 1].url = this.sliceSerialize(token); + } + /** @type {Handle} */ + + function onexitautolinkemail(token) { + onexitdata.call(this, token); + this.stack[this.stack.length - 1].url = + 'mailto:' + this.sliceSerialize(token); + } // + // Creaters. + // + + /** @returns {Blockquote} */ + + function blockQuote() { + return { + type: 'blockquote', + children: [] + } + } + /** @returns {Code} */ + + function codeFlow() { + // @ts-expect-error: we’ve always used `null`. + return { + type: 'code', + lang: null, + meta: null, + value: '' + } + } + /** @returns {InlineCode} */ + + function codeText() { + return { + type: 'inlineCode', + value: '' + } + } + /** @returns {Definition} */ + + function definition() { + return { + type: 'definition', + identifier: '', + // @ts-expect-error: we’ve always used `null`. + label: null, + // @ts-expect-error: we’ve always used `null`. + title: null, + url: '' + } + } + /** @returns {Emphasis} */ + + function emphasis() { + return { + type: 'emphasis', + children: [] + } + } + /** @returns {Heading} */ + + function heading() { + // @ts-expect-error `depth` will be set later. + return { + type: 'heading', + depth: undefined, + children: [] + } + } + /** @returns {Break} */ + + function hardBreak() { + return { + type: 'break' + } + } + /** @returns {HTML} */ + + function html() { + return { + type: 'html', + value: '' + } + } + /** @returns {Image} */ + + function image() { + // @ts-expect-error: we’ve always used `null`. + return { + type: 'image', + title: null, + url: '', + alt: null + } + } + /** @returns {Link} */ + + function link() { + // @ts-expect-error: we’ve always used `null`. + return { + type: 'link', + title: null, + url: '', + children: [] + } + } + /** + * @param {Token} token + * @returns {List} + */ + + function list(token) { + return { + type: 'list', + ordered: token.type === 'listOrdered', + // @ts-expect-error: we’ve always used `null`. + start: null, + // @ts-expect-error Patched. + spread: token._spread, + children: [] + } + } + /** + * @param {Token} token + * @returns {ListItem} + */ + + function listItem(token) { + return { + type: 'listItem', + // @ts-expect-error Patched. + spread: token._spread, + // @ts-expect-error: we’ve always used `null`. + checked: null, + children: [] + } + } + /** @returns {Paragraph} */ + + function paragraph() { + return { + type: 'paragraph', + children: [] + } + } + /** @returns {Strong} */ + + function strong() { + return { + type: 'strong', + children: [] + } + } + /** @returns {Text} */ + + function text() { + return { + type: 'text', + value: '' + } + } + /** @returns {ThematicBreak} */ + + function thematicBreak() { + return { + type: 'thematicBreak' + } + } +} +/** + * @param {Extension} combined + * @param {Array.>} extensions + * @returns {Extension} + */ + +function configure$1(combined, extensions) { + let index = -1; + + while (++index < extensions.length) { + const value = extensions[index]; + + if (Array.isArray(value)) { + configure$1(combined, value); + } else { + extension(combined, value); + } + } + + return combined +} +/** + * @param {Extension} combined + * @param {Extension} extension + * @returns {void} + */ + +function extension(combined, extension) { + /** @type {string} */ + let key; + + for (key in extension) { + if (own$4.call(extension, key)) { + const list = key === 'canContainEols' || key === 'transforms'; + const maybe = own$4.call(combined, key) ? combined[key] : undefined; + /* c8 ignore next */ + + const left = maybe || (combined[key] = list ? [] : {}); + const right = extension[key]; + + if (right) { + if (list) { + // @ts-expect-error: `left` is an array. + combined[key] = [...left, ...right]; + } else { + Object.assign(left, right); + } + } + } + } +} + +/** + * @typedef {import('mdast').Root} Root + * @typedef {import('mdast-util-from-markdown').Options} Options + */ + +/** @type {import('unified').Plugin<[Options?] | void[], string, Root>} */ +function remarkParse(options) { + /** @type {import('unified').ParserFunction} */ + const parser = (doc) => { + // Assume options. + const settings = /** @type {Options} */ (this.data('settings')); + + return fromMarkdown( + doc, + Object.assign({}, settings, options, { + // Note: these options are not in the readme. + // The goal is for them to be set by plugins on `data` instead of being + // passed by users. + extensions: this.data('micromarkExtensions') || [], + mdastExtensions: this.data('fromMarkdownExtensions') || [] + }) + ) + }; + + Object.assign(this, {Parser: parser}); +} + +var own$3 = {}.hasOwnProperty; + +/** + * @callback Handler + * @param {...unknown} value + * @return {unknown} * - * *···List item. + * @typedef {Record} Handlers * - * @example - * {"name": "not-ok.md", "setting": "mixed", "label": "output"} + * @typedef {Object} Options + * @property {Handler} [unknown] + * @property {Handler} [invalid] + * @property {Handlers} [handlers] + */ + +/** + * Handle values based on a property. * - * 1:5: Incorrect list-item indent: remove 2 spaces + * @param {string} key + * @param {Options} [options] + */ +function zwitch(key, options) { + var settings = options || {}; + + /** + * Handle one value. + * Based on the bound `key`, a respective handler will be called. + * If `value` is not an object, or doesn’t have a `key` property, the special + * “invalid” handler will be called. + * If `value` has an unknown `key`, the special “unknown” handler will be + * called. + * + * All arguments, and the context object, are passed through to the handler, + * and it’s result is returned. + * + * @param {...unknown} [value] + * @this {unknown} + * @returns {unknown} + * @property {Handler} invalid + * @property {Handler} unknown + * @property {Handlers} handlers + */ + function one(value) { + var fn = one.invalid; + var handlers = one.handlers; + + if (value && own$3.call(value, key)) { + fn = own$3.call(handlers, value[key]) ? handlers[value[key]] : one.unknown; + } + + if (fn) { + return fn.apply(this, arguments) + } + } + + one.handlers = settings.handlers || {}; + one.invalid = settings.invalid; + one.unknown = settings.unknown; + + return one +} + +/** + * @typedef {import('./types.js').Options} Options + * @typedef {import('./types.js').Context} Context + */ + +/** + * @param {Context} base + * @param {Options} extension + * @returns {Context} + */ +function configure(base, extension) { + let index = -1; + /** @type {string} */ + let key; + + // First do subextensions. + if (extension.extensions) { + while (++index < extension.extensions.length) { + configure(base, extension.extensions[index]); + } + } + + for (key in extension) { + if (key === 'extensions') ; else if (key === 'unsafe' || key === 'join') { + /* c8 ignore next 2 */ + // @ts-expect-error: hush. + base[key] = [...(base[key] || []), ...(extension[key] || [])]; + } else if (key === 'handlers') { + base[key] = Object.assign(base[key], extension[key] || {}); + } else { + // @ts-expect-error: hush. + base.options[key] = extension[key]; + } + } + + return base +} + +/** + * @typedef {import('../types.js').Node} Node + * @typedef {import('../types.js').Parent} Parent + * @typedef {import('../types.js').Join} Join + * @typedef {import('../types.js').Context} Context + */ + +/** + * @param {Parent} parent + * @param {Context} context + * @returns {string} + */ +function containerFlow(parent, context) { + const children = parent.children || []; + /** @type {Array.} */ + const results = []; + let index = -1; + + while (++index < children.length) { + const child = children[index]; + + results.push( + context.handle(child, parent, context, {before: '\n', after: '\n'}) + ); + + if (index < children.length - 1) { + results.push(between(child, children[index + 1])); + } + } + + return results.join('') + + /** + * @param {Node} left + * @param {Node} right + * @returns {string} + */ + function between(left, right) { + let index = context.join.length; + /** @type {ReturnType} */ + let result; + + while (index--) { + result = context.join[index](left, right, parent, context); + + if (result === true || result === 1) { + break + } + + if (typeof result === 'number') { + return '\n'.repeat(1 + result) + } + + if (result === false) { + return '\n\n\n\n' + } + } + + return '\n\n' + } +} + +/** + * @callback Map + * @param {string} value + * @param {number} line + * @param {boolean} blank + * @returns {string} + */ + +const eol = /\r?\n|\r/g; + +/** + * @param {string} value + * @param {Map} map + * @returns {string} + */ +function indentLines(value, map) { + /** @type {Array.} */ + const result = []; + let start = 0; + let line = 0; + /** @type {RegExpExecArray|null} */ + let match; + + while ((match = eol.exec(value))) { + one(value.slice(start, match.index)); + result.push(match[0]); + start = match.index + match[0].length; + line++; + } + + one(value.slice(start)); + + return result.join('') + + /** + * @param {string} value + */ + function one(value) { + result.push(map(value, line, !value)); + } +} + +/** + * @typedef {import('mdast').Blockquote} Blockquote + * @typedef {import('../types.js').Handle} Handle + * @typedef {import('../util/indent-lines.js').Map} Map + */ + +/** + * @type {Handle} + * @param {Blockquote} node + */ +function blockquote(node, _, context) { + const exit = context.enter('blockquote'); + const value = indentLines(containerFlow(node, context), map$1); + exit(); + return value +} + +/** @type {Map} */ +function map$1(line, _, blank) { + return '>' + (blank ? '' : ' ') + line +} + +/** + * @typedef {import('../types.js').Unsafe} Unsafe + */ + +/** + * @param {Array.} stack + * @param {Unsafe} pattern + * @returns {boolean} + */ +function patternInScope(stack, pattern) { + return ( + listInScope(stack, pattern.inConstruct, true) && + !listInScope(stack, pattern.notInConstruct, false) + ) +} + +/** + * @param {Array.} stack + * @param {Unsafe['inConstruct']} list + * @param {boolean} none + * @returns {boolean} + */ +function listInScope(stack, list, none) { + if (!list) { + return none + } + + if (typeof list === 'string') { + list = [list]; + } + + let index = -1; + + while (++index < list.length) { + if (stack.includes(list[index])) { + return true + } + } + + return false +} + +/** + * @typedef {import('../types.js').Handle} Handle + * @typedef {import('mdast').Break} Break + */ + +/** + * @type {Handle} + * @param {Break} _ + */ +function hardBreak(_, _1, context, safe) { + let index = -1; + + while (++index < context.unsafe.length) { + // If we can’t put eols in this construct (setext headings, tables), use a + // space instead. + if ( + context.unsafe[index].character === '\n' && + patternInScope(context.stack, context.unsafe[index]) + ) { + return /[ \t]/.test(safe.before) ? '' : ' ' + } + } + + return '\\\n' +} + +/** + * Get the count of the longest repeating streak of `character` in `value`. * - * @example - * {"name": "not-ok.md", "setting": "💩", "label": "output", "positionless": true} + * @param {string} value Content. + * @param {string} character Single character to look for + * @returns {number} Count of most frequent adjacent `character`s in `value` + */ +function longestStreak(value, character) { + var source = String(value); + var index = source.indexOf(character); + var expected = index; + var count = 0; + var max = 0; + + if (typeof character !== 'string' || character.length !== 1) { + throw new Error('Expected character') + } + + while (index !== -1) { + if (index === expected) { + if (++count > max) { + max = count; + } + } else { + count = 1; + } + + expected = index + 1; + index = source.indexOf(character, expected); + } + + return max +} + +/** + * @typedef {import('mdast').Code} Code + * @typedef {import('../types.js').Context} Context + */ + +/** + * @param {Code} node + * @param {Context} context + * @returns {boolean} + */ +function formatCodeAsIndented(node, context) { + return Boolean( + !context.options.fences && + node.value && + // If there’s no info… + !node.lang && + // And there’s a non-whitespace character… + /[^ \r\n]/.test(node.value) && + // And the value doesn’t start or end in a blank… + !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node.value) + ) +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').Options} Options + */ + +/** + * @param {Context} context + * @returns {Exclude} + */ +function checkFence(context) { + const marker = context.options.fence || '`'; + + if (marker !== '`' && marker !== '~') { + throw new Error( + 'Cannot serialize code with `' + + marker + + '` for `options.fence`, expected `` ` `` or `~`' + ) + } + + return marker +} + +/** + * @typedef {import('../types.js').Unsafe} Unsafe + */ + +/** + * @param {Unsafe} pattern + * @returns {RegExp} + */ +function patternCompile(pattern) { + if (!pattern._compiled) { + const before = + (pattern.atBreak ? '[\\r\\n][\\t ]*' : '') + + (pattern.before ? '(?:' + pattern.before + ')' : ''); + + pattern._compiled = new RegExp( + (before ? '(' + before + ')' : '') + + (/[|\\{}()[\]^$+*?.-]/.test(pattern.character) ? '\\' : '') + + pattern.character + + (pattern.after ? '(?:' + pattern.after + ')' : ''), + 'g' + ); + } + + return pattern._compiled +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').SafeOptions} SafeOptions + */ + +/** + * @param {Context} context + * @param {string|null|undefined} input + * @param {SafeOptions & {encode?: Array.}} config + * @returns {string} + */ +function safe(context, input, config) { + const value = (config.before || '') + (input || '') + (config.after || ''); + /** @type {Array.} */ + const positions = []; + /** @type {Array.} */ + const result = []; + /** @type {Record} */ + const infos = {}; + let index = -1; + + while (++index < context.unsafe.length) { + const pattern = context.unsafe[index]; + + if (!patternInScope(context.stack, pattern)) { + continue + } + + const expression = patternCompile(pattern); + /** @type {RegExpExecArray|null} */ + let match; + + while ((match = expression.exec(value))) { + const before = 'before' in pattern || Boolean(pattern.atBreak); + const after = 'after' in pattern; + const position = match.index + (before ? match[1].length : 0); + + if (positions.includes(position)) { + if (infos[position].before && !before) { + infos[position].before = false; + } + + if (infos[position].after && !after) { + infos[position].after = false; + } + } else { + positions.push(position); + infos[position] = {before, after}; + } + } + } + + positions.sort(numerical); + + let start = config.before ? config.before.length : 0; + const end = value.length - (config.after ? config.after.length : 0); + index = -1; + + while (++index < positions.length) { + const position = positions[index]; + + // Character before or after matched: + if (position < start || position >= end) { + continue + } + + // If this character is supposed to be escaped because it has a condition on + // the next character, and the next character is definitly being escaped, + // then skip this escape. + if ( + position + 1 < end && + positions[index + 1] === position + 1 && + infos[position].after && + !infos[position + 1].before && + !infos[position + 1].after + ) { + continue + } + + if (start !== position) { + // If we have to use a character reference, an ampersand would be more + // correct, but as backslashes only care about punctuation, either will + // do the trick + result.push(escapeBackslashes(value.slice(start, position), '\\')); + } + + start = position; + + if ( + /[!-/:-@[-`{-~]/.test(value.charAt(position)) && + (!config.encode || !config.encode.includes(value.charAt(position))) + ) { + // Character escape. + result.push('\\'); + } else { + // Character reference. + result.push( + '&#x' + value.charCodeAt(position).toString(16).toUpperCase() + ';' + ); + start++; + } + } + + result.push(escapeBackslashes(value.slice(start, end), config.after)); + + return result.join('') +} + +/** + * @param {number} a + * @param {number} b + * @returns {number} + */ +function numerical(a, b) { + return a - b +} + +/** + * @param {string} value + * @param {string} after + * @returns {string} + */ +function escapeBackslashes(value, after) { + const expression = /\\(?=[!-/:-@[-`{-~])/g; + /** @type {Array.} */ + const positions = []; + /** @type {Array.} */ + const results = []; + const whole = value + after; + let index = -1; + let start = 0; + /** @type {RegExpExecArray|null} */ + let match; + + while ((match = expression.exec(whole))) { + positions.push(match.index); + } + + while (++index < positions.length) { + if (start !== positions[index]) { + results.push(value.slice(start, positions[index])); + } + + results.push('\\'); + start = positions[index]; + } + + results.push(value.slice(start)); + + return results.join('') +} + +/** + * @typedef {import('mdast').Code} Code + * @typedef {import('../types.js').Handle} Handle + * @typedef {import('../types.js').Exit} Exit + * @typedef {import('../util/indent-lines.js').Map} Map + */ + +/** + * @type {Handle} + * @param {Code} node + */ +function code$1(node, _, context) { + const marker = checkFence(context); + const raw = node.value || ''; + const suffix = marker === '`' ? 'GraveAccent' : 'Tilde'; + /** @type {string} */ + let value; + /** @type {Exit} */ + let exit; + + if (formatCodeAsIndented(node, context)) { + exit = context.enter('codeIndented'); + value = indentLines(raw, map); + } else { + const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3)); + /** @type {Exit} */ + let subexit; + exit = context.enter('codeFenced'); + value = sequence; + + if (node.lang) { + subexit = context.enter('codeFencedLang' + suffix); + value += safe(context, node.lang, { + before: '`', + after: ' ', + encode: ['`'] + }); + subexit(); + } + + if (node.lang && node.meta) { + subexit = context.enter('codeFencedMeta' + suffix); + value += + ' ' + + safe(context, node.meta, { + before: ' ', + after: '\n', + encode: ['`'] + }); + subexit(); + } + + value += '\n'; + + if (raw) { + value += raw + '\n'; + } + + value += sequence; + } + + exit(); + return value +} + +/** @type {Map} */ +function map(line, _, blank) { + return (blank ? '' : ' ') + line +} + +/** + * @typedef {import('mdast').Association} Association + */ + +const characterEscape = /\\([!-/:-@[-`{-~])/g; +const characterReference = /&(#(\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; + +/** + * The `label` of an association is the string value: character escapes and + * references work, and casing is intact. + * The `identifier` is used to match one association to another: controversially, + * character escapes and references don’t work in this matching: `©` does + * not match `©`, and `\+` does not match `+`. + * But casing is ignored (and whitespace) is trimmed and collapsed: ` A\nb` + * matches `a b`. + * So, we do prefer the label when figuring out how we’re going to serialize: + * it has whitespace, casing, and we can ignore most useless character escapes + * and all character references. * - * 1:1: Incorrect list-item indent style `💩`: use either `'tab-size'`, `'space'`, or `'mixed'` + * @param {Association} node + * @returns {string} + */ +function association(node) { + if (node.label || !node.identifier) { + return node.label || '' + } + + return node.identifier + .replace(characterEscape, '$1') + .replace(characterReference, decodeIfPossible) +} + +/** + * @param {string} $0 + * @param {string} $1 + * @returns {string} + */ +function decodeIfPossible($0, $1) { + return decodeEntity($1) || $0 +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').Options} Options + */ + +/** + * @param {Context} context + * @returns {Exclude} + */ +function checkQuote(context) { + const marker = context.options.quote || '"'; + + if (marker !== '"' && marker !== "'") { + throw new Error( + 'Cannot serialize title with `' + + marker + + '` for `options.quote`, expected `"`, or `\'`' + ) + } + + return marker +} + +/** + * @typedef {import('mdast').Definition} Definition + * @typedef {import('../types.js').Handle} Handle + */ + +/** + * @type {Handle} + * @param {Definition} node + */ +function definition(node, _, context) { + const marker = checkQuote(context); + const suffix = marker === '"' ? 'Quote' : 'Apostrophe'; + const exit = context.enter('definition'); + let subexit = context.enter('label'); + let value = + '[' + safe(context, association(node), {before: '[', after: ']'}) + ']: '; + + subexit(); + + if ( + // If there’s no url, or… + !node.url || + // If there’s whitespace, enclosed is prettier. + /[ \t\r\n]/.test(node.url) + ) { + subexit = context.enter('destinationLiteral'); + value += '<' + safe(context, node.url, {before: '<', after: '>'}) + '>'; + } else { + // No whitespace, raw is prettier. + subexit = context.enter('destinationRaw'); + value += safe(context, node.url, {before: ' ', after: ' '}); + } + + subexit(); + + if (node.title) { + subexit = context.enter('title' + suffix); + value += + ' ' + + marker + + safe(context, node.title, {before: marker, after: marker}) + + marker; + subexit(); + } + + exit(); + + return value +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').Options} Options + */ + +/** + * @param {Context} context + * @returns {Exclude} + */ +function checkEmphasis(context) { + const marker = context.options.emphasis || '*'; + + if (marker !== '*' && marker !== '_') { + throw new Error( + 'Cannot serialize emphasis with `' + + marker + + '` for `options.emphasis`, expected `*`, or `_`' + ) + } + + return marker +} + +/** + * @typedef {import('../types.js').Node} Node + * @typedef {import('../types.js').Parent} Parent + * @typedef {import('../types.js').SafeOptions} SafeOptions + * @typedef {import('../types.js').Context} Context + */ + +/** + * @param {Parent} parent + * @param {Context} context + * @param {SafeOptions} safeOptions + * @returns {string} + */ +function containerPhrasing(parent, context, safeOptions) { + const children = parent.children || []; + /** @type {Array.} */ + const results = []; + let index = -1; + let before = safeOptions.before; + + while (++index < children.length) { + const child = children[index]; + /** @type {string} */ + let after; + + if (index + 1 < children.length) { + // @ts-expect-error: hush, it’s actually a `zwitch`. + let handle = context.handle.handlers[children[index + 1].type]; + if (handle && handle.peek) handle = handle.peek; + after = handle + ? handle(children[index + 1], parent, context, { + before: '', + after: '' + }).charAt(0) + : ''; + } else { + after = safeOptions.after; + } + + // In some cases, html (text) can be found in phrasing right after an eol. + // When we’d serialize that, in most cases that would be seen as html + // (flow). + // As we can’t escape or so to prevent it from happening, we take a somewhat + // reasonable approach: replace that eol with a space. + // See: + if ( + results.length > 0 && + (before === '\r' || before === '\n') && + child.type === 'html' + ) { + results[results.length - 1] = results[results.length - 1].replace( + /(\r?\n|\r)$/, + ' ' + ); + before = ' '; + } + + results.push(context.handle(child, parent, context, {before, after})); + + before = results[results.length - 1].slice(-1); + } + + return results.join('') +} + +/** + * @typedef {import('mdast').Emphasis} Emphasis + * @typedef {import('../types.js').Handle} Handle + */ + +emphasis.peek = emphasisPeek; + +// To do: there are cases where emphasis cannot “form” depending on the +// previous or next character of sequences. +// There’s no way around that though, except for injecting zero-width stuff. +// Do we need to safeguard against that? +/** + * @type {Handle} + * @param {Emphasis} node + */ +function emphasis(node, _, context) { + const marker = checkEmphasis(context); + const exit = context.enter('emphasis'); + const value = containerPhrasing(node, context, { + before: marker, + after: marker + }); + exit(); + return marker + value + marker +} + +/** + * @type {Handle} + * @param {Emphasis} _ + */ +function emphasisPeek(_, _1, context) { + return context.options.emphasis || '*' +} + +/** + * @typedef {import('mdast').Heading} Heading + * @typedef {import('../types.js').Context} Context + */ + +/** + * @param {Heading} node + * @param {Context} context + * @returns {boolean} + */ +function formatHeadingAsSetext(node, context) { + return Boolean( + context.options.setext && (!node.depth || node.depth < 3) && toString(node) + ) +} + +/** + * @typedef {import('mdast').Heading} Heading + * @typedef {import('../types.js').Handle} Handle + * @typedef {import('../types.js').Exit} Exit + */ + +/** + * @type {Handle} + * @param {Heading} node + */ +function heading(node, _, context) { + const rank = Math.max(Math.min(6, node.depth || 1), 1); + /** @type {Exit} */ + let exit; + /** @type {Exit} */ + let subexit; + /** @type {string} */ + let value; + + if (formatHeadingAsSetext(node, context)) { + exit = context.enter('headingSetext'); + subexit = context.enter('phrasing'); + value = containerPhrasing(node, context, {before: '\n', after: '\n'}); + subexit(); + exit(); + + return ( + value + + '\n' + + (rank === 1 ? '=' : '-').repeat( + // The whole size… + value.length - + // Minus the position of the character after the last EOL (or + // 0 if there is none)… + (Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1) + ) + ) + } + + const sequence = '#'.repeat(rank); + exit = context.enter('headingAtx'); + subexit = context.enter('phrasing'); + value = containerPhrasing(node, context, {before: '# ', after: '\n'}); + value = value ? sequence + ' ' + value : sequence; + if (context.options.closeAtx) { + value += ' ' + sequence; + } + + subexit(); + exit(); + + return value +} + +/** + * @typedef {import('mdast').HTML} HTML + * @typedef {import('../types.js').Handle} Handle + */ + +html.peek = htmlPeek; + +/** + * @type {Handle} + * @param {HTML} node + */ +function html(node) { + return node.value || '' +} + +/** + * @type {Handle} + */ +function htmlPeek() { + return '<' +} + +/** + * @typedef {import('mdast').Image} Image + * @typedef {import('../types.js').Handle} Handle + */ + +image.peek = imagePeek; + +/** + * @type {Handle} + * @param {Image} node + */ +function image(node, _, context) { + const quote = checkQuote(context); + const suffix = quote === '"' ? 'Quote' : 'Apostrophe'; + const exit = context.enter('image'); + let subexit = context.enter('label'); + let value = '![' + safe(context, node.alt, {before: '[', after: ']'}) + ']('; + + subexit(); + + if ( + // If there’s no url but there is a title… + (!node.url && node.title) || + // Or if there’s markdown whitespace or an eol, enclose. + /[ \t\r\n]/.test(node.url) + ) { + subexit = context.enter('destinationLiteral'); + value += '<' + safe(context, node.url, {before: '<', after: '>'}) + '>'; + } else { + // No whitespace, raw is prettier. + subexit = context.enter('destinationRaw'); + value += safe(context, node.url, { + before: '(', + after: node.title ? ' ' : ')' + }); + } + + subexit(); + + if (node.title) { + subexit = context.enter('title' + suffix); + value += + ' ' + + quote + + safe(context, node.title, {before: quote, after: quote}) + + quote; + subexit(); + } + + value += ')'; + exit(); + + return value +} + +/** + * @type {Handle} + */ +function imagePeek() { + return '!' +} + +/** + * @typedef {import('mdast').ImageReference} ImageReference + * @typedef {import('../types.js').Handle} Handle + */ + +imageReference.peek = imageReferencePeek; + +/** + * @type {Handle} + * @param {ImageReference} node + */ +function imageReference(node, _, context) { + const type = node.referenceType; + const exit = context.enter('imageReference'); + let subexit = context.enter('label'); + const alt = safe(context, node.alt, {before: '[', after: ']'}); + let value = '![' + alt + ']'; + + subexit(); + // Hide the fact that we’re in phrasing, because escapes don’t work. + const stack = context.stack; + context.stack = []; + subexit = context.enter('reference'); + const reference = safe(context, association(node), {before: '[', after: ']'}); + subexit(); + context.stack = stack; + exit(); + + if (type === 'full' || !alt || alt !== reference) { + value += '[' + reference + ']'; + } else if (type !== 'shortcut') { + value += '[]'; + } + + return value +} + +/** + * @type {Handle} + */ +function imageReferencePeek() { + return '!' +} + +/** + * @typedef {import('mdast').InlineCode} InlineCode + * @typedef {import('../types.js').Handle} Handle + */ + +inlineCode.peek = inlineCodePeek; + +/** + * @type {Handle} + * @param {InlineCode} node + */ +function inlineCode(node, _, context) { + let value = node.value || ''; + let sequence = '`'; + let index = -1; + + // If there is a single grave accent on its own in the code, use a fence of + // two. + // If there are two in a row, use one. + while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) { + sequence += '`'; + } + + // If this is not just spaces or eols (tabs don’t count), and either the + // first or last character are a space, eol, or tick, then pad with spaces. + if ( + /[^ \r\n]/.test(value) && + ((/^[ \r\n]/.test(value) && /[ \r\n]$/.test(value)) || /^`|`$/.test(value)) + ) { + value = ' ' + value + ' '; + } + + // We have a potential problem: certain characters after eols could result in + // blocks being seen. + // For example, if someone injected the string `'\n# b'`, then that would + // result in an ATX heading. + // We can’t escape characters in `inlineCode`, but because eols are + // transformed to spaces when going from markdown to HTML anyway, we can swap + // them out. + while (++index < context.unsafe.length) { + const pattern = context.unsafe[index]; + const expression = patternCompile(pattern); + /** @type {RegExpExecArray|null} */ + let match; + + // Only look for `atBreak`s. + // Btw: note that `atBreak` patterns will always start the regex at LF or + // CR. + if (!pattern.atBreak) continue + + while ((match = expression.exec(value))) { + let position = match.index; + + // Support CRLF (patterns only look for one of the characters). + if ( + value.charCodeAt(position) === 10 /* `\n` */ && + value.charCodeAt(position - 1) === 13 /* `\r` */ + ) { + position--; + } + + value = value.slice(0, position) + ' ' + value.slice(match.index + 1); + } + } + + return sequence + value + sequence +} + +/** + * @type {Handle} */ +function inlineCodePeek() { + return '`' +} -const remarkLintListItemIndent = lintRule( - 'remark-lint:list-item-indent', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file, option = 'tab-size') => { - const value = String(file); +/** + * @typedef {import('mdast').Link} Link + * @typedef {import('../types.js').Context} Context + */ - if (option !== 'tab-size' && option !== 'space' && option !== 'mixed') { - file.fail( - 'Incorrect list-item indent style `' + - option + - "`: use either `'tab-size'`, `'space'`, or `'mixed'`" - ); +/** + * @param {Link} node + * @param {Context} context + * @returns {boolean} + */ +function formatLinkAsAutolink(node, context) { + const raw = toString(node); + + return Boolean( + !context.options.resourceLink && + // If there’s a url… + node.url && + // And there’s a no title… + !node.title && + // And the content of `node` is a single text node… + node.children && + node.children.length === 1 && + node.children[0].type === 'text' && + // And if the url is the same as the content… + (raw === node.url || 'mailto:' + raw === node.url) && + // And that starts w/ a protocol… + /^[a-z][a-z+.-]+:/i.test(node.url) && + // And that doesn’t contain ASCII control codes (character escapes and + // references don’t work) or angle brackets… + !/[\0- <>\u007F]/.test(node.url) + ) +} + +/** + * @typedef {import('mdast').Link} Link + * @typedef {import('../types.js').Handle} Handle + * @typedef {import('../types.js').Exit} Exit + */ + +link.peek = linkPeek; + +/** + * @type {Handle} + * @param {Link} node + */ +function link(node, _, context) { + const quote = checkQuote(context); + const suffix = quote === '"' ? 'Quote' : 'Apostrophe'; + /** @type {Exit} */ + let exit; + /** @type {Exit} */ + let subexit; + /** @type {string} */ + let value; + + if (formatLinkAsAutolink(node, context)) { + // Hide the fact that we’re in phrasing, because escapes don’t work. + const stack = context.stack; + context.stack = []; + exit = context.enter('autolink'); + value = + '<' + containerPhrasing(node, context, {before: '<', after: '>'}) + '>'; + exit(); + context.stack = stack; + return value + } + + exit = context.enter('link'); + subexit = context.enter('label'); + value = + '[' + containerPhrasing(node, context, {before: '[', after: ']'}) + ']('; + subexit(); + + if ( + // If there’s no url but there is a title… + (!node.url && node.title) || + // Or if there’s markdown whitespace or an eol, enclose. + /[ \t\r\n]/.test(node.url) + ) { + subexit = context.enter('destinationLiteral'); + value += '<' + safe(context, node.url, {before: '<', after: '>'}) + '>'; + } else { + // No whitespace, raw is prettier. + subexit = context.enter('destinationRaw'); + value += safe(context, node.url, { + before: '(', + after: node.title ? ' ' : ')' + }); + } + + subexit(); + + if (node.title) { + subexit = context.enter('title' + suffix); + value += + ' ' + + quote + + safe(context, node.title, {before: quote, after: quote}) + + quote; + subexit(); + } + + value += ')'; + + exit(); + return value +} + +/** + * @type {Handle} + * @param {Link} node + */ +function linkPeek(node, _, context) { + return formatLinkAsAutolink(node, context) ? '<' : '[' +} + +/** + * @typedef {import('mdast').LinkReference} LinkReference + * @typedef {import('../types.js').Handle} Handle + */ + +linkReference.peek = linkReferencePeek; + +/** + * @type {Handle} + * @param {LinkReference} node + */ +function linkReference(node, _, context) { + const type = node.referenceType; + const exit = context.enter('linkReference'); + let subexit = context.enter('label'); + const text = containerPhrasing(node, context, {before: '[', after: ']'}); + let value = '[' + text + ']'; + + subexit(); + // Hide the fact that we’re in phrasing, because escapes don’t work. + const stack = context.stack; + context.stack = []; + subexit = context.enter('reference'); + const reference = safe(context, association(node), {before: '[', after: ']'}); + subexit(); + context.stack = stack; + exit(); + + if (type === 'full' || !text || text !== reference) { + value += '[' + reference + ']'; + } else if (type !== 'shortcut') { + value += '[]'; + } + + return value +} + +/** + * @type {Handle} + */ +function linkReferencePeek() { + return '[' +} + +/** + * @typedef {import('mdast').List} List + * @typedef {import('../types.js').Handle} Handle + */ + +/** + * @type {Handle} + * @param {List} node + */ +function list(node, _, context) { + const exit = context.enter('list'); + const value = containerFlow(node, context); + exit(); + return value +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').Options} Options + */ + +/** + * @param {Context} context + * @returns {Exclude} + */ +function checkBullet(context) { + const marker = context.options.bullet || '*'; + + if (marker !== '*' && marker !== '+' && marker !== '-') { + throw new Error( + 'Cannot serialize items with `' + + marker + + '` for `options.bullet`, expected `*`, `+`, or `-`' + ) + } + + return marker +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').Options} Options + */ + +/** + * @param {Context} context + * @returns {Exclude} + */ +function checkListItemIndent(context) { + const style = context.options.listItemIndent || 'tab'; + + // To do: remove in a major. + // @ts-expect-error: deprecated. + if (style === 1 || style === '1') { + return 'one' + } + + if (style !== 'tab' && style !== 'one' && style !== 'mixed') { + throw new Error( + 'Cannot serialize items with `' + + style + + '` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`' + ) + } + + return style +} + +/** + * @typedef {import('mdast').ListItem} ListItem + * @typedef {import('mdast').List} List + * @typedef {import('../util/indent-lines.js').Map} Map + * @typedef {import('../types.js').Options} Options + * @typedef {import('../types.js').Handle} Handle + */ + +/** + * @type {Handle} + * @param {ListItem} node + */ +function listItem(node, parent, context) { + const listItemIndent = checkListItemIndent(context); + /** @type {string} */ + let bullet = checkBullet(context); + + if (parent && parent.type === 'list' && parent.ordered) { + bullet = + (typeof parent.start === 'number' && parent.start > -1 + ? parent.start + : 1) + + (context.options.incrementListMarker === false + ? 0 + : parent.children.indexOf(node)) + + '.'; + } + + let size = bullet.length + 1; + + if ( + listItemIndent === 'tab' || + (listItemIndent === 'mixed' && + ((parent && 'spread' in parent && parent.spread) || node.spread)) + ) { + size = Math.ceil(size / 4) * 4; + } + + const exit = context.enter('listItem'); + const value = indentLines(containerFlow(node, context), map); + exit(); + + return value + + /** @type {Map} */ + function map(line, index, blank) { + if (index) { + return (blank ? '' : ' '.repeat(size)) + line } - visit$2(tree, 'list', (node) => { - if (generated(node)) return + return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line + } +} + +/** + * @typedef {import('mdast').Paragraph} Paragraph + * @typedef {import('../types.js').Handle} Handle + */ + +/** + * @type {Handle} + * @param {Paragraph} node + */ +function paragraph(node, _, context) { + const exit = context.enter('paragraph'); + const subexit = context.enter('phrasing'); + const value = containerPhrasing(node, context, {before: '\n', after: '\n'}); + subexit(); + exit(); + return value +} + +/** + * @typedef {import('mdast').Root} Root + * @typedef {import('../types.js').Handle} Handle + */ + +/** + * @type {Handle} + * @param {Root} node + */ +function root(node, _, context) { + return containerFlow(node, context) +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').Options} Options + */ + +/** + * @param {Context} context + * @returns {Exclude} + */ +function checkStrong(context) { + const marker = context.options.strong || '*'; + + if (marker !== '*' && marker !== '_') { + throw new Error( + 'Cannot serialize strong with `' + + marker + + '` for `options.strong`, expected `*`, or `_`' + ) + } + + return marker +} + +/** + * @typedef {import('mdast').Strong} Strong + * @typedef {import('../types.js').Handle} Handle + */ + +strong.peek = strongPeek; + +// To do: there are cases where emphasis cannot “form” depending on the +// previous or next character of sequences. +// There’s no way around that though, except for injecting zero-width stuff. +// Do we need to safeguard against that? +/** + * @type {Handle} + * @param {Strong} node + */ +function strong(node, _, context) { + const marker = checkStrong(context); + const exit = context.enter('strong'); + const value = containerPhrasing(node, context, { + before: marker, + after: marker + }); + exit(); + return marker + marker + value + marker + marker +} + +/** + * @type {Handle} + * @param {Strong} _ + */ +function strongPeek(_, _1, context) { + return context.options.strong || '*' +} + +/** + * @typedef {import('mdast').Text} Text + * @typedef {import('../types.js').Handle} Handle + */ + +/** + * @type {Handle} + * @param {Text} node + */ +function text$1(node, _, context, safeOptions) { + return safe(context, node.value, safeOptions) +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').Options} Options + */ + +/** + * @param {Context} context + * @returns {Exclude} + */ +function checkRuleRepetition(context) { + const repetition = context.options.ruleRepetition || 3; + + if (repetition < 3) { + throw new Error( + 'Cannot serialize rules with repetition `' + + repetition + + '` for `options.ruleRepetition`, expected `3` or more' + ) + } + + return repetition +} + +/** + * @typedef {import('../types.js').Context} Context + * @typedef {import('../types.js').Options} Options + */ + +/** + * @param {Context} context + * @returns {Exclude} + */ +function checkRule(context) { + const marker = context.options.rule || '*'; + + if (marker !== '*' && marker !== '-' && marker !== '_') { + throw new Error( + 'Cannot serialize rules with `' + + marker + + '` for `options.rule`, expected `*`, `-`, or `_`' + ) + } + + return marker +} + +/** + * @typedef {import('../types.js').Handle} Handle + * @typedef {import('mdast').ThematicBreak} ThematicBreak + */ + +/** + * @type {Handle} + * @param {ThematicBreak} _ + */ +function thematicBreak(_, _1, context) { + const value = ( + checkRule(context) + (context.options.ruleSpaces ? ' ' : '') + ).repeat(checkRuleRepetition(context)); + + return context.options.ruleSpaces ? value.slice(0, -1) : value +} + +const handle = { + blockquote, + break: hardBreak, + code: code$1, + definition, + emphasis, + hardBreak, + heading, + html, + image, + imageReference, + inlineCode, + link, + linkReference, + list, + listItem, + paragraph, + root, + strong, + text: text$1, + thematicBreak +}; + +/** + * @typedef {import('./types.js').Join} Join + */ + +/** @type {Array.} */ +const join = [joinDefaults]; + +/** @type {Join} */ +function joinDefaults(left, right, parent, context) { + if ( + // Two lists with the same marker. + (right.type === 'list' && + right.type === left.type && + Boolean(left.ordered) === Boolean(right.ordered)) || + // Indented code after list or another indented code. + (right.type === 'code' && + formatCodeAsIndented(right, context) && + (left.type === 'list' || + (left.type === right.type && formatCodeAsIndented(left, context)))) + ) { + return false + } + + // Join children of a list or an item. + // In which case, `parent` has a `spread` field. + if ('spread' in parent && typeof parent.spread === 'boolean') { + if ( + left.type === 'paragraph' && + // Two paragraphs. + (left.type === right.type || + right.type === 'definition' || + // Paragraph followed by a setext heading. + (right.type === 'heading' && formatHeadingAsSetext(right, context))) + ) { + return + } + + return parent.spread ? 1 : 0 + } +} + +/** + * @typedef {import('./types.js').Unsafe} Unsafe + */ + +/** @type {Array.} */ +const unsafe = [ + { + character: '\t', + inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde'] + }, + { + character: '\r', + inConstruct: [ + 'codeFencedLangGraveAccent', + 'codeFencedLangTilde', + 'codeFencedMetaGraveAccent', + 'codeFencedMetaTilde', + 'destinationLiteral', + 'headingAtx' + ] + }, + { + character: '\n', + inConstruct: [ + 'codeFencedLangGraveAccent', + 'codeFencedLangTilde', + 'codeFencedMetaGraveAccent', + 'codeFencedMetaTilde', + 'destinationLiteral', + 'headingAtx' + ] + }, + { + character: ' ', + inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde'] + }, + // An exclamation mark can start an image, if it is followed by a link or + // a link reference. + {character: '!', after: '\\[', inConstruct: 'phrasing'}, + // A quote can break out of a title. + {character: '"', inConstruct: 'titleQuote'}, + // A number sign could start an ATX heading if it starts a line. + {atBreak: true, character: '#'}, + {character: '#', inConstruct: 'headingAtx', after: '(?:[\r\n]|$)'}, + // Dollar sign and percentage are not used in markdown. + // An ampersand could start a character reference. + {character: '&', after: '[#A-Za-z]', inConstruct: 'phrasing'}, + // An apostrophe can break out of a title. + {character: "'", inConstruct: 'titleApostrophe'}, + // A left paren could break out of a destination raw. + {character: '(', inConstruct: 'destinationRaw'}, + {before: '\\]', character: '(', inConstruct: 'phrasing'}, + // A right paren could start a list item or break out of a destination + // raw. + {atBreak: true, before: '\\d+', character: ')'}, + {character: ')', inConstruct: 'destinationRaw'}, + // An asterisk can start thematic breaks, list items, emphasis, strong. + {atBreak: true, character: '*'}, + {character: '*', inConstruct: 'phrasing'}, + // A plus sign could start a list item. + {atBreak: true, character: '+'}, + // A dash can start thematic breaks, list items, and setext heading + // underlines. + {atBreak: true, character: '-'}, + // A dot could start a list item. + {atBreak: true, before: '\\d+', character: '.', after: '(?:[ \t\r\n]|$)'}, + // Slash, colon, and semicolon are not used in markdown for constructs. + // A less than can start html (flow or text) or an autolink. + // HTML could start with an exclamation mark (declaration, cdata, comment), + // slash (closing tag), question mark (instruction), or a letter (tag). + // An autolink also starts with a letter. + // Finally, it could break out of a destination literal. + {atBreak: true, character: '<', after: '[!/?A-Za-z]'}, + {character: '<', after: '[!/?A-Za-z]', inConstruct: 'phrasing'}, + {character: '<', inConstruct: 'destinationLiteral'}, + // An equals to can start setext heading underlines. + {atBreak: true, character: '='}, + // A greater than can start block quotes and it can break out of a + // destination literal. + {atBreak: true, character: '>'}, + {character: '>', inConstruct: 'destinationLiteral'}, + // Question mark and at sign are not used in markdown for constructs. + // A left bracket can start definitions, references, labels, + {atBreak: true, character: '['}, + {character: '[', inConstruct: ['phrasing', 'label', 'reference']}, + // A backslash can start an escape (when followed by punctuation) or a + // hard break (when followed by an eol). + // Note: typical escapes are handled in `safe`! + {character: '\\', after: '[\\r\\n]', inConstruct: 'phrasing'}, + // A right bracket can exit labels. + { + character: ']', + inConstruct: ['label', 'reference'] + }, + // Caret is not used in markdown for constructs. + // An underscore can start emphasis, strong, or a thematic break. + {atBreak: true, character: '_'}, + {before: '[^A-Za-z]', character: '_', inConstruct: 'phrasing'}, + {character: '_', after: '[^A-Za-z]', inConstruct: 'phrasing'}, + // A grave accent can start code (fenced or text), or it can break out of + // a grave accent code fence. + {atBreak: true, character: '`'}, + { + character: '`', + inConstruct: [ + 'codeFencedLangGraveAccent', + 'codeFencedMetaGraveAccent', + 'phrasing' + ] + }, + // Left brace, vertical bar, right brace are not used in markdown for + // constructs. + // A tilde can start code (fenced). + {atBreak: true, character: '~'} +]; - const spread = node.spread; - let index = -1; +/** + * @typedef {import('./types.js').Node} Node + * @typedef {import('./types.js').Options} Options + * @typedef {import('./types.js').Context} Context + * @typedef {import('./types.js').Handle} Handle + * @typedef {import('./types.js').Join} Join + * @typedef {import('./types.js').Unsafe} Unsafe + */ - while (++index < node.children.length) { - const item = node.children[index]; - const head = item.children[0]; - const final = pointStart(head); +/** + * @param {Node} tree + * @param {Options} [options] + * @returns {string} + */ +function toMarkdown(tree, options = {}) { + /** @type {Context} */ + // @ts-expect-error: we’ll add `handle` later. + const context = { + enter, + stack: [], + unsafe: [], + join: [], + handlers: {}, + options: {} + }; - const marker = value - .slice(pointStart(item).offset, final.offset) - .replace(/\[[x ]?]\s*$/i, ''); + configure(context, {unsafe, join, handlers: handle}); + configure(context, options); - const bulletSize = marker.replace(/\s+$/, '').length; + if (context.options.tightDefinitions) { + configure(context, {join: [joinDefinition]}); + } - const style = - option === 'tab-size' || (option === 'mixed' && spread) - ? Math.ceil(bulletSize / 4) * 4 - : bulletSize + 1; + /** @type {Handle} */ + context.handle = zwitch('type', { + invalid, + // @ts-expect-error: hush. + unknown, + // @ts-expect-error: hush. + handlers: context.handlers + }); - if (marker.length !== style) { - const diff = style - marker.length; - const abs = Math.abs(diff); + let result = context.handle(tree, null, context, {before: '\n', after: '\n'}); - file.message( - 'Incorrect list-item indent: ' + - (diff > 0 ? 'add' : 'remove') + - ' ' + - abs + - ' ' + - plural('space', abs), - final - ); - } - } - }); + if ( + result && + result.charCodeAt(result.length - 1) !== 10 && + result.charCodeAt(result.length - 1) !== 13 + ) { + result += '\n'; } -); -var remarkLintListItemIndent$1 = remarkLintListItemIndent; + return result -/** - * @typedef Options - * @property {boolean} [includeImageAlt=true] - */ + /** @type {Context['enter']} */ + function enter(name) { + context.stack.push(name); + return exit -/** - * Get the text content of a node. - * Prefer the node’s plain-text fields, otherwise serialize its children, - * and if the given value is an array, serialize the nodes in it. - * - * @param {unknown} node - * @param {Options} [options] - * @returns {string} - */ -function toString(node, options) { - var {includeImageAlt = true} = options || {}; - return one(node, includeImageAlt) + function exit() { + context.stack.pop(); + } + } } /** - * @param {unknown} node - * @param {boolean} includeImageAlt - * @returns {string} + * @type {Handle} + * @param {unknown} value */ -function one(node, includeImageAlt) { - return ( - (node && - typeof node === 'object' && - // @ts-ignore looks like a literal. - (node.value || - // @ts-ignore looks like an image. - (includeImageAlt ? node.alt : '') || - // @ts-ignore looks like a parent. - ('children' in node && all(node.children, includeImageAlt)) || - (Array.isArray(node) && all(node, includeImageAlt)))) || - '' - ) +function invalid(value) { + throw new Error('Cannot handle value `' + value + '`, expected node') } /** - * @param {Array.} values - * @param {boolean} includeImageAlt - * @returns {string} + * @type {Handle} + * @param {Node} node */ -function all(values, includeImageAlt) { - /** @type {Array.} */ - var result = []; - var index = -1; - - while (++index < values.length) { - result[index] = one(values[index], includeImageAlt); - } - - return result.join('') +function unknown(node) { + throw new Error('Cannot handle unknown node `' + node.type + '`') } -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module no-auto-link-without-protocol - * @fileoverview - * Warn for autolinks without protocol. - * Autolinks are URLs enclosed in `<` (less than) and `>` (greater than) - * characters. - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * adds a protocol where needed. - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * @example - * {"name": "ok.md"} - * - * - * - * - * Most Markdown vendors don’t recognize the following as a link: - * - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * - * - * @example - * {"name": "not-ok.md", "label": "output"} - * - * 1:1-1:14: All automatic links must start with a protocol - */ - -// Protocol expression. -// See: . -const protocol = /^[a-z][a-z+.-]+:\/?/i; - -const remarkLintNoAutoLinkWithoutProtocol = lintRule( - 'remark-lint:no-auto-link-without-protocol', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - visit$2(tree, 'link', (node) => { - if ( - !generated(node) && - pointStart(node).column === pointStart(node.children[0]).column - 1 && - pointEnd(node).column === - pointEnd(node.children[node.children.length - 1]).column + 1 && - !protocol.test(toString(node)) - ) { - file.message('All automatic links must start with a protocol', node); - } - }); +/** @type {Join} */ +function joinDefinition(left, right) { + // No blank line between adjacent definitions. + if (left.type === 'definition' && left.type === right.type) { + return 0 } -); - -var remarkLintNoAutoLinkWithoutProtocol$1 = remarkLintNoAutoLinkWithoutProtocol; +} /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module no-blockquote-without-marker - * @fileoverview - * Warn when blank lines without `>` (greater than) markers are found in a - * block quote. - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * adds markers to every line in a block quote. - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * @example - * {"name": "ok.md"} - * - * > Foo… - * > …bar… - * > …baz. - * - * @example - * {"name": "ok-tabs.md"} - * - * >»Foo… - * >»…bar… - * >»…baz. - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * > Foo… - * …bar… - * > …baz. - * - * @example - * {"name": "not-ok.md", "label": "output"} - * - * 2:1: Missing marker in block quote - * - * @example - * {"name": "not-ok-tabs.md", "label": "input"} - * - * >»Foo… - * »…bar… - * …baz. - * - * @example - * {"name": "not-ok-tabs.md", "label": "output"} - * - * 2:1: Missing marker in block quote - * 3:1: Missing marker in block quote + * @typedef {import('mdast').Root|import('mdast').Content} Node + * @typedef {import('mdast-util-to-markdown').Options} Options */ -const remarkLintNoBlockquoteWithoutMarker = lintRule( - 'remark-lint:no-blockquote-without-marker', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - const value = String(file); - const loc = location(file); - - visit$2(tree, 'blockquote', (node) => { - let index = -1; - - while (++index < node.children.length) { - const child = node.children[index]; - - if (child.type === 'paragraph' && !generated(child)) { - const end = pointEnd(child).line; - const column = pointStart(child).column; - let line = pointStart(child).line; - - // Skip past the first line. - while (++line <= end) { - const offset = loc.toOffset({line, column}); - - if (/>[\t ]+$/.test(value.slice(offset - 5, offset))) { - continue - } - - // Roughly here. - file.message('Missing marker in block quote', { - line, - column: column - 2 - }); - } - } - } - }); - } -); - -var remarkLintNoBlockquoteWithoutMarker$1 = remarkLintNoBlockquoteWithoutMarker; +/** @type {import('unified').Plugin<[Options]|void[], Node, string>} */ +function remarkStringify(options) { + /** @type {import('unified').CompilerFunction} */ + const compiler = (tree) => { + // Assume options. + const settings = /** @type {Options} */ (this.data('settings')); -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module no-literal-urls - * @fileoverview - * Warn for literal URLs in text. - * URLs are treated as links in some Markdown vendors, but not in others. - * To make sure they are always linked, wrap them in `<` (less than) and `>` - * (greater than). - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * never creates literal URLs and always uses `<` (less than) and `>` - * (greater than). - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * @example - * {"name": "ok.md"} - * - * - * - * @example - * {"name": "not-ok.md", "label": "input", "gfm": true} - * - * http://foo.bar/baz - * - * @example - * {"name": "not-ok.md", "label": "output", "gfm": true} - * - * 1:1-1:19: Don’t use literal URLs without angle brackets - */ + return toMarkdown( + tree, + Object.assign({}, settings, options, { + // Note: this option is not in the readme. + // The goal is for it to be set by plugins on `data` instead of being + // passed by users. + extensions: this.data('toMarkdownExtensions') || [] + }) + ) + }; -const remarkLintNoLiteralUrls = lintRule( - 'remark-lint:no-literal-urls', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - visit$2(tree, 'link', (node) => { - const value = toString(node); + Object.assign(this, {Compiler: compiler}); +} - if ( - !generated(node) && - pointStart(node).column === pointStart(node.children[0]).column && - pointEnd(node).column === - pointEnd(node.children[node.children.length - 1]).column && - (node.url === 'mailto:' + value || node.url === value) - ) { - file.message('Don’t use literal URLs without angle brackets', node); - } - }); - } -); +const remark = unified().use(remarkParse).use(remarkStringify).freeze(); -var remarkLintNoLiteralUrls$1 = remarkLintNoLiteralUrls; +const name$1 = "remark"; +const version$1 = "14.0.1"; +const description$1 = "Markdown processor powered by plugins part of the unified collective"; +const license = "MIT"; +const keywords = [ + "unified", + "remark", + "markdown", + "mdast", + "abstract", + "syntax", + "tree", + "ast", + "parse", + "stringify", + "serialize", + "compile", + "process" +]; +const homepage = "https://remark.js.org"; +const repository = "https://github.com/remarkjs/remark/tree/main/packages/remark"; +const bugs = "https://github.com/remarkjs/remark/issues"; +const funding = { + type: "opencollective", + url: "https://opencollective.com/unified" +}; +const author = "Titus Wormer (https://wooorm.com)"; +const contributors = [ + "Titus Wormer (https://wooorm.com)" +]; +const sideEffects = false; +const type = "module"; +const main$1 = "index.js"; +const types = "index.d.ts"; +const files = [ + "index.d.ts", + "index.js" +]; +const dependencies$1 = { + "@types/mdast": "^3.0.0", + "remark-parse": "^10.0.0", + "remark-stringify": "^10.0.0", + unified: "^10.0.0" +}; +const scripts$1 = { + test: "node --conditions development test.js", + build: "rimraf \"*.d.ts\" && tsc && type-coverage" +}; +const xo = false; +const typeCoverage = { + atLeast: 100, + detail: true, + strict: true, + ignoreCatch: true +}; +var proc = { + name: name$1, + version: version$1, + description: description$1, + license: license, + keywords: keywords, + homepage: homepage, + repository: repository, + bugs: bugs, + funding: funding, + author: author, + contributors: contributors, + sideEffects: sideEffects, + type: type, + main: main$1, + types: types, + files: files, + dependencies: dependencies$1, + scripts: scripts$1, + xo: xo, + typeCoverage: typeCoverage +}; -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module ordered-list-marker-style - * @fileoverview - * Warn when the list item marker style of ordered lists violate a given style. - * - * Options: `'consistent'`, `'.'`, or `')'`, default: `'consistent'`. - * - * `'consistent'` detects the first used list style and warns when subsequent - * lists use different styles. - * - * @example - * {"name": "ok.md"} - * - * 1. Foo - * - * - * 1. Bar - * - * Unordered lists are not affected by this rule. - * - * * Foo - * - * @example - * {"name": "ok.md", "setting": "."} - * - * 1. Foo - * - * 2. Bar - * - * @example - * {"name": "ok.md", "setting": ")"} - * - * 1) Foo - * - * 2) Bar - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * 1. Foo - * - * 2) Bar - * - * @example - * {"name": "not-ok.md", "label": "output"} - * - * 3:1-3:8: Marker style should be `.` - * - * @example - * {"name": "not-ok.md", "label": "output", "setting": "💩", "positionless": true} +const name = "node-lint-md-cli-rollup"; +const description = "remark packaged for Node.js Markdown linting"; +const version = "2.0.2"; +const devDependencies = { + "@rollup/plugin-commonjs": "^20.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.0.4", + rollup: "^2.52.7", + shx: "^0.3.3" +}; +const dependencies = { + "markdown-extensions": "^1.1.1", + remark: "^14.0.0", + "remark-gfm": "^2.0.0", + "remark-preset-lint-node": "^3.0.0", + "unified-args": "^9.0.0" +}; +const main = "dist/index.js"; +const scripts = { + build: "npx rollup -c", + "build-node": "npm run build && npx shx cp dist/index.js ../lint-md.js" +}; +var cli = { + name: name, + description: description, + version: version, + devDependencies: devDependencies, + dependencies: dependencies, + main: main, + scripts: scripts +}; + +/** + * @typedef {import('unist').Point} Point + * @typedef {import('vfile').VFile} VFile * - * 1:1: Incorrect ordered list item marker style `💩`: use either `'.'` or `')'` + * @typedef {Pick} PositionalPoint + * @typedef {Required} FullPoint + * @typedef {NonNullable} Offset */ -const remarkLintOrderedListMarkerStyle = lintRule( - 'remark-lint:ordered-list-marker-style', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file, option = 'consistent') => { - const value = String(file); - - if (option !== 'consistent' && option !== '.' && option !== ')') { - file.fail( - 'Incorrect ordered list item marker style `' + - option + - "`: use either `'.'` or `')'`" - ); - } +/** + * Get transform functions for the given `document`. + * + * @param {string|Uint8Array|VFile} file + */ +function location(file) { + var value = String(file); + /** @type {Array.} */ + var indices = []; + var search = /\r?\n|\r/g; - visit$2(tree, 'list', (node) => { - let index = -1; + while (search.test(value)) { + indices.push(search.lastIndex); + } - if (!node.ordered) return + indices.push(value.length + 1); - while (++index < node.children.length) { - const child = node.children[index]; + return {toPoint, toOffset} - if (!generated(child)) { - const marker = /** @type {Marker} */ ( - value - .slice( - pointStart(child).offset, - pointStart(child.children[0]).offset - ) - .replace(/\s|\d/g, '') - .replace(/\[[x ]?]\s*$/i, '') - ); + /** + * Get the line and column-based `point` for `offset` in the bound indices. + * Returns a point with `undefined` values when given invalid or out of bounds + * input. + * + * @param {Offset} offset + * @returns {FullPoint} + */ + function toPoint(offset) { + var index = -1; - if (option === 'consistent') { - option = marker; - } else if (marker !== option) { - file.message('Marker style should be `' + option + '`', child); + if (offset > -1 && offset < indices[indices.length - 1]) { + while (++index < indices.length) { + if (indices[index] > offset) { + return { + line: index + 1, + column: offset - (indices[index - 1] || 0) + 1, + offset } } } - }); + } + + return {line: undefined, column: undefined, offset: undefined} } -); -var remarkLintOrderedListMarkerStyle$1 = remarkLintOrderedListMarkerStyle; + /** + * Get the `offset` for a line and column-based `point` in the bound indices. + * Returns `-1` when given invalid or out of bounds input. + * + * @param {PositionalPoint} point + * @returns {Offset} + */ + function toOffset(point) { + var line = point && point.line; + var column = point && point.column; + /** @type {number} */ + var offset; + + if ( + typeof line === 'number' && + typeof column === 'number' && + !Number.isNaN(line) && + !Number.isNaN(column) && + line - 1 in indices + ) { + offset = (indices[line - 2] || 0) + column - 1 || 0; + } + + return offset > -1 && offset < indices[indices.length - 1] ? offset : -1 + } +} /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module hard-break-spaces - * @fileoverview - * Warn when too many spaces are used to create a hard break. - * - * @example - * {"name": "ok.md"} - * - * Lorem ipsum·· - * dolor sit amet - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * Lorem ipsum··· - * dolor sit amet. + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Parent} Parent * - * @example - * {"name": "not-ok.md", "label": "output"} + * @typedef {string} Type + * @typedef {Object} Props * - * 1:12-2:1: Use two spaces for hard line breaks + * @typedef {null|undefined|Type|Props|TestFunctionAnything|Array.} Test */ -const remarkLintHardBreakSpaces = lintRule( - 'remark-lint:hard-break-spaces', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - const value = String(file); - - visit$2(tree, 'break', (node) => { - if (!generated(node)) { - const slice = value - .slice(pointStart(node).offset, pointEnd(node).offset) - .split('\n', 1)[0] - .replace(/\r$/, ''); +const convert = + /** + * @type {( + * ((test: T['type']|Partial|TestFunctionPredicate) => AssertPredicate) & + * ((test?: Test) => AssertAnything) + * )} + */ + ( + /** + * Generate an assertion from a check. + * @param {Test} [test] + * When nullish, checks if `node` is a `Node`. + * When `string`, works like passing `function (node) {return node.type === test}`. + * When `function` checks if function passed the node is true. + * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values. + * When `array`, checks any one of the subtests pass. + * @returns {AssertAnything} + */ + function (test) { + if (test === undefined || test === null) { + return ok + } - if (slice.length > 2) { - file.message('Use two spaces for hard line breaks', node); - } + if (typeof test === 'string') { + return typeFactory(test) } - }); - } -); -var remarkLintHardBreakSpaces$1 = remarkLintHardBreakSpaces; + if (typeof test === 'object') { + return Array.isArray(test) ? anyFactory(test) : propsFactory(test) + } -var own$3 = {}.hasOwnProperty; + if (typeof test === 'function') { + return castFactory(test) + } + throw new Error('Expected function, string, or object as test') + } + ); /** - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Position} Position - * @typedef {import('unist').Point} Point + * @param {Array.} tests + * @returns {AssertAnything} */ +function anyFactory(tests) { + /** @type {Array.} */ + const checks = []; + let index = -1; -/** - * Stringify one point, a position (start and end points), or a node’s - * positional information. - * - * @param {Node|Position|Point} [value] - * @returns {string} - */ -function stringifyPosition$1(value) { - // Nothing. - if (!value || typeof value !== 'object') { - return '' + while (++index < tests.length) { + checks[index] = convert(tests[index]); } - // Node. - if (own$3.call(value, 'position') || own$3.call(value, 'type')) { - // @ts-ignore looks like a node. - return position$3(value.position) - } + return castFactory(any) - // Position. - if (own$3.call(value, 'start') || own$3.call(value, 'end')) { - // @ts-ignore looks like a position. - return position$3(value) - } + /** + * @this {unknown} + * @param {unknown[]} parameters + * @returns {boolean} + */ + function any(...parameters) { + let index = -1; - // Point. - if (own$3.call(value, 'line') || own$3.call(value, 'column')) { - // @ts-ignore looks like a point. - return point$1(value) - } + while (++index < checks.length) { + if (checks[index].call(this, ...parameters)) return true + } - // ? - return '' + return false + } } /** - * @param {Point} point - * @returns {string} + * Utility to assert each property in `test` is represented in `node`, and each + * values are strictly equal. + * + * @param {Props} check + * @returns {AssertAnything} */ -function point$1(point) { - return index$1(point && point.line) + ':' + index$1(point && point.column) -} +function propsFactory(check) { + return castFactory(all) -/** - * @param {Position} pos - * @returns {string} - */ -function position$3(pos) { - return point$1(pos && pos.start) + '-' + point$1(pos && pos.end) -} + /** + * @param {Node} node + * @returns {boolean} + */ + function all(node) { + /** @type {string} */ + let key; -/** - * @param {number} value - * @returns {number} - */ -function index$1(value) { - return value && typeof value === 'number' ? value : 1 + for (key in check) { + // @ts-expect-error: hush, it sure works as an index. + if (node[key] !== check[key]) return false + } + + return true + } } /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module no-duplicate-definitions - * @fileoverview - * Warn when duplicate definitions are found. - * - * @example - * {"name": "ok.md"} - * - * [foo]: bar - * [baz]: qux - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * [foo]: bar - * [foo]: qux - * - * @example - * {"name": "not-ok.md", "label": "output"} + * Utility to convert a string into a function which checks a given node’s type + * for said string. * - * 2:1-2:11: Do not use definitions with the same identifier (1:1) + * @param {Type} check + * @returns {AssertAnything} */ +function typeFactory(check) { + return castFactory(type) -const remarkLintNoDuplicateDefinitions = lintRule( - 'remark-lint:no-duplicate-definitions', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - /** @type {Record} */ - const map = Object.create(null); - - visit$2(tree, (node) => { - if ( - (node.type === 'definition' || node.type === 'footnoteDefinition') && - !generated(node) - ) { - const identifier = node.identifier; - const duplicate = map[identifier]; - - if (duplicate) { - file.message( - 'Do not use definitions with the same identifier (' + - duplicate + - ')', - node - ); - } - - map[identifier] = stringifyPosition$1(pointStart(node)); - } - }); + /** + * @param {Node} node + */ + function type(node) { + return node && node.type === check } -); - -var remarkLintNoDuplicateDefinitions$1 = remarkLintNoDuplicateDefinitions; - -/** - * @typedef {import('mdast').Heading} Heading - * @typedef {'atx'|'atx-closed'|'setext'} Style - */ +} /** - * @param {Heading} node - * @param {Style} [relative] - * @returns {Style|null} + * Utility to convert a string into a function which checks a given node’s type + * for said string. + * @param {TestFunctionAnything} check + * @returns {AssertAnything} */ -function headingStyle(node, relative) { - var last = node.children[node.children.length - 1]; - var depth = node.depth; - var pos = node && node.position && node.position.end; - var final = last && last.position && last.position.end; - - if (!pos) { - return null - } - - // This can only occur for `'atx'` and `'atx-closed'` headings. - // This might incorrectly match `'atx'` headings with lots of trailing white - // space as an `'atx-closed'` heading. - if (!last) { - if (pos.column - 1 <= depth * 2) { - return consolidate(depth, relative) - } - - return 'atx-closed' - } - - if (final.line + 1 === pos.line) { - return 'setext' - } +function castFactory(check) { + return assertion - if (final.column + depth < pos.column) { - return 'atx-closed' + /** + * @this {unknown} + * @param {Array.} parameters + * @returns {boolean} + */ + function assertion(...parameters) { + // @ts-expect-error: spreading is fine. + return Boolean(check.call(this, ...parameters)) } +} - return consolidate(depth, relative) +// Utility to return true. +function ok() { + return true } /** - * Get the probable style of an atx-heading, depending on preferred style. - * - * @param {number} depth - * @param {Style} relative - * @returns {Style|null} + * @param {string} d + * @returns {string} */ -function consolidate(depth, relative) { - return depth < 3 - ? 'atx' - : relative === 'atx' || relative === 'setext' - ? relative - : null +function color$2(d) { + return '\u001B[33m' + d + '\u001B[39m' } /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module no-heading-content-indent - * @fileoverview - * Warn when content of headings is indented. - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * removes all unneeded padding around content in headings. - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * @example - * {"name": "ok.md"} - * - * #·Foo - * - * ## Bar·## - * - * ##·Baz - * - * Setext headings are not affected. - * - * Baz - * === - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * #··Foo - * - * ## Bar··## - * - * ##··Baz - * - * @example - * {"name": "not-ok.md", "label": "output"} - * - * 1:4: Remove 1 space before this heading’s content - * 3:7: Remove 1 space after this heading’s content - * 5:7: Remove 1 space before this heading’s content - * - * @example - * {"name": "empty-heading.md"} - * - * #·· + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Parent} Parent + * @typedef {import('unist-util-is').Test} Test */ -const remarkLintNoHeadingContentIndent = lintRule( - 'remark-lint:no-heading-content-indent', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - visit$2(tree, 'heading', (node) => { - if (generated(node)) { - return +/** + * Continue traversing as normal + */ +const CONTINUE$2 = true; +/** + * Do not traverse this node’s children + */ +const SKIP$2 = 'skip'; +/** + * Stop traversing immediately + */ +const EXIT$2 = false; + +const visitParents$2 = + /** + * @type {( + * ((tree: Node, test: T['type']|Partial|import('unist-util-is').TestFunctionPredicate|Array.|import('unist-util-is').TestFunctionPredicate>, visitor: Visitor, reverse?: boolean) => void) & + * ((tree: Node, test: Test, visitor: Visitor, reverse?: boolean) => void) & + * ((tree: Node, visitor: Visitor, reverse?: boolean) => void) + * )} + */ + ( + /** + * Visit children of tree which pass a test + * + * @param {Node} tree Abstract syntax tree to walk + * @param {Test} test test Test node + * @param {Visitor} visitor Function to run for each node + * @param {boolean} [reverse] Fisit the tree in reverse, defaults to false + */ + function (tree, test, visitor, reverse) { + if (typeof test === 'function' && typeof visitor !== 'function') { + reverse = visitor; + // @ts-ignore no visitor given, so `visitor` is test. + visitor = test; + test = null; } - const type = headingStyle(node, 'atx'); + var is = convert(test); + var step = reverse ? -1 : 1; - if (type === 'atx' || type === 'atx-closed') { - const head = pointStart(node.children[0]).column; + factory(tree, null, [])(); + + /** + * @param {Node} node + * @param {number?} index + * @param {Array.} parents + */ + function factory(node, index, parents) { + /** @type {Object.} */ + var value = typeof node === 'object' && node !== null ? node : {}; + /** @type {string} */ + var name; + + if (typeof value.type === 'string') { + name = + typeof value.tagName === 'string' + ? value.tagName + : typeof value.name === 'string' + ? value.name + : undefined; - // Ignore empty headings. - if (!head) { - return + Object.defineProperty(visit, 'name', { + value: + 'node (' + + color$2(value.type + (name ? '<' + name + '>' : '')) + + ')' + }); } - const diff = head - pointStart(node).column - 1 - node.depth; + return visit - if (diff) { - file.message( - 'Remove ' + - Math.abs(diff) + - ' ' + - plural('space', Math.abs(diff)) + - ' before this heading’s content', - pointStart(node.children[0]) - ); - } - } + function visit() { + /** @type {ActionTuple} */ + var result = []; + /** @type {ActionTuple} */ + var subresult; + /** @type {number} */ + var offset; + /** @type {Array.} */ + var grandparents; - // Closed ATX headings always must have a space between their content and - // the final hashes, thus, there is no `add x spaces`. - if (type === 'atx-closed') { - const final = pointEnd(node.children[node.children.length - 1]); - const diff = pointEnd(node).column - final.column - 1 - node.depth; + if (!test || is(node, index, parents[parents.length - 1] || null)) { + result = toResult$2(visitor(node, parents)); - if (diff) { - file.message( - 'Remove ' + - diff + - ' ' + - plural('space', diff) + - ' after this heading’s content', - final - ); - } - } - }); - } -); + if (result[0] === EXIT$2) { + return result + } + } -var remarkLintNoHeadingContentIndent$1 = remarkLintNoHeadingContentIndent; + if (node.children && result[0] !== SKIP$2) { + // @ts-ignore looks like a parent. + offset = (reverse ? node.children.length : -1) + step; + // @ts-ignore looks like a parent. + grandparents = parents.concat(node); -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module no-inline-padding - * @fileoverview - * Warn when phrasing content is padded with spaces between their markers and - * content. - * - * Warns for emphasis, strong, delete, image, and link. - * - * @example - * {"name": "ok.md"} - * - * Alpha [bravo](http://echo.fox/trot) - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * Alpha [ bravo ](http://echo.fox/trot) - * - * @example - * {"name": "not-ok.md", "label": "output"} - * - * 1:7-1:38: Don’t pad `link` with inner spaces - */ + // @ts-ignore looks like a parent. + while (offset > -1 && offset < node.children.length) { + subresult = factory(node.children[offset], offset, grandparents)(); -const remarkLintNoInlinePadding = lintRule( - 'remark-lint:no-inline-padding', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - // Note: `emphasis`, `strong`, `delete` (GFM) can’t have padding anymore - // since CM. - visit$2(tree, (node) => { - if ( - (node.type === 'link' || node.type === 'linkReference') && - !generated(node) - ) { - const value = toString(node); + if (subresult[0] === EXIT$2) { + return subresult + } - if (value.charAt(0) === ' ' || value.charAt(value.length - 1) === ' ') { - file.message('Don’t pad `' + node.type + '` with inner spaces', node); + offset = + typeof subresult[1] === 'number' ? subresult[1] : offset + step; + } + } + + return result } } - }); - } -); - -var remarkLintNoInlinePadding$1 = remarkLintNoInlinePadding; + } + ); /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module no-shortcut-reference-image - * @fileoverview - * Warn when shortcut reference images are used. - * - * Shortcut references render as images when a definition is found, and as - * plain text without definition. - * Sometimes, you don’t intend to create an image from the reference, but this - * rule still warns anyway. - * In that case, you can escape the reference like so: `!\[foo]`. - * - * @example - * {"name": "ok.md"} - * - * ![foo][] - * - * [foo]: http://foo.bar/baz.png - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * ![foo] - * - * [foo]: http://foo.bar/baz.png - * - * @example - * {"name": "not-ok.md", "label": "output"} - * - * 1:1-1:7: Use the trailing [] on reference images + * @param {VisitorResult} value + * @returns {ActionTuple} */ +function toResult$2(value) { + if (Array.isArray(value)) { + return value + } -const remarkLintNoShortcutReferenceImage = lintRule( - 'remark-lint:no-shortcut-reference-image', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - visit$2(tree, 'imageReference', (node) => { - if (!generated(node) && node.referenceType === 'shortcut') { - file.message('Use the trailing [] on reference images', node); - } - }); + if (typeof value === 'number') { + return [CONTINUE$2, value] } -); -var remarkLintNoShortcutReferenceImage$1 = remarkLintNoShortcutReferenceImage; + return [value] +} /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module no-shortcut-reference-link - * @fileoverview - * Warn when shortcut reference links are used. - * - * Shortcut references render as links when a definition is found, and as - * plain text without definition. - * Sometimes, you don’t intend to create a link from the reference, but this - * rule still warns anyway. - * In that case, you can escape the reference like so: `\[foo]`. - * - * @example - * {"name": "ok.md"} - * - * [foo][] - * - * [foo]: http://foo.bar/baz - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * [foo] - * - * [foo]: http://foo.bar/baz - * - * @example - * {"name": "not-ok.md", "label": "output"} - * - * 1:1-1:6: Use the trailing `[]` on reference links + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Parent} Parent + * @typedef {import('unist-util-is').Test} Test + * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult */ -const remarkLintNoShortcutReferenceLink = lintRule( - 'remark-lint:no-shortcut-reference-link', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - visit$2(tree, 'linkReference', (node) => { - if (!generated(node) && node.referenceType === 'shortcut') { - file.message('Use the trailing `[]` on reference links', node); +const visit$1 = + /** + * @type {( + * ((tree: Node, test: T['type']|Partial|import('unist-util-is').TestFunctionPredicate|Array.|import('unist-util-is').TestFunctionPredicate>, visitor: Visitor, reverse?: boolean) => void) & + * ((tree: Node, test: Test, visitor: Visitor, reverse?: boolean) => void) & + * ((tree: Node, visitor: Visitor, reverse?: boolean) => void) + * )} + */ + ( + /** + * Visit children of tree which pass a test + * + * @param {Node} tree Abstract syntax tree to walk + * @param {Test} test test Test node + * @param {Visitor} visitor Function to run for each node + * @param {boolean} [reverse] Fisit the tree in reverse, defaults to false + */ + function (tree, test, visitor, reverse) { + if (typeof test === 'function' && typeof visitor !== 'function') { + reverse = visitor; + visitor = test; + test = null; } - }); - } -); -var remarkLintNoShortcutReferenceLink$1 = remarkLintNoShortcutReferenceLink; + visitParents$2(tree, test, overload, reverse); -/** - * Normalize an identifier (such as used in definitions). - * - * @param {string} value - * @returns {string} - */ -function normalizeIdentifier(value) { - return ( - value // Collapse Markdown whitespace. - .replace(/[\t\n\r ]+/g, ' ') // Trim. - .replace(/^ | $/g, '') // Some characters are considered “uppercase”, but if their lowercase - // counterpart is uppercased will result in a different uppercase - // character. - // Hence, to get that form, we perform both lower- and uppercase. - // Upper case makes sure keys will not interact with default prototypal - // methods: no method is uppercase. - .toLowerCase() - .toUpperCase() - ) -} + /** + * @param {Node} node + * @param {Array.} parents + */ + function overload(node, parents) { + var parent = parents[parents.length - 1]; + return visitor( + node, + parent ? parent.children.indexOf(node) : null, + parent + ) + } + } + ); /** - * @author Titus Wormer - * @copyright 2016 Titus Wormer - * @license MIT - * @module no-undefined-references - * @fileoverview - * Warn when references to undefined definitions are found. - * - * Options: `Object`, optional. - * - * The object can have an `allow` field, set to an array of strings that may - * appear between `[` and `]`, but that should not be treated as link - * identifiers. - * - * @example - * {"name": "ok.md"} - * - * [foo][] - * - * Just a [ bracket. - * - * Typically, you’d want to use escapes (with a backslash: \\) to escape what - * could turn into a \[reference otherwise]. - * - * Just two braces can’t link: []. - * - * [foo]: https://example.com - * - * @example - * {"name": "ok-allow.md", "setting": {"allow": ["...", "…"]}} - * - * > Eliding a portion of a quoted passage […] is acceptable. + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Parent} Parent + * @typedef {import('unist').Point} Point + * @typedef {import('unist-util-is').Test} Test + * @typedef {import('vfile').VFile} VFile + * @typedef {import('vfile-message').VFileMessage} VFileMessage * - * @example - * {"name": "not-ok.md", "label": "input"} + * @typedef {OptionsWithoutReset|OptionsWithReset} Options + * @typedef {OptionsBaseFields & OptionsWithoutResetFields} OptionsWithoutReset + * @typedef {OptionsBaseFields & OptionsWithResetFields} OptionsWithReset * - * [bar] + * @typedef OptionsWithoutResetFields + * @property {false} [reset] + * Whether to treat all messages as turned off initially. + * @property {string[]} [disable] + * List of `ruleId`s to turn off. * - * [baz][] + * @typedef OptionsWithResetFields + * @property {true} reset + * Whether to treat all messages as turned off initially. + * @property {string[]} [enable] + * List of `ruleId`s to initially turn on. * - * [text][qux] + * @typedef OptionsBaseFields + * @property {string} name + * Name of markers that can control the message sources. * - * Spread [over - * lines][] + * For example, `{name: 'alpha'}` controls `alpha` markers: * - * > in [a - * > block quote][] + * ```html + * + * ``` + * @property {MarkerParser} marker + * Parse a possible marker to a comment marker object (Marker). + * If the marker isn't a marker, should return `null`. + * @property {Test} [test] + * Test for possible markers + * @property {string[]} [known] + * List of allowed `ruleId`s. When given a warning is shown + * when someone tries to control an unknown rule. * - * [asd][a + * For example, `{name: 'alpha', known: ['bravo']}` results in a warning if + * `charlie` is configured: * - * Can include [*emphasis*]. + * ```html + * + * ``` + * @property {string|string[]} [source] + * Sources that can be controlled with `name` markers. + * Defaults to `name`. * - * Multiple pairs: [a][b][c]. + * @callback MarkerParser + * Parse a possible comment marker node to a Marker. + * @param {Node} node + * Node to parse * - * @example - * {"name": "not-ok.md", "label": "output"} + * @typedef Marker + * A comment marker. + * @property {string} name + * Name of marker. + * @property {string} attributes + * Value after name. + * @property {Record} parameters + * Parsed attributes. + * @property {Node} node + * Reference to given node. * - * 1:1-1:6: Found reference to undefined definition - * 3:1-3:8: Found reference to undefined definition - * 5:1-5:12: Found reference to undefined definition - * 7:8-8:9: Found reference to undefined definition - * 10:6-11:17: Found reference to undefined definition - * 13:1-13:6: Found reference to undefined definition - * 15:13-15:25: Found reference to undefined definition - * 17:17-17:23: Found reference to undefined definition - * 17:23-17:26: Found reference to undefined definition + * @typedef Mark + * @property {Point|undefined} point + * @property {boolean} state */ -const remarkLintNoUndefinedReferences = lintRule( - 'remark-lint:no-undefined-references', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file, option = {}) => { - const contents = String(file); - const loc = location(file); - const lineEnding = /(\r?\n|\r)[\t ]*(>[\t ]*)*/g; - const allow = new Set( - (option.allow || []).map((d) => normalizeIdentifier(d)) - ); - /** @type {Record} */ - const map = Object.create(null); +const own$2 = {}.hasOwnProperty; + +/** + * @type {import('unified').Plugin<[Options]>} + * @returns {(tree: Node, file: VFile) => void} + */ +function messageControl(options) { + if (!options || typeof options !== 'object' || !options.name) { + throw new Error( + 'Expected `name` in `options`, got `' + (options || {}).name + '`' + ) + } + + if (!options.marker) { + throw new Error( + 'Expected `marker` in `options`, got `' + options.marker + '`' + ) + } + + const enable = 'enable' in options && options.enable ? options.enable : []; + const disable = 'disable' in options && options.disable ? options.disable : []; + let reset = options.reset; + const sources = + typeof options.source === 'string' + ? [options.source] + : options.source || [options.name]; + + return transformer + + /** + * @param {Node} tree + * @param {VFile} file + */ + function transformer(tree, file) { + const toOffset = location(file).toOffset; + const initial = !reset; + const gaps = detectGaps(tree, file); + /** @type {Record} */ + const scope = {}; + /** @type {Mark[]} */ + const globals = []; + + visit$1(tree, options.test, visitor); + + file.messages = file.messages.filter((m) => filter(m)); + + /** + * @param {Node} node + * @param {number|null} position + * @param {Parent|null} parent + */ + function visitor(node, position, parent) { + /** @type {Marker|null} */ + const mark = options.marker(node); + + if (!mark || mark.name !== options.name) { + return + } + + const ruleIds = mark.attributes.split(/\s/g); + const point = mark.node.position && mark.node.position.start; + const next = + (parent && position !== null && parent.children[position + 1]) || + undefined; + const tail = (next && next.position && next.position.end) || undefined; + let index = -1; + + /** @type {string} */ + // @ts-expect-error: we’ll check for unknown values next. + const verb = ruleIds.shift(); + + if (verb !== 'enable' && verb !== 'disable' && verb !== 'ignore') { + file.fail( + 'Unknown keyword `' + + verb + + '`: expected ' + + "`'enable'`, `'disable'`, or `'ignore'`", + mark.node + ); + } + + // Apply to all rules. + if (ruleIds.length > 0) { + while (++index < ruleIds.length) { + const ruleId = ruleIds[index]; + + if (isKnown(ruleId, verb, mark.node)) { + toggle(point, verb === 'enable', ruleId); + + if (verb === 'ignore') { + toggle(tail, true, ruleId); + } + } + } + } else if (verb === 'ignore') { + toggle(point, false); + toggle(tail, true); + } else { + toggle(point, verb === 'enable'); + reset = verb !== 'enable'; + } + } + + /** + * @param {VFileMessage} message + * @returns {boolean} + */ + function filter(message) { + let gapIndex = gaps.length; + + // Keep messages from a different source. + if (!message.source || !sources.includes(message.source)) { + return true + } + + // We only ignore messages if they‘re disabled, *not* when they’re not in + // the document. + if (!message.line) { + message.line = 1; + } - visit$2(tree, (node) => { - if ( - (node.type === 'definition' || node.type === 'footnoteDefinition') && - !generated(node) - ) { - map[normalizeIdentifier(node.identifier)] = true; + if (!message.column) { + message.column = 1; } - }); - visit$2(tree, (node) => { - // CM specifiers that references only form when defined. - // Still, they could be added by plugins, so let’s keep it. - /* c8 ignore next 10 */ - if ( - (node.type === 'imageReference' || - node.type === 'linkReference' || - node.type === 'footnoteReference') && - !generated(node) && - !(normalizeIdentifier(node.identifier) in map) && - !allow.has(normalizeIdentifier(node.identifier)) - ) { - file.message('Found reference to undefined definition', node); + // Check whether the warning is inside a gap. + // @ts-expect-error: we just normalized `null` to `number`s. + const offset = toOffset(message); + + while (gapIndex--) { + if (gaps[gapIndex][0] <= offset && gaps[gapIndex][1] > offset) { + return false + } } - if (node.type === 'paragraph' || node.type === 'heading') { - findInPhrasing(node); + // Check whether allowed by specific and global states. + return ( + (!message.ruleId || + check(message, scope[message.ruleId], message.ruleId)) && + check(message, globals) + ) + } + + /** + * Helper to check (and possibly warn) if a `ruleId` is unknown. + * + * @param {string} ruleId + * @param {string} verb + * @param {Node} node + * @returns {boolean} + */ + function isKnown(ruleId, verb, node) { + const result = options.known ? options.known.includes(ruleId) : true; + + if (!result) { + file.message( + 'Unknown rule: cannot ' + verb + " `'" + ruleId + "'`", + node + ); } - }); + + return result + } /** - * @param {Heading|Paragraph} node + * Get the latest state of a rule. + * When without `ruleId`, gets global state. + * + * @param {string|undefined} ruleId + * @returns {boolean} */ - function findInPhrasing(node) { - /** @type {Range[]} */ - let ranges = []; + function getState(ruleId) { + const ranges = ruleId ? scope[ruleId] : globals; - visit$2(node, (child) => { - // Ignore the node itself. - if (child === node) return + if (ranges && ranges.length > 0) { + return ranges[ranges.length - 1].state + } - // Can’t have links in links, so reset ranges. - if (child.type === 'link' || child.type === 'linkReference') { - ranges = []; - return SKIP$2 - } + if (!ruleId) { + return !reset + } - // Enter non-text. - if (child.type !== 'text') return + return reset ? enable.includes(ruleId) : !disable.includes(ruleId) + } - const start = pointStart(child).offset; - const end = pointEnd(child).offset; + /** + * Handle a rule. + * + * @param {Point|undefined} point + * @param {boolean} state + * @param {string|undefined} [ruleId] + * @returns {void} + */ + function toggle(point, state, ruleId) { + let markers = ruleId ? scope[ruleId] : globals; - // Bail if there’s no positional info. - if (typeof start !== 'number' || typeof end !== 'number') { - return EXIT$2 - } + if (!markers) { + markers = []; + scope[String(ruleId)] = markers; + } - const source = contents.slice(start, end); - /** @type {Array.<[number, string]>} */ - const lines = [[start, '']]; - let last = 0; + const previousState = getState(ruleId); - lineEnding.lastIndex = 0; - let match = lineEnding.exec(source); + if (state !== previousState) { + markers.push({state, point}); + } - while (match) { - const index = match.index; - lines[lines.length - 1][1] = source.slice(last, index); - last = index + match[0].length; - lines.push([start + last, '']); - match = lineEnding.exec(source); + // Toggle all known rules. + if (!ruleId) { + for (ruleId in scope) { + if (own$2.call(scope, ruleId)) { + toggle(point, state, ruleId); + } } + } + } - lines[lines.length - 1][1] = source.slice(last); - let lineIndex = -1; + /** + * Check all `ranges` for `message`. + * + * @param {VFileMessage} message + * @param {Mark[]|undefined} ranges + * @param {string|undefined} [ruleId] + * @returns {boolean} + */ + function check(message, ranges, ruleId) { + if (ranges && ranges.length > 0) { + // Check the state at the message’s position. + let index = ranges.length; - while (++lineIndex < lines.length) { - const line = lines[lineIndex][1]; - let index = 0; + while (index--) { + const range = ranges[index]; - while (index < line.length) { - const code = line.charCodeAt(index); + if ( + message.line && + message.column && + range.point && + range.point.line && + range.point.column && + (range.point.line < message.line || + (range.point.line === message.line && + range.point.column <= message.column)) + ) { + return range.state === true + } + } + } - // Skip past escaped brackets. - if (code === 92) { - const next = line.charCodeAt(index + 1); - index++; + // The first marker ocurred after the first message, so we check the + // initial state. + if (!ruleId) { + return Boolean(initial || reset) + } - if (next === 91 || next === 93) { - index++; - } - } - // Opening bracket. - else if (code === 91) { - ranges.push([lines[lineIndex][0] + index]); - index++; - } - // Close bracket. - else if (code === 93) { - // No opening. - if (ranges.length === 0) { - index++; - } else if (line.charCodeAt(index + 1) === 91) { - index++; + return reset ? enable.includes(ruleId) : !disable.includes(ruleId) + } + } +} - // Collapsed or full. - let range = ranges.pop(); +/** + * Detect gaps in `tree`. + * + * @param {Node} tree + * @param {VFile} file + */ +function detectGaps(tree, file) { + /** @type {Node[]} */ + // @ts-expect-error: fine. + const children = tree.children || []; + const lastNode = children[children.length - 1]; + /** @type {[number, number][]} */ + const gaps = []; + let offset = 0; + /** @type {boolean|undefined} */ + let gap; - // Range should always exist. - // eslint-disable-next-line max-depth - if (range) { - range.push(lines[lineIndex][0] + index); + // Find all gaps. + visit$1(tree, one); - // This is the end of a reference already. - // eslint-disable-next-line max-depth - if (range.length === 4) { - handleRange(range); - range = []; - } + // Get the end of the document. + // This detects if the last node was the last node. + // If not, there’s an extra gap between the last node and the end of the + // document. + if ( + lastNode && + lastNode.position && + lastNode.position.end && + offset === lastNode.position.end.offset && + file.toString().slice(offset).trim() !== '' + ) { + update(); - range.push(lines[lineIndex][0] + index); - ranges.push(range); - index++; - } - } else { - index++; + update( + tree && + tree.position && + tree.position.end && + tree.position.end.offset && + tree.position.end.offset - 1 + ); + } - // Shortcut or typical end of a reference. - const range = ranges.pop(); + return gaps - // Range should always exist. - // eslint-disable-next-line max-depth - if (range) { - range.push(lines[lineIndex][0] + index); - handleRange(range); - } - } - } - // Anything else. - else { - index++; - } - } - } - }); + /** + * @param {Node} node + */ + function one(node) { + update(node.position && node.position.start && node.position.start.offset); - let index = -1; + if (!('children' in node)) { + update(node.position && node.position.end && node.position.end.offset); + } + } - while (++index < ranges.length) { - handleRange(ranges[index]); + /** + * Detect a new position. + * + * @param {number|undefined} [latest] + * @returns {void} + */ + function update(latest) { + if (latest === null || latest === undefined) { + gap = true; + } else if (offset < latest) { + if (gap) { + gaps.push([offset, latest]); + gap = undefined; } - return SKIP$2 + offset = latest; + } + } +} - /** - * @param {Range} range - */ - function handleRange(range) { - if (range.length === 1) return - if (range.length === 3) range.length = 2; +/** + * @typedef {string|number|boolean} MarkerParameterValue + * @typedef {Object.} MarkerParameters + * + * @typedef HtmlNode + * @property {'html'} type + * @property {string} value + * + * @typedef CommentNode + * @property {'comment'} type + * @property {string} value + * + * @typedef Marker + * @property {string} name + * @property {string} attributes + * @property {MarkerParameters|null} parameters + * @property {HtmlNode|CommentNode} node + */ - // No need to warn for just `[]`. - if (range.length === 2 && range[0] + 2 === range[1]) return +var commentExpression = /\s*([a-zA-Z\d-]+)(\s+([\s\S]*))?\s*/; - const offset = range.length === 4 && range[2] + 2 !== range[3] ? 2 : 0; - const id = contents - .slice(range[0 + offset] + 1, range[1 + offset] - 1) - .replace(lineEnding, ' '); - const pos = { - start: loc.toPoint(range[0]), - end: loc.toPoint(range[range.length - 1]) - }; +var markerExpression = new RegExp( + '(\\s*\\s*)' +); - if ( - !generated({position: pos}) && - !(normalizeIdentifier(id) in map) && - !allow.has(normalizeIdentifier(id)) - ) { - file.message('Found reference to undefined definition', pos); +/** + * Parse a comment marker. + * @param {unknown} node + * @returns {Marker|null} + */ +function commentMarker(node) { + /** @type {RegExpMatchArray} */ + var match; + /** @type {number} */ + var offset; + /** @type {MarkerParameters} */ + var parameters; + + if ( + node && + typeof node === 'object' && + // @ts-ignore hush + (node.type === 'html' || node.type === 'comment') + ) { + // @ts-ignore hush + match = node.value.match( + // @ts-ignore hush + node.type === 'comment' ? commentExpression : markerExpression + ); + + // @ts-ignore hush + if (match && match[0].length === node.value.length) { + // @ts-ignore hush + offset = node.type === 'comment' ? 1 : 2; + parameters = parseParameters(match[offset + 1] || ''); + + if (parameters) { + return { + name: match[offset], + attributes: match[offset + 2] || '', + parameters, + // @ts-ignore hush + node } } } } -); -var remarkLintNoUndefinedReferences$1 = remarkLintNoUndefinedReferences; + return null +} /** - * @author Titus Wormer - * @copyright 2016 Titus Wormer - * @license MIT - * @module no-unused-definitions - * @fileoverview - * Warn when unused definitions are found. - * - * @example - * {"name": "ok.md"} - * - * [foo][] + * Parse `value` into an object. * - * [foo]: https://example.com + * @param {string} value + * @returns {MarkerParameters|null} + */ +function parseParameters(value) { + /** @type {MarkerParameters} */ + var parameters = {}; + + return value + .replace( + /\s+([-\w]+)(?:=(?:"((?:\\[\s\S]|[^"])+)"|'((?:\\[\s\S]|[^'])+)'|((?:\\[\s\S]|[^"'\s])+)))?/gi, + replacer + ) + .replace(/\s+/g, '') + ? null + : parameters + + /** + * @param {string} _ + * @param {string} $1 + * @param {string} $2 + * @param {string} $3 + * @param {string} $4 + */ + // eslint-disable-next-line max-params + function replacer(_, $1, $2, $3, $4) { + /** @type {MarkerParameterValue} */ + var value = $2 || $3 || $4 || ''; + + if (value === 'true' || value === '') { + value = true; + } else if (value === 'false') { + value = false; + } else if (!Number.isNaN(Number(value))) { + value = Number(value); + } + + parameters[$1] = value; + + return '' + } +} + +/** + * @typedef {import('mdast').Root} Root + * @typedef {import('vfile').VFile} VFile + * @typedef {import('unified-message-control')} MessageControl + * @typedef {Omit|Omit} Options + */ + +const test = [ + 'html', // Comments are `html` nodes in mdast. + 'comment' // In MDX, comments have their own node. +]; + +/** + * Plugin to enable, disable, and ignore messages. * - * @example - * {"name": "not-ok.md", "label": "input"} + * @type {import('unified').Plugin<[Options], Root>} + * @returns {(node: Root, file: VFile) => void} + */ +function remarkMessageControl(options) { + return messageControl( + Object.assign({marker: commentMarker, test}, options) + ) +} + +/** + * @typedef {import('mdast').Root} Root + */ + +/** + * The core plugin for `remark-lint`. + * This adds support for ignoring stuff from messages (``). + * All rules are in their own packages and presets. * - * [bar]: https://example.com + * @type {import('unified').Plugin} + */ +function remarkLint() { + this.use(lintMessageControl); +} + +/** @type {import('unified').Plugin} */ +function lintMessageControl() { + return remarkMessageControl({name: 'lint', source: 'remark-lint'}) +} + +/** + * @typedef {import('unist').Node} Node + * @typedef {import('vfile').VFile} VFile * - * @example - * {"name": "not-ok.md", "label": "output"} + * @typedef {0|1|2} Severity + * @typedef {'warn'|'on'|'off'|'error'} Label + * @typedef {[Severity, ...unknown[]]} SeverityTuple * - * 1:1-1:27: Found unused definition + * @callback Rule + * @param {Node} tree + * @param {VFile} file + * @param {unknown} options + * @returns {void} */ -const own$2 = {}.hasOwnProperty; +const primitives$G = new Set(['string', 'number', 'boolean']); -const remarkLintNoUnusedDefinitions = lintRule( - 'remark-lint:no-unused-definitions', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - /** @type {Record} */ - const map = Object.create(null); +/** + * @param {string} id + * @param {Rule} rule + */ +function lintRule$G(id, rule) { + const parts = id.split(':'); + // Possibly useful if externalised later. + /* c8 ignore next */ + const source = parts[1] ? parts[0] : undefined; + const ruleId = parts[1]; - visit$2(tree, (node) => { - if ( - (node.type === 'definition' || node.type === 'footnoteDefinition') && - !generated(node) - ) { - map[node.identifier.toUpperCase()] = {node, used: false}; - } - }); + Object.defineProperty(plugin, 'name', {value: id}); - visit$2(tree, (node) => { - if ( - node.type === 'imageReference' || - node.type === 'linkReference' || - node.type === 'footnoteReference' - ) { - const info = map[node.identifier.toUpperCase()]; + return plugin - if (!generated(node) && info) { - info.used = true; - } - } - }); + /** @type {import('unified').Plugin<[unknown]|void[]>} */ + function plugin(raw) { + const [severity, options] = coerce$H(ruleId, raw); - /** @type {string} */ - let identifier; + if (!severity) return - for (identifier in map) { - if (own$2.call(map, identifier)) { - const entry = map[identifier]; + const fatal = severity === 2; - if (!entry.used) { - file.message('Found unused definition', entry.node); - } - } - } - } -); + return (tree, file, next) => { + let index = file.messages.length - 1; -var remarkLintNoUnusedDefinitions$1 = remarkLintNoUnusedDefinitions; + wrap(rule, (error) => { + const messages = file.messages; -/** - * @fileoverview - * remark preset to configure `remark-lint` with settings that prevent - * mistakes or stuff that fails across vendors. - */ + // Add the error, if not already properly added. + // Only happens for incorrect plugins. + /* c8 ignore next 6 */ + // @ts-expect-error: errors could be `messages`. + if (error && !messages.includes(error)) { + try { + file.fail(error); + } catch {} + } -/** @type {Preset} */ -const remarkPresetLintRecommended = { - plugins: [ - remarkLint, - // Unix compatibility. - remarkLintFinalNewline$1, - // Rendering across vendors differs greatly if using other styles. - remarkLintListItemBulletIndent$1, - [remarkLintListItemIndent$1, 'tab-size'], - // Differs or unsupported across vendors. - remarkLintNoAutoLinkWithoutProtocol$1, - remarkLintNoBlockquoteWithoutMarker$1, - remarkLintNoLiteralUrls$1, - [remarkLintOrderedListMarkerStyle$1, '.'], - // Mistakes. - remarkLintHardBreakSpaces$1, - remarkLintNoDuplicateDefinitions$1, - remarkLintNoHeadingContentIndent$1, - remarkLintNoInlinePadding$1, - remarkLintNoShortcutReferenceImage$1, - remarkLintNoShortcutReferenceLink$1, - remarkLintNoUndefinedReferences$1, - remarkLintNoUnusedDefinitions$1 - ] -}; + while (++index < messages.length) { + Object.assign(messages[index], {ruleId, source, fatal}); + } -var remarkPresetLintRecommended$1 = remarkPresetLintRecommended; + next(); + })(tree, file, options); + } + } +} /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module blockquote-indentation - * @fileoverview - * Warn when block quotes are indented too much or too little. - * - * Options: `number` or `'consistent'`, default: `'consistent'`. - * - * `'consistent'` detects the first used indentation and will warn when - * other block quotes use a different indentation. - * - * @example - * {"name": "ok.md", "setting": 4} - * - * > Hello - * - * Paragraph. - * - * > World - * @example - * {"name": "ok.md", "setting": 2} - * - * > Hello - * - * Paragraph. - * - * > World - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * > Hello - * - * Paragraph. - * - * > World - * - * Paragraph. - * - * > World - * - * @example - * {"name": "not-ok.md", "label": "output"} + * Coerce a value to a severity--options tuple. * - * 5:5: Remove 1 space between block quote and content - * 9:3: Add 1 space between block quote and content + * @param {string} name + * @param {unknown} value + * @returns {SeverityTuple} */ +function coerce$H(name, value) { + /** @type {unknown[]} */ + let result; -const remarkLintBlockquoteIndentation = lintRule( - 'remark-lint:blockquote-indentation', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file, option = 'consistent') => { - visit$2(tree, 'blockquote', (node) => { - if (generated(node) || node.children.length === 0) { - return - } + if (typeof value === 'boolean') { + result = [value]; + } else if (value === null || value === undefined) { + result = [1]; + } else if ( + Array.isArray(value) && + // `isArray(unknown)` is turned into `any[]`: + // type-coverage:ignore-next-line + primitives$G.has(typeof value[0]) + ) { + // `isArray(unknown)` is turned into `any[]`: + // type-coverage:ignore-next-line + result = [...value]; + } else { + result = [1, value]; + } - if (option === 'consistent') { - option = check(node); - } else { - const diff = option - check(node); + let level = result[0]; - if (diff !== 0) { - const abs = Math.abs(diff); + if (typeof level === 'boolean') { + level = level ? 1 : 0; + } else if (typeof level === 'string') { + if (level === 'off') { + level = 0; + } else if (level === 'on' || level === 'warn') { + level = 1; + } else if (level === 'error') { + level = 2; + } else { + level = 1; + result = [level, result]; + } + } - file.message( - (diff > 0 ? 'Add' : 'Remove') + - ' ' + - abs + - ' ' + - plural('space', abs) + - ' between block quote and content', - pointStart(node.children[0]) - ); - } - } - }); + if (typeof level !== 'number' || level < 0 || level > 2) { + throw new Error( + 'Incorrect severity `' + + level + + '` for `' + + name + + '`, ' + + 'expected 0, 1, or 2' + ) } -); -var remarkLintBlockquoteIndentation$1 = remarkLintBlockquoteIndentation; + result[0] = level; -/** - * @param {Blockquote} node - * @returns {number} - */ -function check(node) { - return pointStart(node.children[0]).column - pointStart(node).column + // @ts-expect-error: it’s now a valid tuple. + return result } /** * @author Titus Wormer * @copyright 2015 Titus Wormer * @license MIT - * @module checkbox-character-style + * @module final-newline * @fileoverview - * Warn when list item checkboxes violate a given style. - * - * Options: `Object` or `'consistent'`, default: `'consistent'`. - * - * `'consistent'` detects the first used checked and unchecked checkbox - * styles and warns when subsequent checkboxes use different styles. - * - * Styles can also be passed in like so: + * Warn when a line feed at the end of a file is missing. + * Empty files are allowed. * - * ```js - * {checked: 'x', unchecked: ' '} - * ``` + * See [StackExchange](https://unix.stackexchange.com/questions/18743) for why. * * ## Fix * * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * formats checked checkboxes using `x` (lowercase X) and unchecked checkboxes - * as `·` (a single space). + * always adds a final line feed to files. * * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) * on how to automatically fix warnings for this rule. * - * @example - * {"name": "ok.md", "setting": {"checked": "x"}, "gfm": true} + * ## Example * - * - [x] List item - * - [x] List item + * ##### `ok.md` * - * @example - * {"name": "ok.md", "setting": {"checked": "X"}, "gfm": true} + * ###### In * - * - [X] List item - * - [X] List item + * Note: `␊` represents LF. * - * @example - * {"name": "ok.md", "setting": {"unchecked": " "}, "gfm": true} + * ```markdown + * Alpha␊ + * ``` * - * - [ ] List item - * - [ ] List item - * - [ ]·· - * - [ ] + * ###### Out * - * @example - * {"name": "ok.md", "setting": {"unchecked": "\t"}, "gfm": true} + * No messages. * - * - [»] List item - * - [»] List item + * ##### `not-ok.md` * - * @example - * {"name": "not-ok.md", "label": "input", "gfm": true} + * ###### In * - * - [x] List item - * - [X] List item - * - [ ] List item - * - [»] List item + * Note: The below file does not have a final newline. * - * @example - * {"name": "not-ok.md", "label": "output", "gfm": true} + * ```markdown + * Bravo + * ``` * - * 2:5: Checked checkboxes should use `x` as a marker - * 4:5: Unchecked checkboxes should use ` ` as a marker + * ###### Out * - * @example - * {"setting": {"unchecked": "💩"}, "name": "not-ok.md", "label": "output", "positionless": true, "gfm": true} + * ```text + * 1:1: Missing newline character at end of file + * ``` + */ + +const remarkLintFinalNewline = lintRule$G( + 'remark-lint:final-newline', + /** @type {import('unified-lint-rule').Rule} */ + (_, file) => { + const value = String(file); + const last = value.length - 1; + + if (last > -1 && value.charAt(last) !== '\n') { + file.message('Missing newline character at end of file'); + } + } +); + +var remarkLintFinalNewline$1 = remarkLintFinalNewline; + +/** + * @typedef {import('unist').Node} Node + * @typedef {import('vfile').VFile} VFile * - * 1:1: Incorrect unchecked checkbox marker `💩`: use either `'\t'`, or `' '` + * @typedef {0|1|2} Severity + * @typedef {'warn'|'on'|'off'|'error'} Label + * @typedef {[Severity, ...unknown[]]} SeverityTuple * - * @example - * {"setting": {"checked": "💩"}, "name": "not-ok.md", "label": "output", "positionless": true, "gfm": true} + * @callback Rule + * @param {Node} tree + * @param {VFile} file + * @param {unknown} options + * @returns {void} + */ + +const primitives$F = new Set(['string', 'number', 'boolean']); + +/** + * @param {string} id + * @param {Rule} rule + */ +function lintRule$F(id, rule) { + const parts = id.split(':'); + // Possibly useful if externalised later. + /* c8 ignore next */ + const source = parts[1] ? parts[0] : undefined; + const ruleId = parts[1]; + + Object.defineProperty(plugin, 'name', {value: id}); + + return plugin + + /** @type {import('unified').Plugin<[unknown]|void[]>} */ + function plugin(raw) { + const [severity, options] = coerce$G(ruleId, raw); + + if (!severity) return + + const fatal = severity === 2; + + return (tree, file, next) => { + let index = file.messages.length - 1; + + wrap(rule, (error) => { + const messages = file.messages; + + // Add the error, if not already properly added. + // Only happens for incorrect plugins. + /* c8 ignore next 6 */ + // @ts-expect-error: errors could be `messages`. + if (error && !messages.includes(error)) { + try { + file.fail(error); + } catch {} + } + + while (++index < messages.length) { + Object.assign(messages[index], {ruleId, source, fatal}); + } + + next(); + })(tree, file, options); + } + } +} + +/** + * Coerce a value to a severity--options tuple. * - * 1:1: Incorrect checked checkbox marker `💩`: use either `'x'`, or `'X'` + * @param {string} name + * @param {unknown} value + * @returns {SeverityTuple} */ +function coerce$G(name, value) { + /** @type {unknown[]} */ + let result; -const remarkLintCheckboxCharacterStyle = lintRule( - 'remark-lint:checkbox-character-style', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file, option = 'consistent') => { - const value = String(file); - /** @type {'x'|'X'|'consistent'} */ - let checked = 'consistent'; - /** @type {' '|'\x09'|'consistent'} */ - let unchecked = 'consistent'; + if (typeof value === 'boolean') { + result = [value]; + } else if (value === null || value === undefined) { + result = [1]; + } else if ( + Array.isArray(value) && + // `isArray(unknown)` is turned into `any[]`: + // type-coverage:ignore-next-line + primitives$F.has(typeof value[0]) + ) { + // `isArray(unknown)` is turned into `any[]`: + // type-coverage:ignore-next-line + result = [...value]; + } else { + result = [1, value]; + } - if (typeof option === 'object') { - checked = option.checked || 'consistent'; - unchecked = option.unchecked || 'consistent'; + let level = result[0]; + + if (typeof level === 'boolean') { + level = level ? 1 : 0; + } else if (typeof level === 'string') { + if (level === 'off') { + level = 0; + } else if (level === 'on' || level === 'warn') { + level = 1; + } else if (level === 'error') { + level = 2; + } else { + level = 1; + result = [level, result]; + } + } + + if (typeof level !== 'number' || level < 0 || level > 2) { + throw new Error( + 'Incorrect severity `' + + level + + '` for `' + + name + + '`, ' + + 'expected 0, 1, or 2' + ) + } + + result[0] = level; + + // @ts-expect-error: it’s now a valid tuple. + return result +} + +var pluralize = {exports: {}}; + +/* global define */ + +(function (module, exports) { +(function (root, pluralize) { + /* istanbul ignore else */ + if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') { + // Node. + module.exports = pluralize(); + } else { + // Browser global. + root.pluralize = pluralize(); + } +})(commonjsGlobal, function () { + // Rule storage - pluralize and singularize need to be run sequentially, + // while other rules can be optimized using an object for instant lookups. + var pluralRules = []; + var singularRules = []; + var uncountables = {}; + var irregularPlurals = {}; + var irregularSingles = {}; + + /** + * Sanitize a pluralization rule to a usable regular expression. + * + * @param {(RegExp|string)} rule + * @return {RegExp} + */ + function sanitizeRule (rule) { + if (typeof rule === 'string') { + return new RegExp('^' + rule + '$', 'i'); + } + + return rule; + } + + /** + * Pass in a word token to produce a function that can replicate the case on + * another word. + * + * @param {string} word + * @param {string} token + * @return {Function} + */ + function restoreCase (word, token) { + // Tokens are an exact match. + if (word === token) return token; + + // Lower cased words. E.g. "hello". + if (word === word.toLowerCase()) return token.toLowerCase(); + + // Upper cased words. E.g. "WHISKY". + if (word === word.toUpperCase()) return token.toUpperCase(); + + // Title cased words. E.g. "Title". + if (word[0] === word[0].toUpperCase()) { + return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase(); + } + + // Lower cased words. E.g. "test". + return token.toLowerCase(); + } + + /** + * Interpolate a regexp string. + * + * @param {string} str + * @param {Array} args + * @return {string} + */ + function interpolate (str, args) { + return str.replace(/\$(\d{1,2})/g, function (match, index) { + return args[index] || ''; + }); + } + + /** + * Replace a word using a rule. + * + * @param {string} word + * @param {Array} rule + * @return {string} + */ + function replace (word, rule) { + return word.replace(rule[0], function (match, index) { + var result = interpolate(rule[1], arguments); + + if (match === '') { + return restoreCase(word[index - 1], result); + } + + return restoreCase(match, result); + }); + } + + /** + * Sanitize a word by passing in the word and sanitization rules. + * + * @param {string} token + * @param {string} word + * @param {Array} rules + * @return {string} + */ + function sanitizeWord (token, word, rules) { + // Empty string or doesn't need fixing. + if (!token.length || uncountables.hasOwnProperty(token)) { + return word; } - if (unchecked !== 'consistent' && unchecked !== ' ' && unchecked !== '\t') { - file.fail( - 'Incorrect unchecked checkbox marker `' + - unchecked + - "`: use either `'\\t'`, or `' '`" - ); - } + var len = rules.length; - if (checked !== 'consistent' && checked !== 'x' && checked !== 'X') { - file.fail( - 'Incorrect checked checkbox marker `' + - checked + - "`: use either `'x'`, or `'X'`" - ); + // Iterate over the sanitization rules and use the first one to match. + while (len--) { + var rule = rules[len]; + + if (rule[0].test(word)) return replace(word, rule); } - visit$2(tree, 'listItem', (node) => { - const head = node.children[0]; - const point = pointStart(head); + return word; + } - // Exit early for items without checkbox. - // A list item cannot be checked and empty, according to GFM. - if ( - typeof node.checked !== 'boolean' || - !head || - typeof point.offset !== 'number' - ) { - return + /** + * Replace a word with the updated word. + * + * @param {Object} replaceMap + * @param {Object} keepMap + * @param {Array} rules + * @return {Function} + */ + function replaceWord (replaceMap, keepMap, rules) { + return function (word) { + // Get the correct token and case restoration functions. + var token = word.toLowerCase(); + + // Check against the keep object map. + if (keepMap.hasOwnProperty(token)) { + return restoreCase(word, token); } - // Move back to before `] `. - point.offset -= 2; - point.column -= 2; + // Check against the replacement map for a direct word replacement. + if (replaceMap.hasOwnProperty(token)) { + return restoreCase(word, replaceMap[token]); + } - // Assume we start with a checkbox, because well, `checked` is set. - const match = /\[([\t Xx])]/.exec( - value.slice(point.offset - 2, point.offset + 1) - ); + // Run all the rules against the word. + return sanitizeWord(token, word, rules); + }; + } - // Failsafe to make sure we don‘t crash if there actually isn’t a checkbox. - /* c8 ignore next */ - if (!match) return + /** + * Check if a word is part of the map. + */ + function checkWord (replaceMap, keepMap, rules, bool) { + return function (word) { + var token = word.toLowerCase(); - const style = node.checked ? checked : unchecked; + if (keepMap.hasOwnProperty(token)) return true; + if (replaceMap.hasOwnProperty(token)) return false; - if (style === 'consistent') { - if (node.checked) { - // @ts-expect-error: valid marker. - checked = match[1]; - } else { - // @ts-expect-error: valid marker. - unchecked = match[1]; - } - } else if (match[1] !== style) { - file.message( - (node.checked ? 'Checked' : 'Unchecked') + - ' checkboxes should use `' + - style + - '` as a marker', - point - ); - } - }); + return sanitizeWord(token, token, rules) === token; + }; } -); -var remarkLintCheckboxCharacterStyle$1 = remarkLintCheckboxCharacterStyle; + /** + * Pluralize or singularize a word based on the passed in count. + * + * @param {string} word The word to pluralize + * @param {number} count How many of the word exist + * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks) + * @return {string} + */ + function pluralize (word, count, inclusive) { + var pluralized = count === 1 + ? pluralize.singular(word) : pluralize.plural(word); -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module checkbox-content-indent - * @fileoverview - * Warn when list item checkboxes are followed by too much whitespace. - * - * @example - * {"name": "ok.md", "gfm": true} - * - * - [ ] List item - * + [x] List Item - * * [X] List item - * - [ ] List item - * - * @example - * {"name": "not-ok.md", "label": "input", "gfm": true} - * - * - [ ] List item - * + [x] List item - * * [X] List item - * - [ ] List item - * - * @example - * {"name": "not-ok.md", "label": "output", "gfm": true} - * - * 2:7-2:8: Checkboxes should be followed by a single character - * 3:7-3:9: Checkboxes should be followed by a single character - * 4:7-4:10: Checkboxes should be followed by a single character - */ + return (inclusive ? count + ' ' : '') + pluralized; + } -const remarkLintCheckboxContentIndent = lintRule( - 'remark-lint:checkbox-content-indent', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - const value = String(file); - const loc = location(file); + /** + * Pluralize a word. + * + * @type {Function} + */ + pluralize.plural = replaceWord( + irregularSingles, irregularPlurals, pluralRules + ); - visit$2(tree, 'listItem', (node) => { - const head = node.children[0]; - const point = pointStart(head); + /** + * Check if a word is plural. + * + * @type {Function} + */ + pluralize.isPlural = checkWord( + irregularSingles, irregularPlurals, pluralRules + ); - // Exit early for items without checkbox. - // A list item cannot be checked and empty, according to GFM. - if ( - typeof node.checked !== 'boolean' || - !head || - typeof point.offset !== 'number' - ) { - return - } + /** + * Singularize a word. + * + * @type {Function} + */ + pluralize.singular = replaceWord( + irregularPlurals, irregularSingles, singularRules + ); - // Assume we start with a checkbox, because well, `checked` is set. - const match = /\[([\t xX])]/.exec( - value.slice(point.offset - 4, point.offset + 1) - ); + /** + * Check if a word is singular. + * + * @type {Function} + */ + pluralize.isSingular = checkWord( + irregularPlurals, irregularSingles, singularRules + ); - // Failsafe to make sure we don‘t crash if there actually isn’t a checkbox. - /* c8 ignore next */ - if (!match) return + /** + * Add a pluralization rule to the collection. + * + * @param {(string|RegExp)} rule + * @param {string} replacement + */ + pluralize.addPluralRule = function (rule, replacement) { + pluralRules.push([sanitizeRule(rule), replacement]); + }; - // Move past checkbox. - const initial = point.offset; - let final = initial; + /** + * Add a singularization rule to the collection. + * + * @param {(string|RegExp)} rule + * @param {string} replacement + */ + pluralize.addSingularRule = function (rule, replacement) { + singularRules.push([sanitizeRule(rule), replacement]); + }; - while (/[\t ]/.test(value.charAt(final))) final++; + /** + * Add an uncountable word rule. + * + * @param {(string|RegExp)} word + */ + pluralize.addUncountableRule = function (word) { + if (typeof word === 'string') { + uncountables[word.toLowerCase()] = true; + return; + } - if (final - initial > 0) { - file.message('Checkboxes should be followed by a single character', { - start: loc.toPoint(initial), - end: loc.toPoint(final) - }); - } - }); - } -); + // Set singular and plural references for the word. + pluralize.addPluralRule(word, '$0'); + pluralize.addSingularRule(word, '$0'); + }; -var remarkLintCheckboxContentIndent$1 = remarkLintCheckboxContentIndent; + /** + * Add an irregular word definition. + * + * @param {string} single + * @param {string} plural + */ + pluralize.addIrregularRule = function (single, plural) { + plural = plural.toLowerCase(); + single = single.toLowerCase(); -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module code-block-style - * @fileoverview - * Warn when code blocks do not adhere to a given style. - * - * Options: `'consistent'`, `'fenced'`, or `'indented'`, default: `'consistent'`. - * - * `'consistent'` detects the first used code block style and warns when - * subsequent code blocks uses different styles. - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * formats code blocks using a fence if they have a language flag and - * indentation if not. - * Pass - * [`fences: true`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsfences) - * to always use fences for code blocks. - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * @example - * {"setting": "indented", "name": "ok.md"} - * - * alpha() - * - * Paragraph. - * - * bravo() - * - * @example - * {"setting": "indented", "name": "not-ok.md", "label": "input"} - * - * ``` - * alpha() - * ``` - * - * Paragraph. - * - * ``` - * bravo() - * ``` - * - * @example - * {"setting": "indented", "name": "not-ok.md", "label": "output"} - * - * 1:1-3:4: Code blocks should be indented - * 7:1-9:4: Code blocks should be indented - * - * @example - * {"setting": "fenced", "name": "ok.md"} - * - * ``` - * alpha() - * ``` - * - * Paragraph. - * - * ``` - * bravo() - * ``` - * - * @example - * {"setting": "fenced", "name": "not-ok-fenced.md", "label": "input"} - * - * alpha() - * - * Paragraph. - * - * bravo() - * - * @example - * {"setting": "fenced", "name": "not-ok-fenced.md", "label": "output"} - * - * 1:1-1:12: Code blocks should be fenced - * 5:1-5:12: Code blocks should be fenced - * - * @example - * {"name": "not-ok-consistent.md", "label": "input"} - * - * alpha() - * - * Paragraph. - * - * ``` - * bravo() - * ``` - * - * @example - * {"name": "not-ok-consistent.md", "label": "output"} - * - * 5:1-7:4: Code blocks should be indented - * - * @example - * {"setting": "💩", "name": "not-ok-incorrect.md", "label": "output", "positionless": true} - * - * 1:1: Incorrect code block style `💩`: use either `'consistent'`, `'fenced'`, or `'indented'` - */ + irregularSingles[single] = plural; + irregularPlurals[plural] = single; + }; -const remarkLintCodeBlockStyle = lintRule( - 'remark-lint:code-block-style', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file, option = 'consistent') => { - const value = String(file); + /** + * Irregular rules. + */ + [ + // Pronouns. + ['I', 'we'], + ['me', 'us'], + ['he', 'they'], + ['she', 'they'], + ['them', 'them'], + ['myself', 'ourselves'], + ['yourself', 'yourselves'], + ['itself', 'themselves'], + ['herself', 'themselves'], + ['himself', 'themselves'], + ['themself', 'themselves'], + ['is', 'are'], + ['was', 'were'], + ['has', 'have'], + ['this', 'these'], + ['that', 'those'], + // Words ending in with a consonant and `o`. + ['echo', 'echoes'], + ['dingo', 'dingoes'], + ['volcano', 'volcanoes'], + ['tornado', 'tornadoes'], + ['torpedo', 'torpedoes'], + // Ends with `us`. + ['genus', 'genera'], + ['viscus', 'viscera'], + // Ends with `ma`. + ['stigma', 'stigmata'], + ['stoma', 'stomata'], + ['dogma', 'dogmata'], + ['lemma', 'lemmata'], + ['schema', 'schemata'], + ['anathema', 'anathemata'], + // Other irregular rules. + ['ox', 'oxen'], + ['axe', 'axes'], + ['die', 'dice'], + ['yes', 'yeses'], + ['foot', 'feet'], + ['eave', 'eaves'], + ['goose', 'geese'], + ['tooth', 'teeth'], + ['quiz', 'quizzes'], + ['human', 'humans'], + ['proof', 'proofs'], + ['carve', 'carves'], + ['valve', 'valves'], + ['looey', 'looies'], + ['thief', 'thieves'], + ['groove', 'grooves'], + ['pickaxe', 'pickaxes'], + ['passerby', 'passersby'] + ].forEach(function (rule) { + return pluralize.addIrregularRule(rule[0], rule[1]); + }); - if ( - option !== 'consistent' && - option !== 'fenced' && - option !== 'indented' - ) { - file.fail( - 'Incorrect code block style `' + - option + - "`: use either `'consistent'`, `'fenced'`, or `'indented'`" - ); - } + /** + * Pluralization rules. + */ + [ + [/s?$/i, 's'], + [/[^\u0000-\u007F]$/i, '$0'], + [/([^aeiou]ese)$/i, '$1'], + [/(ax|test)is$/i, '$1es'], + [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'], + [/(e[mn]u)s?$/i, '$1s'], + [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'], + [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'], + [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'], + [/(seraph|cherub)(?:im)?$/i, '$1im'], + [/(her|at|gr)o$/i, '$1oes'], + [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'], + [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'], + [/sis$/i, 'ses'], + [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'], + [/([^aeiouy]|qu)y$/i, '$1ies'], + [/([^ch][ieo][ln])ey$/i, '$1ies'], + [/(x|ch|ss|sh|zz)$/i, '$1es'], + [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'], + [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'], + [/(pe)(?:rson|ople)$/i, '$1ople'], + [/(child)(?:ren)?$/i, '$1ren'], + [/eaux$/i, '$0'], + [/m[ae]n$/i, 'men'], + ['thou', 'you'] + ].forEach(function (rule) { + return pluralize.addPluralRule(rule[0], rule[1]); + }); + + /** + * Singularization rules. + */ + [ + [/s$/i, ''], + [/(ss)$/i, '$1'], + [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'], + [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'], + [/ies$/i, 'y'], + [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'], + [/\b(mon|smil)ies$/i, '$1ey'], + [/\b((?:tit)?m|l)ice$/i, '$1ouse'], + [/(seraph|cherub)im$/i, '$1'], + [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'], + [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'], + [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'], + [/(test)(?:is|es)$/i, '$1is'], + [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'], + [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'], + [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'], + [/(alumn|alg|vertebr)ae$/i, '$1a'], + [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'], + [/(matr|append)ices$/i, '$1ix'], + [/(pe)(rson|ople)$/i, '$1rson'], + [/(child)ren$/i, '$1'], + [/(eau)x?$/i, '$1'], + [/men$/i, 'man'] + ].forEach(function (rule) { + return pluralize.addSingularRule(rule[0], rule[1]); + }); + + /** + * Uncountable rules. + */ + [ + // Singular words with no plurals. + 'adulthood', + 'advice', + 'agenda', + 'aid', + 'aircraft', + 'alcohol', + 'ammo', + 'analytics', + 'anime', + 'athletics', + 'audio', + 'bison', + 'blood', + 'bream', + 'buffalo', + 'butter', + 'carp', + 'cash', + 'chassis', + 'chess', + 'clothing', + 'cod', + 'commerce', + 'cooperation', + 'corps', + 'debris', + 'diabetes', + 'digestion', + 'elk', + 'energy', + 'equipment', + 'excretion', + 'expertise', + 'firmware', + 'flounder', + 'fun', + 'gallows', + 'garbage', + 'graffiti', + 'hardware', + 'headquarters', + 'health', + 'herpes', + 'highjinks', + 'homework', + 'housework', + 'information', + 'jeans', + 'justice', + 'kudos', + 'labour', + 'literature', + 'machinery', + 'mackerel', + 'mail', + 'media', + 'mews', + 'moose', + 'music', + 'mud', + 'manga', + 'news', + 'only', + 'personnel', + 'pike', + 'plankton', + 'pliers', + 'police', + 'pollution', + 'premises', + 'rain', + 'research', + 'rice', + 'salmon', + 'scissors', + 'series', + 'sewage', + 'shambles', + 'shrimp', + 'software', + 'species', + 'staff', + 'swine', + 'tennis', + 'traffic', + 'transportation', + 'trout', + 'tuna', + 'wealth', + 'welfare', + 'whiting', + 'wildebeest', + 'wildlife', + 'you', + /pok[eé]mon$/i, + // Regexes. + /[^aeiou]ese$/i, // "chinese", "japanese" + /deer$/i, // "deer", "reindeer" + /fish$/i, // "fish", "blowfish", "angelfish" + /measles$/i, + /o[iu]s$/i, // "carnivorous" + /pox$/i, // "chickpox", "smallpox" + /sheep$/i + ].forEach(pluralize.addUncountableRule); - visit$2(tree, 'code', (node) => { - if (generated(node)) { - return - } + return pluralize; +}); +}(pluralize)); - const initial = pointStart(node).offset; - const final = pointEnd(node).offset; +var plural = pluralize.exports; - const current = - node.lang || /^\s*([~`])\1{2,}/.test(value.slice(initial, final)) - ? 'fenced' - : 'indented'; +/** + * @param {string} d + * @returns {string} + */ +function color$1(d) { + return '\u001B[33m' + d + '\u001B[39m' +} - if (option === 'consistent') { - option = current; - } else if (option !== current) { - file.message('Code blocks should be ' + option, node); - } - }); - } -); +/** + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Parent} Parent + * @typedef {import('unist-util-is').Test} Test + */ -var remarkLintCodeBlockStyle$1 = remarkLintCodeBlockStyle; +/** + * Continue traversing as normal + */ +const CONTINUE$1 = true; +/** + * Do not traverse this node’s children + */ +const SKIP$1 = 'skip'; +/** + * Stop traversing immediately + */ +const EXIT$1 = false; /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module definition-spacing - * @fileoverview - * Warn when consecutive whitespace is used in a definition. - * - * @example - * {"name": "ok.md"} - * - * [example domain]: http://example.com "Example Domain" - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * [example····domain]: http://example.com "Example Domain" - * - * @example - * {"name": "not-ok.md", "label": "output"} + * Visit children of tree which pass a test * - * 1:1-1:57: Do not use consecutive whitespace in definition labels + * @param tree Abstract syntax tree to walk + * @param test Test node, optional + * @param visitor Function to run for each node + * @param reverse Visit the tree in reverse order, defaults to false */ +const visitParents$1 = + /** + * @type {( + * ((tree: Tree, test: Check, visitor: Visitor, Check>>, reverse?: boolean) => void) & + * ((tree: Tree, visitor: Visitor>, reverse?: boolean) => void) + * )} + */ + ( + /** + * @param {Node} tree + * @param {Test} test + * @param {Visitor} visitor + * @param {boolean} [reverse] + */ + function (tree, test, visitor, reverse) { + if (typeof test === 'function' && typeof visitor !== 'function') { + reverse = visitor; + // @ts-expect-error no visitor given, so `visitor` is test. + visitor = test; + test = null; + } -const label = /^\s*\[((?:\\[\s\S]|[^[\]])+)]/; + const is = convert(test); + const step = reverse ? -1 : 1; -const remarkLintDefinitionSpacing = lintRule( - 'remark-lint:definition-spacing', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file) => { - const value = String(file); + factory(tree, null, [])(); - visit$2(tree, (node) => { - if (node.type === 'definition' || node.type === 'footnoteDefinition') { - const start = pointStart(node).offset; - const end = pointEnd(node).offset; + /** + * @param {Node} node + * @param {number?} index + * @param {Array.} parents + */ + function factory(node, index, parents) { + /** @type {Object.} */ + // @ts-expect-error: hush + const value = typeof node === 'object' && node !== null ? node : {}; + /** @type {string|undefined} */ + let name; - if (typeof start === 'number' && typeof end === 'number') { - const match = value.slice(start, end).match(label); + if (typeof value.type === 'string') { + name = + typeof value.tagName === 'string' + ? value.tagName + : typeof value.name === 'string' + ? value.name + : undefined; - if (match && /[ \t\n]{2,}/.test(match[1])) { - file.message( - 'Do not use consecutive whitespace in definition labels', - node - ); - } + Object.defineProperty(visit, 'name', { + value: + 'node (' + + color$1(value.type + (name ? '<' + name + '>' : '')) + + ')' + }); } - } - }); - } -); -var remarkLintDefinitionSpacing$1 = remarkLintDefinitionSpacing; + return visit -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module fenced-code-flag - * @fileoverview - * Check fenced code block flags. - * - * Options: `Array.` or `Object`, optional. - * - * Providing an array is as passing `{flags: Array}`. - * - * The object can have an array of `'flags'` which are allowed: other flags - * will not be allowed. - * An `allowEmpty` field (`boolean`, default: `false`) can be set to allow - * code blocks without language flags. - * - * @example - * {"name": "ok.md"} - * - * ```alpha - * bravo() - * ``` - * - * @example - * {"name": "not-ok.md", "label": "input"} - * - * ``` - * alpha() - * ``` - * - * @example - * {"name": "not-ok.md", "label": "output"} - * - * 1:1-3:4: Missing code language flag - * - * @example - * {"name": "ok.md", "setting": {"allowEmpty": true}} - * - * ``` - * alpha() - * ``` - * - * @example - * {"name": "not-ok.md", "setting": {"allowEmpty": false}, "label": "input"} - * - * ``` - * alpha() - * ``` - * - * @example - * {"name": "not-ok.md", "setting": {"allowEmpty": false}, "label": "output"} - * - * 1:1-3:4: Missing code language flag - * - * @example - * {"name": "ok.md", "setting": ["alpha"]} - * - * ```alpha - * bravo() - * ``` - * - * @example - * {"name": "ok.md", "setting": {"flags":["alpha"]}} - * - * ```alpha - * bravo() - * ``` - * - * @example - * {"name": "not-ok.md", "setting": ["charlie"], "label": "input"} - * - * ```alpha - * bravo() - * ``` - * - * @example - * {"name": "not-ok.md", "setting": ["charlie"], "label": "output"} - * - * 1:1-3:4: Incorrect code language flag - */ + function visit() { + /** @type {ActionTuple} */ + let result = []; + /** @type {ActionTuple} */ + let subresult; + /** @type {number} */ + let offset; + /** @type {Array.} */ + let grandparents; -const fence = /^ {0,3}([~`])\1{2,}/; + if (!test || is(node, index, parents[parents.length - 1] || null)) { + result = toResult$1(visitor(node, parents)); -const remarkLintFencedCodeFlag = lintRule( - 'remark-lint:fenced-code-flag', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file, option) => { - const value = String(file); - let allowEmpty = false; - /** @type {string[]} */ - let allowed = []; + if (result[0] === EXIT$1) { + return result + } + } - if (typeof option === 'object') { - if (Array.isArray(option)) { - allowed = option; - } else { - allowEmpty = Boolean(option.allowEmpty); + // @ts-expect-error looks like a parent. + if (node.children && result[0] !== SKIP$1) { + // @ts-expect-error looks like a parent. + offset = (reverse ? node.children.length : -1) + step; + // @ts-expect-error looks like a parent. + grandparents = parents.concat(node); - if (option.flags) { - allowed = option.flags; - } - } - } + // @ts-expect-error looks like a parent. + while (offset > -1 && offset < node.children.length) { + // @ts-expect-error looks like a parent. + subresult = factory(node.children[offset], offset, grandparents)(); - visit$2(tree, 'code', (node) => { - if (!generated(node)) { - if (node.lang) { - if (allowed.length > 0 && !allowed.includes(node.lang)) { - file.message('Incorrect code language flag', node); - } - } else { - const slice = value.slice( - pointStart(node).offset, - pointEnd(node).offset - ); + if (subresult[0] === EXIT$1) { + return subresult + } - if (!allowEmpty && fence.test(slice)) { - file.message('Missing code language flag', node); + offset = + typeof subresult[1] === 'number' ? subresult[1] : offset + step; + } } + + return result } } - }); - } -); - -var remarkLintFencedCodeFlag$1 = remarkLintFencedCodeFlag; + } + ); /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module fenced-code-marker - * @fileoverview - * Warn for violating fenced code markers. - * - * Options: `` '`' ``, `'~'`, or `'consistent'`, default: `'consistent'`. - * - * `'consistent'` detects the first used fenced code marker style and warns - * when subsequent fenced code blocks use different styles. - * - * ## Fix - * - * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) - * formats fences using ``'`'`` (grave accent) by default. - * Pass - * [`fence: '~'`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsfence) - * to use `~` (tilde) instead. - * - * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) - * on how to automatically fix warnings for this rule. - * - * @example - * {"name": "ok.md"} - * - * Indented code blocks are not affected by this rule: - * - * bravo() - * - * @example - * {"name": "ok.md", "setting": "`"} - * - * ```alpha - * bravo() - * ``` - * - * ``` - * charlie() - * ``` - * - * @example - * {"name": "ok.md", "setting": "~"} - * - * ~~~alpha - * bravo() - * ~~~ - * - * ~~~ - * charlie() - * ~~~ - * - * @example - * {"name": "not-ok-consistent-tick.md", "label": "input"} - * - * ```alpha - * bravo() - * ``` - * - * ~~~ - * charlie() - * ~~~ - * - * @example - * {"name": "not-ok-consistent-tick.md", "label": "output"} - * - * 5:1-7:4: Fenced code should use `` ` `` as a marker - * - * @example - * {"name": "not-ok-consistent-tilde.md", "label": "input"} - * - * ~~~alpha - * bravo() - * ~~~ - * - * ``` - * charlie() - * ``` - * - * @example - * {"name": "not-ok-consistent-tilde.md", "label": "output"} - * - * 5:1-7:4: Fenced code should use `~` as a marker - * - * @example - * {"name": "not-ok-incorrect.md", "setting": "💩", "label": "output", "positionless": true} - * - * 1:1: Incorrect fenced code marker `💩`: use either `'consistent'`, `` '`' ``, or `'~'` + * @param {VisitorResult} value + * @returns {ActionTuple} */ +function toResult$1(value) { + if (Array.isArray(value)) { + return value + } -const remarkLintFencedCodeMarker = lintRule( - 'remark-lint:fenced-code-marker', - /** @type {import('unified-lint-rule').Rule} */ - (tree, file, option = 'consistent') => { - const contents = String(file); - - if (option !== 'consistent' && option !== '~' && option !== '`') { - file.fail( - 'Incorrect fenced code marker `' + - option + - "`: use either `'consistent'`, `` '`' ``, or `'~'`" - ); - } - - visit$2(tree, 'code', (node) => { - const start = pointStart(node).offset; - - if (typeof start === 'number') { - const marker = contents - .slice(start, start + 4) - .replace(/^\s+/, '') - .charAt(0); - - // Ignore unfenced code blocks. - if (marker === '~' || marker === '`') { - if (option === 'consistent') { - option = marker; - } else if (marker !== option) { - file.message( - 'Fenced code should use `' + - (option === '~' ? option : '` ` `') + - '` as a marker', - node - ); - } - } - } - }); + if (typeof value === 'number') { + return [CONTINUE$1, value] } -); -var remarkLintFencedCodeMarker$1 = remarkLintFencedCodeMarker; + return [value] +} + +/** + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Parent} Parent + * @typedef {import('unist-util-is').Test} Test + * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult + */ /** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module file-extension - * @fileoverview - * Warn when the file extension differ from the preferred extension. - * - * Does not warn when given documents have no file extensions (such as - * `AUTHORS` or `LICENSE`). - * - * Options: `string`, default: `'md'` — Expected file extension. - * - * @example - * {"name": "readme.md"} - * - * @example - * {"name": "readme"} - * - * @example - * {"name": "readme.mkd", "label": "output", "positionless": true} - * - * 1:1: Incorrect extension: use `md` + * Visit children of tree which pass a test * - * @example - * {"name": "readme.mkd", "setting": "mkd"} + * @param tree Abstract syntax tree to walk + * @param test Test, optional + * @param visitor Function to run for each node + * @param reverse Fisit the tree in reverse, defaults to false */ +const visit = + /** + * @type {( + * ((tree: Tree, test: Check, visitor: Visitor, Check>>, reverse?: boolean) => void) & + * ((tree: Tree, visitor: Visitor>, reverse?: boolean) => void) + * )} + */ + ( + /** + * @param {Node} tree + * @param {Test} test + * @param {Visitor} visitor + * @param {boolean} [reverse] + */ + function (tree, test, visitor, reverse) { + if (typeof test === 'function' && typeof visitor !== 'function') { + reverse = visitor; + visitor = test; + test = null; + } -const remarkLintFileExtension = lintRule( - 'remark-lint:file-extension', - /** @type {import('unified-lint-rule').Rule} */ - (_, file, option = 'md') => { - const ext = file.extname; + visitParents$1(tree, test, overload, reverse); - if (ext && ext.slice(1) !== option) { - file.message('Incorrect extension: use `' + option + '`'); + /** + * @param {Node} node + * @param {Array.} parents + */ + function overload(node, parents) { + const parent = parents[parents.length - 1]; + return visitor( + node, + parent ? parent.children.indexOf(node) : null, + parent + ) + } } - } -); - -var remarkLintFileExtension$1 = remarkLintFileExtension; + ); /** * @author Titus Wormer * @copyright 2015 Titus Wormer * @license MIT - * @module final-definition + * @module list-item-bullet-indent * @fileoverview - * Warn when definitions are placed somewhere other than at the end of - * the file. + * Warn when list item bullets are indented. + * + * ## Fix + * + * [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) + * removes all indentation before bullets. + * + * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) + * on how to automatically fix warnings for this rule. * * @example * {"name": "ok.md"} * * Paragraph. * - * [example]: http://example.com "Example Domain" + * * List item + * * List item * * @example * {"name": "not-ok.md", "label": "input"} * * Paragraph. * - * [example]: http://example.com "Example Domain" - * - * Another paragraph. + * ·* List item + * ·* List item * * @example * {"name": "not-ok.md", "label": "output"} * - * 3:1-3:47: Move definitions to the end of the file (after the node at line `5`) - * - * @example - * {"name": "ok-comments.md"} - * - * Paragraph. - * - * [example-1]: http://example.com/one/ - * - * - * - * [example-2]: http://example.com/two/ + * 3:2: Incorrect indentation before bullet: remove 1 space + * 4:2: Incorrect indentation before bullet: remove 1 space */ -const remarkLintFinalDefinition = lintRule( - 'remark-lint:final-definition', +const remarkLintListItemBulletIndent = lintRule$F( + 'remark-lint:list-item-bullet-indent', /** @type {import('unified-lint-rule').Rule} */ (tree, file) => { - let last = 0; + visit(tree, 'list', (list, _, grandparent) => { + let index = -1; + + while (++index < list.children.length) { + const item = list.children[index]; - visit$2( - tree, - (node) => { - // Ignore generated and HTML comment nodes. if ( - node.type === 'root' || - generated(node) || - (node.type === 'html' && /^\s* + * + * [example-2]: http://example.com/two/ + */ - ch = state.input.charCodeAt(state.position); +const remarkLintFinalDefinition = lintRule$j( + 'remark-lint:final-definition', + /** @type {import('unified-lint-rule').Rule} */ + (tree, file) => { + let last = 0; - if (ch === 0x5B/* [ */) { - terminator = 0x5D;/* ] */ - isMapping = false; - _result = []; - } else if (ch === 0x7B/* { */) { - terminator = 0x7D;/* } */ - isMapping = true; - _result = {}; - } else { - return false; - } + visit( + tree, + (node) => { + // Ignore generated and HTML comment nodes. + if ( + node.type === 'root' || + generated(node) || + (node.type === 'html' && /^\s*\n\n' - } - } - - return '\n\n' - } -} - -/** - * @callback Map - * @param {string} value - * @param {number} line - * @param {boolean} blank - * @returns {string} - */ - -const eol = /\r?\n|\r/g; - -/** - * @param {string} value - * @param {Map} map - * @returns {string} - */ -function indentLines(value, map) { - /** @type {Array.} */ - const result = []; - let start = 0; - let line = 0; - /** @type {RegExpExecArray|null} */ - let match; - - while ((match = eol.exec(value))) { - one(value.slice(start, match.index)); - result.push(match[0]); - start = match.index + match[0].length; - line++; - } - - one(value.slice(start)); - - return result.join('') - - /** - * @param {string} value - */ - function one(value) { - result.push(map(value, line, !value)); - } -} - -/** - * @typedef {import('mdast').ListItem} ListItem - * @typedef {import('mdast').List} List - * @typedef {import('../util/indent-lines.js').Map} Map - * @typedef {import('../types.js').Options} Options - * @typedef {import('../types.js').Handle} Handle - */ - -/** - * @type {Handle} - * @param {ListItem} node - */ -function listItem(node, parent, context) { - const listItemIndent = checkListItemIndent(context); - /** @type {string} */ - let bullet = checkBullet(context); - - if (parent && parent.type === 'list' && parent.ordered) { - bullet = - (typeof parent.start === 'number' && parent.start > -1 - ? parent.start - : 1) + - (context.options.incrementListMarker === false - ? 0 - : parent.children.indexOf(node)) + - '.'; - } - - let size = bullet.length + 1; - - if ( - listItemIndent === 'tab' || - (listItemIndent === 'mixed' && - ((parent && 'spread' in parent && parent.spread) || node.spread)) - ) { - size = Math.ceil(size / 4) * 4; - } - - const exit = context.enter('listItem'); - const value = indentLines(containerFlow(node, context), map); - exit(); - - return value - - /** @type {Map} */ - function map(line, index, blank) { - if (index) { - return (blank ? '' : ' '.repeat(size)) + line - } - - return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line - } -} - /** * @typedef {import('mdast').ListItem} ListItem * @typedef {import('mdast').Paragraph} Paragraph @@ -65829,7 +61261,7 @@ function gfmToMarkdown(options) { function remarkGfm(options = {}) { const data = this.data(); - add('micromarkExtensions', gfm$1(options)); + add('micromarkExtensions', gfm(options)); add('fromMarkdownExtensions', gfmFromMarkdown); add('toMarkdownExtensions', gfmToMarkdown(options)); @@ -65848,26 +61280,10 @@ function remarkGfm(options = {}) { } } -var remarkGfm$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - 'default': remarkGfm -}); - -var require$$6 = /*@__PURE__*/getAugmentedNamespace(remarkGfm$1); - // To aid in future maintenance, this layout closely matches remark-cli/cli.js. -// https://github.com/remarkjs/remark/blob/master/packages/remark-cli/cli.js - -const start = unifiedArgs; -const extensions = markdownExtensions; -const processor = remark; -const proc = require$$3; -const cli = require$$4; -const lintNode = require$$5; -const gfm = require$$6; - -start({ - processor: processor().use(gfm).use(lintNode), + +args({ + processor: remark().use(remarkGfm).use(remarkPresetLintNode), name: proc.name, description: cli.description, version: [ @@ -65879,8 +61295,6 @@ start({ packageField: proc.name + 'Config', rcName: '.' + proc.name + 'rc', ignoreName: '.' + proc.name + 'ignore', - extensions: extensions, + extensions: markdownExtensions, detectConfig: false, }); - -module.exports = cliEntry; diff --git a/tools/node-lint-md-cli-rollup/package-lock.json b/tools/node-lint-md-cli-rollup/package-lock.json index baf5c94d622b90..3cfe12696fad45 100644 --- a/tools/node-lint-md-cli-rollup/package-lock.json +++ b/tools/node-lint-md-cli-rollup/package-lock.json @@ -579,11 +579,11 @@ } }, "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -740,19 +740,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/hast-util-from-parse5/node_modules/vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "dependencies": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/hast-util-is-element": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-2.1.1.tgz", @@ -799,15 +786,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/hast-util-to-html/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/hast-util-whitespace": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-2.0.0.tgz", @@ -1184,26 +1162,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", - "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mdast-util-find-and-replace/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", @@ -2133,51 +2091,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-blockquote-indentation/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-blockquote-indentation/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-blockquote-indentation/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-blockquote-indentation/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/remark-lint-checkbox-character-style": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/remark-lint-checkbox-character-style/-/remark-lint-checkbox-character-style-4.0.0.tgz", @@ -2209,51 +2122,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-checkbox-character-style/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-checkbox-character-style/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-checkbox-character-style/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-checkbox-character-style/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/remark-lint-checkbox-content-indent": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/remark-lint-checkbox-content-indent/-/remark-lint-checkbox-content-indent-4.0.0.tgz", @@ -2286,57 +2154,62 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-checkbox-content-indent/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-checkbox-content-indent/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", + "node_modules/remark-lint-code-block-style": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-code-block-style/-/remark-lint-code-block-style-3.0.0.tgz", + "integrity": "sha512-xZMfFeaMOb5OIM4SrNz3QTRV3u5g3/+e6Oq40A3Apwd+a9Kx49lZbGxl8vfqaczP89PTNanm2e4OqqRsCen4Mg==", + "dependencies": { + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-checkbox-content-indent/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-code-block-style/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-checkbox-content-indent/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-definition-spacing": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-definition-spacing/-/remark-lint-definition-spacing-3.0.0.tgz", + "integrity": "sha512-3LxU7lwCpfPstldcGly2ULb8knH4IOqZHoABT2KyKFw3rRFUCAEUBSl0k5eetnXXNc/X4NlHmnyjIyzhyl4PhA==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-checkbox-content-indent/node_modules/vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", + "node_modules/remark-lint-definition-spacing/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", + "trough": "^2.0.0", + "unified": "^10.0.0", "vfile": "^5.0.0" }, "funding": { @@ -2344,10 +2217,10 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-code-block-style": { + "node_modules/remark-lint-fenced-code-flag": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-code-block-style/-/remark-lint-code-block-style-3.0.0.tgz", - "integrity": "sha512-xZMfFeaMOb5OIM4SrNz3QTRV3u5g3/+e6Oq40A3Apwd+a9Kx49lZbGxl8vfqaczP89PTNanm2e4OqqRsCen4Mg==", + "resolved": "https://registry.npmjs.org/remark-lint-fenced-code-flag/-/remark-lint-fenced-code-flag-3.0.0.tgz", + "integrity": "sha512-wvyaTvQ5F78yuw4BDQsneTCvkxHGAjq0OuDQU4pawAZMYO3qFJlau7qoLppgquY1D+jBakejMT/yKnoQgRf1dQ==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", @@ -2361,7 +2234,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-code-block-style/node_modules/unified-lint-rule": { + "node_modules/remark-lint-fenced-code-flag/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2376,59 +2249,75 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-code-block-style/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", + "node_modules/remark-lint-fenced-code-marker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-fenced-code-marker/-/remark-lint-fenced-code-marker-3.0.0.tgz", + "integrity": "sha512-x3wr1+22Atr72Z7+dUS8cqwuz8m8d4UgCAfBTNO+E6pRLVeCnVMvEtuJbDI5UqBlqvkLGlNofV4lJZQvrZUxqQ==", + "dependencies": { + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-code-block-style/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", + "node_modules/remark-lint-fenced-code-marker/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", + "dependencies": { + "@types/unist": "^2.0.0", + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-code-block-style/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-file-extension": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-file-extension/-/remark-lint-file-extension-2.0.0.tgz", + "integrity": "sha512-fZ0nDGyuZSgkrakLKl+cjqXwOT7iAz0wfSbrkCabYW3DdN6X1QYeSlMtHPizGXuri+AZhVkrUnujSn+9P4hJ2w==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-code-block-style/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-file-extension/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-definition-spacing": { + "node_modules/remark-lint-final-definition": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-definition-spacing/-/remark-lint-definition-spacing-3.0.0.tgz", - "integrity": "sha512-3LxU7lwCpfPstldcGly2ULb8knH4IOqZHoABT2KyKFw3rRFUCAEUBSl0k5eetnXXNc/X4NlHmnyjIyzhyl4PhA==", + "resolved": "https://registry.npmjs.org/remark-lint-final-definition/-/remark-lint-final-definition-3.0.0.tgz", + "integrity": "sha512-RHR8aku0jCH4AoHVepw9b0tCmiBevMtLPG1l5FKhbkLtBWk9GRRryuD3GExxsInEUN2P/a6FhvcBBtRSJbIfIA==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", "unist-util-position": "^4.0.0", "unist-util-visit": "^4.0.0" }, @@ -2437,7 +2326,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-definition-spacing/node_modules/unified-lint-rule": { + "node_modules/remark-lint-final-definition/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2452,61 +2341,44 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-definition-spacing/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-definition-spacing/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-definition-spacing/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-final-newline/-/remark-lint-final-newline-2.0.0.tgz", + "integrity": "sha512-3u1IbgVfUN5Qgid8iqc1qlZhzscs4YPu8mwyahvLWVKMkBtoRWjDIVL6+CXcPPoUB2k3p+zuZ5oaE4yfO5Pb4w==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-definition-spacing/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-final-newline/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-fenced-code-flag": { + "node_modules/remark-lint-first-heading-level": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-fenced-code-flag/-/remark-lint-fenced-code-flag-3.0.0.tgz", - "integrity": "sha512-wvyaTvQ5F78yuw4BDQsneTCvkxHGAjq0OuDQU4pawAZMYO3qFJlau7qoLppgquY1D+jBakejMT/yKnoQgRf1dQ==", + "resolved": "https://registry.npmjs.org/remark-lint-first-heading-level/-/remark-lint-first-heading-level-3.0.0.tgz", + "integrity": "sha512-SMvBHO4HJd1ZkFDfx7OikJAoq5FQe+nFPm3n4DeAKIgM1FywaC7tD7ShwTRUL2DJMzdPjlta7UQRtTryAQGj+w==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", "unist-util-visit": "^4.0.0" }, "funding": { @@ -2514,7 +2386,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-fenced-code-flag/node_modules/unified-lint-rule": { + "node_modules/remark-lint-first-heading-level/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2529,60 +2401,48 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-fenced-code-flag/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-fenced-code-flag/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-fenced-code-flag/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-hard-break-spaces": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-hard-break-spaces/-/remark-lint-hard-break-spaces-3.0.0.tgz", + "integrity": "sha512-TNTI32Va6hE33pTYC6iqn4NvyZHqCULsOKKLnAzBocFFFIYuaNUdfKyVc9wknAAutbQLqApr8tgs1mLHtHm9Fw==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-fenced-code-flag/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-hard-break-spaces/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-fenced-code-marker": { + "node_modules/remark-lint-heading-style": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-fenced-code-marker/-/remark-lint-fenced-code-marker-3.0.0.tgz", - "integrity": "sha512-x3wr1+22Atr72Z7+dUS8cqwuz8m8d4UgCAfBTNO+E6pRLVeCnVMvEtuJbDI5UqBlqvkLGlNofV4lJZQvrZUxqQ==", + "resolved": "https://registry.npmjs.org/remark-lint-heading-style/-/remark-lint-heading-style-3.0.0.tgz", + "integrity": "sha512-pPiXG24yXER7xXZr+J11iuMd1DXa71m6Cx7jqUO5z1Ptc7WkolcW6lNRFG76BCOJp8Jp6vH5eNITuQxYa0AnJw==", "dependencies": { "@types/mdast": "^3.0.0", + "mdast-util-heading-style": "^2.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", - "unist-util-position": "^4.0.0", + "unist-util-generated": "^2.0.0", "unist-util-visit": "^4.0.0" }, "funding": { @@ -2590,7 +2450,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-fenced-code-marker/node_modules/unified-lint-rule": { + "node_modules/remark-lint-heading-style/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2605,66 +2465,56 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-fenced-code-marker/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-fenced-code-marker/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-fenced-code-marker/node_modules/unist-util-visit": { + "node_modules/remark-lint-list-item-bullet-indent": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "resolved": "https://registry.npmjs.org/remark-lint-list-item-bullet-indent/-/remark-lint-list-item-bullet-indent-4.0.0.tgz", + "integrity": "sha512-b/U3wAJPE00xGQGYBvjPPsdXsBPJxUvITYgAZee7aA2sGEiflMGmg90anS2sJZEAoD4XtNzp96bPaY6QLN89dQ==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "pluralize": "^8.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-fenced-code-marker/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-list-item-bullet-indent/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-file-extension": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-file-extension/-/remark-lint-file-extension-2.0.0.tgz", - "integrity": "sha512-fZ0nDGyuZSgkrakLKl+cjqXwOT7iAz0wfSbrkCabYW3DdN6X1QYeSlMtHPizGXuri+AZhVkrUnujSn+9P4hJ2w==", + "node_modules/remark-lint-list-item-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-list-item-indent/-/remark-lint-list-item-indent-3.0.0.tgz", + "integrity": "sha512-z7doG/aJCy8ivmfbE/cSm9HOpIeUaV5zZHMqSsZ6XZ+wXIj4wtMFVhI7fsAVs5pAB1gzSvZQuwJOfSs2//Fw2g==", "dependencies": { "@types/mdast": "^3.0.0", + "pluralize": "^8.0.0", "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0" + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-file-extension/node_modules/unified-lint-rule": { + "node_modules/remark-lint-list-item-indent/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2679,10 +2529,10 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-final-definition": { + "node_modules/remark-lint-maximum-line-length": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-final-definition/-/remark-lint-final-definition-3.0.0.tgz", - "integrity": "sha512-RHR8aku0jCH4AoHVepw9b0tCmiBevMtLPG1l5FKhbkLtBWk9GRRryuD3GExxsInEUN2P/a6FhvcBBtRSJbIfIA==", + "resolved": "https://registry.npmjs.org/remark-lint-maximum-line-length/-/remark-lint-maximum-line-length-3.0.0.tgz", + "integrity": "sha512-0x5TsUDlc4IDPUObNjVtcQxzI1JokUwbVpr22akWypnZaX9QMIL+Cp1OXrKRknZVU3rIndt4QCNnjMEYKezn1g==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", @@ -2696,7 +2546,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-final-definition/node_modules/unified-lint-rule": { + "node_modules/remark-lint-maximum-line-length/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2711,66 +2561,92 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-final-definition/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", + "node_modules/remark-lint-no-auto-link-without-protocol": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-auto-link-without-protocol/-/remark-lint-no-auto-link-without-protocol-3.0.0.tgz", + "integrity": "sha512-qeJhWZcO0wnavTdpLU6M1q5RBfo4nZnYmzASoSCmIj/ZxIinluXLmLcMHC2Ol46egWdvwDNpr3V0dJP79fiJMQ==", + "dependencies": { + "@types/mdast": "^3.0.0", + "mdast-util-to-string": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-final-definition/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", + "node_modules/remark-lint-no-auto-link-without-protocol/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", + "dependencies": { + "@types/unist": "^2.0.0", + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-final-definition/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-no-blockquote-without-marker": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-blockquote-without-marker/-/remark-lint-no-blockquote-without-marker-5.0.0.tgz", + "integrity": "sha512-6m1KZE8X2OhNV9wpEPVUfFxdzgVD523unRkstlRedKC3ONLlqP/CIliAOITRmIGuUxXVjyD7mDC892bFJnJTfw==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0", + "vfile-location": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-final-definition/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-no-blockquote-without-marker/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-final-newline/-/remark-lint-final-newline-2.0.0.tgz", - "integrity": "sha512-3u1IbgVfUN5Qgid8iqc1qlZhzscs4YPu8mwyahvLWVKMkBtoRWjDIVL6+CXcPPoUB2k3p+zuZ5oaE4yfO5Pb4w==", + "node_modules/remark-lint-no-consecutive-blank-lines": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-consecutive-blank-lines/-/remark-lint-no-consecutive-blank-lines-4.0.0.tgz", + "integrity": "sha512-gP1b3lM+oemvA0WOC5HbvkjESG2BiZHL8ZDSX+wbg/2+7zu14rOmAAMiUOlk/CxbusttwJxsz8a/Wn1dEK/jPg==", "dependencies": { "@types/mdast": "^3.0.0", + "@types/unist": "^2.0.0", + "pluralize": "^8.0.0", "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0" + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-final-newline/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-consecutive-blank-lines/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2785,15 +2661,17 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-first-heading-level": { + "node_modules/remark-lint-no-duplicate-definitions": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-first-heading-level/-/remark-lint-first-heading-level-3.0.0.tgz", - "integrity": "sha512-SMvBHO4HJd1ZkFDfx7OikJAoq5FQe+nFPm3n4DeAKIgM1FywaC7tD7ShwTRUL2DJMzdPjlta7UQRtTryAQGj+w==", + "resolved": "https://registry.npmjs.org/remark-lint-no-duplicate-definitions/-/remark-lint-no-duplicate-definitions-3.0.0.tgz", + "integrity": "sha512-6VOGPegh2ZQ0d9yronmhNXhg2wLYA5litT7bC1ljg2LQwMTIjYOgJbJsQJSKWD+FiHuqVhdWvXHzyTbFCch8Aw==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-stringify-position": "^3.0.0", "unist-util-visit": "^4.0.0" }, "funding": { @@ -2801,7 +2679,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-first-heading-level/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-duplicate-definitions/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2816,60 +2694,50 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-first-heading-level/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-first-heading-level/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-no-file-name-articles": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-articles/-/remark-lint-no-file-name-articles-2.0.0.tgz", + "integrity": "sha512-PgyJXEsZDT2r1bvtwaChwTjYKPxo47/OxpJmiozwLcnPsBNbsDtrH+W5gIjNkvkENNcIQD48WZ9jIwyJiskBng==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-first-heading-level/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-no-file-name-articles/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-hard-break-spaces": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-hard-break-spaces/-/remark-lint-hard-break-spaces-3.0.0.tgz", - "integrity": "sha512-TNTI32Va6hE33pTYC6iqn4NvyZHqCULsOKKLnAzBocFFFIYuaNUdfKyVc9wknAAutbQLqApr8tgs1mLHtHm9Fw==", + "node_modules/remark-lint-no-file-name-consecutive-dashes": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-consecutive-dashes/-/remark-lint-no-file-name-consecutive-dashes-2.0.0.tgz", + "integrity": "sha512-o7yz//+vel7IFDoZ/M0BmOS4sVE3sTAFOkeYlH44meGbNnEudr+TKKa0lwopMqZHKhXgUPSayCq+D5dgRO6JLA==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" + "unified-lint-rule": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-hard-break-spaces/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-file-name-consecutive-dashes/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2884,61 +2752,47 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-hard-break-spaces/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-hard-break-spaces/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-hard-break-spaces/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-no-file-name-outer-dashes": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-outer-dashes/-/remark-lint-no-file-name-outer-dashes-2.0.0.tgz", + "integrity": "sha512-SZS9FeGLty0wOBLTKyboDUZpjIKMihH88ZvgdqCUgIiDlZ9/72JKtZv43UuMnMVRgKJWQCRyZtT3nSNw3HwM+g==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-hard-break-spaces/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-no-file-name-outer-dashes/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-heading-style": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-heading-style/-/remark-lint-heading-style-3.0.0.tgz", - "integrity": "sha512-pPiXG24yXER7xXZr+J11iuMd1DXa71m6Cx7jqUO5z1Ptc7WkolcW6lNRFG76BCOJp8Jp6vH5eNITuQxYa0AnJw==", + "node_modules/remark-lint-no-heading-content-indent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-heading-content-indent/-/remark-lint-no-heading-content-indent-4.0.0.tgz", + "integrity": "sha512-2SljHUYTN83EN5DEZrl7WH4ibmUxai6gONhZaQrQOJyGUO2ReZj5Zdn4xi79NHpORSzCzjn2tSXPB6yL3AhJag==", "dependencies": { "@types/mdast": "^3.0.0", "mdast-util-heading-style": "^2.0.0", + "pluralize": "^8.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", "unist-util-visit": "^4.0.0" }, "funding": { @@ -2946,7 +2800,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-heading-style/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-heading-content-indent/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -2961,51 +2815,49 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-heading-style/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-heading-style/node_modules/unist-util-visit": { + "node_modules/remark-lint-no-heading-indent": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "resolved": "https://registry.npmjs.org/remark-lint-no-heading-indent/-/remark-lint-no-heading-indent-4.0.0.tgz", + "integrity": "sha512-t4MWiMjPH6TOdM8d5i5Eik6NVrOokoYy6z0GnuI7PNrmNmVVIV9CVBJU94aSXZ7friKx5ucvUEw6NhXIRcNtOw==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "pluralize": "^8.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-heading-style/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-no-heading-indent/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-bullet-indent": { + "node_modules/remark-lint-no-inline-padding": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-list-item-bullet-indent/-/remark-lint-list-item-bullet-indent-4.0.0.tgz", - "integrity": "sha512-b/U3wAJPE00xGQGYBvjPPsdXsBPJxUvITYgAZee7aA2sGEiflMGmg90anS2sJZEAoD4XtNzp96bPaY6QLN89dQ==", + "resolved": "https://registry.npmjs.org/remark-lint-no-inline-padding/-/remark-lint-no-inline-padding-4.0.0.tgz", + "integrity": "sha512-dugEtHudM/UVQYzTbQoWy4aeG9Micd9g6O/uzN59sIMM8Xb+Srbv/p5/2JNtJWej9PmzINldE0AHjpuB8NiNLA==", "dependencies": { "@types/mdast": "^3.0.0", - "pluralize": "^8.0.0", + "mdast-util-to-string": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", "unist-util-visit": "^4.0.0" }, "funding": { @@ -3013,7 +2865,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-bullet-indent/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-inline-padding/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -3028,53 +2880,50 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-bullet-indent/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-list-item-bullet-indent/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-no-literal-urls": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-literal-urls/-/remark-lint-no-literal-urls-3.0.0.tgz", + "integrity": "sha512-P+9VxemAeSGWGMmFGKcQMIsPgVDaoXnQLl0Bx/TuBms0Favb7XI3ecii/HjjDeks3zlrxlVhzvEkHBk1uH1tdA==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "mdast-util-to-string": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-bullet-indent/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-no-literal-urls/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-indent": { + "node_modules/remark-lint-no-multiple-toplevel-headings": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-list-item-indent/-/remark-lint-list-item-indent-3.0.0.tgz", - "integrity": "sha512-z7doG/aJCy8ivmfbE/cSm9HOpIeUaV5zZHMqSsZ6XZ+wXIj4wtMFVhI7fsAVs5pAB1gzSvZQuwJOfSs2//Fw2g==", + "resolved": "https://registry.npmjs.org/remark-lint-no-multiple-toplevel-headings/-/remark-lint-no-multiple-toplevel-headings-3.0.0.tgz", + "integrity": "sha512-HzPTSy9nu9RHSIUfZCbxEa7KP4CoKNbfI4SW8txh7KnYwr6vC6QgqXPF77z1sIpiSgD9X2z0LwMk0DBk1v3bmA==", "dependencies": { "@types/mdast": "^3.0.0", - "pluralize": "^8.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", "unist-util-generated": "^2.0.0", "unist-util-position": "^4.0.0", + "unist-util-stringify-position": "^3.0.0", "unist-util-visit": "^4.0.0" }, "funding": { @@ -3082,7 +2931,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-indent/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-multiple-toplevel-headings/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -3097,61 +2946,77 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-indent/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", + "node_modules/remark-lint-no-shell-dollars": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-shell-dollars/-/remark-lint-no-shell-dollars-3.0.0.tgz", + "integrity": "sha512-jygHSWi+w7C/VT6+oKIMHhrnMlURWF+ohjdtkxDc/C/7FXWyHg1nJR2t+c+j5Dmirz3oSfInSGw/jUfYP048GQ==", + "dependencies": { + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-visit": "^4.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-indent/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", + "node_modules/remark-lint-no-shell-dollars/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", + "dependencies": { + "@types/unist": "^2.0.0", + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-indent/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-no-shortcut-reference-image": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-no-shortcut-reference-image/-/remark-lint-no-shortcut-reference-image-3.0.0.tgz", + "integrity": "sha512-PyB5xkCd8moJf1MrmIXlBTSXZ8pkjXtdrmHzYba7La8S/6TKN2+LFrfN9daLG9pVsD0DSBAlvbajM/MBFh2DfQ==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-list-item-indent/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-no-shortcut-reference-image/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-maximum-line-length": { + "node_modules/remark-lint-no-shortcut-reference-link": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-maximum-line-length/-/remark-lint-maximum-line-length-3.0.0.tgz", - "integrity": "sha512-0x5TsUDlc4IDPUObNjVtcQxzI1JokUwbVpr22akWypnZaX9QMIL+Cp1OXrKRknZVU3rIndt4QCNnjMEYKezn1g==", + "resolved": "https://registry.npmjs.org/remark-lint-no-shortcut-reference-link/-/remark-lint-no-shortcut-reference-link-3.0.0.tgz", + "integrity": "sha512-SbPrP6ZfRA2IJ++L7xAivXl7PJdOMzBUlhVwlt5PsWJKWHX07TIB02GGAiMnSOLN0FnUCvgF2c5we6eU1K3plA==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", "unist-util-visit": "^4.0.0" }, "funding": { @@ -3159,7 +3024,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-maximum-line-length/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-shortcut-reference-link/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -3174,1452 +3039,54 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-maximum-line-length/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-maximum-line-length/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-maximum-line-length/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-maximum-line-length/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-auto-link-without-protocol": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-auto-link-without-protocol/-/remark-lint-no-auto-link-without-protocol-3.0.0.tgz", - "integrity": "sha512-qeJhWZcO0wnavTdpLU6M1q5RBfo4nZnYmzASoSCmIj/ZxIinluXLmLcMHC2Ol46egWdvwDNpr3V0dJP79fiJMQ==", - "dependencies": { - "@types/mdast": "^3.0.0", - "mdast-util-to-string": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-auto-link-without-protocol/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-auto-link-without-protocol/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-auto-link-without-protocol/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-auto-link-without-protocol/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-auto-link-without-protocol/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-blockquote-without-marker": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-blockquote-without-marker/-/remark-lint-no-blockquote-without-marker-5.0.0.tgz", - "integrity": "sha512-6m1KZE8X2OhNV9wpEPVUfFxdzgVD523unRkstlRedKC3ONLlqP/CIliAOITRmIGuUxXVjyD7mDC892bFJnJTfw==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0", - "vfile-location": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-blockquote-without-marker/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-blockquote-without-marker/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-blockquote-without-marker/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-blockquote-without-marker/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-blockquote-without-marker/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-blockquote-without-marker/node_modules/vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "dependencies": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-consecutive-blank-lines": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-consecutive-blank-lines/-/remark-lint-no-consecutive-blank-lines-4.0.0.tgz", - "integrity": "sha512-gP1b3lM+oemvA0WOC5HbvkjESG2BiZHL8ZDSX+wbg/2+7zu14rOmAAMiUOlk/CxbusttwJxsz8a/Wn1dEK/jPg==", - "dependencies": { - "@types/mdast": "^3.0.0", - "@types/unist": "^2.0.0", - "pluralize": "^8.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-consecutive-blank-lines/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-consecutive-blank-lines/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-consecutive-blank-lines/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-consecutive-blank-lines/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-consecutive-blank-lines/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-duplicate-definitions": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-duplicate-definitions/-/remark-lint-no-duplicate-definitions-3.0.0.tgz", - "integrity": "sha512-6VOGPegh2ZQ0d9yronmhNXhg2wLYA5litT7bC1ljg2LQwMTIjYOgJbJsQJSKWD+FiHuqVhdWvXHzyTbFCch8Aw==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-stringify-position": "^3.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-duplicate-definitions/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-duplicate-definitions/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-duplicate-definitions/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-duplicate-definitions/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-duplicate-definitions/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-file-name-articles": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-articles/-/remark-lint-no-file-name-articles-2.0.0.tgz", - "integrity": "sha512-PgyJXEsZDT2r1bvtwaChwTjYKPxo47/OxpJmiozwLcnPsBNbsDtrH+W5gIjNkvkENNcIQD48WZ9jIwyJiskBng==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-file-name-articles/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-file-name-consecutive-dashes": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-consecutive-dashes/-/remark-lint-no-file-name-consecutive-dashes-2.0.0.tgz", - "integrity": "sha512-o7yz//+vel7IFDoZ/M0BmOS4sVE3sTAFOkeYlH44meGbNnEudr+TKKa0lwopMqZHKhXgUPSayCq+D5dgRO6JLA==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-file-name-consecutive-dashes/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-file-name-outer-dashes": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-file-name-outer-dashes/-/remark-lint-no-file-name-outer-dashes-2.0.0.tgz", - "integrity": "sha512-SZS9FeGLty0wOBLTKyboDUZpjIKMihH88ZvgdqCUgIiDlZ9/72JKtZv43UuMnMVRgKJWQCRyZtT3nSNw3HwM+g==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-file-name-outer-dashes/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-content-indent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-heading-content-indent/-/remark-lint-no-heading-content-indent-4.0.0.tgz", - "integrity": "sha512-2SljHUYTN83EN5DEZrl7WH4ibmUxai6gONhZaQrQOJyGUO2ReZj5Zdn4xi79NHpORSzCzjn2tSXPB6yL3AhJag==", - "dependencies": { - "@types/mdast": "^3.0.0", - "mdast-util-heading-style": "^2.0.0", - "pluralize": "^8.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-content-indent/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-content-indent/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-content-indent/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-content-indent/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-content-indent/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-indent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-heading-indent/-/remark-lint-no-heading-indent-4.0.0.tgz", - "integrity": "sha512-t4MWiMjPH6TOdM8d5i5Eik6NVrOokoYy6z0GnuI7PNrmNmVVIV9CVBJU94aSXZ7friKx5ucvUEw6NhXIRcNtOw==", - "dependencies": { - "@types/mdast": "^3.0.0", - "pluralize": "^8.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-indent/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-indent/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-indent/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-indent/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-heading-indent/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-inline-padding": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-inline-padding/-/remark-lint-no-inline-padding-4.0.0.tgz", - "integrity": "sha512-dugEtHudM/UVQYzTbQoWy4aeG9Micd9g6O/uzN59sIMM8Xb+Srbv/p5/2JNtJWej9PmzINldE0AHjpuB8NiNLA==", - "dependencies": { - "@types/mdast": "^3.0.0", - "mdast-util-to-string": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-inline-padding/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-inline-padding/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-inline-padding/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-inline-padding/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-literal-urls": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-literal-urls/-/remark-lint-no-literal-urls-3.0.0.tgz", - "integrity": "sha512-P+9VxemAeSGWGMmFGKcQMIsPgVDaoXnQLl0Bx/TuBms0Favb7XI3ecii/HjjDeks3zlrxlVhzvEkHBk1uH1tdA==", - "dependencies": { - "@types/mdast": "^3.0.0", - "mdast-util-to-string": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-literal-urls/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-literal-urls/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-literal-urls/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-literal-urls/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-literal-urls/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-multiple-toplevel-headings": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-multiple-toplevel-headings/-/remark-lint-no-multiple-toplevel-headings-3.0.0.tgz", - "integrity": "sha512-HzPTSy9nu9RHSIUfZCbxEa7KP4CoKNbfI4SW8txh7KnYwr6vC6QgqXPF77z1sIpiSgD9X2z0LwMk0DBk1v3bmA==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-stringify-position": "^3.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-multiple-toplevel-headings/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-multiple-toplevel-headings/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-multiple-toplevel-headings/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-multiple-toplevel-headings/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-multiple-toplevel-headings/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shell-dollars": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-shell-dollars/-/remark-lint-no-shell-dollars-3.0.0.tgz", - "integrity": "sha512-jygHSWi+w7C/VT6+oKIMHhrnMlURWF+ohjdtkxDc/C/7FXWyHg1nJR2t+c+j5Dmirz3oSfInSGw/jUfYP048GQ==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shell-dollars/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shell-dollars/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shell-dollars/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shell-dollars/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-image": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-shortcut-reference-image/-/remark-lint-no-shortcut-reference-image-3.0.0.tgz", - "integrity": "sha512-PyB5xkCd8moJf1MrmIXlBTSXZ8pkjXtdrmHzYba7La8S/6TKN2+LFrfN9daLG9pVsD0DSBAlvbajM/MBFh2DfQ==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-image/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-image/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-image/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-image/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-link": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-shortcut-reference-link/-/remark-lint-no-shortcut-reference-link-3.0.0.tgz", - "integrity": "sha512-SbPrP6ZfRA2IJ++L7xAivXl7PJdOMzBUlhVwlt5PsWJKWHX07TIB02GGAiMnSOLN0FnUCvgF2c5we6eU1K3plA==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-link/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-link/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-link/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-shortcut-reference-link/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-table-indentation": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-table-indentation/-/remark-lint-no-table-indentation-4.0.0.tgz", - "integrity": "sha512-S1u4DHBS75xAcM/u1zsYize/0uB2u+xAoHbstN3JmFWsTRj5LUSppwkSrWsPk/3y9/jHJAQ4XSihwH7C95EObQ==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0", - "vfile-location": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-table-indentation/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-table-indentation/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-table-indentation/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-table-indentation/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-table-indentation/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-table-indentation/node_modules/vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "dependencies": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-tabs": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-tabs/-/remark-lint-no-tabs-3.0.0.tgz", - "integrity": "sha512-iK5gXQLoBchviHRNNDIWKQsMAbsLIZzK2ZKo0ywzNBHBckd8fy+wIP6RUosb6p/RBHtq1JG1lUC5ADg1PSj0tQ==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "vfile-location": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-tabs/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-tabs/node_modules/vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "dependencies": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-trailing-spaces": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/remark-lint-no-trailing-spaces/-/remark-lint-no-trailing-spaces-2.0.1.tgz", - "integrity": "sha512-cj8t+nvtO6eAY2lJC7o5du8VeOCK13XiDUHL4U6k5aw6ZLr3EYWbQ/rNc6cr60eHkh5Ldm09KiZjV3CWpxqJ0g==", - "dependencies": { - "unified-lint-rule": "^1.0.2" - } - }, - "node_modules/remark-lint-no-undefined-references": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-undefined-references/-/remark-lint-no-undefined-references-4.0.0.tgz", - "integrity": "sha512-HI68vLoTTCXDADAp8LQ6RqCuf9QHX7bSaaqKI1V82EyvizxgnFtvN46XIi1uiDTN+Jv/KzAAGaFrofV8OJknBA==", - "dependencies": { - "@types/mdast": "^3.0.0", - "micromark-util-normalize-identifier": "^1.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0", - "vfile-location": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-undefined-references/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-undefined-references/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-undefined-references/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-undefined-references/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-undefined-references/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-undefined-references/node_modules/vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "dependencies": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-unused-definitions": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-unused-definitions/-/remark-lint-no-unused-definitions-3.0.0.tgz", - "integrity": "sha512-1LqEZx0IJx59ezXA9e0qq6h5W3n9I6oiBm3Kl+HvmXTFl1OME6f8SVFwtDbt9EaGmf+3NL+T24cWIhZWjmZ0bA==", - "dependencies": { - "@types/mdast": "^3.0.0", - "unified": "^10.0.0", - "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-unused-definitions/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-unused-definitions/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-unused-definitions/node_modules/unist-util-visit": { + "node_modules/remark-lint-no-table-indentation": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-no-unused-definitions/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-ordered-list-marker-style": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-ordered-list-marker-style/-/remark-lint-ordered-list-marker-style-3.0.0.tgz", - "integrity": "sha512-HDg5Fyg3tENtmI5SpEL34TvEjIiVX4GhuOjU8aOGF7T4SMG69kLyx+IWMKhg39pBw+3h4lG6FDC8IfqYXONNLg==", + "resolved": "https://registry.npmjs.org/remark-lint-no-table-indentation/-/remark-lint-no-table-indentation-4.0.0.tgz", + "integrity": "sha512-S1u4DHBS75xAcM/u1zsYize/0uB2u+xAoHbstN3JmFWsTRj5LUSppwkSrWsPk/3y9/jHJAQ4XSihwH7C95EObQ==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-ordered-list-marker-style/node_modules/unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "dependencies": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-ordered-list-marker-style/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-ordered-list-marker-style/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-ordered-list-marker-style/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "unist-util-visit": "^4.0.0", + "vfile-location": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-ordered-list-marker-style/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-no-table-indentation/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-prohibited-strings": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-prohibited-strings/-/remark-lint-prohibited-strings-2.0.0.tgz", - "integrity": "sha512-N94RTdAT4qmYNBczNZEZbnpGvtl9GiLPO/xdG569IpbbtNFh5l+Nf5Mx5B1VeJMC8/hAR7wShag03Zf29MOO6Q==", - "dependencies": { - "escape-string-regexp": "^4.0.0", - "unified-lint-rule": "^1.0.2", - "unist-util-position": "^3.1.0", - "unist-util-visit": "^2.0.0", - "vfile-location": "^3.0.1" - } - }, - "node_modules/remark-lint-rule-style": { + "node_modules/remark-lint-no-tabs": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-rule-style/-/remark-lint-rule-style-3.0.0.tgz", - "integrity": "sha512-KHSPHW/7YCl9gHFsqqWOqIkJYmPuxTu/5G3Ks3lG8seBDf1bg+lPPUg5TigsKa/E7juVgfTR7AhK6P+lYAp4EA==", + "resolved": "https://registry.npmjs.org/remark-lint-no-tabs/-/remark-lint-no-tabs-3.0.0.tgz", + "integrity": "sha512-iK5gXQLoBchviHRNNDIWKQsMAbsLIZzK2ZKo0ywzNBHBckd8fy+wIP6RUosb6p/RBHtq1JG1lUC5ADg1PSj0tQ==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" + "vfile-location": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-rule-style/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-tabs/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -4634,60 +3101,57 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-rule-style/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-rule-style/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "node_modules/remark-lint-no-trailing-spaces": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-trailing-spaces/-/remark-lint-no-trailing-spaces-2.0.1.tgz", + "integrity": "sha512-cj8t+nvtO6eAY2lJC7o5du8VeOCK13XiDUHL4U6k5aw6ZLr3EYWbQ/rNc6cr60eHkh5Ldm09KiZjV3CWpxqJ0g==", + "dependencies": { + "unified-lint-rule": "^1.0.2" } }, - "node_modules/remark-lint-rule-style/node_modules/unist-util-visit": { + "node_modules/remark-lint-no-undefined-references": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "resolved": "https://registry.npmjs.org/remark-lint-no-undefined-references/-/remark-lint-no-undefined-references-4.0.0.tgz", + "integrity": "sha512-HI68vLoTTCXDADAp8LQ6RqCuf9QHX7bSaaqKI1V82EyvizxgnFtvN46XIi1uiDTN+Jv/KzAAGaFrofV8OJknBA==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0", + "vfile-location": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-rule-style/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-no-undefined-references/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-strong-marker": { + "node_modules/remark-lint-no-unused-definitions": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-strong-marker/-/remark-lint-strong-marker-3.0.0.tgz", - "integrity": "sha512-nNyW3tKl0rEf2j784HzVWChAomCxzld+v2A5R5r5Zw5VogUNikZA7ZRwy51HsmhqiTWHArVGeyuvCPrpkTDZ0A==", + "resolved": "https://registry.npmjs.org/remark-lint-no-unused-definitions/-/remark-lint-no-unused-definitions-3.0.0.tgz", + "integrity": "sha512-1LqEZx0IJx59ezXA9e0qq6h5W3n9I6oiBm3Kl+HvmXTFl1OME6f8SVFwtDbt9EaGmf+3NL+T24cWIhZWjmZ0bA==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", - "unist-util-position": "^4.0.0", + "unist-util-generated": "^2.0.0", "unist-util-visit": "^4.0.0" }, "funding": { @@ -4695,7 +3159,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-strong-marker/node_modules/unified-lint-rule": { + "node_modules/remark-lint-no-unused-definitions/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -4710,60 +3174,15 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-strong-marker/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-strong-marker/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-strong-marker/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-strong-marker/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-table-cell-padding": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-table-cell-padding/-/remark-lint-table-cell-padding-4.0.0.tgz", - "integrity": "sha512-jYBhfu/x0bEXt+wilHnm76q6wHnPVW2v2EuTdvAsxqkVtlvWSl9BbO4bb/L7jKqwlfiTK8E/luHKZuPiNWlucw==", + "node_modules/remark-lint-ordered-list-marker-style": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-ordered-list-marker-style/-/remark-lint-ordered-list-marker-style-3.0.0.tgz", + "integrity": "sha512-HDg5Fyg3tENtmI5SpEL34TvEjIiVX4GhuOjU8aOGF7T4SMG69kLyx+IWMKhg39pBw+3h4lG6FDC8IfqYXONNLg==", "dependencies": { "@types/mdast": "^3.0.0", - "@types/unist": "^2.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", "unist-util-position": "^4.0.0", "unist-util-visit": "^4.0.0" }, @@ -4772,7 +3191,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-table-cell-padding/node_modules/unified-lint-rule": { + "node_modules/remark-lint-ordered-list-marker-style/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -4787,55 +3206,37 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-table-cell-padding/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-table-cell-padding/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-table-cell-padding/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-prohibited-strings": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-prohibited-strings/-/remark-lint-prohibited-strings-3.0.0.tgz", + "integrity": "sha512-Aw21KVeoOiDte6dNfeTfTgjKV19yWXpPjLxfJ3ShC22/r97gkGdOo4dnuwyEEAfKhr3uimtSf3rRQyGSudY5tQ==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "escape-string-regexp": "^5.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-position": "^4.0.1", + "unist-util-visit": "^4.0.0", + "vfile-location": "^4.0.1" } }, - "node_modules/remark-lint-table-cell-padding/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-prohibited-strings/node_modules/unified-lint-rule": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.1.tgz", + "integrity": "sha512-2RzZuuuWW+ifftM0zd/ZEng0Hb5lah+Zi+ZL/ybj8BrLO/TH2aQAMYvG+iC95aCg2FkWu/pcvVvHqsh2UMmzPg==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-table-pipes": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-table-pipes/-/remark-lint-table-pipes-4.0.0.tgz", - "integrity": "sha512-wOIAwkPAEDArKYMEpDylycGOCCt9hUxfgirgYCaHujCvyg484GWO+n+Moabgd19O9ZjuYr2P7akuOocsTh2z3g==", + "node_modules/remark-lint-rule-style": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-rule-style/-/remark-lint-rule-style-3.0.0.tgz", + "integrity": "sha512-KHSPHW/7YCl9gHFsqqWOqIkJYmPuxTu/5G3Ks3lG8seBDf1bg+lPPUg5TigsKa/E7juVgfTR7AhK6P+lYAp4EA==", "dependencies": { "@types/mdast": "^3.0.0", "unified": "^10.0.0", @@ -4848,7 +3249,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-table-pipes/node_modules/unified-lint-rule": { + "node_modules/remark-lint-rule-style/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -4863,60 +3264,46 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-table-pipes/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-table-pipes/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-lint-table-pipes/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-strong-marker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-strong-marker/-/remark-lint-strong-marker-3.0.0.tgz", + "integrity": "sha512-nNyW3tKl0rEf2j784HzVWChAomCxzld+v2A5R5r5Zw5VogUNikZA7ZRwy51HsmhqiTWHArVGeyuvCPrpkTDZ0A==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-table-pipes/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-strong-marker/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-unordered-list-marker-style": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-unordered-list-marker-style/-/remark-lint-unordered-list-marker-style-3.0.0.tgz", - "integrity": "sha512-iwliMh7GzTdFAWKnVSabpdfcI6qoDE5PPX8hacDIZNbTe4xuUVFbopGCzsTlLiFQkTn6m3ePwOQn+lIbFofKDQ==", + "node_modules/remark-lint-table-cell-padding": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-table-cell-padding/-/remark-lint-table-cell-padding-4.0.0.tgz", + "integrity": "sha512-jYBhfu/x0bEXt+wilHnm76q6wHnPVW2v2EuTdvAsxqkVtlvWSl9BbO4bb/L7jKqwlfiTK8E/luHKZuPiNWlucw==", "dependencies": { "@types/mdast": "^3.0.0", + "@types/unist": "^2.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", - "unist-util-generated": "^2.0.0", "unist-util-position": "^4.0.0", "unist-util-visit": "^4.0.0" }, @@ -4925,7 +3312,7 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-unordered-list-marker-style/node_modules/unified-lint-rule": { + "node_modules/remark-lint-table-cell-padding/node_modules/unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", @@ -4940,45 +3327,63 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-unordered-list-marker-style/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", + "node_modules/remark-lint-table-pipes": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-table-pipes/-/remark-lint-table-pipes-4.0.0.tgz", + "integrity": "sha512-wOIAwkPAEDArKYMEpDylycGOCCt9hUxfgirgYCaHujCvyg484GWO+n+Moabgd19O9ZjuYr2P7akuOocsTh2z3g==", + "dependencies": { + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-unordered-list-marker-style/node_modules/unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", + "node_modules/remark-lint-table-pipes/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", + "dependencies": { + "@types/unist": "^2.0.0", + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-unordered-list-marker-style/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", + "node_modules/remark-lint-unordered-list-marker-style": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-unordered-list-marker-style/-/remark-lint-unordered-list-marker-style-3.0.0.tgz", + "integrity": "sha512-iwliMh7GzTdFAWKnVSabpdfcI6qoDE5PPX8hacDIZNbTe4xuUVFbopGCzsTlLiFQkTn6m3ePwOQn+lIbFofKDQ==", "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/remark-lint-unordered-list-marker-style/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "node_modules/remark-lint-unordered-list-marker-style/node_modules/unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", @@ -5000,9 +3405,9 @@ } }, "node_modules/remark-preset-lint-node": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-preset-lint-node/-/remark-preset-lint-node-3.0.0.tgz", - "integrity": "sha512-H1YwlVi/K0xmFT2JaVqnySNHdW/gqd9EQRbGVcH2mkxLNLdO+FIawkSU+UVYIhsm63pKAkHFW8HEtdoEAkNxOg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/remark-preset-lint-node/-/remark-preset-lint-node-3.0.1.tgz", + "integrity": "sha512-L7yhho9q9vmpsfMHO2gRKFNj36106iFM4KpodE+3k3rGg5dcmhV+zcsftNh5NGzbKKKYsGQj9C5XxCR/0NwKDg==", "dependencies": { "js-yaml": "^4.0.0", "remark-lint-blockquote-indentation": "^3.0.0", @@ -5028,7 +3433,7 @@ "remark-lint-no-table-indentation": "^4.0.0", "remark-lint-no-tabs": "^3.0.0", "remark-lint-no-trailing-spaces": "^2.0.1", - "remark-lint-prohibited-strings": "^2.0.0", + "remark-lint-prohibited-strings": "^3.0.0", "remark-lint-rule-style": "^3.0.0", "remark-lint-strong-marker": "^3.0.0", "remark-lint-table-cell-padding": "^4.0.0", @@ -5058,42 +3463,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-preset-lint-node/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-preset-lint-node/node_modules/unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/remark-preset-lint-node/node_modules/unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/remark-preset-lint-recommended": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/remark-preset-lint-recommended/-/remark-preset-lint-recommended-6.0.0.tgz", @@ -5180,15 +3549,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-preset-lint-recommended/node_modules/unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/remark-preset-lint-recommended/node_modules/unist-util-visit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", @@ -5216,19 +3576,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-preset-lint-recommended/node_modules/vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "dependencies": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/remark-stringify": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-10.0.0.tgz", @@ -5265,9 +3612,9 @@ } }, "node_modules/rollup": { - "version": "2.52.7", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.52.7.tgz", - "integrity": "sha512-55cSH4CCU6MaPr9TAOyrIC+7qFCHscL7tkNsm1MBfIJRRqRbCEY0mmeFn4Wg8FKsHtEH8r389Fz38r/o+kgXLg==", + "version": "2.56.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.2.tgz", + "integrity": "sha512-s8H00ZsRi29M2/lGdm1u8DJpJ9ML8SUOpVVBd33XNeEeL3NVaTiUcSBHzBdF3eAyR0l7VSpsuoVUGrRHq7aPwQ==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -5576,18 +3923,18 @@ } }, "node_modules/unist-util-is": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.4.tgz", - "integrity": "sha512-3dF39j/u423v4BBQrk1AQ2Ve1FxY5W3JKwXxVFzBODQ6WEvccguhgp802qQLKSnxPODE6WuRZtV+ohlUg4meBA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", + "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, "node_modules/unist-util-position": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.1.0.tgz", - "integrity": "sha512-w+PkwCbYSFw8vpgWD0v7zRCl1FpY3fjDSQ3/N/wNd9Ffa4gPi8+4keqt99N3XW6F99t/mUzp2xAhNmfKWp95QA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", + "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==", "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" @@ -5606,13 +3953,13 @@ } }, "node_modules/unist-util-visit": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", - "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", + "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^5.0.0" }, "funding": { "type": "opencollective", @@ -5620,12 +3967,12 @@ } }, "node_modules/unist-util-visit-parents": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz", - "integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", + "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" + "unist-util-is": "^5.0.0" }, "funding": { "type": "opencollective", @@ -5653,9 +4000,13 @@ } }, "node_modules/vfile-location": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.2.0.tgz", - "integrity": "sha512-aLEIZKv/oxuCDZ8lkJGhuhztf/BW4M+iHdCwglA/eWc+vtuRFJj8EtgceYFX4LRjOhCAAiNHsKGssC6onJ+jbA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", + "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", + "dependencies": { + "@types/unist": "^2.0.0", + "vfile": "^5.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" @@ -6209,9 +4560,9 @@ } }, "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==" }, "estree-walker": { "version": "2.0.2", @@ -6323,17 +4674,6 @@ "vfile": "^5.0.0", "vfile-location": "^4.0.0", "web-namespaces": "^2.0.0" - }, - "dependencies": { - "vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "requires": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - } - } } }, "hast-util-is-element": { @@ -6368,13 +4708,6 @@ "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "unist-util-is": "^5.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - } } }, "hast-util-whitespace": { @@ -6637,16 +4970,6 @@ "unist-util-visit-parents": "^4.0.0" }, "dependencies": { - "escape-string-regexp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", - "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==" - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, "unist-util-visit-parents": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", @@ -7229,35 +5552,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7283,35 +5577,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7338,44 +5603,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } - }, - "vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "requires": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - } } } }, @@ -7402,35 +5629,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7456,35 +5654,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7511,35 +5680,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7551,48 +5691,19 @@ "@types/mdast": "^3.0.0", "unified": "^10.0.0", "unified-lint-rule": "^2.0.0", - "unist-util-position": "^4.0.0", - "unist-util-visit": "^4.0.0" - }, - "dependencies": { - "unified-lint-rule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "requires": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" + }, + "dependencies": { + "unified-lint-rule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "requires": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" } } } @@ -7643,35 +5754,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7720,30 +5802,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7770,35 +5828,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7825,30 +5854,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7874,30 +5879,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7925,35 +5906,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -7980,35 +5932,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8036,35 +5959,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8092,44 +5986,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } - }, - "vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "requires": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - } } } }, @@ -8158,35 +6014,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8214,35 +6041,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8340,35 +6138,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8396,35 +6165,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8451,30 +6191,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8502,35 +6218,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8551,41 +6238,12 @@ "unified-lint-rule": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.0.tgz", - "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", - "requires": { - "@types/unist": "^2.0.0", - "trough": "^2.0.0", - "unified": "^10.0.0", - "vfile": "^5.0.0" - } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", + "integrity": "sha512-3V+eyHZR+PAeKavQrrvSacXq83C3TGVDZJpTZ8+MTlHZmS4arL1ul5U4WRymok0zobAsMiri42bJj0rCHIlIjA==", "requires": { "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" } } } @@ -8612,30 +6270,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8661,30 +6295,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8710,30 +6320,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8760,44 +6346,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } - }, - "vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "requires": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - } } } }, @@ -8822,15 +6370,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "requires": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - } } } }, @@ -8867,44 +6406,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } - }, - "vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "requires": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - } } } }, @@ -8930,30 +6431,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -8980,48 +6457,32 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, "remark-lint-prohibited-strings": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-prohibited-strings/-/remark-lint-prohibited-strings-2.0.0.tgz", - "integrity": "sha512-N94RTdAT4qmYNBczNZEZbnpGvtl9GiLPO/xdG569IpbbtNFh5l+Nf5Mx5B1VeJMC8/hAR7wShag03Zf29MOO6Q==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-prohibited-strings/-/remark-lint-prohibited-strings-3.0.0.tgz", + "integrity": "sha512-Aw21KVeoOiDte6dNfeTfTgjKV19yWXpPjLxfJ3ShC22/r97gkGdOo4dnuwyEEAfKhr3uimtSf3rRQyGSudY5tQ==", "requires": { - "escape-string-regexp": "^4.0.0", - "unified-lint-rule": "^1.0.2", - "unist-util-position": "^3.1.0", - "unist-util-visit": "^2.0.0", - "vfile-location": "^3.0.1" + "escape-string-regexp": "^5.0.0", + "unified-lint-rule": "^2.0.0", + "unist-util-position": "^4.0.1", + "unist-util-visit": "^4.0.0", + "vfile-location": "^4.0.1" + }, + "dependencies": { + "unified-lint-rule": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unified-lint-rule/-/unified-lint-rule-2.0.1.tgz", + "integrity": "sha512-2RzZuuuWW+ifftM0zd/ZEng0Hb5lah+Zi+ZL/ybj8BrLO/TH2aQAMYvG+iC95aCg2FkWu/pcvVvHqsh2UMmzPg==", + "requires": { + "@types/unist": "^2.0.0", + "trough": "^2.0.0", + "unified": "^10.0.0", + "vfile": "^5.0.0" + } + } } }, "remark-lint-rule-style": { @@ -9046,35 +6507,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -9100,35 +6532,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -9155,35 +6558,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -9209,35 +6583,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -9264,35 +6609,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-position": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", - "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -9307,9 +6623,9 @@ } }, "remark-preset-lint-node": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remark-preset-lint-node/-/remark-preset-lint-node-3.0.0.tgz", - "integrity": "sha512-H1YwlVi/K0xmFT2JaVqnySNHdW/gqd9EQRbGVcH2mkxLNLdO+FIawkSU+UVYIhsm63pKAkHFW8HEtdoEAkNxOg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/remark-preset-lint-node/-/remark-preset-lint-node-3.0.1.tgz", + "integrity": "sha512-L7yhho9q9vmpsfMHO2gRKFNj36106iFM4KpodE+3k3rGg5dcmhV+zcsftNh5NGzbKKKYsGQj9C5XxCR/0NwKDg==", "requires": { "js-yaml": "^4.0.0", "remark-lint-blockquote-indentation": "^3.0.0", @@ -9335,7 +6651,7 @@ "remark-lint-no-table-indentation": "^4.0.0", "remark-lint-no-tabs": "^3.0.0", "remark-lint-no-trailing-spaces": "^2.0.1", - "remark-lint-prohibited-strings": "^2.0.0", + "remark-lint-prohibited-strings": "^3.0.0", "remark-lint-rule-style": "^3.0.0", "remark-lint-strong-marker": "^3.0.0", "remark-lint-table-cell-padding": "^4.0.0", @@ -9357,30 +6673,6 @@ "unified": "^10.0.0", "vfile": "^5.0.0" } - }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, - "unist-util-visit": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", - "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0", - "unist-util-visit-parents": "^5.0.0" - } - }, - "unist-util-visit-parents": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", - "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^5.0.0" - } } } }, @@ -9450,11 +6742,6 @@ "vfile-message": "^3.0.0" } }, - "unist-util-is": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", - "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" - }, "unist-util-visit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", @@ -9473,15 +6760,6 @@ "@types/unist": "^2.0.0", "unist-util-is": "^5.0.0" } - }, - "vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", - "requires": { - "@types/unist": "^2.0.0", - "vfile": "^5.0.0" - } } } }, @@ -9511,9 +6789,9 @@ } }, "rollup": { - "version": "2.52.7", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.52.7.tgz", - "integrity": "sha512-55cSH4CCU6MaPr9TAOyrIC+7qFCHscL7tkNsm1MBfIJRRqRbCEY0mmeFn4Wg8FKsHtEH8r389Fz38r/o+kgXLg==", + "version": "2.56.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.2.tgz", + "integrity": "sha512-s8H00ZsRi29M2/lGdm1u8DJpJ9ML8SUOpVVBd33XNeEeL3NVaTiUcSBHzBdF3eAyR0l7VSpsuoVUGrRHq7aPwQ==", "dev": true, "requires": { "fsevents": "~2.3.2" @@ -9726,14 +7004,14 @@ } }, "unist-util-is": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.4.tgz", - "integrity": "sha512-3dF39j/u423v4BBQrk1AQ2Ve1FxY5W3JKwXxVFzBODQ6WEvccguhgp802qQLKSnxPODE6WuRZtV+ohlUg4meBA==" + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", + "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==" }, "unist-util-position": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.1.0.tgz", - "integrity": "sha512-w+PkwCbYSFw8vpgWD0v7zRCl1FpY3fjDSQ3/N/wNd9Ffa4gPi8+4keqt99N3XW6F99t/mUzp2xAhNmfKWp95QA==" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.1.tgz", + "integrity": "sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==" }, "unist-util-stringify-position": { "version": "3.0.0", @@ -9744,22 +7022,22 @@ } }, "unist-util-visit": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", - "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.0.0.tgz", + "integrity": "sha512-3HWTvrtU10/E7qgPznBfiOyG0TXj9W8c1GSfaI8L9GkaG1pLePiQPZ7E35a0R3ToQ/zcy4Im6aZ9WBgOTnv1MQ==", "requires": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^5.0.0" } }, "unist-util-visit-parents": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz", - "integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.0.0.tgz", + "integrity": "sha512-CVaLOYPM/EaFTYMytbaju3Tw4QI3DHnHFnL358FkEu0hZOzSm/hqBdVwOQDR60jF5ZzhB1tlZlRH0ll/yekZIQ==", "requires": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" + "unist-util-is": "^5.0.0" } }, "util-deprecate": { @@ -9779,9 +7057,13 @@ } }, "vfile-location": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.2.0.tgz", - "integrity": "sha512-aLEIZKv/oxuCDZ8lkJGhuhztf/BW4M+iHdCwglA/eWc+vtuRFJj8EtgceYFX4LRjOhCAAiNHsKGssC6onJ+jbA==" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", + "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", + "requires": { + "@types/unist": "^2.0.0", + "vfile": "^5.0.0" + } }, "vfile-message": { "version": "3.0.2", diff --git a/tools/node-lint-md-cli-rollup/rollup.config.js b/tools/node-lint-md-cli-rollup/rollup.config.js index 531103d729dfd8..33ebeab368a1fd 100644 --- a/tools/node-lint-md-cli-rollup/rollup.config.js +++ b/tools/node-lint-md-cli-rollup/rollup.config.js @@ -13,16 +13,12 @@ module.exports = { exports: 'none', }, external: [ - 'stream', - 'path', - 'module', - 'util', - 'tty', - 'os', - 'fs', - 'fsevents', - 'events', - 'assert', + 'node:events', + 'node:fs', + 'node:path', + 'node:process', + 'node:stream', + 'node:url', ], plugins: [ { @@ -47,7 +43,7 @@ module.exports = { json({ preferConst: true }), - nodeResolve(), // tells Rollup how to find date-fns in node_modules + nodeResolve({exportConditions: ['node']}), commonjs(), { name: 'banner', From 09213f387206089710b886e27bbcf877ef5f8742 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 21 Aug 2021 08:37:08 -0700 Subject: [PATCH 2/4] fixup! tools: fix markdown linting --- tools/node-lint-md-cli-rollup/rollup.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/node-lint-md-cli-rollup/rollup.config.js b/tools/node-lint-md-cli-rollup/rollup.config.js index 33ebeab368a1fd..013ba13b9b774c 100644 --- a/tools/node-lint-md-cli-rollup/rollup.config.js +++ b/tools/node-lint-md-cli-rollup/rollup.config.js @@ -43,7 +43,7 @@ module.exports = { json({ preferConst: true }), - nodeResolve({exportConditions: ['node']}), + nodeResolve({ exportConditions: ['node'] }), commonjs(), { name: 'banner', From 09d820e0ee7c944f703126e61e2f2710350d7cd0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 21 Aug 2021 08:45:07 -0700 Subject: [PATCH 3/4] fixup! fixup! tools: fix markdown linting --- Makefile | 2 +- tools/{lint-md.js => lint-md.mjs} | 531 ++++++++---------- tools/node-lint-md-cli-rollup/package.json | 2 +- .../node-lint-md-cli-rollup/rollup.config.js | 4 +- 4 files changed, 249 insertions(+), 290 deletions(-) rename tools/{lint-md.js => lint-md.mjs} (98%) diff --git a/Makefile b/Makefile index ec4c774748cd91..609d0614419f86 100644 --- a/Makefile +++ b/Makefile @@ -1235,7 +1235,7 @@ LINT_MD_TARGETS = doc src lib benchmark test tools/doc tools/icu $(wildcard *.md LINT_MD_FILES = $(shell $(FIND) $(LINT_MD_TARGETS) -type f \ ! -path '*node_modules*' ! -path 'test/fixtures/*' -name '*.md' \ $(LINT_MD_NEWER)) -run-lint-md = tools/lint-md.js -q -f --no-stdout $(LINT_MD_FILES) +run-lint-md = tools/lint-md.mjs -q -f --no-stdout $(LINT_MD_FILES) # Lint all changed markdown files maintained by us tools/.mdlintstamp: $(LINT_MD_FILES) $(info Running Markdown linter...) diff --git a/tools/lint-md.js b/tools/lint-md.mjs similarity index 98% rename from tools/lint-md.js rename to tools/lint-md.mjs index b7109dc74ef200..b614ae37d81af3 100644 --- a/tools/lint-md.js +++ b/tools/lint-md.mjs @@ -1,60 +1,19 @@ -'use strict'; - -// Don't change this file manually, -// it is generated from tools/node-lint-md-cli-rollup - -var path$b = require('path'); -var require$$0$3 = require('fs'); -var url = require('url'); -var process$2 = require('node:process'); -var stream = require('node:stream'); -var require$$0$2 = require('os'); -var tty$1 = require('tty'); -var require$$0$5 = require('events'); -var require$$0$4 = require('util'); -var require$$1 = require('stream'); -var path$c = require('node:path'); -var node_url = require('node:url'); -var assert$2 = require('assert'); -var fs$a = require('node:fs'); -var node_events = require('node:events'); -var process$1 = require('process'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -var path__default = /*#__PURE__*/_interopDefaultLegacy(path$b); -var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3); -var process__default$1 = /*#__PURE__*/_interopDefaultLegacy(process$2); -var stream__default = /*#__PURE__*/_interopDefaultLegacy(stream); -var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$2); -var tty__default = /*#__PURE__*/_interopDefaultLegacy(tty$1); -var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5); -var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4); -var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); -var path__default$1 = /*#__PURE__*/_interopDefaultLegacy(path$c); -var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$2); -var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$a); -var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1); +import path$b from 'path'; +import require$$0$3, { realpathSync as realpathSync$1, statSync, Stats } from 'fs'; +import { URL as URL$1, fileURLToPath, pathToFileURL } from 'url'; +import process$2 from 'node:process'; +import stream, { PassThrough } from 'node:stream'; +import require$$0$2 from 'os'; +import tty$1 from 'tty'; +import require$$0$5 from 'events'; +import require$$0$4, { format as format$2, inspect as inspect$1 } from 'util'; +import require$$1 from 'stream'; +import path$c from 'node:path'; +import { pathToFileURL as pathToFileURL$1 } from 'node:url'; +import assert$2 from 'assert'; +import fs$a from 'node:fs'; +import { EventEmitter as EventEmitter$1 } from 'node:events'; +import process$1 from 'process'; var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -1422,8 +1381,8 @@ var hasFlag$4 = (flag, argv = process.argv) => { return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); }; -const os$2 = require$$0__default['default']; -const tty = tty__default['default']; +const os$2 = require$$0$2; +const tty = tty$1; const hasFlag$3 = hasFlag$4; const {env: env$2} = process; @@ -1962,7 +1921,7 @@ var chokidar = {}; var utils$7 = {}; -const path$a = path__default['default']; +const path$a = path$b; const WIN_SLASH = '\\\\/'; const WIN_NO_SLASH = `[^${WIN_SLASH}]`; @@ -2142,7 +2101,7 @@ var constants$5 = { (function (exports) { -const path = path__default['default']; +const path = path$b; const win32 = process.platform === 'win32'; const { REGEX_BACKSLASH, @@ -3665,7 +3624,7 @@ parse$e.fastpaths = (input, options) => { var parse_1$2 = parse$e; -const path$9 = path__default['default']; +const path$9 = path$b; const scan = scan_1; const parse$d = parse_1$2; const utils$4 = utils$7; @@ -4005,10 +3964,10 @@ var picomatch_1 = picomatch$3; var picomatch$2 = picomatch_1; -const fs$9 = require$$0__default$1['default']; -const { Readable } = require$$1__default['default']; -const sysPath$3 = path__default['default']; -const { promisify: promisify$3 } = require$$0__default$2['default']; +const fs$9 = require$$0$3; +const { Readable } = require$$1; +const sysPath$3 = path$b; +const { promisify: promisify$3 } = require$$0$4; const picomatch$1 = picomatch$2; const readdir$1 = promisify$3(fs$9.readdir); @@ -4503,8 +4462,8 @@ var isGlob$2 = function isGlob(str, options) { }; var isGlob$1 = isGlob$2; -var pathPosixDirname = path__default['default'].posix.dirname; -var isWin32 = require$$0__default['default'].platform() === 'win32'; +var pathPosixDirname = path$b.posix.dirname; +var isWin32 = require$$0$2.platform() === 'win32'; var slash = '/'; var backslash = /\\/g; @@ -5000,7 +4959,7 @@ var toRegexRange_1 = toRegexRange$1; * Licensed under the MIT License. */ -const util$3 = require$$0__default$2['default']; +const util$3 = require$$0$4; const toRegexRange = toRegexRange_1; const isObject$2 = val => val !== null && typeof val === 'object' && !Array.isArray(val); @@ -6226,7 +6185,7 @@ var require$$0$1 = [ var binaryExtensions$1 = require$$0$1; -const path$8 = path__default['default']; +const path$8 = path$b; const binaryExtensions = binaryExtensions$1; const extensions = new Set(binaryExtensions); @@ -6237,9 +6196,9 @@ var constants$1 = {}; (function (exports) { -const {sep} = path__default['default']; +const {sep} = path$b; const {platform} = process; -const os = require$$0__default['default']; +const os = require$$0$2; exports.EV_ALL = 'all'; exports.EV_READY = 'ready'; @@ -6302,9 +6261,9 @@ exports.isLinux = platform === 'linux'; exports.isIBMi = os.type() === 'OS400'; }(constants$1)); -const fs$8 = require$$0__default$1['default']; -const sysPath$2 = path__default['default']; -const { promisify: promisify$2 } = require$$0__default$2['default']; +const fs$8 = require$$0$3; +const sysPath$2 = path$b; +const { promisify: promisify$2 } = require$$0$4; const isBinaryPath = isBinaryPath$1; const { isWindows: isWindows$3, @@ -6939,9 +6898,9 @@ var nodefsHandler = NodeFsHandler$1; var fseventsHandler = {exports: {}}; -const fs$7 = require$$0__default$1['default']; -const sysPath$1 = path__default['default']; -const { promisify: promisify$1 } = require$$0__default$2['default']; +const fs$7 = require$$0$3; +const sysPath$1 = path$b; +const { promisify: promisify$1 } = require$$0$4; let fsevents; try { @@ -7462,10 +7421,10 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) { fseventsHandler.exports = FsEventsHandler$1; fseventsHandler.exports.canUse = canUse; -const { EventEmitter } = require$$0__default$3['default']; -const fs$6 = require$$0__default$1['default']; -const sysPath = path__default['default']; -const { promisify } = require$$0__default$2['default']; +const { EventEmitter } = require$$0$5; +const fs$6 = require$$0$3; +const sysPath = path$b; +const { promisify } = require$$0$4; const readdirp = readdirp_1; const anymatch = anymatch$2.exports.default; const globParent = globParent$1; @@ -12513,7 +12472,7 @@ var isArrayish$2 = function isArrayish(obj) { (obj.length >= 0 && obj.splice instanceof Function); }; -var util$2 = require$$0__default$2['default']; +var util$2 = require$$0$4; var isArrayish$1 = isArrayish$2; var errorEx$1 = function errorEx(name, properties) { @@ -14439,7 +14398,7 @@ var hasFlag$2 = (flag, argv) => { return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); }; -const os$1 = require$$0__default['default']; +const os$1 = require$$0$2; const hasFlag$1 = hasFlag$2; const env$1 = process.env; @@ -15979,8 +15938,8 @@ var node = {exports: {}}; */ (function (module, exports) { -const tty = tty__default['default']; -const util = require$$0__default$2['default']; +const tty = tty$1; +const util = require$$0$4; /** * This is the Node.js implementation of `debug()`. @@ -19041,7 +19000,7 @@ var packageJsonReader = reader; * @returns {{string: string}} */ function read$3(jsonPath) { - return find$1(path__default['default'].dirname(jsonPath)) + return find$1(path$b.dirname(jsonPath)) } /** @@ -19050,14 +19009,14 @@ function read$3(jsonPath) { */ function find$1(dir) { try { - const string = require$$0__default$1['default'].readFileSync( - path__default['default'].toNamespacedPath(path__default['default'].join(dir, 'package.json')), + const string = require$$0$3.readFileSync( + path$b.toNamespacedPath(path$b.join(dir, 'package.json')), 'utf8' ); return {string} } catch (error) { if (error.code === 'ENOENT') { - const parent = path__default['default'].dirname(dir); + const parent = path$b.dirname(dir); if (dir !== parent) return find$1(parent) return {string: undefined} // Throw all other errors. @@ -19132,7 +19091,7 @@ codes.ERR_INVALID_PACKAGE_TARGET = createError( target.length > 0 && !target.startsWith('./'); if (key === '.') { - assert__default['default'](isImport === false); + assert$2(isImport === false); return ( `Invalid "exports" main target ${JSON.stringify(target)} defined ` + `in the package config ${pkgPath}package.json${ @@ -19220,7 +19179,7 @@ codes.ERR_INVALID_ARG_VALUE = createError( * @param {string} [reason='is invalid'] */ (name, value, reason = 'is invalid') => { - let inspected = require$$0$4.inspect(value); + let inspected = inspect$1(value); if (inspected.length > 128) { inspected = `${inspected.slice(0, 128)}...`; @@ -19395,7 +19354,7 @@ function getMessage(key, args, self) { const message = messages.get(key); if (typeof message === 'function') { - assert__default['default']( + assert$2( message.length <= args.length, // Default options do not count. `Code: ${key}; The provided arguments length (${args.length}) does not ` + `match the required ones (${message.length}).` @@ -19404,7 +19363,7 @@ function getMessage(key, args, self) { } const expectedLength = (message.match(/%[dfijoOs]/g) || []).length; - assert__default['default']( + assert$2( expectedLength === args.length, `Code: ${key}; The provided arguments length (${args.length}) does not ` + `match the required ones (${expectedLength}).` @@ -19412,7 +19371,7 @@ function getMessage(key, args, self) { if (args.length === 0) return message args.unshift(message); - return Reflect.apply(require$$0$4.format, null, args) + return Reflect.apply(format$2, null, args) } // Manually “tree shaken” from: @@ -19430,12 +19389,12 @@ const extensionFormatMap = { * @param {string} url * @returns {{format: string|null}} */ -function defaultGetFormat(url$1) { - if (url$1.startsWith('node:')) { +function defaultGetFormat(url) { + if (url.startsWith('node:')) { return {format: 'builtin'} } - const parsed = new url.URL(url$1); + const parsed = new URL$1(url); if (parsed.protocol === 'data:') { const {1: mime} = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec( @@ -19446,7 +19405,7 @@ function defaultGetFormat(url$1) { } if (parsed.protocol === 'file:') { - const ext = path__default['default'].extname(parsed.pathname); + const ext = path$b.extname(parsed.pathname); /** @type {string} */ let format; if (ext === '.js') { @@ -19456,7 +19415,7 @@ function defaultGetFormat(url$1) { } if (!format) { - throw new ERR_UNKNOWN_FILE_EXTENSION(ext, url.fileURLToPath(url$1)) + throw new ERR_UNKNOWN_FILE_EXTENSION(ext, fileURLToPath(url)) } return {format: format || null} @@ -19502,7 +19461,7 @@ const packageJsonCache = new Map(); * @returns {void} */ function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) { - const pjsonPath = url.fileURLToPath(pjsonUrl); + const pjsonPath = fileURLToPath(pjsonUrl); if (emittedPackageWarnings.has(pjsonPath + '|' + match)) return emittedPackageWarnings.add(pjsonPath + '|' + match); @@ -19510,7 +19469,7 @@ function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) { `Use of deprecated folder mapping "${match}" in the ${ isExports ? '"exports"' : '"imports"' } field module resolution of the package at ${pjsonPath}${ - base ? ` imported from ${url.fileURLToPath(base)}` : '' + base ? ` imported from ${fileURLToPath(base)}` : '' }.\n` + `Update this package.json to use a subpath pattern like "${match}*".`, 'DeprecationWarning', @@ -19525,12 +19484,12 @@ function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) { * @param {unknown} [main] * @returns {void} */ -function emitLegacyIndexDeprecation(url$1, packageJsonUrl, base, main) { - const {format} = defaultGetFormat(url$1.href); +function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) { + const {format} = defaultGetFormat(url.href); if (format !== 'module') return - const path = url.fileURLToPath(url$1.href); - const pkgPath = url.fileURLToPath(new url.URL('.', packageJsonUrl)); - const basePath = url.fileURLToPath(base); + const path = fileURLToPath(url.href); + const pkgPath = fileURLToPath(new URL$1('.', packageJsonUrl)); + const basePath = fileURLToPath(base); if (main) process.emitWarning( `Package ${pkgPath} has a "main" field set to ${JSON.stringify(main)}, ` + @@ -19578,9 +19537,9 @@ function getConditionsSet(conditions) { function tryStatSync(path) { // Note: from Node 15 onwards we can use `throwIfNoEntry: false` instead. try { - return require$$0$3.statSync(path) + return statSync(path) } catch { - return new require$$0$3.Stats() + return new Stats() } } @@ -19620,7 +19579,7 @@ function getPackageConfig(path, specifier, base) { } catch (error) { throw new ERR_INVALID_PACKAGE_CONFIG( path, - (base ? `"${specifier}" from ` : '') + url.fileURLToPath(base || specifier), + (base ? `"${specifier}" from ` : '') + fileURLToPath(base || specifier), error.message ) } @@ -19648,7 +19607,7 @@ function getPackageConfig(path, specifier, base) { * @returns {PackageConfig} */ function getPackageScopeConfig(resolved) { - let packageJsonUrl = new url.URL('./package.json', resolved); + let packageJsonUrl = new URL$1('./package.json', resolved); while (true) { const packageJsonPath = packageJsonUrl.pathname; @@ -19656,20 +19615,20 @@ function getPackageScopeConfig(resolved) { if (packageJsonPath.endsWith('node_modules/package.json')) break const packageConfig = getPackageConfig( - url.fileURLToPath(packageJsonUrl), + fileURLToPath(packageJsonUrl), resolved ); if (packageConfig.exists) return packageConfig const lastPackageJsonUrl = packageJsonUrl; - packageJsonUrl = new url.URL('../package.json', packageJsonUrl); + packageJsonUrl = new URL$1('../package.json', packageJsonUrl); // Terminates at root where ../package.json equals ../../package.json // (can't just check "/package.json" for Windows support). if (packageJsonUrl.pathname === lastPackageJsonUrl.pathname) break } - const packageJsonPath = url.fileURLToPath(packageJsonUrl); + const packageJsonPath = fileURLToPath(packageJsonUrl); /** @type {PackageConfig} */ const packageConfig = { pjsonPath: packageJsonPath, @@ -19695,8 +19654,8 @@ function getPackageScopeConfig(resolved) { * @param {URL} url * @returns {boolean} */ -function fileExists(url$1) { - return tryStatSync(url.fileURLToPath(url$1)).isFile() +function fileExists(url) { + return tryStatSync(fileURLToPath(url)).isFile() } /** @@ -19709,7 +19668,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) { /** @type {URL} */ let guess; if (packageConfig.main !== undefined) { - guess = new url.URL(`./${packageConfig.main}`, packageJsonUrl); + guess = new URL$1(`./${packageConfig.main}`, packageJsonUrl); // Note: fs check redundances will be handled by Descriptor cache here. if (fileExists(guess)) return guess @@ -19724,7 +19683,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) { let i = -1; while (++i < tries.length) { - guess = new url.URL(tries[i], packageJsonUrl); + guess = new URL$1(tries[i], packageJsonUrl); if (fileExists(guess)) break guess = undefined; } @@ -19745,7 +19704,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) { let i = -1; while (++i < tries.length) { - guess = new url.URL(tries[i], packageJsonUrl); + guess = new URL$1(tries[i], packageJsonUrl); if (fileExists(guess)) break guess = undefined; } @@ -19757,8 +19716,8 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) { // Not found. throw new ERR_MODULE_NOT_FOUND( - url.fileURLToPath(new url.URL('.', packageJsonUrl)), - url.fileURLToPath(base) + fileURLToPath(new URL$1('.', packageJsonUrl)), + fileURLToPath(base) ) } @@ -19772,15 +19731,15 @@ function finalizeResolution(resolved, base) { throw new ERR_INVALID_MODULE_SPECIFIER( resolved.pathname, 'must not include encoded "/" or "\\" characters', - url.fileURLToPath(base) + fileURLToPath(base) ) - const path = url.fileURLToPath(resolved); + const path = fileURLToPath(resolved); const stats = tryStatSync(path.endsWith('/') ? path.slice(-1) : path); if (stats.isDirectory()) { - const error = new ERR_UNSUPPORTED_DIR_IMPORT(path, url.fileURLToPath(base)); + const error = new ERR_UNSUPPORTED_DIR_IMPORT(path, fileURLToPath(base)); // @ts-expect-error Add this for `import.meta.resolve`. error.url = String(resolved); throw error @@ -19789,7 +19748,7 @@ function finalizeResolution(resolved, base) { if (!stats.isFile()) { throw new ERR_MODULE_NOT_FOUND( path || resolved.pathname, - base && url.fileURLToPath(base), + base && fileURLToPath(base), 'module' ) } @@ -19806,8 +19765,8 @@ function finalizeResolution(resolved, base) { function throwImportNotDefined(specifier, packageJsonUrl, base) { throw new ERR_PACKAGE_IMPORT_NOT_DEFINED( specifier, - packageJsonUrl && url.fileURLToPath(new url.URL('.', packageJsonUrl)), - url.fileURLToPath(base) + packageJsonUrl && fileURLToPath(new URL$1('.', packageJsonUrl)), + fileURLToPath(base) ) } @@ -19819,9 +19778,9 @@ function throwImportNotDefined(specifier, packageJsonUrl, base) { */ function throwExportsNotFound(subpath, packageJsonUrl, base) { throw new ERR_PACKAGE_PATH_NOT_EXPORTED( - url.fileURLToPath(new url.URL('.', packageJsonUrl)), + fileURLToPath(new URL$1('.', packageJsonUrl)), subpath, - base && url.fileURLToPath(base) + base && fileURLToPath(base) ) } @@ -19835,12 +19794,12 @@ function throwExportsNotFound(subpath, packageJsonUrl, base) { function throwInvalidSubpath(subpath, packageJsonUrl, internal, base) { const reason = `request is not a valid subpath for the "${ internal ? 'imports' : 'exports' - }" resolution of ${url.fileURLToPath(packageJsonUrl)}`; + }" resolution of ${fileURLToPath(packageJsonUrl)}`; throw new ERR_INVALID_MODULE_SPECIFIER( subpath, reason, - base && url.fileURLToPath(base) + base && fileURLToPath(base) ) } @@ -19865,11 +19824,11 @@ function throwInvalidPackageTarget( : `${target}`; throw new ERR_INVALID_PACKAGE_TARGET( - url.fileURLToPath(new url.URL('.', packageJsonUrl)), + fileURLToPath(new URL$1('.', packageJsonUrl)), subpath, target, internal, - base && url.fileURLToPath(base) + base && fileURLToPath(base) ) } @@ -19902,7 +19861,7 @@ function resolvePackageTargetString( let isURL = false; try { - new url.URL(target); + new URL$1(target); isURL = true; } catch {} @@ -19921,9 +19880,9 @@ function resolvePackageTargetString( if (invalidSegmentRegEx.test(target.slice(2))) throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base); - const resolved = new url.URL(target, packageJsonUrl); + const resolved = new URL$1(target, packageJsonUrl); const resolvedPath = resolved.pathname; - const packagePath = new url.URL('.', packageJsonUrl).pathname; + const packagePath = new URL$1('.', packageJsonUrl).pathname; if (!resolvedPath.startsWith(packagePath)) throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base); @@ -19933,8 +19892,8 @@ function resolvePackageTargetString( if (invalidSegmentRegEx.test(subpath)) throwInvalidSubpath(match + subpath, packageJsonUrl, internal, base); - if (pattern) return new url.URL(resolved.href.replace(patternRegEx, subpath)) - return new url.URL(subpath, resolved) + if (pattern) return new URL$1(resolved.href.replace(patternRegEx, subpath)) + return new URL$1(subpath, resolved) } /** @@ -20038,7 +19997,7 @@ function resolvePackageTarget( const key = keys[i]; if (isArrayIndex(key)) { throw new ERR_INVALID_PACKAGE_CONFIG( - url.fileURLToPath(packageJsonUrl), + fileURLToPath(packageJsonUrl), base, '"exports" cannot contain numeric property keys.' ) @@ -20104,7 +20063,7 @@ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) { isConditionalSugar = curIsConditionalSugar; } else if (isConditionalSugar !== curIsConditionalSugar) { throw new ERR_INVALID_PACKAGE_CONFIG( - url.fileURLToPath(packageJsonUrl), + fileURLToPath(packageJsonUrl), base, '"exports" cannot contain some keys starting with \'.\' and some not.' + ' The exports object must either be an object of package subpath keys' + @@ -20207,7 +20166,7 @@ function packageExportsResolve( function packageImportsResolve(name, base, conditions) { if (name === '#' || name.startsWith('#/')) { const reason = 'is not a valid internal imports specifier name'; - throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, url.fileURLToPath(base)) + throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base)) } /** @type {URL} */ @@ -20216,7 +20175,7 @@ function packageImportsResolve(name, base, conditions) { const packageConfig = getPackageScopeConfig(base); if (packageConfig.exists) { - packageJsonUrl = url.pathToFileURL(packageConfig.pjsonPath); + packageJsonUrl = pathToFileURL(packageConfig.pjsonPath); const imports = packageConfig.imports; if (imports) { if (own$d.call(imports, name)) { @@ -20325,7 +20284,7 @@ function parsePackageName(specifier, base) { throw new ERR_INVALID_MODULE_SPECIFIER( specifier, 'is not a valid package name', - url.fileURLToPath(base) + fileURLToPath(base) ) } @@ -20353,7 +20312,7 @@ function packageResolve(specifier, base, conditions) { // Can’t test. /* c8 ignore next 16 */ if (packageConfig.exists) { - const packageJsonUrl = url.pathToFileURL(packageConfig.pjsonPath); + const packageJsonUrl = pathToFileURL(packageConfig.pjsonPath); if ( packageConfig.name === packageName && packageConfig.exports !== undefined && @@ -20369,24 +20328,24 @@ function packageResolve(specifier, base, conditions) { } } - let packageJsonUrl = new url.URL( + let packageJsonUrl = new URL$1( './node_modules/' + packageName + '/package.json', base ); - let packageJsonPath = url.fileURLToPath(packageJsonUrl); + let packageJsonPath = fileURLToPath(packageJsonUrl); /** @type {string} */ let lastPath; do { const stat = tryStatSync(packageJsonPath.slice(0, -13)); if (!stat.isDirectory()) { lastPath = packageJsonPath; - packageJsonUrl = new url.URL( + packageJsonUrl = new URL$1( (isScoped ? '../../../../node_modules/' : '../../../node_modules/') + packageName + '/package.json', packageJsonUrl ); - packageJsonPath = url.fileURLToPath(packageJsonUrl); + packageJsonPath = fileURLToPath(packageJsonUrl); continue } @@ -20402,11 +20361,11 @@ function packageResolve(specifier, base, conditions) { ).resolved if (packageSubpath === '.') return legacyMainResolve(packageJsonUrl, packageConfig, base) - return new url.URL(packageSubpath, packageJsonUrl) + return new URL$1(packageSubpath, packageJsonUrl) // Cross-platform root check. } while (packageJsonPath.length !== lastPath.length) - throw new ERR_MODULE_NOT_FOUND(packageName, url.fileURLToPath(base)) + throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base)) } /** @@ -20455,12 +20414,12 @@ function moduleResolve(specifier, base, conditions) { let resolved; if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) { - resolved = new url.URL(specifier, base); + resolved = new URL$1(specifier, base); } else if (specifier[0] === '#') { ({resolved} = packageImportsResolve(specifier, base, conditions)); } else { try { - resolved = new url.URL(specifier); + resolved = new URL$1(specifier); } catch { resolved = packageResolve(specifier, base, conditions); } @@ -20480,7 +20439,7 @@ function defaultResolve(specifier, context = {}) { let parsed; try { - parsed = new url.URL(specifier); + parsed = new URL$1(specifier); if (parsed.protocol === 'data:') { return {url: specifier} } @@ -20496,20 +20455,20 @@ function defaultResolve(specifier, context = {}) { if (parentURL.startsWith('data:')) { // This is gonna blow up, we want the error - new url.URL(specifier, parentURL); + new URL$1(specifier, parentURL); } const conditions = getConditionsSet(context.conditions); - let url$1 = moduleResolve(specifier, new url.URL(parentURL), conditions); + let url = moduleResolve(specifier, new URL$1(parentURL), conditions); - const urlPath = url.fileURLToPath(url$1); - const real = require$$0$3.realpathSync(urlPath); - const old = url$1; - url$1 = url.pathToFileURL(real + (urlPath.endsWith(path__default['default'].sep) ? '/' : '')); - url$1.search = old.search; - url$1.hash = old.hash; + const urlPath = fileURLToPath(url); + const real = realpathSync$1(urlPath); + const old = url; + url = pathToFileURL(real + (urlPath.endsWith(path$b.sep) ? '/' : '')); + url.search = old.search; + url.hash = old.hash; - return {url: `${url$1}`} + return {url: `${url}`} } /** @@ -20625,7 +20584,7 @@ class FiggyPudding { } } try { - const util = require$$0__default$2['default']; + const util = require$$0$4; FiggyPudding.prototype[util.inspect.custom] = function (depth, opts) { return ( this[Symbol.toStringTag] + ' ' @@ -20746,7 +20705,7 @@ var locatePath$1 = {exports: {}}; var pathExists$1 = {exports: {}}; -const fs$5 = require$$0__default$1['default']; +const fs$5 = require$$0$3; pathExists$1.exports = fp => new Promise(resolve => { fs$5.access(fp, err => { @@ -20866,7 +20825,7 @@ var pLocate$1 = (iterable, tester, opts) => { .catch(err => err instanceof EndError ? err.value : Promise.reject(err)); }; -const path$7 = path__default['default']; +const path$7 = path$b; const pathExists = pathExists$1.exports; const pLocate = pLocate$1; @@ -20890,7 +20849,7 @@ locatePath$1.exports.sync = (iterable, options) => { } }; -const path$6 = path__default['default']; +const path$6 = path$b; const locatePath = locatePath$1.exports; findUp$1.exports = (filename, opts = {}) => { @@ -21145,12 +21104,12 @@ function unsafe$1 (val, doUnesc) { return val } -const fs$4 = require$$0__default$1['default']; +const fs$4 = require$$0$3; const figgyPudding = figgyPudding_1; const findUp = findUp$1.exports; const ini = ini$1; -const os = require$$0__default['default']; -const path$5 = path__default['default']; +const os = require$$0$2; +const path$5 = path$b; const NpmConfig = figgyPudding({}, { // Open up the pudding object. @@ -21276,7 +21235,7 @@ let builtinNpmConfig; // pass to `libnpmconfig` explicitly: /* c8 ignore next 4 */ if (windows && appData) { - builtinNpmConfig = {prefix: path__default['default'].join(appData, 'npm')}; + builtinNpmConfig = {prefix: path$b.join(appData, 'npm')}; } /** @@ -21291,12 +21250,12 @@ let npmPrefix = libnpmconfig.read(null, builtinNpmConfig).prefix; /* c8 ignore next 5 */ if (!npmPrefix) { npmPrefix = windows - ? path__default['default'].dirname(process.execPath) - : path__default['default'].resolve(process.execPath, '../..'); + ? path$b.dirname(process.execPath) + : path$b.resolve(process.execPath, '../..'); } const globalsDefault = electron || argv.indexOf(npmPrefix) === 0; -let globalDir = path__default['default'].resolve(npmPrefix, globalsLibrary, 'node_modules'); +let globalDir = path$b.resolve(npmPrefix, globalsLibrary, 'node_modules'); // If we’re in Electron, we’re running in a modified Node that cannot really // install global node modules. @@ -21307,8 +21266,8 @@ let globalDir = path__default['default'].resolve(npmPrefix, globalsLibrary, 'nod // Luckily NVM leaks some environment variables that we can pick up on to try // and detect the actual modules. /* c8 ignore next 3 */ -if (electron && nvm && !require$$0__default$1['default'].existsSync(globalDir)) { - globalDir = path__default['default'].resolve(nvm, '..', globalsLibrary, 'node_modules'); +if (electron && nvm && !require$$0$3.existsSync(globalDir)) { + globalDir = path$b.resolve(nvm, '..', globalsLibrary, 'node_modules'); } /** @@ -21324,7 +21283,7 @@ async function loadPlugin(name, options = {}) { /** @type {Object.} */ // Bug with coverage on Node@12. /* c8 ignore next 3 */ - const mod = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(url.pathToFileURL(fp).href)); }); + const mod = await import(pathToFileURL(fp).href); return key === false ? mod : mod[key] } @@ -21418,8 +21377,8 @@ async function resolvePlugin(name, options = {}) { try { // `import-meta-resolve` resolves from files, whereas `load-plugin` works // on folders, which is why we add a `/` at the end. - return url.fileURLToPath( - await resolve(name, url.pathToFileURL(base).href + '/') + return fileURLToPath( + await resolve(name, pathToFileURL(base).href + '/') ) // Bug with coverage on Node@12. /* c8 ignore next 1 */ @@ -21639,7 +21598,7 @@ class FindUp { /** @type {string|undefined} */ this.givenFilePath = options.filePath - ? path__default$1['default'].resolve(options.cwd, options.filePath) + ? path$c.resolve(options.cwd, options.filePath) : undefined; /* eslint-disable no-unused-expressions */ @@ -21664,12 +21623,12 @@ class FindUp { const cbs = [callback]; this.givenFile = cbs; debug$b('Checking given file `%s`', givenFilePath); - fs__default['default'].readFile(givenFilePath, (error, buf) => { + fs$a.readFile(givenFilePath, (error, buf) => { if (error) { /** @type {NodeJS.ErrnoException} */ const result = fault( 'Cannot read given file `%s`\n%s', - path__default$1['default'].relative(this.cwd, givenFilePath), + path$c.relative(this.cwd, givenFilePath), error.stack ); result.code = 'ENOENT'; @@ -21683,7 +21642,7 @@ class FindUp { loaded( fault( 'Cannot parse given file `%s`\n%s', - path__default$1['default'].relative(this.cwd, givenFilePath), + path$c.relative(this.cwd, givenFilePath), error.stack ) ); @@ -21709,8 +21668,8 @@ class FindUp { return callback(null) } - filePath = path__default$1['default'].resolve(this.cwd, filePath); - const parent = path__default$1['default'].dirname(filePath); + filePath = path$c.resolve(this.cwd, filePath); + const parent = path$c.dirname(filePath); if (parent in this.cache) { apply(callback, this.cache[parent]); @@ -21732,9 +21691,9 @@ class FindUp { // We do not use `readdir` because on huge directories, that could be // *very* slow. if (++index < self.names.length) { - fs__default['default'].readFile(path__default$1['default'].join(directory, self.names[index]), done); + fs$a.readFile(path$c.join(directory, self.names[index]), done); } else { - const parent = path__default$1['default'].dirname(directory); + const parent = path$c.dirname(directory); if (directory === parent) { debug$b('No files found for `%s`', filePath); @@ -21754,7 +21713,7 @@ class FindUp { * @returns {void} */ function done(error, buf) { - const fp = path__default$1['default'].join(directory, self.names[index]); + const fp = path$c.join(directory, self.names[index]); if (error) { // Hard to test. @@ -21767,7 +21726,7 @@ class FindUp { return found( fault( 'Cannot read file `%s`\n%s', - path__default$1['default'].relative(self.cwd, fp), + path$c.relative(self.cwd, fp), error.message ) ) @@ -21778,7 +21737,7 @@ class FindUp { found( fault( 'Cannot parse file `%s`\n%s', - path__default$1['default'].relative(self.cwd, fp), + path$c.relative(self.cwd, fp), error.message ) ); @@ -21955,7 +21914,7 @@ class Configuration { */ load(filePath, callback) { this.findUp.load( - filePath || path__default$1['default'].resolve(this.cwd, 'stdin.js'), + filePath || path$c.resolve(this.cwd, 'stdin.js'), (error, file) => { if (error || file) { return callback(error, file) @@ -21976,7 +21935,7 @@ class Configuration { async create(buf, filePath) { const options = {prefix: this.pluginPrefix, cwd: this.cwd}; const result = {settings: {}, plugins: []}; - const extname = filePath ? path__default$1['default'].extname(filePath) : undefined; + const extname = filePath ? path$c.extname(filePath) : undefined; const loader = extname && extname in loaders ? loaders[extname] : defaultLoader; /** @type {Preset|undefined} */ @@ -21994,7 +21953,7 @@ class Configuration { if ( filePath && value === undefined && - path__default$1['default'].basename(filePath) === 'package.json' + path$c.basename(filePath) === 'package.json' ) { return } @@ -22012,7 +21971,7 @@ class Configuration { result, value, // @ts-expect-error: `value` can only exist if w/ `filePath`. - Object.assign({}, options, {root: path__default$1['default'].dirname(filePath)}) + Object.assign({}, options, {root: path$c.dirname(filePath)}) ); } @@ -22042,7 +22001,7 @@ async function loadYaml(buf, filePath) { // C8 bug on Node@12 /* c8 ignore next 4 */ // @ts-expect-error: Assume it matches config. - return jsYaml.load(String(buf), {filename: path__default$1['default'].basename(filePath)}) + return jsYaml.load(String(buf), {filename: path$c.basename(filePath)}) } /** @type {Loader} */ @@ -22053,7 +22012,7 @@ async function loadJson(buf, filePath) { // C8 bug on Node@12 /* c8 ignore next 8 */ // @ts-expect-error: Assume it matches config. - return path__default$1['default'].basename(filePath) === 'package.json' + return path$c.basename(filePath) === 'package.json' ? // @ts-expect-error: `this` is the configuration context, TS doesn’t like // `this` on callbacks. // type-coverage:ignore-next-line @@ -22180,14 +22139,14 @@ async function merge(target, raw, options) { await merge( target, result, - Object.assign({}, options, {root: path__default$1['default'].dirname(fp)}) + Object.assign({}, options, {root: path$c.dirname(fp)}) ); } } catch { throw fault( 'Error: Expected preset or plugin, not %s, at `%s`', result, - path__default$1['default'].relative(options.root, fp) + path$c.relative(options.root, fp) ) } // C8 bug on Node@12 @@ -22251,7 +22210,7 @@ function find(entries, plugin) { async function loadFromAbsolutePath(fp, base) { try { /** @type {{default?: unknown}} */ - const result = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(node_url.pathToFileURL(fp).href)); }); + const result = await import(pathToFileURL$1(fp).href); if (!('default' in result)) { throw new Error( @@ -22264,7 +22223,7 @@ async function loadFromAbsolutePath(fp, base) { // C8 bug on Node@12 /* c8 ignore next 4 */ } catch (error) { - throw fault('Cannot import `%s`\n%s', path__default$1['default'].relative(base, fp), error.stack) + throw fault('Cannot import `%s`\n%s', path$c.relative(base, fp), error.stack) } } @@ -22924,19 +22883,19 @@ class Ignore { if (error) { callback(error); } else if (ignoreSet) { - const normal = path__default$1['default'].relative( - path__default$1['default'].resolve( + const normal = path$c.relative( + path$c.resolve( this.cwd, this.ignorePathResolveFrom === 'cwd' ? '.' : ignoreSet.filePath ), - path__default$1['default'].resolve(this.cwd, filePath) + path$c.resolve(this.cwd, filePath) ); if ( normal === '' || normal === '..' || - normal.charAt(0) === path__default$1['default'].sep || - normal.slice(0, 3) === '..' + path__default$1['default'].sep + normal.charAt(0) === path$c.sep || + normal.slice(0, 3) === '..' + path$c.sep ) { callback(null, false); } else { @@ -22957,7 +22916,7 @@ class Ignore { function create(buf, filePath) { /** @type {IgnoreConfig} */ return Object.assign(ignore().add(String(buf)), { - filePath: path__default$1['default'].dirname(filePath) + filePath: path$c.dirname(filePath) }) } @@ -22984,9 +22943,9 @@ var old$1 = {}; // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var pathModule = path__default['default']; +var pathModule = path$b; var isWindows = process.platform === 'win32'; -var fs$3 = require$$0__default$1['default']; +var fs$3 = require$$0$3; // JavaScript implementation of realpath, ported from node pre-v6 @@ -23274,7 +23233,7 @@ realpath.realpathSync = realpathSync; realpath.monkeypatch = monkeypatch; realpath.unmonkeypatch = unmonkeypatch; -var fs$2 = require$$0__default$1['default']; +var fs$2 = require$$0$3; var origRealpath = fs$2.realpath; var origRealpathSync = fs$2.realpathSync; @@ -23609,7 +23568,7 @@ minimatch$3.Minimatch = Minimatch$1; var path$4 = { sep: '/' }; try { - path$4 = path__default['default']; + path$4 = path$b; } catch (er) {} var GLOBSTAR = minimatch$3.GLOBSTAR = Minimatch$1.GLOBSTAR = {}; @@ -24561,7 +24520,7 @@ if (typeof Object.create === 'function') { } try { - var util$1 = require$$0__default$2['default']; + var util$1 = require$$0$4; /* istanbul ignore next */ if (typeof util$1.inherits !== 'function') throw ''; inherits$2.exports = util$1.inherits; @@ -24607,7 +24566,7 @@ function ownProp$2 (obj, field) { return Object.prototype.hasOwnProperty.call(obj, field) } -var path$3 = path__default['default']; +var path$3 = path$b; var minimatch$2 = minimatch_1; var isAbsolute$2 = pathIsAbsolute.exports; var Minimatch = minimatch$2.Minimatch; @@ -24837,11 +24796,11 @@ function childrenIgnored$2 (self, path) { var sync$1 = globSync$1; globSync$1.GlobSync = GlobSync$1; -var fs$1 = require$$0__default$1['default']; +var fs$1 = require$$0$3; var rp$1 = fs_realpath; var minimatch$1 = minimatch_1; -var path$2 = path__default['default']; -var assert$1 = assert__default['default']; +var path$2 = path$b; +var assert$1 = assert$2; var isAbsolute$1 = pathIsAbsolute.exports; var common$1 = common$2; common$1.alphasort; @@ -25490,13 +25449,13 @@ function slice$1 (args) { var glob_1 = glob; -var fs = require$$0__default$1['default']; +var fs = require$$0$3; var rp = fs_realpath; var minimatch = minimatch_1; var inherits$1 = inherits$2.exports; -var EE = require$$0__default$3['default'].EventEmitter; -var path$1 = path__default['default']; -var assert = assert__default['default']; +var EE = require$$0$5.EventEmitter; +var path$1 = path$b; +var assert = assert$2; var isAbsolute = pathIsAbsolute.exports; var globSync = sync$1; var common = common$2; @@ -26629,7 +26588,7 @@ class VFile { * Access parent path (`~`). */ get dirname() { - return typeof this.path === 'string' ? path__default['default'].dirname(this.path) : undefined + return typeof this.path === 'string' ? path$b.dirname(this.path) : undefined } /** @@ -26638,14 +26597,14 @@ class VFile { */ set dirname(dirname) { assertPath(this.path, 'dirname'); - this.path = path__default['default'].join(dirname || '', this.basename); + this.path = path$b.join(dirname || '', this.basename); } /** * Access basename (including extname) (`index.min.js`). */ get basename() { - return typeof this.path === 'string' ? path__default['default'].basename(this.path) : undefined + return typeof this.path === 'string' ? path$b.basename(this.path) : undefined } /** @@ -26656,14 +26615,14 @@ class VFile { set basename(basename) { assertNonEmpty(basename, 'basename'); assertPart(basename, 'basename'); - this.path = path__default['default'].join(this.dirname || '', basename); + this.path = path$b.join(this.dirname || '', basename); } /** * Access extname (including dot) (`.js`). */ get extname() { - return typeof this.path === 'string' ? path__default['default'].extname(this.path) : undefined + return typeof this.path === 'string' ? path$b.extname(this.path) : undefined } /** @@ -26684,7 +26643,7 @@ class VFile { } } - this.path = path__default['default'].join(this.dirname, this.stem + (extname || '')); + this.path = path$b.join(this.dirname, this.stem + (extname || '')); } /** @@ -26692,7 +26651,7 @@ class VFile { */ get stem() { return typeof this.path === 'string' - ? path__default['default'].basename(this.path, this.extname) + ? path$b.basename(this.path, this.extname) : undefined } @@ -26703,7 +26662,7 @@ class VFile { set stem(stem) { assertNonEmpty(stem, 'stem'); assertPart(stem, 'stem'); - this.path = path__default['default'].join(this.dirname || '', stem + (this.extname || '')); + this.path = path$b.join(this.dirname || '', stem + (this.extname || '')); } /** @@ -26786,9 +26745,9 @@ class VFile { * @returns {void} */ function assertPart(part, name) { - if (part && part.includes(path__default['default'].sep)) { + if (part && part.includes(path$b.sep)) { throw new Error( - '`' + name + '` cannot be a path: did not expect `' + path__default['default'].sep + '`' + '`' + name + '` cannot be a path: did not expect `' + path$b.sep + '`' ) } } @@ -26845,8 +26804,8 @@ function assertPath(path, name) { function toVFile(options) { if (typeof options === 'string' || isBuffer(options)) { options = {path: String(options)}; - } else if (options instanceof url.URL) { - options = {path: url.fileURLToPath(options)}; + } else if (options instanceof URL$1) { + options = {path: fileURLToPath(options)}; } return looksLikeAVFile$1(options) ? options : new VFile(options) @@ -26861,7 +26820,7 @@ function toVFile(options) { */ function readSync(description, options) { var file = toVFile(description); - file.value = require$$0__default$1['default'].readFileSync(path__default['default'].resolve(file.cwd, file.path), options); + file.value = require$$0$3.readFileSync(path$b.resolve(file.cwd, file.path), options); return file } @@ -26874,7 +26833,7 @@ function readSync(description, options) { */ function writeSync(description, options) { var file = toVFile(description); - require$$0__default$1['default'].writeFileSync(path__default['default'].resolve(file.cwd, file.path), file.value || '', options); + require$$0$3.writeFileSync(path$b.resolve(file.cwd, file.path), file.value || '', options); return file } @@ -26924,12 +26883,12 @@ const read$2 = var fp; try { - fp = path__default['default'].resolve(file.cwd, file.path); + fp = path$b.resolve(file.cwd, file.path); } catch (error) { return reject(error) } - require$$0__default$1['default'].readFile(fp, options, done); + require$$0$3.readFile(fp, options, done); /** * @param {Error} error @@ -26994,12 +26953,12 @@ const write = var fp; try { - fp = path__default['default'].resolve(file.cwd, file.path); + fp = path$b.resolve(file.cwd, file.path); } catch (error) { return reject(error) } - require$$0__default$1['default'].writeFile(fp, file.value || '', options, done); + require$$0$3.writeFile(fp, file.value || '', options, done); /** * @param {Error} error @@ -27129,11 +27088,11 @@ function expand(input, options, next) { } else { // `relative` to make the paths canonical. file = - path__default$1['default'].relative(options.cwd, path__default$1['default'].resolve(options.cwd, file)) || '.'; + path$c.relative(options.cwd, path$c.resolve(options.cwd, file)) || '.'; paths.push(file); } } else { - const fp = file.path ? path__default$1['default'].relative(options.cwd, file.path) : options.cwd; + const fp = file.path ? path$c.relative(options.cwd, file.path) : options.cwd; file.cwd = options.cwd; file.path = fp; file.history = [fp]; @@ -27187,11 +27146,11 @@ function search$1(input, options, next) { * @param {string|VFile} file */ function each(file) { - const ext = typeof file === 'string' ? path__default$1['default'].extname(file) : file.extname; + const ext = typeof file === 'string' ? path$c.extname(file) : file.extname; // Normalise globs. if (typeof file === 'string') { - file = file.split('/').join(path__default$1['default'].sep); + file = file.split('/').join(path$c.sep); } const part = base$1(file); @@ -27214,8 +27173,8 @@ function search$1(input, options, next) { } if (!ignored && dir) { - return fs__default['default'].readdir( - path__default$1['default'].resolve(options.cwd, filePath(file)), + return fs$a.readdir( + path$c.resolve(options.cwd, filePath(file)), (error, basenames) => { // Should not happen often: the directory is `stat`ed first, which was ok, // but reading it is not. @@ -27231,7 +27190,7 @@ function search$1(input, options, next) { one(null, [otherFile]); } else { search$1( - basenames.map((name) => path__default$1['default'].join(filePath(file), name)), + basenames.map((name) => path$c.join(filePath(file), name)), Object.assign({}, options, {nested: true}), one ); @@ -27301,8 +27260,8 @@ function search$1(input, options, next) { * @param {(error: NodeJS.ErrnoException|null, result?: SearchResults) => void} callback */ function statAndIgnore(file, options, callback) { - const fp = path__default$1['default'].resolve(options.cwd, filePath(file)); - const normal = path__default$1['default'].relative(options.cwd, fp); + const fp = path$c.resolve(options.cwd, filePath(file)); + const normal = path$c.relative(options.cwd, fp); let expected = 1; let actual = 0; /** @type {Stats|undefined} */ @@ -27312,7 +27271,7 @@ function statAndIgnore(file, options, callback) { if (typeof file === 'string' || !file.value) { expected++; - fs__default['default'].stat(fp, (error, value) => { + fs$a.stat(fp, (error, value) => { stats = value; onStartOrCheck(error); }); @@ -27339,8 +27298,8 @@ function statAndIgnore(file, options, callback) { ignored || (normal === '' || normal === '..' || - normal.charAt(0) === path__default$1['default'].sep || - normal.slice(0, 3) === '..' + path__default$1['default'].sep + normal.charAt(0) === path$c.sep || + normal.slice(0, 3) === '..' + path$c.sep ? false : options.extraIgnore.ignores(normal)) }); @@ -27353,7 +27312,7 @@ function statAndIgnore(file, options, callback) { * @returns {string} */ function base$1(file) { - return typeof file === 'string' ? path__default$1['default'].basename(file) : file.basename + return typeof file === 'string' ? path$c.basename(file) : file.basename } /** @@ -28159,7 +28118,7 @@ function packF32(v) { return packIEEE754(v, 8, 23); } }()); }(typedarray)); -var Writable = require$$1__default['default'].Writable; +var Writable = require$$1.Writable; var inherits = inherits$2.exports; var bufferFrom = bufferFrom_1; @@ -28369,7 +28328,7 @@ function stdin(context, settings, next) { * @typedef {import('trough').Pipeline} Pipeline */ -class FileSet extends node_events.EventEmitter { +class FileSet extends EventEmitter$1 { /** * FileSet constructor. * A FileSet is created to process multiple files through unified processors. @@ -28497,10 +28456,10 @@ function read$1(context, file, next) { debug$8('Not reading failed file `%s`', filePath); next(); } else { - filePath = path__default$1['default'].resolve(context.settings.cwd, filePath); + filePath = path$c.resolve(context.settings.cwd, filePath); debug$8('Reading `%s` in `%s`', filePath, 'utf8'); - fs__default['default'].readFile(filePath, 'utf8', (error, value) => { + fs$a.readFile(filePath, 'utf8', (error, value) => { debug$8('Read `%s` (error: %s)', filePath, error); file.value = value || ''; @@ -29196,15 +29155,15 @@ function copy(context, file, next) { return } - const outpath = path__default$1['default'].resolve(context.settings.cwd, output); + const outpath = path$c.resolve(context.settings.cwd, output); debug$2('Copying `%s`', currentPath); - fs__default['default'].stat(outpath, (error, stats) => { + fs$a.stat(outpath, (error, stats) => { if (error) { if ( error.code !== 'ENOENT' || - output.charAt(output.length - 1) === path__default$1['default'].sep + output.charAt(output.length - 1) === path$c.sep ) { return next( new Error('Cannot read output directory. Error:\n' + error.message) @@ -29213,7 +29172,7 @@ function copy(context, file, next) { // This is either given an error, or the parent exists which is a directory, // but we should keep the basename of the given file. - fs__default['default'].stat(path__default$1['default'].dirname(outpath), (error) => { + fs$a.stat(path$c.dirname(outpath), (error) => { if (error) { next( new Error('Cannot read parent directory. Error:\n' + error.message) @@ -29237,7 +29196,7 @@ function copy(context, file, next) { ) } - file[directory ? 'dirname' : 'path'] = path__default$1['default'].relative(file.cwd, outpath); + file[directory ? 'dirname' : 'path'] = path$c.relative(file.cwd, outpath); debug$2('Copying document from %s to %s', currentPath, file.path); @@ -29318,11 +29277,11 @@ function fileSystem(context, file, next) { return next() } - destinationPath = path__default$1['default'].resolve(context.settings.cwd, destinationPath); + destinationPath = path$c.resolve(context.settings.cwd, destinationPath); debug('Writing document to `%s`', destinationPath); file.stored = true; - fs__default['default'].writeFile(destinationPath, file.toString(), next); + fs$a.writeFile(destinationPath, file.toString(), next); } /** @@ -29435,14 +29394,14 @@ function transform$1(context, settings, next) { } } -function hasFlag(flag, argv = process__default['default'].argv) { +function hasFlag(flag, argv = process$1.argv) { const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); const position = argv.indexOf(prefix + flag); const terminatorPosition = argv.indexOf('--'); return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); } -const {env} = process__default['default']; +const {env} = process$1; let flagForceColor; if (hasFlag('no-color') || @@ -29518,10 +29477,10 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { return min; } - if (process__default['default'].platform === 'win32') { + if (process$1.platform === 'win32') { // Windows 10 build 10586 is the first Windows release that supports 256 colors. // Windows 10 build 14931 is the first release that supports 16m/TrueColor. - const osRelease = require$$0__default['default'].release().split('.'); + const osRelease = require$$0$2.release().split('.'); if ( Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 @@ -29585,8 +29544,8 @@ function createSupportsColor(stream, options = {}) { } const supportsColor = { - stdout: createSupportsColor({isTTY: tty__default['default'].isatty(1)}), - stderr: createSupportsColor({isTTY: tty__default['default'].isatty(2)}) + stdout: createSupportsColor({isTTY: tty$1.isatty(1)}), + stderr: createSupportsColor({isTTY: tty$1.isatty(2)}) }; function ansiRegex({onlyFirst = false} = {}) { @@ -30367,10 +30326,10 @@ function engine(options, callback) { const settings = {}; /** @type {NodeJS.ReadStream} */ // @ts-expect-error: `PassThrough` sure is readable. - let stdin = new stream.PassThrough(); + let stdin = new PassThrough(); try { - stdin = process__default$1['default'].stdin; + stdin = process$2.stdin; // Obscure bug in Node (seen on Windows). // See: , // . @@ -30393,7 +30352,7 @@ function engine(options, callback) { settings.processor = options.processor; // Path to run as. - settings.cwd = options.cwd || process__default$1['default'].cwd(); + settings.cwd = options.cwd || process$2.cwd(); // Input. settings.files = options.files || []; @@ -30405,8 +30364,8 @@ function engine(options, callback) { settings.streamIn = options.streamIn || stdin; // Output. - settings.streamOut = options.streamOut || process__default$1['default'].stdout; - settings.streamError = options.streamError || process__default$1['default'].stderr; + settings.streamOut = options.streamOut || process$2.stdout; + settings.streamError = options.streamError || process$2.stderr; settings.alwaysStringify = options.alwaysStringify; settings.output = options.output; settings.out = options.out; @@ -32913,15 +32872,15 @@ function parseJSON(value) { */ // Fake TTY stream. -const ttyStream = Object.assign(new stream__default['default'].Readable(), {isTTY: true}); +const ttyStream = Object.assign(new stream.Readable(), {isTTY: true}); // Exit, lazily, with the correct exit status code. let exitStatus = 0; -process__default$1['default'].on('exit', onexit); +process$2.on('exit', onexit); // Handle uncaught errors, such as from unexpected async behaviour. -process__default$1['default'].on('uncaughtException', fail); +process$2.on('uncaughtException', fail); /** * Start the CLI. @@ -32938,13 +32897,13 @@ function args(cliConfig) { try { // @ts-expect-error: Close enough. - config = options(process__default$1['default'].argv.slice(2), cliConfig); + config = options(process$2.argv.slice(2), cliConfig); } catch (error) { return fail(error, true) } if (config.help) { - process__default$1['default'].stdout.write( + process$2.stdout.write( [ 'Usage: ' + cliConfig.name + ' [options] [path | glob ...]', '', @@ -32962,7 +32921,7 @@ function args(cliConfig) { } if (config.version) { - process__default$1['default'].stdout.write(cliConfig.version + '\n', noop$1); + process$2.stdout.write(cliConfig.version + '\n', noop$1); return } @@ -32977,7 +32936,7 @@ function args(cliConfig) { // Do not write to stdout(4). config.out = false; - process__default$1['default'].stderr.write( + process$2.stderr.write( source$1.bold('Watching...') + ' (press CTRL+C to exit)\n', noop$1 ); @@ -32986,7 +32945,7 @@ function args(cliConfig) { if (output === true) { config.output = false; - process__default$1['default'].stderr.write( + process$2.stderr.write( source$1.yellow('Note') + ': Ignoring `--output` until exit.\n', noop$1 ); @@ -33037,14 +32996,14 @@ function args(cliConfig) { engine(config, done); }); - process__default$1['default'].on('SIGINT', onsigint); + process$2.on('SIGINT', onsigint); /** * Handle a SIGINT. */ function onsigint() { // Hide the `^C` in terminal. - process__default$1['default'].stderr.write('\n', noop$1); + process$2.stderr.write('\n', noop$1); clean(); @@ -33071,12 +33030,12 @@ function fail(error, pretty) { exitStatus = 1; - process__default$1['default'].stderr.write(message.trim() + '\n', noop$1); + process$2.stderr.write(message.trim() + '\n', noop$1); } function onexit() { /* eslint-disable unicorn/no-process-exit */ - process__default$1['default'].exit(exitStatus); + process$2.exit(exitStatus); /* eslint-enable unicorn/no-process-exit */ } @@ -45473,7 +45432,7 @@ const dependencies = { const main = "dist/index.js"; const scripts = { build: "npx rollup -c", - "build-node": "npm run build && npx shx cp dist/index.js ../lint-md.js" + "build-node": "npm run build && npx shx cp dist/index.mjs ../lint-md.mjs" }; var cli = { name: name, @@ -56030,12 +55989,12 @@ function* getLinksRecursively(node) { } function validateLinks(tree, vfile) { - const currentFileURL = url.pathToFileURL(path__default['default'].join(vfile.cwd, vfile.path)); + const currentFileURL = pathToFileURL(path$b.join(vfile.cwd, vfile.path)); let previousDefinitionLabel; for (const node of getLinksRecursively(tree)) { if (node.url[0] !== "#") { const targetURL = new URL(node.url, currentFileURL); - if (targetURL.protocol === "file:" && !require$$0__default$1['default'].existsSync(targetURL)) { + if (targetURL.protocol === "file:" && !require$$0$3.existsSync(targetURL)) { vfile.message("Broken link", node); } else if (targetURL.pathname === currentFileURL.pathname) { const expected = node.url.includes("#") diff --git a/tools/node-lint-md-cli-rollup/package.json b/tools/node-lint-md-cli-rollup/package.json index 0602d902c2a37e..56ad44b391eee2 100644 --- a/tools/node-lint-md-cli-rollup/package.json +++ b/tools/node-lint-md-cli-rollup/package.json @@ -19,6 +19,6 @@ "main": "dist/index.js", "scripts": { "build": "npx rollup -c", - "build-node": "npm run build && npx shx cp dist/index.js ../lint-md.js" + "build-node": "npm run build && npx shx cp dist/index.mjs ../lint-md.mjs" } } diff --git a/tools/node-lint-md-cli-rollup/rollup.config.js b/tools/node-lint-md-cli-rollup/rollup.config.js index 013ba13b9b774c..0a2b2098e69dd6 100644 --- a/tools/node-lint-md-cli-rollup/rollup.config.js +++ b/tools/node-lint-md-cli-rollup/rollup.config.js @@ -7,8 +7,8 @@ const json = require('@rollup/plugin-json'); module.exports = { input: 'src/cli-entry.mjs', output: { - file: 'dist/index.js', - format: 'cjs', + file: 'dist/index.mjs', + format: 'es', sourcemap: false, exports: 'none', }, From c6f73a9dd2bdc1bbb3278c72af03383164cc868f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 21 Aug 2021 09:07:00 -0700 Subject: [PATCH 4/4] fixup! fixup! fixup! tools: fix markdown linting --- .eslintignore | 2 +- vcbuild.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintignore b/.eslintignore index 19e0fcee9e1b5a..e8b8c3f297709a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,7 +4,7 @@ test/addons/??_* test/fixtures test/message/esm_display_syntax_error.mjs tools/icu -tools/lint-md.js +tools/lint-md.mjs tools/node-lint-md-cli-rollup/dist benchmark/tmp doc/**/*.js diff --git a/vcbuild.bat b/vcbuild.bat index 202b0ecb7e69e8..f5f3fa4226bb6e 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -674,7 +674,7 @@ for /D %%D IN (doc\*) do ( set "lint_md_files="%%F" !lint_md_files!" ) ) -%node_exe% tools\lint-md.js -q -f %lint_md_files% +%node_exe% tools\lint-md.mjs -q -f %lint_md_files% ENDLOCAL goto exit