/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 3029:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
Z: () => (/* binding */ createCache)
});
;// CONCATENATED MODULE: ./node_modules/.pnpm/@emotion+sheet@1.2.2/node_modules/@emotion/sheet/dist/emotion-sheet.browser.esm.js
/*
Based off glamor's StyleSheet, thanks Sunil ❤️
high performance StyleSheet for css-in-js systems
- uses multiple style tags behind the scenes for millions of rules
- uses `insertRule` for appending in production for *much* faster performance
// usage
import { StyleSheet } from '@emotion/sheet'
let styleSheet = new StyleSheet({ key: '', container: document.head })
styleSheet.insert('#box { border: 1px solid red; }')
- appends a css rule into the stylesheet
styleSheet.flush()
- empties the stylesheet of all its contents
*/
// $FlowFixMe
function sheetForTag(tag) {
if (tag.sheet) {
// $FlowFixMe
return tag.sheet;
} // this weirdness brought to you by firefox
/* istanbul ignore next */
for (var i = 0; i < document.styleSheets.length; i++) {
if (document.styleSheets[i].ownerNode === tag) {
// $FlowFixMe
return document.styleSheets[i];
}
}
}
function createStyleElement(options) {
var tag = document.createElement('style');
tag.setAttribute('data-emotion', options.key);
if (options.nonce !== undefined) {
tag.setAttribute('nonce', options.nonce);
}
tag.appendChild(document.createTextNode(''));
tag.setAttribute('data-s', '');
return tag;
}
var StyleSheet = /*#__PURE__*/function () {
// Using Node instead of HTMLElement since container may be a ShadowRoot
function StyleSheet(options) {
var _this = this;
this._insertTag = function (tag) {
var before;
if (_this.tags.length === 0) {
if (_this.insertionPoint) {
before = _this.insertionPoint.nextSibling;
} else if (_this.prepend) {
before = _this.container.firstChild;
} else {
before = _this.before;
}
} else {
before = _this.tags[_this.tags.length - 1].nextSibling;
}
_this.container.insertBefore(tag, before);
_this.tags.push(tag);
};
this.isSpeedy = options.speedy === undefined ? "production" === 'production' : options.speedy;
this.tags = [];
this.ctr = 0;
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets
this.key = options.key;
this.container = options.container;
this.prepend = options.prepend;
this.insertionPoint = options.insertionPoint;
this.before = null;
}
var _proto = StyleSheet.prototype;
_proto.hydrate = function hydrate(nodes) {
nodes.forEach(this._insertTag);
};
_proto.insert = function insert(rule) {
// the max length is how many rules we have per style tag, it's 65000 in speedy mode
// it's 1 in dev because we insert source maps that map a single rule to a location
// and you can only have one source map per style tag
if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {
this._insertTag(createStyleElement(this));
}
var tag = this.tags[this.tags.length - 1];
if (false) { var isImportRule; }
if (this.isSpeedy) {
var sheet = sheetForTag(tag);
try {
// this is the ultrafast version, works across browsers
// the big drawback is that the css won't be editable in devtools
sheet.insertRule(rule, sheet.cssRules.length);
} catch (e) {
if (false) {}
}
} else {
tag.appendChild(document.createTextNode(rule));
}
this.ctr++;
};
_proto.flush = function flush() {
// $FlowFixMe
this.tags.forEach(function (tag) {
return tag.parentNode && tag.parentNode.removeChild(tag);
});
this.tags = [];
this.ctr = 0;
if (false) {}
};
return StyleSheet;
}();
;// CONCATENATED MODULE: ./node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Utility.js
/**
* @param {number}
* @return {number}
*/
var abs = Math.abs;
/**
* @param {number}
* @return {string}
*/
var Utility_from = String.fromCharCode;
/**
* @param {object}
* @return {object}
*/
var Utility_assign = Object.assign;
/**
* @param {string} value
* @param {number} length
* @return {number}
*/
function hash(value, length) {
return Utility_charat(value, 0) ^ 45 ? (((length << 2 ^ Utility_charat(value, 0)) << 2 ^ Utility_charat(value, 1)) << 2 ^ Utility_charat(value, 2)) << 2 ^ Utility_charat(value, 3) : 0;
}
/**
* @param {string} value
* @return {string}
*/
function trim(value) {
return value.trim();
}
/**
* @param {string} value
* @param {RegExp} pattern
* @return {string?}
*/
function Utility_match(value, pattern) {
return (value = pattern.exec(value)) ? value[0] : value;
}
/**
* @param {string} value
* @param {(string|RegExp)} pattern
* @param {string} replacement
* @return {string}
*/
function Utility_replace(value, pattern, replacement) {
return value.replace(pattern, replacement);
}
/**
* @param {string} value
* @param {string} search
* @return {number}
*/
function indexof(value, search) {
return value.indexOf(search);
}
/**
* @param {string} value
* @param {number} index
* @return {number}
*/
function Utility_charat(value, index) {
return value.charCodeAt(index) | 0;
}
/**
* @param {string} value
* @param {number} begin
* @param {number} end
* @return {string}
*/
function Utility_substr(value, begin, end) {
return value.slice(begin, end);
}
/**
* @param {string} value
* @return {number}
*/
function Utility_strlen(value) {
return value.length;
}
/**
* @param {any[]} value
* @return {number}
*/
function Utility_sizeof(value) {
return value.length;
}
/**
* @param {any} value
* @param {any[]} array
* @return {any}
*/
function Utility_append(value, array) {
return array.push(value), value;
}
/**
* @param {string[]} array
* @param {function} callback
* @return {string}
*/
function Utility_combine(array, callback) {
return array.map(callback).join('');
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Tokenizer.js
var line = 1;
var column = 1;
var Tokenizer_length = 0;
var position = 0;
var character = 0;
var characters = '';
/**
* @param {string} value
* @param {object | null} root
* @param {object | null} parent
* @param {string} type
* @param {string[] | string} props
* @param {object[] | string} children
* @param {number} length
*/
function node(value, root, parent, type, props, children, length) {
return {
value: value,
root: root,
parent: parent,
type: type,
props: props,
children: children,
line: line,
column: column,
length: length,
return: ''
};
}
/**
* @param {object} root
* @param {object} props
* @return {object}
*/
function Tokenizer_copy(root, props) {
return Utility_assign(node('', null, null, '', null, null, 0), root, {
length: -root.length
}, props);
}
/**
* @return {number}
*/
function Tokenizer_char() {
return character;
}
/**
* @return {number}
*/
function prev() {
character = position > 0 ? Utility_charat(characters, --position) : 0;
if (column--, character === 10) column = 1, line--;
return character;
}
/**
* @return {number}
*/
function next() {
character = position < Tokenizer_length ? Utility_charat(characters, position++) : 0;
if (column++, character === 10) column = 1, line++;
return character;
}
/**
* @return {number}
*/
function peek() {
return Utility_charat(characters, position);
}
/**
* @return {number}
*/
function caret() {
return position;
}
/**
* @param {number} begin
* @param {number} end
* @return {string}
*/
function slice(begin, end) {
return Utility_substr(characters, begin, end);
}
/**
* @param {number} type
* @return {number}
*/
function token(type) {
switch (type) {
// \0 \t \n \r \s whitespace token
case 0:
case 9:
case 10:
case 13:
case 32:
return 5;
// ! + , / > @ ~ isolate token
case 33:
case 43:
case 44:
case 47:
case 62:
case 64:
case 126:
// ; { } breakpoint token
case 59:
case 123:
case 125:
return 4;
// : accompanied token
case 58:
return 3;
// " ' ( [ opening delimit token
case 34:
case 39:
case 40:
case 91:
return 2;
// ) ] closing delimit token
case 41:
case 93:
return 1;
}
return 0;
}
/**
* @param {string} value
* @return {any[]}
*/
function alloc(value) {
return line = column = 1, Tokenizer_length = Utility_strlen(characters = value), position = 0, [];
}
/**
* @param {any} value
* @return {any}
*/
function dealloc(value) {
return characters = '', value;
}
/**
* @param {number} type
* @return {string}
*/
function delimit(type) {
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)));
}
/**
* @param {string} value
* @return {string[]}
*/
function Tokenizer_tokenize(value) {
return dealloc(tokenizer(alloc(value)));
}
/**
* @param {number} type
* @return {string}
*/
function whitespace(type) {
while (character = peek()) if (character < 33) next();else break;
return token(type) > 2 || token(character) > 3 ? '' : ' ';
}
/**
* @param {string[]} children
* @return {string[]}
*/
function tokenizer(children) {
while (next()) switch (token(character)) {
case 0:
append(identifier(position - 1), children);
break;
case 2:
append(delimit(character), children);
break;
default:
append(from(character), children);
}
return children;
}
/**
* @param {number} index
* @param {number} count
* @return {string}
*/
function escaping(index, count) {
while (--count && next())
// not 0-9 A-F a-f
if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97) break;
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32));
}
/**
* @param {number} type
* @return {number}
*/
function delimiter(type) {
while (next()) switch (character) {
// ] ) " '
case type:
return position;
// " '
case 34:
case 39:
if (type !== 34 && type !== 39) delimiter(character);
break;
// (
case 40:
if (type === 41) delimiter(type);
break;
// \
case 92:
next();
break;
}
return position;
}
/**
* @param {number} type
* @param {number} index
* @return {number}
*/
function commenter(type, index) {
while (next())
// //
if (type + character === 47 + 10) break;
// /*
else if (type + character === 42 + 42 && peek() === 47) break;
return '/*' + slice(index, position - 1) + '*' + Utility_from(type === 47 ? type : next());
}
/**
* @param {number} index
* @return {string}
*/
function identifier(index) {
while (!token(peek())) next();
return slice(index, position);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Enum.js
var Enum_MS = '-ms-';
var Enum_MOZ = '-moz-';
var Enum_WEBKIT = '-webkit-';
var COMMENT = 'comm';
var Enum_RULESET = 'rule';
var Enum_DECLARATION = 'decl';
var PAGE = '@page';
var MEDIA = '@media';
var IMPORT = '@import';
var CHARSET = '@charset';
var VIEWPORT = '@viewport';
var SUPPORTS = '@supports';
var DOCUMENT = '@document';
var NAMESPACE = '@namespace';
var Enum_KEYFRAMES = '@keyframes';
var FONT_FACE = '@font-face';
var COUNTER_STYLE = '@counter-style';
var FONT_FEATURE_VALUES = '@font-feature-values';
var LAYER = '@layer';
;// CONCATENATED MODULE: ./node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Serializer.js
/**
* @param {object[]} children
* @param {function} callback
* @return {string}
*/
function Serializer_serialize(children, callback) {
var output = '';
var length = Utility_sizeof(children);
for (var i = 0; i < length; i++) output += callback(children[i], i, children, callback) || '';
return output;
}
/**
* @param {object} element
* @param {number} index
* @param {object[]} children
* @param {function} callback
* @return {string}
*/
function stringify(element, index, children, callback) {
switch (element.type) {
case LAYER:
if (element.children.length) break;
case IMPORT:
case Enum_DECLARATION:
return element.return = element.return || element.value;
case COMMENT:
return '';
case Enum_KEYFRAMES:
return element.return = element.value + '{' + Serializer_serialize(element.children, callback) + '}';
case Enum_RULESET:
element.value = element.props.join(',');
}
return Utility_strlen(children = Serializer_serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : '';
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Middleware.js
/**
* @param {function[]} collection
* @return {function}
*/
function middleware(collection) {
var length = Utility_sizeof(collection);
return function (element, index, children, callback) {
var output = '';
for (var i = 0; i < length; i++) output += collection[i](element, index, children, callback) || '';
return output;
};
}
/**
* @param {function} callback
* @return {function}
*/
function rulesheet(callback) {
return function (element) {
if (!element.root) if (element = element.return) callback(element);
};
}
/**
* @param {object} element
* @param {number} index
* @param {object[]} children
* @param {function} callback
*/
function prefixer(element, index, children, callback) {
if (element.length > -1) if (!element.return) switch (element.type) {
case DECLARATION:
element.return = prefix(element.value, element.length, children);
return;
case KEYFRAMES:
return serialize([copy(element, {
value: replace(element.value, '@', '@' + WEBKIT)
})], callback);
case RULESET:
if (element.length) return combine(element.props, function (value) {
switch (match(value, /(::plac\w+|:read-\w+)/)) {
// :read-(only|write)
case ':read-only':
case ':read-write':
return serialize([copy(element, {
props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]
})], callback);
// :placeholder
case '::placeholder':
return serialize([copy(element, {
props: [replace(value, /:(plac\w+)/, ':' + WEBKIT + 'input-$1')]
}), copy(element, {
props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]
}), copy(element, {
props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]
})], callback);
}
return '';
});
}
}
/**
* @param {object} element
* @param {number} index
* @param {object[]} children
*/
function namespace(element) {
switch (element.type) {
case RULESET:
element.props = element.props.map(function (value) {
return combine(tokenize(value), function (value, index, children) {
switch (charat(value, 0)) {
// \f
case 12:
return substr(value, 1, strlen(value));
// \0 ( + > ~
case 0:
case 40:
case 43:
case 62:
case 126:
return value;
// :
case 58:
if (children[++index] === 'global') children[index] = '', children[++index] = '\f' + substr(children[index], index = 1, -1);
// \s
case 32:
return index === 1 ? '' : value;
default:
switch (index) {
case 0:
element = value;
return sizeof(children) > 1 ? '' : value;
case index = sizeof(children) - 1:
case 2:
return index === 2 ? value + element + element : value + element;
default:
return value;
}
}
});
});
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Parser.js
/**
* @param {string} value
* @return {object[]}
*/
function compile(value) {
return dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value));
}
/**
* @param {string} value
* @param {object} root
* @param {object?} parent
* @param {string[]} rule
* @param {string[]} rules
* @param {string[]} rulesets
* @param {number[]} pseudo
* @param {number[]} points
* @param {string[]} declarations
* @return {object}
*/
function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
var index = 0;
var offset = 0;
var length = pseudo;
var atrule = 0;
var property = 0;
var previous = 0;
var variable = 1;
var scanning = 1;
var ampersand = 1;
var character = 0;
var type = '';
var props = rules;
var children = rulesets;
var reference = rule;
var characters = type;
while (scanning) switch (previous = character, character = next()) {
// (
case 40:
if (previous != 108 && Utility_charat(characters, length - 1) == 58) {
if (indexof(characters += Utility_replace(delimit(character), '&', '&\f'), '&\f') != -1) ampersand = -1;
break;
}
// " ' [
case 34:
case 39:
case 91:
characters += delimit(character);
break;
// \t \n \r \s
case 9:
case 10:
case 13:
case 32:
characters += whitespace(previous);
break;
// \
case 92:
characters += escaping(caret() - 1, 7);
continue;
// /
case 47:
switch (peek()) {
case 42:
case 47:
Utility_append(comment(commenter(next(), caret()), root, parent), declarations);
break;
default:
characters += '/';
}
break;
// {
case 123 * variable:
points[index++] = Utility_strlen(characters) * ampersand;
// } ; \0
case 125 * variable:
case 59:
case 0:
switch (character) {
// \0 }
case 0:
case 125:
scanning = 0;
// ;
case 59 + offset:
if (ampersand == -1) characters = Utility_replace(characters, /\f/g, '');
if (property > 0 && Utility_strlen(characters) - length) Utility_append(property > 32 ? declaration(characters + ';', rule, parent, length - 1) : declaration(Utility_replace(characters, ' ', '') + ';', rule, parent, length - 2), declarations);
break;
// @ ;
case 59:
characters += ';';
// { rule/at-rule
default:
Utility_append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length), rulesets);
if (character === 123) if (offset === 0) parse(characters, root, reference, reference, props, rulesets, length, points, children);else switch (atrule === 99 && Utility_charat(characters, 3) === 110 ? 100 : atrule) {
// d l m s
case 100:
case 108:
case 109:
case 115:
parse(value, reference, reference, rule && Utility_append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length), children), rules, children, length, points, rule ? props : children);
break;
default:
parse(characters, reference, reference, reference, [''], children, 0, points, children);
}
}
index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo;
break;
// :
case 58:
length = 1 + Utility_strlen(characters), property = previous;
default:
if (variable < 1) if (character == 123) --variable;else if (character == 125 && variable++ == 0 && prev() == 125) continue;
switch (characters += Utility_from(character), character * variable) {
// &
case 38:
ampersand = offset > 0 ? 1 : (characters += '\f', -1);
break;
// ,
case 44:
points[index++] = (Utility_strlen(characters) - 1) * ampersand, ampersand = 1;
break;
// @
case 64:
// -
if (peek() === 45) characters += delimit(next());
atrule = peek(), offset = length = Utility_strlen(type = characters += identifier(caret())), character++;
break;
// -
case 45:
if (previous === 45 && Utility_strlen(characters) == 2) variable = 0;
}
}
return rulesets;
}
/**
* @param {string} value
* @param {object} root
* @param {object?} parent
* @param {number} index
* @param {number} offset
* @param {string[]} rules
* @param {number[]} points
* @param {string} type
* @param {string[]} props
* @param {string[]} children
* @param {number} length
* @return {object}
*/
function ruleset(value, root, parent, index, offset, rules, points, type, props, children, length) {
var post = offset - 1;
var rule = offset === 0 ? rules : [''];
var size = Utility_sizeof(rule);
for (var i = 0, j = 0, k = 0; i < index; ++i) for (var x = 0, y = Utility_substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x) if (z = trim(j > 0 ? rule[x] + ' ' + y : Utility_replace(y, /&\f/g, rule[x]))) props[k++] = z;
return node(value, root, parent, offset === 0 ? Enum_RULESET : type, props, children, length);
}
/**
* @param {number} value
* @param {object} root
* @param {object?} parent
* @return {object}
*/
function comment(value, root, parent) {
return node(value, root, parent, COMMENT, Utility_from(Tokenizer_char()), Utility_substr(value, 2, -2), 0);
}
/**
* @param {string} value
* @param {object} root
* @param {object?} parent
* @param {number} length
* @return {object}
*/
function declaration(value, root, parent, length) {
return node(value, root, parent, Enum_DECLARATION, Utility_substr(value, 0, length), Utility_substr(value, length + 1, -1), length);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/@emotion+cache@11.11.0/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js
var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
var previous = 0;
var character = 0;
while (true) {
previous = character;
character = peek(); // &\f
if (previous === 38 && character === 12) {
points[index] = 1;
}
if (token(character)) {
break;
}
next();
}
return slice(begin, position);
};
var toRules = function toRules(parsed, points) {
// pretend we've started with a comma
var index = -1;
var character = 44;
do {
switch (token(character)) {
case 0:
// &\f
if (character === 38 && peek() === 12) {
// this is not 100% correct, we don't account for literal sequences here - like for example quoted strings
// stylis inserts \f after & to know when & where it should replace this sequence with the context selector
// and when it should just concatenate the outer and inner selectors
// it's very unlikely for this sequence to actually appear in a different context, so we just leverage this fact here
points[index] = 1;
}
parsed[index] += identifierWithPointTracking(position - 1, points, index);
break;
case 2:
parsed[index] += delimit(character);
break;
case 4:
// comma
if (character === 44) {
// colon
parsed[++index] = peek() === 58 ? '&\f' : '';
points[index] = parsed[index].length;
break;
}
// fallthrough
default:
parsed[index] += Utility_from(character);
}
} while (character = next());
return parsed;
};
var getRules = function getRules(value, points) {
return dealloc(toRules(alloc(value), points));
}; // WeakSet would be more appropriate, but only WeakMap is supported in IE11
var fixedElements = /* #__PURE__ */new WeakMap();
var compat = function compat(element) {
if (element.type !== 'rule' || !element.parent ||
// positive .length indicates that this rule contains pseudo
// negative .length indicates that this rule has been already prefixed
element.length < 1) {
return;
}
var value = element.value,
parent = element.parent;
var isImplicitRule = element.column === parent.column && element.line === parent.line;
while (parent.type !== 'rule') {
parent = parent.parent;
if (!parent) return;
} // short-circuit for the simplest case
if (element.props.length === 1 && value.charCodeAt(0) !== 58
/* colon */ && !fixedElements.get(parent)) {
return;
} // if this is an implicitly inserted rule (the one eagerly inserted at the each new nested level)
// then the props has already been manipulated beforehand as they that array is shared between it and its "rule parent"
if (isImplicitRule) {
return;
}
fixedElements.set(element, true);
var points = [];
var rules = getRules(value, points);
var parentRules = parent.props;
for (var i = 0, k = 0; i < rules.length; i++) {
for (var j = 0; j < parentRules.length; j++, k++) {
element.props[k] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
}
}
};
var removeLabel = function removeLabel(element) {
if (element.type === 'decl') {
var value = element.value;
if (
// charcode for l
value.charCodeAt(0) === 108 &&
// charcode for b
value.charCodeAt(2) === 98) {
// this ignores label
element["return"] = '';
element.value = '';
}
}
};
var ignoreFlag = 'emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason';
var isIgnoringComment = function isIgnoringComment(element) {
return element.type === 'comm' && element.children.indexOf(ignoreFlag) > -1;
};
var createUnsafeSelectorsAlarm = function createUnsafeSelectorsAlarm(cache) {
return function (element, index, children) {
if (element.type !== 'rule' || cache.compat) return;
var unsafePseudoClasses = element.value.match(/(:first|:nth|:nth-last)-child/g);
if (unsafePseudoClasses) {
var isNested = !!element.parent; // in nested rules comments become children of the "auto-inserted" rule and that's always the `element.parent`
//
// considering this input:
// .a {
// .b /* comm */ {}
// color: hotpink;
// }
// we get output corresponding to this:
// .a {
// & {
// /* comm */
// color: hotpink;
// }
// .b {}
// }
var commentContainer = isNested ? element.parent.children :
// global rule at the root level
children;
for (var i = commentContainer.length - 1; i >= 0; i--) {
var node = commentContainer[i];
if (node.line < element.line) {
break;
} // it is quite weird but comments are *usually* put at `column: element.column - 1`
// so we seek *from the end* for the node that is earlier than the rule's `element` and check that
// this will also match inputs like this:
// .a {
// /* comm */
// .b {}
// }
//
// but that is fine
//
// it would be the easiest to change the placement of the comment to be the first child of the rule:
// .a {
// .b { /* comm */ }
// }
// with such inputs we wouldn't have to search for the comment at all
// TODO: consider changing this comment placement in the next major version
if (node.column < element.column) {
if (isIgnoringComment(node)) {
return;
}
break;
}
}
unsafePseudoClasses.forEach(function (unsafePseudoClass) {
console.error("The pseudo class \"" + unsafePseudoClass + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + unsafePseudoClass.split('-child')[0] + "-of-type\".");
});
}
};
};
var isImportRule = function isImportRule(element) {
return element.type.charCodeAt(1) === 105 && element.type.charCodeAt(0) === 64;
};
var isPrependedWithRegularRules = function isPrependedWithRegularRules(index, children) {
for (var i = index - 1; i >= 0; i--) {
if (!isImportRule(children[i])) {
return true;
}
}
return false;
}; // use this to remove incorrect elements from further processing
// so they don't get handed to the `sheet` (or anything else)
// as that could potentially lead to additional logs which in turn could be overhelming to the user
var nullifyElement = function nullifyElement(element) {
element.type = '';
element.value = '';
element["return"] = '';
element.children = '';
element.props = '';
};
var incorrectImportAlarm = function incorrectImportAlarm(element, index, children) {
if (!isImportRule(element)) {
return;
}
if (element.parent) {
console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles.");
nullifyElement(element);
} else if (isPrependedWithRegularRules(index, children)) {
console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules.");
nullifyElement(element);
}
};
/* eslint-disable no-fallthrough */
function emotion_cache_browser_esm_prefix(value, length) {
switch (hash(value, length)) {
// color-adjust
case 5103:
return Enum_WEBKIT + 'print-' + value + value;
// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
case 5737:
case 4201:
case 3177:
case 3433:
case 1641:
case 4457:
case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
case 5572:
case 6356:
case 5844:
case 3191:
case 6645:
case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
case 6391:
case 5879:
case 5623:
case 6135:
case 4599:
case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
case 4215:
case 6389:
case 5109:
case 5365:
case 5621:
case 3829:
return Enum_WEBKIT + value + value;
// appearance, user-select, transform, hyphens, text-size-adjust
case 5349:
case 4246:
case 4810:
case 6968:
case 2756:
return Enum_WEBKIT + value + Enum_MOZ + value + Enum_MS + value + value;
// flex, flex-direction
case 6828:
case 4268:
return Enum_WEBKIT + value + Enum_MS + value + value;
// order
case 6165:
return Enum_WEBKIT + value + Enum_MS + 'flex-' + value + value;
// align-items
case 5187:
return Enum_WEBKIT + value + Utility_replace(value, /(\w+).+(:[^]+)/, Enum_WEBKIT + 'box-$1$2' + Enum_MS + 'flex-$1$2') + value;
// align-self
case 5443:
return Enum_WEBKIT + value + Enum_MS + 'flex-item-' + Utility_replace(value, /flex-|-self/, '') + value;
// align-content
case 4675:
return Enum_WEBKIT + value + Enum_MS + 'flex-line-pack' + Utility_replace(value, /align-content|flex-|-self/, '') + value;
// flex-shrink
case 5548:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, 'shrink', 'negative') + value;
// flex-basis
case 5292:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, 'basis', 'preferred-size') + value;
// flex-grow
case 6060:
return Enum_WEBKIT + 'box-' + Utility_replace(value, '-grow', '') + Enum_WEBKIT + value + Enum_MS + Utility_replace(value, 'grow', 'positive') + value;
// transition
case 4554:
return Enum_WEBKIT + Utility_replace(value, /([^-])(transform)/g, '$1' + Enum_WEBKIT + '$2') + value;
// cursor
case 6187:
return Utility_replace(Utility_replace(Utility_replace(value, /(zoom-|grab)/, Enum_WEBKIT + '$1'), /(image-set)/, Enum_WEBKIT + '$1'), value, '') + value;
// background, background-image
case 5495:
case 3959:
return Utility_replace(value, /(image-set\([^]*)/, Enum_WEBKIT + '$1' + '$`$1');
// justify-content
case 4968:
return Utility_replace(Utility_replace(value, /(.+:)(flex-)?(.*)/, Enum_WEBKIT + 'box-pack:$3' + Enum_MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + Enum_WEBKIT + value + value;
// (margin|padding)-inline-(start|end)
case 4095:
case 3583:
case 4068:
case 2532:
return Utility_replace(value, /(.+)-inline(.+)/, Enum_WEBKIT + '$1$2') + value;
// (min|max)?(width|height|inline-size|block-size)
case 8116:
case 7059:
case 5753:
case 5535:
case 5445:
case 5701:
case 4933:
case 4677:
case 5533:
case 5789:
case 5021:
case 4765:
// stretch, max-content, min-content, fill-available
if (Utility_strlen(value) - 1 - length > 6) switch (Utility_charat(value, length + 1)) {
// (m)ax-content, (m)in-content
case 109:
// -
if (Utility_charat(value, length + 4) !== 45) break;
// (f)ill-available, (f)it-content
case 102:
return Utility_replace(value, /(.+:)(.+)-([^]+)/, '$1' + Enum_WEBKIT + '$2-$3' + '$1' + Enum_MOZ + (Utility_charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value;
// (s)tretch
case 115:
return ~indexof(value, 'stretch') ? emotion_cache_browser_esm_prefix(Utility_replace(value, 'stretch', 'fill-available'), length) + value : value;
}
break;
// position: sticky
case 4949:
// (s)ticky?
if (Utility_charat(value, length + 1) !== 115) break;
// display: (flex|inline-flex)
case 6444:
switch (Utility_charat(value, Utility_strlen(value) - 3 - (~indexof(value, '!important') && 10))) {
// stic(k)y
case 107:
return Utility_replace(value, ':', ':' + Enum_WEBKIT) + value;
// (inline-)?fl(e)x
case 101:
return Utility_replace(value, /(.+:)([^;!]+)(;|!.+)?/, '$1' + Enum_WEBKIT + (Utility_charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + Enum_WEBKIT + '$2$3' + '$1' + Enum_MS + '$2box$3') + value;
}
break;
// writing-mode
case 5936:
switch (Utility_charat(value, length + 11)) {
// vertical-l(r)
case 114:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, /[svh]\w+-[tblr]{2}/, 'tb') + value;
// vertical-r(l)
case 108:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') + value;
// horizontal(-)tb
case 45:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, /[svh]\w+-[tblr]{2}/, 'lr') + value;
}
return Enum_WEBKIT + value + Enum_MS + value + value;
}
return value;
}
var emotion_cache_browser_esm_prefixer = function prefixer(element, index, children, callback) {
if (element.length > -1) if (!element["return"]) switch (element.type) {
case Enum_DECLARATION:
element["return"] = emotion_cache_browser_esm_prefix(element.value, element.length);
break;
case Enum_KEYFRAMES:
return Serializer_serialize([Tokenizer_copy(element, {
value: Utility_replace(element.value, '@', '@' + Enum_WEBKIT)
})], callback);
case Enum_RULESET:
if (element.length) return Utility_combine(element.props, function (value) {
switch (Utility_match(value, /(::plac\w+|:read-\w+)/)) {
// :read-(only|write)
case ':read-only':
case ':read-write':
return Serializer_serialize([Tokenizer_copy(element, {
props: [Utility_replace(value, /:(read-\w+)/, ':' + Enum_MOZ + '$1')]
})], callback);
// :placeholder
case '::placeholder':
return Serializer_serialize([Tokenizer_copy(element, {
props: [Utility_replace(value, /:(plac\w+)/, ':' + Enum_WEBKIT + 'input-$1')]
}), Tokenizer_copy(element, {
props: [Utility_replace(value, /:(plac\w+)/, ':' + Enum_MOZ + '$1')]
}), Tokenizer_copy(element, {
props: [Utility_replace(value, /:(plac\w+)/, Enum_MS + 'input-$1')]
})], callback);
}
return '';
});
}
};
var defaultStylisPlugins = [emotion_cache_browser_esm_prefixer];
var createCache = function createCache(options) {
var key = options.key;
if (false) {}
if (key === 'css') {
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
// document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
// note this very very intentionally targets all style elements regardless of the key to ensure
// that creating a cache works inside of render of a React component
Array.prototype.forEach.call(ssrStyles, function (node) {
// we want to only move elements which have a space in the data-emotion attribute value
// because that indicates that it is an Emotion 11 server-side rendered style elements
// while we will already ignore Emotion 11 client-side inserted styles because of the :not([data-s]) part in the selector
// Emotion 10 client-side inserted styles did not have data-s (but importantly did not have a space in their data-emotion attributes)
// so checking for the space ensures that loading Emotion 11 after Emotion 10 has inserted some styles
// will not result in the Emotion 10 styles being destroyed
var dataEmotionAttribute = node.getAttribute('data-emotion');
if (dataEmotionAttribute.indexOf(' ') === -1) {
return;
}
document.head.appendChild(node);
node.setAttribute('data-s', '');
});
}
var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
if (false) {}
var inserted = {};
var container;
var nodesToHydrate = [];
{
container = options.container || document.head;
Array.prototype.forEach.call(
// this means we will ignore elements which don't have a space in them which
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) {
var attrib = node.getAttribute("data-emotion").split(' '); // $FlowFixMe
for (var i = 1; i < attrib.length; i++) {
inserted[attrib[i]] = true;
}
nodesToHydrate.push(node);
});
}
var _insert;
var omnipresentPlugins = [compat, removeLabel];
if (false) {}
{
var currentSheet;
var finalizingPlugins = [stringify, false ? 0 : rulesheet(function (rule) {
currentSheet.insert(rule);
})];
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
var stylis = function stylis(styles) {
return Serializer_serialize(compile(styles), serializer);
};
_insert = function insert(selector, serialized, sheet, shouldCache) {
currentSheet = sheet;
if (false) {}
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
if (shouldCache) {
cache.inserted[serialized.name] = true;
}
};
}
var cache = {
key: key,
sheet: new StyleSheet({
key: key,
container: container,
nonce: options.nonce,
speedy: options.speedy,
prepend: options.prepend,
insertionPoint: options.insertionPoint
}),
nonce: options.nonce,
inserted: inserted,
registered: {},
insert: _insert
};
cache.sheet.hydrate(nodesToHydrate);
return cache;
};
/***/ }),
/***/ 7506:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Z: () => (/* binding */ memoize)
/* harmony export */ });
function memoize(fn) {
var cache = Object.create(null);
return function (arg) {
if (cache[arg] === undefined) cache[arg] = fn(arg);
return cache[arg];
};
}
/***/ }),
/***/ 2412:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ C: () => (/* binding */ CacheProvider),
/* harmony export */ T: () => (/* binding */ ThemeContext),
/* harmony export */ i: () => (/* binding */ isBrowser),
/* harmony export */ w: () => (/* binding */ withEmotionCache)
/* harmony export */ });
/* unused harmony exports E, _, a, b, c, h, u */
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7948);
/* harmony import */ var _emotion_cache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3029);
/* harmony import */ var _emotion_serialize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7073);
/* harmony import */ var _emotion_use_insertion_effect_with_fallbacks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(122);
var isBrowser = "object" !== 'undefined';
var hasOwnProperty = {}.hasOwnProperty;
var EmotionCacheContext = /* #__PURE__ */react__WEBPACK_IMPORTED_MODULE_0__.createContext(
// we're doing this to avoid preconstruct's dead code elimination in this one case
// because this module is primarily intended for the browser and node
// but it's also required in react native and similar environments sometimes
// and we could have a special build just for that
// but this is much easier and the native packages
// might use a different theme context in the future anyway
typeof HTMLElement !== 'undefined' ? /* #__PURE__ */(0,_emotion_cache__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)({
key: 'css'
}) : null);
if (false) {}
var CacheProvider = EmotionCacheContext.Provider;
var __unsafe_useEmotionCache = function useEmotionCache() {
return useContext(EmotionCacheContext);
};
var withEmotionCache = function withEmotionCache(func) {
// $FlowFixMe
return /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function (props, ref) {
// the cache will never be null in the browser
var cache = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(EmotionCacheContext);
return func(props, cache, ref);
});
};
if (!isBrowser) {
withEmotionCache = function withEmotionCache(func) {
return function (props) {
var cache = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(EmotionCacheContext);
if (cache === null) {
// yes, we're potentially creating this on every render
// it doesn't actually matter though since it's only on the server
// so there will only every be a single render
// that could change in the future because of suspense and etc. but for now,
// this works and i don't want to optimise for a future thing that we aren't sure about
cache = (0,_emotion_cache__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)({
key: 'css'
});
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EmotionCacheContext.Provider, {
value: cache
}, func(props, cache));
} else {
return func(props, cache);
}
};
};
}
var ThemeContext = /* #__PURE__ */react__WEBPACK_IMPORTED_MODULE_0__.createContext({});
if (false) {}
var useTheme = function useTheme() {
return React.useContext(ThemeContext);
};
var getTheme = function getTheme(outerTheme, theme) {
if (typeof theme === 'function') {
var mergedTheme = theme(outerTheme);
if (false) {}
return mergedTheme;
}
if (false) {}
return _extends({}, outerTheme, theme);
};
var createCacheWithTheme = /* #__PURE__ */(/* unused pure expression or super */ null && (weakMemoize(function (outerTheme) {
return weakMemoize(function (theme) {
return getTheme(outerTheme, theme);
});
})));
var ThemeProvider = function ThemeProvider(props) {
var theme = React.useContext(ThemeContext);
if (props.theme !== theme) {
theme = createCacheWithTheme(theme)(props.theme);
}
return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
value: theme
}, props.children);
};
function withTheme(Component) {
var componentName = Component.displayName || Component.name || 'Component';
var render = function render(props, ref) {
var theme = React.useContext(ThemeContext);
return /*#__PURE__*/React.createElement(Component, _extends({
theme: theme,
ref: ref
}, props));
}; // $FlowFixMe
var WithTheme = /*#__PURE__*/React.forwardRef(render);
WithTheme.displayName = "WithTheme(" + componentName + ")";
return hoistNonReactStatics(WithTheme, Component);
}
var getLastPart = function getLastPart(functionName) {
// The match may be something like 'Object.createEmotionProps' or
// 'Loader.prototype.render'
var parts = functionName.split('.');
return parts[parts.length - 1];
};
var getFunctionNameFromStackTraceLine = function getFunctionNameFromStackTraceLine(line) {
// V8
var match = /^\s+at\s+([A-Za-z0-9$.]+)\s/.exec(line);
if (match) return getLastPart(match[1]); // Safari / Firefox
match = /^([A-Za-z0-9$.]+)@/.exec(line);
if (match) return getLastPart(match[1]);
return undefined;
};
var internalReactFunctionNames = /* #__PURE__ */new Set(['renderWithHooks', 'processChild', 'finishClassComponent', 'renderToString']); // These identifiers come from error stacks, so they have to be valid JS
// identifiers, thus we only need to replace what is a valid character for JS,
// but not for CSS.
var sanitizeIdentifier = function sanitizeIdentifier(identifier) {
return identifier.replace(/\$/g, '-');
};
var getLabelFromStackTrace = function getLabelFromStackTrace(stackTrace) {
if (!stackTrace) return undefined;
var lines = stackTrace.split('\n');
for (var i = 0; i < lines.length; i++) {
var functionName = getFunctionNameFromStackTraceLine(lines[i]); // The first line of V8 stack traces is just "Error"
if (!functionName) continue; // If we reach one of these, we have gone too far and should quit
if (internalReactFunctionNames.has(functionName)) break; // The component name is the first function in the stack that starts with an
// uppercase letter
if (/^[A-Z]/.test(functionName)) return sanitizeIdentifier(functionName);
}
return undefined;
};
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
var createEmotionProps = function createEmotionProps(type, props) {
if (false) {}
var newProps = {};
for (var key in props) {
if (hasOwnProperty.call(props, key)) {
newProps[key] = props[key];
}
}
newProps[typePropName] = type; // For performance, only call getLabelFromStackTrace in development and when
// the label hasn't already been computed
if (false) { var label; }
return newProps;
};
var Insertion = function Insertion(_ref) {
var cache = _ref.cache,
serialized = _ref.serialized,
isStringTag = _ref.isStringTag;
registerStyles(cache, serialized, isStringTag);
useInsertionEffectAlwaysWithSyncFallback(function () {
return insertStyles(cache, serialized, isStringTag);
});
return null;
};
var Emotion = /* #__PURE__ */(/* unused pure expression or super */ null && (withEmotionCache(function (props, cache, ref) {
var cssProp = props.css; // so that using `css` from `emotion` and passing the result to the css prop works
// not passing the registered cache to serializeStyles because it would
// make certain babel optimisations not possible
if (typeof cssProp === 'string' && cache.registered[cssProp] !== undefined) {
cssProp = cache.registered[cssProp];
}
var WrappedComponent = props[typePropName];
var registeredStyles = [cssProp];
var className = '';
if (typeof props.className === 'string') {
className = getRegisteredStyles(cache.registered, registeredStyles, props.className);
} else if (props.className != null) {
className = props.className + " ";
}
var serialized = serializeStyles(registeredStyles, undefined, React.useContext(ThemeContext));
if (false) { var labelFromStack; }
className += cache.key + "-" + serialized.name;
var newProps = {};
for (var key in props) {
if (hasOwnProperty.call(props, key) && key !== 'css' && key !== typePropName && ( true || 0)) {
newProps[key] = props[key];
}
}
newProps.ref = ref;
newProps.className = className;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
cache: cache,
serialized: serialized,
isStringTag: typeof WrappedComponent === 'string'
}), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
})));
if (false) {}
var Emotion$1 = (/* unused pure expression or super */ null && (Emotion));
/***/ }),
/***/ 2150:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ F4: () => (/* binding */ keyframes),
/* harmony export */ iv: () => (/* binding */ css),
/* harmony export */ xB: () => (/* binding */ Global)
/* harmony export */ });
/* unused harmony exports ClassNames, createElement, jsx */
/* harmony import */ var _emotion_element_c39617d8_browser_esm_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2412);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7948);
/* harmony import */ var _emotion_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1443);
/* harmony import */ var _emotion_use_insertion_effect_with_fallbacks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(122);
/* harmony import */ var _emotion_serialize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7073);
/* harmony import */ var _emotion_cache__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3029);
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9761);
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_4__);
var pkg = {
name: "@emotion/react",
version: "11.11.1",
main: "dist/emotion-react.cjs.js",
module: "dist/emotion-react.esm.js",
browser: {
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
},
exports: {
".": {
module: {
worker: "./dist/emotion-react.worker.esm.js",
browser: "./dist/emotion-react.browser.esm.js",
"default": "./dist/emotion-react.esm.js"
},
"import": "./dist/emotion-react.cjs.mjs",
"default": "./dist/emotion-react.cjs.js"
},
"./jsx-runtime": {
module: {
worker: "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
browser: "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
},
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
},
"./_isolated-hnrs": {
module: {
worker: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
browser: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
},
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
},
"./jsx-dev-runtime": {
module: {
worker: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
browser: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
},
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
},
"./package.json": "./package.json",
"./types/css-prop": "./types/css-prop.d.ts",
"./macro": {
types: {
"import": "./macro.d.mts",
"default": "./macro.d.ts"
},
"default": "./macro.js"
}
},
types: "types/index.d.ts",
files: ["src", "dist", "jsx-runtime", "jsx-dev-runtime", "_isolated-hnrs", "types/*.d.ts", "macro.*"],
sideEffects: false,
author: "Emotion Contributors",
license: "MIT",
scripts: {
"test:typescript": "dtslint types"
},
dependencies: {
"@babel/runtime": "^7.18.3",
"@emotion/babel-plugin": "^11.11.0",
"@emotion/cache": "^11.11.0",
"@emotion/serialize": "^1.1.2",
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
"@emotion/utils": "^1.2.1",
"@emotion/weak-memoize": "^0.3.1",
"hoist-non-react-statics": "^3.3.1"
},
peerDependencies: {
react: ">=16.8.0"
},
peerDependenciesMeta: {
"@types/react": {
optional: true
}
},
devDependencies: {
"@definitelytyped/dtslint": "0.0.112",
"@emotion/css": "11.11.0",
"@emotion/css-prettifier": "1.1.3",
"@emotion/server": "11.11.0",
"@emotion/styled": "11.11.0",
"html-tag-names": "^1.1.2",
react: "16.14.0",
"svg-tag-names": "^1.1.1",
typescript: "^4.5.5"
},
repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
publishConfig: {
access: "public"
},
"umd:main": "dist/emotion-react.umd.min.js",
preconstruct: {
entrypoints: ["./index.js", "./jsx-runtime.js", "./jsx-dev-runtime.js", "./_isolated-hnrs.js"],
umdName: "emotionReact",
exports: {
envConditions: ["browser", "worker"],
extra: {
"./types/css-prop": "./types/css-prop.d.ts",
"./macro": {
types: {
"import": "./macro.d.mts",
"default": "./macro.d.ts"
},
"default": "./macro.js"
}
}
}
}
};
var jsx = function jsx(type, props) {
var args = arguments;
if (props == null || !hasOwnProperty.call(props, 'css')) {
// $FlowFixMe
return React.createElement.apply(undefined, args);
}
var argsLength = args.length;
var createElementArgArray = new Array(argsLength);
createElementArgArray[0] = Emotion;
createElementArgArray[1] = createEmotionProps(type, props);
for (var i = 2; i < argsLength; i++) {
createElementArgArray[i] = args[i];
} // $FlowFixMe
return React.createElement.apply(null, createElementArgArray);
};
var warnedAboutCssPropForGlobal = false; // maintain place over rerenders.
// initial render from browser, insertBefore context.sheet.tags[0] or if a style hasn't been inserted there yet, appendChild
// initial client-side render from SSR, use place of hydrating tag
var Global = /* #__PURE__ */(0,_emotion_element_c39617d8_browser_esm_js__WEBPACK_IMPORTED_MODULE_5__.w)(function (props, cache) {
if (false) {}
var styles = props.styles;
var serialized = (0,_emotion_serialize__WEBPACK_IMPORTED_MODULE_2__/* .serializeStyles */ .O)([styles], undefined, react__WEBPACK_IMPORTED_MODULE_0__.useContext(_emotion_element_c39617d8_browser_esm_js__WEBPACK_IMPORTED_MODULE_5__.T));
if (!_emotion_element_c39617d8_browser_esm_js__WEBPACK_IMPORTED_MODULE_5__.i) {
var _ref;
var serializedNames = serialized.name;
var serializedStyles = serialized.styles;
var next = serialized.next;
while (next !== undefined) {
serializedNames += ' ' + next.name;
serializedStyles += next.styles;
next = next.next;
}
var shouldCache = cache.compat === true;
var rules = cache.insert("", {
name: serializedNames,
styles: serializedStyles
}, cache.sheet, shouldCache);
if (shouldCache) {
return null;
}
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("style", (_ref = {}, _ref["data-emotion"] = cache.key + "-global " + serializedNames, _ref.dangerouslySetInnerHTML = {
__html: rules
}, _ref.nonce = cache.sheet.nonce, _ref));
} // yes, i know these hooks are used conditionally
// but it is based on a constant that will never change at runtime
// it's effectively like having two implementations and switching them out
// so it's not actually breaking anything
var sheetRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef();
(0,_emotion_use_insertion_effect_with_fallbacks__WEBPACK_IMPORTED_MODULE_1__/* .useInsertionEffectWithLayoutFallback */ .j)(function () {
var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
var sheet = new cache.sheet.constructor({
key: key,
nonce: cache.sheet.nonce,
container: cache.sheet.container,
speedy: cache.sheet.isSpeedy
});
var rehydrating = false; // $FlowFixMe
var node = document.querySelector("style[data-emotion=\"" + key + " " + serialized.name + "\"]");
if (cache.sheet.tags.length) {
sheet.before = cache.sheet.tags[0];
}
if (node !== null) {
rehydrating = true; // clear the hash so this node won't be recognizable as rehydratable by other
} */
let marker;
return start;
/**
* Start of code.
*
* ```markdown
* > | ~~~js
* ^
* | alert(1)
* | ~~~
* ```
*
* @type {State}
*/
function start(code) {
// To do: parse whitespace like `markdown-rs`.
return beforeSequenceOpen(code);
}
/**
* In opening fence, after prefix, at sequence.
*
* ```markdown
* > | ~~~js
* ^
* | alert(1)
* | ~~~
* ```
*
* @type {State}
*/
function beforeSequenceOpen(code) {
const tail = self.events[self.events.length - 1];
initialPrefix = tail && tail[1].type === 'linePrefix' ? tail[2].sliceSerialize(tail[1], true).length : 0;
marker = code;
effects.enter('codeFenced');
effects.enter('codeFencedFence');
effects.enter('codeFencedFenceSequence');
return sequenceOpen(code);
}
/**
* In opening fence sequence.
*
* ```markdown
* > | ~~~js
* ^
* | alert(1)
* | ~~~
* ```
*
* @type {State}
*/
function sequenceOpen(code) {
if (code === marker) {
sizeOpen++;
effects.consume(code);
return sequenceOpen;
}
if (sizeOpen < 3) {
return nok(code);
}
effects.exit('codeFencedFenceSequence');
return markdownSpace(code) ? factorySpace(effects, infoBefore, 'whitespace')(code) : infoBefore(code);
}
/**
* In opening fence, after the sequence (and optional whitespace), before info.
*
* ```markdown
* > | ~~~js
* ^
* | alert(1)
* | ~~~
* ```
*
* @type {State}
*/
function infoBefore(code) {
if (code === null || markdownLineEnding(code)) {
effects.exit('codeFencedFence');
return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
}
effects.enter('codeFencedFenceInfo');
effects.enter('chunkString', {
contentType: 'string'
});
return info(code);
}
/**
* In info.
*
* ```markdown
* > | ~~~js
* ^
* | alert(1)
* | ~~~
* ```
*
* @type {State}
*/
function info(code) {
if (code === null || markdownLineEnding(code)) {
effects.exit('chunkString');
effects.exit('codeFencedFenceInfo');
return infoBefore(code);
}
if (markdownSpace(code)) {
effects.exit('chunkString');
effects.exit('codeFencedFenceInfo');
return factorySpace(effects, metaBefore, 'whitespace')(code);
}
if (code === 96 && code === marker) {
return nok(code);
}
effects.consume(code);
return info;
}
/**
* In opening fence, after info and whitespace, before meta.
*
* ```markdown
* > | ~~~js eval
* ^
* | alert(1)
* | ~~~
* ```
*
* @type {State}
*/
function metaBefore(code) {
if (code === null || markdownLineEnding(code)) {
return infoBefore(code);
}
effects.enter('codeFencedFenceMeta');
effects.enter('chunkString', {
contentType: 'string'
});
return meta(code);
}
/**
* In meta.
*
* ```markdown
* > | ~~~js eval
* ^
* | alert(1)
* | ~~~
* ```
*
* @type {State}
*/
function meta(code) {
if (code === null || markdownLineEnding(code)) {
effects.exit('chunkString');
effects.exit('codeFencedFenceMeta');
return infoBefore(code);
}
if (code === 96 && code === marker) {
return nok(code);
}
effects.consume(code);
return meta;
}
/**
* At eol/eof in code, before a non-lazy closing fence or content.
*
* ```markdown
* > | ~~~js
* ^
* > | alert(1)
* ^
* | ~~~
* ```
*
* @type {State}
*/
function atNonLazyBreak(code) {
return effects.attempt(closeStart, after, contentBefore)(code);
}
/**
* Before code content, not a closing fence, at eol.
*
* ```markdown
* | ~~~js
* > | alert(1)
* ^
* | ~~~
* ```
*
* @type {State}
*/
function contentBefore(code) {
effects.enter('lineEnding');
effects.consume(code);
effects.exit('lineEnding');
return contentStart;
}
/**
* Before code content, not a closing fence.
*
* ```markdown
* | ~~~js
* > | alert(1)
* ^
* | ~~~
* ```
*
* @type {State}
*/
function contentStart(code) {
return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, 'linePrefix', initialPrefix + 1)(code) : beforeContentChunk(code);
}
/**
* Before code content, after optional prefix.
*
* ```markdown
* | ~~~js
* > | alert(1)
* ^
* | ~~~
* ```
*
* @type {State}
*/
function beforeContentChunk(code) {
if (code === null || markdownLineEnding(code)) {
return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
}
effects.enter('codeFlowValue');
return contentChunk(code);
}
/**
* In code content.
*
* ```markdown
* | ~~~js
* > | alert(1)
* ^^^^^^^^
* | ~~~
* ```
*
* @type {State}
*/
function contentChunk(code) {
if (code === null || markdownLineEnding(code)) {
effects.exit('codeFlowValue');
return beforeContentChunk(code);
}
effects.consume(code);
return contentChunk;
}
/**
* After code.
*
* ```markdown
* | ~~~js
* | alert(1)
* > | ~~~
* ^
* ```
*
* @type {State}
*/
function after(code) {
effects.exit('codeFenced');
return ok(code);
}
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeCloseStart(effects, ok, nok) {
let size = 0;
return startBefore;
/**
*
*
* @type {State}
*/
function startBefore(code) {
effects.enter('lineEnding');
effects.consume(code);
effects.exit('lineEnding');
return start;
}
/**
* Before closing fence, at optional whitespace.
*
* ```markdown
* | ~~~js
* | alert(1)
* > | ~~~
* ^
* ```
*
* @type {State}
*/
function start(code) {
// Always populated by defaults.
// To do: `enter` here or in next state?
effects.enter('codeFencedFence');
return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, 'linePrefix', self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : beforeSequenceClose(code);
}
/**
* In closing fence, after optional whitespace, at sequence.
*
* ```markdown
* | ~~~js
* | alert(1)
* > | ~~~
* ^
* ```
*
* @type {State}
*/
function beforeSequenceClose(code) {
if (code === marker) {
effects.enter('codeFencedFenceSequence');
return sequenceClose(code);
}
return nok(code);
}
/**
* In closing fence sequence.
*
* ```markdown
* | ~~~js
* | alert(1)
* > | ~~~
* ^
* ```
*
* @type {State}
*/
function sequenceClose(code) {
if (code === marker) {
size++;
effects.consume(code);
return sequenceClose;
}
if (size >= sizeOpen) {
effects.exit('codeFencedFenceSequence');
return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, 'whitespace')(code) : sequenceCloseAfter(code);
}
return nok(code);
}
/**
* After closing fence sequence, after optional whitespace.
*
* ```markdown
* | ~~~js
* | alert(1)
* > | ~~~
* ^
* ```
*
* @type {State}
*/
function sequenceCloseAfter(code) {
if (code === null || markdownLineEnding(code)) {
effects.exit('codeFencedFence');
return ok(code);
}
return nok(code);
}
}
}
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeNonLazyContinuation(effects, ok, nok) {
const self = this;
return start;
/**
*
*
* @type {State}
*/
function start(code) {
if (code === null) {
return nok(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);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/decode-named-character-reference@1.0.2/node_modules/decode-named-character-reference/index.dom.js
///
/* eslint-env browser */
const index_dom_element = document.createElement('i');
/**
* @param {string} value
* @returns {string|false}
*/
function decodeNamedCharacterReference(value) {
const characterReference = '&' + value + ';';
index_dom_element.innerHTML = characterReference;
const char = index_dom_element.textContent;
// Some named character references do not require the closing semicolon
// (`¬`, for instance), which leads to situations where parsing the assumed
// named reference of `¬it;` will result in the string `¬it;`.
// When we encounter a trailing semicolon after parsing, and the character
// reference to decode was not a semicolon (`;`), we can assume that the
// matching was not complete.
// @ts-expect-error: TypeScript is wrong that `textContent` on elements can
// yield `null`.
if (char.charCodeAt(char.length - 1) === 59 /* `;` */ && value !== 'semi') {
return false;
}
// If the decoded string is equal to the input, the character reference was
// not valid.
// @ts-expect-error: TypeScript is wrong that `textContent` on elements can
// yield `null`.
return char === characterReference ? false : char;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/character-reference.js
/**
* @typedef {import('micromark-util-types').Code} Code
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const characterReference = {
name: 'characterReference',
tokenize: tokenizeCharacterReference
};
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeCharacterReference(effects, ok, nok) {
const self = this;
let size = 0;
/** @type {number} */
let max;
/** @type {(code: Code) => boolean} */
let test;
return start;
/**
* Start of character reference.
*
* ```markdown
* > | a&b
* ^
* > | a{b
* ^
* > | a b
* ^
* ```
*
* @type {State}
*/
function start(code) {
effects.enter('characterReference');
effects.enter('characterReferenceMarker');
effects.consume(code);
effects.exit('characterReferenceMarker');
return open;
}
/**
* After `&`, at `#` for numeric references or alphanumeric for named
* references.
*
* ```markdown
* > | a&b
* ^
* > | a{b
* ^
* > | a b
* ^
* ```
*
* @type {State}
*/
function open(code) {
if (code === 35) {
effects.enter('characterReferenceMarkerNumeric');
effects.consume(code);
effects.exit('characterReferenceMarkerNumeric');
return numeric;
}
effects.enter('characterReferenceValue');
max = 31;
test = asciiAlphanumeric;
return value(code);
}
/**
* After `#`, at `x` for hexadecimals or digit for decimals.
*
* ```markdown
* > | a{b
* ^
* > | a b
* ^
* ```
*
* @type {State}
*/
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;
}
effects.enter('characterReferenceValue');
max = 7;
test = asciiDigit;
return value(code);
}
/**
* After markers (``, ``, or `&`), in value, before `;`.
*
* The character reference kind defines what and how many characters are
* allowed.
*
* ```markdown
* > | a&b
* ^^^
* > | a{b
* ^^^
* > | a b
* ^
* ```
*
* @type {State}
*/
function value(code) {
if (code === 59 && size) {
const token = effects.exit('characterReferenceValue');
if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) {
return nok(code);
}
// To do: `markdown-rs` uses a different name:
// `CharacterReferenceMarkerSemi`.
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);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/character-escape.js
/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const characterEscape = {
name: 'characterEscape',
tokenize: tokenizeCharacterEscape
};
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeCharacterEscape(effects, ok, nok) {
return start;
/**
* Start of character escape.
*
* ```markdown
* > | a\*b
* ^
* ```
*
* @type {State}
*/
function start(code) {
effects.enter('characterEscape');
effects.enter('escapeMarker');
effects.consume(code);
effects.exit('escapeMarker');
return inside;
}
/**
* After `\`, at punctuation.
*
* ```markdown
* > | a\*b
* ^
* ```
*
* @type {State}
*/
function inside(code) {
// ASCII punctuation.
if (asciiPunctuation(code)) {
effects.enter('characterEscapeValue');
effects.consume(code);
effects.exit('characterEscapeValue');
effects.exit('characterEscape');
return ok;
}
return nok(code);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/line-ending.js
/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const lineEnding = {
name: 'lineEnding',
tokenize: tokenizeLineEnding
};
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeLineEnding(effects, ok) {
return start;
/** @type {State} */
function start(code) {
effects.enter('lineEnding');
effects.consume(code);
effects.exit('lineEnding');
return factorySpace(effects, ok, 'linePrefix');
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/label-end.js
/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').Event} Event
* @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').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const labelEnd = {
name: 'labelEnd',
tokenize: tokenizeLabelEnd,
resolveTo: resolveToLabelEnd,
resolveAll: resolveAllLabelEnd
};
/** @type {Construct} */
const resourceConstruct = {
tokenize: tokenizeResource
};
/** @type {Construct} */
const referenceFullConstruct = {
tokenize: tokenizeReferenceFull
};
/** @type {Construct} */
const referenceCollapsedConstruct = {
tokenize: tokenizeReferenceCollapsed
};
/** @type {Resolver} */
function resolveAllLabelEnd(events) {
let index = -1;
while (++index < events.length) {
const 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++;
}
}
return events;
}
/** @type {Resolver} */
function resolveToLabelEnd(events, context) {
let index = events.length;
let offset = 0;
/** @type {Token} */
let token;
/** @type {number | undefined} */
let open;
/** @type {number | undefined} */
let close;
/** @type {Array} */
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;
}
}
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]]);
// Always populated by defaults.
// 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;
}
/**
* @this {TokenizeContext}
* @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 ((self.events[index][1].type === 'labelImage' || self.events[index][1].type === 'labelLink') && !self.events[index][1]._balanced) {
labelStart = self.events[index][1];
break;
}
}
return start;
/**
* Start of label end.
*
* ```markdown
* > | [a](b) c
* ^
* > | [a][b] c
* ^
* > | [a][] b
* ^
* > | [a] b
* ```
*
* @type {State}
*/
function start(code) {
// If there is not an okay opening.
if (!labelStart) {
return nok(code);
}
// If the corresponding label (link) start is marked as inactive,
// it means we’d be wrapping a link, like this:
//
// ```markdown
// > | a [b [c](d) e](f) g.
// ^
// ```
//
// We can’t have that, so it’s just balanced brackets.
if (labelStart._inactive) {
return labelEndNok(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 after;
}
/**
* After `]`.
*
* ```markdown
* > | [a](b) c
* ^
* > | [a][b] c
* ^
* > | [a][] b
* ^
* > | [a] b
* ^
* ```
*
* @type {State}
*/
function after(code) {
// Note: `markdown-rs` also parses GFM footnotes here, which for us is in
// an extension.
// Resource (`[asd](fgh)`)?
if (code === 40) {
return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code);
}
// Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference?
if (code === 91) {
return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code);
}
// Shortcut (`[asd]`) reference?
return defined ? labelEndOk(code) : labelEndNok(code);
}
/**
* After `]`, at `[`, but not at a full reference.
*
* > 👉 **Note**: we only get here if the label is defined.
*
* ```markdown
* > | [a][] b
* ^
* > | [a] b
* ^
* ```
*
* @type {State}
*/
function referenceNotFull(code) {
return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);
}
/**
* Done, we found something.
*
* ```markdown
* > | [a](b) c
* ^
* > | [a][b] c
* ^
* > | [a][] b
* ^
* > | [a] b
* ^
* ```
*
* @type {State}
*/
function labelEndOk(code) {
// Note: `markdown-rs` does a bunch of stuff here.
return ok(code);
}
/**
* Done, it’s nothing.
*
* There was an okay opening, but we didn’t match anything.
*
* ```markdown
* > | [a](b c
* ^
* > | [a][b c
* ^
* > | [a] b
* ^
* ```
*
* @type {State}
*/
function labelEndNok(code) {
labelStart._balanced = true;
return nok(code);
}
}
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeResource(effects, ok, nok) {
return resourceStart;
/**
* At a resource.
*
* ```markdown
* > | [a](b) c
* ^
* ```
*
* @type {State}
*/
function resourceStart(code) {
effects.enter('resource');
effects.enter('resourceMarker');
effects.consume(code);
effects.exit('resourceMarker');
return resourceBefore;
}
/**
* In resource, after `(`, at optional whitespace.
*
* ```markdown
* > | [a](b) c
* ^
* ```
*
* @type {State}
*/
function resourceBefore(code) {
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);
}
/**
* In resource, after optional whitespace, at `)` or a destination.
*
* ```markdown
* > | [a](b) c
* ^
* ```
*
* @type {State}
*/
function resourceOpen(code) {
if (code === 41) {
return resourceEnd(code);
}
return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, 'resourceDestination', 'resourceDestinationLiteral', 'resourceDestinationLiteralMarker', 'resourceDestinationRaw', 'resourceDestinationString', 32)(code);
}
/**
* In resource, after destination, at optional whitespace.
*
* ```markdown
* > | [a](b) c
* ^
* ```
*
* @type {State}
*/
function resourceDestinationAfter(code) {
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);
}
/**
* At invalid destination.
*
* ```markdown
* > | [a](<<) b
* ^
* ```
*
* @type {State}
*/
function resourceDestinationMissing(code) {
return nok(code);
}
/**
* In resource, after destination and whitespace, at `(` or title.
*
* ```markdown
* > | [a](b ) c
* ^
* ```
*
* @type {State}
*/
function resourceBetween(code) {
if (code === 34 || code === 39 || code === 40) {
return factoryTitle(effects, resourceTitleAfter, nok, 'resourceTitle', 'resourceTitleMarker', 'resourceTitleString')(code);
}
return resourceEnd(code);
}
/**
* In resource, after title, at optional whitespace.
*
* ```markdown
* > | [a](b "c") d
* ^
* ```
*
* @type {State}
*/
function resourceTitleAfter(code) {
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);
}
/**
* In resource, at `)`.
*
* ```markdown
* > | [a](b) d
* ^
* ```
*
* @type {State}
*/
function resourceEnd(code) {
if (code === 41) {
effects.enter('resourceMarker');
effects.consume(code);
effects.exit('resourceMarker');
effects.exit('resource');
return ok;
}
return nok(code);
}
}
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeReferenceFull(effects, ok, nok) {
const self = this;
return referenceFull;
/**
* In a reference (full), at the `[`.
*
* ```markdown
* > | [a][b] d
* ^
* ```
*
* @type {State}
*/
function referenceFull(code) {
return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, 'reference', 'referenceMarker', 'referenceString')(code);
}
/**
* In a reference (full), after `]`.
*
* ```markdown
* > | [a][b] d
* ^
* ```
*
* @type {State}
*/
function referenceFullAfter(code) {
return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code);
}
/**
* In reference (full) that was missing.
*
* ```markdown
* > | [a][b d
* ^
* ```
*
* @type {State}
*/
function referenceFullMissing(code) {
return nok(code);
}
}
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeReferenceCollapsed(effects, ok, nok) {
return referenceCollapsedStart;
/**
* In reference (collapsed), at `[`.
*
* > 👉 **Note**: we only get here if the label is defined.
*
* ```markdown
* > | [a][] d
* ^
* ```
*
* @type {State}
*/
function referenceCollapsedStart(code) {
// We only attempt a collapsed label if there’s a `[`.
effects.enter('reference');
effects.enter('referenceMarker');
effects.consume(code);
effects.exit('referenceMarker');
return referenceCollapsedOpen;
}
/**
* In reference (collapsed), at `]`.
*
* > 👉 **Note**: we only get here if the label is defined.
*
* ```markdown
* > | [a][] d
* ^
* ```
*
* @type {State}
*/
function referenceCollapsedOpen(code) {
if (code === 93) {
effects.enter('referenceMarker');
effects.consume(code);
effects.exit('referenceMarker');
effects.exit('reference');
return ok;
}
return nok(code);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/label-start-image.js
/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const labelStartImage = {
name: 'labelStartImage',
tokenize: tokenizeLabelStartImage,
resolveAll: labelEnd.resolveAll
};
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeLabelStartImage(effects, ok, nok) {
const self = this;
return start;
/**
* Start of label (image) start.
*
* ```markdown
* > | a ![b] c
* ^
* ```
*
* @type {State}
*/
function start(code) {
effects.enter('labelImage');
effects.enter('labelImageMarker');
effects.consume(code);
effects.exit('labelImageMarker');
return open;
}
/**
* After `!`, at `[`.
*
* ```markdown
* > | a ![b] c
* ^
* ```
*
* @type {State}
*/
function open(code) {
if (code === 91) {
effects.enter('labelMarker');
effects.consume(code);
effects.exit('labelMarker');
effects.exit('labelImage');
return after;
}
return nok(code);
}
/**
* After `![`.
*
* ```markdown
* > | a ![b] c
* ^
* ```
*
* This is needed in because, when GFM footnotes are enabled, images never
* form when started with a `^`.
* Instead, links form:
*
* ```markdown
* 
*
* ![^a][b]
*
* [b]: c
* ```
*
* ```html
* !^a
* !^a
* ```
*
* @type {State}
*/
function after(code) {
// To do: use a new field to do this, this is still needed for
// `micromark-extension-gfm-footnote`, but the `label-start-link`
// behavior isn’t.
// Hidden footnotes hook.
/* c8 ignore next 3 */
return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-util-classify-character@1.1.0/node_modules/micromark-util-classify-character/index.js
/**
* @typedef {import('micromark-util-types').Code} Code
*/
/**
* Classify whether a 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**: eof (`null`) is seen as whitespace.
*
* @param {Code} code
* Code.
* @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}
* Group.
*/
function classifyCharacter(code) {
if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {
return 1;
}
if (unicodePunctuation(code)) {
return 2;
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/attention.js
/**
* @typedef {import('micromark-util-types').Code} Code
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').Event} Event
* @typedef {import('micromark-util-types').Point} Point
* @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').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const attention = {
name: 'attention',
tokenize: tokenizeAttention,
resolveAll: resolveAllAttention
};
/**
* Take all events and resolve attention to emphasis or strong.
*
* @type {Resolver}
*/
function resolveAllAttention(events, context) {
let index = -1;
/** @type {number} */
let open;
/** @type {Token} */
let group;
/** @type {Token} */
let text;
/** @type {Token} */
let openingSequence;
/** @type {Token} */
let closingSequence;
/** @type {number} */
let use;
/** @type {Array} */
let nextEvents;
/** @type {number} */
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.
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.
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.
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.
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.
nextEvents = push(nextEvents, [['enter', group, context], ['enter', openingSequence, context], ['exit', openingSequence, context], ['enter', text, context]]);
// Always populated by defaults.
// Between.
nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));
// Closing.
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.
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;
}
splice(events, open - 1, index - open + 3, nextEvents);
index = open + nextEvents.length - offset - 2;
break;
}
}
}
}
// Remove remaining sequences.
index = -1;
while (++index < events.length) {
if (events[index][1].type === 'attentionSequence') {
events[index][1].type = 'data';
}
}
return events;
}
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeAttention(effects, ok) {
const attentionMarkers = this.parser.constructs.attentionMarkers.null;
const previous = this.previous;
const before = classifyCharacter(previous);
/** @type {NonNullable} */
let marker;
return start;
/**
* Before a sequence.
*
* ```markdown
* > | **
* ^
* ```
*
* @type {State}
*/
function start(code) {
marker = code;
effects.enter('attentionSequence');
return inside(code);
}
/**
* In a sequence.
*
* ```markdown
* > | **
* ^^
* ```
*
* @type {State}
*/
function inside(code) {
if (code === marker) {
effects.consume(code);
return inside;
}
const token = effects.exit('attentionSequence');
// To do: next major: move this to resolver, just like `markdown-rs`.
const after = classifyCharacter(code);
// Always populated by defaults.
const open = !after || after === 2 && before || attentionMarkers.includes(code);
const close = !before || before === 2 && after || attentionMarkers.includes(previous);
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}
*/
function movePoint(point, offset) {
point.column += offset;
point.offset += offset;
point._bufferIndex += offset;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/autolink.js
/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const autolink = {
name: 'autolink',
tokenize: tokenizeAutolink
};
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeAutolink(effects, ok, nok) {
let size = 0;
return start;
/**
* Start of an autolink.
*
* ```markdown
* > | ab
* ^
* > | ab
* ^
* ```
*
* @type {State}
*/
function start(code) {
effects.enter('autolink');
effects.enter('autolinkMarker');
effects.consume(code);
effects.exit('autolinkMarker');
effects.enter('autolinkProtocol');
return open;
}
/**
* After `<`, at protocol or atext.
*
* ```markdown
* > | ab
* ^
* > | ab
* ^
* ```
*
* @type {State}
*/
function open(code) {
if (asciiAlpha(code)) {
effects.consume(code);
return schemeOrEmailAtext;
}
return emailAtext(code);
}
/**
* At second byte of protocol or atext.
*
* ```markdown
* > | ab
* ^
* > | ab
* ^
* ```
*
* @type {State}
*/
function schemeOrEmailAtext(code) {
// ASCII alphanumeric and `+`, `-`, and `.`.
if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {
// Count the previous alphabetical from `open` too.
size = 1;
return schemeInsideOrEmailAtext(code);
}
return emailAtext(code);
}
/**
* In ambiguous protocol or atext.
*
* ```markdown
* > | ab
* ^
* > | ab
* ^
* ```
*
* @type {State}
*/
function schemeInsideOrEmailAtext(code) {
if (code === 58) {
effects.consume(code);
size = 0;
return urlInside;
}
// ASCII alphanumeric and `+`, `-`, and `.`.
if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {
effects.consume(code);
return schemeInsideOrEmailAtext;
}
size = 0;
return emailAtext(code);
}
/**
* After protocol, in URL.
*
* ```markdown
* > | ab
* ^
* ```
*
* @type {State}
*/
function urlInside(code) {
if (code === 62) {
effects.exit('autolinkProtocol');
effects.enter('autolinkMarker');
effects.consume(code);
effects.exit('autolinkMarker');
effects.exit('autolink');
return ok;
}
// ASCII control, space, or `<`.
if (code === null || code === 32 || code === 60 || asciiControl(code)) {
return nok(code);
}
effects.consume(code);
return urlInside;
}
/**
* In email atext.
*
* ```markdown
* > | ab
* ^
* ```
*
* @type {State}
*/
function emailAtext(code) {
if (code === 64) {
effects.consume(code);
return emailAtSignOrDot;
}
if (asciiAtext(code)) {
effects.consume(code);
return emailAtext;
}
return nok(code);
}
/**
* In label, after at-sign or dot.
*
* ```markdown
* > | ab
* ^ ^
* ```
*
* @type {State}
*/
function emailAtSignOrDot(code) {
return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
}
/**
* In label, where `.` and `>` are allowed.
*
* ```markdown
* > | ab
* ^
* ```
*
* @type {State}
*/
function emailLabel(code) {
if (code === 46) {
effects.consume(code);
size = 0;
return emailAtSignOrDot;
}
if (code === 62) {
// Exit, then change the token type.
effects.exit('autolinkProtocol').type = 'autolinkEmail';
effects.enter('autolinkMarker');
effects.consume(code);
effects.exit('autolinkMarker');
effects.exit('autolink');
return ok;
}
return emailValue(code);
}
/**
* In label, where `.` and `>` are *not* allowed.
*
* Though, this is also used in `emailLabel` to parse other values.
*
* ```markdown
* > | ab
* ^
* ```
*
* @type {State}
*/
function emailValue(code) {
// ASCII alphanumeric or `-`.
if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
const next = code === 45 ? emailValue : emailLabel;
effects.consume(code);
return next;
}
return nok(code);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/html-text.js
/**
* @typedef {import('micromark-util-types').Code} Code
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const htmlText = {
name: 'htmlText',
tokenize: tokenizeHtmlText
};
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeHtmlText(effects, ok, nok) {
const self = this;
/** @type {NonNullable | undefined} */
let marker;
/** @type {number} */
let index;
/** @type {State} */
let returnState;
return start;
/**
* Start of HTML (text).
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function start(code) {
effects.enter('htmlText');
effects.enter('htmlTextData');
effects.consume(code);
return open;
}
/**
* After `<`, at tag name or other stuff.
*
* ```markdown
* > | a c
* ^
* > | a c
* ^
* > | a c
* ^
* ```
*
* @type {State}
*/
function open(code) {
if (code === 33) {
effects.consume(code);
return declarationOpen;
}
if (code === 47) {
effects.consume(code);
return tagCloseStart;
}
if (code === 63) {
effects.consume(code);
return instruction;
}
// ASCII alphabetical.
if (asciiAlpha(code)) {
effects.consume(code);
return tagOpen;
}
return nok(code);
}
/**
* After ` | a c
* ^
* > | a c
* ^
* > | a &<]]> c
* ^
* ```
*
* @type {State}
*/
function declarationOpen(code) {
if (code === 45) {
effects.consume(code);
return commentOpenInside;
}
if (code === 91) {
effects.consume(code);
index = 0;
return cdataOpenInside;
}
if (asciiAlpha(code)) {
effects.consume(code);
return declaration;
}
return nok(code);
}
/**
* In a comment, after ` | a c
* ^
* ```
*
* @type {State}
*/
function commentOpenInside(code) {
if (code === 45) {
effects.consume(code);
return commentEnd;
}
return nok(code);
}
/**
* In comment.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function comment(code) {
if (code === null) {
return nok(code);
}
if (code === 45) {
effects.consume(code);
return commentClose;
}
if (markdownLineEnding(code)) {
returnState = comment;
return lineEndingBefore(code);
}
effects.consume(code);
return comment;
}
/**
* In comment, after `-`.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function commentClose(code) {
if (code === 45) {
effects.consume(code);
return commentEnd;
}
return comment(code);
}
/**
* In comment, after `--`.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function commentEnd(code) {
return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
}
/**
* After ` | a &<]]> b
* ^^^^^^
* ```
*
* @type {State}
*/
function cdataOpenInside(code) {
const value = 'CDATA[';
if (code === value.charCodeAt(index++)) {
effects.consume(code);
return index === value.length ? cdata : cdataOpenInside;
}
return nok(code);
}
/**
* In CDATA.
*
* ```markdown
* > | a &<]]> b
* ^^^
* ```
*
* @type {State}
*/
function cdata(code) {
if (code === null) {
return nok(code);
}
if (code === 93) {
effects.consume(code);
return cdataClose;
}
if (markdownLineEnding(code)) {
returnState = cdata;
return lineEndingBefore(code);
}
effects.consume(code);
return cdata;
}
/**
* In CDATA, after `]`, at another `]`.
*
* ```markdown
* > | a &<]]> b
* ^
* ```
*
* @type {State}
*/
function cdataClose(code) {
if (code === 93) {
effects.consume(code);
return cdataEnd;
}
return cdata(code);
}
/**
* In CDATA, after `]]`, at `>`.
*
* ```markdown
* > | a &<]]> b
* ^
* ```
*
* @type {State}
*/
function cdataEnd(code) {
if (code === 62) {
return end(code);
}
if (code === 93) {
effects.consume(code);
return cdataEnd;
}
return cdata(code);
}
/**
* In declaration.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function declaration(code) {
if (code === null || code === 62) {
return end(code);
}
if (markdownLineEnding(code)) {
returnState = declaration;
return lineEndingBefore(code);
}
effects.consume(code);
return declaration;
}
/**
* In instruction.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function instruction(code) {
if (code === null) {
return nok(code);
}
if (code === 63) {
effects.consume(code);
return instructionClose;
}
if (markdownLineEnding(code)) {
returnState = instruction;
return lineEndingBefore(code);
}
effects.consume(code);
return instruction;
}
/**
* In instruction, after `?`, at `>`.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function instructionClose(code) {
return code === 62 ? end(code) : instruction(code);
}
/**
* After ``, in closing tag, at tag name.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function tagCloseStart(code) {
// ASCII alphabetical.
if (asciiAlpha(code)) {
effects.consume(code);
return tagClose;
}
return nok(code);
}
/**
* After ` | a c
* ^
* ```
*
* @type {State}
*/
function tagClose(code) {
// ASCII alphanumerical and `-`.
if (code === 45 || asciiAlphanumeric(code)) {
effects.consume(code);
return tagClose;
}
return tagCloseBetween(code);
}
/**
* In closing tag, after tag name.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function tagCloseBetween(code) {
if (markdownLineEnding(code)) {
returnState = tagCloseBetween;
return lineEndingBefore(code);
}
if (markdownSpace(code)) {
effects.consume(code);
return tagCloseBetween;
}
return end(code);
}
/**
* After ` | a c
* ^
* ```
*
* @type {State}
*/
function tagOpen(code) {
// ASCII alphanumerical and `-`.
if (code === 45 || asciiAlphanumeric(code)) {
effects.consume(code);
return tagOpen;
}
if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
return tagOpenBetween(code);
}
return nok(code);
}
/**
* In opening tag, after tag name.
*
* ```markdown
* > | a c
* ^
* ```
*
* @type {State}
*/
function tagOpenBetween(code) {
if (code === 47) {
effects.consume(code);
return end;
}
// ASCII alphabetical and `:` and `_`.
if (code === 58 || code === 95 || asciiAlpha(code)) {
effects.consume(code);
return tagOpenAttributeName;
}
if (markdownLineEnding(code)) {
returnState = tagOpenBetween;
return lineEndingBefore(code);
}
if (markdownSpace(code)) {
effects.consume(code);
return tagOpenBetween;
}
return end(code);
}
/**
* In attribute name.
*
* ```markdown
* > | a d
* ^
* ```
*
* @type {State}
*/
function tagOpenAttributeName(code) {
// ASCII alphabetical and `-`, `.`, `:`, and `_`.
if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
effects.consume(code);
return tagOpenAttributeName;
}
return tagOpenAttributeNameAfter(code);
}
/**
* After attribute name, before initializer, the end of the tag, or
* whitespace.
*
* ```markdown
* > | a d
* ^
* ```
*
* @type {State}
*/
function tagOpenAttributeNameAfter(code) {
if (code === 61) {
effects.consume(code);
return tagOpenAttributeValueBefore;
}
if (markdownLineEnding(code)) {
returnState = tagOpenAttributeNameAfter;
return lineEndingBefore(code);
}
if (markdownSpace(code)) {
effects.consume(code);
return tagOpenAttributeNameAfter;
}
return tagOpenBetween(code);
}
/**
* Before unquoted, double quoted, or single quoted attribute value, allowing
* whitespace.
*
* ```markdown
* > | a e
* ^
* ```
*
* @type {State}
*/
function tagOpenAttributeValueBefore(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 tagOpenAttributeValueQuoted;
}
if (markdownLineEnding(code)) {
returnState = tagOpenAttributeValueBefore;
return lineEndingBefore(code);
}
if (markdownSpace(code)) {
effects.consume(code);
return tagOpenAttributeValueBefore;
}
effects.consume(code);
return tagOpenAttributeValueUnquoted;
}
/**
* In double or single quoted attribute value.
*
* ```markdown
* > | a e
* ^
* ```
*
* @type {State}
*/
function tagOpenAttributeValueQuoted(code) {
if (code === marker) {
effects.consume(code);
marker = undefined;
return tagOpenAttributeValueQuotedAfter;
}
if (code === null) {
return nok(code);
}
if (markdownLineEnding(code)) {
returnState = tagOpenAttributeValueQuoted;
return lineEndingBefore(code);
}
effects.consume(code);
return tagOpenAttributeValueQuoted;
}
/**
* In unquoted attribute value.
*
* ```markdown
* > | a e
* ^
* ```
*
* @type {State}
*/
function tagOpenAttributeValueUnquoted(code) {
if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) {
return nok(code);
}
if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
return tagOpenBetween(code);
}
effects.consume(code);
return tagOpenAttributeValueUnquoted;
}
/**
* After double or single quoted attribute value, before whitespace or the end
* of the tag.
*
* ```markdown
* > | a e
* ^
* ```
*
* @type {State}
*/
function tagOpenAttributeValueQuotedAfter(code) {
if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
return tagOpenBetween(code);
}
return nok(code);
}
/**
* In certain circumstances of a tag where only an `>` is allowed.
*
* ```markdown
* > | a e
* ^
* ```
*
* @type {State}
*/
function end(code) {
if (code === 62) {
effects.consume(code);
effects.exit('htmlTextData');
effects.exit('htmlText');
return ok;
}
return nok(code);
}
/**
* At eol.
*
* > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
* > empty tokens.
*
* ```markdown
* > | a
* ```
*
* @type {State}
*/
function lineEndingBefore(code) {
effects.exit('htmlTextData');
effects.enter('lineEnding');
effects.consume(code);
effects.exit('lineEnding');
return lineEndingAfter;
}
/**
* After eol, at optional whitespace.
*
* > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
* > empty tokens.
*
* ```markdown
* | a
* ^
* ```
*
* @type {State}
*/
function lineEndingAfter(code) {
// Always populated by defaults.
return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, 'linePrefix', self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : lineEndingAfterPrefix(code);
}
/**
* After eol, after optional whitespace.
*
* > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
* > empty tokens.
*
* ```markdown
* | a
* ^
* ```
*
* @type {State}
*/
function lineEndingAfterPrefix(code) {
effects.enter('htmlTextData');
return returnState(code);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/label-start-link.js
/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const labelStartLink = {
name: 'labelStartLink',
tokenize: tokenizeLabelStartLink,
resolveAll: labelEnd.resolveAll
};
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeLabelStartLink(effects, ok, nok) {
const self = this;
return start;
/**
* Start of label (link) start.
*
* ```markdown
* > | a [b] c
* ^
* ```
*
* @type {State}
*/
function start(code) {
effects.enter('labelLink');
effects.enter('labelMarker');
effects.consume(code);
effects.exit('labelMarker');
effects.exit('labelLink');
return after;
}
/** @type {State} */
function after(code) {
// To do: this isn’t needed in `micromark-extension-gfm-footnote`,
// remove.
// Hidden footnotes hook.
/* c8 ignore next 3 */
return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/hard-break-escape.js
/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const hardBreakEscape = {
name: 'hardBreakEscape',
tokenize: tokenizeHardBreakEscape
};
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeHardBreakEscape(effects, ok, nok) {
return start;
/**
* Start of a hard break (escape).
*
* ```markdown
* > | a\
* ^
* | b
* ```
*
* @type {State}
*/
function start(code) {
effects.enter('hardBreakEscape');
effects.consume(code);
return after;
}
/**
* After `\`, at eol.
*
* ```markdown
* > | a\
* ^
* | b
* ```
*
* @type {State}
*/
function after(code) {
if (markdownLineEnding(code)) {
effects.exit('hardBreakEscape');
return ok(code);
}
return nok(code);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-core-commonmark@1.1.0/node_modules/micromark-core-commonmark/lib/code-text.js
/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').Previous} Previous
* @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').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
*/
/** @type {Construct} */
const codeText = {
name: 'codeText',
tokenize: tokenizeCodeText,
resolve: resolveCodeText,
previous
};
// To do: next major: don’t resolve, like `markdown-rs`.
/** @type {Resolver} */
function resolveCodeText(events) {
let tailExitIndex = events.length - 4;
let headEnterIndex = 3;
/** @type {number} */
let index;
/** @type {number | undefined} */
let enter;
// If we start and end with an EOL or a space.
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.
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.
index = headEnterIndex - 1;
tailExitIndex++;
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 (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;
}
enter = undefined;
}
}
return events;
}
/**
* @this {TokenizeContext}
* @type {Previous}
*/
function previous(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';
}
/**
* @this {TokenizeContext}
* @type {Tokenizer}
*/
function tokenizeCodeText(effects, ok, nok) {
const self = this;
let sizeOpen = 0;
/** @type {number} */
let size;
/** @type {Token} */
let token;
return start;
/**
* Start of code (text).
*
* ```markdown
* > | `a`
* ^
* > | \`a`
* ^
* ```
*
* @type {State}
*/
function start(code) {
effects.enter('codeText');
effects.enter('codeTextSequence');
return sequenceOpen(code);
}
/**
* In opening sequence.
*
* ```markdown
* > | `a`
* ^
* ```
*
* @type {State}
*/
function sequenceOpen(code) {
if (code === 96) {
effects.consume(code);
sizeOpen++;
return sequenceOpen;
}
effects.exit('codeTextSequence');
return between(code);
}
/**
* Between something and something else.
*
* ```markdown
* > | `a`
* ^^
* ```
*
* @type {State}
*/
function between(code) {
// EOF.
if (code === null) {
return nok(code);
}
// To do: next major: don’t do spaces in resolve, but when compiling,
// like `markdown-rs`.
// Tabs don’t work, and virtual spaces don’t make sense.
if (code === 32) {
effects.enter('space');
effects.consume(code);
effects.exit('space');
return between;
}
// Closing fence? Could also be data.
if (code === 96) {
token = effects.enter('codeTextSequence');
size = 0;
return sequenceClose(code);
}
if (markdownLineEnding(code)) {
effects.enter('lineEnding');
effects.consume(code);
effects.exit('lineEnding');
return between;
}
// Data.
effects.enter('codeTextData');
return data(code);
}
/**
* In data.
*
* ```markdown
* > | `a`
* ^
* ```
*
* @type {State}
*/
function data(code) {
if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {
effects.exit('codeTextData');
return between(code);
}
effects.consume(code);
return data;
}
/**
* In closing sequence.
*
* ```markdown
* > | `a`
* ^
* ```
*
* @type {State}
*/
function sequenceClose(code) {
// More.
if (code === 96) {
effects.consume(code);
size++;
return sequenceClose;
}
// Done!
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);
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark@3.2.0/node_modules/micromark/lib/constructs.js
/**
* @typedef {import('micromark-util-types').Extension} Extension
*/
/** @satisfies {Extension['document']} */
const constructs_document = {
[42]: list,
[43]: list,
[45]: list,
[48]: list,
[49]: list,
[50]: list,
[51]: list,
[52]: list,
[53]: list,
[54]: list,
[55]: list,
[56]: list,
[57]: list,
[62]: blockQuote
};
/** @satisfies {Extension['contentInitial']} */
const contentInitial = {
[91]: definition
};
/** @satisfies {Extension['flowInitial']} */
const flowInitial = {
[-2]: codeIndented,
[-1]: codeIndented,
[32]: codeIndented
};
/** @satisfies {Extension['flow']} */
const constructs_flow = {
[35]: headingAtx,
[42]: thematicBreak,
[45]: [setextUnderline, thematicBreak],
[60]: htmlFlow,
[61]: setextUnderline,
[95]: thematicBreak,
[96]: codeFenced,
[126]: codeFenced
};
/** @satisfies {Extension['string']} */
const constructs_string = {
[38]: characterReference,
[92]: characterEscape
};
/** @satisfies {Extension['text']} */
const constructs_text = {
[-5]: lineEnding,
[-4]: lineEnding,
[-3]: lineEnding,
[33]: labelStartImage,
[38]: characterReference,
[42]: attention,
[60]: [autolink, htmlText],
[91]: labelStartLink,
[92]: [hardBreakEscape, characterEscape],
[93]: labelEnd,
[95]: attention,
[96]: codeText
};
/** @satisfies {Extension['insideSpan']} */
const insideSpan = {
null: [attention, resolver]
};
/** @satisfies {Extension['attentionMarkers']} */
const attentionMarkers = {
null: [42, 95]
};
/** @satisfies {Extension['disable']} */
const disable = {
null: []
};
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark@3.2.0/node_modules/micromark/lib/parse.js
/**
* @typedef {import('micromark-util-types').Create} Create
* @typedef {import('micromark-util-types').FullNormalizedExtension} FullNormalizedExtension
* @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct
* @typedef {import('micromark-util-types').ParseContext} ParseContext
* @typedef {import('micromark-util-types').ParseOptions} ParseOptions
*/
/**
* @param {ParseOptions | null | undefined} [options]
* @returns {ParseContext}
*/
function parse(options) {
const settings = options || {};
const constructs = /** @type {FullNormalizedExtension} */
combineExtensions([constructs_namespaceObject, ...(settings.extensions || [])]);
/** @type {ParseContext} */
const parser = {
defined: [],
lazy: {},
constructs,
content: create(content),
document: create(document_document),
flow: create(flow),
string: create(string),
text: create(text_text)
};
return parser;
/**
* @param {InitialConstruct} initial
*/
function create(initial) {
return creator;
/** @type {Create} */
function creator(from) {
return createTokenizer(parser, initial, from);
}
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark@3.2.0/node_modules/micromark/lib/preprocess.js
/**
* @typedef {import('micromark-util-types').Chunk} Chunk
* @typedef {import('micromark-util-types').Code} Code
* @typedef {import('micromark-util-types').Encoding} Encoding
* @typedef {import('micromark-util-types').Value} Value
*/
/**
* @callback Preprocessor
* @param {Value} value
* @param {Encoding | null | undefined} [encoding]
* @param {boolean | null | undefined} [end=false]
* @returns {Array}
*/
const search = /[\0\t\n\r]/g;
/**
* @returns {Preprocessor}
*/
function preprocess() {
let column = 1;
let buffer = '';
/** @type {boolean | undefined} */
let start = true;
/** @type {boolean | undefined} */
let atCarriageReturn;
return preprocessor;
/** @type {Preprocessor} */
function preprocessor(value, encoding, end) {
/** @type {Array} */
const chunks = [];
/** @type {RegExpMatchArray | null} */
let match;
/** @type {number} */
let next;
/** @type {number} */
let startPosition;
/** @type {number} */
let endPosition;
/** @type {Code} */
let code;
// @ts-expect-error `Buffer` does allow an encoding.
value = buffer + value.toString(encoding);
startPosition = 0;
buffer = '';
if (start) {
// To do: `markdown-rs` actually parses BOMs (byte order mark).
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;
}
case 9:
{
next = Math.ceil(column / 4) * 4;
chunks.push(-2);
while (column++ < next) chunks.push(-1);
break;
}
case 10:
{
chunks.push(-4);
column = 1;
break;
}
default:
{
atCarriageReturn = true;
column = 1;
}
}
}
startPosition = endPosition + 1;
}
if (end) {
if (atCarriageReturn) chunks.push(-5);
if (buffer) chunks.push(buffer);
chunks.push(null);
}
return chunks;
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark@3.2.0/node_modules/micromark/lib/postprocess.js
/**
* @typedef {import('micromark-util-types').Event} Event
*/
/**
* @param {Array} events
* @returns {Array}
*/
function postprocess(events) {
while (!subtokenize(events)) {
// Empty
}
return events;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-util-decode-numeric-character-reference@1.1.0/node_modules/micromark-util-decode-numeric-character-reference/index.js
/**
* Turn the number (in string form as either hexa- or plain decimal) coming from
* a numeric character reference into a character.
*
* Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
* non-characters and control characters safe.
*
* @param {string} value
* Value to decode.
* @param {number} base
* Numeric base.
* @returns {string}
* Character.
*/
function decodeNumericCharacterReference(value, base) {
const code = Number.parseInt(value, base);
if (
// C0 except for HT, LF, FF, CR, space.
code < 9 || code === 11 || code > 13 && code < 32 ||
// Control character (DEL) of C0, and C1 controls.
code > 126 && code < 160 ||
// Lone high surrogates and low surrogates.
code > 55295 && code < 57344 ||
// Noncharacters.
code > 64975 && code < 65008 /* eslint-disable no-bitwise */ || (code & 65535) === 65535 || (code & 65535) === 65534 /* eslint-enable no-bitwise */ ||
// Out of range
code > 1114111) {
return '\uFFFD';
}
return String.fromCharCode(code);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-util-decode-string@1.1.0/node_modules/micromark-util-decode-string/index.js
const characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
/**
* Decode markdown strings (which occur in places such as fenced code info
* strings, destinations, labels, and titles).
*
* The “string” content type allows character escapes and -references.
* This decodes those.
*
* @param {string} value
* Value to decode.
* @returns {string}
* Decoded value.
*/
function decodeString(value) {
return value.replace(characterEscapeOrReference, decode);
}
/**
* @param {string} $0
* @param {string} $1
* @param {string} $2
* @returns {string}
*/
function decode($0, $1, $2) {
if ($1) {
// Escape.
return $1;
}
// Reference.
const head = $2.charCodeAt(0);
if (head === 35) {
const head = $2.charCodeAt(1);
const hex = head === 120 || head === 88;
return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);
}
return decodeNamedCharacterReference($2) || $0;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-from-markdown@1.3.1/node_modules/mdast-util-from-markdown/lib/index.js
/**
* @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 {import('unist').Parent} UnistParent
* @typedef {import('unist').Point} Point
*
* @typedef {import('mdast').PhrasingContent} PhrasingContent
* @typedef {import('mdast').StaticPhrasingContent} StaticPhrasingContent
* @typedef {import('mdast').Content} Content
* @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').ImageReference} ImageReference
* @typedef {import('mdast').InlineCode} InlineCode
* @typedef {import('mdast').Link} Link
* @typedef {import('mdast').LinkReference} LinkReference
* @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
* @typedef {import('mdast').ReferenceType} ReferenceType
* @typedef {import('../index.js').CompileData} CompileData
*/
/**
* @typedef {Root | Content} Node
* @typedef {Extract} Parent
*
* @typedef {Omit & {type: 'fragment', children: Array}} Fragment
*/
/**
* @callback Transform
* Extra transform, to change the AST afterwards.
* @param {Root} tree
* Tree to transform.
* @returns {Root | undefined | null | void}
* New tree or nothing (in which case the current tree is used).
*
* @callback Handle
* Handle a token.
* @param {CompileContext} this
* Context.
* @param {Token} token
* Current token.
* @returns {void}
* Nothing.
*
* @typedef {Record} Handles
* Token types mapping to handles
*
* @callback OnEnterError
* Handle the case where the `right` token is open, but it is closed (by the
* `left` token) or because we reached the end of the document.
* @param {Omit} this
* Context.
* @param {Token | undefined} left
* Left token.
* @param {Token} right
* Right token.
* @returns {void}
* Nothing.
*
* @callback OnExitError
* Handle the case where the `right` token is open but it is closed by
* exiting the `left` token.
* @param {Omit} this
* Context.
* @param {Token} left
* Left token.
* @param {Token} right
* Right token.
* @returns {void}
* Nothing.
*
* @typedef {[Token, OnEnterError | undefined]} TokenTuple
* Open token on the stack, with an optional error handler for when
* that token isn’t closed properly.
*/
/**
* @typedef Config
* Configuration.
*
* We have our defaults, but extensions will add more.
* @property {Array} canContainEols
* Token types where line endings are used.
* @property {Handles} enter
* Opening handles.
* @property {Handles} exit
* Closing handles.
* @property {Array} transforms
* Tree transforms.
*
* @typedef {Partial} Extension
* Change how markdown tokens from micromark are turned into mdast.
*
* @typedef CompileContext
* mdast compiler context.
* @property {Array} stack
* Stack of nodes.
* @property {Array} tokenStack
* Stack of tokens.
* @property {(key: Key) => CompileData[Key]} getData
* Get data from the key/value store.
* @property {(key: Key, value?: CompileData[Key]) => void} setData
* Set data into the key/value store.
* @property {(this: CompileContext) => void} buffer
* Capture some of the output data.
* @property {(this: CompileContext) => string} resume
* Stop capturing and access the output data.
* @property {(this: CompileContext, node: Kind, token: Token, onError?: OnEnterError) => Kind} enter
* Enter a token.
* @property {(this: CompileContext, token: Token, onError?: OnExitError) => Node} exit
* Exit a token.
* @property {TokenizeContext['sliceSerialize']} sliceSerialize
* Get the string value of a token.
* @property {Config} config
* Configuration.
*
* @typedef FromMarkdownOptions
* Configuration for how to build mdast.
* @property {Array> | null | undefined} [mdastExtensions]
* Extensions for this utility to change how tokens are turned into a tree.
*
* @typedef {ParseOptions & FromMarkdownOptions} Options
* Configuration.
*/
// To do: micromark: create a registry of tokens?
// To do: next major: don’t return given `Node` from `enter`.
// To do: next major: remove setter/getter.
const lib_own = {}.hasOwnProperty;
/**
* @param value
* Markdown to parse.
* @param encoding
* Character encoding for when `value` is `Buffer`.
* @param options
* Configuration.
* @returns
* mdast tree.
*/
const fromMarkdown =
/**
* @type {(
* ((value: Value, encoding: Encoding, options?: Options | null | undefined) => Root) &
* ((value: Value, options?: Options | null | undefined) => Root)
* )}
*/
/**
* @param {Value} value
* @param {Encoding | Options | null | undefined} [encoding]
* @param {Options | null | undefined} [options]
* @returns {Root}
*/
function (value, encoding, options) {
if (typeof encoding !== 'string') {
options = encoding;
encoding = undefined;
}
return compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));
};
/**
* Note this compiler only understand complete buffering, not streaming.
*
* @param {Options | null | undefined} [options]
*/
function compiler(options) {
/** @type {Config} */
const config = {
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()
}
};
configure(config, (options || {}).mdastExtensions || []);
/** @type {CompileData} */
const data = {};
return compile;
/**
* Turn micromark events into an mdast tree.
*
* @param {Array} events
* Events.
* @returns {Root}
* mdast tree.
*/
function compile(events) {
/** @type {Root} */
let tree = {
type: 'root',
children: []
};
/** @type {Omit} */
const context = {
stack: [tree],
tokenStack: [],
config,
enter,
exit,
buffer,
resume,
setData,
getData
};
/** @type {Array} */
const listStack = [];
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 (lib_own.call(handler, events[index][1].type)) {
handler[events[index][1].type].call(Object.assign({
sliceSerialize: events[index][2].sliceSerialize
}, context), events[index][1]);
}
}
// Handle tokens still being open.
if (context.tokenStack.length > 0) {
const tail = context.tokenStack[context.tokenStack.length - 1];
const handler = tail[1] || defaultOnError;
handler.call(context, undefined, tail[0]);
}
// Figure out `root` position.
tree.position = {
start: lib_point(events.length > 0 ? events[0][1].start : {
line: 1,
column: 1,
offset: 0
}),
end: lib_point(events.length > 0 ? events[events.length - 2][1].end : {
line: 1,
column: 1,
offset: 0
})
};
// Call transforms.
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') {
// Empty.
} 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') {
// Empty
} else {
break;
}
}
if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) {
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',
_spread: false,
start: Object.assign({}, event[1].start),
// @ts-expect-error: we’ll add `end` in a second.
end: undefined
};
// @ts-expect-error: `listItem` is most definitely defined, TS...
events.splice(index, 0, ['enter', listItem, event[2]]);
index++;
length++;
firstBlankLineIndex = undefined;
atMarker = true;
}
}
}
events[start][1]._spread = listSpread;
return length;
}
/**
* Set data.
*
* @template {keyof CompileData} Key
* Field type.
* @param {Key} key
* Key of field.
* @param {CompileData[Key]} [value]
* New value.
* @returns {void}
* Nothing.
*/
function setData(key, value) {
data[key] = value;
}
/**
* Get data.
*
* @template {keyof CompileData} Key
* Field type.
* @param {Key} key
* Key of field.
* @returns {CompileData[Key]}
* Value.
*/
function getData(key) {
return data[key];
}
/**
* Create an opener handle.
*
* @param {(token: Token) => Node} create
* Create a node.
* @param {Handle} [and]
* Optional function to also run.
* @returns {Handle}
* 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);
}
}
/**
* @this {CompileContext}
* @returns {void}
*/
function buffer() {
this.stack.push({
type: 'fragment',
children: []
});
}
/**
* @template {Node} Kind
* Node type.
* @this {CompileContext}
* Context.
* @param {Kind} node
* Node to enter.
* @param {Token} token
* Corresponding token.
* @param {OnEnterError | undefined} [errorHandler]
* Handle the case where this token is open, but it is closed by something else.
* @returns {Kind}
* The given node.
*/
function enter(node, token, errorHandler) {
const parent = this.stack[this.stack.length - 1];
// @ts-expect-error: Assume `Node` can exist as a child of `parent`.
parent.children.push(node);
this.stack.push(node);
this.tokenStack.push([token, errorHandler]);
// @ts-expect-error: `end` will be patched later.
node.position = {
start: lib_point(token.start)
};
return node;
}
/**
* Create a closer handle.
*
* @param {Handle} [and]
* Optional function to also run.
* @returns {Handle}
* 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);
}
}
/**
* @this {CompileContext}
* Context.
* @param {Token} token
* Corresponding token.
* @param {OnExitError | undefined} [onExitError]
* Handle the case where another token is open.
* @returns {Node}
* The closed node.
*/
function exit(token, onExitError) {
const node = this.stack.pop();
const open = this.tokenStack.pop();
if (!open) {
throw new Error('Cannot close `' + token.type + '` (' + stringifyPosition({
start: token.start,
end: token.end
}) + '): it’s not open');
} else if (open[0].type !== token.type) {
if (onExitError) {
onExitError.call(this, token, open[0]);
} else {
const handler = open[1] || defaultOnError;
handler.call(this, token, open[0]);
}
}
node.position.end = lib_point(token.end);
return node;
}
/**
* @this {CompileContext}
* @returns {string}
*/
function resume() {
return lib_toString(this.stack.pop());
}
//
// Handlers.
//
/**
* @this {CompileContext}
* @type {Handle}
*/
function onenterlistordered() {
setData('expectingFirstListItemValue', true);
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onenterlistitemvalue(token) {
if (getData('expectingFirstListItemValue')) {
const ancestor = this.stack[this.stack.length - 2];
ancestor.start = Number.parseInt(this.sliceSerialize(token), 10);
setData('expectingFirstListItemValue');
}
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitcodefencedfenceinfo() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.lang = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitcodefencedfencemeta() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.meta = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitcodefencedfence() {
// Exit if this is the closing fence.
if (getData('flowCodeInside')) return;
this.buffer();
setData('flowCodeInside', true);
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitcodefenced() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, '');
setData('flowCodeInside');
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitcodeindented() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.value = data.replace(/(\r?\n|\r)$/g, '');
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitdefinitionlabelstring(token) {
const label = this.resume();
const node = this.stack[this.stack.length - 1];
node.label = label;
node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitdefinitiontitlestring() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.title = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitdefinitiondestinationstring() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.url = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitatxheadingsequence(token) {
const node = this.stack[this.stack.length - 1];
if (!node.depth) {
const depth = this.sliceSerialize(token).length;
node.depth = depth;
}
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitsetextheadingtext() {
setData('setextHeadingSlurpLineEnding', true);
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitsetextheadinglinesequence(token) {
const node = this.stack[this.stack.length - 1];
node.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitsetextheading() {
setData('setextHeadingSlurpLineEnding');
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onenterdata(token) {
const node = this.stack[this.stack.length - 1];
let tail = node.children[node.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: lib_point(token.start)
};
// @ts-expect-error: Assume `parent` accepts `text`.
node.children.push(tail);
}
this.stack.push(tail);
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitdata(token) {
const tail = this.stack.pop();
tail.value += this.sliceSerialize(token);
tail.position.end = lib_point(token.end);
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitlineending(token) {
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 = lib_point(token.end);
setData('atHardBreak');
return;
}
if (!getData('setextHeadingSlurpLineEnding') && config.canContainEols.includes(context.type)) {
onenterdata.call(this, token);
onexitdata.call(this, token);
}
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexithardbreak() {
setData('atHardBreak', true);
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexithtmlflow() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.value = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexithtmltext() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.value = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitcodetext() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.value = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitlink() {
const node = this.stack[this.stack.length - 1];
// Note: there are also `identifier` and `label` fields on this link node!
// These are used / cleaned here.
// To do: clean.
if (getData('inReference')) {
/** @type {ReferenceType} */
const referenceType = getData('referenceType') || 'shortcut';
node.type += 'Reference';
// @ts-expect-error: mutate.
node.referenceType = referenceType;
// @ts-expect-error: mutate.
delete node.url;
delete node.title;
} else {
// @ts-expect-error: mutate.
delete node.identifier;
// @ts-expect-error: mutate.
delete node.label;
}
setData('referenceType');
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitimage() {
const node = this.stack[this.stack.length - 1];
// Note: there are also `identifier` and `label` fields on this link node!
// These are used / cleaned here.
// To do: clean.
if (getData('inReference')) {
/** @type {ReferenceType} */
const referenceType = getData('referenceType') || 'shortcut';
node.type += 'Reference';
// @ts-expect-error: mutate.
node.referenceType = referenceType;
// @ts-expect-error: mutate.
delete node.url;
delete node.title;
} else {
// @ts-expect-error: mutate.
delete node.identifier;
// @ts-expect-error: mutate.
delete node.label;
}
setData('referenceType');
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitlabeltext(token) {
const string = this.sliceSerialize(token);
const ancestor = this.stack[this.stack.length - 2];
// @ts-expect-error: stash this on the node, as it might become a reference
// later.
ancestor.label = decodeString(string);
// @ts-expect-error: same as above.
ancestor.identifier = normalizeIdentifier(string).toLowerCase();
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitlabel() {
const fragment = this.stack[this.stack.length - 1];
const value = this.resume();
const node = this.stack[this.stack.length - 1];
// Assume a reference.
setData('inReference', true);
if (node.type === 'link') {
/** @type {Array} */
// @ts-expect-error: Assume static phrasing content.
const children = fragment.children;
node.children = children;
} else {
node.alt = value;
}
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitresourcedestinationstring() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.url = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitresourcetitlestring() {
const data = this.resume();
const node = this.stack[this.stack.length - 1];
node.title = data;
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitresource() {
setData('inReference');
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onenterreference() {
setData('referenceType', 'collapsed');
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitreferencestring(token) {
const label = this.resume();
const node = this.stack[this.stack.length - 1];
// @ts-expect-error: stash this on the node, as it might become a reference
// later.
node.label = label;
// @ts-expect-error: same as above.
node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
setData('referenceType', 'full');
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitcharacterreferencemarker(token) {
setData('characterReferenceType', token.type);
}
/**
* @this {CompileContext}
* @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 {
const result = decodeNamedCharacterReference(data);
value = result;
}
const tail = this.stack.pop();
tail.value += value;
tail.position.end = lib_point(token.end);
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitautolinkprotocol(token) {
onexitdata.call(this, token);
const node = this.stack[this.stack.length - 1];
node.url = this.sliceSerialize(token);
}
/**
* @this {CompileContext}
* @type {Handle}
*/
function onexitautolinkemail(token) {
onexitdata.call(this, token);
const node = this.stack[this.stack.length - 1];
node.url = 'mailto:' + this.sliceSerialize(token);
}
//
// Creaters.
//
/** @returns {Blockquote} */
function blockQuote() {
return {
type: 'blockquote',
children: []
};
}
/** @returns {Code} */
function codeFlow() {
return {
type: 'code',
lang: null,
meta: null,
value: ''
};
}
/** @returns {InlineCode} */
function codeText() {
return {
type: 'inlineCode',
value: ''
};
}
/** @returns {Definition} */
function definition() {
return {
type: 'definition',
identifier: '',
label: 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() {
return {
type: 'image',
title: null,
url: '',
alt: null
};
}
/** @returns {Link} */
function link() {
return {
type: 'link',
title: null,
url: '',
children: []
};
}
/**
* @param {Token} token
* @returns {List}
*/
function list(token) {
return {
type: 'list',
ordered: token.type === 'listOrdered',
start: null,
spread: token._spread,
children: []
};
}
/**
* @param {Token} token
* @returns {ListItem}
*/
function listItem(token) {
return {
type: 'listItem',
spread: token._spread,
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'
};
}
}
/**
* Copy a point-like value.
*
* @param {Point} d
* Point-like value.
* @returns {Point}
* unist point.
*/
function lib_point(d) {
return {
line: d.line,
column: d.column,
offset: d.offset
};
}
/**
* @param {Config} combined
* @param {Array>} extensions
* @returns {void}
*/
function configure(combined, extensions) {
let index = -1;
while (++index < extensions.length) {
const value = extensions[index];
if (Array.isArray(value)) {
configure(combined, value);
} else {
extension(combined, value);
}
}
}
/**
* @param {Config} combined
* @param {Extension} extension
* @returns {void}
*/
function extension(combined, extension) {
/** @type {keyof Extension} */
let key;
for (key in extension) {
if (lib_own.call(extension, key)) {
if (key === 'canContainEols') {
const right = extension[key];
if (right) {
combined[key].push(...right);
}
} else if (key === 'transforms') {
const right = extension[key];
if (right) {
combined[key].push(...right);
}
} else if (key === 'enter' || key === 'exit') {
const right = extension[key];
if (right) {
Object.assign(combined[key], right);
}
}
}
}
}
/** @type {OnEnterError} */
function defaultOnError(left, right) {
if (left) {
throw new Error('Cannot close `' + left.type + '` (' + stringifyPosition({
start: left.start,
end: left.end
}) + '): a different token (`' + right.type + '`, ' + stringifyPosition({
start: right.start,
end: right.end
}) + ') is open');
} else {
throw new Error('Cannot close document, a token (`' + right.type + '`, ' + stringifyPosition({
start: right.start,
end: right.end
}) + ') is still open');
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/remark-parse@10.0.2/node_modules/remark-parse/lib/index.js
/**
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast-util-from-markdown').Options} Options
*/
/**
* @this {import('unified').Processor}
* @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
});
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/micromark-util-sanitize-uri@1.2.0/node_modules/micromark-util-sanitize-uri/index.js
/**
* Make a value safe for injection as a URL.
*
* This encodes unsafe characters with percent-encoding and skips already
* encoded sequences (see `normalizeUri`).
* Further unsafe characters are encoded as character references (see
* `micromark-util-encode`).
*
* A regex of allowed protocols can be given, in which case the URL is
* sanitized.
* For example, `/^(https?|ircs?|mailto|xmpp)$/i` can be used for `a[href]`, or
* `/^https?$/i` for `img[src]` (this is what `github.com` allows).
* If the URL includes an unknown protocol (one not matched by `protocol`, such
* as a dangerous example, `javascript:`), the value is ignored.
*
* @param {string | undefined} url
* URI to sanitize.
* @param {RegExp | null | undefined} [protocol]
* Allowed protocols.
* @returns {string}
* Sanitized URI.
*/
function sanitizeUri(url, protocol) {
const value = encode(normalizeUri(url || ''));
if (!protocol) {
return value;
}
const colon = value.indexOf(':');
const questionMark = value.indexOf('?');
const numberSign = value.indexOf('#');
const slash = value.indexOf('/');
if (
// If there is no protocol, it’s relative.
colon < 0 ||
// If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.
slash > -1 && colon > slash || questionMark > -1 && colon > questionMark || numberSign > -1 && colon > numberSign ||
// It is a protocol, it should be allowed.
protocol.test(value.slice(0, colon))) {
return value;
}
return '';
}
/**
* Normalize a URL.
*
* Encode unsafe characters with percent-encoding, skipping already encoded
* sequences.
*
* @param {string} value
* URI to normalize.
* @returns {string}
* Normalized URI.
*/
function normalizeUri(value) {
/** @type {Array} */
const result = [];
let index = -1;
let start = 0;
let skip = 0;
while (++index < value.length) {
const code = value.charCodeAt(index);
/** @type {string} */
let replace = '';
// A correct percent encoded value.
if (code === 37 && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) {
skip = 2;
}
// ASCII.
else if (code < 128) {
if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) {
replace = String.fromCharCode(code);
}
}
// Astral.
else if (code > 55295 && code < 57344) {
const next = value.charCodeAt(index + 1);
// A correct surrogate pair.
if (code < 56320 && next > 56319 && next < 57344) {
replace = String.fromCharCode(code, next);
skip = 1;
}
// Lone surrogate.
else {
replace = '\uFFFD';
}
}
// Unicode.
else {
replace = String.fromCharCode(code);
}
if (replace) {
result.push(value.slice(start, index), encodeURIComponent(replace));
start = index + skip + 1;
replace = '';
}
if (skip) {
index += skip;
skip = 0;
}
}
return result.join('') + value.slice(start);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/footer.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').ElementContent} ElementContent
*
* @typedef {import('./state.js').State} State
*/
/**
* Generate a hast footer for called footnote definitions.
*
* @param {State} state
* Info passed around.
* @returns {Element | undefined}
* `section` element or `undefined`.
*/
function footer(state) {
/** @type {Array} */
const listItems = [];
let index = -1;
while (++index < state.footnoteOrder.length) {
const def = state.footnoteById[state.footnoteOrder[index]];
if (!def) {
continue;
}
const content = state.all(def);
const id = String(def.identifier).toUpperCase();
const safeId = normalizeUri(id.toLowerCase());
let referenceIndex = 0;
/** @type {Array} */
const backReferences = [];
while (++referenceIndex <= state.footnoteCounts[id]) {
/** @type {Element} */
const backReference = {
type: 'element',
tagName: 'a',
properties: {
href: '#' + state.clobberPrefix + 'fnref-' + safeId + (referenceIndex > 1 ? '-' + referenceIndex : ''),
dataFootnoteBackref: true,
className: ['data-footnote-backref'],
ariaLabel: state.footnoteBackLabel
},
children: [{
type: 'text',
value: '↩'
}]
};
if (referenceIndex > 1) {
backReference.children.push({
type: 'element',
tagName: 'sup',
children: [{
type: 'text',
value: String(referenceIndex)
}]
});
}
if (backReferences.length > 0) {
backReferences.push({
type: 'text',
value: ' '
});
}
backReferences.push(backReference);
}
const tail = content[content.length - 1];
if (tail && tail.type === 'element' && tail.tagName === 'p') {
const tailTail = tail.children[tail.children.length - 1];
if (tailTail && tailTail.type === 'text') {
tailTail.value += ' ';
} else {
tail.children.push({
type: 'text',
value: ' '
});
}
tail.children.push(...backReferences);
} else {
content.push(...backReferences);
}
/** @type {Element} */
const listItem = {
type: 'element',
tagName: 'li',
properties: {
id: state.clobberPrefix + 'fn-' + safeId
},
children: state.wrap(content, true)
};
state.patch(def, listItem);
listItems.push(listItem);
}
if (listItems.length === 0) {
return;
}
return {
type: 'element',
tagName: 'section',
properties: {
dataFootnotes: true,
className: ['footnotes']
},
children: [{
type: 'element',
tagName: state.footnoteLabelTagName,
properties: {
// To do: use structured clone.
...JSON.parse(JSON.stringify(state.footnoteLabelProperties)),
id: 'footnote-label'
},
children: [{
type: 'text',
value: state.footnoteLabel
}]
}, {
type: 'text',
value: '\n'
}, {
type: 'element',
tagName: 'ol',
properties: {},
children: state.wrap(listItems, true)
}, {
type: 'text',
value: '\n'
}]
};
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/index.js
/**
* @typedef {import('unist').Node} Node
* @typedef {import('unist').Parent} Parent
*/
/**
* @typedef {Record} Props
* @typedef {null | undefined | string | Props | TestFunctionAnything | Array} Test
* Check for an arbitrary node, unaware of TypeScript inferral.
*
* @callback TestFunctionAnything
* Check if a node passes a test, unaware of TypeScript inferral.
* @param {unknown} this
* The given context.
* @param {Node} node
* A node.
* @param {number | null | undefined} [index]
* The node’s position in its parent.
* @param {Parent | null | undefined} [parent]
* The node’s parent.
* @returns {boolean | void}
* Whether this node passes the test.
*/
/**
* @template {Node} Kind
* Node type.
* @typedef {Kind['type'] | Partial | TestFunctionPredicate | Array | TestFunctionPredicate>} PredicateTest
* Check for a node that can be inferred by TypeScript.
*/
/**
* Check if a node passes a certain test.
*
* @template {Node} Kind
* Node type.
* @callback TestFunctionPredicate
* Complex test function for a node that can be inferred by TypeScript.
* @param {Node} node
* A node.
* @param {number | null | undefined} [index]
* The node’s position in its parent.
* @param {Parent | null | undefined} [parent]
* The node’s parent.
* @returns {node is Kind}
* Whether this node passes the test.
*/
/**
* @callback AssertAnything
* Check that an arbitrary value is a node, unaware of TypeScript inferral.
* @param {unknown} [node]
* Anything (typically a node).
* @param {number | null | undefined} [index]
* The node’s position in its parent.
* @param {Parent | null | undefined} [parent]
* The node’s parent.
* @returns {boolean}
* Whether this is a node and passes a test.
*/
/**
* Check if a node is a node and passes a certain node test.
*
* @template {Node} Kind
* Node type.
* @callback AssertPredicate
* Check that an arbitrary value is a specific node, aware of TypeScript.
* @param {unknown} [node]
* Anything (typically a node).
* @param {number | null | undefined} [index]
* The node’s position in its parent.
* @param {Parent | null | undefined} [parent]
* The node’s parent.
* @returns {node is Kind}
* Whether this is a node and passes a test.
*/
/**
* Check if `node` is a `Node` and whether it passes the given test.
*
* @param node
* Thing to check, typically `Node`.
* @param test
* A check for a specific node.
* @param index
* The node’s position in its parent.
* @param parent
* The node’s parent.
* @returns
* Whether `node` is a node and passes a test.
*/
const is =
/**
* @type {(
* (() => false) &
* ((node: unknown, test: PredicateTest, index: number, parent: Parent, context?: unknown) => node is Kind) &
* ((node: unknown, test: PredicateTest, index?: null | undefined, parent?: null | undefined, context?: unknown) => node is Kind) &
* ((node: unknown, test: Test, index: number, parent: Parent, context?: unknown) => boolean) &
* ((node: unknown, test?: Test, index?: null | undefined, parent?: null | undefined, context?: unknown) => boolean)
* )}
*/
/**
* @param {unknown} [node]
* @param {Test} [test]
* @param {number | null | undefined} [index]
* @param {Parent | null | undefined} [parent]
* @param {unknown} [context]
* @returns {boolean}
*/
// eslint-disable-next-line max-params
function is(node, test, index, parent, context) {
const check = convert(test);
if (index !== undefined && index !== null && (typeof index !== 'number' || index < 0 || index === Number.POSITIVE_INFINITY)) {
throw new Error('Expected positive finite index');
}
if (parent !== undefined && parent !== null && (!is(parent) || !parent.children)) {
throw new Error('Expected parent node');
}
if ((parent === undefined || parent === null) !== (index === undefined || index === null)) {
throw new Error('Expected both parent and index');
}
// @ts-expect-error Looks like a node.
return node && node.type && typeof node.type === 'string' ? Boolean(check.call(context, node, index, parent)) : false;
};
/**
* Generate an assertion from a test.
*
* Useful if you’re going to test many nodes, for example when creating a
* utility where something else passes a compatible test.
*
* The created function is a bit faster because it expects valid input only:
* a `node`, `index`, and `parent`.
*
* @param test
* * when nullish, checks if `node` is a `Node`.
* * when `string`, works like passing `(node) => 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 if any one of the subtests pass.
* @returns
* An assertion.
*/
const convert =
/**
* @type {(
* ((test: PredicateTest) => AssertPredicate) &
* ((test?: Test) => AssertAnything)
* )}
*/
/**
* @param {Test} [test]
* @returns {AssertAnything}
*/
function (test) {
if (test === undefined || test === null) {
return ok;
}
if (typeof test === 'string') {
return typeFactory(test);
}
if (typeof test === 'object') {
return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
}
if (typeof test === 'function') {
return castFactory(test);
}
throw new Error('Expected function, string, or object as test');
};
/**
* @param {Array} tests
* @returns {AssertAnything}
*/
function anyFactory(tests) {
/** @type {Array} */
const checks = [];
let index = -1;
while (++index < tests.length) {
checks[index] = convert(tests[index]);
}
return castFactory(any);
/**
* @this {unknown}
* @param {Array} parameters
* @returns {boolean}
*/
function any() {
let index = -1;
for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
parameters[_key] = arguments[_key];
}
while (++index < checks.length) {
if (checks[index].call(this, ...parameters)) return true;
}
return false;
}
}
/**
* Turn an object into a test for a node with a certain fields.
*
* @param {Props} check
* @returns {AssertAnything}
*/
function propsFactory(check) {
return castFactory(all);
/**
* @param {Node} node
* @returns {boolean}
*/
function all(node) {
/** @type {string} */
let key;
for (key in check) {
// @ts-expect-error: hush, it sure works as an index.
if (node[key] !== check[key]) return false;
}
return true;
}
}
/**
* Turn a string into a test for a node with a certain type.
*
* @param {string} check
* @returns {AssertAnything}
*/
function typeFactory(check) {
return castFactory(type);
/**
* @param {Node} node
*/
function type(node) {
return node && node.type === check;
}
}
/**
* Turn a custom test into a test for a node that passes that test.
*
* @param {TestFunctionAnything} check
* @returns {AssertAnything}
*/
function castFactory(check) {
return assertion;
/**
* @this {unknown}
* @param {unknown} node
* @param {Array} parameters
* @returns {boolean}
*/
function assertion(node) {
for (var _len2 = arguments.length, parameters = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
parameters[_key2 - 1] = arguments[_key2];
}
return Boolean(node && typeof node === 'object' && 'type' in node &&
// @ts-expect-error: fine.
Boolean(check.call(this, node, ...parameters)));
}
}
function ok() {
return true;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/color.browser.js
/**
* @param {string} d
* @returns {string}
*/
function color(d) {
return d;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/index.js
/**
* @typedef {import('unist').Node} Node
* @typedef {import('unist').Parent} Parent
* @typedef {import('unist-util-is').Test} Test
*/
/**
* @typedef {boolean | 'skip'} Action
* Union of the action types.
*
* @typedef {number} Index
* Move to the sibling at `index` next (after node itself is completely
* traversed).
*
* Useful if mutating the tree, such as removing the node the visitor is
* currently on, or any of its previous siblings.
* Results less than 0 or greater than or equal to `children.length` stop
* traversing the parent.
*
* @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple
* List with one or two values, the first an action, the second an index.
*
* @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult
* Any value that can be returned from a visitor.
*/
/**
* @template {Node} [Visited=Node]
* Visited node type.
* @template {Parent} [Ancestor=Parent]
* Ancestor type.
* @callback Visitor
* Handle a node (matching `test`, if given).
*
* Visitors are free to transform `node`.
* They can also transform the parent of node (the last of `ancestors`).
*
* Replacing `node` itself, if `SKIP` is not returned, still causes its
* descendants to be walked (which is a bug).
*
* When adding or removing previous siblings of `node` (or next siblings, in
* case of reverse), the `Visitor` should return a new `Index` to specify the
* sibling to traverse after `node` is traversed.
* Adding or removing next siblings of `node` (or previous siblings, in case
* of reverse) is handled as expected without needing to return a new `Index`.
*
* Removing the children property of an ancestor still results in them being
* traversed.
* @param {Visited} node
* Found node.
* @param {Array} ancestors
* Ancestors of `node`.
* @returns {VisitorResult}
* What to do next.
*
* An `Index` is treated as a tuple of `[CONTINUE, Index]`.
* An `Action` is treated as a tuple of `[Action]`.
*
* Passing a tuple back only makes sense if the `Action` is `SKIP`.
* When the `Action` is `EXIT`, that action can be returned.
* When the `Action` is `CONTINUE`, `Index` can be returned.
*/
/**
* @template {Node} [Tree=Node]
* Tree type.
* @template {Test} [Check=string]
* Test type.
* @typedef {Visitor, Check>, Extract, Parent>>} BuildVisitor
* Build a typed `Visitor` function from a tree and a test.
*
* It will infer which values are passed as `node` and which as `parents`.
*/
/**
* Continue traversing as normal.
*/
const CONTINUE = true;
/**
* Stop traversing immediately.
*/
const EXIT = false;
/**
* Do not traverse this node’s children.
*/
const SKIP = 'skip';
/**
* Visit nodes, with ancestral information.
*
* This algorithm performs *depth-first* *tree traversal* in *preorder*
* (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
*
* You can choose for which nodes `visitor` is called by passing a `test`.
* For complex tests, you should test yourself in `visitor`, as it will be
* faster and will have improved type information.
*
* Walking the tree is an intensive task.
* Make use of the return values of the visitor when possible.
* Instead of walking a tree multiple times, walk it once, use `unist-util-is`
* to check if a node matches, and then perform different operations.
*
* You can change the tree.
* See `Visitor` for more info.
*
* @param tree
* Tree to traverse.
* @param test
* `unist-util-is`-compatible test
* @param visitor
* Handle each node.
* @param reverse
* Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
* @returns
* Nothing.
*/
const visitParents =
/**
* @type {(
* ((tree: Tree, test: Check, visitor: BuildVisitor, reverse?: boolean | null | undefined) => void) &
* ((tree: Tree, visitor: BuildVisitor, reverse?: boolean | null | undefined) => void)
* )}
*/
/**
* @param {Node} tree
* @param {Test} test
* @param {Visitor} visitor
* @param {boolean | null | undefined} [reverse]
* @returns {void}
*/
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 is = convert(test);
const step = reverse ? -1 : 1;
factory(tree, undefined, [])();
/**
* @param {Node} node
* @param {number | undefined} index
* @param {Array} parents
*/
function factory(node, index, parents) {
/** @type {Record} */
// @ts-expect-error: hush
const value = node && typeof node === 'object' ? node : {};
if (typeof value.type === 'string') {
const name =
// `hast`
typeof value.tagName === 'string' ? value.tagName :
// `xast`
typeof value.name === 'string' ? value.name : undefined;
Object.defineProperty(visit, 'name', {
value: 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'
});
}
return visit;
function visit() {
/** @type {ActionTuple} */
let result = [];
/** @type {ActionTuple} */
let subresult;
/** @type {number} */
let offset;
/** @type {Array} */
let grandparents;
if (!test || is(node, index, parents[parents.length - 1] || null)) {
result = toResult(visitor(node, parents));
if (result[0] === EXIT) {
return result;
}
}
// @ts-expect-error looks like a parent.
if (node.children && result[0] !== SKIP) {
// @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);
// @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)();
if (subresult[0] === EXIT) {
return subresult;
}
offset = typeof subresult[1] === 'number' ? subresult[1] : offset + step;
}
}
return result;
}
}
};
/**
* Turn a return value into a clean result.
*
* @param {VisitorResult} value
* Valid return values from visitors.
* @returns {ActionTuple}
* Clean result.
*/
function toResult(value) {
if (Array.isArray(value)) {
return value;
}
if (typeof value === 'number') {
return [CONTINUE, value];
}
return [value];
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js
/**
* @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
*/
/**
* Check if `Child` can be a child of `Ancestor`.
*
* Returns the ancestor when `Child` can be a child of `Ancestor`, or returns
* `never`.
*
* @template {Node} Ancestor
* Node type.
* @template {Node} Child
* Node type.
* @typedef {(
* Ancestor extends Parent
* ? Child extends Ancestor['children'][number]
* ? Ancestor
* : never
* : never
* )} ParentsOf
*/
/**
* @template {Node} [Visited=Node]
* Visited node type.
* @template {Parent} [Ancestor=Parent]
* Ancestor type.
* @callback Visitor
* Handle a node (matching `test`, if given).
*
* Visitors are free to transform `node`.
* They can also transform `parent`.
*
* Replacing `node` itself, if `SKIP` is not returned, still causes its
* descendants to be walked (which is a bug).
*
* When adding or removing previous siblings of `node` (or next siblings, in
* case of reverse), the `Visitor` should return a new `Index` to specify the
* sibling to traverse after `node` is traversed.
* Adding or removing next siblings of `node` (or previous siblings, in case
* of reverse) is handled as expected without needing to return a new `Index`.
*
* Removing the children property of `parent` still results in them being
* traversed.
* @param {Visited} node
* Found node.
* @param {Visited extends Node ? number | null : never} index
* Index of `node` in `parent`.
* @param {Ancestor extends Node ? Ancestor | null : never} parent
* Parent of `node`.
* @returns {VisitorResult}
* What to do next.
*
* An `Index` is treated as a tuple of `[CONTINUE, Index]`.
* An `Action` is treated as a tuple of `[Action]`.
*
* Passing a tuple back only makes sense if the `Action` is `SKIP`.
* When the `Action` is `EXIT`, that action can be returned.
* When the `Action` is `CONTINUE`, `Index` can be returned.
*/
/**
* Build a typed `Visitor` function from a node and all possible parents.
*
* It will infer which values are passed as `node` and which as `parent`.
*
* @template {Node} Visited
* Node type.
* @template {Parent} Ancestor
* Parent type.
* @typedef {Visitor>} BuildVisitorFromMatch
*/
/**
* Build a typed `Visitor` function from a list of descendants and a test.
*
* It will infer which values are passed as `node` and which as `parent`.
*
* @template {Node} Descendant
* Node type.
* @template {Test} Check
* Test type.
* @typedef {(
* BuildVisitorFromMatch<
* import('unist-util-visit-parents/complex-types.js').Matches,
* Extract
* >
* )} BuildVisitorFromDescendants
*/
/**
* Build a typed `Visitor` function from a tree and a test.
*
* It will infer which values are passed as `node` and which as `parent`.
*
* @template {Node} [Tree=Node]
* Node type.
* @template {Test} [Check=string]
* Test type.
* @typedef {(
* BuildVisitorFromDescendants<
* import('unist-util-visit-parents/complex-types.js').InclusiveDescendant,
* Check
* >
* )} BuildVisitor
*/
/**
* Visit nodes.
*
* This algorithm performs *depth-first* *tree traversal* in *preorder*
* (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
*
* You can choose for which nodes `visitor` is called by passing a `test`.
* For complex tests, you should test yourself in `visitor`, as it will be
* faster and will have improved type information.
*
* Walking the tree is an intensive task.
* Make use of the return values of the visitor when possible.
* Instead of walking a tree multiple times, walk it once, use `unist-util-is`
* to check if a node matches, and then perform different operations.
*
* You can change the tree.
* See `Visitor` for more info.
*
* @param tree
* Tree to traverse.
* @param test
* `unist-util-is`-compatible test
* @param visitor
* Handle each node.
* @param reverse
* Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
* @returns
* Nothing.
*/
const visit =
/**
* @type {(
* ((tree: Tree, test: Check, visitor: BuildVisitor, reverse?: boolean | null | undefined) => void) &
* ((tree: Tree, visitor: BuildVisitor, reverse?: boolean | null | undefined) => void)
* )}
*/
/**
* @param {Node} tree
* @param {Test} test
* @param {Visitor} visitor
* @param {boolean | null | undefined} [reverse]
* @returns {void}
*/
function (tree, test, visitor, reverse) {
if (typeof test === 'function' && typeof visitor !== 'function') {
reverse = visitor;
visitor = test;
test = null;
}
visitParents(tree, test, overload, reverse);
/**
* @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);
}
};
;// CONCATENATED MODULE: ./node_modules/.pnpm/unist-util-position@4.0.4/node_modules/unist-util-position/lib/index.js
/**
* @typedef {import('unist').Position} Position
* @typedef {import('unist').Node} Node
* @typedef {import('unist').Point} Point
*/
/**
* @typedef NodeLike
* @property {string} type
* @property {PositionLike | null | undefined} [position]
*
* @typedef PositionLike
* @property {PointLike | null | undefined} [start]
* @property {PointLike | null | undefined} [end]
*
* @typedef PointLike
* @property {number | null | undefined} [line]
* @property {number | null | undefined} [column]
* @property {number | null | undefined} [offset]
*/
/**
* Get the starting point of `node`.
*
* @param node
* Node.
* @returns
* Point.
*/
const pointStart = unist_util_position_lib_point('start');
/**
* Get the ending point of `node`.
*
* @param node
* Node.
* @returns
* Point.
*/
const pointEnd = unist_util_position_lib_point('end');
/**
* Get the positional info of `node`.
*
* @param {NodeLike | Node | null | undefined} [node]
* Node.
* @returns {Position}
* Position.
*/
function lib_position(node) {
return {
start: pointStart(node),
end: pointEnd(node)
};
}
/**
* Get the positional info of `node`.
*
* @param {'start' | 'end'} type
* Side.
* @returns
* Getter.
*/
function unist_util_position_lib_point(type) {
return point;
/**
* Get the point info of `node` at a bound side.
*
* @param {NodeLike | Node | null | undefined} [node]
* @returns {Point}
*/
function point(node) {
const point = node && node.position && node.position[type] || {};
// To do: next major: don’t return points when invalid.
return {
// @ts-expect-error: in practice, null is allowed.
line: point.line || null,
// @ts-expect-error: in practice, null is allowed.
column: point.column || null,
// @ts-expect-error: in practice, null is allowed.
offset: point.offset > -1 ? point.offset : null
};
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/unist-util-generated@2.0.1/node_modules/unist-util-generated/lib/index.js
/**
* @typedef PointLike
* @property {number | null | undefined} [line]
* @property {number | null | undefined} [column]
* @property {number | null | undefined} [offset]
*
* @typedef PositionLike
* @property {PointLike | null | undefined} [start]
* @property {PointLike | null | undefined} [end]
*
* @typedef NodeLike
* @property {PositionLike | null | undefined} [position]
*/
/**
* Check if `node` is generated.
*
* @param {NodeLike | null | undefined} [node]
* Node to check.
* @returns {boolean}
* Whether `node` is generated (does not have positional info).
*/
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;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-definitions@5.1.2/node_modules/mdast-util-definitions/lib/index.js
/**
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast').Content} Content
* @typedef {import('mdast').Definition} Definition
*/
/**
* @typedef {Root | Content} Node
*
* @callback GetDefinition
* Get a definition by identifier.
* @param {string | null | undefined} [identifier]
* Identifier of definition.
* @returns {Definition | null}
* Definition corresponding to `identifier` or `null`.
*/
const mdast_util_definitions_lib_own = {}.hasOwnProperty;
/**
* Find definitions in `tree`.
*
* Uses CommonMark precedence, which means that earlier definitions are
* preferred over duplicate later definitions.
*
* @param {Node} tree
* Tree to check.
* @returns {GetDefinition}
* Getter.
*/
function definitions(tree) {
/** @type {Record} */
const cache = Object.create(null);
if (!tree || !tree.type) {
throw new Error('mdast-util-definitions expected node');
}
visit(tree, 'definition', definition => {
const id = clean(definition.identifier);
if (id && !mdast_util_definitions_lib_own.call(cache, id)) {
cache[id] = definition;
}
});
return definition;
/** @type {GetDefinition} */
function definition(identifier) {
const id = clean(identifier);
// To do: next major: return `undefined` when not found.
return id && mdast_util_definitions_lib_own.call(cache, id) ? cache[id] : null;
}
}
/**
* @param {string | null | undefined} [value]
* @returns {string}
*/
function clean(value) {
return String(value || '').toUpperCase();
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/blockquote.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').Blockquote} Blockquote
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `blockquote` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Blockquote} node
* mdast node.
* @returns {Element}
* hast node.
*/
function blockquote(state, node) {
/** @type {Element} */
const result = {
type: 'element',
tagName: 'blockquote',
properties: {},
children: state.wrap(state.all(node), true)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/break.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Text} Text
* @typedef {import('mdast').Break} Break
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `break` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Break} node
* mdast node.
* @returns {Array}
* hast element content.
*/
function hardBreak(state, node) {
/** @type {Element} */
const result = {
type: 'element',
tagName: 'br',
properties: {},
children: []
};
state.patch(node, result);
return [state.applyData(node, result), {
type: 'text',
value: '\n'
}];
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/code.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Properties} Properties
* @typedef {import('mdast').Code} Code
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `code` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Code} node
* mdast node.
* @returns {Element}
* hast node.
*/
function code(state, node) {
const value = node.value ? node.value + '\n' : '';
// To do: next major, use `node.lang` w/o regex, the splitting’s been going
// on for years in remark now.
const lang = node.lang ? node.lang.match(/^[^ \t]+(?=[ \t]|$)/) : null;
/** @type {Properties} */
const properties = {};
if (lang) {
properties.className = ['language-' + lang];
}
// Create ``.
/** @type {Element} */
let result = {
type: 'element',
tagName: 'code',
properties,
children: [{
type: 'text',
value
}]
};
if (node.meta) {
result.data = {
meta: node.meta
};
}
state.patch(node, result);
result = state.applyData(node, result);
// Create ``.
result = {
type: 'element',
tagName: 'pre',
properties: {},
children: [result]
};
state.patch(node, result);
return result;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/delete.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').Delete} Delete
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `delete` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Delete} node
* mdast node.
* @returns {Element}
* hast node.
*/
function strikethrough(state, node) {
/** @type {Element} */
const result = {
type: 'element',
tagName: 'del',
properties: {},
children: state.all(node)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/emphasis.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').Emphasis} Emphasis
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `emphasis` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Emphasis} node
* mdast node.
* @returns {Element}
* hast node.
*/
function emphasis(state, node) {
/** @type {Element} */
const result = {
type: 'element',
tagName: 'em',
properties: {},
children: state.all(node)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js
/**
* @typedef {import('mdast').FootnoteReference} FootnoteReference
* @typedef {import('hast').Element} Element
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `footnoteReference` node into hast.
*
* @param {State} state
* Info passed around.
* @param {FootnoteReference} node
* mdast node.
* @returns {Element}
* hast node.
*/
function footnoteReference(state, node) {
const id = String(node.identifier).toUpperCase();
const safeId = normalizeUri(id.toLowerCase());
const index = state.footnoteOrder.indexOf(id);
/** @type {number} */
let counter;
if (index === -1) {
state.footnoteOrder.push(id);
state.footnoteCounts[id] = 1;
counter = state.footnoteOrder.length;
} else {
state.footnoteCounts[id]++;
counter = index + 1;
}
const reuseCounter = state.footnoteCounts[id];
/** @type {Element} */
const link = {
type: 'element',
tagName: 'a',
properties: {
href: '#' + state.clobberPrefix + 'fn-' + safeId,
id: state.clobberPrefix + 'fnref-' + safeId + (reuseCounter > 1 ? '-' + reuseCounter : ''),
dataFootnoteRef: true,
ariaDescribedBy: ['footnote-label']
},
children: [{
type: 'text',
value: String(counter)
}]
};
state.patch(node, link);
/** @type {Element} */
const sup = {
type: 'element',
tagName: 'sup',
properties: {},
children: [link]
};
state.patch(node, sup);
return state.applyData(node, sup);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/footnote.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').Footnote} Footnote
* @typedef {import('../state.js').State} State
*/
// To do: when both:
// *
// *
// …are archived, remove this (also from mdast).
// These inline notes are not used in GFM.
/**
* Turn an mdast `footnote` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Footnote} node
* mdast node.
* @returns {Element}
* hast node.
*/
function footnote(state, node) {
const footnoteById = state.footnoteById;
let no = 1;
while (no in footnoteById) no++;
const identifier = String(no);
footnoteById[identifier] = {
type: 'footnoteDefinition',
identifier,
children: [{
type: 'paragraph',
children: node.children
}],
position: node.position
};
return footnoteReference(state, {
type: 'footnoteReference',
identifier,
position: node.position
});
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/heading.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').Heading} Heading
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `heading` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Heading} node
* mdast node.
* @returns {Element}
* hast node.
*/
function heading(state, node) {
/** @type {Element} */
const result = {
type: 'element',
tagName: 'h' + node.depth,
properties: {},
children: state.all(node)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/html.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').HTML} Html
* @typedef {import('../state.js').State} State
* @typedef {import('../../index.js').Raw} Raw
*/
/**
* Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise
* nothing).
*
* @param {State} state
* Info passed around.
* @param {Html} node
* mdast node.
* @returns {Raw | Element | null}
* hast node.
*/
function html(state, node) {
if (state.dangerous) {
/** @type {Raw} */
const result = {
type: 'raw',
value: node.value
};
state.patch(node, result);
return state.applyData(node, result);
}
// To do: next major: return `undefined`.
return null;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/revert.js
/**
* @typedef {import('hast').ElementContent} ElementContent
*
* @typedef {import('mdast').Content} Content
* @typedef {import('mdast').Reference} Reference
* @typedef {import('mdast').Root} Root
*
* @typedef {import('./state.js').State} State
*/
/**
* @typedef {Root | Content} Nodes
* @typedef {Extract} References
*/
// To do: next major: always return array.
/**
* Return the content of a reference without definition as plain text.
*
* @param {State} state
* Info passed around.
* @param {References} node
* Reference node (image, link).
* @returns {ElementContent | Array}
* hast content.
*/
function revert(state, node) {
const subtype = node.referenceType;
let suffix = ']';
if (subtype === 'collapsed') {
suffix += '[]';
} else if (subtype === 'full') {
suffix += '[' + (node.label || node.identifier) + ']';
}
if (node.type === 'imageReference') {
return {
type: 'text',
value: '![' + node.alt + suffix
};
}
const contents = state.all(node);
const head = contents[0];
if (head && head.type === 'text') {
head.value = '[' + head.value;
} else {
contents.unshift({
type: 'text',
value: '['
});
}
const tail = contents[contents.length - 1];
if (tail && tail.type === 'text') {
tail.value += suffix;
} else {
contents.push({
type: 'text',
value: suffix
});
}
return contents;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/image-reference.js
/**
* @typedef {import('hast').ElementContent} ElementContent
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Properties} Properties
* @typedef {import('mdast').ImageReference} ImageReference
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `imageReference` node into hast.
*
* @param {State} state
* Info passed around.
* @param {ImageReference} node
* mdast node.
* @returns {ElementContent | Array}
* hast node.
*/
function imageReference(state, node) {
const def = state.definition(node.identifier);
if (!def) {
return revert(state, node);
}
/** @type {Properties} */
const properties = {
src: normalizeUri(def.url || ''),
alt: node.alt
};
if (def.title !== null && def.title !== undefined) {
properties.title = def.title;
}
/** @type {Element} */
const result = {
type: 'element',
tagName: 'img',
properties,
children: []
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/image.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Properties} Properties
* @typedef {import('mdast').Image} Image
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `image` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Image} node
* mdast node.
* @returns {Element}
* hast node.
*/
function image_image(state, node) {
/** @type {Properties} */
const properties = {
src: normalizeUri(node.url)
};
if (node.alt !== null && node.alt !== undefined) {
properties.alt = node.alt;
}
if (node.title !== null && node.title !== undefined) {
properties.title = node.title;
}
/** @type {Element} */
const result = {
type: 'element',
tagName: 'img',
properties,
children: []
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/inline-code.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Text} Text
* @typedef {import('mdast').InlineCode} InlineCode
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `inlineCode` node into hast.
*
* @param {State} state
* Info passed around.
* @param {InlineCode} node
* mdast node.
* @returns {Element}
* hast node.
*/
function inlineCode(state, node) {
/** @type {Text} */
const text = {
type: 'text',
value: node.value.replace(/\r?\n|\r/g, ' ')
};
state.patch(node, text);
/** @type {Element} */
const result = {
type: 'element',
tagName: 'code',
properties: {},
children: [text]
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/link-reference.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').ElementContent} ElementContent
* @typedef {import('hast').Properties} Properties
* @typedef {import('mdast').LinkReference} LinkReference
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `linkReference` node into hast.
*
* @param {State} state
* Info passed around.
* @param {LinkReference} node
* mdast node.
* @returns {ElementContent | Array}
* hast node.
*/
function linkReference(state, node) {
const def = state.definition(node.identifier);
if (!def) {
return revert(state, node);
}
/** @type {Properties} */
const properties = {
href: normalizeUri(def.url || '')
};
if (def.title !== null && def.title !== undefined) {
properties.title = def.title;
}
/** @type {Element} */
const result = {
type: 'element',
tagName: 'a',
properties,
children: state.all(node)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/link.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Properties} Properties
* @typedef {import('mdast').Link} Link
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `link` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Link} node
* mdast node.
* @returns {Element}
* hast node.
*/
function link_link(state, node) {
/** @type {Properties} */
const properties = {
href: normalizeUri(node.url)
};
if (node.title !== null && node.title !== undefined) {
properties.title = node.title;
}
/** @type {Element} */
const result = {
type: 'element',
tagName: 'a',
properties,
children: state.all(node)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/list-item.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').ElementContent} ElementContent
* @typedef {import('hast').Properties} Properties
* @typedef {import('mdast').Content} Content
* @typedef {import('mdast').ListItem} ListItem
* @typedef {import('mdast').Parent} Parent
* @typedef {import('mdast').Root} Root
* @typedef {import('../state.js').State} State
*/
/**
* @typedef {Root | Content} Nodes
* @typedef {Extract} Parents
*/
/**
* Turn an mdast `listItem` node into hast.
*
* @param {State} state
* Info passed around.
* @param {ListItem} node
* mdast node.
* @param {Parents | null | undefined} parent
* Parent of `node`.
* @returns {Element}
* hast node.
*/
function listItem(state, node, parent) {
const results = state.all(node);
const loose = parent ? listLoose(parent) : listItemLoose(node);
/** @type {Properties} */
const properties = {};
/** @type {Array} */
const children = [];
if (typeof node.checked === 'boolean') {
const head = results[0];
/** @type {Element} */
let paragraph;
if (head && head.type === 'element' && head.tagName === 'p') {
paragraph = head;
} else {
paragraph = {
type: 'element',
tagName: 'p',
properties: {},
children: []
};
results.unshift(paragraph);
}
if (paragraph.children.length > 0) {
paragraph.children.unshift({
type: 'text',
value: ' '
});
}
paragraph.children.unshift({
type: 'element',
tagName: 'input',
properties: {
type: 'checkbox',
checked: node.checked,
disabled: true
},
children: []
});
// According to github-markdown-css, this class hides bullet.
// See: .
properties.className = ['task-list-item'];
}
let index = -1;
while (++index < results.length) {
const child = results[index];
// Add eols before nodes, except if this is a loose, first paragraph.
if (loose || index !== 0 || child.type !== 'element' || child.tagName !== 'p') {
children.push({
type: 'text',
value: '\n'
});
}
if (child.type === 'element' && child.tagName === 'p' && !loose) {
children.push(...child.children);
} else {
children.push(child);
}
}
const tail = results[results.length - 1];
// Add a final eol.
if (tail && (loose || tail.type !== 'element' || tail.tagName !== 'p')) {
children.push({
type: 'text',
value: '\n'
});
}
/** @type {Element} */
const result = {
type: 'element',
tagName: 'li',
properties,
children
};
state.patch(node, result);
return state.applyData(node, result);
}
/**
* @param {Parents} node
* @return {Boolean}
*/
function listLoose(node) {
let loose = false;
if (node.type === 'list') {
loose = node.spread || false;
const children = node.children;
let index = -1;
while (!loose && ++index < children.length) {
loose = listItemLoose(children[index]);
}
}
return loose;
}
/**
* @param {ListItem} node
* @return {Boolean}
*/
function listItemLoose(node) {
const spread = node.spread;
return spread === undefined || spread === null ? node.children.length > 1 : spread;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/list.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Properties} Properties
* @typedef {import('mdast').List} List
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `list` node into hast.
*
* @param {State} state
* Info passed around.
* @param {List} node
* mdast node.
* @returns {Element}
* hast node.
*/
function list_list(state, node) {
/** @type {Properties} */
const properties = {};
const results = state.all(node);
let index = -1;
if (typeof node.start === 'number' && node.start !== 1) {
properties.start = node.start;
}
// Like GitHub, add a class for custom styling.
while (++index < results.length) {
const child = results[index];
if (child.type === 'element' && child.tagName === 'li' && child.properties && Array.isArray(child.properties.className) && child.properties.className.includes('task-list-item')) {
properties.className = ['contains-task-list'];
break;
}
}
/** @type {Element} */
const result = {
type: 'element',
tagName: node.ordered ? 'ol' : 'ul',
properties,
children: state.wrap(results, true)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/paragraph.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').Paragraph} Paragraph
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `paragraph` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Paragraph} node
* mdast node.
* @returns {Element}
* hast node.
*/
function paragraph(state, node) {
/** @type {Element} */
const result = {
type: 'element',
tagName: 'p',
properties: {},
children: state.all(node)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/root.js
/**
* @typedef {import('hast').Root} HastRoot
* @typedef {import('hast').Element} HastElement
* @typedef {import('mdast').Root} MdastRoot
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `root` node into hast.
*
* @param {State} state
* Info passed around.
* @param {MdastRoot} node
* mdast node.
* @returns {HastRoot | HastElement}
* hast node.
*/
function root(state, node) {
/** @type {HastRoot} */
const result = {
type: 'root',
children: state.wrap(state.all(node))
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/strong.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').Strong} Strong
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `strong` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Strong} node
* mdast node.
* @returns {Element}
* hast node.
*/
function strong(state, node) {
/** @type {Element} */
const result = {
type: 'element',
tagName: 'strong',
properties: {},
children: state.all(node)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/table.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').Table} Table
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `table` node into hast.
*
* @param {State} state
* Info passed around.
* @param {Table} node
* mdast node.
* @returns {Element}
* hast node.
*/
function table(state, node) {
const rows = state.all(node);
const firstRow = rows.shift();
/** @type {Array} */
const tableContent = [];
if (firstRow) {
/** @type {Element} */
const head = {
type: 'element',
tagName: 'thead',
properties: {},
children: state.wrap([firstRow], true)
};
state.patch(node.children[0], head);
tableContent.push(head);
}
if (rows.length > 0) {
/** @type {Element} */
const body = {
type: 'element',
tagName: 'tbody',
properties: {},
children: state.wrap(rows, true)
};
const start = pointStart(node.children[1]);
const end = pointEnd(node.children[node.children.length - 1]);
if (start.line && end.line) body.position = {
start,
end
};
tableContent.push(body);
}
/** @type {Element} */
const result = {
type: 'element',
tagName: 'table',
properties: {},
children: state.wrap(tableContent, true)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/table-row.js
/**
* @typedef {import('hast').Properties} Properties
* @typedef {import('hast').Element} Element
* @typedef {import('hast').ElementContent} ElementContent
* @typedef {import('mdast').Content} Content
* @typedef {import('mdast').Parent} Parent
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast').TableRow} TableRow
* @typedef {import('../state.js').State} State
*/
/**
* @typedef {Root | Content} Nodes
* @typedef {Extract} Parents
*/
/**
* Turn an mdast `tableRow` node into hast.
*
* @param {State} state
* Info passed around.
* @param {TableRow} node
* mdast node.
* @param {Parents | null | undefined} parent
* Parent of `node`.
* @returns {Element}
* hast node.
*/
function tableRow(state, node, parent) {
const siblings = parent ? parent.children : undefined;
// Generate a body row when without parent.
const rowIndex = siblings ? siblings.indexOf(node) : 1;
const tagName = rowIndex === 0 ? 'th' : 'td';
const align = parent && parent.type === 'table' ? parent.align : undefined;
const length = align ? align.length : node.children.length;
let cellIndex = -1;
/** @type {Array} */
const cells = [];
while (++cellIndex < length) {
// Note: can also be undefined.
const cell = node.children[cellIndex];
/** @type {Properties} */
const properties = {};
const alignValue = align ? align[cellIndex] : undefined;
if (alignValue) {
properties.align = alignValue;
}
/** @type {Element} */
let result = {
type: 'element',
tagName,
properties,
children: []
};
if (cell) {
result.children = state.all(cell);
state.patch(cell, result);
result = state.applyData(node, result);
}
cells.push(result);
}
/** @type {Element} */
const result = {
type: 'element',
tagName: 'tr',
properties: {},
children: state.wrap(cells, true)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/table-cell.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').TableCell} TableCell
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `tableCell` node into hast.
*
* @param {State} state
* Info passed around.
* @param {TableCell} node
* mdast node.
* @returns {Element}
* hast node.
*/
function tableCell(state, node) {
// Note: this function is normally not called: see `table-row` for how rows
// and their cells are compiled.
/** @type {Element} */
const result = {
type: 'element',
tagName: 'td',
// Assume body cell.
properties: {},
children: state.all(node)
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/trim-lines@3.0.1/node_modules/trim-lines/index.js
const tab = 9; /* `\t` */
const space = 32; /* ` ` */
/**
* Remove initial and final spaces and tabs at the line breaks in `value`.
* Does not trim initial and final spaces and tabs of the value itself.
*
* @param {string} value
* Value to trim.
* @returns {string}
* Trimmed value.
*/
function trimLines(value) {
const source = String(value);
const search = /\r?\n|\r/g;
let match = search.exec(source);
let last = 0;
/** @type {Array} */
const lines = [];
while (match) {
lines.push(trimLine(source.slice(last, match.index), last > 0, true), match[0]);
last = match.index + match[0].length;
match = search.exec(source);
}
lines.push(trimLine(source.slice(last), last > 0, false));
return lines.join('');
}
/**
* @param {string} value
* Line to trim.
* @param {boolean} start
* Whether to trim the start of the line.
* @param {boolean} end
* Whether to trim the end of the line.
* @returns {string}
* Trimmed line.
*/
function trimLine(value, start, end) {
let startIndex = 0;
let endIndex = value.length;
if (start) {
let code = value.codePointAt(startIndex);
while (code === tab || code === space) {
startIndex++;
code = value.codePointAt(startIndex);
}
}
if (end) {
let code = value.codePointAt(endIndex - 1);
while (code === tab || code === space) {
endIndex--;
code = value.codePointAt(endIndex - 1);
}
}
return endIndex > startIndex ? value.slice(startIndex, endIndex) : '';
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/text.js
/**
* @typedef {import('hast').Element} HastElement
* @typedef {import('hast').Text} HastText
* @typedef {import('mdast').Text} MdastText
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `text` node into hast.
*
* @param {State} state
* Info passed around.
* @param {MdastText} node
* mdast node.
* @returns {HastText | HastElement}
* hast node.
*/
function handlers_text_text(state, node) {
/** @type {HastText} */
const result = {
type: 'text',
value: trimLines(String(node.value))
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
/**
* @typedef {import('hast').Element} Element
* @typedef {import('mdast').ThematicBreak} ThematicBreak
* @typedef {import('../state.js').State} State
*/
/**
* Turn an mdast `thematicBreak` node into hast.
*
* @param {State} state
* Info passed around.
* @param {ThematicBreak} node
* mdast node.
* @returns {Element}
* hast node.
*/
function thematic_break_thematicBreak(state, node) {
/** @type {Element} */
const result = {
type: 'element',
tagName: 'hr',
properties: {},
children: []
};
state.patch(node, result);
return state.applyData(node, result);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/handlers/index.js
/**
* Default handlers for nodes.
*/
const handlers = {
blockquote: blockquote,
break: hardBreak,
code: code,
delete: strikethrough,
emphasis: emphasis,
footnoteReference: footnoteReference,
footnote: footnote,
heading: heading,
html: html,
imageReference: imageReference,
image: image_image,
inlineCode: inlineCode,
linkReference: linkReference,
link: link_link,
listItem: listItem,
list: list_list,
paragraph: paragraph,
root: root,
strong: strong,
table: table,
tableCell: tableCell,
tableRow: tableRow,
text: handlers_text_text,
thematicBreak: thematic_break_thematicBreak,
toml: ignore,
yaml: ignore,
definition: ignore,
footnoteDefinition: ignore
};
// Return nothing for nodes that are ignored.
function ignore() {
// To do: next major: return `undefined`.
return null;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/state.js
/**
* @typedef {import('hast').Content} HastContent
* @typedef {import('hast').Element} HastElement
* @typedef {import('hast').ElementContent} HastElementContent
* @typedef {import('hast').Properties} HastProperties
* @typedef {import('hast').Root} HastRoot
* @typedef {import('hast').Text} HastText
*
* @typedef {import('mdast').Content} MdastContent
* @typedef {import('mdast').Definition} MdastDefinition
* @typedef {import('mdast').FootnoteDefinition} MdastFootnoteDefinition
* @typedef {import('mdast').Parent} MdastParent
* @typedef {import('mdast').Root} MdastRoot
*/
/**
* @typedef {HastRoot | HastContent} HastNodes
* @typedef {MdastRoot | MdastContent} MdastNodes
* @typedef {Extract} MdastParents
*
* @typedef EmbeddedHastFields
* hast fields.
* @property {string | null | undefined} [hName]
* Generate a specific element with this tag name instead.
* @property {HastProperties | null | undefined} [hProperties]
* Generate an element with these properties instead.
* @property {Array | null | undefined} [hChildren]
* Generate an element with this content instead.
*
* @typedef {Record & EmbeddedHastFields} MdastData
* mdast data with embedded hast fields.
*
* @typedef {MdastNodes & {data?: MdastData | null | undefined}} MdastNodeWithData
* mdast node with embedded hast data.
*
* @typedef PointLike
* Point-like value.
* @property {number | null | undefined} [line]
* Line.
* @property {number | null | undefined} [column]
* Column.
* @property {number | null | undefined} [offset]
* Offset.
*
* @typedef PositionLike
* Position-like value.
* @property {PointLike | null | undefined} [start]
* Point-like value.
* @property {PointLike | null | undefined} [end]
* Point-like value.
*
* @callback Handler
* Handle a node.
* @param {State} state
* Info passed around.
* @param {any} node
* mdast node to handle.
* @param {MdastParents | null | undefined} parent
* Parent of `node`.
* @returns {HastElementContent | Array | null | undefined}
* hast node.
*
* @callback HFunctionProps
* Signature of `state` for when props are passed.
* @param {MdastNodes | PositionLike | null | undefined} node
* mdast node or unist position.
* @param {string} tagName
* HTML tag name.
* @param {HastProperties} props
* Properties.
* @param {Array | null | undefined} [children]
* hast content.
* @returns {HastElement}
* Compiled element.
*
* @callback HFunctionNoProps
* Signature of `state` for when no props are passed.
* @param {MdastNodes | PositionLike | null | undefined} node
* mdast node or unist position.
* @param {string} tagName
* HTML tag name.
* @param {Array | null | undefined} [children]
* hast content.
* @returns {HastElement}
* Compiled element.
*
* @typedef HFields
* Info on `state`.
* @property {boolean} dangerous
* Whether HTML is allowed.
* @property {string} clobberPrefix
* Prefix to use to prevent DOM clobbering.
* @property {string} footnoteLabel
* Label to use to introduce the footnote section.
* @property {string} footnoteLabelTagName
* HTML used for the footnote label.
* @property {HastProperties} footnoteLabelProperties
* Properties on the HTML tag used for the footnote label.
* @property {string} footnoteBackLabel
* Label to use from backreferences back to their footnote call.
* @property {(identifier: string) => MdastDefinition | null} definition
* Definition cache.
* @property {Record} footnoteById
* Footnote definitions by their identifier.
* @property {Array} footnoteOrder
* Identifiers of order when footnote calls first appear in tree order.
* @property {Record} footnoteCounts
* Counts for how often the same footnote was called.
* @property {Handlers} handlers
* Applied handlers.
* @property {Handler} unknownHandler
* Handler for any none not in `passThrough` or otherwise handled.
* @property {(from: MdastNodes, node: HastNodes) => void} patch
* Copy a node’s positional info.
* @property {(from: MdastNodes, to: Type) => Type | HastElement} applyData
* Honor the `data` of `from`, and generate an element instead of `node`.
* @property {(node: MdastNodes, parent: MdastParents | null | undefined) => HastElementContent | Array | null | undefined} one
* Transform an mdast node to hast.
* @property {(node: MdastNodes) => Array} all
* Transform the children of an mdast parent to hast.
* @property {(nodes: Array, loose?: boolean | null | undefined) => Array} wrap
* Wrap `nodes` with line endings between each node, adds initial/final line endings when `loose`.
* @property {(left: MdastNodeWithData | PositionLike | null | undefined, right: HastElementContent) => HastElementContent} augment
* Like `state` but lower-level and usable on non-elements.
* Deprecated: use `patch` and `applyData`.
* @property {Array} passThrough
* List of node types to pass through untouched (except for their children).
*
* @typedef Options
* Configuration (optional).
* @property {boolean | null | undefined} [allowDangerousHtml=false]
* Whether to persist raw HTML in markdown in the hast tree.
* @property {string | null | undefined} [clobberPrefix='user-content-']
* Prefix to use before the `id` attribute on footnotes to prevent it from
* *clobbering*.
* @property {string | null | undefined} [footnoteBackLabel='Back to content']
* Label to use from backreferences back to their footnote call (affects
* screen readers).
* @property {string | null | undefined} [footnoteLabel='Footnotes']
* Label to use for the footnotes section (affects screen readers).
* @property {HastProperties | null | undefined} [footnoteLabelProperties={className: ['sr-only']}]
* Properties to use on the footnote label (note that `id: 'footnote-label'`
* is always added as footnote calls use it with `aria-describedby` to
* provide an accessible label).
* @property {string | null | undefined} [footnoteLabelTagName='h2']
* Tag name to use for the footnote label.
* @property {Handlers | null | undefined} [handlers]
* Extra handlers for nodes.
* @property {Array | null | undefined} [passThrough]
* List of custom mdast node types to pass through (keep) in hast (note that
* the node itself is passed, but eventual children are transformed).
* @property {Handler | null | undefined} [unknownHandler]
* Handler for all unknown nodes.
*
* @typedef {Record} Handlers
* Handle nodes.
*
* @typedef {HFunctionProps & HFunctionNoProps & HFields} State
* Info passed around.
*/
const state_own = {}.hasOwnProperty;
/**
* Create `state` from an mdast tree.
*
* @param {MdastNodes} tree
* mdast node to transform.
* @param {Options | null | undefined} [options]
* Configuration.
* @returns {State}
* `state` function.
*/
function createState(tree, options) {
const settings = options || {};
const dangerous = settings.allowDangerousHtml || false;
/** @type {Record} */
const footnoteById = {};
// To do: next major: add `options` to state, remove:
// `dangerous`, `clobberPrefix`, `footnoteLabel`, `footnoteLabelTagName`,
// `footnoteLabelProperties`, `footnoteBackLabel`, `passThrough`,
// `unknownHandler`.
// To do: next major: move to `state.options.allowDangerousHtml`.
state.dangerous = dangerous;
// To do: next major: move to `state.options`.
state.clobberPrefix = settings.clobberPrefix === undefined || settings.clobberPrefix === null ? 'user-content-' : settings.clobberPrefix;
// To do: next major: move to `state.options`.
state.footnoteLabel = settings.footnoteLabel || 'Footnotes';
// To do: next major: move to `state.options`.
state.footnoteLabelTagName = settings.footnoteLabelTagName || 'h2';
// To do: next major: move to `state.options`.
state.footnoteLabelProperties = settings.footnoteLabelProperties || {
className: ['sr-only']
};
// To do: next major: move to `state.options`.
state.footnoteBackLabel = settings.footnoteBackLabel || 'Back to content';
// To do: next major: move to `state.options`.
state.unknownHandler = settings.unknownHandler;
// To do: next major: move to `state.options`.
state.passThrough = settings.passThrough;
state.handlers = {
...handlers,
...settings.handlers
};
// To do: next major: replace utility with `definitionById` object, so we
// only walk once (as we need footnotes too).
state.definition = definitions(tree);
state.footnoteById = footnoteById;
/** @type {Array} */
state.footnoteOrder = [];
/** @type {Record} */
state.footnoteCounts = {};
state.patch = patch;
state.applyData = applyData;
state.one = oneBound;
state.all = allBound;
state.wrap = state_wrap;
// To do: next major: remove `augment`.
state.augment = augment;
visit(tree, 'footnoteDefinition', definition => {
const id = String(definition.identifier).toUpperCase();
// Mimick CM behavior of link definitions.
// See: .
if (!state_own.call(footnoteById, id)) {
footnoteById[id] = definition;
}
});
// @ts-expect-error Hush, it’s fine!
return state;
/**
* Finalise the created `right`, a hast node, from `left`, an mdast node.
*
* @param {MdastNodeWithData | PositionLike | null | undefined} left
* @param {HastElementContent} right
* @returns {HastElementContent}
*/
/* c8 ignore start */
// To do: next major: remove.
function augment(left, right) {
// Handle `data.hName`, `data.hProperties, `data.hChildren`.
if (left && 'data' in left && left.data) {
/** @type {MdastData} */
const data = left.data;
if (data.hName) {
if (right.type !== 'element') {
right = {
type: 'element',
tagName: '',
properties: {},
children: []
};
}
right.tagName = data.hName;
}
if (right.type === 'element' && data.hProperties) {
right.properties = {
...right.properties,
...data.hProperties
};
}
if ('children' in right && right.children && data.hChildren) {
right.children = data.hChildren;
}
}
if (left) {
const ctx = 'type' in left ? left : {
position: left
};
if (!generated(ctx)) {
// @ts-expect-error: fine.
right.position = {
start: pointStart(ctx),
end: pointEnd(ctx)
};
}
}
return right;
}
/* c8 ignore stop */
/**
* Create an element for `node`.
*
* @type {HFunctionProps}
*/
/* c8 ignore start */
// To do: next major: remove.
function state(node, tagName, props, children) {
if (Array.isArray(props)) {
children = props;
props = {};
}
// @ts-expect-error augmenting an element yields an element.
return augment(node, {
type: 'element',
tagName,
properties: props || {},
children: children || []
});
}
/* c8 ignore stop */
/**
* Transform an mdast node into a hast node.
*
* @param {MdastNodes} node
* mdast node.
* @param {MdastParents | null | undefined} [parent]
* Parent of `node`.
* @returns {HastElementContent | Array | null | undefined}
* Resulting hast node.
*/
function oneBound(node, parent) {
// @ts-expect-error: that’s a state :)
return state_one(state, node, parent);
}
/**
* Transform the children of an mdast node into hast nodes.
*
* @param {MdastNodes} parent
* mdast node to compile
* @returns {Array}
* Resulting hast nodes.
*/
function allBound(parent) {
// @ts-expect-error: that’s a state :)
return state_all(state, parent);
}
}
/**
* Copy a node’s positional info.
*
* @param {MdastNodes} from
* mdast node to copy from.
* @param {HastNodes} to
* hast node to copy into.
* @returns {void}
* Nothing.
*/
function patch(from, to) {
if (from.position) to.position = lib_position(from);
}
/**
* Honor the `data` of `from` and maybe generate an element instead of `to`.
*
* @template {HastNodes} Type
* Node type.
* @param {MdastNodes} from
* mdast node to use data from.
* @param {Type} to
* hast node to change.
* @returns {Type | HastElement}
* Nothing.
*/
function applyData(from, to) {
/** @type {Type | HastElement} */
let result = to;
// Handle `data.hName`, `data.hProperties, `data.hChildren`.
if (from && from.data) {
const hName = from.data.hName;
const hChildren = from.data.hChildren;
const hProperties = from.data.hProperties;
if (typeof hName === 'string') {
// Transforming the node resulted in an element with a different name
// than wanted:
if (result.type === 'element') {
result.tagName = hName;
}
// Transforming the node resulted in a non-element, which happens for
// raw, text, and root nodes (unless custom handlers are passed).
// The intent is likely to keep the content around (otherwise: pass
// `hChildren`).
else {
result = {
type: 'element',
tagName: hName,
properties: {},
children: []
};
// To do: next major: take the children from the `root`, or inject the
// raw/text/comment or so into the element?
// if ('children' in node) {
// // @ts-expect-error: assume `children` are allowed in elements.
// result.children = node.children
// } else {
// // @ts-expect-error: assume `node` is allowed in elements.
// result.children.push(node)
// }
}
}
if (result.type === 'element' && hProperties) {
result.properties = {
...result.properties,
...hProperties
};
}
if ('children' in result && result.children && hChildren !== null && hChildren !== undefined) {
// @ts-expect-error: assume valid children are defined.
result.children = hChildren;
}
}
return result;
}
/**
* Transform an mdast node into a hast node.
*
* @param {State} state
* Info passed around.
* @param {MdastNodes} node
* mdast node.
* @param {MdastParents | null | undefined} [parent]
* Parent of `node`.
* @returns {HastElementContent | Array | null | undefined}
* Resulting hast node.
*/
// To do: next major: do not expose, keep bound.
function state_one(state, node, parent) {
const type = node && node.type;
// Fail on non-nodes.
if (!type) {
throw new Error('Expected node, got `' + node + '`');
}
if (state_own.call(state.handlers, type)) {
return state.handlers[type](state, node, parent);
}
if (state.passThrough && state.passThrough.includes(type)) {
// To do: next major: deep clone.
// @ts-expect-error: types of passed through nodes are expected to be added manually.
return 'children' in node ? {
...node,
children: state_all(state, node)
} : node;
}
if (state.unknownHandler) {
return state.unknownHandler(state, node, parent);
}
return defaultUnknownHandler(state, node);
}
/**
* Transform the children of an mdast node into hast nodes.
*
* @param {State} state
* Info passed around.
* @param {MdastNodes} parent
* mdast node to compile
* @returns {Array}
* Resulting hast nodes.
*/
// To do: next major: do not expose, keep bound.
function state_all(state, parent) {
/** @type {Array} */
const values = [];
if ('children' in parent) {
const nodes = parent.children;
let index = -1;
while (++index < nodes.length) {
const result = state_one(state, nodes[index], parent);
// To do: see if we van clean this? Can we merge texts?
if (result) {
if (index && nodes[index - 1].type === 'break') {
if (!Array.isArray(result) && result.type === 'text') {
result.value = result.value.replace(/^\s+/, '');
}
if (!Array.isArray(result) && result.type === 'element') {
const head = result.children[0];
if (head && head.type === 'text') {
head.value = head.value.replace(/^\s+/, '');
}
}
}
if (Array.isArray(result)) {
values.push(...result);
} else {
values.push(result);
}
}
}
}
return values;
}
/**
* Transform an unknown node.
*
* @param {State} state
* Info passed around.
* @param {MdastNodes} node
* Unknown mdast node.
* @returns {HastText | HastElement}
* Resulting hast node.
*/
function defaultUnknownHandler(state, node) {
const data = node.data || {};
/** @type {HastText | HastElement} */
const result = 'value' in node && !(state_own.call(data, 'hProperties') || state_own.call(data, 'hChildren')) ? {
type: 'text',
value: node.value
} : {
type: 'element',
tagName: 'div',
properties: {},
children: state_all(state, node)
};
state.patch(node, result);
return state.applyData(node, result);
}
/**
* Wrap `nodes` with line endings between each node.
*
* @template {HastContent} Type
* Node type.
* @param {Array} nodes
* List of nodes to wrap.
* @param {boolean | null | undefined} [loose=false]
* Whether to add line endings at start and end.
* @returns {Array}
* Wrapped nodes.
*/
function state_wrap(nodes, loose) {
/** @type {Array} */
const result = [];
let index = -1;
if (loose) {
result.push({
type: 'text',
value: '\n'
});
}
while (++index < nodes.length) {
if (index) result.push({
type: 'text',
value: '\n'
});
result.push(nodes[index]);
}
if (loose && nodes.length > 0) {
result.push({
type: 'text',
value: '\n'
});
}
return result;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/mdast-util-to-hast@12.3.0/node_modules/mdast-util-to-hast/lib/index.js
/**
* @typedef {import('hast').Content} HastContent
* @typedef {import('hast').Root} HastRoot
*
* @typedef {import('mdast').Content} MdastContent
* @typedef {import('mdast').Root} MdastRoot
*
* @typedef {import('./state.js').Options} Options
*/
/**
* @typedef {HastRoot | HastContent} HastNodes
* @typedef {MdastRoot | MdastContent} MdastNodes
*/
/**
* Transform mdast to hast.
*
* ##### Notes
*
* ###### HTML
*
* Raw HTML is available in mdast as `html` nodes and can be embedded in hast
* as semistandard `raw` nodes.
* Most utilities ignore `raw` nodes but two notable ones don’t:
*
* * `hast-util-to-html` also has an option `allowDangerousHtml` which will
* output the raw HTML.
* This is typically discouraged as noted by the option name but is useful
* if you completely trust authors
* * `hast-util-raw` can handle the raw embedded HTML strings by parsing them
* into standard hast nodes (`element`, `text`, etc).
* This is a heavy task as it needs a full HTML parser, but it is the only
* way to support untrusted content
*
* ###### Footnotes
*
* Many options supported here relate to footnotes.
* Footnotes are not specified by CommonMark, which we follow by default.
* They are supported by GitHub, so footnotes can be enabled in markdown with
* `mdast-util-gfm`.
*
* The options `footnoteBackLabel` and `footnoteLabel` define natural language
* that explains footnotes, which is hidden for sighted users but shown to
* assistive technology.
* When your page is not in English, you must define translated values.
*
* Back references use ARIA attributes, but the section label itself uses a
* heading that is hidden with an `sr-only` class.
* To show it to sighted users, define different attributes in
* `footnoteLabelProperties`.
*
* ###### Clobbering
*
* Footnotes introduces a problem, as it links footnote calls to footnote
* definitions on the page through `id` attributes generated from user content,
* which results in DOM clobbering.
*
* DOM clobbering is this:
*
* ```html
*
*
* ```
*
* Elements by their ID are made available by browsers on the `window` object,
* which is a security risk.
* Using a prefix solves this problem.
*
* More information on how to handle clobbering and the prefix is explained in
* Example: headings (DOM clobbering) in `rehype-sanitize`.
*
* ###### Unknown nodes
*
* Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.
* The default behavior for unknown nodes is:
*
* * when the node has a `value` (and doesn’t have `data.hName`,
* `data.hProperties`, or `data.hChildren`, see later), create a hast `text`
* node
* * otherwise, create a `` element (which could be changed with
* `data.hName`), with its children mapped from mdast to hast as well
*
* This behavior can be changed by passing an `unknownHandler`.
*
* @param {MdastNodes} tree
* mdast tree.
* @param {Options | null | undefined} [options]
* Configuration.
* @returns {HastNodes | null | undefined}
* hast tree.
*/
// To do: next major: always return a single `root`.
function toHast(tree, options) {
const state = createState(tree, options);
const node = state.one(tree, null);
const foot = footer(state);
if (foot) {
// @ts-expect-error If there’s a footer, there were definitions, meaning block
// content.
// So assume `node` is a parent node.
node.children.push({
type: 'text',
value: '\n'
}, foot);
}
// To do: next major: always return root?
return Array.isArray(node) ? {
type: 'root',
children: node
} : node;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/remark-rehype@10.1.0/node_modules/remark-rehype/lib/index.js
/**
* @typedef {import('hast').Root} HastRoot
* @typedef {import('mdast').Root} MdastRoot
* @typedef {import('mdast-util-to-hast').Options} Options
* @typedef {import('unified').Processor} Processor
*
* @typedef {import('mdast-util-to-hast')} DoNotTouchAsThisImportIncludesRawInTree
*/
// Note: the `` overload doesn’t seem to work :'(
/**
* Plugin that turns markdown into HTML to support rehype.
*
* * If a destination processor is given, that processor runs with a new HTML
* (hast) tree (bridge-mode).
* As the given processor runs with a hast tree, and rehype plugins support
* hast, that means rehype plugins can be used with the given processor.
* The hast tree is discarded in the end.
* It’s highly unlikely that you want to do this.
* * The common case is to not pass a destination processor, in which case the
* current processor continues running with a new HTML (hast) tree
* (mutate-mode).
* As the current processor continues with a hast tree, and rehype plugins
* support hast, that means rehype plugins can be used after
* `remark-rehype`.
* It’s likely that this is what you want to do.
*
* @param destination
* Optional unified processor.
* @param options
* Options passed to `mdast-util-to-hast`.
*/
const remarkRehype = /** @type {(import('unified').Plugin<[Processor, Options?]|[null|undefined, Options?]|[Options]|[], MdastRoot>)} */
function (destination, options) {
return destination && 'run' in destination ? bridge(destination, options) : mutate(destination || options);
};
/* harmony default export */ const lib = (remarkRehype);
/**
* Bridge-mode.
* Runs the destination with the new hast tree.
*
* @type {import('unified').Plugin<[Processor, Options?], MdastRoot>}
*/
function bridge(destination, options) {
return (node, file, next) => {
destination.run(toHast(node, options), file, error => {
next(error);
});
};
}
/**
* Mutate-mode.
* Further plugins run on the hast tree.
*
* @type {import('unified').Plugin<[Options?]|void[], MdastRoot, HastRoot>}
*/
function mutate(options) {
// @ts-expect-error: assume a corresponding node is returned by `toHast`.
return node => toHast(node, options);
}
// EXTERNAL MODULE: ./node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js
var prop_types = __webpack_require__(7897);
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/util/schema.js
/**
* @typedef {import('./info.js').Info} Info
* @typedef {Record} Properties
* @typedef {Record} Normal
*/
class Schema {
/**
* @constructor
* @param {Properties} property
* @param {Normal} normal
* @param {string} [space]
*/
constructor(property, normal, space) {
this.property = property;
this.normal = normal;
if (space) {
this.space = space;
}
}
}
/** @type {Properties} */
Schema.prototype.property = {};
/** @type {Normal} */
Schema.prototype.normal = {};
/** @type {string|null} */
Schema.prototype.space = null;
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/util/merge.js
/**
* @typedef {import('./schema.js').Properties} Properties
* @typedef {import('./schema.js').Normal} Normal
*/
/**
* @param {Schema[]} definitions
* @param {string} [space]
* @returns {Schema}
*/
function merge(definitions, space) {
/** @type {Properties} */
const property = {};
/** @type {Normal} */
const normal = {};
let index = -1;
while (++index < definitions.length) {
Object.assign(property, definitions[index].property);
Object.assign(normal, definitions[index].normal);
}
return new Schema(property, normal, space);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/normalize.js
/**
* @param {string} value
* @returns {string}
*/
function normalize_normalize(value) {
return value.toLowerCase();
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/util/info.js
class Info {
/**
* @constructor
* @param {string} property
* @param {string} attribute
*/
constructor(property, attribute) {
/** @type {string} */
this.property = property;
/** @type {string} */
this.attribute = attribute;
}
}
/** @type {string|null} */
Info.prototype.space = null;
Info.prototype.boolean = false;
Info.prototype.booleanish = false;
Info.prototype.overloadedBoolean = false;
Info.prototype.number = false;
Info.prototype.commaSeparated = false;
Info.prototype.spaceSeparated = false;
Info.prototype.commaOrSpaceSeparated = false;
Info.prototype.mustUseProperty = false;
Info.prototype.defined = false;
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/util/types.js
let powers = 0;
const types_boolean = increment();
const booleanish = increment();
const overloadedBoolean = increment();
const number = increment();
const spaceSeparated = increment();
const commaSeparated = increment();
const commaOrSpaceSeparated = increment();
function increment() {
return 2 ** ++powers;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/util/defined-info.js
/** @type {Array} */
// @ts-expect-error: hush.
const checks = Object.keys(types_namespaceObject);
class DefinedInfo extends Info {
/**
* @constructor
* @param {string} property
* @param {string} attribute
* @param {number|null} [mask]
* @param {string} [space]
*/
constructor(property, attribute, mask, space) {
let index = -1;
super(property, attribute);
mark(this, 'space', space);
if (typeof mask === 'number') {
while (++index < checks.length) {
const check = checks[index];
mark(this, checks[index], (mask & types_namespaceObject[check]) === types_namespaceObject[check]);
}
}
}
}
DefinedInfo.prototype.defined = true;
/**
* @param {DefinedInfo} values
* @param {string} key
* @param {unknown} value
*/
function mark(values, key, value) {
if (value) {
// @ts-expect-error: assume `value` matches the expected value of `key`.
values[key] = value;
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/util/create.js
/**
* @typedef {import('./schema.js').Properties} Properties
* @typedef {import('./schema.js').Normal} Normal
*
* @typedef {Record} Attributes
*
* @typedef {Object} Definition
* @property {Record} properties
* @property {(attributes: Attributes, property: string) => string} transform
* @property {string} [space]
* @property {Attributes} [attributes]
* @property {Array} [mustUseProperty]
*/
const create_own = {}.hasOwnProperty;
/**
* @param {Definition} definition
* @returns {Schema}
*/
function create(definition) {
/** @type {Properties} */
const property = {};
/** @type {Normal} */
const normal = {};
/** @type {string} */
let prop;
for (prop in definition.properties) {
if (create_own.call(definition.properties, prop)) {
const value = definition.properties[prop];
const info = new DefinedInfo(prop, definition.transform(definition.attributes || {}, prop), value, definition.space);
if (definition.mustUseProperty && definition.mustUseProperty.includes(prop)) {
info.mustUseProperty = true;
}
property[prop] = info;
normal[normalize_normalize(prop)] = prop;
normal[normalize_normalize(info.attribute)] = prop;
}
}
return new Schema(property, normal, definition.space);
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/xlink.js
const xlink = create({
space: 'xlink',
transform(_, prop) {
return 'xlink:' + prop.slice(5).toLowerCase();
},
properties: {
xLinkActuate: null,
xLinkArcRole: null,
xLinkHref: null,
xLinkRole: null,
xLinkShow: null,
xLinkTitle: null,
xLinkType: null
}
});
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/xml.js
const xml = create({
space: 'xml',
transform(_, prop) {
return 'xml:' + prop.slice(3).toLowerCase();
},
properties: {
xmlLang: null,
xmlBase: null,
xmlSpace: null
}
});
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/util/case-sensitive-transform.js
/**
* @param {Record} attributes
* @param {string} attribute
* @returns {string}
*/
function caseSensitiveTransform(attributes, attribute) {
return attribute in attributes ? attributes[attribute] : attribute;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/util/case-insensitive-transform.js
/**
* @param {Record} attributes
* @param {string} property
* @returns {string}
*/
function caseInsensitiveTransform(attributes, property) {
return caseSensitiveTransform(attributes, property.toLowerCase());
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/xmlns.js
const xmlns = create({
space: 'xmlns',
attributes: {
xmlnsxlink: 'xmlns:xlink'
},
transform: caseInsensitiveTransform,
properties: {
xmlns: null,
xmlnsXLink: null
}
});
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/aria.js
const aria = create({
transform(_, prop) {
return prop === 'role' ? prop : 'aria-' + prop.slice(4).toLowerCase();
},
properties: {
ariaActiveDescendant: null,
ariaAtomic: booleanish,
ariaAutoComplete: null,
ariaBusy: booleanish,
ariaChecked: booleanish,
ariaColCount: number,
ariaColIndex: number,
ariaColSpan: number,
ariaControls: spaceSeparated,
ariaCurrent: null,
ariaDescribedBy: spaceSeparated,
ariaDetails: null,
ariaDisabled: booleanish,
ariaDropEffect: spaceSeparated,
ariaErrorMessage: null,
ariaExpanded: booleanish,
ariaFlowTo: spaceSeparated,
ariaGrabbed: booleanish,
ariaHasPopup: null,
ariaHidden: booleanish,
ariaInvalid: null,
ariaKeyShortcuts: null,
ariaLabel: null,
ariaLabelledBy: spaceSeparated,
ariaLevel: number,
ariaLive: null,
ariaModal: booleanish,
ariaMultiLine: booleanish,
ariaMultiSelectable: booleanish,
ariaOrientation: null,
ariaOwns: spaceSeparated,
ariaPlaceholder: null,
ariaPosInSet: number,
ariaPressed: booleanish,
ariaReadOnly: booleanish,
ariaRelevant: null,
ariaRequired: booleanish,
ariaRoleDescription: spaceSeparated,
ariaRowCount: number,
ariaRowIndex: number,
ariaRowSpan: number,
ariaSelected: booleanish,
ariaSetSize: number,
ariaSort: null,
ariaValueMax: number,
ariaValueMin: number,
ariaValueNow: number,
ariaValueText: null,
role: null
}
});
;// CONCATENATED MODULE: ./node_modules/.pnpm/property-information@6.3.0/node_modules/property-information/lib/html.js
const html_html = create({
space: 'html',
attributes: {
acceptcharset: 'accept-charset',
classname: 'class',
htmlfor: 'for',
httpequiv: 'http-equiv'
},
transform: caseInsensitiveTransform,
mustUseProperty: ['checked', 'multiple', 'muted', 'selected'],
properties: {
// Standard Properties.
abbr: null,
accept: commaSeparated,
acceptCharset: spaceSeparated,
accessKey: spaceSeparated,
action: null,
allow: null,
allowFullScreen: types_boolean,
allowPaymentRequest: types_boolean,
allowUserMedia: types_boolean,
alt: null,
as: null,
async: types_boolean,
autoCapitalize: null,
autoComplete: spaceSeparated,
autoFocus: types_boolean,
autoPlay: types_boolean,
blocking: spaceSeparated,
capture: types_boolean,
charSet: null,
checked: types_boolean,
cite: null,
className: spaceSeparated,
cols: number,
colSpan: null,
content: null,
contentEditable: booleanish,
controls: types_boolean,
controlsList: spaceSeparated,
coords: number | commaSeparated,
crossOrigin: null,
data: null,
dateTime: null,
decoding: null,
default: types_boolean,
defer: types_boolean,
dir: null,
dirName: null,
disabled: types_boolean,
download: overloadedBoolean,
draggable: booleanish,
encType: null,
enterKeyHint: null,
fetchPriority: null,
form: null,
formAction: null,
formEncType: null,
formMethod: null,
formNoValidate: types_boolean,
formTarget: null,
headers: spaceSeparated,
height: number,
hidden: types_boolean,
high: number,
href: null,
hrefLang: null,
htmlFor: spaceSeparated,
httpEquiv: spaceSeparated,
id: null,
imageSizes: null,
imageSrcSet: null,
inert: types_boolean,
inputMode: null,
integrity: null,
is: null,
isMap: types_boolean,
itemId: null,
itemProp: spaceSeparated,
itemRef: spaceSeparated,
itemScope: types_boolean,
itemType: spaceSeparated,
kind: null,
label: null,
lang: null,
language: null,
list: null,
loading: null,
loop: types_boolean,
low: number,
manifest: null,
max: null,
maxLength: number,
media: null,
method: null,
min: null,
minLength: number,
multiple: types_boolean,
muted: types_boolean,
name: null,
nonce: null,
noModule: types_boolean,
noValidate: types_boolean,
onAbort: null,
onAfterPrint: null,
onAuxClick: null,
onBeforeMatch: null,
onBeforePrint: null,
onBeforeUnload: null,
onBlur: null,
onCancel: null,
onCanPlay: null,
onCanPlayThrough: null,
onChange: null,
onClick: null,
onClose: null,
onContextLost: null,
onContextMenu: null,
onContextRestored: null,
onCopy: null,
onCueChange: null,
onCut: null,
onDblClick: null,
onDrag: null,
onDragEnd: null,
onDragEnter: null,
onDragExit: null,
onDragLeave: null,
onDragOver: null,
onDragStart: null,
onDrop: null,
onDurationChange: null,
onEmptied: null,
onEnded: null,
onError: null,
onFocus: null,
onFormData: null,
onHashChange: null,
onInput: null,
onInvalid: null,
onKeyDown: null,
onKeyPress: null,
onKeyUp: null,
onLanguageChange: null,
onLoad: null,
onLoadedData: null,
onLoadedMetadata: null,
onLoadEnd: null,
onLoadStart: null,
onMessage: null,
onMessageError: null,
onMouseDown: null,
onMouseEnter: null,
onMouseLeave: null,
onMouseMove: null,
onMouseOut: null,
onMouseOver: null,
onMouseUp: null,
onOffline: null,
onOnline: null,
onPageHide: null,
onPageShow: null,
onPaste: null,
onPause: null,
onPlay: null,
onPlaying: null,
onPopState: null,
onProgress: null,
onRateChange: null,
onRejectionHandled: null,
onReset: null,
onResize: null,
onScroll: null,
onScrollEnd: null,
onSecurityPolicyViolation: null,
onSeeked: null,
onSeeking: null,
onSelect: null,
onSlotChange: null,
onStalled: null,
onStorage: null,
onSubmit: null,
onSuspend: null,
onTimeUpdate: null,
onToggle: null,
onUnhandledRejection: null,
onUnload: null,
onVolumeChange: null,
onWaiting: null,
onWheel: null,
open: types_boolean,
optimum: number,
pattern: null,
ping: spaceSeparated,
placeholder: null,
playsInline: types_boolean,
popover: null,
popoverTarget: null,
popoverTargetAction: null,
poster: null,
preload: null,
readOnly: types_boolean,
referrerPolicy: null,
rel: spaceSeparated,
required: types_boolean,
reversed: types_boolean,
rows: number,
rowSpan: number,
sandbox: spaceSeparated,
scope: null,
scoped: types_boolean,
seamless: types_boolean,
selected: types_boolean,
shape: null,
size: number,
sizes: null,
slot: null,
span: number,
spellCheck: booleanish,
src: null,
srcDoc: null,
srcLang: null,
srcSet: null,
start: number,
step: null,
style: null,
tabIndex: number,
target: null,
title: null,
translate: null,
type: null,
typeMustMatch: types_boolean,
useMap: null,
value: booleanish,
width: number,
wrap: null,
// Legacy.
// See: https://html.spec.whatwg.org/#other-elements,-attributes-and-apis
align: null,
// Several. Use CSS `text-align` instead,
aLink: null,
// ``. Use CSS `a:active {color}` instead
archive: spaceSeparated,
// `