? state.options.clobberPrefix : "user-content-"; const id = String(node2.identifier).toUpperCase(); const safeId = normalizeUri(id.toLowerCase()); const index2 = state.footnoteOrder.indexOf(id); let counter; let reuseCounter = state.footnoteCounts.get(id); if (reuseCounter === void 0) { reuseCounter = 0; state.footnoteOrder.push(id); counter = state.footnoteOrder.length; } else { counter = index2 + 1; } reuseCounter += 1; state.footnoteCounts.set(id, reuseCounter); const link2 = { type: "element", tagName: "a", properties: { href: "#" + clobberPrefix + "fn-" + safeId, id: clobberPrefix + "fnref-" + safeId + (reuseCounter > 1 ? "-" + reuseCounter : ""), dataFootnoteRef: true, ariaDescribedBy: ["footnote-label"] }, children: [{ type: "text", value: String(counter) }] }; state.patch(node2, link2); const sup = { type: "element", tagName: "sup", properties: {}, children: [link2] }; state.patch(node2, sup); return state.applyData(node2, sup); } // node_modules/mdast-util-to-hast/lib/handlers/heading.js function heading(state, node2) { const result = { type: "element", tagName: "h" + node2.depth, properties: {}, children: state.all(node2) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/html.js function html3(state, node2) { if (state.options.allowDangerousHtml) { const result = { type: "raw", value: node2.value }; state.patch(node2, result); return state.applyData(node2, result); } return void 0; } // node_modules/mdast-util-to-hast/lib/revert.js function revert(state, node2) { const subtype = node2.referenceType; let suffix = "]"; if (subtype === "collapsed") { suffix += "[]"; } else if (subtype === "full") { suffix += "[" + (node2.label || node2.identifier) + "]"; } if (node2.type === "imageReference") { return [{ type: "text", value: "![" + node2.alt + suffix }]; } const contents = state.all(node2); 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; } // node_modules/mdast-util-to-hast/lib/handlers/image-reference.js function imageReference(state, node2) { const id = String(node2.identifier).toUpperCase(); const definition2 = state.definitionById.get(id); if (!definition2) { return revert(state, node2); } const properties = { src: normalizeUri(definition2.url || ""), alt: node2.alt }; if (definition2.title !== null && definition2.title !== void 0) { properties.title = definition2.title; } const result = { type: "element", tagName: "img", properties, children: [] }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/image.js function image(state, node2) { const properties = { src: normalizeUri(node2.url) }; if (node2.alt !== null && node2.alt !== void 0) { properties.alt = node2.alt; } if (node2.title !== null && node2.title !== void 0) { properties.title = node2.title; } const result = { type: "element", tagName: "img", properties, children: [] }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/inline-code.js function inlineCode(state, node2) { const text5 = { type: "text", value: node2.value.replace(/\r?\n|\r/g, " ") }; state.patch(node2, text5); const result = { type: "element", tagName: "code", properties: {}, children: [text5] }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/link-reference.js function linkReference(state, node2) { const id = String(node2.identifier).toUpperCase(); const definition2 = state.definitionById.get(id); if (!definition2) { return revert(state, node2); } const properties = { href: normalizeUri(definition2.url || "") }; if (definition2.title !== null && definition2.title !== void 0) { properties.title = definition2.title; } const result = { type: "element", tagName: "a", properties, children: state.all(node2) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/link.js function link(state, node2) { const properties = { href: normalizeUri(node2.url) }; if (node2.title !== null && node2.title !== void 0) { properties.title = node2.title; } const result = { type: "element", tagName: "a", properties, children: state.all(node2) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/list-item.js function listItem(state, node2, parent) { const results = state.all(node2); const loose = parent ? listLoose(parent) : listItemLoose(node2); const properties = {}; const children = []; if (typeof node2.checked === "boolean") { const head = results[0]; let paragraph2; if (head && head.type === "element" && head.tagName === "p") { paragraph2 = head; } else { paragraph2 = { type: "element", tagName: "p", properties: {}, children: [] }; results.unshift(paragraph2); } if (paragraph2.children.length > 0) { paragraph2.children.unshift({ type: "text", value: " " }); } paragraph2.children.unshift({ type: "element", tagName: "input", properties: { type: "checkbox", checked: node2.checked, disabled: true }, children: [] }); properties.className = ["task-list-item"]; } let index2 = -1; while (++index2 < results.length) { const child = results[index2]; if (loose || index2 !== 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]; if (tail && (loose || tail.type !== "element" || tail.tagName !== "p")) { children.push({ type: "text", value: "\n" }); } const result = { type: "element", tagName: "li", properties, children }; state.patch(node2, result); return state.applyData(node2, result); } function listLoose(node2) { let loose = false; if (node2.type === "list") { loose = node2.spread || false; const children = node2.children; let index2 = -1; while (!loose && ++index2 < children.length) { loose = listItemLoose(children[index2]); } } return loose; } function listItemLoose(node2) { const spread = node2.spread; return spread === null || spread === void 0 ? node2.children.length > 1 : spread; } // node_modules/mdast-util-to-hast/lib/handlers/list.js function list2(state, node2) { const properties = {}; const results = state.all(node2); let index2 = -1; if (typeof node2.start === "number" && node2.start !== 1) { properties.start = node2.start; } while (++index2 < results.length) { const child = results[index2]; 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; } } const result = { type: "element", tagName: node2.ordered ? "ol" : "ul", properties, children: state.wrap(results, true) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/paragraph.js function paragraph(state, node2) { const result = { type: "element", tagName: "p", properties: {}, children: state.all(node2) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/root.js function root2(state, node2) { const result = { type: "root", children: state.wrap(state.all(node2)) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/strong.js function strong(state, node2) { const result = { type: "element", tagName: "strong", properties: {}, children: state.all(node2) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/table.js function table(state, node2) { const rows = state.all(node2); const firstRow = rows.shift(); const tableContent = []; if (firstRow) { const head = { type: "element", tagName: "thead", properties: {}, children: state.wrap([firstRow], true) }; state.patch(node2.children[0], head); tableContent.push(head); } if (rows.length > 0) { const body = { type: "element", tagName: "tbody", properties: {}, children: state.wrap(rows, true) }; const start2 = pointStart(node2.children[1]); const end = pointEnd(node2.children[node2.children.length - 1]); if (start2 && end) body.position = { start: start2, end }; tableContent.push(body); } const result = { type: "element", tagName: "table", properties: {}, children: state.wrap(tableContent, true) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/table-row.js function tableRow(state, node2, parent) { const siblings = parent ? parent.children : void 0; const rowIndex = siblings ? siblings.indexOf(node2) : 1; const tagName = rowIndex === 0 ? "th" : "td"; const align = parent && parent.type === "table" ? parent.align : void 0; const length = align ? align.length : node2.children.length; let cellIndex = -1; const cells = []; while (++cellIndex < length) { const cell = node2.children[cellIndex]; const properties = {}; const alignValue = align ? align[cellIndex] : void 0; if (alignValue) { properties.align = alignValue; } let result2 = { type: "element", tagName, properties, children: [] }; if (cell) { result2.children = state.all(cell); state.patch(cell, result2); result2 = state.applyData(cell, result2); } cells.push(result2); } const result = { type: "element", tagName: "tr", properties: {}, children: state.wrap(cells, true) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/table-cell.js function tableCell(state, node2) { const result = { type: "element", tagName: "td", // Assume body cell. properties: {}, children: state.all(node2) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/trim-lines/index.js var tab = 9; var space = 32; function trimLines(value) { const source = String(value); const search2 = /\r?\n|\r/g; let match = search2.exec(source); let last = 0; const lines = []; while (match) { lines.push( trimLine(source.slice(last, match.index), last > 0, true), match[0] ); last = match.index + match[0].length; match = search2.exec(source); } lines.push(trimLine(source.slice(last), last > 0, false)); return lines.join(""); } function trimLine(value, start2, end) { let startIndex = 0; let endIndex = value.length; if (start2) { let code2 = value.codePointAt(startIndex); while (code2 === tab || code2 === space) { startIndex++; code2 = value.codePointAt(startIndex); } } if (end) { let code2 = value.codePointAt(endIndex - 1); while (code2 === tab || code2 === space) { endIndex--; code2 = value.codePointAt(endIndex - 1); } } return endIndex > startIndex ? value.slice(startIndex, endIndex) : ""; } // node_modules/mdast-util-to-hast/lib/handlers/text.js function text4(state, node2) { const result = { type: "text", value: trimLines(String(node2.value)) }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js function thematicBreak2(state, node2) { const result = { type: "element", tagName: "hr", properties: {}, children: [] }; state.patch(node2, result); return state.applyData(node2, result); } // node_modules/mdast-util-to-hast/lib/handlers/index.js var handlers = { blockquote, break: hardBreak, code, delete: strikethrough, emphasis, footnoteReference, heading, html: html3, imageReference, image, inlineCode, linkReference, link, listItem, list: list2, paragraph, // @ts-expect-error: root is different, but hard to type. root: root2, strong, table, tableCell, tableRow, text: text4, thematicBreak: thematicBreak2, toml: ignore, yaml: ignore, definition: ignore, footnoteDefinition: ignore }; function ignore() { return void 0; } // node_modules/@ungap/structured-clone/esm/types.js var VOID = -1; var PRIMITIVE = 0; var ARRAY = 1; var OBJECT = 2; var DATE = 3; var REGEXP = 4; var MAP = 5; var SET = 6; var ERROR = 7; var BIGINT = 8; // node_modules/@ungap/structured-clone/esm/deserialize.js var env = typeof self === "object" ? self : globalThis; var deserializer = ($, _) => { const as = (out, index2) => { $.set(index2, out); return out; }; const unpair = (index2) => { if ($.has(index2)) return $.get(index2); const [type, value] = _[index2]; switch (type) { case PRIMITIVE: case VOID: return as(value, index2); case ARRAY: { const arr = as([], index2); for (const index3 of value) arr.push(unpair(index3)); return arr; } case OBJECT: { const object = as({}, index2); for (const [key, index3] of value) object[unpair(key)] = unpair(index3); return object; } case DATE: return as(new Date(value), index2); case REGEXP: { const { source, flags } = value; return as(new RegExp(source, flags), index2); } case MAP: { const map = as(/* @__PURE__ */ new Map(), index2); for (const [key, index3] of value) map.set(unpair(key), unpair(index3)); return map; } case SET: { const set = as(/* @__PURE__ */ new Set(), index2); for (const index3 of value) set.add(unpair(index3)); return set; } case ERROR: { const { name: name2, message } = value; return as(new env[name2](message), index2); } case BIGINT: return as(BigInt(value), index2); case "BigInt": return as(Object(BigInt(value)), index2); case "ArrayBuffer": return as(new Uint8Array(value).buffer, value); case "DataView": { const { buffer } = new Uint8Array(value); return as(new DataView(buffer), value); } } return as(new env[type](value), index2); }; return unpair; }; var deserialize = (serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0); // node_modules/@ungap/structured-clone/esm/serialize.js var EMPTY = ""; var { toString: toString2 } = {}; var { keys } = Object; var typeOf = (value) => { const type = typeof value; if (type !== "object" || !value) return [PRIMITIVE, type]; const asString = toString2.call(value).slice(8, -1); switch (asString) { case "Array": return [ARRAY, EMPTY]; case "Object": return [OBJECT, EMPTY]; case "Date": return [DATE, EMPTY]; case "RegExp": return [REGEXP, EMPTY]; case "Map": return [MAP, EMPTY]; case "Set": return [SET, EMPTY]; case "DataView": return [ARRAY, asString]; } if (asString.includes("Array")) return [ARRAY, asString]; if (asString.includes("Error")) return [ERROR, asString]; return [OBJECT, asString]; }; var shouldSkip = ([TYPE, type]) => TYPE === PRIMITIVE && (type === "function" || type === "symbol"); var serializer = (strict, json, $, _) => { const as = (out, value) => { const index2 = _.push(out) - 1; $.set(value, index2); return index2; }; const pair = (value) => { if ($.has(value)) return $.get(value); let [TYPE, type] = typeOf(value); switch (TYPE) { case PRIMITIVE: { let entry = value; switch (type) { case "bigint": TYPE = BIGINT; entry = value.toString(); break; case "function": case "symbol": if (strict) throw new TypeError("unable to serialize " + type); entry = null; break; case "undefined": return as([VOID], value); } return as([TYPE, entry], value); } case ARRAY: { if (type) { let spread = value; if (type === "DataView") { spread = new Uint8Array(value.buffer); } else if (type === "ArrayBuffer") { spread = new Uint8Array(value); } return as([type, [...spread]], value); } const arr = []; const index2 = as([TYPE, arr], value); for (const entry of value) arr.push(pair(entry)); return index2; } case OBJECT: { if (type) { switch (type) { case "BigInt": return as([type, value.toString()], value); case "Boolean": case "Number": case "String": return as([type, value.valueOf()], value); } } if (json && "toJSON" in value) return pair(value.toJSON()); const entries = []; const index2 = as([TYPE, entries], value); for (const key of keys(value)) { if (strict || !shouldSkip(typeOf(value[key]))) entries.push([pair(key), pair(value[key])]); } return index2; } case DATE: return as([TYPE, value.toISOString()], value); case REGEXP: { const { source, flags } = value; return as([TYPE, { source, flags }], value); } case MAP: { const entries = []; const index2 = as([TYPE, entries], value); for (const [key, entry] of value) { if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry)))) entries.push([pair(key), pair(entry)]); } return index2; } case SET: { const entries = []; const index2 = as([TYPE, entries], value); for (const entry of value) { if (strict || !shouldSkip(typeOf(entry))) entries.push(pair(entry)); } return index2; } } const { message } = value; return as([TYPE, { name: type, message }], value); }; return pair; }; var serialize = (value, { json, lossy } = {}) => { const _ = []; return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _; }; // node_modules/@ungap/structured-clone/esm/index.js var esm_default = typeof structuredClone === "function" ? ( /* c8 ignore start */ (any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize(any, options)) : structuredClone(any) ) : (any, options) => deserialize(serialize(any, options)); // node_modules/mdast-util-to-hast/lib/footer.js function defaultFootnoteBackContent(_, rereferenceIndex) { const result = [{ type: "text", value: "↩" }]; if (rereferenceIndex > 1) { result.push({ type: "element", tagName: "sup", properties: {}, children: [{ type: "text", value: String(rereferenceIndex) }] }); } return result; } function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) { return "Back to reference " + (referenceIndex + 1) + (rereferenceIndex > 1 ? "-" + rereferenceIndex : ""); } function footer(state) { const clobberPrefix = typeof state.options.clobberPrefix === "string" ? state.options.clobberPrefix : "user-content-"; const footnoteBackContent = state.options.footnoteBackContent || defaultFootnoteBackContent; const footnoteBackLabel = state.options.footnoteBackLabel || defaultFootnoteBackLabel; const footnoteLabel = state.options.footnoteLabel || "Footnotes"; const footnoteLabelTagName = state.options.footnoteLabelTagName || "h2"; const footnoteLabelProperties = state.options.footnoteLabelProperties || { className: ["sr-only"] }; const listItems = []; let referenceIndex = -1; while (++referenceIndex < state.footnoteOrder.length) { const definition2 = state.footnoteById.get( state.footnoteOrder[referenceIndex] ); if (!definition2) { continue; } const content3 = state.all(definition2); const id = String(definition2.identifier).toUpperCase(); const safeId = normalizeUri(id.toLowerCase()); let rereferenceIndex = 0; const backReferences = []; const counts = state.footnoteCounts.get(id); while (counts !== void 0 && ++rereferenceIndex <= counts) { if (backReferences.length > 0) { backReferences.push({ type: "text", value: " " }); } let children = typeof footnoteBackContent === "string" ? footnoteBackContent : footnoteBackContent(referenceIndex, rereferenceIndex); if (typeof children === "string") { children = { type: "text", value: children }; } backReferences.push({ type: "element", tagName: "a", properties: { href: "#" + clobberPrefix + "fnref-" + safeId + (rereferenceIndex > 1 ? "-" + rereferenceIndex : ""), dataFootnoteBackref: "", ariaLabel: typeof footnoteBackLabel === "string" ? footnoteBackLabel : footnoteBackLabel(referenceIndex, rereferenceIndex), className: ["data-footnote-backref"] }, children: Array.isArray(children) ? children : [children] }); } const tail = content3[content3.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 { content3.push(...backReferences); } const listItem2 = { type: "element", tagName: "li", properties: { id: clobberPrefix + "fn-" + safeId }, children: state.wrap(content3, true) }; state.patch(definition2, listItem2); listItems.push(listItem2); } if (listItems.length === 0) { return; } return { type: "element", tagName: "section", properties: { dataFootnotes: true, className: ["footnotes"] }, children: [ { type: "element", tagName: footnoteLabelTagName, properties: { ...esm_default(footnoteLabelProperties), id: "footnote-label" }, children: [{ type: "text", value: footnoteLabel }] }, { type: "text", value: "\n" }, { type: "element", tagName: "ol", properties: {}, children: state.wrap(listItems, true) }, { type: "text", value: "\n" } ] }; } // node_modules/unist-util-is/lib/index.js var convert = ( // Note: overloads in JSDoc can’t yet use different `@template`s. /** * @type {( * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) & * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) & * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate) & * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) & * ((test?: Test) => Check) * )} */ /** * @param {Test} [test] * @returns {Check} */ function(test) { if (test === null || test === void 0) { return ok2; } if (typeof test === "function") { return castFactory(test); } if (typeof test === "object") { return Array.isArray(test) ? anyFactory(test) : propsFactory(test); } if (typeof test === "string") { return typeFactory(test); } throw new Error("Expected function, string, or object as test"); } ); function anyFactory(tests) { const checks2 = []; let index2 = -1; while (++index2 < tests.length) { checks2[index2] = convert(tests[index2]); } return castFactory(any); function any(...parameters) { let index3 = -1; while (++index3 < checks2.length) { if (checks2[index3].apply(this, parameters)) return true; } return false; } } function propsFactory(check) { const checkAsRecord = ( /** @type {Record} */ check ); return castFactory(all2); function all2(node2) { const nodeAsRecord = ( /** @type {Record} */ /** @type {unknown} */ node2 ); let key; for (key in check) { if (nodeAsRecord[key] !== checkAsRecord[key]) return false; } return true; } } function typeFactory(check) { return castFactory(type); function type(node2) { return node2 && node2.type === check; } } function castFactory(testFunction) { return check; function check(value, index2, parent) { return Boolean( looksLikeANode(value) && testFunction.call( this, value, typeof index2 === "number" ? index2 : void 0, parent || void 0 ) ); } } function ok2() { return true; } function looksLikeANode(value) { return value !== null && typeof value === "object" && "type" in value; } // node_modules/unist-util-visit-parents/lib/color.js function color(d) { return d; } // node_modules/unist-util-visit-parents/lib/index.js var empty2 = []; var CONTINUE = true; var EXIT = false; var SKIP = "skip"; function visitParents(tree, test, visitor, reverse) { let check; if (typeof test === "function" && typeof visitor !== "function") { reverse = visitor; visitor = test; } else { check = test; } const is2 = convert(check); const step = reverse ? -1 : 1; factory(tree, void 0, [])(); function factory(node2, index2, parents) { const value = ( /** @type {Record} */ node2 && typeof node2 === "object" ? node2 : {} ); if (typeof value.type === "string") { const name2 = ( // `hast` typeof value.tagName === "string" ? value.tagName : ( // `xast` typeof value.name === "string" ? value.name : void 0 ) ); Object.defineProperty(visit2, "name", { value: "node (" + color(node2.type + (name2 ? "<" + name2 + ">" : "")) + ")" }); } return visit2; function visit2() { let result = empty2; let subresult; let offset; let grandparents; if (!test || is2(node2, index2, parents[parents.length - 1] || void 0)) { result = toResult(visitor(node2, parents)); if (result[0] === EXIT) { return result; } } if ("children" in node2 && node2.children) { const nodeAsParent = ( /** @type {UnistParent} */ node2 ); if (nodeAsParent.children && result[0] !== SKIP) { offset = (reverse ? nodeAsParent.children.length : -1) + step; grandparents = parents.concat(nodeAsParent); while (offset > -1 && offset < nodeAsParent.children.length) { const child = nodeAsParent.children[offset]; subresult = factory(child, offset, grandparents)(); if (subresult[0] === EXIT) { return subresult; } offset = typeof subresult[1] === "number" ? subresult[1] : offset + step; } } } return result; } } } function toResult(value) { if (Array.isArray(value)) { return value; } if (typeof value === "number") { return [CONTINUE, value]; } return value === null || value === void 0 ? empty2 : [value]; } // node_modules/unist-util-visit/lib/index.js function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) { let reverse; let test; let visitor; if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") { test = void 0; visitor = testOrVisitor; reverse = visitorOrReverse; } else { test = testOrVisitor; visitor = visitorOrReverse; reverse = maybeReverse; } visitParents(tree, test, overload, reverse); function overload(node2, parents) { const parent = parents[parents.length - 1]; const index2 = parent ? parent.children.indexOf(node2) : void 0; return visitor(node2, index2, parent); } } // node_modules/mdast-util-to-hast/lib/state.js var own3 = {}.hasOwnProperty; var emptyOptions3 = {}; function createState(tree, options) { const settings = options || emptyOptions3; const definitionById = /* @__PURE__ */ new Map(); const footnoteById = /* @__PURE__ */ new Map(); const footnoteCounts = /* @__PURE__ */ new Map(); const handlers2 = { ...handlers, ...settings.handlers }; const state = { all: all2, applyData, definitionById, footnoteById, footnoteCounts, footnoteOrder: [], handlers: handlers2, one: one3, options: settings, patch, wrap }; visit(tree, function(node2) { if (node2.type === "definition" || node2.type === "footnoteDefinition") { const map = node2.type === "definition" ? definitionById : footnoteById; const id = String(node2.identifier).toUpperCase(); if (!map.has(id)) { map.set(id, node2); } } }); return state; function one3(node2, parent) { const type = node2.type; const handle = state.handlers[type]; if (own3.call(state.handlers, type) && handle) { return handle(state, node2, parent); } if (state.options.passThrough && state.options.passThrough.includes(type)) { if ("children" in node2) { const { children, ...shallow } = node2; const result = esm_default(shallow); result.children = state.all(node2); return result; } return esm_default(node2); } const unknown = state.options.unknownHandler || defaultUnknownHandler; return unknown(state, node2, parent); } function all2(parent) { const values2 = []; if ("children" in parent) { const nodes = parent.children; let index2 = -1; while (++index2 < nodes.length) { const result = state.one(nodes[index2], parent); if (result) { if (index2 && nodes[index2 - 1].type === "break") { if (!Array.isArray(result) && result.type === "text") { result.value = trimMarkdownSpaceStart(result.value); } if (!Array.isArray(result) && result.type === "element") { const head = result.children[0]; if (head && head.type === "text") { head.value = trimMarkdownSpaceStart(head.value); } } } if (Array.isArray(result)) { values2.push(...result); } else { values2.push(result); } } } } return values2; } } function patch(from, to) { if (from.position) to.position = position(from); } function applyData(from, to) { let result = to; if (from && from.data) { const hName = from.data.hName; const hChildren = from.data.hChildren; const hProperties = from.data.hProperties; if (typeof hName === "string") { if (result.type === "element") { result.tagName = hName; } else { const children = "children" in result ? result.children : [result]; result = { type: "element", tagName: hName, properties: {}, children }; } } if (result.type === "element" && hProperties) { Object.assign(result.properties, esm_default(hProperties)); } if ("children" in result && result.children && hChildren !== null && hChildren !== void 0) { result.children = hChildren; } } return result; } function defaultUnknownHandler(state, node2) { const data = node2.data || {}; const result = "value" in node2 && !(own3.call(data, "hProperties") || own3.call(data, "hChildren")) ? { type: "text", value: node2.value } : { type: "element", tagName: "div", properties: {}, children: state.all(node2) }; state.patch(node2, result); return state.applyData(node2, result); } function wrap(nodes, loose) { const result = []; let index2 = -1; if (loose) { result.push({ type: "text", value: "\n" }); } while (++index2 < nodes.length) { if (index2) result.push({ type: "text", value: "\n" }); result.push(nodes[index2]); } if (loose && nodes.length > 0) { result.push({ type: "text", value: "\n" }); } return result; } function trimMarkdownSpaceStart(value) { let index2 = 0; let code2 = value.charCodeAt(index2); while (code2 === 9 || code2 === 32) { index2++; code2 = value.charCodeAt(index2); } return value.slice(index2); } // node_modules/mdast-util-to-hast/lib/index.js function toHast(tree, options) { const state = createState(tree, options); const node2 = state.one(tree, void 0); const foot = footer(state); const result = Array.isArray(node2) ? { type: "root", children: node2 } : node2 || { type: "root", children: [] }; if (foot) { ok("children" in result); result.children.push({ type: "text", value: "\n" }, foot); } return result; } // node_modules/remark-rehype/lib/index.js function remarkRehype(destination, options) { if (destination && "run" in destination) { return async function(tree, file) { const hastTree = ( /** @type {HastRoot} */ toHast(tree, { file, ...options }) ); await destination.run(hastTree, file); }; } return function(tree, file) { return ( /** @type {HastRoot} */ toHast(tree, { file, ...destination || options }) ); }; } // node_modules/bail/index.js function bail(error) { if (error) { throw error; } } // node_modules/unified/lib/index.js var import_extend = __toESM(require_extend(), 1); // node_modules/is-plain-obj/index.js function isPlainObject(value) { if (typeof value !== "object" || value === null) { return false; } const prototype = Object.getPrototypeOf(value); return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value); } // node_modules/trough/lib/index.js function trough() { const fns = []; const pipeline = { run, use }; return pipeline; function run(...values2) { let middlewareIndex = -1; const callback = values2.pop(); if (typeof callback !== "function") { throw new TypeError("Expected function as last argument, not " + callback); } next(null, ...values2); function next(error, ...output) { const fn = fns[++middlewareIndex]; let index2 = -1; if (error) { callback(error); return; } while (++index2 < values2.length) { if (output[index2] === null || output[index2] === void 0) { output[index2] = values2[index2]; } } values2 = output; if (fn) { wrap2(fn, next)(...output); } else { callback(null, ...output); } } } function use(middelware) { if (typeof middelware !== "function") { throw new TypeError( "Expected `middelware` to be a function, not " + middelware ); } fns.push(middelware); return pipeline; } } function wrap2(middleware, callback) { let called; return wrapped; function wrapped(...parameters) { const fnExpectsCallback = middleware.length > parameters.length; let result; if (fnExpectsCallback) { parameters.push(done); } try { result = middleware.apply(this, parameters); } catch (error) { const exception = ( /** @type {Error} */ error ); if (fnExpectsCallback && called) { throw exception; } return done(exception); } if (!fnExpectsCallback) { if (result && result.then && typeof result.then === "function") { result.then(then, done); } else if (result instanceof Error) { done(result); } else { then(result); } } } function done(error, ...output) { if (!called) { called = true; callback(error, ...output); } } function then(value) { done(null, value); } } // node_modules/vfile/lib/minpath.browser.js var minpath = { basename, dirname, extname, join, sep: "/" }; function basename(path, extname2) { if (extname2 !== void 0 && typeof extname2 !== "string") { throw new TypeError('"ext" argument must be a string'); } assertPath(path); let start2 = 0; let end = -1; let index2 = path.length; let seenNonSlash; if (extname2 === void 0 || extname2.length === 0 || extname2.length > path.length) { while (index2--) { if (path.codePointAt(index2) === 47) { if (seenNonSlash) { start2 = index2 + 1; break; } } else if (end < 0) { seenNonSlash = true; end = index2 + 1; } } return end < 0 ? "" : path.slice(start2, end); } if (extname2 === path) { return ""; } let firstNonSlashEnd = -1; let extnameIndex = extname2.length - 1; while (index2--) { if (path.codePointAt(index2) === 47) { if (seenNonSlash) { start2 = index2 + 1; break; } } else { if (firstNonSlashEnd < 0) { seenNonSlash = true; firstNonSlashEnd = index2 + 1; } if (extnameIndex > -1) { if (path.codePointAt(index2) === extname2.codePointAt(extnameIndex--)) { if (extnameIndex < 0) { end = index2; } } else { extnameIndex = -1; end = firstNonSlashEnd; } } } } if (start2 === end) { end = firstNonSlashEnd; } else if (end < 0) { end = path.length; } return path.slice(start2, end); } function dirname(path) { assertPath(path); if (path.length === 0) { return "."; } let end = -1; let index2 = path.length; let unmatchedSlash; while (--index2) { if (path.codePointAt(index2) === 47) { if (unmatchedSlash) { end = index2; break; } } else if (!unmatchedSlash) { unmatchedSlash = true; } } return end < 0 ? path.codePointAt(0) === 47 ? "/" : "." : end === 1 && path.codePointAt(0) === 47 ? "//" : path.slice(0, end); } function extname(path) { assertPath(path); let index2 = path.length; let end = -1; let startPart = 0; let startDot = -1; let preDotState = 0; let unmatchedSlash; while (index2--) { const code2 = path.codePointAt(index2); if (code2 === 47) { if (unmatchedSlash) { startPart = index2 + 1; break; } continue; } if (end < 0) { unmatchedSlash = true; end = index2 + 1; } if (code2 === 46) { if (startDot < 0) { startDot = index2; } else if (preDotState !== 1) { preDotState = 1; } } else if (startDot > -1) { preDotState = -1; } } if (startDot < 0 || end < 0 || // We saw a non-dot character immediately before the dot. preDotState === 0 || // The (right-most) trimmed path component is exactly `..`. preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { return ""; } return path.slice(startDot, end); } function join(...segments) { let index2 = -1; let joined; while (++index2 < segments.length) { assertPath(segments[index2]); if (segments[index2]) { joined = joined === void 0 ? segments[index2] : joined + "/" + segments[index2]; } } return joined === void 0 ? "." : normalize2(joined); } function normalize2(path) { assertPath(path); const absolute = path.codePointAt(0) === 47; let value = normalizeString(path, !absolute); if (value.length === 0 && !absolute) { value = "."; } if (value.length > 0 && path.codePointAt(path.length - 1) === 47) { value += "/"; } return absolute ? "/" + value : value; } function normalizeString(path, allowAboveRoot) { let result = ""; let lastSegmentLength = 0; let lastSlash = -1; let dots = 0; let index2 = -1; let code2; let lastSlashIndex; while (++index2 <= path.length) { if (index2 < path.length) { code2 = path.codePointAt(index2); } else if (code2 === 47) { break; } else { code2 = 47; } if (code2 === 47) { if (lastSlash === index2 - 1 || dots === 1) { } else if (lastSlash !== index2 - 1 && dots === 2) { if (result.length < 2 || lastSegmentLength !== 2 || result.codePointAt(result.length - 1) !== 46 || result.codePointAt(result.length - 2) !== 46) { if (result.length > 2) { lastSlashIndex = result.lastIndexOf("/"); if (lastSlashIndex !== result.length - 1) { if (lastSlashIndex < 0) { result = ""; lastSegmentLength = 0; } else { result = result.slice(0, lastSlashIndex); lastSegmentLength = result.length - 1 - result.lastIndexOf("/"); } lastSlash = index2; dots = 0; continue; } } else if (result.length > 0) { result = ""; lastSegmentLength = 0; lastSlash = index2; dots = 0; continue; } } if (allowAboveRoot) { result = result.length > 0 ? result + "/.." : ".."; lastSegmentLength = 2; } } else { if (result.length > 0) { result += "/" + path.slice(lastSlash + 1, index2); } else { result = path.slice(lastSlash + 1, index2); } lastSegmentLength = index2 - lastSlash - 1; } lastSlash = index2; dots = 0; } else if (code2 === 46 && dots > -1) { dots++; } else { dots = -1; } } return result; } function assertPath(path) { if (typeof path !== "string") { throw new TypeError( "Path must be a string. Received " + JSON.stringify(path) ); } } // node_modules/vfile/lib/minproc.browser.js var minproc = { cwd }; function cwd() { return "/"; } // node_modules/vfile/lib/minurl.shared.js function isUrl(fileUrlOrPath) { return Boolean( fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && "href" in fileUrlOrPath && fileUrlOrPath.href && "protocol" in fileUrlOrPath && fileUrlOrPath.protocol && // @ts-expect-error: indexing is fine. fileUrlOrPath.auth === void 0 ); } // node_modules/vfile/lib/minurl.browser.js function urlToPath(path) { if (typeof path === "string") { path = new URL(path); } else if (!isUrl(path)) { const error = new TypeError( 'The "path" argument must be of type string or an instance of URL. Received `' + path + "`" ); error.code = "ERR_INVALID_ARG_TYPE"; throw error; } if (path.protocol !== "file:") { const error = new TypeError("The URL must be of scheme file"); error.code = "ERR_INVALID_URL_SCHEME"; throw error; } return getPathFromURLPosix(path); } function getPathFromURLPosix(url) { if (url.hostname !== "") { const error = new TypeError( 'File URL host must be "localhost" or empty on darwin' ); error.code = "ERR_INVALID_FILE_URL_HOST"; throw error; } const pathname = url.pathname; let index2 = -1; while (++index2 < pathname.length) { if (pathname.codePointAt(index2) === 37 && pathname.codePointAt(index2 + 1) === 50) { const third = pathname.codePointAt(index2 + 2); if (third === 70 || third === 102) { const error = new TypeError( "File URL path must not include encoded / characters" ); error.code = "ERR_INVALID_FILE_URL_PATH"; throw error; } } } return decodeURIComponent(pathname); } // node_modules/vfile/lib/index.js var order = ( /** @type {const} */ [ "history", "path", "basename", "stem", "extname", "dirname" ] ); var VFile = class { /** * Create a new virtual file. * * `options` is treated as: * * * `string` or `Uint8Array` — `{value: options}` * * `URL` — `{path: options}` * * `VFile` — shallow copies its data over to the new file * * `object` — all fields are shallow copied over to the new file * * Path related fields are set in the following order (least specific to * most specific): `history`, `path`, `basename`, `stem`, `extname`, * `dirname`. * * You cannot set `dirname` or `extname` without setting either `history`, * `path`, `basename`, or `stem` too. * * @param {Compatible | null | undefined} [value] * File value. * @returns * New instance. */ constructor(value) { let options; if (!value) { options = {}; } else if (isUrl(value)) { options = { path: value }; } else if (typeof value === "string" || isUint8Array(value)) { options = { value }; } else { options = value; } this.cwd = "cwd" in options ? "" : minproc.cwd(); this.data = {}; this.history = []; this.messages = []; this.value; this.map; this.result; this.stored; let index2 = -1; while (++index2 < order.length) { const field2 = order[index2]; if (field2 in options && options[field2] !== void 0 && options[field2] !== null) { this[field2] = field2 === "history" ? [...options[field2]] : options[field2]; } } let field; for (field in options) { if (!order.includes(field)) { this[field] = options[field]; } } } /** * Get the basename (including extname) (example: `'index.min.js'`). * * @returns {string | undefined} * Basename. */ get basename() { return typeof this.path === "string" ? minpath.basename(this.path) : void 0; } /** * Set basename (including extname) (`'index.min.js'`). * * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` * on windows). * Cannot be nullified (use `file.path = file.dirname` instead). * * @param {string} basename * Basename. * @returns {undefined} * Nothing. */ set basename(basename2) { assertNonEmpty(basename2, "basename"); assertPart(basename2, "basename"); this.path = minpath.join(this.dirname || "", basename2); } /** * Get the parent path (example: `'~'`). * * @returns {string | undefined} * Dirname. */ get dirname() { return typeof this.path === "string" ? minpath.dirname(this.path) : void 0; } /** * Set the parent path (example: `'~'`). * * Cannot be set if there’s no `path` yet. * * @param {string | undefined} dirname * Dirname. * @returns {undefined} * Nothing. */ set dirname(dirname2) { assertPath2(this.basename, "dirname"); this.path = minpath.join(dirname2 || "", this.basename); } /** * Get the extname (including dot) (example: `'.js'`). * * @returns {string | undefined} * Extname. */ get extname() { return typeof this.path === "string" ? minpath.extname(this.path) : void 0; } /** * Set the extname (including dot) (example: `'.js'`). * * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` * on windows). * Cannot be set if there’s no `path` yet. * * @param {string | undefined} extname * Extname. * @returns {undefined} * Nothing. */ set extname(extname2) { assertPart(extname2, "extname"); assertPath2(this.dirname, "extname"); if (extname2) { if (extname2.codePointAt(0) !== 46) { throw new Error("`extname` must start with `.`"); } if (extname2.includes(".", 1)) { throw new Error("`extname` cannot contain multiple dots"); } } this.path = minpath.join(this.dirname, this.stem + (extname2 || "")); } /** * Get the full path (example: `'~/index.min.js'`). * * @returns {string} * Path. */ get path() { return this.history[this.history.length - 1]; } /** * Set the full path (example: `'~/index.min.js'`). * * Cannot be nullified. * You can set a file URL (a `URL` object with a `file:` protocol) which will * be turned into a path with `url.fileURLToPath`. * * @param {URL | string} path * Path. * @returns {undefined} * Nothing. */ set path(path) { if (isUrl(path)) { path = urlToPath(path); } assertNonEmpty(path, "path"); if (this.path !== path) { this.history.push(path); } } /** * Get the stem (basename w/o extname) (example: `'index.min'`). * * @returns {string | undefined} * Stem. */ get stem() { return typeof this.path === "string" ? minpath.basename(this.path, this.extname) : void 0; } /** * Set the stem (basename w/o extname) (example: `'index.min'`). * * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` * on windows). * Cannot be nullified (use `file.path = file.dirname` instead). * * @param {string} stem * Stem. * @returns {undefined} * Nothing. */ set stem(stem) { assertNonEmpty(stem, "stem"); assertPart(stem, "stem"); this.path = minpath.join(this.dirname || "", stem + (this.extname || "")); } // Normal prototypal methods. /** * Create a fatal message for `reason` associated with the file. * * The `fatal` field of the message is set to `true` (error; file not usable) * and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {never} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {never} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns {never} * Never. * @throws {VFileMessage} * Message. */ fail(causeOrReason, optionsOrParentOrPlace, origin) { const message = this.message(causeOrReason, optionsOrParentOrPlace, origin); message.fatal = true; throw message; } /** * Create an info message for `reason` associated with the file. * * The `fatal` field of the message is set to `undefined` (info; change * likely not needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns {VFileMessage} * Message. */ info(causeOrReason, optionsOrParentOrPlace, origin) { const message = this.message(causeOrReason, optionsOrParentOrPlace, origin); message.fatal = void 0; return message; } /** * Create a message for `reason` associated with the file. * * The `fatal` field of the message is set to `false` (warning; change may be * needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns {VFileMessage} * Message. */ message(causeOrReason, optionsOrParentOrPlace, origin) { const message = new VFileMessage( // @ts-expect-error: the overloads are fine. causeOrReason, optionsOrParentOrPlace, origin ); if (this.path) { message.name = this.path + ":" + message.name; message.file = this.path; } message.fatal = false; this.messages.push(message); return message; } /** * Serialize the file. * * > **Note**: which encodings are supported depends on the engine. * > For info on Node.js, see: * > . * * @param {string | null | undefined} [encoding='utf8'] * Character encoding to understand `value` as when it’s a `Uint8Array` * (default: `'utf-8'`). * @returns {string} * Serialized file. */ toString(encoding) { if (this.value === void 0) { return ""; } if (typeof this.value === "string") { return this.value; } const decoder = new TextDecoder(encoding || void 0); return decoder.decode(this.value); } }; function assertPart(part, name2) { if (part && part.includes(minpath.sep)) { throw new Error( "`" + name2 + "` cannot be a path: did not expect `" + minpath.sep + "`" ); } } function assertNonEmpty(part, name2) { if (!part) { throw new Error("`" + name2 + "` cannot be empty"); } } function assertPath2(path, name2) { if (!path) { throw new Error("Setting `" + name2 + "` requires `path` to be set too"); } } function isUint8Array(value) { return Boolean( value && typeof value === "object" && "byteLength" in value && "byteOffset" in value ); } // node_modules/unified/lib/callable-instance.js var CallableInstance = ( /** * @type {new , Result>(property: string | symbol) => (...parameters: Parameters) => Result} */ /** @type {unknown} */ /** * @this {Function} * @param {string | symbol} property * @returns {(...parameters: Array) => unknown} */ function(property) { const self2 = this; const constr = self2.constructor; const proto = ( /** @type {Record} */ // Prototypes do exist. // type-coverage:ignore-next-line constr.prototype ); const value = proto[property]; const apply = function() { return value.apply(apply, arguments); }; Object.setPrototypeOf(apply, proto); return apply; } ); // node_modules/unified/lib/index.js var own4 = {}.hasOwnProperty; var Processor = class _Processor extends CallableInstance { /** * Create a processor. */ constructor() { super("copy"); this.Compiler = void 0; this.Parser = void 0; this.attachers = []; this.compiler = void 0; this.freezeIndex = -1; this.frozen = void 0; this.namespace = {}; this.parser = void 0; this.transformers = trough(); } /** * Copy a processor. * * @deprecated * This is a private internal method and should not be used. * @returns {Processor} * New *unfrozen* processor ({@linkcode Processor}) that is * configured to work the same as its ancestor. * When the descendant processor is configured in the future it does not * affect the ancestral processor. */ copy() { const destination = ( /** @type {Processor} */ new _Processor() ); let index2 = -1; while (++index2 < this.attachers.length) { const attacher = this.attachers[index2]; destination.use(...attacher); } destination.data((0, import_extend.default)(true, {}, this.namespace)); return destination; } /** * Configure the processor with info available to all plugins. * Information is stored in an object. * * Typically, options can be given to a specific plugin, but sometimes it * makes sense to have information shared with several plugins. * For example, a list of HTML elements that are self-closing, which is * needed during all phases. * * > **Note**: setting information cannot occur on *frozen* processors. * > Call the processor first to create a new unfrozen processor. * * > **Note**: to register custom data in TypeScript, augment the * > {@linkcode Data} interface. * * @example * This example show how to get and set info: * * ```js * import {unified} from 'unified' * * const processor = unified().data('alpha', 'bravo') * * processor.data('alpha') // => 'bravo' * * processor.data() // => {alpha: 'bravo'} * * processor.data({charlie: 'delta'}) * * processor.data() // => {charlie: 'delta'} * ``` * * @template {keyof Data} Key * * @overload * @returns {Data} * * @overload * @param {Data} dataset * @returns {Processor} * * @overload * @param {Key} key * @returns {Data[Key]} * * @overload * @param {Key} key * @param {Data[Key]} value * @returns {Processor} * * @param {Data | Key} [key] * Key to get or set, or entire dataset to set, or nothing to get the * entire dataset (optional). * @param {Data[Key]} [value] * Value to set (optional). * @returns {unknown} * The current processor when setting, the value at `key` when getting, or * the entire dataset when getting without key. */ data(key, value) { if (typeof key === "string") { if (arguments.length === 2) { assertUnfrozen("data", this.frozen); this.namespace[key] = value; return this; } return own4.call(this.namespace, key) && this.namespace[key] || void 0; } if (key) { assertUnfrozen("data", this.frozen); this.namespace = key; return this; } return this.namespace; } /** * Freeze a processor. * * Frozen processors are meant to be extended and not to be configured * directly. * * When a processor is frozen it cannot be unfrozen. * New processors working the same way can be created by calling the * processor. * * It’s possible to freeze processors explicitly by calling `.freeze()`. * Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`, * `.stringify()`, `.process()`, or `.processSync()` are called. * * @returns {Processor} * The current processor. */ freeze() { if (this.frozen) { return this; } const self2 = ( /** @type {Processor} */ /** @type {unknown} */ this ); while (++this.freezeIndex < this.attachers.length) { const [attacher, ...options] = this.attachers[this.freezeIndex]; if (options[0] === false) { continue; } if (options[0] === true) { options[0] = void 0; } const transformer = attacher.call(self2, ...options); if (typeof transformer === "function") { this.transformers.use(transformer); } } this.frozen = true; this.freezeIndex = Number.POSITIVE_INFINITY