@lobehub/ui 5.34.2 → 5.35.0

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 (103) hide show
  1. package/es/ActionIconGroup/ActionIconGroup.mjs +1 -1
  2. package/es/ActionIconGroup/ActionIconGroup.mjs.map +1 -1
  3. package/es/ActionIconGroup/type.d.mts +2 -2
  4. package/es/Alert/Alert.mjs +1 -1
  5. package/es/Alert/Alert.mjs.map +1 -1
  6. package/es/Burger/Burger.mjs +1 -1
  7. package/es/Burger/Burger.mjs.map +1 -1
  8. package/es/Burger/type.d.mts +2 -2
  9. package/es/CodeDiff/DiffPanel.mjs +1 -1
  10. package/es/CodeDiff/DiffPanel.mjs.map +1 -1
  11. package/es/CopyButton/CopyButton.mjs +1 -1
  12. package/es/CopyButton/CopyButton.mjs.map +1 -1
  13. package/es/CopyButton/type.d.mts +2 -2
  14. package/es/DownloadButton/DownloadButton.mjs +1 -1
  15. package/es/DownloadButton/DownloadButton.mjs.map +1 -1
  16. package/es/DownloadButton/type.d.mts +2 -2
  17. package/es/DraggablePanel/components/DraggablePanelHeader.mjs +1 -1
  18. package/es/DraggablePanel/components/DraggablePanelHeader.mjs.map +1 -1
  19. package/es/Drawer/Drawer.mjs +1 -1
  20. package/es/Drawer/Drawer.mjs.map +1 -1
  21. package/es/Drawer/type.d.mts +2 -2
  22. package/es/EditableText/ControlInput.d.mts +2 -2
  23. package/es/EditableText/ControlInput.mjs +1 -1
  24. package/es/EditableText/ControlInput.mjs.map +1 -1
  25. package/es/EditableText/EditableText.mjs +1 -1
  26. package/es/EditableText/EditableText.mjs.map +1 -1
  27. package/es/EmojiPicker/EmojiPicker.mjs +1 -1
  28. package/es/EmojiPicker/EmojiPicker.mjs.map +1 -1
  29. package/es/GuideCard/GuideCard.mjs +1 -1
  30. package/es/GuideCard/GuideCard.mjs.map +1 -1
  31. package/es/GuideCard/type.d.mts +2 -2
  32. package/es/Highlighter/FullFeatured.mjs +1 -1
  33. package/es/Highlighter/FullFeatured.mjs.map +1 -1
  34. package/es/Highlighter/type.d.mts +2 -2
  35. package/es/HotkeyInput/HotkeyInput.mjs +1 -1
  36. package/es/HotkeyInput/HotkeyInput.mjs.map +1 -1
  37. package/es/HtmlPreview/HtmlPreview.mjs +1 -1
  38. package/es/HtmlPreview/HtmlPreview.mjs.map +1 -1
  39. package/es/HtmlPreview/type.d.mts +2 -2
  40. package/es/Image/type.d.mts +1 -0
  41. package/es/Image/viewer/GalleryNav.mjs +1 -1
  42. package/es/Image/viewer/GalleryNav.mjs.map +1 -1
  43. package/es/Image/viewer/ImageViewer.mjs +75 -70
  44. package/es/Image/viewer/ImageViewer.mjs.map +1 -1
  45. package/es/Image/viewer/Toolbar.mjs +19 -7
  46. package/es/Image/viewer/Toolbar.mjs.map +1 -1
  47. package/es/Image/viewer/ViewerChrome.mjs +1 -1
  48. package/es/Image/viewer/ViewerChrome.mjs.map +1 -1
  49. package/es/Markdown/plugins/rehypeKatex.mjs +73 -0
  50. package/es/Markdown/plugins/rehypeKatex.mjs.map +1 -0
  51. package/es/Markdown/plugins/remarkCustomFootnotes.mjs +1 -2
  52. package/es/Markdown/plugins/remarkCustomFootnotes.mjs.map +1 -1
  53. package/es/Mermaid/FullFeatured.mjs +1 -1
  54. package/es/Mermaid/FullFeatured.mjs.map +1 -1
  55. package/es/Mermaid/type.d.mts +2 -2
  56. package/es/Modal/Modal.mjs +1 -1
  57. package/es/Modal/Modal.mjs.map +1 -1
  58. package/es/SortableList/components/DragHandle.d.mts +2 -2
  59. package/es/SortableList/components/DragHandle.mjs +1 -1
  60. package/es/SortableList/components/DragHandle.mjs.map +1 -1
  61. package/es/Tabs/Tabs.mjs +1 -1
  62. package/es/Tabs/Tabs.mjs.map +1 -1
  63. package/es/ThemeSwitch/ThemeSwitch.mjs +1 -1
  64. package/es/ThemeSwitch/ThemeSwitch.mjs.map +1 -1
  65. package/es/ThemeSwitch/type.d.mts +2 -2
  66. package/es/Toc/TocMobile.mjs +1 -1
  67. package/es/Toc/TocMobile.mjs.map +1 -1
  68. package/es/Video/index.mjs +1 -1
  69. package/es/Video/index.mjs.map +1 -1
  70. package/es/base-ui/Button/SplitButton.mjs +1 -1
  71. package/es/base-ui/Form/components/FormSubmitFooter.mjs +1 -1
  72. package/es/base-ui/Input/style.d.mts +1 -1
  73. package/es/base-ui/Modal/imperative.mjs +1 -1
  74. package/es/base-ui/Tag/Tag.mjs +1 -1
  75. package/es/base-ui/Tag/Tag.mjs.map +1 -1
  76. package/es/base-ui/Tag/style.mjs +8 -3
  77. package/es/base-ui/Tag/style.mjs.map +1 -1
  78. package/es/base-ui/Text/style.d.mts +1 -1
  79. package/es/base-ui/index.d.mts +4 -4
  80. package/es/base-ui/index.mjs +6 -6
  81. package/es/chat/ChatHeader/ChatHeader.mjs +1 -1
  82. package/es/chat/ChatHeader/ChatHeader.mjs.map +1 -1
  83. package/es/chat/EditableMessageList/EditableMessageList.mjs +1 -1
  84. package/es/chat/EditableMessageList/EditableMessageList.mjs.map +1 -1
  85. package/es/chat/TokenTag/TokenTag.mjs +1 -1
  86. package/es/chat/TokenTag/TokenTag.mjs.map +1 -1
  87. package/es/chat/TokenTag/type.d.mts +2 -2
  88. package/es/hooks/useMarkdown/useMarkdownRehypePlugins.mjs +1 -1
  89. package/es/hooks/useMarkdown/useMarkdownRehypePlugins.mjs.map +1 -1
  90. package/es/mdx/Mdx/index.mjs +1 -1
  91. package/es/mdx/Mdx/index.mjs.map +1 -1
  92. package/es/mobile/ChatHeader/ChatHeader.mjs +1 -1
  93. package/es/mobile/ChatHeader/ChatHeader.mjs.map +1 -1
  94. package/es/mobile/ChatInputArea/ChatInputArea.mjs +1 -1
  95. package/es/mobile/ChatInputArea/ChatInputArea.mjs.map +1 -1
  96. package/es/node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs +2 -2
  97. package/package.json +4 -2
  98. package/es/node_modules/.pnpm/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.mjs +0 -117
  99. package/es/node_modules/.pnpm/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.mjs.map +0 -1
  100. package/es/node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.mjs +0 -12
  101. package/es/node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.mjs.map +0 -1
  102. package/es/node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.mjs +0 -330
  103. package/es/node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.mjs.map +0 -1
@@ -1,330 +0,0 @@
1
- import { convert } from "../../../../unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.mjs";
2
- import { color } from "./color.node.mjs";
3
- //#region node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.js
4
- /**
5
- * @import {Node as UnistNode, Parent as UnistParent} from 'unist'
6
- */
7
- /**
8
- * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
9
- * Test from `unist-util-is`.
10
- *
11
- * Note: we have remove and add `undefined`, because otherwise when generating
12
- * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
13
- * which doesn’t work when publishing on npm.
14
- */
15
- /**
16
- * @typedef {(
17
- * Fn extends (value: any) => value is infer Thing
18
- * ? Thing
19
- * : Fallback
20
- * )} Predicate
21
- * Get the value of a type guard `Fn`.
22
- * @template Fn
23
- * Value; typically function that is a type guard (such as `(x): x is Y`).
24
- * @template Fallback
25
- * Value to yield if `Fn` is not a type guard.
26
- */
27
- /**
28
- * @typedef {(
29
- * Check extends null | undefined // No test.
30
- * ? Value
31
- * : Value extends {type: Check} // String (type) test.
32
- * ? Value
33
- * : Value extends Check // Partial test.
34
- * ? Value
35
- * : Check extends Function // Function test.
36
- * ? Predicate<Check, Value> extends Value
37
- * ? Predicate<Check, Value>
38
- * : never
39
- * : never // Some other test?
40
- * )} MatchesOne
41
- * Check whether a node matches a primitive check in the type system.
42
- * @template Value
43
- * Value; typically unist `Node`.
44
- * @template Check
45
- * Value; typically `unist-util-is`-compatible test, but not arrays.
46
- */
47
- /**
48
- * @typedef {(
49
- * Check extends ReadonlyArray<infer T>
50
- * ? MatchesOne<Value, T>
51
- * : Check extends Array<infer T>
52
- * ? MatchesOne<Value, T>
53
- * : MatchesOne<Value, Check>
54
- * )} Matches
55
- * Check whether a node matches a check in the type system.
56
- * @template Value
57
- * Value; typically unist `Node`.
58
- * @template Check
59
- * Value; typically `unist-util-is`-compatible test.
60
- */
61
- /**
62
- * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
63
- * Number; capped reasonably.
64
- */
65
- /**
66
- * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment
67
- * Increment a number in the type system.
68
- * @template {Uint} [I=0]
69
- * Index.
70
- */
71
- /**
72
- * @typedef {(
73
- * Node extends UnistParent
74
- * ? Node extends {children: Array<infer Children>}
75
- * ? Child extends Children ? Node : never
76
- * : never
77
- * : never
78
- * )} InternalParent
79
- * Collect nodes that can be parents of `Child`.
80
- * @template {UnistNode} Node
81
- * All node types in a tree.
82
- * @template {UnistNode} Child
83
- * Node to search for.
84
- */
85
- /**
86
- * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent
87
- * Collect nodes in `Tree` that can be parents of `Child`.
88
- * @template {UnistNode} Tree
89
- * All node types in a tree.
90
- * @template {UnistNode} Child
91
- * Node to search for.
92
- */
93
- /**
94
- * @typedef {(
95
- * Depth extends Max
96
- * ? never
97
- * :
98
- * | InternalParent<Node, Child>
99
- * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>
100
- * )} InternalAncestor
101
- * Collect nodes in `Tree` that can be ancestors of `Child`.
102
- * @template {UnistNode} Node
103
- * All node types in a tree.
104
- * @template {UnistNode} Child
105
- * Node to search for.
106
- * @template {Uint} [Max=10]
107
- * Max; searches up to this depth.
108
- * @template {Uint} [Depth=0]
109
- * Current depth.
110
- */
111
- /**
112
- * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor
113
- * Collect nodes in `Tree` that can be ancestors of `Child`.
114
- * @template {UnistNode} Tree
115
- * All node types in a tree.
116
- * @template {UnistNode} Child
117
- * Node to search for.
118
- */
119
- /**
120
- * @typedef {(
121
- * Tree extends UnistParent
122
- * ? Depth extends Max
123
- * ? Tree
124
- * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
125
- * : Tree
126
- * )} InclusiveDescendant
127
- * Collect all (inclusive) descendants of `Tree`.
128
- *
129
- * > 👉 **Note**: for performance reasons, this seems to be the fastest way to
130
- * > recurse without actually running into an infinite loop, which the
131
- * > previous version did.
132
- * >
133
- * > Practically, a max of `2` is typically enough assuming a `Root` is
134
- * > passed, but it doesn’t improve performance.
135
- * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
136
- * > Using up to `10` doesn’t hurt or help either.
137
- * @template {UnistNode} Tree
138
- * Tree type.
139
- * @template {Uint} [Max=10]
140
- * Max; searches up to this depth.
141
- * @template {Uint} [Depth=0]
142
- * Current depth.
143
- */
144
- /**
145
- * @typedef {'skip' | boolean} Action
146
- * Union of the action types.
147
- *
148
- * @typedef {number} Index
149
- * Move to the sibling at `index` next (after node itself is completely
150
- * traversed).
151
- *
152
- * Useful if mutating the tree, such as removing the node the visitor is
153
- * currently on, or any of its previous siblings.
154
- * Results less than 0 or greater than or equal to `children.length` stop
155
- * traversing the parent.
156
- *
157
- * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple
158
- * List with one or two values, the first an action, the second an index.
159
- *
160
- * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult
161
- * Any value that can be returned from a visitor.
162
- */
163
- /**
164
- * @callback Visitor
165
- * Handle a node (matching `test`, if given).
166
- *
167
- * Visitors are free to transform `node`.
168
- * They can also transform the parent of node (the last of `ancestors`).
169
- *
170
- * Replacing `node` itself, if `SKIP` is not returned, still causes its
171
- * descendants to be walked (which is a bug).
172
- *
173
- * When adding or removing previous siblings of `node` (or next siblings, in
174
- * case of reverse), the `Visitor` should return a new `Index` to specify the
175
- * sibling to traverse after `node` is traversed.
176
- * Adding or removing next siblings of `node` (or previous siblings, in case
177
- * of reverse) is handled as expected without needing to return a new `Index`.
178
- *
179
- * Removing the children property of an ancestor still results in them being
180
- * traversed.
181
- * @param {Visited} node
182
- * Found node.
183
- * @param {Array<VisitedParents>} ancestors
184
- * Ancestors of `node`.
185
- * @returns {VisitorResult}
186
- * What to do next.
187
- *
188
- * An `Index` is treated as a tuple of `[CONTINUE, Index]`.
189
- * An `Action` is treated as a tuple of `[Action]`.
190
- *
191
- * Passing a tuple back only makes sense if the `Action` is `SKIP`.
192
- * When the `Action` is `EXIT`, that action can be returned.
193
- * When the `Action` is `CONTINUE`, `Index` can be returned.
194
- * @template {UnistNode} [Visited=UnistNode]
195
- * Visited node type.
196
- * @template {UnistParent} [VisitedParents=UnistParent]
197
- * Ancestor type.
198
- */
199
- /**
200
- * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor
201
- * Build a typed `Visitor` function from a tree and a test.
202
- *
203
- * It will infer which values are passed as `node` and which as `parents`.
204
- * @template {UnistNode} [Tree=UnistNode]
205
- * Tree type.
206
- * @template {Test} [Check=Test]
207
- * Test type.
208
- */
209
- /** @type {Readonly<ActionTuple>} */
210
- const empty = [];
211
- /**
212
- * Do not traverse this node’s children.
213
- */
214
- const SKIP = "skip";
215
- /**
216
- * Visit nodes, with ancestral information.
217
- *
218
- * This algorithm performs *depth-first* *tree traversal* in *preorder*
219
- * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
220
- *
221
- * You can choose for which nodes `visitor` is called by passing a `test`.
222
- * For complex tests, you should test yourself in `visitor`, as it will be
223
- * faster and will have improved type information.
224
- *
225
- * Walking the tree is an intensive task.
226
- * Make use of the return values of the visitor when possible.
227
- * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
228
- * to check if a node matches, and then perform different operations.
229
- *
230
- * You can change the tree.
231
- * See `Visitor` for more info.
232
- *
233
- * @overload
234
- * @param {Tree} tree
235
- * @param {Check} check
236
- * @param {BuildVisitor<Tree, Check>} visitor
237
- * @param {boolean | null | undefined} [reverse]
238
- * @returns {undefined}
239
- *
240
- * @overload
241
- * @param {Tree} tree
242
- * @param {BuildVisitor<Tree>} visitor
243
- * @param {boolean | null | undefined} [reverse]
244
- * @returns {undefined}
245
- *
246
- * @param {UnistNode} tree
247
- * Tree to traverse.
248
- * @param {Visitor | Test} test
249
- * `unist-util-is`-compatible test
250
- * @param {Visitor | boolean | null | undefined} [visitor]
251
- * Handle each node.
252
- * @param {boolean | null | undefined} [reverse]
253
- * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
254
- * @returns {undefined}
255
- * Nothing.
256
- *
257
- * @template {UnistNode} Tree
258
- * Node type.
259
- * @template {Test} Check
260
- * `unist-util-is`-compatible test.
261
- */
262
- function visitParents(tree, test, visitor, reverse) {
263
- /** @type {Test} */
264
- let check;
265
- if (typeof test === "function" && typeof visitor !== "function") {
266
- reverse = visitor;
267
- visitor = test;
268
- } else check = test;
269
- const is = convert(check);
270
- const step = reverse ? -1 : 1;
271
- factory(tree, void 0, [])();
272
- /**
273
- * @param {UnistNode} node
274
- * @param {number | undefined} index
275
- * @param {Array<UnistParent>} parents
276
- */
277
- function factory(node, index, parents) {
278
- const value = node && typeof node === "object" ? node : {};
279
- if (typeof value.type === "string") {
280
- const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : void 0;
281
- Object.defineProperty(visit, "name", { value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")" });
282
- }
283
- return visit;
284
- function visit() {
285
- /** @type {Readonly<ActionTuple>} */
286
- let result = empty;
287
- /** @type {Readonly<ActionTuple>} */
288
- let subresult;
289
- /** @type {number} */
290
- let offset;
291
- /** @type {Array<UnistParent>} */
292
- let grandparents;
293
- if (!test || is(node, index, parents[parents.length - 1] || void 0)) {
294
- result = toResult(visitor(node, parents));
295
- if (result[0] === false) return result;
296
- }
297
- if ("children" in node && node.children) {
298
- const nodeAsParent = node;
299
- if (nodeAsParent.children && result[0] !== "skip") {
300
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
301
- grandparents = parents.concat(nodeAsParent);
302
- while (offset > -1 && offset < nodeAsParent.children.length) {
303
- const child = nodeAsParent.children[offset];
304
- subresult = factory(child, offset, grandparents)();
305
- if (subresult[0] === false) return subresult;
306
- offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
307
- }
308
- }
309
- }
310
- return result;
311
- }
312
- }
313
- }
314
- /**
315
- * Turn a return value into a clean result.
316
- *
317
- * @param {VisitorResult} value
318
- * Valid return values from visitors.
319
- * @returns {Readonly<ActionTuple>}
320
- * Clean result.
321
- */
322
- function toResult(value) {
323
- if (Array.isArray(value)) return value;
324
- if (typeof value === "number") return [true, value];
325
- return value === null || value === void 0 ? empty : [value];
326
- }
327
- //#endregion
328
- export { SKIP, visitParents };
329
-
330
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.js"],"sourcesContent":["/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends ReadonlyArray<infer T>\n * ? MatchesOne<Value, T>\n * : Check extends Array<infer T>\n * ? MatchesOne<Value, T>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {'skip' | boolean} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<VisitedParents>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [VisitedParents=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n * @template {UnistNode} [Tree=UnistNode]\n * Tree type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from 'unist-util-visit-parents/do-not-use-color'\n\n/** @type {Readonly<ActionTuple>} */\nconst empty = []\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} test\n * `unist-util-is`-compatible test\n * @param {Visitor | boolean | null | undefined} [visitor]\n * Handle each node.\n * @param {boolean | null | undefined} [reverse]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visitParents(tree, test, visitor, reverse) {\n /** @type {Test} */\n let check\n\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n } else {\n // @ts-expect-error visitor given, so `test` isn’t a visitor.\n check = test\n }\n\n const is = convert(check)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {UnistNode} node\n * @param {number | undefined} index\n * @param {Array<UnistParent>} parents\n */\n function factory(node, index, parents) {\n const value = /** @type {Record<string, unknown>} */ (\n node && typeof node === 'object' ? node : {}\n )\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {Readonly<ActionTuple>} */\n let result = empty\n /** @type {Readonly<ActionTuple>} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<UnistParent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || undefined)) {\n // @ts-expect-error: `visitor` is now a visitor.\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n if ('children' in node && node.children) {\n const nodeAsParent = /** @type {UnistParent} */ (node)\n\n if (nodeAsParent.children && result[0] !== SKIP) {\n offset = (reverse ? nodeAsParent.children.length : -1) + step\n grandparents = parents.concat(nodeAsParent)\n\n while (offset > -1 && offset < nodeAsParent.children.length) {\n const child = nodeAsParent.children[offset]\n\n subresult = factory(child, offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n }\n\n return result\n }\n }\n}\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {Readonly<ActionTuple>}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return value === null || value === undefined ? empty : [value]\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgOA,MAAM,QAAQ,CAAC;;;;AAef,MAAa,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDpB,SAAgB,aAAa,MAAM,MAAM,SAAS,SAAS;;CAEzD,IAAI;CAEJ,IAAI,OAAO,SAAS,cAAc,OAAO,YAAY,YAAY;EAC/D,UAAU;EAEV,UAAU;CACZ,OAEE,QAAQ;CAGV,MAAM,KAAK,QAAQ,KAAK;CACxB,MAAM,OAAO,UAAU,KAAK;CAE5B,QAAQ,MAAM,KAAA,GAAW,CAAC,CAAC,CAAC,CAAC;;;;;;CAO7B,SAAS,QAAQ,MAAM,OAAO,SAAS;EACrC,MAAM,QACJ,QAAQ,OAAO,SAAS,WAAW,OAAO,CAAC;EAG7C,IAAI,OAAO,MAAM,SAAS,UAAU;GAClC,MAAM,OAEJ,OAAO,MAAM,YAAY,WACrB,MAAM,UAEN,OAAO,MAAM,SAAS,WACpB,MAAM,OACN,KAAA;GAER,OAAO,eAAe,OAAO,QAAQ,EACnC,OACE,WAAW,MAAM,KAAK,QAAQ,OAAO,MAAM,OAAO,MAAM,GAAG,IAAI,IACnE,CAAC;EACH;EAEA,OAAO;EAEP,SAAS,QAAQ;;GAEf,IAAI,SAAS;;GAEb,IAAI;;GAEJ,IAAI;;GAEJ,IAAI;GAEJ,IAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,QAAQ,QAAQ,SAAS,MAAM,KAAA,CAAS,GAAG;IAEtE,SAAS,SAAS,QAAQ,MAAM,OAAO,CAAC;IAExC,IAAI,OAAO,OAAA,OACT,OAAO;GAEX;GAEA,IAAI,cAAc,QAAQ,KAAK,UAAU;IACvC,MAAM,eAA2C;IAEjD,IAAI,aAAa,YAAY,OAAO,OAAA,QAAa;KAC/C,UAAU,UAAU,aAAa,SAAS,SAAS,MAAM;KACzD,eAAe,QAAQ,OAAO,YAAY;KAE1C,OAAO,SAAS,MAAM,SAAS,aAAa,SAAS,QAAQ;MAC3D,MAAM,QAAQ,aAAa,SAAS;MAEpC,YAAY,QAAQ,OAAO,QAAQ,YAAY,CAAC,CAAC;MAEjD,IAAI,UAAU,OAAA,OACZ,OAAO;MAGT,SACE,OAAO,UAAU,OAAO,WAAW,UAAU,KAAK,SAAS;KAC/D;IACF;GACF;GAEA,OAAO;EACT;CACF;AACF;;;;;;;;;AAUA,SAAS,SAAS,OAAO;CACvB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAGT,IAAI,OAAO,UAAU,UACnB,OAAO,CAAA,MAAW,KAAK;CAGzB,OAAO,UAAU,QAAQ,UAAU,KAAA,IAAY,QAAQ,CAAC,KAAK;AAC/D"}