@intlayer/core 9.7.1 → 9.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  2. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +8 -2
  3. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  4. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  5. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  6. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  7. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  8. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  9. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  10. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  11. package/dist/cjs/interpreter/getContent/plugins.cjs +2 -2
  12. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  13. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  14. package/dist/cjs/messageFormat/resolveMessage.cjs +1 -1
  15. package/dist/cjs/messageFormat/resolveMessage.cjs.map +1 -1
  16. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  17. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  18. package/dist/cjs/utils/intl.cjs.map +1 -1
  19. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  20. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  21. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +8 -2
  22. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  23. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  24. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  25. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  26. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  27. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  28. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  29. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  30. package/dist/esm/interpreter/getContent/plugins.mjs +2 -2
  31. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  32. package/dist/esm/markdown/compiler.mjs.map +1 -1
  33. package/dist/esm/messageFormat/resolveMessage.mjs +1 -1
  34. package/dist/esm/messageFormat/resolveMessage.mjs.map +1 -1
  35. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  36. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  37. package/dist/esm/utils/intl.mjs.map +1 -1
  38. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  39. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  40. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +6 -0
  41. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -1
  42. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -1
  43. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +1 -1
  44. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -1
  45. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -1
  46. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +1 -1
  47. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +1 -1
  48. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +1 -1
  49. package/dist/types/index.d.ts +2 -2
  50. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  51. package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -1
  52. package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
  53. package/dist/types/utils/intl.d.ts +25 -0
  54. package/dist/types/utils/intl.d.ts.map +1 -1
  55. package/package.json +72 -72
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":["getNestingOptimized"],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n PluralContent,\n PluralContentState,\n SelectContent,\n TranslationContent,\n} from '../../transpiler';\nimport { DEFAULT_PLURAL_VARIABLE } from '../../transpiler/plural/plural';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getNesting as getNestingOptimized } from '../getNesting.optimized';\nimport { getPlural } from '../getPlural';\nimport { getSelect } from '../getSelect';\nimport { getTranslation } from '../getTranslation';\nimport {\n isInterpolableWrapperNode,\n transformInterpolableNode,\n} from '../interpolableNode';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * FALLBACK PLUGIN\n *\n * Used to fallback a tree-shaken plugin\n * --------------------------------------------- */\n\nexport const fallbackPlugin: Plugins = {\n id: 'fallback-plugin',\n canHandle: () => false,\n transform: (node) => node,\n};\n\n/**\n * Whether a resolved branch still expects insertion values.\n *\n * Some renderers return callable nodes (Svelte components, Angular proxies)\n * exposing their content on `.value`: those are final and must not be called\n * with the values. A pending insertion either has no `.value` or a function\n * one.\n */\nconst isAwaitingValues = (\n branch: unknown\n): branch is (values: Record<string, unknown>) => unknown => {\n if (typeof branch !== 'function') return false;\n\n const { value } = branch as { value?: unknown };\n\n return value === undefined || typeof value === 'function';\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.TRANSLATION]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins =>\n process.env.INTLAYER_NODE_TYPE_TRANSLATION === 'false'\n ? fallbackPlugin\n : {\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n // Resolve on the raw content first: only the displayed locale (and\n // the fallback keys it lacks) is ever transformed\n const content = getTranslation(\n node[NodeTypes.TRANSLATION] ?? {},\n locale,\n fallback\n );\n\n return deepTransformNode(content, {\n ...props,\n children: content,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.TRANSLATION, key: locale } as KeyPath,\n ],\n });\n },\n };\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.ENUMERATION]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[typeof NodeTypes.ENUMERATION][keyof T[typeof NodeTypes.ENUMERATION]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_ENUMERATION === 'false'\n ? fallbackPlugin\n : {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.ENUMERATION,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const original = node[NodeTypes.ENUMERATION];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as unknown as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.ENUMERATION, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * PLURAL PLUGIN\n * --------------------------------------------- */\n\n/**\n * A plural branch wrapped in an `insertion` node (auto-transformed\n * `{{count}}`) resolves to its inner content: the plural applies the values.\n */\ntype PluralBranch<Branch> = Branch extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer InsertionContent;\n fields: readonly string[];\n}\n ? InsertionContent\n : Branch;\n\n/** Value name a plural node selects on (`variable`, defaulting to `count`). */\ntype PluralVariable<T> = T extends { variable: infer Variable extends string }\n ? Variable\n : typeof DEFAULT_PLURAL_VARIABLE;\n\nexport type PluralCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.PLURAL]: object;\n}\n ? (\n arg:\n | number\n | ({ [Key in PluralVariable<T>]: number } & { [key: string]: unknown })\n ) => DeepTransformContent<\n PluralBranch<\n T[typeof NodeTypes.PLURAL][keyof T[typeof NodeTypes.PLURAL]]\n >,\n S\n >\n : never;\n\ntype SubResultFunction = (values: Record<string, string | number>) => string;\n\n/**\n * Plural plugin. Replaces node with a function that takes a count (or\n * `{ count, ...values }`) => string, picking the matching CLDR plural form\n * for the active locale and interpolating `{{count}}` (and other values).\n */\nexport const pluralPlugin = (locale?: LocalesValues): Plugins =>\n process.env.INTLAYER_NODE_TYPE_PLURAL === 'false'\n ? fallbackPlugin\n : {\n id: 'plural-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.PLURAL,\n transform: (node: PluralContent, props, deepTransformNode) => {\n const original = node[NodeTypes.PLURAL];\n const result: Record<string, any> = {};\n const variable = node.variable ?? DEFAULT_PLURAL_VARIABLE;\n // The plural interpolates its own branches. A string plugin from an\n // enclosing `insert()` or `plural()` would turn them into functions.\n const branchPlugins = (props.plugins ?? []).filter(\n (plugin) =>\n plugin.id !== 'insertion-string-plugin' &&\n plugin.id !== 'plural-string-plugin'\n );\n\n /** String plugin for plural. Replaces string node with a component that renders the insertion. */\n const pluralStringPlugin: Plugins = {\n id: 'plural-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // An `insertion` node below the plural (e.g. auto-transformed\n // `{{count}}` branches) already returns `(values) => …`. Leave its\n // strings untouched, or its template would become a function.\n const isInsideInsertion = subProps.keyPath\n .slice(props.keyPath.length)\n .some((keyPath) => keyPath.type === NodeTypes.INSERTION);\n\n if (isInsideInsertion) {\n return deepTransformNode(node, {\n ...subProps,\n plugins: subProps.plugins?.filter(\n (plugin) => plugin.id !== 'plural-string-plugin'\n ),\n });\n }\n\n // `html()`/`markdown()` nodes carry their `{{count}}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (values: { [k: string]: string | number }) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n branchPlugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...branchPlugins.filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (values: { [k: string]: string | number }) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: branchPlugins,\n children,\n });\n };\n },\n };\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.PLURAL, key } as KeyPath,\n ],\n plugins: [pluralStringPlugin, ...branchPlugins],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n const effectiveLocale = String(locale ?? props.locale ?? 'en');\n\n return (arg: number | { [key: string]: unknown }) => {\n const values: Record<string, unknown> =\n typeof arg === 'number' ? { [variable]: arg } : arg;\n const count = Number(values[variable]);\n\n const subResult: string | SubResultFunction = getPlural(\n result as PluralContent['plural'] as PluralContentState<string>,\n count,\n effectiveLocale\n );\n\n if (isAwaitingValues(subResult)) {\n return (subResult as SubResultFunction)(\n values as Record<string, string | number>\n );\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.CONDITION]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[typeof NodeTypes.CONDITION][keyof T[typeof NodeTypes.CONDITION]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_CONDITION === 'false'\n ? fallbackPlugin\n : {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.CONDITION,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const original = node[NodeTypes.CONDITION];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.CONDITION, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result as any, value);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I;\n fields: readonly string[];\n}\n ? (\n values: {\n [K in T['fields'][number]]: string | number;\n }\n ) => I extends string\n ? DeepTransformContent<string, S>\n : DeepTransformContent<I, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, result);\n },\n };\n\n/** Container nodes resolved by a selector call: `enu(3)`, `cond(true)`, … */\nconst selectorNodeTypes: string[] = [\n NodeTypes.ENUMERATION,\n NodeTypes.CONDITION,\n NodeTypes.PLURAL,\n NodeTypes.GENDER,\n NodeTypes.SELECT,\n];\n\n/**\n * Binds the values of an `insert()` to the selector node it wraps, returning\n * `(selector) => content`. Any other child result is returned unchanged.\n *\n * `areBranchesInterpolated` is set by frameworks that interpolate the branch\n * strings as soon as the values are known: the selected branch is then final\n * content and is never called with the values.\n */\nexport const bindInsertedValues = (\n children: unknown,\n result: unknown,\n values: Record<string, unknown>,\n areBranchesInterpolated = false\n): unknown => {\n const nodeType = (children as { nodeType?: string })?.nodeType;\n if (\n typeof result !== 'function' ||\n !nodeType ||\n !selectorNodeTypes.includes(nodeType)\n ) {\n return result;\n }\n\n const isCountSelector =\n nodeType === NodeTypes.PLURAL || nodeType === NodeTypes.ENUMERATION;\n\n return (selector: unknown) => {\n // Object selectors (`{ count }`, `{ value }`) carry the values along.\n if (typeof selector === 'object' && selector !== null) {\n return result({ ...values, ...selector });\n }\n\n // The count both selects the branch and fills `{{count}}`: the selector\n // wins over a `count` passed with the values.\n if (isCountSelector) {\n return result({ ...values, count: selector });\n }\n\n const selected = result(selector);\n\n return !areBranchesInterpolated && isAwaitingValues(selected)\n ? selected(values)\n : selected;\n };\n};\n\n/**\n * Shapes the result of `insert()` wrapping a selector node as\n * `(values) => (selector) => content`, so the values reach the selected\n * branch. Any other child result is returned unchanged.\n */\nexport const resolveInsertedSelector = (\n children: unknown,\n result: unknown\n): unknown =>\n typeof result === 'function' &&\n selectorNodeTypes.includes(\n (children as { nodeType?: string })?.nodeType ?? ''\n )\n ? (values: Record<string, unknown>) =>\n bindInsertedValues(children, result, values)\n : result;\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.GENDER]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<\n T[typeof NodeTypes.GENDER][keyof T[typeof NodeTypes.GENDER]],\n S\n >\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_GENDER === 'false'\n ? fallbackPlugin\n : {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.GENDER,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const original = node[NodeTypes.GENDER];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.GENDER, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result as any, value);\n },\n };\n\n/** ---------------------------------------------\n * SELECT PLUGIN\n * --------------------------------------------- */\n\n/**\n * Accepted selector for a select node.\n *\n * When the node declares a `fallback` case, any string is accepted (the\n * fallback covers the unmatched values) while the declared cases still\n * autocomplete. Without a `fallback`, only the declared cases are accepted.\n */\nexport type SelectSelector<States> = 'fallback' extends keyof States\n ? Exclude<keyof States & string, 'fallback'> | (string & {})\n : keyof States & string;\n\nexport type SelectCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.SELECT]: object;\n}\n ? (\n value:\n | SelectSelector<T[typeof NodeTypes.SELECT]>\n | { value: SelectSelector<T[typeof NodeTypes.SELECT]> }\n ) => DeepTransformContent<\n T[typeof NodeTypes.SELECT][keyof T[typeof NodeTypes.SELECT]],\n S\n >\n : never;\n\n/** Select plugin. Replaces node with a function that takes a string => content. */\nexport const selectPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_SELECT === 'false'\n ? fallbackPlugin\n : {\n id: 'select-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.SELECT,\n transform: (node: SelectContent, props, deepTransformNode) => {\n const original = node[NodeTypes.SELECT];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.SELECT, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: string | { value: string }) => {\n const value = typeof arg === 'string' ? arg : arg?.value;\n const subResult = getSelect(result, value);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.NESTED]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/**\n * Resolver used to turn a nested node into content.\n *\n * Optimized builds set `INTLAYER_OPTIMIZED_NESTING` so bundlers fold this to\n * the local resolver and dead-code-eliminate the registry-based one — together\n * with its `getIntlayer` import, and therefore the whole\n * `@intlayer/dictionaries-entry` module. That is what allows the dictionaries\n * entry to be emptied while `nest()` keeps working.\n */\nconst resolveNesting =\n process.env.INTLAYER_OPTIMIZED_NESTING === 'true'\n ? getNestingOptimized\n : getNesting;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins =>\n process.env.INTLAYER_NODE_TYPE_NESTED === 'false'\n ? fallbackPlugin\n : {\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeTypes.NESTED || node?.nodeType === 'n'),\n transform: (node: NestedContent, props) =>\n resolveNesting(\n node[NodeTypes.NESTED].dictionaryKey,\n node[NodeTypes.NESTED].path,\n {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }\n ),\n };\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.FILE]: string;\n content?: string;\n}\n ? DeepTransformContent<string, S>\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_FILE === 'false'\n ? fallbackPlugin\n : {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.FILE,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n };\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n /**\n * Dictionaries referenced through `nest()`, attached to the consuming\n * dictionary by the build optimization and threaded down by\n * `deepTransformNode`.\n *\n * Present only in optimized builds, where the global dictionary registry is\n * stripped and `getNesting` resolves from this map instead. See\n * `getNesting.optimized.ts`.\n */\n nestedDictionaries?: Record<string, unknown>;\n /**\n * Forces eager traversal of plain objects in `deepTransformNode`. By default\n * traversal is lazy (property getters), so callers that discard the returned\n * value never trigger plugins on nested nodes. Set this when running plugins\n * for their side effects only (e.g. missing-locale detection), or when most\n * of the content is read anyway: defining a getter per key, then redefining\n * it on first read, costs more than transforming the key outright.\n */\n eager?: boolean;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n plural: PluralCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n select: SelectCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T, S, L>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n plural: true;\n condition: true;\n insertion: true;\n gender: true;\n select: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S, L extends LocalesValues = DeclaredLocales> =\n T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> =\n IsAny<T> extends true\n ? T\n : CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L> extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin's transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoEA,MAAa,iBAA0B;CACrC,IAAI;CACJ,iBAAiB;CACjB,YAAY,SAAS;AACvB;;;;;;;;;AAUA,MAAM,oBACJ,WAC2D;CAC3D,IAAI,OAAO,WAAW,YAAY,OAAO;CAEzC,MAAM,EAAE,UAAU;CAElB,OAAO,UAAU,UAAa,OAAO,UAAU;AACjD;;AAmCA,MAAa,qBACX,QACA,aAEA,QAAQ,IAAI,mCAAmC,UAC3C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA0B,OAAO,sBAAsB;EAGjE,MAAM,UAAU,eACd,KAAK,UAAU,gBAAgB,CAAC,GAChC,QACA,QACF;EAEA,OAAO,kBAAkB,SAAS;GAChC,GAAG;GACH,UAAU;GACV,SAAS,CACP,GAAG,MAAM,SACT;IAAE,MAAM,UAAU;IAAa,KAAK;GAAO,CAC7C;EACF,CAAC;CACH;AACF;;AAmBN,MAAa,oBACX,QAAQ,IAAI,mCAAmC,U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,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAqB,OAAO,sBAAsB;EAC5D,MAAM,WAAW,KAAK,UAAU;EAChC,MAAM,SAA8B,CAAC;EAErC,KAAK,MAAM,OAAO,UAAU;GAC1B,MAAM,QAAQ,SAAS;GASvB,OAAO,OAAO,kBAAkB,OAAO;IAPrC,GAAG;IACH,UAAU;IACV,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM,UAAU;KAAQ;IAAI,CAChC;GAE8C,CAAC;EACnD;EAEA,QAAQ,QAAoC;GAC1C,MAAM,QAAQ,OAAO,QAAQ,WAAW,MAAM,KAAK;GACnD,MAAM,YAAY,UAAU,QAAQ,KAAK;GAEzC,IAAI,iBAAiB,SAAS,KAAK,OAAO,QAAQ,UAChD,OAAO,UAAU,GAAG;GAGtB,OAAO;EACT;CACF;AACF;;;;;;;;;;AA2BN,MAAM,iBACJ,QAAQ,IAAI,+BAA+B,SACvCA,eACA;;AAGN,MAAa,gBAAgB,WAC3B,QAAQ,IAAI,8BAA8B,UACtC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,aACf,MAAM,aAAa,UAAU,UAAU,MAAM,aAAa;CAC7D,YAAY,MAAqB,UAC/B,eACE,KAAK,UAAU,OAAO,CAAC,eACvB,KAAK,UAAU,OAAO,CAAC,MACvB;EACE,GAAG;EACH,QAAS,UAAU,MAAM;CAC3B,CACF;AACJ;;AAeN,MAAa,aACX,QAAQ,IAAI,4BAA4B,UACpC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAmB,OAAO,kBACpC,cAAc,KAAK,SAAS;EAC1B,GAAG;EACH,UAAU,KAAK;CACjB,CAAC;AACL"}
1
+ {"version":3,"file":"plugins.mjs","names":["getNestingOptimized"],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n PluralContent,\n PluralContentState,\n SelectContent,\n TranslationContent,\n} from '../../transpiler';\nimport { DEFAULT_PLURAL_VARIABLE } from '../../transpiler/plural/plural';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getNesting as getNestingOptimized } from '../getNesting.optimized';\nimport { getPlural } from '../getPlural';\nimport { getSelect } from '../getSelect';\nimport { getTranslation } from '../getTranslation';\nimport {\n isInterpolableWrapperNode,\n transformInterpolableNode,\n} from '../interpolableNode';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * FALLBACK PLUGIN\n *\n * Used to fallback a tree-shaken plugin\n * --------------------------------------------- */\n\nexport const fallbackPlugin: Plugins = {\n id: 'fallback-plugin',\n canHandle: () => false,\n transform: (node) => node,\n};\n\n/**\n * Whether a resolved branch still expects insertion values.\n *\n * Some renderers return callable nodes (Svelte components, Angular proxies)\n * exposing their content on `.value`: those are final and must not be called\n * with the values. A pending insertion either has no `.value` or a function\n * one.\n */\nconst isAwaitingValues = (\n branch: unknown\n): branch is (values: Record<string, unknown>) => unknown => {\n if (typeof branch !== 'function') return false;\n\n const { value } = branch as { value?: unknown };\n\n return value === undefined || typeof value === 'function';\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.TRANSLATION]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins =>\n process.env.INTLAYER_NODE_TYPE_TRANSLATION === 'false'\n ? fallbackPlugin\n : {\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n // Resolve on the raw content first: only the displayed locale (and\n // the fallback keys it lacks) is ever transformed\n const content = getTranslation(\n node[NodeTypes.TRANSLATION] ?? {},\n locale,\n fallback\n );\n\n return deepTransformNode(content, {\n ...props,\n children: content,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.TRANSLATION, key: locale } as KeyPath,\n ],\n });\n },\n };\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.ENUMERATION]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[typeof NodeTypes.ENUMERATION][keyof T[typeof NodeTypes.ENUMERATION]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_ENUMERATION === 'false'\n ? fallbackPlugin\n : {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.ENUMERATION,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const original = node[NodeTypes.ENUMERATION];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as unknown as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.ENUMERATION, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * PLURAL PLUGIN\n * --------------------------------------------- */\n\n/**\n * A plural branch wrapped in an `insertion` node (auto-transformed\n * `{{count}}`) resolves to its inner content: the plural applies the values.\n */\ntype PluralBranch<Branch> = Branch extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer InsertionContent;\n fields: readonly string[];\n}\n ? InsertionContent\n : Branch;\n\n/** Value name a plural node selects on (`variable`, defaulting to `count`). */\ntype PluralVariable<T> = T extends { variable: infer Variable extends string }\n ? Variable\n : typeof DEFAULT_PLURAL_VARIABLE;\n\nexport type PluralCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.PLURAL]: object;\n}\n ? (\n arg:\n | number\n | ({ [Key in PluralVariable<T>]: number } & { [key: string]: unknown })\n ) => DeepTransformContent<\n PluralBranch<\n T[typeof NodeTypes.PLURAL][keyof T[typeof NodeTypes.PLURAL]]\n >,\n S\n >\n : never;\n\ntype SubResultFunction = (values: Record<string, string | number>) => string;\n\n/**\n * Plural plugin. Replaces node with a function that takes a count (or\n * `{ count, ...values }`) => string, picking the matching CLDR plural form\n * for the active locale and interpolating `{{count}}` (and other values).\n */\nexport const pluralPlugin = (locale?: LocalesValues): Plugins =>\n process.env.INTLAYER_NODE_TYPE_PLURAL === 'false'\n ? fallbackPlugin\n : {\n id: 'plural-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.PLURAL,\n transform: (node: PluralContent, props, deepTransformNode) => {\n const original = node[NodeTypes.PLURAL];\n const result: Record<string, any> = {};\n const variable = node.variable ?? DEFAULT_PLURAL_VARIABLE;\n // The plural interpolates its own branches. A string plugin from an\n // enclosing `insert()` or `plural()` would turn them into functions.\n const branchPlugins = (props.plugins ?? []).filter(\n (plugin) =>\n plugin.id !== 'insertion-string-plugin' &&\n plugin.id !== 'plural-string-plugin'\n );\n\n /** String plugin for plural. Replaces string node with a component that renders the insertion. */\n const pluralStringPlugin: Plugins = {\n id: 'plural-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // An `insertion` node below the plural (e.g. auto-transformed\n // `{{count}}` branches) already returns `(values) => …`. Leave its\n // strings untouched, or its template would become a function.\n const isInsideInsertion = subProps.keyPath\n .slice(props.keyPath.length)\n .some((keyPath) => keyPath.type === NodeTypes.INSERTION);\n\n if (isInsideInsertion) {\n return deepTransformNode(node, {\n ...subProps,\n plugins: subProps.plugins?.filter(\n (plugin) => plugin.id !== 'plural-string-plugin'\n ),\n });\n }\n\n // `html()`/`markdown()` nodes carry their `{{count}}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (values: { [k: string]: string | number }) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n branchPlugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: branchPlugins.filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (values: { [k: string]: string | number }) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: branchPlugins,\n children,\n });\n };\n },\n };\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.PLURAL, key } as KeyPath,\n ],\n plugins: [pluralStringPlugin, ...branchPlugins],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n const effectiveLocale = String(locale ?? props.locale ?? 'en');\n\n return (arg: number | { [key: string]: unknown }) => {\n const values: Record<string, unknown> =\n typeof arg === 'number' ? { [variable]: arg } : arg;\n const count = Number(values[variable]);\n\n const subResult: string | SubResultFunction = getPlural(\n result as PluralContent['plural'] as PluralContentState<string>,\n count,\n effectiveLocale\n );\n\n if (isAwaitingValues(subResult)) {\n return (subResult as SubResultFunction)(\n values as Record<string, string | number>\n );\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.CONDITION]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[typeof NodeTypes.CONDITION][keyof T[typeof NodeTypes.CONDITION]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_CONDITION === 'false'\n ? fallbackPlugin\n : {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.CONDITION,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const original = node[NodeTypes.CONDITION];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.CONDITION, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result as any, value);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I;\n fields: readonly string[];\n}\n ? (values: {\n [K in T['fields'][number]]: string | number;\n }) => I extends string\n ? DeepTransformContent<string, S>\n : DeepTransformContent<I, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: (props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, result);\n },\n };\n\n/** Container nodes resolved by a selector call: `enu(3)`, `cond(true)`, … */\nconst selectorNodeTypes: string[] = [\n NodeTypes.ENUMERATION,\n NodeTypes.CONDITION,\n NodeTypes.PLURAL,\n NodeTypes.GENDER,\n NodeTypes.SELECT,\n];\n\n/**\n * Binds the values of an `insert()` to the selector node it wraps, returning\n * `(selector) => content`. Any other child result is returned unchanged.\n *\n * `areBranchesInterpolated` is set by frameworks that interpolate the branch\n * strings as soon as the values are known: the selected branch is then final\n * content and is never called with the values.\n */\nexport const bindInsertedValues = (\n children: unknown,\n result: unknown,\n values: Record<string, unknown>,\n areBranchesInterpolated = false\n): unknown => {\n const nodeType = (children as { nodeType?: string })?.nodeType;\n if (\n typeof result !== 'function' ||\n !nodeType ||\n !selectorNodeTypes.includes(nodeType)\n ) {\n return result;\n }\n\n const isCountSelector =\n nodeType === NodeTypes.PLURAL || nodeType === NodeTypes.ENUMERATION;\n\n return (selector: unknown) => {\n // Object selectors (`{ count }`, `{ value }`) carry the values along.\n if (typeof selector === 'object' && selector !== null) {\n return result({ ...values, ...selector });\n }\n\n // The count both selects the branch and fills `{{count}}`: the selector\n // wins over a `count` passed with the values.\n if (isCountSelector) {\n return result({ ...values, count: selector });\n }\n\n const selected = result(selector);\n\n return !areBranchesInterpolated && isAwaitingValues(selected)\n ? selected(values)\n : selected;\n };\n};\n\n/**\n * Shapes the result of `insert()` wrapping a selector node as\n * `(values) => (selector) => content`, so the values reach the selected\n * branch. Any other child result is returned unchanged.\n */\nexport const resolveInsertedSelector = (\n children: unknown,\n result: unknown\n): unknown =>\n typeof result === 'function' &&\n selectorNodeTypes.includes(\n (children as { nodeType?: string })?.nodeType ?? ''\n )\n ? (values: Record<string, unknown>) =>\n bindInsertedValues(children, result, values)\n : result;\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.GENDER]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<\n T[typeof NodeTypes.GENDER][keyof T[typeof NodeTypes.GENDER]],\n S\n >\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_GENDER === 'false'\n ? fallbackPlugin\n : {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.GENDER,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const original = node[NodeTypes.GENDER];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.GENDER, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result as any, value);\n },\n };\n\n/** ---------------------------------------------\n * SELECT PLUGIN\n * --------------------------------------------- */\n\n/**\n * Accepted selector for a select node.\n *\n * When the node declares a `fallback` case, any string is accepted (the\n * fallback covers the unmatched values) while the declared cases still\n * autocomplete. Without a `fallback`, only the declared cases are accepted.\n */\nexport type SelectSelector<States> = 'fallback' extends keyof States\n ? Exclude<keyof States & string, 'fallback'> | (string & {})\n : keyof States & string;\n\nexport type SelectCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.SELECT]: object;\n}\n ? (\n value:\n | SelectSelector<T[typeof NodeTypes.SELECT]>\n | { value: SelectSelector<T[typeof NodeTypes.SELECT]> }\n ) => DeepTransformContent<\n T[typeof NodeTypes.SELECT][keyof T[typeof NodeTypes.SELECT]],\n S\n >\n : never;\n\n/** Select plugin. Replaces node with a function that takes a string => content. */\nexport const selectPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_SELECT === 'false'\n ? fallbackPlugin\n : {\n id: 'select-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.SELECT,\n transform: (node: SelectContent, props, deepTransformNode) => {\n const original = node[NodeTypes.SELECT];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.SELECT, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: string | { value: string }) => {\n const value = typeof arg === 'string' ? arg : arg?.value;\n const subResult = getSelect(result, value);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.NESTED]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/**\n * Resolver used to turn a nested node into content.\n *\n * Optimized builds set `INTLAYER_OPTIMIZED_NESTING` so bundlers fold this to\n * the local resolver and dead-code-eliminate the registry-based one — together\n * with its `getIntlayer` import, and therefore the whole\n * `@intlayer/dictionaries-entry` module. That is what allows the dictionaries\n * entry to be emptied while `nest()` keeps working.\n */\nconst resolveNesting =\n process.env.INTLAYER_OPTIMIZED_NESTING === 'true'\n ? getNestingOptimized\n : getNesting;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins =>\n process.env.INTLAYER_NODE_TYPE_NESTED === 'false'\n ? fallbackPlugin\n : {\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeTypes.NESTED || node?.nodeType === 'n'),\n transform: (node: NestedContent, props) =>\n resolveNesting(\n node[NodeTypes.NESTED].dictionaryKey,\n node[NodeTypes.NESTED].path,\n {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }\n ),\n };\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.FILE]: string;\n content?: string;\n}\n ? DeepTransformContent<string, S>\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_FILE === 'false'\n ? fallbackPlugin\n : {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.FILE,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n };\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n /**\n * Dictionaries referenced through `nest()`, attached to the consuming\n * dictionary by the build optimization and threaded down by\n * `deepTransformNode`.\n *\n * Present only in optimized builds, where the global dictionary registry is\n * stripped and `getNesting` resolves from this map instead. See\n * `getNesting.optimized.ts`.\n */\n nestedDictionaries?: Record<string, unknown>;\n /**\n * Forces eager traversal of plain objects in `deepTransformNode`. By default\n * traversal is lazy (property getters), so callers that discard the returned\n * value never trigger plugins on nested nodes. Set this when running plugins\n * for their side effects only (e.g. missing-locale detection), or when most\n * of the content is read anyway: defining a getter per key, then redefining\n * it on first read, costs more than transforming the key outright.\n */\n eager?: boolean;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n plural: PluralCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n select: SelectCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T, S, L>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n plural: true;\n condition: true;\n insertion: true;\n gender: true;\n select: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S, L extends LocalesValues = DeclaredLocales> =\n T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> =\n IsAny<T> extends true\n ? T\n : CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L> extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin's transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoEA,MAAa,iBAA0B;CACrC,IAAI;CACJ,iBAAiB;CACjB,YAAY,SAAS;AACvB;;;;;;;;;AAUA,MAAM,oBACJ,WAC2D;CAC3D,IAAI,OAAO,WAAW,YAAY,OAAO;CAEzC,MAAM,EAAE,UAAU;CAElB,OAAO,UAAU,UAAa,OAAO,UAAU;AACjD;;AAmCA,MAAa,qBACX,QACA,aAEA,QAAQ,IAAI,mCAAmC,UAC3C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA0B,OAAO,sBAAsB;EAGjE,MAAM,UAAU,eACd,KAAK,UAAU,gBAAgB,CAAC,GAChC,QACA,QACF;EAEA,OAAO,kBAAkB,SAAS;GAChC,GAAG;GACH,UAAU;GACV,SAAS,CACP,GAAG,MAAM,SACT;IAAE,MAAM,UAAU;IAAa,KAAK;GAAO,CAC7C;EACF,CAAC;CACH;AACF;;AAmBN,MAAa,oBACX,QAAQ,IAAI,mCAAmC,UAC3C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA0B,OAAO,sBAAsB;EACjE,MAAM,WAAW,KAAK,UAAU;EAChC,MAAM,SAA8B,CAAC;EAErC,KAAK,MAAM,OAAO,UAAU;GAC1B,MAAM,QAAQ,SAAS;GASvB,OAAO,OAAO,kBAAkB,OAAO;IAPrC,GAAG;IACH,UAAU;IACV,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM,UAAU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C,MAAM,QAAQ,OAAO,QAAQ,WAAW,MAAM,KAAK;GACnD,MAAM,YAAY,UAAU,QAAQ,KAAK;GAEzC,IAAI,iBAAiB,SAAS,KAAK,OAAO,QAAQ,UAChD,OAAO,UAAU,GAAG;GAGtB,OAAO;EACT;CACF;AACF;;;;;;;;;;AA2BN,MAAM,iBACJ,QAAQ,IAAI,+BAA+B,SACvCA,eACA;;AAGN,MAAa,gBAAgB,WAC3B,QAAQ,IAAI,8BAA8B,UACtC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,aACf,MAAM,aAAa,UAAU,UAAU,MAAM,aAAa;CAC7D,YAAY,MAAqB,UAC/B,eACE,KAAK,UAAU,OAAO,CAAC,eACvB,KAAK,UAAU,OAAO,CAAC,MACvB;EACE,GAAG;EACH,QAAS,UAAU,MAAM;CAC3B,CACF;AACJ;;AAeN,MAAa,aACX,QAAQ,IAAI,4BAA4B,UACpC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAmB,OAAO,kBACpC,cAAc,KAAK,SAAS;EAC1B,GAAG;EACH,UAAU,KAAK;CACjB,CAAC;AACL"}
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.mjs","names":["defaultSlugify","defaultSanitizer"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["import {\n ATTR_EXTRACTOR_R,\n ATTRIBUTE_NAME_START_R,\n ATTRIBUTE_TO_NODE_PROP_MAP,\n BLOCK_END_R,\n BLOCKQUOTE_ALERT_R,\n BLOCKQUOTE_R,\n BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,\n BREAK_LINE_R,\n BREAK_THEMATIC_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n CODE_INLINE_R,\n CONSECUTIVE_NEWLINE_R,\n DO_NOT_PROCESS_HTML_ELEMENTS,\n FOOTNOTE_R,\n FOOTNOTE_REFERENCE_R,\n FRONT_MATTER_R,\n GFM_TASK_R,\n HEADING_ATX_COMPLIANT_R,\n HEADING_R,\n HEADING_SETEXT_R,\n HTML_CHAR_CODE_R,\n HTML_COMMENT_R,\n HTML_LEFT_TRIM_AMOUNT_R,\n LINK_AUTOLINK_BARE_URL_R,\n LINK_AUTOLINK_R,\n type ListType,\n NAMED_CODES_TO_UNICODE,\n NP_TABLE_R,\n ORDERED,\n ORDERED_LIST_ITEM_PREFIX_R,\n ORDERED_LIST_ITEM_R,\n ORDERED_LIST_R,\n PARAGRAPH_R,\n Priority,\n REFERENCE_IMAGE_OR_LINK,\n REFERENCE_IMAGE_R,\n REFERENCE_LINK_R,\n type RuleScopeValue,\n RuleType,\n SCOPE_BLOCK,\n SCOPE_BOTH,\n SCOPE_INLINE,\n SHORTCODE_R,\n SHOULD_RENDER_AS_BLOCK_R,\n TEXT_BOLD_R,\n TEXT_EMPHASIZED_R,\n TEXT_ESCAPED_R,\n TEXT_MARKED_R,\n TEXT_STRIKETHROUGHED_R,\n TRIM_STARTING_NEWLINES,\n UNORDERED,\n UNORDERED_LIST_ITEM_PREFIX_R,\n UNORDERED_LIST_ITEM_R,\n UNORDERED_LIST_R,\n} from './constants';\nimport {\n matchCustomComponent,\n matchHtmlBlockElement,\n matchSelfClosingElement,\n startsWithCustomComponent,\n startsWithElement,\n startsWithHtmlBlockElement,\n startsWithSelfClosingElement,\n} from './elementScanner';\nimport { parserFor } from './parser';\nimport { createRenderer, renderFor } from './renderer';\nimport type {\n CompileOptions,\n ComponentOverrides as ComponentDefinition,\n HeadingNode,\n HTMLTag,\n MarkdownContext,\n MarkdownOptions,\n MarkdownRuntime,\n OrderedListNode,\n ParseState,\n Rule,\n Rules,\n TableNode,\n UnorderedListNode,\n} from './types';\nimport {\n allowInline,\n anyScopeRegex,\n attributeValueToNodePropValue,\n type BlockSyntaxProbe,\n blockRegex,\n captureNothing,\n cx,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n get,\n inlineRegex,\n normalizeAttributeKey,\n parseBlock,\n parseCaptureInline,\n parseInline,\n parseSimpleInline,\n parseTableAlign,\n parseTableCells,\n parseTableRow,\n renderNothing,\n simpleInlineRegex,\n some,\n startsWith,\n trimEnd,\n trimLeadingWhitespaceOutsideFences,\n unescapeString,\n unquote,\n} from './utils';\n\ntype CreateElementFunction = (\n tag: any,\n props: Record<string, any> | null,\n ...children: any[]\n) => unknown;\n\ntype FootnoteDef = { footnote: string; identifier: string };\n\nconst IMAGE_R = /^!\\[(.*?)\\]\\( *((?:\\([^)]*\\)|[^() ])*) *\"?([^)\"]*)?\"?\\)/;\nconst LINK_INSIDE =\n '(?:\\\\[[^\\\\[\\\\]]*(?:\\\\[[^\\\\[\\\\]]*\\\\][^\\\\[\\\\]]*)*\\\\]|[^\\\\[\\\\]])*';\nconst LINK_HREF_AND_TITLE =\n '\\\\s*<?((?:\\\\([^)]*\\\\)|[^\\\\s\\\\\\\\]|\\\\\\\\.)*?)>?(?:\\\\s+[\\'\"]([\\\\s\\\\S]*?)[\\'\"])?\\\\s*';\nconst LINK_R = new RegExp(\n `^\\\\[(${LINK_INSIDE})\\\\]\\\\(${LINK_HREF_AND_TITLE}\\\\)`\n);\n\n/**\n * Case-insensitive `</tag>` probes, cached per tag name.\n *\n * The `htmlBlock` rule is qualified at every candidate position, and it used to\n * lowercase the whole remaining document to look its closing tag up — copying\n * the rest of the file on each probe.\n */\n/**\n * Builds a tag -> component resolver for one set of overrides.\n *\n * The case-insensitive fallback used to rescan every override key on each\n * element created; the lowercase index is now built once per document instead.\n */\nconst createTagResolver = (components: ComponentDefinition<any>) => {\n let lowercaseKeys: Map<string, string> | null = null;\n\n // With no overrides declared — the common case — every tag resolves to\n // itself, so the whole lookup is skipped.\n if (Object.keys(components).length === 0) return (tag: any): any => tag;\n\n const resolved = new Map<string, any>();\n\n return (tag: any): any => {\n if (typeof tag !== 'string') return tag;\n\n const memoized = resolved.get(tag);\n if (memoized !== undefined) return memoized;\n\n const override = get(components, tag);\n\n if (override) {\n resolved.set(tag, override);\n return override;\n }\n\n if (!lowercaseKeys) {\n lowercaseKeys = new Map();\n\n // Later keys win, matching `Array.prototype.find` on `Object.keys`\n // only when they are unique — so the first key of a given lowercase\n // form is kept, as before.\n for (const key of Object.keys(components)) {\n const lowercased = key.toLowerCase();\n\n if (!lowercaseKeys.has(lowercased)) lowercaseKeys.set(lowercased, key);\n }\n }\n\n const key = lowercaseKeys.get(tag.toLowerCase());\n const result = (key ? get(components, key) : undefined) || tag;\n\n resolved.set(tag, result);\n\n return result;\n };\n};\n\n/** Resolves the slugifier for a context, falling back to the built-in one. */\nconst createSlugger =\n (ctx: MarkdownContext<any>) =>\n (input: string): string =>\n ctx.slugify ? ctx.slugify(input, defaultSlugify) : defaultSlugify(input);\n\nconst createElementFactory = (\n ctx: MarkdownContext<any>,\n options: MarkdownOptions\n): CreateElementFunction => {\n const { runtime, components = {} } = ctx;\n const resolveTag = createTagResolver(components);\n const filteredTags = options.tagfilter\n ? new Set([\n 'title',\n 'textarea',\n 'style',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'script',\n 'plaintext',\n ])\n : null;\n\n /**\n * True when `props` can be handed to the runtime untouched: no `class`\n * alias to fold into `className`, and no empty value to drop. Rules build a\n * fresh literal for every element, so reusing it is safe, and it saves an\n * object per element — the single largest allocation in the render phase.\n */\n const needsPropsRewrite = (props: Record<string, any>): boolean => {\n if ('class' in props) return true;\n for (const key in props) {\n const value = props[key];\n if (value === undefined || value === null) return true;\n }\n return false;\n };\n\n return (\n tag: any,\n props: Record<string, any> | null,\n ...children: any[]\n ): unknown => {\n const isStringTag = typeof tag === 'string';\n\n if (\n filteredTags &&\n isStringTag &&\n (filteredTags.has(tag) || filteredTags.has(tag.toLowerCase()))\n ) {\n return null;\n }\n\n let finalProps: Record<string, any>;\n\n if (!props) {\n finalProps = {};\n } else if (!needsPropsRewrite(props)) {\n finalProps = props;\n } else {\n const className = cx(props.className, props.class);\n const mergedProps: Record<string, any> = {};\n let classNameHandled = false;\n\n // Preserve attribute order while merging className\n for (const key in props) {\n const value = props[key];\n\n if (value === undefined || value === null) continue;\n\n if (key === 'className' || key === 'class') {\n if (!classNameHandled) {\n if (className) mergedProps.className = className;\n classNameHandled = true;\n }\n } else {\n mergedProps[key] = value;\n }\n }\n\n if (!classNameHandled && className) {\n mergedProps.className = className;\n }\n\n finalProps = mergedProps;\n }\n\n if (runtime.normalizeProps && isStringTag)\n finalProps = runtime.normalizeProps(tag as string, finalProps);\n\n const component = resolveTag(tag);\n return runtime.createElement(component, finalProps, ...children);\n };\n};\n\n/**\n * Footnote and reference tables belonging to the document currently being\n * parsed or rendered. Rules reach them through a ref so a rule set can outlive\n * a single document and be reused.\n */\ntype DocumentScope = {\n footnotes: FootnoteDef[];\n references: MarkdownReferences;\n slugCounts?: Map<string, number>;\n};\n\ntype DocumentScopeRef = { current: DocumentScope };\n\nconst createDocumentScope = (): DocumentScope => ({\n footnotes: [],\n references: {},\n slugCounts: new Map(),\n});\n\n/**\n * A cached rule set, together with the values it was built from. The signature\n * holds every input that changes the shape of the rules; anything else (the\n * markdown itself, the document scope) is free to vary between uses.\n */\ntype DocumentParser = ReturnType<typeof parserFor>;\ntype DocumentEmitter = ReturnType<typeof renderFor>;\n\ntype RuleSetCacheEntry = {\n /** The inputs this set was built from, compared field by field on lookup. */\n ctx: MarkdownContext<any>;\n options: MarkdownOptions;\n parseOnly: boolean;\n createElement: CreateElementFunction;\n scope: DocumentScopeRef;\n /**\n * Built with the rules, not per call. `parserFor` resolves precedence and\n * fills the first-character dispatch tables, and `renderFor` walks the rule\n * set — repeating either for every string was most of what compiling a\n * dictionary of short strings cost.\n */\n parse: DocumentParser;\n emit: DocumentEmitter;\n};\n\n/**\n * Small enough to scan linearly, large enough that an app mixing a few option\n * sets — say prose and a dictionary rendered with different components — keeps\n * hitting it.\n */\nconst RULE_SET_CACHE_LIMIT = 8;\n\nconst ruleSetCache: RuleSetCacheEntry[] = [];\n\n/**\n * Every input that changes how rules are built. Compared directly rather than\n * through a signature array, which would allocate on every compile.\n */\nconst builtFromSame = (\n entry: RuleSetCacheEntry,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n parseOnly: boolean\n): boolean =>\n entry.parseOnly === parseOnly &&\n entry.ctx.runtime === ctx.runtime &&\n entry.ctx.components === ctx.components &&\n entry.ctx.namedCodesToUnicode === ctx.namedCodesToUnicode &&\n entry.ctx.sanitizer === ctx.sanitizer &&\n entry.ctx.slugify === ctx.slugify &&\n entry.options.disableAutoLink === options.disableAutoLink &&\n entry.options.disableParsingRawHTML === options.disableParsingRawHTML &&\n entry.options.enforceAtxHeadings === options.enforceAtxHeadings &&\n entry.options.tagfilter === options.tagfilter &&\n entry.options.renderRule === options.renderRule;\n\n/**\n * Returns the rule set for these options, building it only when no cached set\n * was made from the same inputs.\n */\nexport const getRuleSet = (\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n parseOnly: boolean\n): RuleSetCacheEntry => {\n for (let index = 0; index < ruleSetCache.length; index++) {\n const entry = ruleSetCache[index]!;\n if (!builtFromSame(entry, ctx, options, parseOnly)) continue;\n\n // Most-recently-used first, so the hot option set stays at the front.\n if (index > 0) {\n ruleSetCache.splice(index, 1);\n ruleSetCache.unshift(entry);\n }\n return entry;\n }\n\n const scope: DocumentScopeRef = { current: createDocumentScope() };\n const createElement = parseOnly\n ? noopCreateElement\n : createElementFactory(ctx, options);\n const rules = createDocumentRules(createElement, ctx, options, scope);\n const entry: RuleSetCacheEntry = {\n ctx,\n options,\n parseOnly,\n createElement,\n scope,\n parse: parserFor(rules),\n emit: renderFor(createRenderer(rules, options.renderRule)),\n };\n\n ruleSetCache.unshift(entry);\n if (ruleSetCache.length > RULE_SET_CACHE_LIMIT) ruleSetCache.pop();\n\n return entry;\n};\n\n/**\n * Runs `operation` with `scope` installed as the current document, restoring\n * whatever was there before. The save/restore keeps a nested compile — a custom\n * component that renders markdown of its own — from clobbering its caller.\n */\nconst withDocumentScope = <TResult>(\n ref: DocumentScopeRef,\n scope: DocumentScope,\n operation: () => TResult\n): TResult => {\n const previous = ref.current;\n ref.current = scope;\n try {\n return operation();\n } finally {\n ref.current = previous;\n }\n};\n\nconst createRules = (\n createElement: CreateElementFunction,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n scope: DocumentScopeRef,\n attrStringToMap: (tag: HTMLTag, str: string) => Record<string, any> | null,\n containsBlockSyntax: (input: string) => boolean,\n nonParagraphBlockSyntaxes: BlockSyntaxProbe[]\n): Rules => {\n const slug = createSlugger(ctx);\n const sanitize = ctx.sanitizer ?? defaultSanitizer;\n const namedCodesToUnicode = ctx.namedCodesToUnicode\n ? { ...NAMED_CODES_TO_UNICODE, ...ctx.namedCodesToUnicode }\n : NAMED_CODES_TO_UNICODE;\n\n /**\n * Raw HTML blocks and custom components differ only in how their tag is\n * spelled: both trim the captured content, decide block or inline parsing\n * from it, and render the tag with its attributes. `rawHtml` adds the two\n * things only real HTML needs — the never-parse element list, and tracking\n * whether we are inside an anchor.\n */\n /**\n * Whether `source` opens an element at the start of a block line, allowing\n * the up-to-three-space indentation CommonMark grants to HTML blocks.\n *\n * The scanner already skips leading spaces, but the dispatch only handed it\n * sources starting with `<`. An indented ` <Tab>` inside a `<Tabs>` block\n * then fell through to the paragraph rule, which swallowed the opening tag\n * as inline HTML and lost every sibling that followed it.\n */\n const qualifiesPairedElement = (source: string, state: ParseState) => {\n if (source.charCodeAt(0) === 60 /* < */) return true;\n\n const isBlockLineStart =\n !state.inline && !state.simple && state.prevCaptureIndent !== undefined;\n\n if (!isBlockLineStart) return false;\n\n let index = 0;\n while (index < 3 && source.charCodeAt(index) === 32 /* space */) index++;\n\n return index > 0 && source.charCodeAt(index) === 60;\n };\n\n const pairedElementRule = (\n match: (source: string) => RegExpMatchArray | null,\n order: number,\n rawHtml: boolean,\n scope: RuleScopeValue = SCOPE_BOTH\n ): Rule<any> => ({\n _scope: scope,\n _firstChars: [60 /* < */, 32 /* space */],\n _qualify: qualifiesPairedElement,\n _match: anyScopeRegex(match),\n _order: order,\n _parse(capture, parse, state) {\n const content = capture[3] ?? '';\n const whitespace = content.match(HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? '';\n const trimmed = trimLeadingWhitespaceOutsideFences(content, whitespace);\n const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;\n const tagName = (capture[1] ?? '').trim();\n const lowercased = tagName.toLowerCase();\n const noInnerParse =\n rawHtml && DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(lowercased) !== -1;\n const tag = (noInnerParse ? lowercased : tagName) as HTMLTag;\n const ast: any = {\n attrs: attrStringToMap(tag, capture[2] ?? ''),\n noInnerParse,\n tag,\n };\n\n if (rawHtml) state.inAnchor = state.inAnchor || lowercased === 'a';\n\n if (noInnerParse) {\n ast.text = content;\n } else {\n const prevInHTML = state.inHTML;\n state.inHTML = true;\n ast.children = parseFunc(parse, trimmed, state);\n state.inHTML = prevInHTML;\n }\n\n if (rawHtml) state.inAnchor = false;\n\n return ast;\n },\n _render(node, output, state = {}) {\n return createElement(\n node.tag,\n { key: state.key, ...(node.attrs ?? {}) },\n node.text ?? (node.children ? output(node.children, state) : '')\n );\n },\n });\n\n const generateListRule = (\n type: ListType\n ): Rule<OrderedListNode | UnorderedListNode> => {\n const ordered = type === ORDERED;\n const LIST_R = ordered ? ORDERED_LIST_R : UNORDERED_LIST_R;\n const LIST_ITEM_R = ordered ? ORDERED_LIST_ITEM_R : UNORDERED_LIST_ITEM_R;\n const LIST_ITEM_PREFIX_R = ordered\n ? ORDERED_LIST_ITEM_PREFIX_R\n : UNORDERED_LIST_ITEM_PREFIX_R;\n\n const firstChars = ordered\n ? [32, 9, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57]\n : [32, 9, 42, 43, 45];\n\n return {\n _scope: SCOPE_BOTH,\n _firstChars: firstChars,\n _qualify: (source, state) =>\n state.prevCaptureIndent !== undefined &&\n Boolean(state.list ?? (!state.inline && !state.simple)) &&\n LIST_ITEM_PREFIX_R.test(source),\n _match: allowInline((source, state) => {\n const lineIndent = state.prevCaptureIndent;\n const isStartOfLine = lineIndent !== undefined;\n const isListAllowed = state.list ?? (!state.inline && !state.simple);\n\n if (isStartOfLine && isListAllowed) {\n const matchSource = lineIndent ? lineIndent + source : source;\n\n const match = LIST_R.exec(matchSource);\n if (!match) return null;\n\n if (lineIndent && match[0].startsWith(lineIndent)) {\n const adjusted = [...match] as RegExpMatchArray;\n adjusted[0] = match[0].slice(lineIndent.length);\n (adjusted as any).fullMatch = match[0];\n return adjusted;\n }\n\n return match;\n }\n\n return null;\n }),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const bullet = capture[2] ?? '';\n const startValue = ordered ? +bullet.slice(0, -1) : undefined;\n const fullSource = (capture as any).fullMatch ?? capture[0] ?? '';\n const items = fullSource\n .replace(BLOCK_END_R, '\\n')\n .match(LIST_ITEM_R) as string[];\n\n if (!items) return { items: [], ordered, start: startValue } as any;\n\n let lastItemWasAParagraph = false;\n\n const result = items.map((item, i) => {\n const prefixCapture = LIST_ITEM_PREFIX_R.exec(item);\n const space = prefixCapture ? prefixCapture[0].length : 0;\n const spaceRegex =\n space <= 8\n ? STRIP_INDENT_REGEXES[space]!\n : new RegExp(`^ {1,${space}}`, 'gm');\n // Slicing the prefix off is the same as stripping the item's own\n // indentation and then its bullet, because the bullet run is greedy:\n // the first line never keeps a leading space either way. It saves a\n // second pass of the prefix pattern over every item.\n const content = item.slice(space).replace(spaceRegex, '');\n const isLastItem = i === items.length - 1;\n const containsBlocks = content.indexOf('\\n\\n') !== -1;\n const thisItemIsAParagraph =\n containsBlocks || (isLastItem && lastItemWasAParagraph);\n\n lastItemWasAParagraph = thisItemIsAParagraph;\n\n const oldStateInline = state.inline;\n const oldStateList = state.list;\n state.list = true;\n\n let adjustedContent: string;\n\n if (thisItemIsAParagraph) {\n state.inline = false;\n adjustedContent = `${trimEnd(content)}\\n\\n`;\n } else {\n state.inline = true;\n adjustedContent = trimEnd(content);\n }\n\n const parsed = parse(adjustedContent, state);\n state.inline = oldStateInline;\n state.list = oldStateList;\n\n return parsed;\n });\n\n return { items: result, ordered, start: startValue };\n },\n _render(node, output, state = {}) {\n return createElement(\n ordered ? 'ol' : 'ul',\n { key: state.key, start: (node as OrderedListNode).start },\n ...node.items.map((item, i) =>\n createElement('li', { key: i }, output(item, state))\n )\n );\n },\n };\n };\n\n const matchParagraph = (\n source: string,\n state: ParseState\n ): RegExpMatchArray | null => {\n if (\n state.inline ||\n state.simple ||\n (state.inHTML &&\n source.indexOf('\\n\\n') === -1 &&\n !state.prevCaptureHasBlankLine)\n )\n return null;\n let start = 0;\n const srcLen = source.length;\n while (start < srcLen) {\n const newlineIndex = source.indexOf('\\n', start);\n const lineEnd = newlineIndex === -1 ? srcLen : newlineIndex;\n\n let p = start;\n while (\n p < lineEnd &&\n (source.charCodeAt(p) === 32 || source.charCodeAt(p) === 9)\n ) {\n p++;\n }\n\n if (p >= lineEnd) {\n break;\n }\n\n if (p - start >= 4 || source.charCodeAt(start) === 9) {\n break;\n }\n\n const ch = source.charCodeAt(p);\n const isDelim =\n ch === 62 || // >\n ch === 96 || // `\n ch === 126 || // ~\n ch === 35 || // #\n ch === 124 || // |\n ch === 42 || // *\n ch === 43 || // +\n ch === 45 || // -\n ch === 61 || // =\n ch === 60 || // <\n (ch >= 48 && ch <= 57); // 0-9\n\n if (isDelim) {\n const line = source.slice(\n start,\n newlineIndex === -1 ? undefined : newlineIndex + 1\n );\n\n if (some(nonParagraphBlockSyntaxes, line)) break;\n }\n\n if (newlineIndex === -1) {\n start = srcLen;\n break;\n }\n start = newlineIndex + 1;\n }\n const match = source.slice(0, start);\n // Align with original simple-markdown behavior: capture the whole match including newlines\n\n if (match === '') return null;\n const captured = trimEnd(match);\n\n if (captured === '') return null;\n\n return [match, undefined, captured] as unknown as RegExpMatchArray;\n };\n\n const rules: Rules = {\n [RuleType.blockQuote]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['>'],\n _match: blockRegex(BLOCKQUOTE_R),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const matchAlert = (capture[0] ?? '')\n .replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, '')\n .match(BLOCKQUOTE_ALERT_R);\n const alert = matchAlert?.[1];\n const content = matchAlert?.[2] ?? '';\n const hasNewline = content.indexOf('\\n') !== -1;\n const children = hasNewline\n ? parseBlock(parse, content, state)\n : parseInline(parse, content, state);\n\n return { alert, children };\n },\n _render(node, output, state = {}) {\n const props: Record<string, any> = { key: state.key };\n\n if (node.alert) {\n props.className = `markdown-alert-${slug(node.alert.toLowerCase())}`;\n node.children.unshift({\n attrs: {},\n children: [{ type: RuleType.text, text: node.alert }],\n noInnerParse: true,\n type: RuleType.htmlBlock,\n tag: 'header',\n } as any);\n }\n\n return createElement('blockquote', props, output(node.children, state));\n },\n },\n [RuleType.breakLine]: {\n _scope: SCOPE_BOTH,\n _qualify: [' '],\n _match: anyScopeRegex(BREAK_LINE_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render(_, __, state = {}) {\n return createElement('br', { key: state.key });\n },\n },\n [RuleType.breakThematic]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['--', '__', '**', '- ', '* ', '_ '],\n _match: blockRegex(BREAK_THEMATIC_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render(_, __, state = {}) {\n return createElement('hr', { key: state.key });\n },\n },\n [RuleType.codeBlock]: {\n _scope: SCOPE_BLOCK,\n _qualify: [' '],\n _match: blockRegex(CODE_BLOCK_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n type: RuleType.codeBlock,\n lang: undefined,\n text: unescapeString(\n trimEnd((capture[0] ?? '').replace(/^ {4}/gm, ''))\n ),\n };\n },\n _render(node, _, state = {}) {\n const attrs = { ...((node as any).attrs ?? {}) } as Record<string, any>;\n const langClass = node.lang ? `lang-${node.lang}` : 'lang-plaintext';\n attrs.className = attrs.className\n ? `${attrs.className} ${langClass}`\n : langClass;\n\n return createElement(\n 'pre',\n { key: state.key },\n createElement('code', attrs, node.text)\n );\n },\n },\n [RuleType.codeFenced]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['```', '~~~'],\n _match: blockRegex(CODE_BLOCK_FENCED_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n attrs: attrStringToMap('code', capture[3] ?? ''),\n lang: capture[2] || undefined,\n text: capture[4] ?? '',\n type: RuleType.codeBlock,\n };\n },\n },\n [RuleType.codeInline]: {\n _scope: SCOPE_INLINE,\n _firstChars: [96 /* ` */],\n _qualify: (source) =>\n source.charCodeAt(0) === 96 && source.indexOf('`', 1) !== -1,\n _match: simpleInlineRegex(CODE_INLINE_R),\n _order: Priority.LOW,\n _parse(capture) {\n return { text: unescapeString(capture[2] ?? '') };\n },\n _render(node, _, state = {}) {\n return createElement('code', { key: state.key }, node.text);\n },\n },\n [RuleType.footnote]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[^'],\n _match: blockRegex(FOOTNOTE_R),\n _order: Priority.MAX,\n _parse(capture) {\n scope.current.footnotes.push({\n footnote: capture[2] ?? '',\n identifier: capture[1] ?? '',\n });\n\n return {};\n },\n _render: renderNothing,\n },\n [RuleType.footnoteReference]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[^'],\n _match: inlineRegex(FOOTNOTE_REFERENCE_R),\n _order: Priority.HIGH,\n _parse(capture) {\n const text = capture[1] ?? '';\n return { target: `#${slug(text)}`, text };\n },\n _render(node, _, state = {}) {\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitize(node.target, 'a', 'href') ?? undefined,\n },\n createElement('sup', { key: state.key }, node.text)\n );\n },\n },\n [RuleType.gfmTask]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[ ]', '[x]'],\n _match: inlineRegex(GFM_TASK_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return { completed: (capture[1] ?? '').toLowerCase() === 'x' };\n },\n _render(node, _, state = {}) {\n return createElement('input', {\n checked: node.completed,\n key: state.key,\n readOnly: true,\n type: 'checkbox',\n });\n },\n },\n [RuleType.heading]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['#'],\n _match: blockRegex(\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R\n ),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const text = capture[2] ?? '';\n const baseSlug = slug(text) || 'section';\n const counts = scope.current.slugCounts;\n let id = baseSlug;\n\n if (counts) {\n const count = counts.get(baseSlug) ?? 0;\n counts.set(baseSlug, count + 1);\n if (count > 0) {\n id = `${baseSlug}-${count}`;\n }\n }\n\n return {\n children: parseInline(parse, text, state),\n id,\n level: (capture[1]?.length ?? 1) as HeadingNode['level'],\n };\n },\n _render(node, output, state = {}) {\n return createElement(\n `h${node.level}` as HTMLTag,\n { id: node.id, key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.headingSetext]: {\n _scope: SCOPE_BLOCK,\n _qualify: (source, state) => {\n if (\n state.prevCaptureIndent === undefined ||\n state.inline ||\n state.simple\n )\n return false;\n const nlIndex = source.indexOf('\\n');\n\n return (\n nlIndex > 0 &&\n nlIndex < source.length - 1 &&\n (source[nlIndex + 1] === '=' || source[nlIndex + 1] === '-')\n );\n },\n _match: blockRegex(HEADING_SETEXT_R),\n _order: Priority.MAX,\n _parse(capture, parse, state) {\n return {\n children: parseInline(parse, capture[1] ?? '', state),\n level: capture[2] === '=' ? 1 : 2,\n type: RuleType.heading,\n };\n },\n },\n [RuleType.htmlBlock]: pairedElementRule(\n // The rule is dropped outright when raw HTML is disabled, and the scanner\n matchHtmlBlockElement,\n Priority.HIGH,\n true,\n SCOPE_BOTH\n ),\n [RuleType.htmlComment]: {\n _scope: SCOPE_BOTH,\n _qualify: ['<!'],\n _match: anyScopeRegex(HTML_COMMENT_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render: renderNothing,\n },\n [RuleType.htmlSelfClosing]: {\n _scope: SCOPE_BOTH,\n _qualify: ['<'],\n _match: anyScopeRegex(matchSelfClosingElement),\n _order: Priority.HIGH,\n _parse(capture) {\n const tag = (capture[1] ?? '').trim() as HTMLTag;\n\n return { attrs: attrStringToMap(tag, capture[2] || ''), tag };\n },\n _render(node, _, state = {}) {\n return createElement(node.tag, {\n key: state.key,\n ...(node.attrs ?? {}),\n });\n },\n },\n [RuleType.customComponent]: pairedElementRule(\n matchCustomComponent,\n Priority.MAX,\n false,\n SCOPE_BOTH\n ),\n [RuleType.paragraph]: {\n _scope: SCOPE_BLOCK,\n _qualify: (_source, state) => !state.inline && !state.simple,\n _match: matchParagraph,\n _order: Priority.LOW,\n _parse: parseCaptureInline,\n _render(node, output, state = {}) {\n return createElement(\n 'p',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.image]: {\n _scope: SCOPE_INLINE,\n _firstChars: [33 /* ! */],\n _qualify: (source) =>\n source.startsWith('![') && source.indexOf('](') !== -1,\n _match: simpleInlineRegex(IMAGE_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return {\n alt: unescapeString(capture[1] ?? ''),\n target: unescapeString(capture[2] ?? ''),\n title: capture[3] ? unescapeString(capture[3]) : undefined,\n };\n },\n _render(node, _, state = {}) {\n return createElement('img', {\n key: state.key,\n alt: node.alt ?? undefined,\n title: node.title ?? undefined,\n src: sanitize(node.target, 'img', 'src') ?? undefined,\n });\n },\n },\n [RuleType.link]: {\n _scope: SCOPE_INLINE,\n _firstChars: [91 /* [ */],\n _qualify: (source) =>\n source.charCodeAt(0) === 91 && source.indexOf('](') !== -1,\n _match: inlineRegex(LINK_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1] ?? '', state),\n target: unescapeString(capture[2] ?? ''),\n title: capture[3] ? unescapeString(capture[3]) : undefined,\n };\n },\n _render(node, output, state = {}) {\n const sanitizedHref = sanitize(node.target, 'a', 'href');\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitizedHref ?? undefined,\n title: node.title ?? undefined,\n },\n output(node.children, state)\n );\n },\n },\n [RuleType.linkAngleBraceStyleDetector]: {\n _scope: SCOPE_INLINE,\n _qualify: ['<'],\n _match: inlineRegex(LINK_AUTOLINK_R),\n _order: Priority.MAX,\n _parse(capture) {\n let target = capture[1] ?? '';\n let isEmail = false;\n\n if (target.indexOf('@') !== -1 && target.indexOf('//') === -1) {\n isEmail = true;\n target = target.replace('mailto:', '');\n }\n\n return {\n children: [{ text: target, type: RuleType.text }],\n target: isEmail ? `mailto:${target}` : target,\n type: RuleType.link,\n };\n },\n },\n [RuleType.linkBareUrlDetector]: {\n _scope: SCOPE_INLINE,\n _firstChars: [104 /* h */],\n _qualify: (source, state) =>\n Boolean(\n state.inline &&\n !state.inAnchor &&\n !options.disableAutoLink &&\n (startsWith(source, 'http://') || startsWith(source, 'https://'))\n ),\n _match: inlineRegex(LINK_AUTOLINK_BARE_URL_R),\n _order: Priority.MAX,\n _parse(capture) {\n const url = capture[1] ?? '';\n return {\n children: [{ text: url, type: RuleType.text }],\n target: url,\n type: RuleType.link,\n };\n },\n },\n [RuleType.newlineCoalescer]: {\n _scope: SCOPE_BOTH,\n _qualify: ['\\n'],\n _match: blockRegex(CONSECUTIVE_NEWLINE_R),\n _order: Priority.LOW,\n _parse: captureNothing,\n _render() {\n return '\\n';\n },\n },\n [RuleType.orderedList]: generateListRule(ORDERED),\n [RuleType.unorderedList]: generateListRule(UNORDERED),\n [RuleType.ref]: {\n _scope: SCOPE_BOTH,\n _qualify: ['['],\n _match: anyScopeRegex(REFERENCE_IMAGE_OR_LINK),\n _order: Priority.MAX,\n _parse(capture) {\n const identifier = capture[1];\n\n if (identifier !== undefined) {\n scope.current.references[identifier] = {\n target: capture[2] ?? '',\n title: capture[4],\n };\n }\n\n return {};\n },\n _render: renderNothing,\n },\n [RuleType.refImage]: {\n _scope: SCOPE_INLINE,\n _firstChars: [33 /* ! */],\n _qualify: (source) =>\n source.startsWith('![') && source.indexOf('](') === -1,\n _match: simpleInlineRegex(REFERENCE_IMAGE_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n alt: capture[1] ? unescapeString(capture[1]) : undefined,\n ref: capture[2] ?? '',\n };\n },\n _render(node, _, state = {}) {\n const ref = scope.current.references[node.ref];\n\n if (!ref) return null;\n\n return createElement('img', {\n key: state.key,\n alt: node.alt,\n src: sanitize(ref.target, 'img', 'src') ?? undefined,\n title: ref.title,\n });\n },\n },\n [RuleType.refLink]: {\n _scope: SCOPE_INLINE,\n _firstChars: [91 /* [ */],\n _qualify: (source) => source.indexOf('](') === -1,\n _match: inlineRegex(REFERENCE_LINK_R),\n _order: Priority.MAX,\n _parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1] ?? '', state),\n fallbackChildren: capture[0] ?? '',\n ref: capture[2] ?? '',\n };\n },\n _render(node, output, state = {}) {\n const ref = scope.current.references[node.ref];\n\n if (!ref)\n return createElement(\n 'span',\n { key: state.key },\n node.fallbackChildren\n );\n\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitize(ref.target, 'a', 'href') ?? undefined,\n title: ref.title,\n },\n output(node.children, state)\n );\n },\n },\n [RuleType.table]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['|'],\n _match: blockRegex(NP_TABLE_R),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n state.inline = true;\n const align = capture[2] ? parseTableAlign(capture[2]) : [];\n const cells = capture[3]\n ? parseTableCells(capture[3], parse, state)\n : [];\n const header = parseTableRow(\n capture[1] ?? '',\n parse,\n state,\n !!cells.length\n );\n state.inline = false;\n\n return cells.length\n ? { align, cells, header, type: RuleType.table }\n : { children: header.flat(), type: RuleType.paragraph };\n },\n _render(node, output, state = {}) {\n const table = node as TableNode;\n const getStyle = (i: number) =>\n table.align[i] && table.align[i] !== 'left'\n ? { textAlign: table.align[i] }\n : {};\n\n return createElement(\n 'table',\n { key: state.key },\n createElement(\n 'thead',\n { key: 'thead' },\n createElement(\n 'tr',\n null,\n ...table.header.map((c, i) =>\n createElement(\n 'th',\n { key: i, style: getStyle(i) },\n output(c, state)\n )\n )\n )\n ),\n createElement(\n 'tbody',\n { key: 'tbody' },\n ...table.cells.map((row, i) =>\n createElement(\n 'tr',\n { key: i },\n ...row.map((c, j) =>\n createElement(\n 'td',\n { key: j, style: getStyle(j) },\n output(c, state)\n )\n )\n )\n )\n )\n );\n },\n },\n [RuleType.tableSeparator]: {\n _scope: SCOPE_INLINE,\n _qualify: ['|'],\n _match: (source, state) => (state.inTable ? /^\\|/.exec(source) : null),\n _order: Priority.HIGH,\n _parse() {\n return { type: RuleType.tableSeparator };\n },\n _render() {\n return ' | ';\n },\n },\n [RuleType.text]: {\n _scope: SCOPE_INLINE,\n _match: allowInline((source, _state) => {\n const len = source.length;\n if (source.charCodeAt(0) === 10 /* \\n */) {\n let j = 1;\n while (j < len && source.charCodeAt(j) === 32 /* space */) {\n j++;\n }\n if (\n j < len &&\n (source.charCodeAt(j) === 42 || // *\n source.charCodeAt(j) === 43 || // +\n source.charCodeAt(j) === 45 || // -\n (source.charCodeAt(j) >= 48 && source.charCodeAt(j) <= 57)) // 0-9\n ) {\n return [source.slice(0, j)] as unknown as RegExpMatchArray;\n }\n return ['\\n'] as unknown as RegExpMatchArray;\n }\n\n if (source.charCodeAt(0) === 58 /* : */) {\n const shortMatch = SHORTCODE_R.exec(source);\n if (shortMatch) return shortMatch;\n }\n // The first character always belongs to the run, whatever it is.\n TEXT_RUN_R.lastIndex = 1;\n TEXT_RUN_R.test(source);\n\n // Text is the most frequent capture by a wide margin, and its `_parse`\n // never re-enters the parser, so one scratch array serves every run\n // instead of allocating one per token.\n TEXT_CAPTURE[0] = source.slice(\n 0,\n trimHardBreak(source, TEXT_RUN_R.lastIndex)\n );\n\n return TEXT_CAPTURE;\n }),\n _order: Priority.MIN,\n _parse(capture) {\n const text = capture[0] ?? '';\n\n // Declaring `type` here — rather than letting the parser add it —\n // keeps every text node on one hidden class. `&` stops a run, so an\n // entity can only ever open one: testing the first character replaces\n // a scan of every character of every text node in the document.\n return {\n type: RuleType.text,\n text:\n text.charCodeAt(0) !== 38 /* & */\n ? text\n : text.replace(HTML_CHAR_CODE_R, (f, i) => {\n if (i.startsWith('#x'))\n return String.fromCharCode(parseInt(i.slice(2), 16));\n if (i.startsWith('#'))\n return String.fromCharCode(parseInt(i.slice(1), 10));\n return namedCodesToUnicode[i] || f;\n }),\n };\n },\n _render(node) {\n return node.text;\n },\n },\n [RuleType.textBolded]: {\n _scope: SCOPE_INLINE,\n _firstChars: [42 /* * */, 95 /* _ */],\n _qualify: (source) => {\n const c = source.charCodeAt(0);\n if (c === 42) {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 42 && source.indexOf('**', 2) !== -1;\n }\n if (c === 95) {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 95 && source.indexOf('__', 2) !== -1;\n }\n return false;\n },\n _match: simpleInlineRegex(TEXT_BOLD_R),\n _order: Priority.MED,\n _parse(capture, parse, state) {\n return { children: parse(capture[2] ?? '', state) };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'strong',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textEmphasized]: {\n _scope: SCOPE_INLINE,\n _firstChars: [42 /* * */, 95 /* _ */],\n _qualify: (source) => {\n const c = source.charCodeAt(0);\n const next = source.charCodeAt(1);\n if (next === 32 || next === 10 || next === 9) return false;\n return (\n (c === 42 && source.indexOf('*', 1) !== -1) ||\n (c === 95 && source.indexOf('_', 1) !== -1)\n );\n },\n _match: simpleInlineRegex(TEXT_EMPHASIZED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parse(capture[2] ?? '', state) };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'em',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textEscaped]: {\n _scope: SCOPE_INLINE,\n _qualify: ['\\\\'],\n _match: simpleInlineRegex(TEXT_ESCAPED_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return { text: capture[1] ?? '', type: RuleType.text };\n },\n },\n [RuleType.textMarked]: {\n _scope: SCOPE_INLINE,\n _firstChars: [61 /* = */],\n _qualify: (source) => {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 61 && source.indexOf('==', 2) !== -1;\n },\n _match: simpleInlineRegex(TEXT_MARKED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parseCaptureInline(capture, parse, state).children };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'mark',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textStrikethroughed]: {\n _scope: SCOPE_INLINE,\n _firstChars: [126 /* ~ */],\n _qualify: (source) => {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 126 && source.indexOf('~~', 2) !== -1;\n },\n _match: simpleInlineRegex(TEXT_STRIKETHROUGHED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parseCaptureInline(capture, parse, state).children };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'del',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n };\n\n return rules;\n};\n\n// Removed compilerCache completely to avoid issues with props changes not invalidating cache\n// const compilerCache = new Map<string, unknown>();\n\n/** Link/image reference definitions (`[id]: target \"title\"`) collected while parsing. */\nexport type MarkdownReferences = Record<\n string,\n { target: string; title?: string }\n>;\n\nexport type ParsedMarkdown = {\n ast: any[];\n footnotes: FootnoteDef[];\n /**\n * Reference definitions gathered during parsing. They must be carried over to\n * the render stage, since `refLink` / `refImage` nodes only store the\n * reference id and resolve their target at render time.\n */\n references: MarkdownReferences;\n inline: boolean;\n};\n\nconst STRIP_INDENT_REGEXES = [\n null,\n /^ {1,1}/gm,\n /^ {1,2}/gm,\n /^ {1,3}/gm,\n /^ {1,4}/gm,\n /^ {1,5}/gm,\n /^ {1,6}/gm,\n /^ {1,7}/gm,\n /^ {1,8}/gm,\n];\n\n/** Scratch capture reused by the text rule; see its `_match`. */\nconst TEXT_CAPTURE = [''] as unknown as RegExpMatchArray;\n\n/**\n * Consumes a run of plain text, stopping before the next character that could\n * open another inline rule or a bare URL. Anchored so `test` leaves the stop\n * offset in `lastIndex` without allocating a match array, and so the scan\n * itself runs in the regex engine.\n *\n * The bare-URL guard is an alternation branch rather than a per-character\n * lookahead, because a lookahead is re-evaluated at every offset while this\n * branch is only reached on an `h`. `&` stops a run purely so that an HTML\n * entity can only ever sit at offset 0 of a text node; adjacent text nodes are\n * merged by the parser, so the tree is unchanged.\n */\nconst TEXT_RUN_R = /(?:[^\\n&h!*:<=[\\\\_`~]+|h(?!ttp))*/y;\n\n/**\n * Pull a run's stop offset back before a hard line break it just swallowed.\n *\n * A run never contains a newline, so ` \\n` can only sit immediately before the\n * stop offset — which makes this O(1) check equivalent to the per-character\n * `(?! {2}\\n)` lookahead the run scanner used to carry.\n */\nconst trimHardBreak = (source: string, end: number): number =>\n end >= 3 &&\n source.charCodeAt(end) === 10 /* \\n */ &&\n source.charCodeAt(end - 1) === 32 /* space */ &&\n source.charCodeAt(end - 2) === 32\n ? end - 2\n : end;\n\nconst noopCreateElement: CreateElementFunction = (\n type,\n props,\n ...children\n) => ({\n children,\n props,\n type,\n});\n\n/**\n * Builds the rule set backing one document.\n *\n * Rules read the document's footnote and reference tables through `scope`\n * rather than closing over them, so one set serves every document sharing the\n * same options. Building this graph dominated the cost of compiling the many\n * short strings a dictionary holds; `getRuleSet` caches it.\n */\nconst createDocumentRules = (\n createElement: CreateElementFunction,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n scope: DocumentScopeRef\n): Rules => {\n const attrStringToMap = (\n tag: HTMLTag,\n str: string\n ): Record<string, any> | null => {\n if (!str?.trim()) return null;\n\n const attributes = str.match(ATTR_EXTRACTOR_R);\n\n if (!attributes) return null;\n\n return attributes.reduce((map: any, raw) => {\n const delimiterIdx = raw.indexOf('=');\n\n if (delimiterIdx !== -1) {\n const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();\n const value = unquote(raw.slice(delimiterIdx + 1).trim());\n const mappedKey = ATTRIBUTE_TO_NODE_PROP_MAP[key] ?? key;\n\n if (mappedKey === 'ref') return map;\n map[mappedKey] = attributeValueToNodePropValue(\n tag,\n key,\n value,\n ctx.sanitizer ?? defaultSanitizer\n );\n\n if (\n typeof map[mappedKey] === 'string' &&\n startsWithElement(map[mappedKey])\n ) {\n map[mappedKey] = parseMarkdown(\n map[mappedKey].trim(),\n ctx,\n options\n ).ast;\n }\n } else if (raw !== 'style' && ATTRIBUTE_NAME_START_R.test(raw)) {\n // Skips tokens that cannot name an attribute, such as the `3` or\n // `3-5` a fence's `{3,3-5}` line-highlight meta splits into.\n map[ATTRIBUTE_TO_NODE_PROP_MAP[raw] ?? raw] = true;\n }\n\n return map;\n }, {});\n };\n\n const nonParagraphBlockSyntaxes = [\n BLOCKQUOTE_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R,\n NP_TABLE_R,\n ORDERED_LIST_R,\n UNORDERED_LIST_R,\n startsWithCustomComponent,\n ];\n\n // Built once: this list is fixed for the whole parse, and rebuilding it per\n // call put a fresh array on every block-syntax probe.\n const blockSyntaxes = (\n options.disableParsingRawHTML\n ? nonParagraphBlockSyntaxes\n : [\n ...nonParagraphBlockSyntaxes,\n PARAGRAPH_R,\n startsWithHtmlBlockElement,\n HTML_COMMENT_R,\n startsWithSelfClosingElement,\n startsWithCustomComponent,\n ]\n ) as BlockSyntaxProbe[];\n\n const containsBlockSyntax = (input: string): boolean => {\n const cleaned = input.replace(TRIM_STARTING_NEWLINES, '');\n const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;\n\n if (slice.indexOf('\\n\\n') !== -1) return true;\n\n return some(blockSyntaxes, slice);\n };\n\n const baseRules = createRules(\n createElement,\n ctx,\n options,\n scope,\n attrStringToMap,\n containsBlockSyntax,\n nonParagraphBlockSyntaxes\n );\n\n return options.disableParsingRawHTML\n ? Object.keys(baseRules).reduce((acc, key) => {\n if (key !== RuleType.htmlBlock && key !== RuleType.htmlSelfClosing) {\n acc[key] = baseRules[key]!;\n }\n\n return acc;\n }, {} as Rules)\n : baseRules;\n};\n\n/** Runs the parse phase against an already-built rule set. */\nconst parseWithRules = (\n markdown: string,\n options: MarkdownOptions,\n parser: DocumentParser,\n footnotes: FootnoteDef[],\n refs: MarkdownReferences\n): ParsedMarkdown => {\n const result =\n !options.preserveFrontmatter && markdown.charCodeAt(0) === 45 /* - */\n ? markdown.replace(FRONT_MATTER_R, '')\n : markdown;\n // Stripped once and reused: both the block/inline decision and the block\n // input below need the source without its leading newlines.\n const trimmedStart =\n result.charCodeAt(0) === 10 /* \\n */\n ? result.replace(TRIM_STARTING_NEWLINES, '')\n : result;\n const inline =\n options.forceInline ||\n (!options.forceBlock &&\n SHOULD_RENDER_AS_BLOCK_R.test(trimmedStart) === false);\n\n const ast = parser(inline ? result : `${trimEnd(trimmedStart)}\\n\\n`, {\n inline,\n });\n\n if (footnotes.length > 0) {\n // Parse footnotes content as well\n for (const def of footnotes) {\n (def as any).parsedAst = parser(def.footnote, { inline: true });\n }\n }\n\n return { ast, footnotes, references: refs, inline };\n};\n\n/** Runs the render phase against an already-built rule set. */\nconst renderWithRules = (\n parsed: ParsedMarkdown,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n emitter: DocumentEmitter,\n createElement: CreateElementFunction\n): unknown => {\n const components = ctx.components ?? {};\n const slug = createSlugger(ctx);\n const footnotes = parsed.footnotes || [];\n\n const inline = parsed.inline;\n const arr = emitter(parsed.ast, { inline }) as unknown as any[];\n\n while (typeof arr[arr.length - 1] === 'string' && !arr[arr.length - 1].trim())\n arr.pop();\n\n const getOuterNode = () => {\n if (options.wrapper === null) return arr;\n const wrapper = options.wrapper ?? (inline ? 'span' : 'div');\n\n if (arr.length > 1 || options.forceWrapper)\n return createElement(wrapper, { key: 'outer' }, arr);\n\n if (arr.length === 1) {\n const node = arr[0];\n\n if (Array.isArray(node)) {\n return createElement(wrapper, { key: 'outer' }, node);\n }\n\n if (typeof node === 'string') {\n const spanProps: Record<string, any> = { key: 'outer' };\n\n if (!inline && components) {\n const pOverrideProps = (get(components, 'p.props', {}) ??\n {}) as Record<string, any>;\n const mergedClassName = cx(\n spanProps.className,\n pOverrideProps.className\n );\n const finalSpanProps: Record<string, any> = {\n ...spanProps,\n ...pOverrideProps,\n };\n\n if (mergedClassName) finalSpanProps.className = mergedClassName;\n\n return createElement('span', finalSpanProps, node);\n }\n\n return createElement('span', spanProps, node);\n }\n\n return node;\n }\n\n return createElement(wrapper, { key: 'outer' }, null);\n };\n\n const node = getOuterNode();\n\n const result = footnotes.length\n ? createElement(\n 'div',\n null,\n node,\n createElement(\n 'footer',\n { key: 'footer' },\n ...footnotes.map((def) =>\n createElement(\n 'div',\n { id: slug(def.identifier), key: def.identifier },\n def.identifier,\n emitter((def as any).parsedAst || def.footnote, { inline: true })\n )\n )\n )\n )\n : node;\n\n return result;\n};\n\nexport const parseMarkdown = (\n markdown: string = '',\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): ParsedMarkdown => {\n // Parsing never emits elements, so it gets its own cache entry built around\n // the no-op factory rather than the render one.\n const { parse, scope } = getRuleSet(ctx, options, true);\n const documentScope = createDocumentScope();\n\n return withDocumentScope(scope, documentScope, () =>\n parseWithRules(\n markdown,\n options,\n parse,\n documentScope.footnotes,\n documentScope.references\n )\n );\n};\n\nexport const renderMarkdownAst = (\n parsed: ParsedMarkdown,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): unknown => {\n const { emit, createElement, scope } = getRuleSet(ctx, options, false);\n const documentScope: DocumentScope = {\n footnotes: parsed.footnotes ?? [],\n references: parsed.references ?? {},\n };\n\n return withDocumentScope(scope, documentScope, () =>\n renderWithRules(parsed, ctx, options, emit, createElement)\n );\n};\n\nexport const compile = (\n markdown: string = '',\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): unknown => {\n if (typeof markdown !== 'string') {\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n 'intlayer: the first argument must be a string. Received',\n typeof markdown\n );\n }\n throw new Error('intlayer: the first argument must be a string');\n }\n\n // Both phases share one rule set: building it twice was the dominant cost\n // when compiling the many short strings a typical dictionary holds.\n const { parse, emit, createElement, scope } = getRuleSet(ctx, options, false);\n const documentScope = createDocumentScope();\n\n return withDocumentScope(scope, documentScope, () => {\n const parsed = parseWithRules(\n markdown,\n options,\n parse,\n documentScope.footnotes,\n documentScope.references\n );\n\n return renderWithRules(parsed, ctx, options, emit, createElement);\n });\n};\n\nexport const createCompiler =\n (ctx: MarkdownContext<any>) =>\n (markdown: string, options?: MarkdownOptions): unknown =>\n compile(markdown, ctx, options);\n\nexport const compileWithOptions = (\n markdown: string,\n runtime: MarkdownRuntime,\n options: CompileOptions<any> = {}\n): unknown => {\n const {\n components,\n namedCodesToUnicode,\n sanitizer,\n slugify,\n ...compilerOptions\n } = options;\n\n return compile(\n markdown,\n { runtime, components, namedCodesToUnicode, sanitizer, slugify },\n compilerOptions\n );\n};\n"],"mappings":";;;;;;;AAyHA,MAAM,UAAU;AAKhB,MAAM,SAAS,IAAI,OACjB,4JACF;;;;;;;;;;;;;;AAeA,MAAM,qBAAqB,eAAyC;CAClE,IAAI,gBAA4C;CAIhD,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,WAAW,GAAG,QAAQ,QAAkB;CAEpE,MAAM,2BAAW,IAAI,IAAiB;CAEtC,QAAQ,QAAkB;EACxB,IAAI,OAAO,QAAQ,UAAU,OAAO;EAEpC,MAAM,WAAW,SAAS,IAAI,GAAG;EACjC,IAAI,aAAa,QAAW,OAAO;EAEnC,MAAM,WAAW,IAAI,YAAY,GAAG;EAEpC,IAAI,UAAU;GACZ,SAAS,IAAI,KAAK,QAAQ;GAC1B,OAAO;EACT;EAEA,IAAI,CAAC,eAAe;GAClB,gCAAgB,IAAI,I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BACA,WACA,SACA,GAAG,oBACD;CAEJ,OAAO,QACL,UACA;EAAE;EAAS;EAAY;EAAqB;EAAW;CAAQ,GAC/D,eACF;AACF"}
1
+ {"version":3,"file":"compiler.mjs","names":["defaultSlugify","defaultSanitizer"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["import {\n ATTR_EXTRACTOR_R,\n ATTRIBUTE_NAME_START_R,\n ATTRIBUTE_TO_NODE_PROP_MAP,\n BLOCK_END_R,\n BLOCKQUOTE_ALERT_R,\n BLOCKQUOTE_R,\n BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,\n BREAK_LINE_R,\n BREAK_THEMATIC_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n CODE_INLINE_R,\n CONSECUTIVE_NEWLINE_R,\n DO_NOT_PROCESS_HTML_ELEMENTS,\n FOOTNOTE_R,\n FOOTNOTE_REFERENCE_R,\n FRONT_MATTER_R,\n GFM_TASK_R,\n HEADING_ATX_COMPLIANT_R,\n HEADING_R,\n HEADING_SETEXT_R,\n HTML_CHAR_CODE_R,\n HTML_COMMENT_R,\n HTML_LEFT_TRIM_AMOUNT_R,\n LINK_AUTOLINK_BARE_URL_R,\n LINK_AUTOLINK_R,\n type ListType,\n NAMED_CODES_TO_UNICODE,\n NP_TABLE_R,\n ORDERED,\n ORDERED_LIST_ITEM_PREFIX_R,\n ORDERED_LIST_ITEM_R,\n ORDERED_LIST_R,\n PARAGRAPH_R,\n Priority,\n REFERENCE_IMAGE_OR_LINK,\n REFERENCE_IMAGE_R,\n REFERENCE_LINK_R,\n type RuleScopeValue,\n RuleType,\n SCOPE_BLOCK,\n SCOPE_BOTH,\n SCOPE_INLINE,\n SHORTCODE_R,\n SHOULD_RENDER_AS_BLOCK_R,\n TEXT_BOLD_R,\n TEXT_EMPHASIZED_R,\n TEXT_ESCAPED_R,\n TEXT_MARKED_R,\n TEXT_STRIKETHROUGHED_R,\n TRIM_STARTING_NEWLINES,\n UNORDERED,\n UNORDERED_LIST_ITEM_PREFIX_R,\n UNORDERED_LIST_ITEM_R,\n UNORDERED_LIST_R,\n} from './constants';\nimport {\n matchCustomComponent,\n matchHtmlBlockElement,\n matchSelfClosingElement,\n startsWithCustomComponent,\n startsWithElement,\n startsWithHtmlBlockElement,\n startsWithSelfClosingElement,\n} from './elementScanner';\nimport { parserFor } from './parser';\nimport { createRenderer, renderFor } from './renderer';\nimport type {\n CompileOptions,\n ComponentOverrides as ComponentDefinition,\n HeadingNode,\n HTMLTag,\n MarkdownContext,\n MarkdownOptions,\n MarkdownRuntime,\n OrderedListNode,\n ParseState,\n Rule,\n Rules,\n TableNode,\n UnorderedListNode,\n} from './types';\nimport {\n allowInline,\n anyScopeRegex,\n attributeValueToNodePropValue,\n type BlockSyntaxProbe,\n blockRegex,\n captureNothing,\n cx,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n get,\n inlineRegex,\n normalizeAttributeKey,\n parseBlock,\n parseCaptureInline,\n parseInline,\n parseSimpleInline,\n parseTableAlign,\n parseTableCells,\n parseTableRow,\n renderNothing,\n simpleInlineRegex,\n some,\n startsWith,\n trimEnd,\n trimLeadingWhitespaceOutsideFences,\n unescapeString,\n unquote,\n} from './utils';\n\ntype CreateElementFunction = (\n tag: any,\n props: Record<string, any> | null,\n ...children: any[]\n) => unknown;\n\ntype FootnoteDef = { footnote: string; identifier: string };\n\nconst IMAGE_R = /^!\\[(.*?)\\]\\( *((?:\\([^)]*\\)|[^() ])*) *\"?([^)\"]*)?\"?\\)/;\nconst LINK_INSIDE =\n '(?:\\\\[[^\\\\[\\\\]]*(?:\\\\[[^\\\\[\\\\]]*\\\\][^\\\\[\\\\]]*)*\\\\]|[^\\\\[\\\\]])*';\nconst LINK_HREF_AND_TITLE =\n '\\\\s*<?((?:\\\\([^)]*\\\\)|[^\\\\s\\\\\\\\]|\\\\\\\\.)*?)>?(?:\\\\s+[\\'\"]([\\\\s\\\\S]*?)[\\'\"])?\\\\s*';\nconst LINK_R = new RegExp(\n `^\\\\[(${LINK_INSIDE})\\\\]\\\\(${LINK_HREF_AND_TITLE}\\\\)`\n);\n\n/**\n * Case-insensitive `</tag>` probes, cached per tag name.\n *\n * The `htmlBlock` rule is qualified at every candidate position, and it used to\n * lowercase the whole remaining document to look its closing tag up — copying\n * the rest of the file on each probe.\n */\n/**\n * Builds a tag -> component resolver for one set of overrides.\n *\n * The case-insensitive fallback used to rescan every override key on each\n * element created; the lowercase index is now built once per document instead.\n */\nconst createTagResolver = (components: ComponentDefinition<any>) => {\n let lowercaseKeys: Map<string, string> | null = null;\n\n // With no overrides declared — the common case — every tag resolves to\n // itself, so the whole lookup is skipped.\n if (Object.keys(components).length === 0) return (tag: any): any => tag;\n\n const resolved = new Map<string, any>();\n\n return (tag: any): any => {\n if (typeof tag !== 'string') return tag;\n\n const memoized = resolved.get(tag);\n if (memoized !== undefined) return memoized;\n\n const override = get(components, tag);\n\n if (override) {\n resolved.set(tag, override);\n return override;\n }\n\n if (!lowercaseKeys) {\n lowercaseKeys = new Map();\n\n // Later keys win, matching `Array.prototype.find` on `Object.keys`\n // only when they are unique — so the first key of a given lowercase\n // form is kept, as before.\n for (const key of Object.keys(components)) {\n const lowercased = key.toLowerCase();\n\n if (!lowercaseKeys.has(lowercased)) lowercaseKeys.set(lowercased, key);\n }\n }\n\n const key = lowercaseKeys.get(tag.toLowerCase());\n const result = (key ? get(components, key) : undefined) || tag;\n\n resolved.set(tag, result);\n\n return result;\n };\n};\n\n/** Resolves the slugifier for a context, falling back to the built-in one. */\nconst createSlugger =\n (ctx: MarkdownContext<any>) =>\n (input: string): string =>\n ctx.slugify ? ctx.slugify(input, defaultSlugify) : defaultSlugify(input);\n\nconst createElementFactory = (\n ctx: MarkdownContext<any>,\n options: MarkdownOptions\n): CreateElementFunction => {\n const { runtime, components = {} } = ctx;\n const resolveTag = createTagResolver(components);\n const filteredTags = options.tagfilter\n ? new Set([\n 'title',\n 'textarea',\n 'style',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'script',\n 'plaintext',\n ])\n : null;\n\n /**\n * True when `props` can be handed to the runtime untouched: no `class`\n * alias to fold into `className`, and no empty value to drop. Rules build a\n * fresh literal for every element, so reusing it is safe, and it saves an\n * object per element — the single largest allocation in the render phase.\n */\n const needsPropsRewrite = (props: Record<string, any>): boolean => {\n if ('class' in props) return true;\n for (const key in props) {\n const value = props[key];\n if (value === undefined || value === null) return true;\n }\n return false;\n };\n\n return (\n tag: any,\n props: Record<string, any> | null,\n ...children: any[]\n ): unknown => {\n const isStringTag = typeof tag === 'string';\n\n if (\n filteredTags &&\n isStringTag &&\n (filteredTags.has(tag) || filteredTags.has(tag.toLowerCase()))\n ) {\n return null;\n }\n\n let finalProps: Record<string, any>;\n\n if (!props) {\n finalProps = {};\n } else if (!needsPropsRewrite(props)) {\n finalProps = props;\n } else {\n const className = cx(props.className, props.class);\n const mergedProps: Record<string, any> = {};\n let classNameHandled = false;\n\n // Preserve attribute order while merging className\n for (const key in props) {\n const value = props[key];\n\n if (value === undefined || value === null) continue;\n\n if (key === 'className' || key === 'class') {\n if (!classNameHandled) {\n if (className) mergedProps.className = className;\n classNameHandled = true;\n }\n } else {\n mergedProps[key] = value;\n }\n }\n\n if (!classNameHandled && className) {\n mergedProps.className = className;\n }\n\n finalProps = mergedProps;\n }\n\n if (runtime.normalizeProps && isStringTag)\n finalProps = runtime.normalizeProps(tag as string, finalProps);\n\n const component = resolveTag(tag);\n return runtime.createElement(component, finalProps, ...children);\n };\n};\n\n/**\n * Footnote and reference tables belonging to the document currently being\n * parsed or rendered. Rules reach them through a ref so a rule set can outlive\n * a single document and be reused.\n */\ntype DocumentScope = {\n footnotes: FootnoteDef[];\n references: MarkdownReferences;\n slugCounts?: Map<string, number>;\n};\n\ntype DocumentScopeRef = { current: DocumentScope };\n\nconst createDocumentScope = (): DocumentScope => ({\n footnotes: [],\n references: {},\n slugCounts: new Map(),\n});\n\n/**\n * A cached rule set, together with the values it was built from. The signature\n * holds every input that changes the shape of the rules; anything else (the\n * markdown itself, the document scope) is free to vary between uses.\n */\ntype DocumentParser = ReturnType<typeof parserFor>;\ntype DocumentEmitter = ReturnType<typeof renderFor>;\n\ntype RuleSetCacheEntry = {\n /** The inputs this set was built from, compared field by field on lookup. */\n ctx: MarkdownContext<any>;\n options: MarkdownOptions;\n parseOnly: boolean;\n createElement: CreateElementFunction;\n scope: DocumentScopeRef;\n /**\n * Built with the rules, not per call. `parserFor` resolves precedence and\n * fills the first-character dispatch tables, and `renderFor` walks the rule\n * set — repeating either for every string was most of what compiling a\n * dictionary of short strings cost.\n */\n parse: DocumentParser;\n emit: DocumentEmitter;\n};\n\n/**\n * Small enough to scan linearly, large enough that an app mixing a few option\n * sets — say prose and a dictionary rendered with different components — keeps\n * hitting it.\n */\nconst RULE_SET_CACHE_LIMIT = 8;\n\nconst ruleSetCache: RuleSetCacheEntry[] = [];\n\n/**\n * Every input that changes how rules are built. Compared directly rather than\n * through a signature array, which would allocate on every compile.\n */\nconst builtFromSame = (\n entry: RuleSetCacheEntry,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n parseOnly: boolean\n): boolean =>\n entry.parseOnly === parseOnly &&\n entry.ctx.runtime === ctx.runtime &&\n entry.ctx.components === ctx.components &&\n entry.ctx.namedCodesToUnicode === ctx.namedCodesToUnicode &&\n entry.ctx.sanitizer === ctx.sanitizer &&\n entry.ctx.slugify === ctx.slugify &&\n entry.options.disableAutoLink === options.disableAutoLink &&\n entry.options.disableParsingRawHTML === options.disableParsingRawHTML &&\n entry.options.enforceAtxHeadings === options.enforceAtxHeadings &&\n entry.options.tagfilter === options.tagfilter &&\n entry.options.renderRule === options.renderRule;\n\n/**\n * Returns the rule set for these options, building it only when no cached set\n * was made from the same inputs.\n */\nexport const getRuleSet = (\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n parseOnly: boolean\n): RuleSetCacheEntry => {\n for (let index = 0; index < ruleSetCache.length; index++) {\n const entry = ruleSetCache[index]!;\n if (!builtFromSame(entry, ctx, options, parseOnly)) continue;\n\n // Most-recently-used first, so the hot option set stays at the front.\n if (index > 0) {\n ruleSetCache.splice(index, 1);\n ruleSetCache.unshift(entry);\n }\n return entry;\n }\n\n const scope: DocumentScopeRef = { current: createDocumentScope() };\n const createElement = parseOnly\n ? noopCreateElement\n : createElementFactory(ctx, options);\n const rules = createDocumentRules(createElement, ctx, options, scope);\n const entry: RuleSetCacheEntry = {\n ctx,\n options,\n parseOnly,\n createElement,\n scope,\n parse: parserFor(rules),\n emit: renderFor(createRenderer(rules, options.renderRule)),\n };\n\n ruleSetCache.unshift(entry);\n if (ruleSetCache.length > RULE_SET_CACHE_LIMIT) ruleSetCache.pop();\n\n return entry;\n};\n\n/**\n * Runs `operation` with `scope` installed as the current document, restoring\n * whatever was there before. The save/restore keeps a nested compile — a custom\n * component that renders markdown of its own — from clobbering its caller.\n */\nconst withDocumentScope = <TResult>(\n ref: DocumentScopeRef,\n scope: DocumentScope,\n operation: () => TResult\n): TResult => {\n const previous = ref.current;\n ref.current = scope;\n try {\n return operation();\n } finally {\n ref.current = previous;\n }\n};\n\nconst createRules = (\n createElement: CreateElementFunction,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n scope: DocumentScopeRef,\n attrStringToMap: (tag: HTMLTag, str: string) => Record<string, any> | null,\n containsBlockSyntax: (input: string) => boolean,\n nonParagraphBlockSyntaxes: BlockSyntaxProbe[]\n): Rules => {\n const slug = createSlugger(ctx);\n const sanitize = ctx.sanitizer ?? defaultSanitizer;\n const namedCodesToUnicode = ctx.namedCodesToUnicode\n ? { ...NAMED_CODES_TO_UNICODE, ...ctx.namedCodesToUnicode }\n : NAMED_CODES_TO_UNICODE;\n\n /**\n * Raw HTML blocks and custom components differ only in how their tag is\n * spelled: both trim the captured content, decide block or inline parsing\n * from it, and render the tag with its attributes. `rawHtml` adds the two\n * things only real HTML needs — the never-parse element list, and tracking\n * whether we are inside an anchor.\n */\n /**\n * Whether `source` opens an element at the start of a block line, allowing\n * the up-to-three-space indentation CommonMark grants to HTML blocks.\n *\n * The scanner already skips leading spaces, but the dispatch only handed it\n * sources starting with `<`. An indented ` <Tab>` inside a `<Tabs>` block\n * then fell through to the paragraph rule, which swallowed the opening tag\n * as inline HTML and lost every sibling that followed it.\n */\n const qualifiesPairedElement = (source: string, state: ParseState) => {\n if (source.charCodeAt(0) === 60 /* < */) return true;\n\n const isBlockLineStart =\n !state.inline && !state.simple && state.prevCaptureIndent !== undefined;\n\n if (!isBlockLineStart) return false;\n\n let index = 0;\n while (index < 3 && source.charCodeAt(index) === 32 /* space */) index++;\n\n return index > 0 && source.charCodeAt(index) === 60;\n };\n\n const pairedElementRule = (\n match: (source: string) => RegExpMatchArray | null,\n order: number,\n rawHtml: boolean,\n scope: RuleScopeValue = SCOPE_BOTH\n ): Rule<any> => ({\n _scope: scope,\n _firstChars: [60 /* < */, 32 /* space */],\n _qualify: qualifiesPairedElement,\n _match: anyScopeRegex(match),\n _order: order,\n _parse(capture, parse, state) {\n const content = capture[3] ?? '';\n const whitespace = content.match(HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? '';\n const trimmed = trimLeadingWhitespaceOutsideFences(content, whitespace);\n const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;\n const tagName = (capture[1] ?? '').trim();\n const lowercased = tagName.toLowerCase();\n const noInnerParse =\n rawHtml && DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(lowercased) !== -1;\n const tag = (noInnerParse ? lowercased : tagName) as HTMLTag;\n const ast: any = {\n attrs: attrStringToMap(tag, capture[2] ?? ''),\n noInnerParse,\n tag,\n };\n\n if (rawHtml) state.inAnchor = state.inAnchor || lowercased === 'a';\n\n if (noInnerParse) {\n ast.text = content;\n } else {\n const prevInHTML = state.inHTML;\n state.inHTML = true;\n ast.children = parseFunc(parse, trimmed, state);\n state.inHTML = prevInHTML;\n }\n\n if (rawHtml) state.inAnchor = false;\n\n return ast;\n },\n _render(node, output, state = {}) {\n return createElement(\n node.tag,\n { key: state.key, ...(node.attrs ?? {}) },\n node.text ?? (node.children ? output(node.children, state) : '')\n );\n },\n });\n\n const generateListRule = (\n type: ListType\n ): Rule<OrderedListNode | UnorderedListNode> => {\n const ordered = type === ORDERED;\n const LIST_R = ordered ? ORDERED_LIST_R : UNORDERED_LIST_R;\n const LIST_ITEM_R = ordered ? ORDERED_LIST_ITEM_R : UNORDERED_LIST_ITEM_R;\n const LIST_ITEM_PREFIX_R = ordered\n ? ORDERED_LIST_ITEM_PREFIX_R\n : UNORDERED_LIST_ITEM_PREFIX_R;\n\n const firstChars = ordered\n ? [32, 9, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57]\n : [32, 9, 42, 43, 45];\n\n return {\n _scope: SCOPE_BOTH,\n _firstChars: firstChars,\n _qualify: (source, state) =>\n state.prevCaptureIndent !== undefined &&\n Boolean(state.list ?? (!state.inline && !state.simple)) &&\n LIST_ITEM_PREFIX_R.test(source),\n _match: allowInline((source, state) => {\n const lineIndent = state.prevCaptureIndent;\n const isStartOfLine = lineIndent !== undefined;\n const isListAllowed = state.list ?? (!state.inline && !state.simple);\n\n if (isStartOfLine && isListAllowed) {\n const matchSource = lineIndent ? lineIndent + source : source;\n\n const match = LIST_R.exec(matchSource);\n if (!match) return null;\n\n if (lineIndent && match[0].startsWith(lineIndent)) {\n const adjusted = [...match] as RegExpMatchArray;\n adjusted[0] = match[0].slice(lineIndent.length);\n (adjusted as any).fullMatch = match[0];\n return adjusted;\n }\n\n return match;\n }\n\n return null;\n }),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const bullet = capture[2] ?? '';\n const startValue = ordered ? +bullet.slice(0, -1) : undefined;\n const fullSource = (capture as any).fullMatch ?? capture[0] ?? '';\n const items = fullSource\n .replace(BLOCK_END_R, '\\n')\n .match(LIST_ITEM_R) as string[];\n\n if (!items) return { items: [], ordered, start: startValue } as any;\n\n let lastItemWasAParagraph = false;\n\n const result = items.map((item, i) => {\n const prefixCapture = LIST_ITEM_PREFIX_R.exec(item);\n const space = prefixCapture ? prefixCapture[0].length : 0;\n const spaceRegex =\n space <= 8\n ? STRIP_INDENT_REGEXES[space]!\n : new RegExp(`^ {1,${space}}`, 'gm');\n // Slicing the prefix off is the same as stripping the item's own\n // indentation and then its bullet, because the bullet run is greedy:\n // the first line never keeps a leading space either way. It saves a\n // second pass of the prefix pattern over every item.\n const content = item.slice(space).replace(spaceRegex, '');\n const isLastItem = i === items.length - 1;\n const containsBlocks = content.indexOf('\\n\\n') !== -1;\n const thisItemIsAParagraph =\n containsBlocks || (isLastItem && lastItemWasAParagraph);\n\n lastItemWasAParagraph = thisItemIsAParagraph;\n\n const oldStateInline = state.inline;\n const oldStateList = state.list;\n state.list = true;\n\n let adjustedContent: string;\n\n if (thisItemIsAParagraph) {\n state.inline = false;\n adjustedContent = `${trimEnd(content)}\\n\\n`;\n } else {\n state.inline = true;\n adjustedContent = trimEnd(content);\n }\n\n const parsed = parse(adjustedContent, state);\n state.inline = oldStateInline;\n state.list = oldStateList;\n\n return parsed;\n });\n\n return { items: result, ordered, start: startValue };\n },\n _render(node, output, state = {}) {\n return createElement(\n ordered ? 'ol' : 'ul',\n { key: state.key, start: (node as OrderedListNode).start },\n ...node.items.map((item, i) =>\n createElement('li', { key: i }, output(item, state))\n )\n );\n },\n };\n };\n\n const matchParagraph = (\n source: string,\n state: ParseState\n ): RegExpMatchArray | null => {\n if (\n state.inline ||\n state.simple ||\n (state.inHTML &&\n source.indexOf('\\n\\n') === -1 &&\n !state.prevCaptureHasBlankLine)\n )\n return null;\n let start = 0;\n const srcLen = source.length;\n while (start < srcLen) {\n const newlineIndex = source.indexOf('\\n', start);\n const lineEnd = newlineIndex === -1 ? srcLen : newlineIndex;\n\n let p = start;\n while (\n p < lineEnd &&\n (source.charCodeAt(p) === 32 || source.charCodeAt(p) === 9)\n ) {\n p++;\n }\n\n if (p >= lineEnd) {\n break;\n }\n\n if (p - start >= 4 || source.charCodeAt(start) === 9) {\n break;\n }\n\n const ch = source.charCodeAt(p);\n const isDelim =\n ch === 62 || // >\n ch === 96 || // `\n ch === 126 || // ~\n ch === 35 || // #\n ch === 124 || // |\n ch === 42 || // *\n ch === 43 || // +\n ch === 45 || // -\n ch === 61 || // =\n ch === 60 || // <\n (ch >= 48 && ch <= 57); // 0-9\n\n if (isDelim) {\n const line = source.slice(\n start,\n newlineIndex === -1 ? undefined : newlineIndex + 1\n );\n\n if (some(nonParagraphBlockSyntaxes, line)) break;\n }\n\n if (newlineIndex === -1) {\n start = srcLen;\n break;\n }\n start = newlineIndex + 1;\n }\n const match = source.slice(0, start);\n // Align with original simple-markdown behavior: capture the whole match including newlines\n\n if (match === '') return null;\n const captured = trimEnd(match);\n\n if (captured === '') return null;\n\n return [match, undefined, captured] as unknown as RegExpMatchArray;\n };\n\n const rules: Rules = {\n [RuleType.blockQuote]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['>'],\n _match: blockRegex(BLOCKQUOTE_R),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const matchAlert = (capture[0] ?? '')\n .replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, '')\n .match(BLOCKQUOTE_ALERT_R);\n const alert = matchAlert?.[1];\n const content = matchAlert?.[2] ?? '';\n const hasNewline = content.indexOf('\\n') !== -1;\n const children = hasNewline\n ? parseBlock(parse, content, state)\n : parseInline(parse, content, state);\n\n return { alert, children };\n },\n _render(node, output, state = {}) {\n const props: Record<string, any> = { key: state.key };\n\n if (node.alert) {\n props.className = `markdown-alert-${slug(node.alert.toLowerCase())}`;\n node.children.unshift({\n attrs: {},\n children: [{ type: RuleType.text, text: node.alert }],\n noInnerParse: true,\n type: RuleType.htmlBlock,\n tag: 'header',\n } as any);\n }\n\n return createElement('blockquote', props, output(node.children, state));\n },\n },\n [RuleType.breakLine]: {\n _scope: SCOPE_BOTH,\n _qualify: [' '],\n _match: anyScopeRegex(BREAK_LINE_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render(_, __, state = {}) {\n return createElement('br', { key: state.key });\n },\n },\n [RuleType.breakThematic]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['--', '__', '**', '- ', '* ', '_ '],\n _match: blockRegex(BREAK_THEMATIC_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render(_, __, state = {}) {\n return createElement('hr', { key: state.key });\n },\n },\n [RuleType.codeBlock]: {\n _scope: SCOPE_BLOCK,\n _qualify: [' '],\n _match: blockRegex(CODE_BLOCK_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n type: RuleType.codeBlock,\n lang: undefined,\n text: unescapeString(\n trimEnd((capture[0] ?? '').replace(/^ {4}/gm, ''))\n ),\n };\n },\n _render(node, _, state = {}) {\n const attrs = { ...((node as any).attrs ?? {}) } as Record<string, any>;\n const langClass = node.lang ? `lang-${node.lang}` : 'lang-plaintext';\n attrs.className = attrs.className\n ? `${attrs.className} ${langClass}`\n : langClass;\n\n return createElement(\n 'pre',\n { key: state.key },\n createElement('code', attrs, node.text)\n );\n },\n },\n [RuleType.codeFenced]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['```', '~~~'],\n _match: blockRegex(CODE_BLOCK_FENCED_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n attrs: attrStringToMap('code', capture[3] ?? ''),\n lang: capture[2] || undefined,\n text: capture[4] ?? '',\n type: RuleType.codeBlock,\n };\n },\n },\n [RuleType.codeInline]: {\n _scope: SCOPE_INLINE,\n _firstChars: [96 /* ` */],\n _qualify: (source) =>\n source.charCodeAt(0) === 96 && source.indexOf('`', 1) !== -1,\n _match: simpleInlineRegex(CODE_INLINE_R),\n _order: Priority.LOW,\n _parse(capture) {\n return { text: unescapeString(capture[2] ?? '') };\n },\n _render(node, _, state = {}) {\n return createElement('code', { key: state.key }, node.text);\n },\n },\n [RuleType.footnote]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[^'],\n _match: blockRegex(FOOTNOTE_R),\n _order: Priority.MAX,\n _parse(capture) {\n scope.current.footnotes.push({\n footnote: capture[2] ?? '',\n identifier: capture[1] ?? '',\n });\n\n return {};\n },\n _render: renderNothing,\n },\n [RuleType.footnoteReference]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[^'],\n _match: inlineRegex(FOOTNOTE_REFERENCE_R),\n _order: Priority.HIGH,\n _parse(capture) {\n const text = capture[1] ?? '';\n return { target: `#${slug(text)}`, text };\n },\n _render(node, _, state = {}) {\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitize(node.target, 'a', 'href') ?? undefined,\n },\n createElement('sup', { key: state.key }, node.text)\n );\n },\n },\n [RuleType.gfmTask]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[ ]', '[x]'],\n _match: inlineRegex(GFM_TASK_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return { completed: (capture[1] ?? '').toLowerCase() === 'x' };\n },\n _render(node, _, state = {}) {\n return createElement('input', {\n checked: node.completed,\n key: state.key,\n readOnly: true,\n type: 'checkbox',\n });\n },\n },\n [RuleType.heading]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['#'],\n _match: blockRegex(\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R\n ),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const text = capture[2] ?? '';\n const baseSlug = slug(text) || 'section';\n const counts = scope.current.slugCounts;\n let id = baseSlug;\n\n if (counts) {\n const count = counts.get(baseSlug) ?? 0;\n counts.set(baseSlug, count + 1);\n if (count > 0) {\n id = `${baseSlug}-${count}`;\n }\n }\n\n return {\n children: parseInline(parse, text, state),\n id,\n level: (capture[1]?.length ?? 1) as HeadingNode['level'],\n };\n },\n _render(node, output, state = {}) {\n return createElement(\n `h${node.level}` as HTMLTag,\n { id: node.id, key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.headingSetext]: {\n _scope: SCOPE_BLOCK,\n _qualify: (source, state) => {\n if (\n state.prevCaptureIndent === undefined ||\n state.inline ||\n state.simple\n )\n return false;\n const nlIndex = source.indexOf('\\n');\n\n return (\n nlIndex > 0 &&\n nlIndex < source.length - 1 &&\n (source[nlIndex + 1] === '=' || source[nlIndex + 1] === '-')\n );\n },\n _match: blockRegex(HEADING_SETEXT_R),\n _order: Priority.MAX,\n _parse(capture, parse, state) {\n return {\n children: parseInline(parse, capture[1] ?? '', state),\n level: capture[2] === '=' ? 1 : 2,\n type: RuleType.heading,\n };\n },\n },\n [RuleType.htmlBlock]: pairedElementRule(\n // The rule is dropped outright when raw HTML is disabled, and the scanner\n matchHtmlBlockElement,\n Priority.HIGH,\n true,\n SCOPE_BOTH\n ),\n [RuleType.htmlComment]: {\n _scope: SCOPE_BOTH,\n _qualify: ['<!'],\n _match: anyScopeRegex(HTML_COMMENT_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render: renderNothing,\n },\n [RuleType.htmlSelfClosing]: {\n _scope: SCOPE_BOTH,\n _qualify: ['<'],\n _match: anyScopeRegex(matchSelfClosingElement),\n _order: Priority.HIGH,\n _parse(capture) {\n const tag = (capture[1] ?? '').trim() as HTMLTag;\n\n return { attrs: attrStringToMap(tag, capture[2] || ''), tag };\n },\n _render(node, _, state = {}) {\n return createElement(node.tag, {\n key: state.key,\n ...(node.attrs ?? {}),\n });\n },\n },\n [RuleType.customComponent]: pairedElementRule(\n matchCustomComponent,\n Priority.MAX,\n false,\n SCOPE_BOTH\n ),\n [RuleType.paragraph]: {\n _scope: SCOPE_BLOCK,\n _qualify: (_source, state) => !state.inline && !state.simple,\n _match: matchParagraph,\n _order: Priority.LOW,\n _parse: parseCaptureInline,\n _render(node, output, state = {}) {\n return createElement(\n 'p',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.image]: {\n _scope: SCOPE_INLINE,\n _firstChars: [33 /* ! */],\n _qualify: (source) =>\n source.startsWith('![') && source.indexOf('](') !== -1,\n _match: simpleInlineRegex(IMAGE_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return {\n alt: unescapeString(capture[1] ?? ''),\n target: unescapeString(capture[2] ?? ''),\n title: capture[3] ? unescapeString(capture[3]) : undefined,\n };\n },\n _render(node, _, state = {}) {\n return createElement('img', {\n key: state.key,\n alt: node.alt ?? undefined,\n title: node.title ?? undefined,\n src: sanitize(node.target, 'img', 'src') ?? undefined,\n });\n },\n },\n [RuleType.link]: {\n _scope: SCOPE_INLINE,\n _firstChars: [91 /* [ */],\n _qualify: (source) =>\n source.charCodeAt(0) === 91 && source.indexOf('](') !== -1,\n _match: inlineRegex(LINK_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1] ?? '', state),\n target: unescapeString(capture[2] ?? ''),\n title: capture[3] ? unescapeString(capture[3]) : undefined,\n };\n },\n _render(node, output, state = {}) {\n const sanitizedHref = sanitize(node.target, 'a', 'href');\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitizedHref ?? undefined,\n title: node.title ?? undefined,\n },\n output(node.children, state)\n );\n },\n },\n [RuleType.linkAngleBraceStyleDetector]: {\n _scope: SCOPE_INLINE,\n _qualify: ['<'],\n _match: inlineRegex(LINK_AUTOLINK_R),\n _order: Priority.MAX,\n _parse(capture) {\n let target = capture[1] ?? '';\n let isEmail = false;\n\n if (target.indexOf('@') !== -1 && target.indexOf('//') === -1) {\n isEmail = true;\n target = target.replace('mailto:', '');\n }\n\n return {\n children: [{ text: target, type: RuleType.text }],\n target: isEmail ? `mailto:${target}` : target,\n type: RuleType.link,\n };\n },\n },\n [RuleType.linkBareUrlDetector]: {\n _scope: SCOPE_INLINE,\n _firstChars: [104 /* h */],\n _qualify: (source, state) =>\n Boolean(\n state.inline &&\n !state.inAnchor &&\n !options.disableAutoLink &&\n (startsWith(source, 'http://') || startsWith(source, 'https://'))\n ),\n _match: inlineRegex(LINK_AUTOLINK_BARE_URL_R),\n _order: Priority.MAX,\n _parse(capture) {\n const url = capture[1] ?? '';\n return {\n children: [{ text: url, type: RuleType.text }],\n target: url,\n type: RuleType.link,\n };\n },\n },\n [RuleType.newlineCoalescer]: {\n _scope: SCOPE_BOTH,\n _qualify: ['\\n'],\n _match: blockRegex(CONSECUTIVE_NEWLINE_R),\n _order: Priority.LOW,\n _parse: captureNothing,\n _render() {\n return '\\n';\n },\n },\n [RuleType.orderedList]: generateListRule(ORDERED),\n [RuleType.unorderedList]: generateListRule(UNORDERED),\n [RuleType.ref]: {\n _scope: SCOPE_BOTH,\n _qualify: ['['],\n _match: anyScopeRegex(REFERENCE_IMAGE_OR_LINK),\n _order: Priority.MAX,\n _parse(capture) {\n const identifier = capture[1];\n\n if (identifier !== undefined) {\n scope.current.references[identifier] = {\n target: capture[2] ?? '',\n title: capture[4],\n };\n }\n\n return {};\n },\n _render: renderNothing,\n },\n [RuleType.refImage]: {\n _scope: SCOPE_INLINE,\n _firstChars: [33 /* ! */],\n _qualify: (source) =>\n source.startsWith('![') && source.indexOf('](') === -1,\n _match: simpleInlineRegex(REFERENCE_IMAGE_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n alt: capture[1] ? unescapeString(capture[1]) : undefined,\n ref: capture[2] ?? '',\n };\n },\n _render(node, _, state = {}) {\n const ref = scope.current.references[node.ref];\n\n if (!ref) return null;\n\n return createElement('img', {\n key: state.key,\n alt: node.alt,\n src: sanitize(ref.target, 'img', 'src') ?? undefined,\n title: ref.title,\n });\n },\n },\n [RuleType.refLink]: {\n _scope: SCOPE_INLINE,\n _firstChars: [91 /* [ */],\n _qualify: (source) => source.indexOf('](') === -1,\n _match: inlineRegex(REFERENCE_LINK_R),\n _order: Priority.MAX,\n _parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1] ?? '', state),\n fallbackChildren: capture[0] ?? '',\n ref: capture[2] ?? '',\n };\n },\n _render(node, output, state = {}) {\n const ref = scope.current.references[node.ref];\n\n if (!ref)\n return createElement(\n 'span',\n { key: state.key },\n node.fallbackChildren\n );\n\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitize(ref.target, 'a', 'href') ?? undefined,\n title: ref.title,\n },\n output(node.children, state)\n );\n },\n },\n [RuleType.table]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['|'],\n _match: blockRegex(NP_TABLE_R),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n state.inline = true;\n const align = capture[2] ? parseTableAlign(capture[2]) : [];\n const cells = capture[3]\n ? parseTableCells(capture[3], parse, state)\n : [];\n const header = parseTableRow(\n capture[1] ?? '',\n parse,\n state,\n !!cells.length\n );\n state.inline = false;\n\n return cells.length\n ? { align, cells, header, type: RuleType.table }\n : { children: header.flat(), type: RuleType.paragraph };\n },\n _render(node, output, state = {}) {\n const table = node as TableNode;\n const getStyle = (i: number) =>\n table.align[i] && table.align[i] !== 'left'\n ? { textAlign: table.align[i] }\n : {};\n\n return createElement(\n 'table',\n { key: state.key },\n createElement(\n 'thead',\n { key: 'thead' },\n createElement(\n 'tr',\n null,\n ...table.header.map((c, i) =>\n createElement(\n 'th',\n { key: i, style: getStyle(i) },\n output(c, state)\n )\n )\n )\n ),\n createElement(\n 'tbody',\n { key: 'tbody' },\n ...table.cells.map((row, i) =>\n createElement(\n 'tr',\n { key: i },\n ...row.map((c, j) =>\n createElement(\n 'td',\n { key: j, style: getStyle(j) },\n output(c, state)\n )\n )\n )\n )\n )\n );\n },\n },\n [RuleType.tableSeparator]: {\n _scope: SCOPE_INLINE,\n _qualify: ['|'],\n _match: (source, state) => (state.inTable ? /^\\|/.exec(source) : null),\n _order: Priority.HIGH,\n _parse() {\n return { type: RuleType.tableSeparator };\n },\n _render() {\n return ' | ';\n },\n },\n [RuleType.text]: {\n _scope: SCOPE_INLINE,\n _match: allowInline((source, _state) => {\n const len = source.length;\n if (source.charCodeAt(0) === 10 /* \\n */) {\n let j = 1;\n while (j < len && source.charCodeAt(j) === 32 /* space */) {\n j++;\n }\n if (\n j < len &&\n (source.charCodeAt(j) === 42 || // *\n source.charCodeAt(j) === 43 || // +\n source.charCodeAt(j) === 45 || // -\n (source.charCodeAt(j) >= 48 && source.charCodeAt(j) <= 57)) // 0-9\n ) {\n return [source.slice(0, j)] as unknown as RegExpMatchArray;\n }\n return ['\\n'] as unknown as RegExpMatchArray;\n }\n\n if (source.charCodeAt(0) === 58 /* : */) {\n const shortMatch = SHORTCODE_R.exec(source);\n if (shortMatch) return shortMatch;\n }\n // The first character always belongs to the run, whatever it is.\n TEXT_RUN_R.lastIndex = 1;\n TEXT_RUN_R.test(source);\n\n // Text is the most frequent capture by a wide margin, and its `_parse`\n // never re-enters the parser, so one scratch array serves every run\n // instead of allocating one per token.\n TEXT_CAPTURE[0] = source.slice(\n 0,\n trimHardBreak(source, TEXT_RUN_R.lastIndex)\n );\n\n return TEXT_CAPTURE;\n }),\n _order: Priority.MIN,\n _parse(capture) {\n const text = capture[0] ?? '';\n\n // Declaring `type` here — rather than letting the parser add it —\n // keeps every text node on one hidden class. `&` stops a run, so an\n // entity can only ever open one: testing the first character replaces\n // a scan of every character of every text node in the document.\n return {\n type: RuleType.text,\n text:\n text.charCodeAt(0) !== 38 /* & */\n ? text\n : text.replace(HTML_CHAR_CODE_R, (f, i) => {\n if (i.startsWith('#x'))\n return String.fromCharCode(parseInt(i.slice(2), 16));\n if (i.startsWith('#'))\n return String.fromCharCode(parseInt(i.slice(1), 10));\n return namedCodesToUnicode[i] || f;\n }),\n };\n },\n _render(node) {\n return node.text;\n },\n },\n [RuleType.textBolded]: {\n _scope: SCOPE_INLINE,\n _firstChars: [42 /* * */, 95 /* _ */],\n _qualify: (source) => {\n const c = source.charCodeAt(0);\n if (c === 42) {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 42 && source.indexOf('**', 2) !== -1;\n }\n if (c === 95) {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 95 && source.indexOf('__', 2) !== -1;\n }\n return false;\n },\n _match: simpleInlineRegex(TEXT_BOLD_R),\n _order: Priority.MED,\n _parse(capture, parse, state) {\n return { children: parse(capture[2] ?? '', state) };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'strong',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textEmphasized]: {\n _scope: SCOPE_INLINE,\n _firstChars: [42 /* * */, 95 /* _ */],\n _qualify: (source) => {\n const c = source.charCodeAt(0);\n const next = source.charCodeAt(1);\n if (next === 32 || next === 10 || next === 9) return false;\n return (\n (c === 42 && source.indexOf('*', 1) !== -1) ||\n (c === 95 && source.indexOf('_', 1) !== -1)\n );\n },\n _match: simpleInlineRegex(TEXT_EMPHASIZED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parse(capture[2] ?? '', state) };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'em',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textEscaped]: {\n _scope: SCOPE_INLINE,\n _qualify: ['\\\\'],\n _match: simpleInlineRegex(TEXT_ESCAPED_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return { text: capture[1] ?? '', type: RuleType.text };\n },\n },\n [RuleType.textMarked]: {\n _scope: SCOPE_INLINE,\n _firstChars: [61 /* = */],\n _qualify: (source) => {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 61 && source.indexOf('==', 2) !== -1;\n },\n _match: simpleInlineRegex(TEXT_MARKED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parseCaptureInline(capture, parse, state).children };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'mark',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textStrikethroughed]: {\n _scope: SCOPE_INLINE,\n _firstChars: [126 /* ~ */],\n _qualify: (source) => {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 126 && source.indexOf('~~', 2) !== -1;\n },\n _match: simpleInlineRegex(TEXT_STRIKETHROUGHED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parseCaptureInline(capture, parse, state).children };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'del',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n };\n\n return rules;\n};\n\n// Removed compilerCache completely to avoid issues with props changes not invalidating cache\n// const compilerCache = new Map<string, unknown>();\n\n/** Link/image reference definitions (`[id]: target \"title\"`) collected while parsing. */\nexport type MarkdownReferences = Record<\n string,\n { target: string; title?: string }\n>;\n\nexport type ParsedMarkdown = {\n ast: any[];\n footnotes: FootnoteDef[];\n /**\n * Reference definitions gathered during parsing. They must be carried over to\n * the render stage, since `refLink` / `refImage` nodes only store the\n * reference id and resolve their target at render time.\n */\n references: MarkdownReferences;\n inline: boolean;\n};\n\nconst STRIP_INDENT_REGEXES = [\n null,\n /^ {1,1}/gm,\n /^ {1,2}/gm,\n /^ {1,3}/gm,\n /^ {1,4}/gm,\n /^ {1,5}/gm,\n /^ {1,6}/gm,\n /^ {1,7}/gm,\n /^ {1,8}/gm,\n];\n\n/** Scratch capture reused by the text rule; see its `_match`. */\nconst TEXT_CAPTURE = [''] as unknown as RegExpMatchArray;\n\n/**\n * Consumes a run of plain text, stopping before the next character that could\n * open another inline rule or a bare URL. Anchored so `test` leaves the stop\n * offset in `lastIndex` without allocating a match array, and so the scan\n * itself runs in the regex engine.\n *\n * The bare-URL guard is an alternation branch rather than a per-character\n * lookahead, because a lookahead is re-evaluated at every offset while this\n * branch is only reached on an `h`. `&` stops a run purely so that an HTML\n * entity can only ever sit at offset 0 of a text node; adjacent text nodes are\n * merged by the parser, so the tree is unchanged.\n */\nconst TEXT_RUN_R = /(?:[^\\n&h!*:<=[\\\\_`~]+|h(?!ttp))*/y;\n\n/**\n * Pull a run's stop offset back before a hard line break it just swallowed.\n *\n * A run never contains a newline, so ` \\n` can only sit immediately before the\n * stop offset — which makes this O(1) check equivalent to the per-character\n * `(?! {2}\\n)` lookahead the run scanner used to carry.\n */\nconst trimHardBreak = (source: string, end: number): number =>\n end >= 3 &&\n source.charCodeAt(end) === 10 /* \\n */ &&\n source.charCodeAt(end - 1) === 32 /* space */ &&\n source.charCodeAt(end - 2) === 32\n ? end - 2\n : end;\n\nconst noopCreateElement: CreateElementFunction = (\n type,\n props,\n ...children\n) => ({\n children,\n props,\n type,\n});\n\n/**\n * Builds the rule set backing one document.\n *\n * Rules read the document's footnote and reference tables through `scope`\n * rather than closing over them, so one set serves every document sharing the\n * same options. Building this graph dominated the cost of compiling the many\n * short strings a dictionary holds; `getRuleSet` caches it.\n */\nconst createDocumentRules = (\n createElement: CreateElementFunction,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n scope: DocumentScopeRef\n): Rules => {\n const attrStringToMap = (\n tag: HTMLTag,\n str: string\n ): Record<string, any> | null => {\n if (!str?.trim()) return null;\n\n const attributes = str.match(ATTR_EXTRACTOR_R);\n\n if (!attributes) return null;\n\n return attributes.reduce((map: any, raw) => {\n const delimiterIdx = raw.indexOf('=');\n\n if (delimiterIdx !== -1) {\n const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();\n const value = unquote(raw.slice(delimiterIdx + 1).trim());\n const mappedKey = ATTRIBUTE_TO_NODE_PROP_MAP[key] ?? key;\n\n if (mappedKey === 'ref') return map;\n map[mappedKey] = attributeValueToNodePropValue(\n tag,\n key,\n value,\n ctx.sanitizer ?? defaultSanitizer\n );\n\n if (\n typeof map[mappedKey] === 'string' &&\n startsWithElement(map[mappedKey])\n ) {\n map[mappedKey] = parseMarkdown(\n map[mappedKey].trim(),\n ctx,\n options\n ).ast;\n }\n } else if (raw !== 'style' && ATTRIBUTE_NAME_START_R.test(raw)) {\n // Skips tokens that cannot name an attribute, such as the `3` or\n // `3-5` a fence's `{3,3-5}` line-highlight meta splits into.\n map[ATTRIBUTE_TO_NODE_PROP_MAP[raw] ?? raw] = true;\n }\n\n return map;\n }, {});\n };\n\n const nonParagraphBlockSyntaxes = [\n BLOCKQUOTE_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R,\n NP_TABLE_R,\n ORDERED_LIST_R,\n UNORDERED_LIST_R,\n startsWithCustomComponent,\n ];\n\n // Built once: this list is fixed for the whole parse, and rebuilding it per\n // call put a fresh array on every block-syntax probe.\n const blockSyntaxes = (\n options.disableParsingRawHTML\n ? nonParagraphBlockSyntaxes\n : [\n ...nonParagraphBlockSyntaxes,\n PARAGRAPH_R,\n startsWithHtmlBlockElement,\n HTML_COMMENT_R,\n startsWithSelfClosingElement,\n startsWithCustomComponent,\n ]\n ) as BlockSyntaxProbe[];\n\n const containsBlockSyntax = (input: string): boolean => {\n const cleaned = input.replace(TRIM_STARTING_NEWLINES, '');\n const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;\n\n if (slice.indexOf('\\n\\n') !== -1) return true;\n\n return some(blockSyntaxes, slice);\n };\n\n const baseRules = createRules(\n createElement,\n ctx,\n options,\n scope,\n attrStringToMap,\n containsBlockSyntax,\n nonParagraphBlockSyntaxes\n );\n\n return options.disableParsingRawHTML\n ? Object.keys(baseRules).reduce((acc, key) => {\n if (key !== RuleType.htmlBlock && key !== RuleType.htmlSelfClosing) {\n acc[key] = baseRules[key]!;\n }\n\n return acc;\n }, {} as Rules)\n : baseRules;\n};\n\n/** Runs the parse phase against an already-built rule set. */\nconst parseWithRules = (\n markdown: string,\n options: MarkdownOptions,\n parser: DocumentParser,\n footnotes: FootnoteDef[],\n refs: MarkdownReferences\n): ParsedMarkdown => {\n const result =\n !options.preserveFrontmatter && markdown.charCodeAt(0) === 45 /* - */\n ? markdown.replace(FRONT_MATTER_R, '')\n : markdown;\n // Stripped once and reused: both the block/inline decision and the block\n // input below need the source without its leading newlines.\n const trimmedStart =\n result.charCodeAt(0) === 10 /* \\n */\n ? result.replace(TRIM_STARTING_NEWLINES, '')\n : result;\n const inline =\n options.forceInline ||\n (!options.forceBlock &&\n SHOULD_RENDER_AS_BLOCK_R.test(trimmedStart) === false);\n\n const ast = parser(inline ? result : `${trimEnd(trimmedStart)}\\n\\n`, {\n inline,\n });\n\n if (footnotes.length > 0) {\n // Parse footnotes content as well\n for (const def of footnotes) {\n (def as any).parsedAst = parser(def.footnote, { inline: true });\n }\n }\n\n return { ast, footnotes, references: refs, inline };\n};\n\n/** Runs the render phase against an already-built rule set. */\nconst renderWithRules = (\n parsed: ParsedMarkdown,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n emitter: DocumentEmitter,\n createElement: CreateElementFunction\n): unknown => {\n const components = ctx.components ?? {};\n const slug = createSlugger(ctx);\n const footnotes = parsed.footnotes || [];\n\n const inline = parsed.inline;\n const arr = emitter(parsed.ast, { inline }) as unknown as any[];\n\n while (typeof arr[arr.length - 1] === 'string' && !arr[arr.length - 1].trim())\n arr.pop();\n\n const getOuterNode = () => {\n if (options.wrapper === null) return arr;\n const wrapper = options.wrapper ?? (inline ? 'span' : 'div');\n\n if (arr.length > 1 || options.forceWrapper)\n return createElement(wrapper, { key: 'outer' }, arr);\n\n if (arr.length === 1) {\n const node = arr[0];\n\n if (Array.isArray(node)) {\n return createElement(wrapper, { key: 'outer' }, node);\n }\n\n if (typeof node === 'string') {\n const spanProps: Record<string, any> = { key: 'outer' };\n\n if (!inline && components) {\n const pOverrideProps = (get(components, 'p.props', {}) ??\n {}) as Record<string, any>;\n const mergedClassName = cx(\n spanProps.className,\n pOverrideProps.className\n );\n const finalSpanProps: Record<string, any> = {\n ...spanProps,\n ...pOverrideProps,\n };\n\n if (mergedClassName) finalSpanProps.className = mergedClassName;\n\n return createElement('span', finalSpanProps, node);\n }\n\n return createElement('span', spanProps, node);\n }\n\n return node;\n }\n\n return createElement(wrapper, { key: 'outer' }, null);\n };\n\n const node = getOuterNode();\n\n const result = footnotes.length\n ? createElement(\n 'div',\n null,\n node,\n createElement(\n 'footer',\n { key: 'footer' },\n ...footnotes.map((def) =>\n createElement(\n 'div',\n { id: slug(def.identifier), key: def.identifier },\n def.identifier,\n emitter((def as any).parsedAst || def.footnote, { inline: true })\n )\n )\n )\n )\n : node;\n\n return result;\n};\n\nexport const parseMarkdown = (\n markdown: string = '',\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): ParsedMarkdown => {\n // Parsing never emits elements, so it gets its own cache entry built around\n // the no-op factory rather than the render one.\n const { parse, scope } = getRuleSet(ctx, options, true);\n const documentScope = createDocumentScope();\n\n return withDocumentScope(scope, documentScope, () =>\n parseWithRules(\n markdown,\n options,\n parse,\n documentScope.footnotes,\n documentScope.references\n )\n );\n};\n\nexport const renderMarkdownAst = (\n parsed: ParsedMarkdown,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): unknown => {\n const { emit, createElement, scope } = getRuleSet(ctx, options, false);\n const documentScope: DocumentScope = {\n footnotes: parsed.footnotes ?? [],\n references: parsed.references ?? {},\n };\n\n return withDocumentScope(scope, documentScope, () =>\n renderWithRules(parsed, ctx, options, emit, createElement)\n );\n};\n\nexport const compile = (\n markdown: string = '',\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): unknown => {\n if (typeof markdown !== 'string') {\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n 'intlayer: the first argument must be a string. Received',\n typeof markdown\n );\n }\n throw new Error('intlayer: the first argument must be a string');\n }\n\n // Both phases share one rule set: building it twice was the dominant cost\n // when compiling the many short strings a typical dictionary holds.\n const { parse, emit, createElement, scope } = getRuleSet(ctx, options, false);\n const documentScope = createDocumentScope();\n\n return withDocumentScope(scope, documentScope, () => {\n const parsed = parseWithRules(\n markdown,\n options,\n parse,\n documentScope.footnotes,\n documentScope.references\n );\n\n return renderWithRules(parsed, ctx, options, emit, createElement);\n });\n};\n\nexport const createCompiler =\n (ctx: MarkdownContext<any>) =>\n (markdown: string, options?: MarkdownOptions): unknown =>\n compile(markdown, ctx, options);\n\nexport const compileWithOptions = (\n markdown: string,\n runtime: MarkdownRuntime,\n options: CompileOptions<any> = {}\n): unknown => {\n const {\n components,\n namedCodesToUnicode,\n sanitizer,\n slugify,\n ...compilerOptions\n } = options;\n\n return compile(\n markdown,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;AACF;AAEA,MAAa,WACX,WAAmB,IACnB,KACA,UAA2B,CAAC,MAChB;CACZ,IAAI,OAAO,aAAa,UAAU;EAChC,6BAA6B,cAC3B,QAAQ,MACN,2DACA,OAAO,QACT;EAEF,MAAM,IAAI,MAAM,+CAA+C;CACjE;CAIA,MAAM,EAAE,OAAO,MAAM,eAAe,UAAU,WAAW,KAAK,SAAS,KAAK;CAC5E,MAAM,gBAAgB,oBAAoB;CAE1C,OAAO,kBAAkB,OAAO,qBAAqB;EACnD,MAAM,SAAS,eACb,UACA,SACA,OACA,cAAc,WACd,cAAc,UAChB;EAEA,OAAO,gBAAgB,QAAQ,KAAK,SAAS,MAAM,aAAa;CAClE,CAAC;AACH;AAEA,MAAa,kBACV,SACA,UAAkB,YACjB,QAAQ,UAAU,KAAK,OAAO;AAElC,MAAa,sBACX,UACA,SACA,UAA+B,CAAC,MACpB;CACZ,MAAM,EACJ,YACA,qBACA,WACA,SACA,GAAG,oBACD;CAEJ,OAAO,QACL,UACA;EAAE;EAAS;EAAY;EAAqB;EAAW;CAAQ,GAC/D,eACF;AACF"}
@@ -2,8 +2,8 @@ import { getCachedIntl } from "../utils/intl.mjs";
2
2
  import { getEnumeration } from "../interpreter/getEnumeration.mjs";
3
3
  import { getPlural } from "../interpreter/getPlural.mjs";
4
4
  import { getSelect } from "../interpreter/getSelect.mjs";
5
- import { icuToIntlayerFormatter } from "./ICU.mjs";
6
5
  import { i18nextToIntlayerFormatter } from "./i18next.mjs";
6
+ import { icuToIntlayerFormatter } from "./ICU.mjs";
7
7
  import { vueI18nToIntlayerFormatter } from "./vue-i18n.mjs";
8
8
  import * as NodeTypes from "@intlayer/types/nodeType";
9
9