UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1,254 lines (1,253 loc) • 29.7 kB
import { c as normalizeIdentifier, l as decodeNamedCharacterReference, n as postprocess, r as parse, t as preprocess } from "./preprocess-CrIuhpzj.mjs"; //#region node_modules/.pnpm/micromark-util-decode-numeric-character-reference@2.0.2/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.fromCodePoint(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(e, t) { const n = Number.parseInt(e, t); if (n < 9 || n === 11 || n > 13 && n < 32 || n > 126 && n < 160 || n > 55295 && n < 57344 || n > 64975 && n < 65008 || (n & 65535) === 65535 || (n & 65535) === 65534 || n > 1114111) return "�"; return String.fromCodePoint(n); } //#endregion //#region node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js /** * @typedef {import('mdast').Nodes} Nodes * * @typedef Options * Configuration (optional). * @property {boolean | null | undefined} [includeImageAlt=true] * Whether to use `alt` for `image`s (default: `true`). * @property {boolean | null | undefined} [includeHtml=true] * Whether to use `value` of HTML (default: `true`). */ /** @type {Options} */ const emptyOptions = {}; /** * Get the text content of a node or list of nodes. * * Prefers the node’s plain-text fields, otherwise serializes its children, * and if the given value is an array, serialize the nodes in it. * * @param {unknown} [value] * Thing to serialize, typically `Node`. * @param {Options | null | undefined} [options] * Configuration (optional). * @returns {string} * Serialized `value`. */ function toString(e, t) { const n = t || emptyOptions; return one(e, typeof n.includeImageAlt === "boolean" ? n.includeImageAlt : true, typeof n.includeHtml === "boolean" ? n.includeHtml : true); } /** * One node or several nodes. * * @param {unknown} value * Thing to serialize. * @param {boolean} includeImageAlt * Include image `alt`s. * @param {boolean} includeHtml * Include HTML. * @returns {string} * Serialized node. */ function one(e, t, n) { if (node(e)) { if ("value" in e) return e.type === "html" && !n ? "" : e.value; if (t && "alt" in e && e.alt) return e.alt; if ("children" in e) return all(e.children, t, n); } if (Array.isArray(e)) return all(e, t, n); return ""; } /** * Serialize a list of nodes. * * @param {Array<unknown>} values * Thing to serialize. * @param {boolean} includeImageAlt * Include image `alt`s. * @param {boolean} includeHtml * Include HTML. * @returns {string} * Serialized nodes. */ function all(e, t, n) { /** @type {Array<string>} */ const r = []; let i = -1; while (++i < e.length) r[i] = one(e[i], t, n); return r.join(""); } /** * Check if `value` looks like a node. * * @param {unknown} value * Thing. * @returns {value is Nodes} * Whether `value` is a node. */ function node(e) { return Boolean(e && typeof e === "object"); } //#endregion //#region node_modules/.pnpm/micromark-util-decode-string@2.0.1/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(e) { return e.replace(characterEscapeOrReference, decode); } /** * @param {string} $0 * Match. * @param {string} $1 * Character escape. * @param {string} $2 * Character reference. * @returns {string} * Decoded value */ function decode(e, t, n) { if (t) return t; if (n.charCodeAt(0) === 35) { const e = n.charCodeAt(1); const t = e === 120 || e === 88; return decodeNumericCharacterReference(n.slice(t ? 2 : 1), t ? 16 : 10); } return decodeNamedCharacterReference(n) || e; } //#endregion //#region node_modules/.pnpm/unist-util-stringify-position@4.0.0/node_modules/unist-util-stringify-position/lib/index.js /** * @typedef {import('unist').Node} Node * @typedef {import('unist').Point} Point * @typedef {import('unist').Position} Position */ /** * @typedef NodeLike * @property {string} type * @property {PositionLike | null | undefined} [position] * * @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] */ /** * Serialize the positional info of a point, position (start and end points), * or node. * * @param {Node | NodeLike | Point | PointLike | Position | PositionLike | null | undefined} [value] * Node, position, or point. * @returns {string} * Pretty printed positional info of a node (`string`). * * In the format of a range `ls:cs-le:ce` (when given `node` or `position`) * or a point `l:c` (when given `point`), where `l` stands for line, `c` for * column, `s` for `start`, and `e` for end. * An empty string (`''`) is returned if the given value is neither `node`, * `position`, nor `point`. */ function stringifyPosition(e) { if (!e || typeof e !== "object") return ""; if ("position" in e || "type" in e) return position(e.position); if ("start" in e || "end" in e) return position(e); if ("line" in e || "column" in e) return point$1(e); return ""; } /** * @param {Point | PointLike | null | undefined} point * @returns {string} */ function point$1(e) { return index(e && e.line) + ":" + index(e && e.column); } /** * @param {Position | PositionLike | null | undefined} pos * @returns {string} */ function position(e) { return point$1(e && e.start) + "-" + point$1(e && e.end); } /** * @param {number | null | undefined} value * @returns {number} */ function index(e) { return e && typeof e === "number" ? e : 1; } //#endregion //#region node_modules/.pnpm/mdast-util-from-markdown@2.1.0_supports-color@10.2.2/node_modules/mdast-util-from-markdown/lib/index.js /** * @import { * Break, * Blockquote, * Code, * Definition, * Emphasis, * Heading, * Html, * Image, * InlineCode, * Link, * ListItem, * List, * Nodes, * Paragraph, * PhrasingContent, * ReferenceType, * Root, * Strong, * Text, * ThematicBreak * } from 'mdast' * @import { * Encoding, * Event, * Token, * Value * } from 'micromark-util-types' * @import {Point} from 'unist' * @import { * CompileContext, * CompileData, * Config, * Extension, * Handle, * OnEnterError, * Options * } from './types.js' */ const own = {}.hasOwnProperty; /** * Turn markdown into a syntax tree. * * @overload * @param {Value} value * @param {Encoding | null | undefined} [encoding] * @param {Options | null | undefined} [options] * @returns {Root} * * @overload * @param {Value} value * @param {Options | null | undefined} [options] * @returns {Root} * * @param {Value} value * Markdown to parse. * @param {Encoding | Options | null | undefined} [encoding] * Character encoding for when `value` is `Buffer`. * @param {Options | null | undefined} [options] * Configuration. * @returns {Root} * mdast tree. */ function fromMarkdown(e, t, n) { if (t && typeof t === "object") { n = t; t = void 0; } return compiler(n)(postprocess(parse(n).document().write(preprocess()(e, t, true)))); } /** * Note this compiler only understand complete buffering, not streaming. * * @param {Options | null | undefined} [options] */ function compiler(e) { /** @type {Config} */ const t = { afterExit: [], beforeEnter: [], 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, characterReference: onexitcharacterreference, 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(t, (e || {}).mdastExtensions || []); /** @type {CompileData} */ const n = {}; return compile; /** * Turn micromark events into an mdast tree. * * @param {Array<Event>} events * Events. * @returns {Root} * mdast tree. */ function compile(e) { /** @type {Root} */ let r = { type: "root", children: [], position: void 0 }; /** @type {Omit<CompileContext, 'sliceSerialize'>} */ const i = { stack: [r], tokenStack: [], config: t, enter, exit, buffer, resume, data: n }; /** @type {Array<number>} */ const a = []; /** @type {Array<Event>} */ const o = []; let s = -1; while (++s < e.length) { o.push(e[s]); if (e[s][1].type === "listOrdered" || e[s][1].type === "listUnordered") { if (e[s][0] === "enter") a.push(o.length - 1); else prepareList(o, a.pop()); } } e = o; s = -1; while (++s < e.length) { const n = t[e[s][0]]; if (e[s][0] === "enter" && t.beforeEnter.length > 0) callListeners(t.beforeEnter, { ...i, sliceSerialize: e[s][2].sliceSerialize }, e[s][1]); if (own.call(n, e[s][1].type)) n[e[s][1].type].call({ ...i, sliceSerialize: e[s][2].sliceSerialize }, e[s][1]); if (e[s][0] === "exit" && t.afterExit.length > 0) callListeners(t.afterExit, { ...i, sliceSerialize: e[s][2].sliceSerialize }, e[s][1]); } if (i.tokenStack.length > 0) { const e = i.tokenStack[i.tokenStack.length - 1]; (e[1] || defaultOnError).call(i, void 0, e[0]); } r.position = { start: point(e.length > 0 ? e[0][1].start : { line: 1, column: 1, offset: 0 }), end: point(e.length > 0 ? e[e.length - 2][1].end : { line: 1, column: 1, offset: 0 }) }; s = -1; while (++s < t.transforms.length) r = t.transforms[s](r) || r; return r; } /** * @param {Array<Handle>} listeners * Listeners. * @param {CompileContext} context * Context. * @param {Token} token * Token. * @returns {undefined} * Nothing. */ function callListeners(e, t, n) { let r = -1; while (++r < e.length) e[r].call(t, n); } /** * @param {Array<Event>} events * Events, ending with the list to prepare. * @param {number} start * Index of the list enter. * @returns {undefined} */ function prepareList(e, t) { const n = e.length - 1; let r = t - 1; let i = -1; let a = false; /** @type {Token | undefined} */ let o; /** @type {number | undefined} */ let s; /** @type {number | undefined} */ let c; /** @type {boolean | undefined} */ let l; /** * `listItem` events to insert before the event at `at`, in walk order. * Merged in after the walk, as inserting while walking would shift the * rest of the list once per item. * @type {Array<{at: number, event: Event}>} */ const u = []; while (++r <= n) { const t = e[r]; switch (t[1].type) { case "listUnordered": case "listOrdered": case "blockQuote": if (t[0] === "enter") i++; else i--; l = void 0; break; case "lineEndingBlank": if (t[0] === "enter") { if (o && !l && !i && !c) c = r; l = void 0; } break; case "linePrefix": case "listItemValue": case "listItemMarker": case "listItemPrefix": case "listItemPrefixWhitespace": break; default: l = void 0; } if (!i && t[0] === "enter" && t[1].type === "listItemPrefix" || i === -1 && t[0] === "exit" && (t[1].type === "listUnordered" || t[1].type === "listOrdered")) { if (o) { let n = r; s = void 0; while (n--) { const t = e[n]; if (t[1].type === "lineEnding" || t[1].type === "lineEndingBlank") { if (t[0] === "exit") continue; if (s) { e[s][1].type = "lineEndingBlank"; a = true; } t[1].type = "lineEnding"; s = n; } else if (t[1].type === "linePrefix" || t[1].type === "blockQuotePrefix" || t[1].type === "blockQuotePrefixWhitespace" || t[1].type === "blockQuoteMarker" || t[1].type === "listItemIndent") {} else break; } if (c && (!s || c < s)) o._spread = true; o.end = Object.assign({}, s ? e[s][1].start : t[1].end); u.push({ at: s || r, event: [ "exit", o, t[2] ] }); } if (t[1].type === "listItemPrefix") { /** @type {Token} */ const e = { type: "listItem", _spread: false, start: Object.assign({}, t[1].start), end: void 0 }; o = e; u.push({ at: r, event: [ "enter", e, t[2] ] }); c = void 0; l = true; } } } const d = e.splice(t); let f = 0; r = -1; while (++r < d.length) { while (f < u.length && u[f].at === t + r) e.push(u[f++].event); e.push(d[r]); } e[t][1]._spread = a; } /** * Create an opener handle. * * @param {(token: Token) => Nodes} create * Create a node. * @param {Handle | undefined} [and] * Optional function to also run. * @returns {Handle} * Handle. */ function opener(e, t) { return open; /** * @this {CompileContext} * @param {Token} token * @returns {undefined} */ function open(n) { enter.call(this, e(n), n); if (t) t.call(this, n); } } /** * @type {CompileContext['buffer']} */ function buffer() { this.stack.push({ type: "fragment", children: [] }); } /** * @type {CompileContext['enter']} */ function enter(e, t, n) { this.stack[this.stack.length - 1].children.push(e); this.stack.push(e); this.tokenStack.push([t, n || void 0]); e.position = { start: point(t.start), end: void 0 }; } /** * Create a closer handle. * * @param {Handle | undefined} [and] * Optional function to also run. * @returns {Handle} * Handle. */ function closer(e) { return close; /** * @this {CompileContext} * @param {Token} token * @returns {undefined} */ function close(t) { if (e) e.call(this, t); exit.call(this, t); } } /** * @type {CompileContext['exit']} */ function exit(e, t) { const n = this.stack.pop(); const r = this.tokenStack.pop(); if (!r) throw new Error("Cannot close `" + e.type + "` (" + stringifyPosition({ start: e.start, end: e.end }) + "): it’s not open"); if (r[0].type !== e.type) { if (t) t.call(this, e, r[0]); else (r[1] || defaultOnError).call(this, e, r[0]); } n.position.end = point(e.end); } /** * @type {CompileContext['resume']} */ function resume() { return toString(this.stack.pop()); } /** * @this {CompileContext} * @type {Handle} */ function onenterlistordered() { this.data.expectingFirstListItemValue = true; } /** * @this {CompileContext} * @type {Handle} */ function onenterlistitemvalue(e) { if (this.data.expectingFirstListItemValue) { const t = this.stack[this.stack.length - 2]; t.start = Number.parseInt(this.sliceSerialize(e), 10); this.data.expectingFirstListItemValue = void 0; } } /** * @this {CompileContext} * @type {Handle} */ function onexitcodefencedfenceinfo() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.lang = e; } /** * @this {CompileContext} * @type {Handle} */ function onexitcodefencedfencemeta() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.meta = e; } /** * @this {CompileContext} * @type {Handle} */ function onexitcodefencedfence() { if (this.data.flowCodeInside) return; this.buffer(); this.data.flowCodeInside = true; } /** * @this {CompileContext} * @type {Handle} */ function onexitcodefenced() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.value = e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ""); this.data.flowCodeInside = void 0; } /** * @this {CompileContext} * @type {Handle} */ function onexitcodeindented() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.value = e.replace(/(\r?\n|\r)$/g, ""); } /** * @this {CompileContext} * @type {Handle} */ function onexitdefinitionlabelstring(e) { const t = this.resume(); const n = this.stack[this.stack.length - 1]; n.label = t; n.identifier = normalizeIdentifier(this.sliceSerialize(e)).toLowerCase(); } /** * @this {CompileContext} * @type {Handle} */ function onexitdefinitiontitlestring() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.title = e; } /** * @this {CompileContext} * @type {Handle} */ function onexitdefinitiondestinationstring() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.url = e; } /** * @this {CompileContext} * @type {Handle} */ function onexitatxheadingsequence(e) { const t = this.stack[this.stack.length - 1]; if (!t.depth) t.depth = this.sliceSerialize(e).length; } /** * @this {CompileContext} * @type {Handle} */ function onexitsetextheadingtext() { this.data.setextHeadingSlurpLineEnding = true; } /** * @this {CompileContext} * @type {Handle} */ function onexitsetextheadinglinesequence(e) { const t = this.stack[this.stack.length - 1]; t.depth = this.sliceSerialize(e).codePointAt(0) === 61 ? 1 : 2; } /** * @this {CompileContext} * @type {Handle} */ function onexitsetextheading() { this.data.setextHeadingSlurpLineEnding = void 0; } /** * @this {CompileContext} * @type {Handle} */ function onenterdata(e) { /** @type {Array<Nodes>} */ const t = this.stack[this.stack.length - 1].children; let n = t[t.length - 1]; if (!n || n.type !== "text") { n = text(); n.position = { start: point(e.start), end: void 0 }; t.push(n); } this.stack.push(n); } /** * @this {CompileContext} * @type {Handle} */ function onexitdata(e) { const t = this.stack.pop(); t.value += this.sliceSerialize(e); t.position.end = point(e.end); } /** * @this {CompileContext} * @type {Handle} */ function onexitlineending(e) { const n = this.stack[this.stack.length - 1]; if (this.data.atHardBreak) { const t = n.children[n.children.length - 1]; t.position.end = point(e.end); this.data.atHardBreak = void 0; return; } if (!this.data.setextHeadingSlurpLineEnding && t.canContainEols.includes(n.type)) { onenterdata.call(this, e); onexitdata.call(this, e); } } /** * @this {CompileContext} * @type {Handle} */ function onexithardbreak() { this.data.atHardBreak = true; } /** * @this {CompileContext} * @type {Handle} */ function onexithtmlflow() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.value = e; } /** * @this {CompileContext} * @type {Handle} */ function onexithtmltext() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.value = e; } /** * @this {CompileContext} * @type {Handle} */ function onexitcodetext() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.value = e; } /** * @this {CompileContext} * @type {Handle} */ function onexitlink() { const e = this.stack[this.stack.length - 1]; if (this.data.inReference) { /** @type {ReferenceType} */ const t = this.data.referenceType || "shortcut"; e.type += "Reference"; e.referenceType = t; delete e.url; delete e.title; } else { delete e.identifier; delete e.label; } this.data.referenceType = void 0; } /** * @this {CompileContext} * @type {Handle} */ function onexitimage() { const e = this.stack[this.stack.length - 1]; if (this.data.inReference) { /** @type {ReferenceType} */ const t = this.data.referenceType || "shortcut"; e.type += "Reference"; e.referenceType = t; delete e.url; delete e.title; } else { delete e.identifier; delete e.label; } this.data.referenceType = void 0; } /** * @this {CompileContext} * @type {Handle} */ function onexitlabeltext(e) { const t = this.sliceSerialize(e); const n = this.stack[this.stack.length - 2]; n.label = decodeString(t); n.identifier = normalizeIdentifier(t).toLowerCase(); } /** * @this {CompileContext} * @type {Handle} */ function onexitlabel() { const e = this.stack[this.stack.length - 1]; const t = this.resume(); const n = this.stack[this.stack.length - 1]; this.data.inReference = true; if (n.type === "link") n.children = e.children; else n.alt = t; } /** * @this {CompileContext} * @type {Handle} */ function onexitresourcedestinationstring() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.url = e; } /** * @this {CompileContext} * @type {Handle} */ function onexitresourcetitlestring() { const e = this.resume(); const t = this.stack[this.stack.length - 1]; t.title = e; } /** * @this {CompileContext} * @type {Handle} */ function onexitresource() { this.data.inReference = void 0; } /** * @this {CompileContext} * @type {Handle} */ function onenterreference() { this.data.referenceType = "collapsed"; } /** * @this {CompileContext} * @type {Handle} */ function onexitreferencestring(e) { const t = this.resume(); const n = this.stack[this.stack.length - 1]; n.label = t; n.identifier = normalizeIdentifier(this.sliceSerialize(e)).toLowerCase(); this.data.referenceType = "full"; } /** * @this {CompileContext} * @type {Handle} */ function onexitcharacterreferencemarker(e) { this.data.characterReferenceType = e.type; } /** * @this {CompileContext} * @type {Handle} */ function onexitcharacterreferencevalue(e) { const t = this.sliceSerialize(e); const n = this.data.characterReferenceType; /** @type {string} */ let r; if (n) { r = decodeNumericCharacterReference(t, n === "characterReferenceMarkerNumeric" ? 10 : 16); this.data.characterReferenceType = void 0; } else r = decodeNamedCharacterReference(t); const i = this.stack[this.stack.length - 1]; i.value += r; } /** * @this {CompileContext} * @type {Handle} */ function onexitcharacterreference(e) { const t = this.stack.pop(); t.position.end = point(e.end); } /** * @this {CompileContext} * @type {Handle} */ function onexitautolinkprotocol(e) { onexitdata.call(this, e); const t = this.stack[this.stack.length - 1]; t.url = this.sliceSerialize(e); } /** * @this {CompileContext} * @type {Handle} */ function onexitautolinkemail(e) { onexitdata.call(this, e); const t = this.stack[this.stack.length - 1]; t.url = "mailto:" + this.sliceSerialize(e); } /** @returns {Blockquote} */ function blockQuote() { return { type: "blockquote", children: [], position: void 0 }; } /** @returns {Code} */ function codeFlow() { return { type: "code", lang: null, meta: null, value: "", position: void 0 }; } /** @returns {InlineCode} */ function codeText() { return { type: "inlineCode", value: "", position: void 0 }; } /** @returns {Definition} */ function definition() { return { type: "definition", identifier: "", label: null, title: null, url: "", position: void 0 }; } /** @returns {Emphasis} */ function emphasis() { return { type: "emphasis", children: [], position: void 0 }; } /** @returns {Heading} */ function heading() { return { type: "heading", depth: 0, children: [], position: void 0 }; } /** @returns {Break} */ function hardBreak() { return { type: "break", position: void 0 }; } /** @returns {Html} */ function html() { return { type: "html", value: "", position: void 0 }; } /** @returns {Image} */ function image() { return { type: "image", title: null, url: "", alt: null, position: void 0 }; } /** @returns {Link} */ function link() { return { type: "link", title: null, url: "", children: [], position: void 0 }; } /** * @param {Token} token * @returns {List} */ function list(e) { return { type: "list", ordered: e.type === "listOrdered", start: null, spread: e._spread, children: [], position: void 0 }; } /** * @param {Token} token * @returns {ListItem} */ function listItem(e) { return { type: "listItem", spread: e._spread, checked: null, children: [], position: void 0 }; } /** @returns {Paragraph} */ function paragraph() { return { type: "paragraph", children: [], position: void 0 }; } /** @returns {Strong} */ function strong() { return { type: "strong", children: [], position: void 0 }; } /** @returns {Text} */ function text() { return { type: "text", value: "", position: void 0 }; } /** @returns {ThematicBreak} */ function thematicBreak() { return { type: "thematicBreak", position: void 0 }; } } /** * Copy a point-like value. * * @param {Point} d * Point-like value. * @returns {Point} * unist point. */ function point(e) { return { line: e.line, column: e.column, offset: e.offset }; } /** * @param {Config} combined * @param {Array<Array<Extension> | Extension>} extensions * @returns {undefined} */ function configure(e, t) { let n = -1; while (++n < t.length) { const r = t[n]; if (Array.isArray(r)) configure(e, r); else extension(e, r); } } /** * @param {Config} combined * @param {Extension} extension * @returns {undefined} */ function extension(e, t) { /** @type {keyof Extension} */ let n; for (n in t) if (own.call(t, n)) switch (n) { case "canContainEols": { const r = t[n]; if (r) e[n].push(...r); break; } case "transforms": { const r = t[n]; if (r) e[n].push(...r); break; } case "afterExit": case "beforeEnter": { const r = t[n]; if (r) e[n].push(r); break; } case "enter": case "exit": { const r = t[n]; if (r) Object.assign(e[n], r); break; } } } /** @type {OnEnterError} */ function defaultOnError(e, t) { if (e) throw new Error("Cannot close `" + e.type + "` (" + stringifyPosition({ start: e.start, end: e.end }) + "): a different token (`" + t.type + "`, " + stringifyPosition({ start: t.start, end: t.end }) + ") is open"); throw new Error("Cannot close document, a token (`" + t.type + "`, " + stringifyPosition({ start: t.start, end: t.end }) + ") is still open"); } //#endregion export { fromMarkdown as t };