@windrun-huaiin/third-ui 14.3.1 → 14.4.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 (54) hide show
  1. package/dist/fuma/fuma-page-genarator.js +3 -4
  2. package/dist/fuma/fuma-page-genarator.mjs +3 -4
  3. package/dist/fuma/mdx/index.d.ts +1 -0
  4. package/dist/fuma/mdx/index.js +5 -0
  5. package/dist/fuma/mdx/index.mjs +1 -0
  6. package/dist/fuma/mdx/toc-clerk-portable.d.ts +19 -0
  7. package/dist/fuma/mdx/toc-clerk-portable.js +328 -0
  8. package/dist/fuma/mdx/toc-clerk-portable.mjs +304 -0
  9. package/dist/main/delayed-img.js +1 -1
  10. package/dist/main/delayed-img.mjs +1 -1
  11. package/dist/main/gallery/gallery-mobile-swiper.js +2 -2
  12. package/dist/main/gallery/gallery-mobile-swiper.mjs +2 -2
  13. package/dist/main/snake-loading-frame.js +3 -3
  14. package/dist/main/snake-loading-frame.mjs +3 -3
  15. package/dist/node_modules/.pnpm/{katex@0.16.38 → katex@0.16.43}/node_modules/katex/dist/katex.js +50 -16
  16. package/dist/node_modules/.pnpm/{katex@0.16.38 → katex@0.16.43}/node_modules/katex/dist/katex.mjs +50 -16
  17. package/dist/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ABZYJK2D.js +1 -1
  18. package/dist/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ABZYJK2D.mjs +1 -1
  19. package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/swiper-core.js +2 -1
  20. package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/swiper-core.mjs +2 -1
  21. package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/swiper-react.js +2 -2
  22. package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/swiper-react.mjs +2 -2
  23. package/package.json +1 -1
  24. package/src/fuma/fuma-page-genarator.tsx +11 -5
  25. package/src/fuma/mdx/index.ts +1 -0
  26. package/src/fuma/mdx/toc-clerk-portable.tsx +623 -0
  27. package/src/main/delayed-img.tsx +0 -1
  28. package/src/main/snake-loading-frame.tsx +3 -3
  29. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/utils/use-animation-frame.js +0 -24
  30. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/utils/use-animation-frame.mjs +0 -22
  31. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/value/use-combine-values.js +0 -40
  32. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/value/use-combine-values.mjs +0 -38
  33. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/value/use-computed.js +0 -22
  34. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/value/use-computed.mjs +0 -20
  35. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/value/use-motion-value.js +0 -41
  36. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/value/use-motion-value.mjs +0 -39
  37. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/value/use-transform.js +0 -50
  38. package/dist/node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/framer-motion/dist/es/value/use-transform.mjs +0 -48
  39. package/dist/node_modules/.pnpm/motion-dom@12.38.0/node_modules/motion-dom/dist/es/utils/transform.js +0 -16
  40. package/dist/node_modules/.pnpm/motion-dom@12.38.0/node_modules/motion-dom/dist/es/utils/transform.mjs +0 -14
  41. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/modules/pagination.js +0 -0
  42. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/modules/pagination.mjs +0 -0
  43. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/classes-to-selector.js +0 -0
  44. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/classes-to-selector.mjs +0 -0
  45. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/create-element-if-not-defined.js +0 -0
  46. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/create-element-if-not-defined.mjs +0 -0
  47. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/ssr-window.esm.js +0 -0
  48. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/ssr-window.esm.mjs +0 -0
  49. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/update-on-virtual-data.js +0 -0
  50. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/update-on-virtual-data.mjs +0 -0
  51. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/update-swiper.js +0 -0
  52. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/update-swiper.mjs +0 -0
  53. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/utils.js +0 -0
  54. /package/dist/node_modules/.pnpm/{swiper@12.1.2 → swiper@12.1.3}/node_modules/swiper/shared/utils.mjs +0 -0
@@ -6,6 +6,7 @@ var page = require('fumadocs-ui/page');
6
6
  var React = require('react');
7
7
  var tocFooterWrapper = require('./mdx/toc-footer-wrapper.js');
8
8
  var lib = require('@windrun-huaiin/lib');
9
+ var tocClerkPortable = require('./mdx/toc-clerk-portable.js');
9
10
 
10
11
  function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
11
12
  const Page = function Page(_a) {
@@ -24,12 +25,10 @@ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSour
24
25
  const MDX = page$1.data.body;
25
26
  return (jsxRuntime.jsxs(page.DocsPage, { breadcrumb: { enabled: showBreadcrumb }, tableOfContent: {
26
27
  enabled: showTableOfContent,
27
- style: 'clerk',
28
28
  single: false,
29
- footer: tocFooterElement,
29
+ component: (jsxRuntime.jsx(tocClerkPortable.PortableClerkTOC, { toc: page$1.data.toc, footer: tocFooterElement })),
30
30
  }, tableOfContentPopover: {
31
- enabled: showTableOfContentPopover,
32
- footer: tocFooterElement,
31
+ enabled: false,
33
32
  }, toc: page$1.data.toc, article: { className: 'max-sm:pb-16' }, children: [jsxRuntime.jsx(page.DocsTitle, { children: page$1.data.title }), jsxRuntime.jsx(page.DocsDescription, { className: "mb-2", children: page$1.data.description }), jsxRuntime.jsx(page.DocsBody, { className: "text-fd-foreground/80", children: jsxRuntime.jsx(MDX, { components: getMDXComponents() }) })] }));
34
33
  });
35
34
  };
@@ -4,6 +4,7 @@ import { DocsPage, DocsTitle, DocsDescription, DocsBody } from 'fumadocs-ui/page
4
4
  import { cloneElement } from 'react';
5
5
  import { TocFooterWrapper } from './mdx/toc-footer-wrapper.mjs';
6
6
  import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib';
7
+ import { PortableClerkTOC } from './mdx/toc-clerk-portable.mjs';
7
8
 
8
9
  function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
9
10
  const Page = function Page(_a) {
@@ -22,12 +23,10 @@ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSour
22
23
  const MDX = page.data.body;
23
24
  return (jsxs(DocsPage, { breadcrumb: { enabled: showBreadcrumb }, tableOfContent: {
24
25
  enabled: showTableOfContent,
25
- style: 'clerk',
26
26
  single: false,
27
- footer: tocFooterElement,
27
+ component: (jsx(PortableClerkTOC, { toc: page.data.toc, footer: tocFooterElement })),
28
28
  }, tableOfContentPopover: {
29
- enabled: showTableOfContentPopover,
30
- footer: tocFooterElement,
29
+ enabled: false,
31
30
  }, toc: page.data.toc, article: { className: 'max-sm:pb-16' }, children: [jsx(DocsTitle, { children: page.data.title }), jsx(DocsDescription, { className: "mb-2", children: page.data.description }), jsx(DocsBody, { className: "text-fd-foreground/80", children: jsx(MDX, { components: getMDXComponents() }) })] }));
32
31
  });
33
32
  };
@@ -8,5 +8,6 @@ export * from './toc-base';
8
8
  export * from './fuma-github-info';
9
9
  export * from './zia-file';
10
10
  export * from './toc-footer-wrapper';
11
+ export * from './toc-clerk-portable';
11
12
  export * from './banner';
12
13
  export * from './suno-embed';
@@ -11,6 +11,7 @@ var tocBase = require('./toc-base.js');
11
11
  var fumaGithubInfo = require('./fuma-github-info.js');
12
12
  var ziaFile = require('./zia-file.js');
13
13
  var tocFooterWrapper = require('./toc-footer-wrapper.js');
14
+ var tocClerkPortable = require('./toc-clerk-portable.js');
14
15
  var banner = require('./banner.js');
15
16
  var sunoEmbed = require('./suno-embed.js');
16
17
 
@@ -29,5 +30,9 @@ exports.FumaGithubInfo = fumaGithubInfo.FumaGithubInfo;
29
30
  exports.ZiaFile = ziaFile.ZiaFile;
30
31
  exports.ZiaFolder = ziaFile.ZiaFolder;
31
32
  exports.TocFooterWrapper = tocFooterWrapper.TocFooterWrapper;
33
+ exports.PortableClerkTOC = tocClerkPortable.PortableClerkTOC;
34
+ exports.PortableClerkTOCItems = tocClerkPortable.PortableClerkTOCItems;
35
+ exports.PortableClerkTOCPopover = tocClerkPortable.PortableClerkTOCPopover;
36
+ exports.PortableClerkTOCScrollArea = tocClerkPortable.PortableClerkTOCScrollArea;
32
37
  exports.Banner = banner.Banner;
33
38
  exports.SunoEmbed = sunoEmbed.SunoEmbed;
@@ -9,5 +9,6 @@ export { EditOnGitHub, LLMCopyButton, LastUpdatedDate } from './toc-base.mjs';
9
9
  export { FumaGithubInfo } from './fuma-github-info.mjs';
10
10
  export { ZiaFile, ZiaFolder } from './zia-file.mjs';
11
11
  export { TocFooterWrapper } from './toc-footer-wrapper.mjs';
12
+ export { PortableClerkTOC, PortableClerkTOCItems, PortableClerkTOCPopover, PortableClerkTOCScrollArea } from './toc-clerk-portable.mjs';
12
13
  export { Banner } from './banner.mjs';
13
14
  export { SunoEmbed } from './suno-embed.mjs';
@@ -0,0 +1,19 @@
1
+ import * as Primitive from 'fumadocs-core/toc';
2
+ import { type ComponentProps, type ReactNode } from 'react';
3
+ type TOCItemType = Primitive.TOCItemType;
4
+ type PortableClerkTOCProps = {
5
+ toc: TOCItemType[];
6
+ header?: ReactNode;
7
+ footer?: ReactNode;
8
+ title?: ReactNode;
9
+ emptyLabel?: ReactNode;
10
+ className?: string;
11
+ };
12
+ export declare function PortableClerkTOC({ toc, header, footer, title, emptyLabel, className, }: PortableClerkTOCProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function PortableClerkTOCPopover({ toc, header, footer, emptyLabel, }: Omit<PortableClerkTOCProps, 'title' | 'className'>): import("react/jsx-runtime").JSX.Element;
14
+ export declare function PortableClerkTOCScrollArea({ ref, className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
15
+ export declare function PortableClerkTOCItems({ toc, emptyLabel, ref, className, ...props }: ComponentProps<'div'> & {
16
+ toc: TOCItemType[];
17
+ emptyLabel?: ReactNode;
18
+ }): import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,328 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var tslib_es6 = require('../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var Primitive = require('fumadocs-core/toc');
7
+ var page = require('fumadocs-ui/layouts/docs/page');
8
+ var React = require('react');
9
+ var lib = require('@windrun-huaiin/base-ui/lib');
10
+
11
+ function _interopNamespaceDefault(e) {
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var Primitive__namespace = /*#__PURE__*/_interopNamespaceDefault(Primitive);
29
+
30
+ // Base stroke width for both the inactive rail and the active highlight path.
31
+ const CLERK_PATH_STROKE_WIDTH = 1;
32
+ // Radius of the moving endpoint dot that marks the latest active heading.
33
+ const CLERK_ACTIVE_DOT_RADIUS = 2;
34
+ // Max vertical space reserved for a turn inside the gap between two headings.
35
+ const CLERK_TURN_CURVE_HEIGHT = 12;
36
+ // Multiplier for bezier control points; higher values make the turn rounder.
37
+ const CLERK_TURN_CONTROL_FACTOR = 0.68;
38
+ // Safety margin that keeps turns away from the heading rows themselves.
39
+ const CLERK_TURN_GAP_MARGIN = 7;
40
+ function PortableClerkTOC({ toc, header, footer, title, emptyLabel = 'No headings', className, }) {
41
+ return (jsxRuntime.jsxs(page.PageTOC, { className: className, children: [header, title !== null && title !== void 0 ? title : jsxRuntime.jsx(page.PageTOCTitle, {}), jsxRuntime.jsx(PortableClerkTOCScrollArea, { children: jsxRuntime.jsx(PortableClerkTOCItems, { toc: toc, emptyLabel: emptyLabel }) }), footer] }));
42
+ }
43
+ function PortableClerkTOCPopover({ toc, header, footer, emptyLabel = 'No headings', }) {
44
+ return (jsxRuntime.jsxs(page.PageTOCPopover, { children: [jsxRuntime.jsx(page.PageTOCPopoverTrigger, {}), jsxRuntime.jsxs(page.PageTOCPopoverContent, { children: [header, jsxRuntime.jsx(PortableClerkTOCScrollArea, { children: jsxRuntime.jsx(PortableClerkTOCItems, { toc: toc, emptyLabel: emptyLabel }) }), footer] })] }));
45
+ }
46
+ function PortableClerkTOCScrollArea(_a) {
47
+ var { ref, className } = _a, props = tslib_es6.__rest(_a, ["ref", "className"]);
48
+ const viewRef = React.useRef(null);
49
+ return (jsxRuntime.jsx("div", Object.assign({ ref: mergeRefs(viewRef, ref), className: cn('relative min-h-0 text-sm ms-px overflow-auto [scrollbar-width:none] mask-[linear-gradient(to_bottom,transparent,white_16px,white_calc(100%-16px),transparent)] py-3', className) }, props, { children: jsxRuntime.jsx(Primitive__namespace.ScrollProvider, { containerRef: viewRef, children: props.children }) })));
50
+ }
51
+ function PortableClerkTOCItems(_a) {
52
+ var { toc, emptyLabel = 'No headings', ref, className } = _a, props = tslib_es6.__rest(_a, ["toc", "emptyLabel", "ref", "className"]);
53
+ const containerRef = React.useRef(null);
54
+ const activeAnchors = Primitive__namespace.useActiveAnchors();
55
+ const itemRefs = React.useRef([]);
56
+ const contentRefs = React.useRef([]);
57
+ const [layout, setLayout] = React.useState({
58
+ height: 0,
59
+ items: [],
60
+ });
61
+ const metas = React.useMemo(() => toc.map(resolveClerkItem), [toc]);
62
+ const outlinePath = React.useMemo(() => buildOutlinePath(layout.items), [layout.items]);
63
+ const activeItems = React.useMemo(() => getActiveItems(layout.items, activeAnchors), [activeAnchors, layout.items]);
64
+ const activePath = React.useMemo(() => buildOutlinePath(activeItems), [activeItems]);
65
+ const activeEndpoint = React.useMemo(() => getActiveEndpoint(activeItems), [activeItems]);
66
+ React.useLayoutEffect(() => {
67
+ const container = containerRef.current;
68
+ if (!container)
69
+ return;
70
+ let frame = 0;
71
+ const updateLayout = () => {
72
+ frame = 0;
73
+ const nextItems = metas.flatMap((meta, index) => {
74
+ const element = itemRefs.current[index];
75
+ const content = contentRefs.current[index];
76
+ if (!element || !content)
77
+ return [];
78
+ const y = measureItemLineY(element, content);
79
+ return [
80
+ {
81
+ url: meta.item.url,
82
+ y,
83
+ x: meta.lineOffset,
84
+ stepNumber: meta.stepNumber,
85
+ },
86
+ ];
87
+ });
88
+ setLayout((prev) => {
89
+ const next = {
90
+ height: container.clientHeight,
91
+ items: nextItems,
92
+ };
93
+ if (isSameLayout(prev, next))
94
+ return prev;
95
+ return next;
96
+ });
97
+ };
98
+ const queueUpdate = () => {
99
+ if (frame !== 0)
100
+ cancelAnimationFrame(frame);
101
+ frame = requestAnimationFrame(updateLayout);
102
+ };
103
+ queueUpdate();
104
+ const observer = new ResizeObserver(queueUpdate);
105
+ observer.observe(container);
106
+ for (const element of itemRefs.current) {
107
+ if (element)
108
+ observer.observe(element);
109
+ }
110
+ return () => {
111
+ if (frame !== 0)
112
+ cancelAnimationFrame(frame);
113
+ observer.disconnect();
114
+ };
115
+ }, [metas]);
116
+ if (toc.length === 0) {
117
+ return (jsxRuntime.jsx("div", { className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground", children: emptyLabel }));
118
+ }
119
+ return (jsxRuntime.jsxs("div", Object.assign({ ref: mergeRefs(containerRef, ref), className: cn('relative flex flex-col', className) }, props, { children: [jsxRuntime.jsx(ClerkOutline, { path: outlinePath, items: layout.items, activePath: activePath, activeAnchors: activeAnchors, activeEndpoint: activeEndpoint }), metas.map((meta, i) => (jsxRuntime.jsx(PortableClerkTOCItem, { item: meta.item, isActive: activeAnchors.includes(meta.item.url.slice(1)), resolvedContent: meta.resolvedContent, itemPadding: meta.itemPadding, contentRef: (node) => {
120
+ contentRefs.current[i] = node;
121
+ }, ref: (node) => {
122
+ itemRefs.current[i] = node;
123
+ } }, meta.item.url)))] })));
124
+ }
125
+ function PortableClerkTOCItem({ item, isActive, resolvedContent, itemPadding, contentRef, ref, }) {
126
+ return (jsxRuntime.jsx(Primitive__namespace.TOCItem, { ref: ref, href: item.url, "data-clerk-item": "", style: {
127
+ paddingInlineStart: itemPadding,
128
+ }, className: cn('prose group relative py-1.5 text-sm transition-colors wrap-anywhere first:pt-0 last:pb-0 hover:text-fd-accent-foreground', isActive ? lib.themeIconColor : 'text-fd-muted-foreground'), children: jsxRuntime.jsx("span", { ref: contentRef, className: "relative z-10", children: resolvedContent }) }));
129
+ }
130
+ function ClerkOutline({ path, items, activePath, activeAnchors, activeEndpoint, }) {
131
+ if (!path)
132
+ return null;
133
+ const activeSet = new Set(activeAnchors);
134
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("svg", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-0 overflow-visible", width: "100%", height: "100%", children: jsxRuntime.jsx("path", { d: path, className: "stroke-fd-foreground/15", fill: "none", strokeWidth: CLERK_PATH_STROKE_WIDTH, strokeLinecap: "round", strokeLinejoin: "round" }) }), jsxRuntime.jsx("svg", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-0 overflow-visible", width: "100%", height: "100%", children: activePath ? (jsxRuntime.jsx("path", { d: activePath, fill: "none", strokeWidth: CLERK_PATH_STROKE_WIDTH, strokeLinecap: "round", strokeLinejoin: "round", stroke: lib.themeSvgIconColor })) : null }), jsxRuntime.jsx("svg", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-0 overflow-visible", width: "100%", height: "100%", children: activeEndpoint ? (jsxRuntime.jsx("circle", { cx: activeEndpoint.x, cy: activeEndpoint.y, r: CLERK_ACTIVE_DOT_RADIUS, fill: lib.themeSvgIconColor })) : null }), jsxRuntime.jsx("svg", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-1 overflow-visible", width: "100%", height: "100%", children: items.map((item) => {
135
+ if (!item.stepNumber)
136
+ return null;
137
+ const isActive = activeSet.has(item.url.slice(1));
138
+ return (jsxRuntime.jsxs("g", { transform: `translate(${item.x}, ${item.y})`, children: [jsxRuntime.jsx("circle", { r: "7", fill: isActive ? lib.themeSvgIconColor : undefined, className: cn(!isActive && 'fill-black dark:fill-white') }), jsxRuntime.jsx("text", { y: "0.5", textAnchor: "middle", dominantBaseline: "middle", className: "fill-white text-[9px] font-medium dark:fill-black", children: item.stepNumber })] }, item.url));
139
+ }) })] }));
140
+ }
141
+ function getItemOffset(depth) {
142
+ if (depth <= 2)
143
+ return 14;
144
+ if (depth === 3)
145
+ return 26;
146
+ return 36;
147
+ }
148
+ function getLineOffset(depth) {
149
+ return depth >= 3 ? 18 : 6;
150
+ }
151
+ function getVisualLinePosition(depth) {
152
+ return getLineOffset(depth);
153
+ }
154
+ function resolveClerkItem(item) {
155
+ const isH3 = item.depth === 3;
156
+ const rawTitle = typeof item.title === 'string' ? item.title : '';
157
+ const { isStep, displayStep, content } = getStepInfoFromTitle(rawTitle);
158
+ let stepNumber = isH3 && isStep ? String(displayStep) : null;
159
+ let resolvedContent = item.title;
160
+ if (isH3 && isStep) {
161
+ resolvedContent = content !== null && content !== void 0 ? content : item.title;
162
+ }
163
+ if (isH3 && !stepNumber) {
164
+ const urlNum = getDigitsFromUrl(item.url);
165
+ if (urlNum != null) {
166
+ const clamped = Math.max(0, Math.min(19, urlNum));
167
+ stepNumber = String(clamped);
168
+ if (typeof rawTitle === 'string') {
169
+ const match = rawTitle.match(/^(\d+(?:\.\d+)*\.?)\s+(.+)$/);
170
+ if (match === null || match === void 0 ? void 0 : match[2]) {
171
+ resolvedContent = match[2];
172
+ }
173
+ }
174
+ }
175
+ }
176
+ return {
177
+ item,
178
+ resolvedContent,
179
+ stepNumber,
180
+ itemPadding: getItemOffset(item.depth),
181
+ lineOffset: getVisualLinePosition(item.depth),
182
+ };
183
+ }
184
+ function buildOutlinePath(items) {
185
+ if (items.length === 0)
186
+ return '';
187
+ const [first] = items;
188
+ const last = items.at(-1);
189
+ if (!last)
190
+ return '';
191
+ let path = `M ${round(first.x)} ${round(first.y)}`;
192
+ for (let i = 1; i < items.length; i++) {
193
+ path += ` ${buildTurnSegment(items[i - 1], items[i])}`;
194
+ }
195
+ return path;
196
+ }
197
+ function buildTurnSegment(previous, current) {
198
+ if (Math.abs(previous.x - current.x) <= 0.5) {
199
+ return `L ${round(current.x)} ${round(current.y)}`;
200
+ }
201
+ const distanceY = current.y - previous.y;
202
+ if (distanceY <= 0) {
203
+ return `L ${round(current.x)} ${round(current.y)}`;
204
+ }
205
+ const gapMidY = previous.y + distanceY / 2;
206
+ const maxCurveHeight = Math.max(distanceY - CLERK_TURN_GAP_MARGIN * 2, 0);
207
+ const curveHeight = Math.min(CLERK_TURN_CURVE_HEIGHT, Math.max(maxCurveHeight, 0));
208
+ if (curveHeight <= 0.5) {
209
+ return `L ${round(current.x)} ${round(current.y)}`;
210
+ }
211
+ const turnStartY = gapMidY - curveHeight / 2;
212
+ const turnEndY = gapMidY + curveHeight / 2;
213
+ const controlDelta = curveHeight * CLERK_TURN_CONTROL_FACTOR;
214
+ return [
215
+ `L ${round(previous.x)} ${round(turnStartY)}`,
216
+ `C ${round(previous.x)} ${round(turnStartY + controlDelta)} ${round(current.x)} ${round(turnEndY - controlDelta)} ${round(current.x)} ${round(turnEndY)}`,
217
+ `L ${round(current.x)} ${round(current.y)}`,
218
+ ].join(' ');
219
+ }
220
+ function getActiveItems(items, activeAnchors) {
221
+ if (items.length === 0 || activeAnchors.length === 0)
222
+ return [];
223
+ return items.filter((item) => activeAnchors.includes(item.url.slice(1)));
224
+ }
225
+ function getActiveEndpoint(items) {
226
+ if (items.length === 0)
227
+ return null;
228
+ const last = items.at(-1);
229
+ if (!last)
230
+ return null;
231
+ return {
232
+ x: last.x,
233
+ y: last.y,
234
+ };
235
+ }
236
+ function isSameLayout(previous, next) {
237
+ if (Math.abs(previous.height - next.height) > 0.5)
238
+ return false;
239
+ if (previous.items.length !== next.items.length)
240
+ return false;
241
+ for (let i = 0; i < previous.items.length; i++) {
242
+ const prev = previous.items[i];
243
+ const curr = next.items[i];
244
+ if (!prev || !curr)
245
+ return false;
246
+ if (prev.url !== curr.url || prev.stepNumber !== curr.stepNumber) {
247
+ return false;
248
+ }
249
+ if (Math.abs(prev.y - curr.y) > 0.5)
250
+ return false;
251
+ if (Math.abs(prev.x - curr.x) > 0.5)
252
+ return false;
253
+ }
254
+ return true;
255
+ }
256
+ function measureItemLineY(element, content) {
257
+ const anchorRect = element.getBoundingClientRect();
258
+ const lineRects = Array.from(content.getClientRects()).filter((rect) => rect.height > 0);
259
+ if (lineRects.length > 0) {
260
+ const lastRect = lineRects.at(-1);
261
+ if (lastRect) {
262
+ return (element.offsetTop +
263
+ (lastRect.top - anchorRect.top) +
264
+ lastRect.height / 2);
265
+ }
266
+ }
267
+ const styles = getComputedStyle(element);
268
+ const top = element.offsetTop + parseFloat(styles.paddingTop);
269
+ const bottom = element.offsetTop +
270
+ element.clientHeight -
271
+ parseFloat(styles.paddingBottom);
272
+ return (top + bottom) / 2;
273
+ }
274
+ function round(value) {
275
+ return Number(value.toFixed(2));
276
+ }
277
+ function getDigitsFromUrl(url) {
278
+ const match = /^#(\d+)-/.exec(url);
279
+ if (!match)
280
+ return null;
281
+ const value = Number.parseInt(match[1], 10);
282
+ return Number.isNaN(value) ? null : value;
283
+ }
284
+ function getStepInfoFromTitle(title) {
285
+ var _a;
286
+ const trimmed = title.trim();
287
+ const match = trimmed.match(/^(\d+(?:\.\d+)*\.?)\s+(.+)$/);
288
+ if (!match)
289
+ return { isStep: false, displayStep: null, content: null };
290
+ const content = ((_a = match[2]) !== null && _a !== void 0 ? _a : '').trim();
291
+ if (content.length === 0) {
292
+ return { isStep: false, displayStep: null, content: null };
293
+ }
294
+ const numericPart = match[1].replace(/\.$/, '');
295
+ const parts = numericPart.split('.').map((part) => Number.parseInt(part, 10));
296
+ const lastPart = parts.at(-1);
297
+ if (lastPart == null || Number.isNaN(lastPart)) {
298
+ return { isStep: false, displayStep: null, content: null };
299
+ }
300
+ const clamped = Math.max(0, Math.min(19, lastPart));
301
+ return { isStep: true, displayStep: clamped, content };
302
+ }
303
+ function cn(...inputs) {
304
+ return inputs.filter(Boolean).join(' ');
305
+ }
306
+ function mergeRefs(...refs) {
307
+ return (node) => {
308
+ for (const ref of refs) {
309
+ if (!ref)
310
+ continue;
311
+ if (typeof ref === 'function') {
312
+ ref(node);
313
+ continue;
314
+ }
315
+ try {
316
+ ref.current = node;
317
+ }
318
+ catch (_a) {
319
+ // ignore readonly refs
320
+ }
321
+ }
322
+ };
323
+ }
324
+
325
+ exports.PortableClerkTOC = PortableClerkTOC;
326
+ exports.PortableClerkTOCItems = PortableClerkTOCItems;
327
+ exports.PortableClerkTOCPopover = PortableClerkTOCPopover;
328
+ exports.PortableClerkTOCScrollArea = PortableClerkTOCScrollArea;