@storybook/addon-docs 9.2.0-alpha.3 → 10.0.0-beta.1

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 (63) hide show
  1. package/README.md +5 -3
  2. package/dist/_browser-chunks/Color-LWAWP22K.js +1566 -0
  3. package/dist/_browser-chunks/DocsRenderer-HT7GNKAR.js +9 -0
  4. package/dist/_browser-chunks/chunk-67KILNXL.js +6831 -0
  5. package/dist/_browser-chunks/chunk-74ZUTOZN.js +65 -0
  6. package/dist/_browser-chunks/chunk-MM7DTO55.js +44 -0
  7. package/dist/_browser-chunks/chunk-RX6225WF.js +46 -0
  8. package/dist/_browser-chunks/chunk-TQ5Q4DDG.js +846 -0
  9. package/dist/_browser-chunks/chunk-UZFOWTVP.js +974 -0
  10. package/dist/_node-chunks/chunk-6DADMWJS.js +248 -0
  11. package/dist/_node-chunks/chunk-LNIOBV3K.js +231 -0
  12. package/dist/_node-chunks/chunk-QLR5HOHE.js +48 -0
  13. package/dist/_node-chunks/chunk-YXBYQIGE.js +35424 -0
  14. package/dist/_node-chunks/mdx-plugin-NOHB7LLV.js +1653 -0
  15. package/dist/_node-chunks/rehype-external-links-D74PKVP3.js +168 -0
  16. package/dist/_node-chunks/rehype-slug-KQZG2QNC.js +127 -0
  17. package/dist/angular/index.d.ts +3 -0
  18. package/dist/angular/index.js +11 -0
  19. package/dist/blocks.d.ts +86 -42
  20. package/dist/blocks.js +8123 -201
  21. package/dist/ember/index.d.ts +3 -0
  22. package/dist/ember/index.js +11 -0
  23. package/dist/index.d.ts +42 -5
  24. package/dist/index.js +17 -15
  25. package/dist/manager.js +85 -154
  26. package/dist/mdx-loader.js +38 -71
  27. package/dist/mdx-react-shim.js +2 -0
  28. package/dist/preset.js +310 -72
  29. package/dist/preview.js +8 -13
  30. package/dist/web-components/index.d.ts +2 -0
  31. package/dist/web-components/index.js +0 -0
  32. package/manager.js +1 -1
  33. package/package.json +45 -89
  34. package/preset.js +1 -1
  35. package/preview.js +1 -1
  36. package/angular/README.md +0 -256
  37. package/angular/index.d.ts +0 -1
  38. package/angular/index.js +0 -4
  39. package/common/README.md +0 -98
  40. package/dist/Color-AVL7NMMY.mjs +0 -10
  41. package/dist/DocsContainer-fccc2203.d.ts +0 -51
  42. package/dist/DocsRenderer-3PZUHFFL.mjs +0 -2
  43. package/dist/DocsRenderer-ULRJ3H2C.mjs +0 -8
  44. package/dist/blocks.mjs +0 -213
  45. package/dist/chunk-2UFMRE4V.mjs +0 -5
  46. package/dist/chunk-CEH6MNVV.mjs +0 -3
  47. package/dist/chunk-GWJYCGSQ.mjs +0 -7
  48. package/dist/chunk-QUZPS4B6.mjs +0 -3
  49. package/dist/chunk-SPFYY5GD.mjs +0 -3
  50. package/dist/index.mjs +0 -8
  51. package/dist/preview.mjs +0 -5
  52. package/dist/shims/mdx-react-shim.js +0 -12
  53. package/dist/shims/mdx-react-shim.mjs +0 -1
  54. package/ember/README.md +0 -153
  55. package/ember/index.d.ts +0 -1
  56. package/ember/index.js +0 -3
  57. package/react/README.md +0 -149
  58. package/svelte/HOC.svelte +0 -7
  59. package/vue/README.md +0 -152
  60. package/vue3/README.md +0 -152
  61. package/web-components/README.md +0 -131
  62. package/web-components/index.js +0 -1
  63. /package/dist/{shims/mdx-react-shim.d.ts → mdx-react-shim.d.ts} +0 -0
@@ -0,0 +1,846 @@
1
+ import {
2
+ __export,
3
+ __name
4
+ } from "./chunk-MM7DTO55.js";
5
+
6
+ // ../../node_modules/tocbot/index.js
7
+ var tocbot_exports = {};
8
+ __export(tocbot_exports, {
9
+ default: () => tocbot_default,
10
+ destroy: () => destroy,
11
+ init: () => init,
12
+ refresh: () => refresh
13
+ });
14
+
15
+ // ../../node_modules/tocbot/src/js/build-html.js
16
+ function build_html_default(options) {
17
+ const forEach = [].forEach;
18
+ const some = [].some;
19
+ const body = typeof window !== "undefined" && document.body;
20
+ const SPACE_CHAR = " ";
21
+ let tocElement;
22
+ let currentlyHighlighting = true;
23
+ let eventCount = 0;
24
+ function createEl(d, container) {
25
+ const link = container.appendChild(createLink(d));
26
+ if (d.children.length) {
27
+ const list = createList(d.isCollapsed);
28
+ d.children.forEach((child) => {
29
+ createEl(child, list);
30
+ });
31
+ link.appendChild(list);
32
+ }
33
+ }
34
+ __name(createEl, "createEl");
35
+ function render(parent, data) {
36
+ const collapsed = false;
37
+ const container = createList(collapsed);
38
+ data.forEach((d) => {
39
+ createEl(d, container);
40
+ });
41
+ tocElement = parent || tocElement;
42
+ if (tocElement === null) {
43
+ return;
44
+ }
45
+ if (tocElement.firstChild) {
46
+ tocElement.removeChild(tocElement.firstChild);
47
+ }
48
+ if (data.length === 0) {
49
+ return tocElement;
50
+ }
51
+ return tocElement.appendChild(container);
52
+ }
53
+ __name(render, "render");
54
+ function createLink(data) {
55
+ const item = document.createElement("li");
56
+ const a = document.createElement("a");
57
+ if (options.listItemClass) {
58
+ item.setAttribute("class", options.listItemClass);
59
+ }
60
+ if (options.onClick) {
61
+ a.onclick = options.onClick;
62
+ }
63
+ if (options.includeTitleTags) {
64
+ a.setAttribute("title", data.textContent);
65
+ }
66
+ if (options.includeHtml && data.childNodes.length) {
67
+ forEach.call(data.childNodes, (node) => {
68
+ a.appendChild(node.cloneNode(true));
69
+ });
70
+ } else {
71
+ a.textContent = data.textContent;
72
+ }
73
+ a.setAttribute("href", `${options.basePath}#${data.id}`);
74
+ a.setAttribute(
75
+ "class",
76
+ `${options.linkClass + SPACE_CHAR}node-name--${data.nodeName}${SPACE_CHAR}${options.extraLinkClasses}`
77
+ );
78
+ item.appendChild(a);
79
+ return item;
80
+ }
81
+ __name(createLink, "createLink");
82
+ function createList(isCollapsed) {
83
+ const listElement = options.orderedList ? "ol" : "ul";
84
+ const list = document.createElement(listElement);
85
+ let classes = options.listClass + SPACE_CHAR + options.extraListClasses;
86
+ if (isCollapsed) {
87
+ classes = classes + SPACE_CHAR + options.collapsibleClass;
88
+ classes = classes + SPACE_CHAR + options.isCollapsedClass;
89
+ }
90
+ list.setAttribute("class", classes);
91
+ return list;
92
+ }
93
+ __name(createList, "createList");
94
+ function updateFixedSidebarClass() {
95
+ const scrollTop = getScrollTop();
96
+ const posFixedEl = document.querySelector(options.positionFixedSelector);
97
+ if (options.fixedSidebarOffset === "auto") {
98
+ options.fixedSidebarOffset = tocElement.offsetTop;
99
+ }
100
+ if (scrollTop > options.fixedSidebarOffset) {
101
+ if (posFixedEl.className.indexOf(options.positionFixedClass) === -1) {
102
+ posFixedEl.className += SPACE_CHAR + options.positionFixedClass;
103
+ }
104
+ } else {
105
+ posFixedEl.className = posFixedEl.className.replace(
106
+ SPACE_CHAR + options.positionFixedClass,
107
+ ""
108
+ );
109
+ }
110
+ }
111
+ __name(updateFixedSidebarClass, "updateFixedSidebarClass");
112
+ function getHeadingTopPos(obj) {
113
+ let position = 0;
114
+ if (obj !== null) {
115
+ position = obj.offsetTop;
116
+ if (options.hasInnerContainers) {
117
+ position += getHeadingTopPos(obj.offsetParent);
118
+ }
119
+ }
120
+ return position;
121
+ }
122
+ __name(getHeadingTopPos, "getHeadingTopPos");
123
+ function updateClassname(obj, className) {
124
+ if (obj && obj.className !== className) {
125
+ obj.className = className;
126
+ }
127
+ return obj;
128
+ }
129
+ __name(updateClassname, "updateClassname");
130
+ function updateToc(headingsArray, event) {
131
+ if (options.positionFixedSelector) {
132
+ updateFixedSidebarClass();
133
+ }
134
+ const headings = headingsArray;
135
+ const clickedHref = event?.target?.getAttribute ? event?.target?.getAttribute("href") : null;
136
+ const isBottomMode = clickedHref && clickedHref.charAt(0) === "#" ? getIsHeaderBottomMode(clickedHref.replace("#", "")) : false;
137
+ const shouldUpdate = currentlyHighlighting || isBottomMode;
138
+ if (event && eventCount < 5) {
139
+ eventCount++;
140
+ }
141
+ if (shouldUpdate && !!tocElement && headings.length > 0) {
142
+ const topHeader = getTopHeader(headings);
143
+ const oldActiveTocLink = tocElement.querySelector(
144
+ `.${options.activeLinkClass}`
145
+ );
146
+ const topHeaderId = topHeader.id.replace(
147
+ /([ #;&,.+*~':"!^$[\]()=>|/\\@])/g,
148
+ "\\$1"
149
+ );
150
+ const hashId = window.location.hash.replace("#", "");
151
+ let activeId = topHeaderId;
152
+ const isPageBottomMode = getIsPageBottomMode();
153
+ if (clickedHref && isBottomMode) {
154
+ activeId = clickedHref.replace("#", "");
155
+ } else if (hashId && hashId !== topHeaderId && isPageBottomMode && (getIsHeaderBottomMode(topHeaderId) || eventCount <= 2)) {
156
+ activeId = hashId;
157
+ }
158
+ const activeTocLink = tocElement.querySelector(
159
+ `.${options.linkClass}[href="${options.basePath}#${activeId}"]`
160
+ );
161
+ if (oldActiveTocLink === activeTocLink) {
162
+ return;
163
+ }
164
+ const tocLinks = tocElement.querySelectorAll(`.${options.linkClass}`);
165
+ forEach.call(tocLinks, (tocLink) => {
166
+ updateClassname(
167
+ tocLink,
168
+ tocLink.className.replace(SPACE_CHAR + options.activeLinkClass, "")
169
+ );
170
+ });
171
+ const tocLis = tocElement.querySelectorAll(`.${options.listItemClass}`);
172
+ forEach.call(tocLis, (tocLi) => {
173
+ updateClassname(
174
+ tocLi,
175
+ tocLi.className.replace(SPACE_CHAR + options.activeListItemClass, "")
176
+ );
177
+ });
178
+ if (activeTocLink && activeTocLink.className.indexOf(options.activeLinkClass) === -1) {
179
+ activeTocLink.className += SPACE_CHAR + options.activeLinkClass;
180
+ }
181
+ const li = activeTocLink?.parentNode;
182
+ if (li && li.className.indexOf(options.activeListItemClass) === -1) {
183
+ li.className += SPACE_CHAR + options.activeListItemClass;
184
+ }
185
+ const tocLists = tocElement.querySelectorAll(
186
+ `.${options.listClass}.${options.collapsibleClass}`
187
+ );
188
+ forEach.call(tocLists, (list) => {
189
+ if (list.className.indexOf(options.isCollapsedClass) === -1) {
190
+ list.className += SPACE_CHAR + options.isCollapsedClass;
191
+ }
192
+ });
193
+ if (activeTocLink?.nextSibling && activeTocLink.nextSibling.className.indexOf(
194
+ options.isCollapsedClass
195
+ ) !== -1) {
196
+ updateClassname(
197
+ activeTocLink.nextSibling,
198
+ activeTocLink.nextSibling.className.replace(
199
+ SPACE_CHAR + options.isCollapsedClass,
200
+ ""
201
+ )
202
+ );
203
+ }
204
+ removeCollapsedFromParents(activeTocLink?.parentNode.parentNode);
205
+ }
206
+ }
207
+ __name(updateToc, "updateToc");
208
+ function removeCollapsedFromParents(element) {
209
+ if (element && element.className.indexOf(options.collapsibleClass) !== -1 && element.className.indexOf(options.isCollapsedClass) !== -1) {
210
+ updateClassname(
211
+ element,
212
+ element.className.replace(SPACE_CHAR + options.isCollapsedClass, "")
213
+ );
214
+ return removeCollapsedFromParents(element.parentNode.parentNode);
215
+ }
216
+ return element;
217
+ }
218
+ __name(removeCollapsedFromParents, "removeCollapsedFromParents");
219
+ function disableTocAnimation(event) {
220
+ const target = event.target || event.srcElement;
221
+ if (typeof target.className !== "string" || target.className.indexOf(options.linkClass) === -1) {
222
+ return;
223
+ }
224
+ currentlyHighlighting = false;
225
+ }
226
+ __name(disableTocAnimation, "disableTocAnimation");
227
+ function enableTocAnimation() {
228
+ currentlyHighlighting = true;
229
+ }
230
+ __name(enableTocAnimation, "enableTocAnimation");
231
+ function getCurrentlyHighlighting() {
232
+ return currentlyHighlighting;
233
+ }
234
+ __name(getCurrentlyHighlighting, "getCurrentlyHighlighting");
235
+ function getIsHeaderBottomMode(headerId) {
236
+ const scrollEl = getScrollEl();
237
+ const activeHeading = document?.getElementById(headerId);
238
+ const isBottomMode = activeHeading.offsetTop > scrollEl.offsetHeight - scrollEl.clientHeight * 1.4 - options.bottomModeThreshold;
239
+ return isBottomMode;
240
+ }
241
+ __name(getIsHeaderBottomMode, "getIsHeaderBottomMode");
242
+ function getIsPageBottomMode() {
243
+ const scrollEl = getScrollEl();
244
+ const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
245
+ const isBottomMode = getScrollTop() + scrollEl.clientHeight > scrollEl.offsetHeight - options.bottomModeThreshold;
246
+ return isScrollable && isBottomMode;
247
+ }
248
+ __name(getIsPageBottomMode, "getIsPageBottomMode");
249
+ function getScrollEl() {
250
+ let el;
251
+ if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
252
+ el = document.querySelector(options.scrollContainer);
253
+ } else {
254
+ el = document.documentElement || body;
255
+ }
256
+ return el;
257
+ }
258
+ __name(getScrollEl, "getScrollEl");
259
+ function getScrollTop() {
260
+ const el = getScrollEl();
261
+ return el?.scrollTop || 0;
262
+ }
263
+ __name(getScrollTop, "getScrollTop");
264
+ function getTopHeader(headings, scrollTop = getScrollTop()) {
265
+ let topHeader;
266
+ some.call(headings, (heading, i) => {
267
+ if (getHeadingTopPos(heading) > scrollTop + options.headingsOffset + 10) {
268
+ const index = i === 0 ? i : i - 1;
269
+ topHeader = headings[index];
270
+ return true;
271
+ }
272
+ if (i === headings.length - 1) {
273
+ topHeader = headings[headings.length - 1];
274
+ return true;
275
+ }
276
+ });
277
+ return topHeader;
278
+ }
279
+ __name(getTopHeader, "getTopHeader");
280
+ function updateUrlHashForHeader(headingsArray) {
281
+ const scrollTop = getScrollTop();
282
+ const topHeader = getTopHeader(headingsArray, scrollTop);
283
+ const isPageBottomMode = getIsPageBottomMode();
284
+ if ((!topHeader || scrollTop < 5) && !isPageBottomMode) {
285
+ if (!(window.location.hash === "#" || window.location.hash === "")) {
286
+ window.history.pushState(null, null, "#");
287
+ }
288
+ } else if (topHeader && !isPageBottomMode) {
289
+ const newHash = `#${topHeader.id}`;
290
+ if (window.location.hash !== newHash) {
291
+ window.history.pushState(null, null, newHash);
292
+ }
293
+ }
294
+ }
295
+ __name(updateUrlHashForHeader, "updateUrlHashForHeader");
296
+ return {
297
+ enableTocAnimation,
298
+ disableTocAnimation,
299
+ render,
300
+ updateToc,
301
+ getCurrentlyHighlighting,
302
+ getTopHeader,
303
+ getScrollTop,
304
+ updateUrlHashForHeader
305
+ };
306
+ }
307
+ __name(build_html_default, "default");
308
+
309
+ // ../../node_modules/tocbot/src/js/default-options.js
310
+ var default_options_default = {
311
+ // Where to render the table of contents.
312
+ tocSelector: ".js-toc",
313
+ // Or, you can pass in a DOM node instead
314
+ tocElement: null,
315
+ // Where to grab the headings to build the table of contents.
316
+ contentSelector: ".js-toc-content",
317
+ // Or, you can pass in a DOM node instead
318
+ contentElement: null,
319
+ // Which headings to grab inside of the contentSelector element.
320
+ headingSelector: "h1, h2, h3",
321
+ // Headings that match the ignoreSelector will be skipped.
322
+ ignoreSelector: ".js-toc-ignore",
323
+ // For headings inside relative or absolute positioned
324
+ // containers within content.
325
+ hasInnerContainers: false,
326
+ // Main class to add to links.
327
+ linkClass: "toc-link",
328
+ // Extra classes to add to links.
329
+ extraLinkClasses: "",
330
+ // Class to add to active links,
331
+ // the link corresponding to the top most heading on the page.
332
+ activeLinkClass: "is-active-link",
333
+ // Main class to add to lists.
334
+ listClass: "toc-list",
335
+ // Extra classes to add to lists.
336
+ extraListClasses: "",
337
+ // Class that gets added when a list should be collapsed.
338
+ isCollapsedClass: "is-collapsed",
339
+ // Class that gets added when a list should be able
340
+ // to be collapsed but isn't necessarily collapsed.
341
+ collapsibleClass: "is-collapsible",
342
+ // Class to add to list items.
343
+ listItemClass: "toc-list-item",
344
+ // Class to add to active list items.
345
+ activeListItemClass: "is-active-li",
346
+ // How many heading levels should not be collapsed.
347
+ // For example, number 6 will show everything since
348
+ // there are only 6 heading levels and number 0 will collapse them all.
349
+ // The sections that are hidden will open
350
+ // and close as you scroll to headings within them.
351
+ collapseDepth: 0,
352
+ // Smooth scrolling enabled.
353
+ scrollSmooth: true,
354
+ // Smooth scroll duration.
355
+ scrollSmoothDuration: 420,
356
+ // Smooth scroll offset.
357
+ scrollSmoothOffset: 0,
358
+ // Callback for scroll end.
359
+ scrollEndCallback: /* @__PURE__ */ __name(function(e) {
360
+ }, "scrollEndCallback"),
361
+ // Headings offset between the headings and the top of
362
+ // the document (this is meant for minor adjustments).
363
+ headingsOffset: 1,
364
+ // Enable the URL hash to update with the proper heading ID as
365
+ // a user scrolls the page.
366
+ enableUrlHashUpdateOnScroll: false,
367
+ // type of scroll handler to use. to make scroll event not too rapid.
368
+ // Options are: "debounce" or "throttle"
369
+ // when set auto , use debounce less than 333ms , other use throttle.
370
+ // for ios browser can't use history.pushState() more than 100 times per 30 seconds reason
371
+ scrollHandlerType: "auto",
372
+ // scrollHandler delay in ms.
373
+ scrollHandlerTimeout: 50,
374
+ // Timeout between events firing to make sure it's
375
+ // not too rapid (for performance reasons).
376
+ throttleTimeout: 50,
377
+ // Element to add the positionFixedClass to.
378
+ positionFixedSelector: null,
379
+ // Fixed position class to add to make sidebar fixed after scrolling
380
+ // down past the fixedSidebarOffset.
381
+ positionFixedClass: "is-position-fixed",
382
+ // fixedSidebarOffset can be any number but by default is set
383
+ // to auto which sets the fixedSidebarOffset to the sidebar
384
+ // element's offsetTop from the top of the document on init.
385
+ fixedSidebarOffset: "auto",
386
+ // includeHtml can be set to true to include the HTML markup from the
387
+ // heading node instead of just including the innerText.
388
+ includeHtml: false,
389
+ // includeTitleTags automatically sets the html title tag of the link
390
+ // to match the title. This can be useful for SEO purposes or
391
+ // when truncating titles.
392
+ includeTitleTags: false,
393
+ // onclick function to apply to all links in toc. will be called with
394
+ // the event as the first parameter, and this can be used to stop,
395
+ // propagation, prevent default or perform action
396
+ onClick: /* @__PURE__ */ __name(function(e) {
397
+ }, "onClick"),
398
+ // orderedList can be set to false to generate unordered lists (ul)
399
+ // instead of ordered lists (ol)
400
+ orderedList: true,
401
+ // If there is a fixed article scroll container, set to calculate offset.
402
+ scrollContainer: null,
403
+ // prevent ToC DOM rendering if it's already rendered by an external system.
404
+ skipRendering: false,
405
+ // Optional callback to change heading labels.
406
+ // For example it can be used to cut down and put ellipses on multiline headings you deem too long.
407
+ // Called each time a heading is parsed. Expects a string and returns the modified label to display.
408
+ // Additionally, the attribute `data-heading-label` may be used on a heading to specify
409
+ // a shorter string to be used in the TOC.
410
+ // function (string) => string
411
+ headingLabelCallback: false,
412
+ // ignore headings that are hidden in DOM
413
+ ignoreHiddenElements: false,
414
+ // Optional callback to modify properties of parsed headings.
415
+ // The heading element is passed in node parameter and information
416
+ // parsed by default parser is provided in obj parameter.
417
+ // Function has to return the same or modified obj.
418
+ // The heading will be excluded from TOC if nothing is returned.
419
+ // function (object, HTMLElement) => object | void
420
+ headingObjectCallback: null,
421
+ // Set the base path, useful if you use a `base` tag in `head`.
422
+ basePath: "",
423
+ // Only takes affect when `tocSelector` is scrolling,
424
+ // keep the toc scroll position in sync with the content.
425
+ disableTocScrollSync: false,
426
+ // If this is null then just use `tocElement` or `tocSelector` instead
427
+ // assuming `disableTocScrollSync` is set to false. This allows for
428
+ // scrolling an outer element (like a nav panel w/ search) containing the toc.
429
+ // Please pass an element, not a selector here.
430
+ tocScrollingWrapper: null,
431
+ // Offset for the toc scroll (top) position when scrolling the page.
432
+ // Only effective if `disableTocScrollSync` is false.
433
+ tocScrollOffset: 30,
434
+ // Threshold for when bottom mode should be enabled to handle
435
+ // highlighting links that cannot be scrolled to.
436
+ bottomModeThreshold: 30
437
+ };
438
+
439
+ // ../../node_modules/tocbot/src/js/parse-content.js
440
+ function parseContent(options) {
441
+ const reduce = [].reduce;
442
+ function getLastItem(array) {
443
+ return array[array.length - 1];
444
+ }
445
+ __name(getLastItem, "getLastItem");
446
+ function getHeadingLevel(heading) {
447
+ return +heading.nodeName.toUpperCase().replace("H", "");
448
+ }
449
+ __name(getHeadingLevel, "getHeadingLevel");
450
+ function isHTMLElement(maybeElement) {
451
+ try {
452
+ return maybeElement instanceof window.HTMLElement || maybeElement instanceof window.parent.HTMLElement;
453
+ } catch (e) {
454
+ return maybeElement instanceof window.HTMLElement;
455
+ }
456
+ }
457
+ __name(isHTMLElement, "isHTMLElement");
458
+ function getHeadingObject(heading) {
459
+ if (!isHTMLElement(heading)) return heading;
460
+ if (options.ignoreHiddenElements && (!heading.offsetHeight || !heading.offsetParent)) {
461
+ return null;
462
+ }
463
+ const headingLabel = heading.getAttribute("data-heading-label") || (options.headingLabelCallback ? String(options.headingLabelCallback(heading.innerText)) : (heading.innerText || heading.textContent).trim());
464
+ const obj = {
465
+ id: heading.id,
466
+ children: [],
467
+ nodeName: heading.nodeName,
468
+ headingLevel: getHeadingLevel(heading),
469
+ textContent: headingLabel
470
+ };
471
+ if (options.includeHtml) {
472
+ obj.childNodes = heading.childNodes;
473
+ }
474
+ if (options.headingObjectCallback) {
475
+ return options.headingObjectCallback(obj, heading);
476
+ }
477
+ return obj;
478
+ }
479
+ __name(getHeadingObject, "getHeadingObject");
480
+ function addNode(node, nest) {
481
+ const obj = getHeadingObject(node);
482
+ const level = obj.headingLevel;
483
+ let array = nest;
484
+ let lastItem = getLastItem(array);
485
+ const lastItemLevel = lastItem ? lastItem.headingLevel : 0;
486
+ let counter = level - lastItemLevel;
487
+ while (counter > 0) {
488
+ lastItem = getLastItem(array);
489
+ if (lastItem && level === lastItem.headingLevel) {
490
+ break;
491
+ } else if (lastItem && lastItem.children !== void 0) {
492
+ array = lastItem.children;
493
+ }
494
+ counter--;
495
+ }
496
+ if (level >= options.collapseDepth) {
497
+ obj.isCollapsed = true;
498
+ }
499
+ array.push(obj);
500
+ return array;
501
+ }
502
+ __name(addNode, "addNode");
503
+ function selectHeadings(contentElement, headingSelector) {
504
+ let selectors = headingSelector;
505
+ if (options.ignoreSelector) {
506
+ selectors = headingSelector.split(",").map(/* @__PURE__ */ __name(function mapSelectors(selector) {
507
+ return `${selector.trim()}:not(${options.ignoreSelector})`;
508
+ }, "mapSelectors"));
509
+ }
510
+ try {
511
+ return contentElement.querySelectorAll(selectors);
512
+ } catch (e) {
513
+ console.warn(`Headers not found with selector: ${selectors}`);
514
+ return null;
515
+ }
516
+ }
517
+ __name(selectHeadings, "selectHeadings");
518
+ function nestHeadingsArray(headingsArray) {
519
+ return reduce.call(
520
+ headingsArray,
521
+ /* @__PURE__ */ __name(function reducer(prev, curr) {
522
+ const currentHeading = getHeadingObject(curr);
523
+ if (currentHeading) {
524
+ addNode(currentHeading, prev.nest);
525
+ }
526
+ return prev;
527
+ }, "reducer"),
528
+ {
529
+ nest: []
530
+ }
531
+ );
532
+ }
533
+ __name(nestHeadingsArray, "nestHeadingsArray");
534
+ return {
535
+ nestHeadingsArray,
536
+ selectHeadings
537
+ };
538
+ }
539
+ __name(parseContent, "parseContent");
540
+
541
+ // ../../node_modules/tocbot/src/js/scroll-smooth/index.js
542
+ function initSmoothScrolling(options) {
543
+ var duration = options.duration;
544
+ var offset = options.offset;
545
+ if (typeof window === "undefined" || typeof location === "undefined") return;
546
+ var pageUrl = location.hash ? stripHash(location.href) : location.href;
547
+ delegatedLinkHijacking();
548
+ function delegatedLinkHijacking() {
549
+ document.body.addEventListener("click", onClick, false);
550
+ function onClick(e) {
551
+ if (!isInPageLink(e.target) || e.target.className.indexOf("no-smooth-scroll") > -1 || e.target.href.charAt(e.target.href.length - 2) === "#" && e.target.href.charAt(e.target.href.length - 1) === "!" || e.target.className.indexOf(options.linkClass) === -1) {
552
+ return;
553
+ }
554
+ jump(e.target.hash, {
555
+ duration,
556
+ offset,
557
+ callback: /* @__PURE__ */ __name(function() {
558
+ setFocus(e.target.hash);
559
+ }, "callback")
560
+ });
561
+ }
562
+ __name(onClick, "onClick");
563
+ }
564
+ __name(delegatedLinkHijacking, "delegatedLinkHijacking");
565
+ function isInPageLink(n) {
566
+ return n.tagName.toLowerCase() === "a" && (n.hash.length > 0 || n.href.charAt(n.href.length - 1) === "#") && (stripHash(n.href) === pageUrl || stripHash(n.href) + "#" === pageUrl);
567
+ }
568
+ __name(isInPageLink, "isInPageLink");
569
+ function stripHash(url) {
570
+ return url.slice(0, url.lastIndexOf("#"));
571
+ }
572
+ __name(stripHash, "stripHash");
573
+ function setFocus(hash) {
574
+ var element = document.getElementById(hash.substring(1));
575
+ if (element) {
576
+ if (!/^(?:a|select|input|button|textarea)$/i.test(element.tagName)) {
577
+ element.tabIndex = -1;
578
+ }
579
+ element.focus();
580
+ }
581
+ }
582
+ __name(setFocus, "setFocus");
583
+ }
584
+ __name(initSmoothScrolling, "initSmoothScrolling");
585
+ function jump(target, options) {
586
+ var start = window.pageYOffset;
587
+ var opt = {
588
+ duration: options.duration,
589
+ offset: options.offset || 0,
590
+ callback: options.callback,
591
+ easing: options.easing || easeInOutQuad
592
+ };
593
+ var tgt = document.querySelector(
594
+ '[id="' + decodeURI(target).split("#").join("") + '"]'
595
+ ) || document.querySelector('[id="' + target.split("#").join("") + '"]');
596
+ var distance = typeof target === "string" ? opt.offset + (target ? tgt && tgt.getBoundingClientRect().top || 0 : -(document.documentElement.scrollTop || document.body.scrollTop)) : target;
597
+ var duration = typeof opt.duration === "function" ? opt.duration(distance) : opt.duration;
598
+ var timeStart;
599
+ var timeElapsed;
600
+ requestAnimationFrame(function(time) {
601
+ timeStart = time;
602
+ loop(time);
603
+ });
604
+ function loop(time) {
605
+ timeElapsed = time - timeStart;
606
+ window.scrollTo(0, opt.easing(timeElapsed, start, distance, duration));
607
+ if (timeElapsed < duration) {
608
+ requestAnimationFrame(loop);
609
+ } else {
610
+ end();
611
+ }
612
+ }
613
+ __name(loop, "loop");
614
+ function end() {
615
+ window.scrollTo(0, start + distance);
616
+ if (typeof opt.callback === "function") {
617
+ opt.callback();
618
+ }
619
+ }
620
+ __name(end, "end");
621
+ function easeInOutQuad(t, b, c, d) {
622
+ t /= d / 2;
623
+ if (t < 1) return c / 2 * t * t + b;
624
+ t--;
625
+ return -c / 2 * (t * (t - 2) - 1) + b;
626
+ }
627
+ __name(easeInOutQuad, "easeInOutQuad");
628
+ }
629
+ __name(jump, "jump");
630
+
631
+ // ../../node_modules/tocbot/src/js/update-toc-scroll.js
632
+ function updateTocScroll(options) {
633
+ const toc = options.tocScrollingWrapper || options.tocElement || document.querySelector(options.tocSelector);
634
+ if (toc && toc.scrollHeight > toc.clientHeight) {
635
+ const activeItem = toc.querySelector(`.${options.activeListItemClass}`);
636
+ if (activeItem) {
637
+ const eTop = activeItem.offsetTop;
638
+ const scrollAmount = eTop - options.tocScrollOffset;
639
+ toc.scrollTop = scrollAmount > 0 ? scrollAmount : 0;
640
+ }
641
+ }
642
+ }
643
+ __name(updateTocScroll, "updateTocScroll");
644
+
645
+ // ../../node_modules/tocbot/src/js/index-esm.js
646
+ var _options = {};
647
+ var _buildHtml;
648
+ var _parseContent;
649
+ var _headingsArray;
650
+ var _scrollListener;
651
+ var clickListener;
652
+ function init(customOptions) {
653
+ let hasInitialized = false;
654
+ _options = extend(default_options_default, customOptions || {});
655
+ if (_options.scrollSmooth) {
656
+ _options.duration = _options.scrollSmoothDuration;
657
+ _options.offset = _options.scrollSmoothOffset;
658
+ initSmoothScrolling(_options);
659
+ }
660
+ _buildHtml = build_html_default(_options);
661
+ _parseContent = parseContent(_options);
662
+ destroy();
663
+ const contentElement = getContentElement(_options);
664
+ if (contentElement === null) {
665
+ return;
666
+ }
667
+ const tocElement = getTocElement(_options);
668
+ if (tocElement === null) {
669
+ return;
670
+ }
671
+ _headingsArray = _parseContent.selectHeadings(
672
+ contentElement,
673
+ _options.headingSelector
674
+ );
675
+ if (_headingsArray === null) {
676
+ return;
677
+ }
678
+ const nestedHeadingsObj = _parseContent.nestHeadingsArray(_headingsArray);
679
+ const nestedHeadings = nestedHeadingsObj.nest;
680
+ if (!_options.skipRendering) {
681
+ _buildHtml.render(tocElement, nestedHeadings);
682
+ } else {
683
+ return this;
684
+ }
685
+ let isClick = false;
686
+ const scrollHandlerTimeout = _options.scrollHandlerTimeout || _options.throttleTimeout;
687
+ const scrollHandler = /* @__PURE__ */ __name((fn, delay) => getScrollHandler(fn, delay, _options.scrollHandlerType), "scrollHandler");
688
+ _scrollListener = scrollHandler((e) => {
689
+ _buildHtml.updateToc(_headingsArray, e);
690
+ !_options.disableTocScrollSync && !isClick && updateTocScroll(_options);
691
+ if (_options.enableUrlHashUpdateOnScroll && hasInitialized) {
692
+ const enableUpdatingHash = _buildHtml.getCurrentlyHighlighting();
693
+ enableUpdatingHash && _buildHtml.updateUrlHashForHeader(_headingsArray);
694
+ }
695
+ const isTop = e?.target?.scrollingElement?.scrollTop === 0;
696
+ if (e && (e.eventPhase === 0 || e.currentTarget === null) || isTop) {
697
+ _buildHtml.updateToc(_headingsArray);
698
+ _options.scrollEndCallback?.(e);
699
+ }
700
+ }, scrollHandlerTimeout);
701
+ if (!hasInitialized) {
702
+ _scrollListener();
703
+ hasInitialized = true;
704
+ }
705
+ window.onhashchange = window.onscrollend = (e) => {
706
+ _scrollListener(e);
707
+ };
708
+ if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
709
+ document.querySelector(_options.scrollContainer).addEventListener("scroll", _scrollListener, false);
710
+ document.querySelector(_options.scrollContainer).addEventListener("resize", _scrollListener, false);
711
+ } else {
712
+ document.addEventListener("scroll", _scrollListener, false);
713
+ document.addEventListener("resize", _scrollListener, false);
714
+ }
715
+ let timeout = null;
716
+ clickListener = throttle((event) => {
717
+ isClick = true;
718
+ if (_options.scrollSmooth) {
719
+ _buildHtml.disableTocAnimation(event);
720
+ }
721
+ _buildHtml.updateToc(_headingsArray, event);
722
+ timeout && clearTimeout(timeout);
723
+ timeout = setTimeout(() => {
724
+ _buildHtml.enableTocAnimation();
725
+ }, _options.scrollSmoothDuration);
726
+ setTimeout(() => {
727
+ isClick = false;
728
+ }, _options.scrollSmoothDuration + 100);
729
+ }, _options.throttleTimeout);
730
+ if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
731
+ document.querySelector(_options.scrollContainer).addEventListener("click", clickListener, false);
732
+ } else {
733
+ document.addEventListener("click", clickListener, false);
734
+ }
735
+ }
736
+ __name(init, "init");
737
+ function destroy() {
738
+ const tocElement = getTocElement(_options);
739
+ if (tocElement === null) {
740
+ return;
741
+ }
742
+ if (!_options.skipRendering) {
743
+ if (tocElement) {
744
+ tocElement.innerHTML = "";
745
+ }
746
+ }
747
+ if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
748
+ document.querySelector(_options.scrollContainer).removeEventListener("scroll", _scrollListener, false);
749
+ document.querySelector(_options.scrollContainer).removeEventListener("resize", _scrollListener, false);
750
+ if (_buildHtml) {
751
+ document.querySelector(_options.scrollContainer).removeEventListener("click", clickListener, false);
752
+ }
753
+ } else {
754
+ document.removeEventListener("scroll", _scrollListener, false);
755
+ document.removeEventListener("resize", _scrollListener, false);
756
+ if (_buildHtml) {
757
+ document.removeEventListener("click", clickListener, false);
758
+ }
759
+ }
760
+ }
761
+ __name(destroy, "destroy");
762
+ function refresh(customOptions) {
763
+ destroy();
764
+ init(customOptions || _options);
765
+ }
766
+ __name(refresh, "refresh");
767
+ var hasOwnProp = Object.prototype.hasOwnProperty;
768
+ function extend(...args) {
769
+ const target = {};
770
+ for (let i = 0; i < args.length; i++) {
771
+ const source = args[i];
772
+ for (const key in source) {
773
+ if (hasOwnProp.call(source, key)) {
774
+ target[key] = source[key];
775
+ }
776
+ }
777
+ }
778
+ return target;
779
+ }
780
+ __name(extend, "extend");
781
+ function throttle(fn, threshold, scope) {
782
+ threshold || (threshold = 250);
783
+ let last;
784
+ let deferTimer;
785
+ return function(...args) {
786
+ const context = scope || this;
787
+ const now = +/* @__PURE__ */ new Date();
788
+ if (last && now < last + threshold) {
789
+ clearTimeout(deferTimer);
790
+ deferTimer = setTimeout(() => {
791
+ last = now;
792
+ fn.apply(context, args);
793
+ }, threshold);
794
+ } else {
795
+ last = now;
796
+ fn.apply(context, args);
797
+ }
798
+ };
799
+ }
800
+ __name(throttle, "throttle");
801
+ function debounce(func, wait) {
802
+ let timeout;
803
+ return (...args) => {
804
+ clearTimeout(timeout);
805
+ timeout = setTimeout(() => func.apply(this, args), wait);
806
+ };
807
+ }
808
+ __name(debounce, "debounce");
809
+ function getScrollHandler(func, timeout, type = "auto") {
810
+ switch (type) {
811
+ case "debounce":
812
+ return debounce(func, timeout);
813
+ case "throttle":
814
+ return throttle(func, timeout);
815
+ default:
816
+ return timeout < 334 ? debounce(func, timeout) : throttle(func, timeout);
817
+ }
818
+ }
819
+ __name(getScrollHandler, "getScrollHandler");
820
+ function getContentElement(options) {
821
+ try {
822
+ return options.contentElement || document.querySelector(options.contentSelector);
823
+ } catch (e) {
824
+ console.warn(`Contents element not found: ${options.contentSelector}`);
825
+ return null;
826
+ }
827
+ }
828
+ __name(getContentElement, "getContentElement");
829
+ function getTocElement(options) {
830
+ try {
831
+ return options.tocElement || document.querySelector(options.tocSelector);
832
+ } catch (e) {
833
+ console.warn(`TOC element not found: ${options.tocSelector}`);
834
+ return null;
835
+ }
836
+ }
837
+ __name(getTocElement, "getTocElement");
838
+
839
+ // ../../node_modules/tocbot/index.js
840
+ var tocbot = { destroy, init, refresh };
841
+ var tocbot_default = tocbot;
842
+
843
+ export {
844
+ tocbot_default,
845
+ tocbot_exports
846
+ };