UNPKG

@rspress-theme-anatole/theme-default

Version:

1,000 lines (998 loc) 258 kB
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime"; import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_react_0d3abecb__ from "@mdx-js/react"; import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime"; import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme"; import * as __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__ from "github-slugger"; import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react"; import * as __WEBPACK_EXTERNAL_MODULE_htmr__ from "htmr"; import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es"; import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress-theme-anatole/shared"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_arrow_right_3f3bb17d__ from "@theme-assets/arrow-right"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_menu_9c72640c__ from "@theme-assets/menu"; import "nprogress/nprogress.css"; import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_wrap_367cf3a3__ from "@theme-assets/wrap"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_wrapped_01fc4d47__ from "@theme-assets/wrapped"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_copy_ebc8477b__ from "@theme-assets/copy"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_success_55638e57__ from "@theme-assets/success"; import * as __WEBPACK_EXTERNAL_MODULE_copy_to_clipboard_b679b6a5__ from "copy-to-clipboard"; import * as __WEBPACK_EXTERNAL_MODULE_react_syntax_highlighter_bbd3b718__ from "react-syntax-highlighter"; import * as __WEBPACK_EXTERNAL_MODULE_virtual_prism_languages_a6edd1ed__ from "virtual-prism-languages"; import * as __WEBPACK_EXTERNAL_MODULE_flexsearch__ from "flexsearch"; import * as __WEBPACK_EXTERNAL_MODULE_virtual_search_index_hash_00b0989e__ from "virtual-search-index-hash"; import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data"; import * as __WEBPACK_EXTERNAL_MODULE_nprogress__ from "nprogress"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_small_menu_b89c442a__ from "@theme-assets/small-menu"; import * as __WEBPACK_EXTERNAL_MODULE_body_scroll_lock_935fd51e__ from "body-scroll-lock"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_translator_e1217f67__ from "@theme-assets/translator"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_arrow_down_f924fb68__ from "@theme-assets/arrow-down"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_moon_c120f886__ from "@theme-assets/moon"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_sun_beb20915__ from "@theme-assets/sun"; import * as __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__ from "react-dom"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_down_345b1d5d__ from "@theme-assets/down"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_close_bcac2df4__ from "@theme-assets/close"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_loading_5f550a25__ from "@theme-assets/loading"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_search_1c295ce0__ from "@theme-assets/search"; import * as __WEBPACK_EXTERNAL_MODULE_virtual_search_hooks_9d01d01f__ from "virtual-search-hooks"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_empty_326d8860__ from "@theme-assets/empty"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_file_9182f35f__ from "@theme-assets/file"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_header_54924fa3__ from "@theme-assets/header"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_jump_20d3ca88__ from "@theme-assets/jump"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_title_56a7311e__ from "@theme-assets/title"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_github_cac38251__ from "@theme-assets/github"; import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_gitlab_a0e4f082__ from "@theme-assets/gitlab"; function isMobileDevice() { return window.innerWidth < 1280; } function renderHtmlOrText(str) { if (!str) return ''; if ('number' == typeof str) return str; const hasValidHtmlElements = /<([a-z]+)([^<]*)(?:>(.*?)<\/\1>|\s*\/>)/i.test(str); if (hasValidHtmlElements) return (0, __WEBPACK_EXTERNAL_MODULE_htmr__["default"])(str); return str.replace(/\\</g, '<').replace(/\\>/g, '>').replace(/&lt;/g, '<').replace(/&gt;/g, '>'); } const CODE_TEXT_PATTERN = /`(.*?)`/g; const STRONG_TEXT_PATTERN = /\*{2}(?!\*)(.*?)\*{2}(?!\*)/g; const EMPHASIS_TEXT_PATTERN = /\*(?!\*)(.*?)\*(?!\*)/g; const DELETE_TEXT_PATTERN = /\~{2}(.*?)\~{2}/g; function renderInlineMarkdown(text) { const htmlText = text.replace(/`[^`]+`/g, (match) => match.replace(/</g, '&lt;')).replace(STRONG_TEXT_PATTERN, '<strong>$1</strong>').replace(EMPHASIS_TEXT_PATTERN, '<em>$1</em>').replace(DELETE_TEXT_PATTERN, '<del>$1</del>').replace(CODE_TEXT_PATTERN, '<code>$1</code>'); return renderHtmlOrText(htmlText); } function parseInlineMarkdownText(mdx) { return mdx.replace(STRONG_TEXT_PATTERN, '$1').replace(EMPHASIS_TEXT_PATTERN, '$1').replace(DELETE_TEXT_PATTERN, '$1').replace(CODE_TEXT_PATTERN, '$1'); } function useEnableNav() { const { siteData: { themeConfig }, page: { frontmatter = {} } } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)(); const initialState = (frontmatter?.navbar ?? true) && themeConfig?.hideNavbar !== 'always'; const [enableNav, setEnableNav] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialState); return [ enableNav, setEnableNav ]; } function useHiddenNav() { const { siteData: { themeConfig } } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)(); const hiddenBehavior = themeConfig.hideNavbar ?? 'never'; const [hiddenNav, setHiddenNav] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false); const { pathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)(); const lastScrollTop = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(0); if ('never' === hiddenBehavior) return false; if ('always' === hiddenBehavior) return true; (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { setHiddenNav(false); const onScrollListen = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.throttle)(() => { const { scrollTop } = document.documentElement; if (scrollTop === lastScrollTop.current) return; const shouldHidden = lastScrollTop.current > 0 && scrollTop - lastScrollTop.current > 0; setHiddenNav(shouldHidden); lastScrollTop.current = scrollTop <= 0 ? 0 : scrollTop; }, 200); window.addEventListener('scroll', onScrollListen); return () => { window.removeEventListener('scroll', onScrollListen); }; }, [ pathname ]); return hiddenNav; } const DEFAULT_NAV_HEIGHT = 72; function getTargetTop(element, fallbackHeight = DEFAULT_NAV_HEIGHT) { const targetPadding = Number.parseInt(window.getComputedStyle(element).paddingTop, 10); const targetTop = window.scrollY + element.getBoundingClientRect().top - fallbackHeight - targetPadding; return Math.round(targetTop); } function scrollToTarget(target, isSmooth, fallbackHeight = DEFAULT_NAV_HEIGHT) { window.scrollTo({ left: 0, top: getTargetTop(target, fallbackHeight), ...isSmooth ? { behavior: 'smooth' } : {} }); } function bindingWindowScroll() { function scrollTo(el, hash, isSmooth = false) { let target = null; try { target = el.classList.contains('header-anchor') ? el : document.getElementById(decodeURIComponent(hash.slice(1))); } catch (e) { console.warn(e); } if (target) scrollToTarget(target, isSmooth); } window.addEventListener('click', (e) => { const link = e.target.closest('a'); if (link) { const { origin, hash, target, pathname, search } = link; const currentUrl = window.location; if (hash && '_blank' !== target && origin === currentUrl.origin) { if (pathname === currentUrl.pathname && search === currentUrl.search && hash && link.classList.contains('header-anchor')) { e.preventDefault(); history.pushState(null, '', hash); scrollTo(link, hash, true); window.dispatchEvent(new Event('hashchange')); } else window.addEventListener('RspressReloadContent', () => { if (location.hash.length > 1) { const ele = document.getElementById(location.hash.slice(1)); scrollToTarget(ele, false); } }); } } }, { capture: true }); window.addEventListener('hashchange', (e) => { e.preventDefault(); }); } function bindingAsideScroll() { function isBottom() { return document.documentElement.scrollTop + window.innerHeight >= document.documentElement.scrollHeight; } const aside = document.getElementById('aside-container'); const links = Array.from(document.querySelectorAll('.rspress-doc .header-anchor')).filter((item) => item.parentElement?.tagName !== 'H1'); if (!aside || !links.length) return; let prevActiveLink = null; const headers = Array.from(aside?.getElementsByTagName('a') || []).map((item) => decodeURIComponent(item.hash)); if (!headers.length) return; const activate = (links, index) => { if (links[index]) { const id = links[index].getAttribute('href'); const currentLink = aside?.querySelector(`a[href="#${id?.slice(1)}"]`); if (currentLink) { if (prevActiveLink) prevActiveLink.classList.remove('aside-active'); prevActiveLink = currentLink; prevActiveLink.classList.add('aside-active'); } } }; const setActiveLink = () => { if (isBottom()) activate(links, links.length - 1); else for (let i = 0; i < links.length; i++) { const currentAnchor = links[i]; const nextAnchor = links[i + 1]; const scrollTop = Math.ceil(window.scrollY); const currentAnchorTop = getTargetTop(currentAnchor.parentElement); if (0 === i && scrollTop < currentAnchorTop || 0 === scrollTop) { activate(links, 0); break; } if (!nextAnchor) { activate(links, i); break; } const nextAnchorTop = getTargetTop(nextAnchor.parentElement); if (scrollTop >= currentAnchorTop && scrollTop < nextAnchorTop) { activate(links, i); break; } } }; const throttledSetLink = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.throttle)(setActiveLink, 100); window.addEventListener('scroll', throttledSetLink); setActiveLink(); return () => { if (prevActiveLink) prevActiveLink.classList.remove('aside-active'); window.removeEventListener('scroll', throttledSetLink); }; } function setup() { if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.inBrowser)()) return; bindingWindowScroll(); } const TocItem = ({ header, baseHeaderLevel }) => (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("li", { children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("a", { href: `#${header.id}`, title: parseInlineMarkdownText(header.text), className: "aside-link transition-all duration-300 hover:text-text-1 text-text-2 block", style: { marginLeft: (header.depth - baseHeaderLevel) * 12, fontWeight: 'semibold' }, onClick: (e) => { e.preventDefault(); window.location.hash = header.id; }, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { className: "aside-link-text block", children: renderInlineMarkdown(header.text) }) }) }); function Aside(props) { const { headers } = props; const hasOutline = headers.length > 0; const baseHeaderLevel = headers[0]?.depth || 2; const hiddenNav = useHiddenNav(); const { hash: locationHash = '', pathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)(); const decodedHash = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(() => decodeURIComponent(locationHash), [ locationHash ]); (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { let unbinding; setTimeout(() => { unbinding = bindingAsideScroll(); }, 100); return () => { if (unbinding) unbinding(); }; }, [ headers ]); (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { if (0 === decodedHash.length) window.scrollTo(0, 0); else { const target = document.getElementById(decodedHash.slice(1)); if (target) scrollToTarget(target, false, hiddenNav ? 0 : DEFAULT_NAV_HEIGHT); } }, [ decodedHash, headers, pathname ]); return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: "flex flex-col", children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: hasOutline ? '<lg:hidden' : 'hidden', children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", { id: "aside-container", className: "relative text-sm font-medium", children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: "leading-7 block text-sm font-semibold pl-3", children: props.outlineTitle }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("nav", { className: "mt-1", children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("ul", { className: "relative", children: headers.map((header) => (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(TocItem, { baseHeaderLevel: baseHeaderLevel, header: header }, `${pathname}#${header.id}`)) }) }) ] }) }) }); } const matchPath = (pattern, currentPathname) => { const prefix = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.withBase)(pattern); if (prefix === currentPathname) return true; const prefixWithTrailingSlash = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addTrailingSlash)(prefix); if (currentPathname.startsWith(prefixWithTrailingSlash)) return true; const prefixWithDot = `${prefix}.`; return currentPathname.startsWith(prefixWithDot); }; function getSidebarDataGroup_isActive(itemLink, currentPathname) { const normalizedItemLink = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeRoutePath)((0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.withBase)(itemLink)); const normalizedCurrentPathname = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeRoutePath)(currentPathname); const linkMatched = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.matchPath)(normalizedItemLink, normalizedCurrentPathname); return null !== linkMatched; } const getSidebarDataGroup = (sidebar, currentPathname) => { const navRoutes = Object.keys(sidebar).sort((a, b) => b.length - a.length); for (const name of navRoutes) if (matchPath(name, currentPathname)) { const sidebarGroup = sidebar[name]; return sidebarGroup; } return []; }; function useLocaleSiteData() { const pageData = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)(); const { page: { lang } } = pageData; const themeConfig = pageData?.siteData?.themeConfig ?? {}; const defaultLang = pageData.siteData.lang ?? ''; const locales = themeConfig?.locales; if (!locales || 0 === locales.length) return { nav: themeConfig.nav, sidebar: themeConfig.sidebar, prevPageText: themeConfig.prevPageText, nextPageText: themeConfig.nextPageText, sourceCodeText: themeConfig.sourceCodeText, searchPlaceholderText: themeConfig.searchPlaceholderText, searchNoResultsText: themeConfig.searchNoResultsText, searchSuggestedQueryText: themeConfig.searchSuggestedQueryText, overview: themeConfig.overview }; const localeInfo = locales.find((locale) => locale.lang === lang); return { ...localeInfo, langRoutePrefix: lang === defaultLang ? '/' : (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addTrailingSlash)(lang) }; } function useSidebarData() { const { sidebar } = useLocaleSiteData(); const { pathname: rawPathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)(); const pathname = decodeURIComponent(rawPathname); const sidebarData = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(() => getSidebarDataGroup(sidebar, pathname), [ sidebar, pathname ]); return sidebarData; } function usePrevNextPage() { const { pathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)(); const items = useSidebarData(); const flattenTitles = []; const walk = (sidebarItem) => { if ('items' in sidebarItem) { if (sidebarItem.link) flattenTitles.push({ text: sidebarItem.text, link: sidebarItem.link }); sidebarItem.items.forEach((item) => { 'dividerType' in item || walk(item); }); } else flattenTitles.push(sidebarItem); }; items.forEach((item) => !('dividerType' in item) && walk(item)); const pageIndex = flattenTitles.findIndex((item) => (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)((0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.withBase)(item.link), pathname)); const prevPage = flattenTitles[pageIndex - 1] || null; const nextPage = flattenTitles[pageIndex + 1] || null; return { prevPage, nextPage }; } const index_module = { pager: "pager_d6903", "has-next": "has-next_e91b1", hasNext: "has-next_e91b1", prev: "prev_c92d1", next: "next_c11be" }; function DocFooter() { const { prevPage, nextPage } = usePrevNextPage(); const { lastUpdated: localesLastUpdated = false } = useLocaleSiteData(); const { siteData } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)(); const { themeConfig } = siteData; const showLastUpdated = themeConfig.lastUpdated || localesLastUpdated; return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("footer", { className: "mt-8", children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: "xs:flex pb-5 px-2 justify-end items-center", children: showLastUpdated && (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.LastUpdated, {}) }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: "flex flex-col", children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.EditLink, {}) }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", { className: "flex flex-col sm:flex-row sm:justify-around gap-4 pt-6", children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: `${index_module.prev} flex flex-col`, children: prevPage ? (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.PrevNextPage, { type: "prev", text: prevPage.text, href: (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeHrefInRuntime)(prevPage.link) }) : null }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: `${index_module.next} flex flex-col`, children: nextPage ? (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.PrevNextPage, { type: "next", text: nextPage.text, href: (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeHrefInRuntime)(nextPage.link) }) : null }) ] }) ] }); } const Nav_index_module = { hidden: "hidden_f8586", container: "container_e4235", navContainer: "navContainer_d18b1", leftNav: "leftNav_e6722", rightNav: "rightNav_a2fea", singleItem: "singleItem_c1154", activeItem: "activeItem_a28b5", navBarTitle: "navBarTitle_c5f07", "menu-item": "menu-item_b8238", menuItem: "menu-item_b8238", mobileNavMenu: "mobileNavMenu_e7045", mask: "mask_cea59", docPage: "docPage_b27ff" }; const NavBarTitle = () => { const { siteData } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)(); const localeData = useLocaleSiteData(); const { logo: rawLogo, logoText } = siteData; const title = localeData.title ?? siteData.title; const logo = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(() => { if (!rawLogo) return null; if ('string' == typeof rawLogo) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("img", { src: (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeImagePath)(rawLogo), alt: "logo", id: "logo", className: "rspress-logo" }); return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, { children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("img", { src: (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeImagePath)(rawLogo.light), alt: "logo", id: "logo", className: "rspress-logo dark:hidden" }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("img", { src: (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeImagePath)(rawLogo.dark), alt: "logo", id: "logo", className: "rspress-logo hidden dark:block" }) ] }); }, [ rawLogo ]); return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: `${Nav_index_module.navBarTitle}`, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.Link, { href: localeData.langRoutePrefix, className: "flex items-center w-full h-full text-base font-semibold transition-opacity duration-300 hover:opacity-60", children: [ logo && (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: "mr-1 min-w-8", children: logo }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { style: { border: '1px solid #D2D5DA', width: '24px', rotate: '-90deg', }, }), logoText && (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { children: logoText }), !logo && !logoText && (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { children: title }), ], }) }); }; function SidebarDivider(props) { const { depth, dividerType } = props; const borderTypeStyle = 'dashed' === dividerType ? 'border-dashed' : 'border-solid'; return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: `${borderTypeStyle} border-t border-divider-light my-3`, style: { marginLeft: 0 === depth ? 0 : '18px' } }); } function SvgWrapper({ icon: Icon, ...rest }) { if (!Icon) return null; if ('string' == typeof Icon) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("img", { src: Icon, alt: "", ...rest }); return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Icon, { ...rest }); } const Sidebar_index_module = { navTitleMask: "navTitleMask_fb17c", sidebar: "sidebar_dd719", sidebarContent: "sidebarContent_da296", open: "open_becbd", menuLink: "menuLink_bb039", menuItem: "menuItem_ac22e", collapseContainer: "collapseContainer_d6e4e", menuItemActive: "menuItemActive_de63c", menuGroupActive: "menuGroupActive_e3177" }; const isSidebarDivider = (item) => 'dividerType' in item; const isSidebarSingleFile = (item) => !('items' in item) && 'link' in item; const isSidebarSectionHeader = (item) => 'sectionHeaderText' in item; const isSideBarCustomLink = (item) => 'link' in item && (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(item.link); const preloadLink = (link) => { const route = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(link); if (route) route.preload(); }; const useActiveMatcher = () => { const { pathname: rawPathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)(); const activeMatcher = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((link) => { const pathname = decodeURIComponent(rawPathname); return getSidebarDataGroup_isActive(link, pathname); }, [ rawPathname ]); return activeMatcher; }; function SidebarGroup(props) { const { item, depth = 0, activeMatcher, id, setSidebarData } = props; const navigate = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useNavigate)(); const containerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null); const transitionRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(); const innerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null); const initialRender = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(true); const initialState = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)('collapsed' in item && item.collapsed); const active = item.link && activeMatcher(item.link); const { collapsed, collapsible = true } = item; const collapsibleIcon = (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { style: { cursor: 'pointer', transition: 'transform 0.2s ease-out', transform: collapsed ? 'rotate(0deg)' : 'rotate(90deg)' }, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SvgWrapper, { icon: __WEBPACK_EXTERNAL_MODULE__theme_assets_arrow_right_3f3bb17d__["default"] }) }); (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { if (initialRender.current) return; if (!containerRef.current || !innerRef.current) return; if (transitionRef.current) clearTimeout(transitionRef.current); const container = containerRef.current; const inner = innerRef.current; const contentHeight = inner.clientHeight + 4; if (collapsed) { container.style.maxHeight = `${contentHeight}px`; container.style.transitionDuration = '0.5s'; inner.style.opacity = '0'; transitionRef.current = window.setTimeout(() => { if (containerRef.current) containerRef.current.style.maxHeight = '0px'; }, 0); } else { container.style.maxHeight = `${contentHeight}px`; container.style.transitionDuration = '0.3s'; inner.style.opacity = '1'; transitionRef.current = window.setTimeout(() => { if (containerRef.current) containerRef.current.style.removeProperty('max-height'); }, 300); } }, [ collapsed ]); (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { initialRender.current = false; }, []); const toggleCollapse = (e) => { e.stopPropagation(); setSidebarData((sidebarData) => { const newSidebarData = [ ...sidebarData ]; const indexes = id.split('-').map(Number); const initialIndex = indexes.shift(); const root = newSidebarData[initialIndex]; let current = root; for (const index of indexes) current = current.items[index]; if ('items' in current) current.collapsed = !current.collapsed; return newSidebarData; }); }; return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("section", { className: "rspress-sidebar-section mt-0.5 block", "data-context": item.context, style: { marginLeft: 0 === depth ? 0 : '18px' }, children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", { className: `rspress-sidebar-collapse flex justify-between items-center ${active ? Sidebar_index_module.menuItemActive : Sidebar_index_module.menuItem}`, "data-context": item.context, onMouseEnter: () => item.link && preloadLink(item.link), onClick: (e) => { if (item.link) navigate((0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.withBase)((0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeHrefInRuntime)(item.link))); collapsible && toggleCollapse(e); }, style: { borderRadius: 0 === depth ? '0 var(--rp-radius) var(--rp-radius) 0' : void 0, cursor: collapsible || item.link ? 'pointer' : 'normal' }, children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("h2", { className: "py-2 px-3 text-sm font-medium flex", style: { ...0 === depth ? highlightTitleStyle : {} }, children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.Tag, { tag: item.tag }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { className: "flex-center", style: { fontSize: 0 === depth ? '14px' : '13px' }, children: renderInlineMarkdown(item.text) }) ] }), collapsible && (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: `${Sidebar_index_module.collapseContainer} p-2 rounded-xl`, onClick: toggleCollapse, children: collapsibleIcon }) ] }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { ref: containerRef, className: "transition-all duration-300 ease-in-out", style: { overflow: 'hidden', maxHeight: initialState.current ? 0 : void 0 }, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { ref: innerRef, className: "rspress-sidebar-group transition-opacity duration-500 ease-in-out", style: { opacity: initialState.current ? 0 : 1, marginLeft: 0 === depth ? '12px' : 0 }, children: item?.items?.map((item, index) => isSidebarDivider(item) ? __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx(SidebarDivider, { depth: depth + 1, dividerType: item.dividerType }, index) : __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx("div", { className: "rspress-sidebar-item", "data-context": item.context, children: __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx(SidebarItem, { ...props, item: item, depth: depth + 1, id: `${id}-${index}` }) }, index)) }) }) ] }, id); } function SidebarItem(props) { const { item, depth = 0, activeMatcher, id, setSidebarData } = props; const active = 'link' in item && item.link && activeMatcher(item.link); const ref = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null); (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { if (active) ref.current?.scrollIntoView({ block: 'center' }); }, []); if ('items' in item) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SidebarGroup, { id: id, activeMatcher: activeMatcher, item: item, depth: depth, collapsed: item.collapsed, setSidebarData: setSidebarData }, `${item.text}-${id}`); return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.Link, { href: (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeHrefInRuntime)(item.link), className: Sidebar_index_module.menuLink, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", { ref: ref, onMouseEnter: () => preloadLink(item.link), className: `${active ? Sidebar_index_module.menuItemActive : Sidebar_index_module.menuItem} mt-0.5 py-2 px-3 font-medium flex`, style: { fontSize: 0 === depth ? '14px' : '13px', marginLeft: 0 === depth ? 0 : '18px', borderRadius: '0 var(--rp-radius) var(--rp-radius) 0', ...0 === depth ? highlightTitleStyle : {} }, children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.Tag, { tag: item.tag }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { children: renderInlineMarkdown(item.text) }) ] }) }); } function SidebarSectionHeader({ sectionHeaderText, tag }) { return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", { className: "rspress-sidebar-section-header", children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.Tag, { tag: tag }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { children: renderInlineMarkdown(sectionHeaderText) }) ] }); } const highlightTitleStyle = { fontSize: '14px', paddingLeft: '24px', fontWeight: 'bold' }; let bodyStyleOverflow; let matchCache = new WeakMap(); function Sidebar(props) { const { isSidebarOpen, beforeSidebar, afterSidebar, uiSwitch, navTitle } = props; const { pathname: rawPathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)(); const rawSidebarData = useSidebarData(); const [sidebarData, setSidebarData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(() => rawSidebarData.filter(Boolean).flat()); const pathname = decodeURIComponent(rawPathname); const activeMatcher = useActiveMatcher(); (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.inBrowser)()) { if (isSidebarOpen) { bodyStyleOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; } else document.body.style.overflow = bodyStyleOverflow || ''; } }, [ isSidebarOpen ]); (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { if (rawSidebarData === sidebarData) return; matchCache = new WeakMap(); const match = (item) => { if (matchCache.has(item)) return matchCache.get(item); if ('link' in item && item.link && activeMatcher(item.link)) { matchCache.set(item, true); return true; } if ('items' in item) { const result = item.items.some((child) => match(child)); if (result) { matchCache.set(item, true); return true; } } matchCache.set(item, false); return false; }; const traverse = (item) => { if ('items' in item) { item.items.forEach(traverse); if (match(item)) item.collapsed = false; } }; const newSidebarData = rawSidebarData.filter(Boolean).flat(); newSidebarData.forEach(traverse); setSidebarData(newSidebarData); }, [ rawSidebarData, pathname ]); return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("aside", { className: `${Sidebar_index_module.sidebar} rspress-sidebar ${isSidebarOpen ? Sidebar_index_module.open : ''}`, children: [ uiSwitch?.showNavbar ? (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: Sidebar_index_module.navTitleMask, children: navTitle || (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(NavBarTitle, {}) }) : null, (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: `rspress-scrollbar ${Sidebar_index_module.sidebarContent}`, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("nav", { className: "pb-2", children: [ beforeSidebar, (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SidebarList, { sidebarData: sidebarData, setSidebarData: setSidebarData }), afterSidebar ] }) }) ] }); } function SidebarList({ sidebarData, setSidebarData }) { const activeMatcher = useActiveMatcher(); return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, { children: sidebarData.map((item, index) => (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SidebarListItem, { item: item, index: index, setSidebarData: setSidebarData, activeMatcher: activeMatcher }, index)) }); } function SidebarListItem(props) { const { item, index, setSidebarData, activeMatcher } = props; if (isSidebarDivider(item)) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SidebarDivider, { depth: 0, dividerType: item.dividerType }, index); if (isSidebarSectionHeader(item)) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SidebarSectionHeader, { sectionHeaderText: item.sectionHeaderText, tag: item.tag }, index); if (isSideBarCustomLink(item)) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: "rspress-sidebar-item rspress-sidebar-custom-link", "data-context": item.context, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SidebarItem, { id: String(index), item: item, depth: 0, collapsed: item.collapsed ?? true, setSidebarData: setSidebarData, activeMatcher: activeMatcher }, index) }, index); return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SidebarItem, { id: String(index), item: item, depth: 0, activeMatcher: activeMatcher, collapsed: item.collapsed ?? true, setSidebarData: setSidebarData }, index); } function SidebarMenu({ isSidebarOpen, onIsSidebarOpenChange, outlineTitle, uiSwitch }) { const tocContainerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null); const outlineButtonRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null); const [isTocOpen, setIsTocOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false); const { pathname } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)(); function openSidebar() { onIsSidebarOpenChange(true); } function closeSidebar() { onIsSidebarOpenChange(false); } (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { onIsSidebarOpenChange(false); }, [ pathname ]); (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => { document.addEventListener('mouseup', handleClickOutsideForToc); document.addEventListener('touchend', handleClickOutsideForToc); return () => { document.addEventListener('mouseup', handleClickOutsideForToc); document.removeEventListener('touchend', handleClickOutsideForToc); }; }, []); const handleClickOutsideForToc = (e) => { const { current: outlineButton } = outlineButtonRef; if (outlineButton?.contains(e.target)) return; const { current: tocContainer } = tocContainerRef; if (tocContainer && !tocContainer.contains(e.target)) setIsTocOpen(false); }; return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", { className: "rspress-sidebar-menu", children: [ uiSwitch?.showSidebar && (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, { children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("button", { onClick: openSidebar, className: "flex-center mr-auto", children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: "text-md mr-2", children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SvgWrapper, { icon: __WEBPACK_EXTERNAL_MODULE__theme_assets_menu_9c72640c__["default"] }) }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { className: "text-sm", children: "Menu" }) ] }), isSidebarOpen && (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { onClick: closeSidebar, className: "rspress-sidebar-back-drop", style: { background: 'rgba(0, 0, 0, 0.6)' } }) ] }), uiSwitch?.showAside && (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, { children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("button", { onClick: () => setIsTocOpen((tocOpened) => !tocOpened), className: "flex-center ml-auto", ref: outlineButtonRef, children: [ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", { className: "text-sm", children: outlineTitle }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: "text-md mr-2", style: { transform: isTocOpen ? 'rotate(90deg)' : 'rotate(0deg)', transition: 'transform 0.2s ease-out', marginTop: '2px' }, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SvgWrapper, { icon: __WEBPACK_EXTERNAL_MODULE__theme_assets_arrow_right_3f3bb17d__["default"] }) }) ] }), (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", { className: `rspress-local-toc-container ${isTocOpen ? 'rspress-local-toc-container-show' : ''}`, children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.Toc, { onItemClick: () => { setIsTocOpen(false); } }) }) ] }) ] }); } const TabDataContext = (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)({ tabData: {}, setTabData: () => { } }); function usePathUtils() { const currentLang = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLang)(); const currentVersion = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useVersion)(); const pageData = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)(); const defaultLang = pageData.siteData.lang; const defaultVersion = pageData.siteData.multiVersion.default; const normalizeLinkHref = (rawHref) => { let href = rawHref; if ((defaultLang || defaultVersion) && !(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(href) && !href.startsWith('#')) { href = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.removeBase)(href); const linkParts = href.split('/').filter(Boolean); let versionPart = ''; let langPart = ''; let purePathPart = ''; if (defaultVersion) { if (currentVersion !== defaultVersion) { versionPart = currentVersion; if (linkParts[0] === currentVersion) linkParts.shift(); } else if (linkParts[0] === defaultVersion) linkParts.shift(); } if (defaultLang) { if (currentLang !== defaultLang) { langPart = currentLang; if (linkParts[0] === currentLang) linkParts.shift(); } else if (linkParts[0] === defaultLang) linkParts.shift(); } purePathPart = linkParts.join('/'); return (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeHrefInRuntime)((0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.withBase)([ versionPart, langPart, purePathPart ].filter(Boolean).join('/'))); } return href; }; return { normalizeLinkHref }; } const docComponents_index_module = { title: "title_fb7eb", blockquote: "blockquote_f1063", link: "link_a9ef4", "inline-link": "inline-link_f855c", inlineLink: "inline-link_f855c" }; const A = (props) => { const { href