docs/.vitepress/theme/components/Search.vue

a92c62778d79ea32c814bfce5540e823c2ad6de1
wotaku/docs/.vitepress/theme/components/Search.vue history · blame · raw

3968 lines · 108222 bytes

   1<script lang="ts" setup>
   2import type { SearchResult } from 'minisearch'
   3import { dataSymbol, type DefaultTheme, inBrowser, useRouter } from 'vitepress'
   4import {
   5  computed,
   6  createApp,
   7  markRaw,
   8  nextTick,
   9  onBeforeUnmount,
  10  onMounted,
  11  type Ref,
  12  ref,
  13  shallowRef,
  14  watch,
  15  watchEffect
  16} from 'vue'
  17// @ts-ignore
  18import { pathToFile } from 'vitepress/dist/client/app/utils'
  19// @ts-ignore
  20import { escapeRegExp } from 'vitepress/dist/client/shared'
  21
  22import {
  23  computedAsync,
  24  onClickOutside,
  25  onKeyStroke,
  26  useElementBounding,
  27  useEventListener,
  28  useLocalStorage,
  29  useScrollLock,
  30  useSessionStorage,
  31  watchDebounced
  32} from '@vueuse/core'
  33import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
  34import { AnimatePresence, motion } from 'motion-v'
  35
  36// @ts-ignore
  37import localSearchIndex from '@localSearchIndex'
  38
  39import {
  40  ArrowLeft,
  41  ArrowLeftToLine,
  42  ArrowRight,
  43  ArrowRightToLine,
  44  ChevronRight,
  45  Clock,
  46  File,
  47  Globe,
  48  Hash,
  49  Layers,
  50  LayoutList,
  51  List,
  52  LocateOff,
  53  Regex,
  54  Search,
  55  Settings,
  56  TextAlignStart,
  57  X
  58} from 'lucide-vue-next'
  59import Mark from 'mark.js/dist/mark.es6.js'
  60import { sidebar } from '../../configs/constants'
  61import type { PageLink } from '../../plugins/urlSearchPlugin'
  62import { LRUCache } from '../composables/search/lru-cache'
  63import { createSearchTranslate } from '../composables/search/translation'
  64import { useData } from '../composables/search/use-data'
  65import { useEffects } from '../composables/useEffects'
  66import { enhanceAppWithTabs } from './tabs'
  67
  68export interface FooterTranslations {
  69  selectText?: string
  70  selectKeyAriaLabel?: string
  71  navigateText?: string
  72  navigateUpKeyAriaLabel?: string
  73  navigateDownKeyAriaLabel?: string
  74  switchTabsText?: string
  75  switchTabsKeyAriaLabel?: string
  76  switchPagesText?: string
  77  switchPagesKeyAriaLabel?: string
  78  closeText?: string
  79  closeKeyAriaLabel?: string
  80}
  81
  82export interface ModalTranslations {
  83  displayDetails?: string
  84  resetButtonTitle?: string
  85  backButtonTitle?: string
  86  noResultsText?: string
  87  footer?: FooterTranslations
  88}
  89
  90const showSearch = defineModel<boolean>()
  91
  92const el = shallowRef<HTMLElement>()
  93const resultsEl = shallowRef<HTMLElement>()
  94
  95/* Search */
  96interface Result {
  97  tabs?: string[]
  98  title: string
  99  titles: string[]
 100  text?: string
 101}
 102
 103const searchIndexData = shallowRef(localSearchIndex)
 104const searchIndexVersion = ref(0)
 105
 106// @ts-ignore
 107if (import.meta.hot) {
 108  // @ts-ignore
 109  import.meta.hot.accept('@localSearchIndex', (m) => {
 110    if (m) {
 111      searchIndexData.value = m.default
 112      searchIndexVersion.value++
 113    }
 114  })
 115}
 116
 117const vitePressData = useData()
 118const { activate } = useFocusTrap(el, {
 119  immediate: true,
 120  allowOutsideClick: true,
 121  clickOutsideDeactivates: true,
 122  escapeDeactivates: true,
 123  returnFocusOnDeactivate: false,
 124  initialFocus: () => {
 125    return searchInput.value
 126  }
 127})
 128const { localeIndex, theme } = vitePressData
 129
 130const disableQueryPersistence = computed(() => {
 131  return (
 132    theme.value.search?.provider === 'local' &&
 133    theme.value.search.options?.disableQueryPersistence === true
 134  )
 135})
 136
 137const filterText = disableQueryPersistence.value
 138  ? ref('')
 139  : useSessionStorage('vitepress:local-search-filter', '')
 140
 141const { effectsEnabled: searchAnimationsEnabled } = useEffects()
 142const showKeyboardShortcuts = computed(() => !filterText.value)
 143
 144const SearchMotionDiv = motion.div
 145const SearchMotionForm = motion.form
 146const SearchMotionLi = motion.li
 147const searchMotionDiv = computed(() =>
 148  searchAnimationsEnabled.value ? SearchMotionDiv : 'div'
 149)
 150const searchMotionForm = computed(() =>
 151  searchAnimationsEnabled.value ? SearchMotionForm : 'form'
 152)
 153const searchMotionLi = computed(() =>
 154  searchAnimationsEnabled.value ? SearchMotionLi : 'li'
 155)
 156const searchMotionEase = [0.16, 1, 0.3, 1]
 157
 158const backdropMotion = computed(() =>
 159  searchAnimationsEnabled.value
 160    ? {
 161      initial: { opacity: 0 },
 162      animate: { opacity: 1 },
 163      exit: { opacity: 0 },
 164      transition: { duration: 0.55, ease: searchMotionEase }
 165    }
 166    : {}
 167)
 168
 169const shellMotion = computed(() =>
 170  searchAnimationsEnabled.value
 171    ? {
 172      layout: 'size',
 173      initial: { opacity: 0, scale: 0.9375 },
 174      animate: { opacity: 1, scale: 1 },
 175      exit: { opacity: 0, scale: 0.9375 },
 176      transition: { duration: 0.55, ease: searchMotionEase }
 177    }
 178    : {}
 179)
 180
 181const formMotion = computed(() =>
 182  searchAnimationsEnabled.value ? { layout: 'position' } : {}
 183)
 184
 185const ribbonMotion = computed(() =>
 186  searchAnimationsEnabled.value
 187    ? {
 188      layout: 'position',
 189      initial: { opacity: 0, height: 0 },
 190      animate: { opacity: 1, height: 'auto' },
 191      exit: { opacity: 0, height: 0 },
 192      transition: { duration: 0.4, ease: searchMotionEase }
 193    }
 194    : {}
 195)
 196
 197const emptyStateMotion = computed(() =>
 198  searchAnimationsEnabled.value
 199    ? {
 200      initial: { opacity: 0 },
 201      animate: {
 202        opacity: 1,
 203        transition: { delay: 0.1 }
 204      },
 205      exit: {
 206        opacity: 0,
 207        height: 0,
 208        transition: { duration: 0.2 }
 209      },
 210      transition: { duration: 0.7, ease: searchMotionEase }
 211    }
 212    : {}
 213)
 214
 215function resultMotion(index: number) {
 216  if (!searchAnimationsEnabled.value) return {}
 217  return {
 218    layout: true,
 219    initial: { opacity: 0, scale: 0.9375 },
 220    animate: { opacity: 1, scale: 1 },
 221    exit: {
 222      opacity: 0,
 223      scale: 0.9375,
 224      height: 0,
 225      transition: { duration: 0.25 }
 226    },
 227    transition: {
 228      duration: 0.55,
 229      ease: searchMotionEase,
 230      delay: index * 0.02
 231    }
 232  }
 233}
 234
 235const excerptMotion = computed(() =>
 236  searchAnimationsEnabled.value
 237    ? {
 238      layout: true,
 239      initial: { height: 0 },
 240      animate: { height: '84px' },
 241      exit: { height: 0 },
 242      transition: { duration: 0.4, ease: searchMotionEase }
 243    }
 244    : {}
 245)
 246
 247const footerMotion = computed(() =>
 248  searchAnimationsEnabled.value ? { layout: true } : {}
 249)
 250
 251const urlFilterDebounced = ref(filterText.value)
 252let urlDebounceTimer: ReturnType<typeof setTimeout> | undefined
 253watch(filterText, (v) => {
 254  clearTimeout(urlDebounceTimer)
 255  if (!v) {
 256    urlFilterDebounced.value = '' // instant clear, no trailing-edge delay
 257    return
 258  }
 259  urlDebounceTimer = setTimeout(() => {
 260    urlFilterDebounced.value = v
 261  }, 60)
 262})
 263onBeforeUnmount(() => clearTimeout(urlDebounceTimer))
 264
 265const showDetailedList = useLocalStorage(
 266  'vitepress:local-search-detailed-list',
 267  true
 268)
 269
 270// Three search modes: 'exact' | 'fuzzy' | 'url'
 271const searchMode = useLocalStorage<'exact' | 'fuzzy' | 'url'>(
 272  'vitepress:local-search-mode',
 273  'exact'
 274)
 275
 276// How many result pages get their excerpts rendered ahead of time
 277const excerptPreload = useLocalStorage<'off' | 'next' | 'all'>(
 278  'vitepress:local-search-excerpt-preload',
 279  'off'
 280)
 281
 282// Cycle through modes on mobile (only active button is visible, tap it to advance)
 283function cycleSearchMode() {
 284  const modes = ['exact', 'fuzzy', 'url'] as const
 285  const idx = modes.indexOf(searchMode.value)
 286  searchMode.value = modes[(idx + 1) % modes.length]
 287}
 288
 289// Keep matchExact and urlSearchMode as computed aliases
 290const matchExact = computed(() => searchMode.value === 'exact')
 291const urlSearchMode = computed(() => searchMode.value === 'url')
 292
 293// Search history
 294interface SearchHistoryEntry {
 295  query: string
 296  mode: SearchMode
 297  path?: string[]
 298  href?: string
 299}
 300
 301const saveHistoryEnabled = useLocalStorage('vitepress:local-search-save-history', false)
 302
 303const searchHistory = useLocalStorage<SearchHistoryEntry[]>(
 304  'vitepress:local-search-history',
 305  []
 306)
 307
 308const showHistory = computed(
 309  () => !filterText.value && searchHistory.value.length > 0
 310)
 311
 312function saveToHistory(query: string, mode: SearchMode, path?: string[], href?: string) {
 313  const trimmed = query.trim()
 314  if (!trimmed || !saveHistoryEnabled.value) return
 315  const pathKey = (path ?? []).join('\n')
 316  searchHistory.value = [
 317    { query: trimmed, mode, path, href },
 318    ...searchHistory.value.filter(
 319      (h) => !(h.query === trimmed && h.mode === mode && (h.path ?? []).join('\n') === pathKey)
 320    )
 321  ]
 322}
 323
 324function removeFromHistory(index: number) {
 325  searchHistory.value = searchHistory.value.filter((_, i) => i !== index)
 326}
 327
 328function applyHistory(entry: SearchHistoryEntry) {
 329  if (entry.href) {
 330    window.dispatchEvent(
 331      new CustomEvent('search-nav', { detail: { query: entry.query } })
 332    )
 333    router.go(entry.href)
 334    showSearch.value = false
 335    return
 336  }
 337  searchMode.value = entry.mode
 338  filterText.value = entry.query
 339  nextTick(() => focusSearchInput(false))
 340}
 341
 342// Mobile settings popup
 343const showSettingsPopup = ref(false)
 344const settingsButtonRef = ref<HTMLButtonElement>()
 345const settingsPopupRef = ref<HTMLDivElement>()
 346const settingsBounding = useElementBounding(settingsButtonRef)
 347type HelpSection = 'search' | 'view' | 'preload' | 'history'
 348const activeHelpSection = ref<HelpSection | null>(null)
 349const helpPopupEl = ref<HTMLDivElement>()
 350const helpPopupPos = ref({ top: -9999, left: -9999 })
 351
 352watch(showSettingsPopup, (val) => {
 353  if (!val) {
 354    activeHelpSection.value = null
 355    helpPopupPos.value = { top: -9999, left: -9999 }
 356  }
 357})
 358
 359const canHoverHelp = () =>
 360  typeof window !== 'undefined' && window.matchMedia('(hover: hover)').matches
 361
 362function positionHelpPopup(btn: HTMLElement) {
 363  helpPopupPos.value = { top: -9999, left: -9999 }
 364  const rect = btn.getBoundingClientRect()
 365  // Anchor to the menu's left edge so the popup sits beside it, not over it.
 366  const menuRect = settingsPopupRef.value?.getBoundingClientRect()
 367  nextTick(() => {
 368    const popupW = helpPopupEl.value?.offsetWidth || 260
 369    const popupH = helpPopupEl.value?.offsetHeight || 200
 370    const vw = window.innerWidth
 371    const margin = 8
 372    const isMobile = vw < 768
 373    if (isMobile) {
 374      const aboveTop = rect.top - popupH - margin
 375      const belowTop = rect.bottom + margin
 376      const top = aboveTop >= margin ? aboveTop : belowTop
 377      const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin))
 378      helpPopupPos.value = { top, left }
 379    } else {
 380      const anchorLeft = menuRect ? menuRect.left : rect.left
 381      helpPopupPos.value = {
 382        left: Math.max(margin, anchorLeft - popupW - 16),
 383        top: rect.top,
 384      }
 385    }
 386  })
 387}
 388
 389function closeHelpSection() {
 390  activeHelpSection.value = null
 391  helpPopupPos.value = { top: -9999, left: -9999 }
 392}
 393
 394function toggleHelpSection(section: HelpSection, e: MouseEvent) {
 395  // Hover devices open/close via mouseenter/leave; touch devices toggle on tap.
 396  if (canHoverHelp()) {
 397    activeHelpSection.value = section
 398    positionHelpPopup(e.currentTarget as HTMLElement)
 399    return
 400  }
 401  if (activeHelpSection.value === section) {
 402    closeHelpSection()
 403    return
 404  }
 405  activeHelpSection.value = section
 406  positionHelpPopup(e.currentTarget as HTMLElement)
 407}
 408
 409function onHelpEnter(section: HelpSection, e: MouseEvent) {
 410  if (!canHoverHelp()) return
 411  activeHelpSection.value = section
 412  positionHelpPopup(e.currentTarget as HTMLElement)
 413}
 414
 415function onHelpLeave() {
 416  if (!canHoverHelp()) return
 417  closeHelpSection()
 418}
 419
 420const settingsPopupStyle = computed(() => ({
 421  top: `${settingsBounding.bottom.value + 8}px`,
 422  right: `calc(100vw - ${settingsBounding.right.value}px)`,
 423}))
 424
 425onClickOutside(settingsPopupRef, () => {
 426  showSettingsPopup.value = false
 427}, { ignore: [settingsButtonRef] })
 428
 429interface PageGroupCount {
 430  key: string
 431  count: number
 432}
 433
 434const urlMatches = shallowRef<PageLink[]>([])
 435const urlPageGroupCounts = shallowRef<PageGroupCount[]>([])
 436
 437interface UrlResult {
 438  tabs?: string[]
 439  href: string
 440  linkText: string
 441  pageId: string
 442  anchor: string
 443  titles: string[]
 444  highlighted: string
 445}
 446
 447const URL_PAGE_SIZE = 25
 448
 449// 1-indexed current page within the URL results.
 450const urlPage = ref(1)
 451
 452// Full URL match set returned by the search worker.
 453// Used for accurate page-group counts in the ribbon and for pagination.
 454
 455// URL mode page ribbon — mirrors the normal pageGroups/filteredResults logic
 456const urlActivePageFilter = ref<string | null>(null)
 457
 458const urlPageGroups = computed(() =>
 459  urlPageGroupCounts.value
 460    .map((group) => ({
 461      key: group.key,
 462      label: getPageLabel(group.key),
 463      count: group.count
 464    }))
 465    .sort((a, b) => getPageOrder(a.key) - getPageOrder(b.key))
 466)
 467
 468// Full match set honoring the active ribbon page filter (uncapped).
 469const urlFilteredMatches = computed((): PageLink[] => {
 470  if (!urlActivePageFilter.value) return urlMatches.value
 471  return urlMatches.value.filter((l) => l.pageId === urlActivePageFilter.value)
 472})
 473
 474// Total number of result pages (Google-style paging through urlFilteredMatches).
 475const urlTotalPages = computed(() =>
 476  Math.max(1, Math.ceil(urlFilteredMatches.value.length / URL_PAGE_SIZE))
 477)
 478
 479// Clamp the current page whenever the result set shrinks.
 480const urlCurrentPage = computed(() =>
 481  Math.min(urlPage.value, urlTotalPages.value)
 482)
 483
 484// The rows actually rendered: the current page's slice of the filtered matches.
 485const filteredUrlResults = computed((): UrlResult[] => {
 486  const matches = urlFilteredMatches.value
 487  const start = (urlCurrentPage.value - 1) * URL_PAGE_SIZE
 488  const end = start + URL_PAGE_SIZE
 489  const out: UrlResult[] = []
 490  const query = urlFilterDebounced.value.trim()
 491  for (let i = start; i < end && i < matches.length; i++) {
 492    const link = matches[i]
 493    out.push({
 494      href: link.href,
 495      linkText: link.linkText,
 496      pageId: link.pageId,
 497      anchor: link.anchor,
 498      titles: link.titles,
 499      tabs: link.tabs,
 500      highlighted: highlightUrl(link.href, query)
 501    })
 502  }
 503  return out
 504})
 505
 506function escapeHtml(value: string) {
 507  return value
 508    .replace(/&/g, '&amp;')
 509    .replace(/</g, '&lt;')
 510    .replace(/>/g, '&gt;')
 511    .replace(/"/g, '&quot;')
 512    .replace(/'/g, '&#39;')
 513}
 514
 515function highlightUrl(url: string, query: string) {
 516  const needle = query.trim()
 517  if (!needle) return escapeHtml(url)
 518
 519  const lowerUrl = url.toLowerCase()
 520  const lowerNeedle = needle.toLowerCase()
 521  let out = ''
 522  let cursor = 0
 523  let index = lowerUrl.indexOf(lowerNeedle)
 524
 525  while (index !== -1) {
 526    out += escapeHtml(url.slice(cursor, index))
 527    out += `<mark class="url-highlight">${
 528      escapeHtml(url.slice(index, index + needle.length))
 529    }</mark>`
 530    cursor = index + needle.length
 531    index = lowerUrl.indexOf(lowerNeedle, cursor)
 532  }
 533
 534  return out + escapeHtml(url.slice(cursor))
 535}
 536
 537// Compact page-number list with ellipses, e.g. [1, '…', 4, 5, 6, '…', 12].
 538const urlPageList = computed<(number | '…')[]>(() => {
 539  const total = urlTotalPages.value
 540  const current = urlCurrentPage.value
 541  if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
 542  const pages: (number | '…')[] = [1]
 543  const left = Math.max(2, current - 1)
 544  const right = Math.min(total - 1, current + 1)
 545  if (left > 2) pages.push('…')
 546  for (let p = left; p <= right; p++) pages.push(p)
 547  if (right < total - 1) pages.push('…')
 548  pages.push(total)
 549  return pages
 550})
 551
 552function goToUrlPage(p: number) {
 553  const target = Math.min(Math.max(1, p), urlTotalPages.value)
 554  if (target === urlCurrentPage.value) return
 555  urlPage.value = target
 556  selectedIndex.value = filteredUrlResults.value.length ? 1 : -1
 557  nextTick(() => {
 558    if (resultsEl.value) resultsEl.value.scrollTop = 0
 559    scrollToSelectedResult()
 560  })
 561}
 562
 563// Reset to page 1 whenever the query changes or the page filter changes.
 564watch([urlFilterDebounced, urlActivePageFilter], () => {
 565  urlPage.value = 1
 566})
 567
 568// Reset URL ribbon filter if the active page disappears from the groups.
 569watch(urlMatches, () => {
 570  if (
 571    urlActivePageFilter.value &&
 572    !urlPageGroups.value.some((g) => g.key === urlActivePageFilter.value)
 573  ) {
 574    urlActivePageFilter.value = null
 575  }
 576})
 577
 578watch(urlSearchMode, (active) => {
 579  if (!active) {
 580    urlActivePageFilter.value = null
 581    urlPage.value = 1
 582  }
 583})
 584
 585function setUrlPageFilter(key: string | null) {
 586  urlActivePageFilter.value = urlActivePageFilter.value === key ? null : key
 587  urlPage.value = 1
 588  selectedIndex.value = filteredUrlResults.value.length ? 1 : -1
 589  nextTick(() => {
 590    if (resultsEl.value) resultsEl.value.scrollTop = 0
 591    scrollToSelectedResult()
 592  })
 593}
 594
 595const disableDetailedView = computed(() => {
 596  return (
 597    theme.value.search?.provider === 'local' &&
 598    theme.value.search.options?.detailedView === false
 599  )
 600})
 601
 602const buttonText = computed(() => {
 603  const options = theme.value.search?.options
 604
 605  return (
 606    options?.locales?.[localeIndex.value]?.translations?.button?.buttonText ||
 607    options?.translations?.button?.buttonText ||
 608    'Search'
 609  )
 610})
 611
 612watchEffect(() => {
 613  if (disableDetailedView.value) {
 614    showDetailedList.value = false
 615  }
 616})
 617
 618const results: Ref<(SearchResult & Result)[]> = shallowRef([])
 619
 620const currentTerms = shallowRef(new Set<string>())
 621
 622const enableNoResults = ref(false)
 623const textSearchLoading = ref(false)
 624const urlSearchLoading = ref(false)
 625const searchLoading = computed(() =>
 626  urlSearchMode.value ? urlSearchLoading.value : textSearchLoading.value
 627)
 628const pageMeta = (() => {
 629  const map = new Map<string, { label: string; order: number }>()
 630  let order = 0
 631  const stripIcon = (text: string) =>
 632    text
 633      .replace(/<[^>]*>/g, '')
 634      .replace(/\s+/g, ' ')
 635      .trim()
 636  const walk = (items: DefaultTheme.SidebarItem[]) => {
 637    for (const item of items) {
 638      if (item.link) {
 639        const key = item.link.replace(/\/$/, '')
 640        if (!map.has(key)) {
 641          map.set(key, { label: stripIcon(item.text ?? key), order: order++ })
 642        }
 643      }
 644      if (item.items) walk(item.items)
 645    }
 646  }
 647  walk(sidebar as DefaultTheme.SidebarItem[])
 648  return map
 649})()
 650
 651type SearchMode = 'exact' | 'fuzzy' | 'url'
 652
 653interface TextSearchWorkerPayload {
 654  results: (SearchResult & Result)[]
 655  terms: string[]
 656}
 657
 658interface UrlSearchWorkerPayload {
 659  matches: PageLink[]
 660  pageGroups: PageGroupCount[]
 661}
 662
 663interface LoadIndexWorkerRequest {
 664  type: 'load-index'
 665  localeIndex: string
 666  indexJson: unknown
 667  indexVersion: number
 668  config: ReturnType<typeof getMiniSearchWorkerConfig>
 669}
 670
 671interface TextSearchWorkerRequest {
 672  type: 'text-search'
 673  query: string
 674  mode: SearchMode
 675  pageOrderEntries: [string, number][]
 676}
 677
 678interface UrlSearchWorkerRequest {
 679  type: 'url-search'
 680  query: string
 681  pageOrderEntries: [string, number][]
 682}
 683
 684interface PreloadMetadataWorkerRequest {
 685  type: 'preload-metadata'
 686  pageOrderEntries: [string, number][]
 687}
 688
 689type SearchWorkerRequest =
 690  | LoadIndexWorkerRequest
 691  | TextSearchWorkerRequest
 692  | UrlSearchWorkerRequest
 693  | PreloadMetadataWorkerRequest
 694
 695const activePageFilter = ref<string | null>(null)
 696const searchWorkerReady = ref(false)
 697const searchWorkerConfigKey = computed(() =>
 698  JSON.stringify(getMiniSearchWorkerConfig())
 699)
 700let searchWorker: Worker | undefined
 701let searchWorkerRequestId = 0
 702let loadedWorkerIndexKey = ''
 703let preloadedSearchDataKey = ''
 704let preloadSearchDataRequest:
 705  | { key: string; promise: Promise<void> }
 706  | undefined
 707const searchWorkerRequests = new Map<
 708  number,
 709  {
 710    resolve: (value: unknown) => void
 711    reject: (reason?: unknown) => void
 712  }
 713>()
 714
 715function getPageOrderEntries(): [string, number][] {
 716  return [...pageMeta.entries()].map(([key, meta]) => [key, meta.order])
 717}
 718
 719async function preloadSearchData(
 720  localeIndexValue: string,
 721  indexVersion: number,
 722  configKey: string
 723) {
 724  const workerIndexKey = `${localeIndexValue}\n${indexVersion}\n${configKey}`
 725  if (preloadedSearchDataKey === workerIndexKey) return
 726  if (preloadSearchDataRequest?.key === workerIndexKey) {
 727    await preloadSearchDataRequest.promise
 728    return
 729  }
 730
 731  const promise = (async () => {
 732    if (loadedWorkerIndexKey !== workerIndexKey) {
 733      const indexJson = (await searchIndexData.value[localeIndexValue]?.())
 734        ?.default
 735      await postSearchWorker<void>({
 736        type: 'load-index',
 737        localeIndex: localeIndexValue,
 738        indexJson,
 739        indexVersion,
 740        config: getMiniSearchWorkerConfig()
 741      })
 742      loadedWorkerIndexKey = workerIndexKey
 743    }
 744
 745    await postSearchWorker<void>({
 746      type: 'preload-metadata',
 747      pageOrderEntries: getPageOrderEntries()
 748    })
 749    preloadedSearchDataKey = workerIndexKey
 750  })()
 751
 752  preloadSearchDataRequest = { key: workerIndexKey, promise }
 753  try {
 754    await promise
 755  } finally {
 756    if (preloadSearchDataRequest?.promise === promise) {
 757      preloadSearchDataRequest = undefined
 758    }
 759  }
 760}
 761
 762function stripNonCloneable(value: unknown): unknown {
 763  if (typeof value === 'function' || typeof value === 'symbol') return undefined
 764  if (!value || typeof value !== 'object') return value
 765  if (Array.isArray(value)) {
 766    return value
 767      .map((item) => stripNonCloneable(item))
 768      .filter((item) => item !== undefined)
 769  }
 770
 771  const out: Record<string, unknown> = {}
 772  for (const [key, nestedValue] of Object.entries(value)) {
 773    const cloneable = stripNonCloneable(nestedValue)
 774    if (cloneable !== undefined) out[key] = cloneable
 775  }
 776  return out
 777}
 778
 779function getMiniSearchWorkerConfig() {
 780  const miniSearch = theme.value.search?.provider === 'local'
 781    ? theme.value.search.options?.miniSearch
 782    : undefined
 783  const rawSearchOptions = miniSearch?.searchOptions as
 784    | Record<string, unknown>
 785    | undefined
 786
 787  return {
 788    options: stripNonCloneable(miniSearch?.options) as
 789      | Record<string, unknown>
 790      | undefined,
 791    searchOptions: stripNonCloneable(rawSearchOptions) as
 792      | Record<string, unknown>
 793      | undefined,
 794    useDefaultBoostDocument:
 795      typeof rawSearchOptions?.boostDocument === 'function'
 796  }
 797}
 798
 799function ensureSearchWorker() {
 800  if (!inBrowser || searchWorker) return searchWorker
 801
 802  try {
 803    searchWorker = new Worker(
 804      new URL('../workers/searchWorker.ts', import.meta.url),
 805      {
 806        type: 'module'
 807      }
 808    )
 809  } catch (error) {
 810    console.error('[search] failed to start search worker', error)
 811    return
 812  }
 813
 814  searchWorker.onmessage = (event: MessageEvent) => {
 815    const data = event.data as {
 816      id: number
 817      type: string
 818      payload?: unknown
 819      error?: string
 820    }
 821    const request = searchWorkerRequests.get(data.id)
 822    if (!request) return
 823
 824    searchWorkerRequests.delete(data.id)
 825    if (data.type.endsWith(':error')) {
 826      request.reject(new Error(data.error ?? 'Search worker failed'))
 827    } else {
 828      request.resolve(data.payload)
 829    }
 830  }
 831  searchWorker.onerror = (event) => {
 832    console.error('[search] search worker error', event)
 833  }
 834  searchWorkerReady.value = true
 835  return searchWorker
 836}
 837
 838function postSearchWorker<T>(message: SearchWorkerRequest) {
 839  const worker = ensureSearchWorker()
 840  if (!worker) return Promise.reject(new Error('Search worker is unavailable'))
 841
 842  const id = ++searchWorkerRequestId
 843  return new Promise<T>((resolve, reject) => {
 844    searchWorkerRequests.set(id, {
 845      resolve: (value) => resolve(value as T),
 846      reject
 847    })
 848    worker.postMessage({ ...message, id })
 849  })
 850}
 851
 852onMounted(() => {
 853  ensureSearchWorker()
 854})
 855
 856onBeforeUnmount(() => {
 857  searchWorker?.terminate()
 858  searchWorker = undefined
 859  loadedWorkerIndexKey = ''
 860  preloadedSearchDataKey = ''
 861  preloadSearchDataRequest = undefined
 862  searchWorkerReady.value = false
 863  for (const request of searchWorkerRequests.values()) {
 864    request.reject(new Error('Search worker was terminated'))
 865  }
 866  searchWorkerRequests.clear()
 867})
 868
 869watch(
 870  () =>
 871    [
 872      searchWorkerReady.value,
 873      showSearch.value,
 874      localeIndex.value,
 875      searchIndexVersion.value,
 876      searchWorkerConfigKey.value
 877    ] as const,
 878  async ([ready, isOpen, localeIndexValue, indexVersion, configKey]) => {
 879    if (!ready || !isOpen) return
 880
 881    try {
 882      await preloadSearchData(localeIndexValue, indexVersion, configKey)
 883    } catch (error) {
 884      console.error('[search] search data preload failed', error)
 885    }
 886  },
 887  { immediate: true }
 888)
 889
 890watch(
 891  () =>
 892    [
 893      searchWorkerReady.value,
 894      showSearch.value,
 895      urlSearchMode.value,
 896      urlFilterDebounced.value
 897    ] as const,
 898  async ([ready, isOpen, active, query], _old, onCleanup) => {
 899    let canceled = false
 900    onCleanup(() => {
 901      canceled = true
 902    })
 903
 904    if (!active || !isOpen || !query.trim()) {
 905      urlMatches.value = []
 906      urlPageGroupCounts.value = []
 907      urlSearchLoading.value = false
 908      return
 909    }
 910    if (!ready) {
 911      urlSearchLoading.value = false
 912      return
 913    }
 914
 915    urlSearchLoading.value = true
 916    try {
 917      const payload = await postSearchWorker<UrlSearchWorkerPayload>({
 918        type: 'url-search',
 919        query,
 920        pageOrderEntries: getPageOrderEntries()
 921      })
 922      if (canceled) return
 923      urlMatches.value = payload.matches
 924      urlPageGroupCounts.value = payload.pageGroups
 925      urlSearchLoading.value = false
 926    } catch (error) {
 927      if (!canceled) {
 928        console.error('[search] URL search worker request failed', error)
 929        urlMatches.value = []
 930        urlPageGroupCounts.value = []
 931        urlSearchLoading.value = false
 932      }
 933    }
 934  },
 935  { immediate: true }
 936)
 937
 938function getPageKey(id: string) {
 939  return getDocId(id).replace(/\/$/, '')
 940}
 941
 942function getDocId(id: string) {
 943  const hashIndex = id.indexOf('#')
 944  return hashIndex === -1 ? id : id.slice(0, hashIndex)
 945}
 946
 947function getDocAnchor(id: string) {
 948  const hashIndex = id.indexOf('#')
 949  return hashIndex === -1 ? '' : id.slice(hashIndex + 1)
 950}
 951
 952function getPageLabel(key: string) {
 953  return pageMeta.get(key)?.label ?? key.replace(/^\//, '')
 954}
 955
 956function getPageOrder(key: string) {
 957  return pageMeta.get(key)?.order ?? Number.MAX_SAFE_INTEGER
 958}
 959
 960const pageGroups = computed(() => {
 961  const map = new Map<string, { key: string; label: string; count: number }>()
 962  for (const r of results.value) {
 963    const key = getPageKey(r.id)
 964    const existing = map.get(key)
 965    if (existing) existing.count++
 966    else map.set(key, { key, label: getPageLabel(key), count: 1 })
 967  }
 968  return [...map.values()].sort(
 969    (a, b) => getPageOrder(a.key) - getPageOrder(b.key)
 970  )
 971})
 972
 973const filteredResults = computed(() => {
 974  if (!activePageFilter.value) return results.value
 975  return results.value.filter(
 976    (r) => getPageKey(r.id) === activePageFilter.value
 977  )
 978})
 979
 980// --- Normal-mode (exact/fuzzy) pagination ---------------------------------
 981// Mirrors the URL-mode pager. filteredResults stays the full filtered set;
 982// pagedResults is the current page slice that actually renders.
 983const NORMAL_PAGE_SIZE = URL_PAGE_SIZE
 984
 985const normalPage = ref(1)
 986
 987const normalTotalPages = computed(() =>
 988  Math.max(1, Math.ceil(filteredResults.value.length / NORMAL_PAGE_SIZE))
 989)
 990
 991const normalCurrentPage = computed(() =>
 992  Math.min(normalPage.value, normalTotalPages.value)
 993)
 994
 995const pagedResults = computed(() => {
 996  const start = (normalCurrentPage.value - 1) * NORMAL_PAGE_SIZE
 997  return filteredResults.value.slice(start, start + NORMAL_PAGE_SIZE)
 998})
 999
1000const normalPageList = computed<(number | '…')[]>(() => {
1001  const total = normalTotalPages.value
1002  const current = normalCurrentPage.value
1003  if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
1004  const pages: (number | '…')[] = [1]
1005  const left = Math.max(2, current - 1)
1006  const right = Math.min(total - 1, current + 1)
1007  if (left > 2) pages.push('…')
1008  for (let p = left; p <= right; p++) pages.push(p)
1009  if (right < total - 1) pages.push('…')
1010  pages.push(total)
1011  return pages
1012})
1013
1014function goToNormalPage(p: number) {
1015  const target = Math.min(Math.max(1, p), normalTotalPages.value)
1016  if (target === normalCurrentPage.value) return
1017  normalPage.value = target
1018  selectedIndex.value = pagedResults.value.length ? 1 : -1
1019  nextTick(() => {
1020    if (resultsEl.value) resultsEl.value.scrollTop = 0
1021    scrollToSelectedResult()
1022    reapplyHighlights()
1023    void buildVisibleExcerpts()
1024  })
1025}
1026
1027// ---------------------------------------------------------------------------
1028
1029function setPageFilter(key: string | null) {
1030  activePageFilter.value = activePageFilter.value === key ? null : key
1031  normalPage.value = 1
1032  selectedIndex.value = filteredResults.value.length ? 1 : -1
1033  nextTick(() => {
1034    if (resultsEl.value) resultsEl.value.scrollTop = 0
1035    scrollToSelectedResult()
1036    reapplyHighlights()
1037    void buildVisibleExcerpts()
1038  })
1039}
1040
1041async function reapplyHighlights() {
1042  if (!showDetailedList.value || !currentTerms.value.size) {
1043    centerExcerptsUntilSettled()
1044    return
1045  }
1046  await new Promise<void>((resolve) => {
1047    mark.value?.unmark({
1048      done: () => {
1049        mark.value?.markRegExp(formMarkRegex(currentTerms.value), {
1050          done: () => resolve()
1051        })
1052      }
1053    })
1054  })
1055  await nextTick()
1056  centerExcerptsUntilSettled()
1057}
1058
1059const toRows = (list: (SearchResult & Result)[]) =>
1060  list.map((r) => {
1061    const map = cache.get(getDocId(r.id))
1062    return { ...r, text: map?.get(getDocAnchor(r.id)) ?? '' }
1063  })
1064
1065let excerptBuildToken = 0
1066
1067function visiblePageDocs(pageOffset: number): string[] {
1068  const start = (normalCurrentPage.value - 1 + pageOffset) * NORMAL_PAGE_SIZE
1069  if (start < 0) return []
1070  const list = filteredResults.value
1071  const docs: string[] = []
1072  const seen = new Set<string>()
1073  for (let i = start; i < start + NORMAL_PAGE_SIZE && i < list.length; i++) {
1074    const docId = getDocId(String(list[i].id))
1075    if (!seen.has(docId)) {
1076      seen.add(docId)
1077      docs.push(docId)
1078    }
1079  }
1080  return docs
1081}
1082
1083// Builds excerpts for the visible pagination page, then prefetches the next.
1084async function buildVisibleExcerpts() {
1085  const token = ++excerptBuildToken
1086  if (!showDetailedList.value || urlSearchMode.value) return
1087
1088  let builtAny = false
1089  let sliceStart = performance.now()
1090
1091  const refreshRows = async () => {
1092    const keepSelected = selectedIndex.value
1093    results.value = toRows(results.value)
1094    await nextTick()
1095    if (token !== excerptBuildToken) return false
1096    selectedIndex.value = keepSelected
1097    return true
1098  }
1099
1100  const buildAll = async (docIds: string[], progressive = false) => {
1101    for (const docId of docIds) {
1102      if (cache.get(docId)) continue
1103      await buildDocExcerpt(docId)
1104      if (token !== excerptBuildToken) return false
1105      builtAny = true
1106      if (performance.now() - sliceStart > 40) {
1107        if (progressive && !(await refreshRows())) return false
1108        await nextFrame()
1109        if (token !== excerptBuildToken) return false
1110        sliceStart = performance.now()
1111      }
1112    }
1113    return true
1114  }
1115
1116  if (!(await buildAll(visiblePageDocs(0), true))) return
1117
1118  const rowsStale = pagedResults.value.some((r) => {
1119    if (r.text) return false
1120    const map = cache.get(getDocId(String(r.id)))
1121    return Boolean(map?.get(getDocAnchor(String(r.id))))
1122  })
1123
1124  if (builtAny || rowsStale) {
1125    if (!(await refreshRows())) return
1126    await reapplyHighlights()
1127    if (token !== excerptBuildToken) return
1128  }
1129
1130  if (excerptPreload.value === 'next') {
1131    await buildAll(visiblePageDocs(1))
1132  } else if (excerptPreload.value === 'all') {
1133    const seen = new Set<string>()
1134    const docs: string[] = []
1135    for (const r of results.value) {
1136      const docId = getDocId(String(r.id))
1137      if (!seen.has(docId)) {
1138        seen.add(docId)
1139        docs.push(docId)
1140      }
1141    }
1142    await buildAll(docs)
1143  }
1144}
1145
1146watch(excerptPreload, () => {
1147  void buildVisibleExcerpts()
1148})
1149
1150watch(results, () => {
1151  if (
1152    activePageFilter.value &&
1153    !pageGroups.value.some((g) => g.key === activePageFilter.value)
1154  ) {
1155    activePageFilter.value = null
1156  }
1157})
1158
1159watch(filterText, () => {
1160  enableNoResults.value = false
1161})
1162
1163const ribbonTrack = shallowRef<HTMLElement>()
1164const ribbonCanScrollLeft = ref(false)
1165const ribbonCanScrollRight = ref(false)
1166
1167function getRibbonTrack(): HTMLElement | null {
1168  return (
1169    ribbonTrack.value ??
1170      (el.value?.querySelector('.page-ribbon-track') as HTMLElement | null)
1171  )
1172}
1173
1174function updateRibbonOverflow() {
1175  const track = getRibbonTrack()
1176  if (!track) {
1177    ribbonCanScrollLeft.value = false
1178    ribbonCanScrollRight.value = false
1179    return
1180  }
1181  ribbonCanScrollLeft.value = track.scrollLeft > 2
1182  ribbonCanScrollRight.value =
1183    track.scrollWidth - track.clientWidth - track.scrollLeft > 2
1184}
1185
1186function scrollActivePagePillIntoView(direction = 0) {
1187  nextTick(() => {
1188    const track = getRibbonTrack()
1189    if (!track) return
1190
1191    const pills = [...track.querySelectorAll<HTMLElement>('.page-pill')]
1192    const activeIndex = pills.findIndex((pill) =>
1193      pill.classList.contains('active')
1194    )
1195    const active = pills[activeIndex]
1196    if (!active) return
1197
1198    const trackRect = track.getBoundingClientRect()
1199    const activeRect = active.getBoundingClientRect()
1200    const gap = 8
1201    let nextScrollLeft = track.scrollLeft
1202
1203    if (activeRect.left < trackRect.left) {
1204      nextScrollLeft += activeRect.left - trackRect.left - gap
1205    } else if (activeRect.right > trackRect.right) {
1206      nextScrollLeft += activeRect.right - trackRect.right + gap
1207    }
1208
1209    const peek = pills[activeIndex + Math.sign(direction)]
1210    if (peek) {
1211      const peekRect = peek.getBoundingClientRect()
1212      if (direction > 0 && peekRect.right > trackRect.right) {
1213        nextScrollLeft += peekRect.right - trackRect.right + gap
1214      } else if (direction < 0 && peekRect.left < trackRect.left) {
1215        nextScrollLeft += peekRect.left - trackRect.left - gap
1216      }
1217    }
1218
1219    const max = track.scrollWidth - track.clientWidth
1220    track.scrollTo({
1221      left: Math.max(0, Math.min(max, nextScrollLeft)),
1222      behavior: searchAnimationsEnabled.value ? 'smooth' : 'auto'
1223    })
1224    updateRibbonOverflow()
1225  })
1226}
1227
1228let ribbonAnimHandle = 0
1229
1230function scrollRibbon(direction: number) {
1231  const track = getRibbonTrack()
1232  if (!track) return
1233  const max = track.scrollWidth - track.clientWidth
1234  const amount = track.clientWidth * 0.7 * direction
1235  const from = track.scrollLeft
1236  const to = Math.max(0, Math.min(max, from + amount))
1237  if (to === from) return
1238
1239  if (ribbonAnimHandle) cancelAnimationFrame(ribbonAnimHandle)
1240
1241  if (!searchAnimationsEnabled.value) {
1242    track.scrollLeft = to
1243    updateRibbonOverflow()
1244    return
1245  }
1246
1247  const duration = 280
1248  const start = performance.now()
1249  const ease = (t: number) => 1 - Math.pow(1 - t, 3)
1250
1251  const step = (now: number) => {
1252    const t = Math.min(1, (now - start) / duration)
1253    track.scrollLeft = from + (to - from) * ease(t)
1254    updateRibbonOverflow()
1255    if (t < 1) {
1256      ribbonAnimHandle = requestAnimationFrame(step)
1257    } else {
1258      ribbonAnimHandle = 0
1259    }
1260  }
1261  ribbonAnimHandle = requestAnimationFrame(step)
1262}
1263
1264watch(pageGroups, () => {
1265  nextTick(updateRibbonOverflow)
1266})
1267
1268watch(urlPageGroups, () => {
1269  nextTick(updateRibbonOverflow)
1270})
1271
1272useEventListener('resize', () => {
1273  updateRibbonOverflow()
1274})
1275
1276const mark = computedAsync(async () => {
1277  if (!resultsEl.value) return
1278  return markRaw(new Mark(resultsEl.value))
1279}, null)
1280
1281const cache = new LRUCache<string, Map<string, string>>(120)
1282
1283const inFlightExcerpts = new Map<string, Promise<void>>()
1284
1285function buildDocExcerpt(docId: string): Promise<void> {
1286  if (cache.get(docId)) return Promise.resolve()
1287  const pending = inFlightExcerpts.get(docId)
1288  if (pending) return pending
1289
1290  const job = (async () => {
1291    const { mod } = await fetchExcerpt(docId)
1292    if (cache.get(docId)) return
1293
1294    const comp = (mod as any).default ?? mod
1295    if (!(comp?.render || comp?.setup)) return // nothing renderable; don't cache
1296
1297    const map = new Map<string, string>()
1298    const app = createApp(comp)
1299    app.config.warnHandler = () => {}
1300    enhanceAppWithTabs(app, { renderAll: true })
1301    app.provide(dataSymbol, vitePressData)
1302    Object.defineProperties(app.config.globalProperties, {
1303      $frontmatter: {
1304        get() {
1305          return vitePressData.frontmatter.value
1306        }
1307      },
1308      $params: {
1309        get() {
1310          return vitePressData.page.value.params
1311        }
1312      }
1313    })
1314    const div = document.createElement('div')
1315    try {
1316      // force lazy images so the detached render doesn't download them
1317      const originalCreateElement = document.createElement
1318      document.createElement = function (
1319        this: Document,
1320        ...args: Parameters<Document['createElement']>
1321      ) {
1322        const el = originalCreateElement.apply(this, args)
1323        if (el instanceof HTMLImageElement) {
1324          el.loading = 'lazy'
1325          el.decoding = 'async'
1326        }
1327        return el
1328      } as typeof document.createElement
1329      try {
1330        app.mount(div)
1331      } finally {
1332        document.createElement = originalCreateElement
1333      }
1334      const headings = div.querySelectorAll('h1, h2, h3, h4, h5, h6')
1335      headings.forEach((heading) => {
1336        const href = heading.querySelector('a')?.getAttribute('href')
1337        const anchor = href?.startsWith('#') && href.slice(1)
1338        if (!anchor) return
1339        let html = ''
1340        let node = heading as Element
1341        while (
1342          (node = node.nextElementSibling!) &&
1343          !/^h[1-6]$/i.test(node.tagName)
1344        ) {
1345          html += (node as HTMLElement).outerHTML
1346        }
1347        map.set(anchor, html)
1348      })
1349    } catch (e) {
1350      console.error('[search] excerpt render failed for', docId, e)
1351    } finally {
1352      try {
1353        app.unmount()
1354      } catch {
1355        /* ignore */
1356      }
1357    }
1358    cache.set(docId, map)
1359  })()
1360
1361  inFlightExcerpts.set(docId, job)
1362  job.finally(() => {
1363    if (inFlightExcerpts.get(docId) === job) inFlightExcerpts.delete(docId)
1364  })
1365  return job
1366}
1367
1368watchDebounced(
1369  () =>
1370    [
1371      searchWorkerReady.value,
1372      showSearch.value,
1373      localeIndex.value,
1374      searchIndexVersion.value,
1375      searchWorkerConfigKey.value,
1376      filterText.value,
1377      showDetailedList.value,
1378      searchMode.value
1379    ] as const,
1380  async (
1381    [
1382      ready,
1383      isOpen,
1384      localeIndexValue,
1385      indexVersion,
1386      configKey,
1387      filterTextValue,
1388      showDetailedListValue,
1389      mode
1390    ],
1391    old,
1392    onCleanup
1393  ) => {
1394    if (
1395      old?.[2] !== localeIndexValue ||
1396      old?.[3] !== indexVersion ||
1397      old?.[4] !== configKey
1398    ) {
1399      // Locale/config changes rebuild the worker index, so cached excerpts may no
1400      // longer match the active result set.
1401      cache.clear()
1402    }
1403
1404    let canceled = false
1405    onCleanup(() => {
1406      canceled = true
1407    })
1408
1409    excerptBuildToken++
1410
1411    if (!ready || !isOpen) {
1412      textSearchLoading.value = false
1413      return
1414    }
1415
1416    // In URL search mode, skip normal text search
1417    if (mode === 'url') {
1418      results.value = []
1419      currentTerms.value = new Set()
1420      enableNoResults.value = Boolean(filterTextValue.trim())
1421      textSearchLoading.value = false
1422      return
1423    }
1424
1425    const searchQuery = filterTextValue.trim()
1426    textSearchLoading.value = Boolean(searchQuery)
1427
1428    try {
1429      await preloadSearchData(localeIndexValue, indexVersion, configKey)
1430      if (canceled) return
1431    } catch (error) {
1432      if (!canceled) {
1433        console.error('[search] text search index preload failed', error)
1434        results.value = []
1435        currentTerms.value = new Set()
1436        enableNoResults.value = Boolean(searchQuery)
1437        textSearchLoading.value = false
1438      }
1439      return
1440    }
1441
1442    if (!searchQuery) {
1443      results.value = []
1444      currentTerms.value = new Set()
1445      enableNoResults.value = false
1446      textSearchLoading.value = false
1447      return
1448    }
1449
1450    let workerPayload: TextSearchWorkerPayload
1451    try {
1452      workerPayload = await postSearchWorker<TextSearchWorkerPayload>({
1453        type: 'text-search',
1454        query: searchQuery,
1455        mode,
1456        pageOrderEntries: getPageOrderEntries()
1457      })
1458    } catch (error) {
1459      if (!canceled) {
1460        console.error('[search] text search worker request failed', error)
1461        results.value = []
1462        currentTerms.value = new Set()
1463        enableNoResults.value = true
1464        textSearchLoading.value = false
1465      }
1466      return
1467    }
1468    if (canceled) return
1469
1470    const _result = workerPayload.results
1471    const terms = new Set(workerPayload.terms)
1472    currentTerms.value = terms
1473    enableNoResults.value = true
1474
1475    if (!_result.length) {
1476      results.value = []
1477      textSearchLoading.value = false
1478      return
1479    }
1480
1481    const highlight = () =>
1482      new Promise<void>((resolve) => {
1483        if (!terms.size || !mark.value) {
1484          resolve()
1485          return
1486        }
1487        mark.value.unmark({
1488          done: () => {
1489            mark.value?.markRegExp(formMarkRegex(terms), {
1490              done: () => resolve()
1491            })
1492          }
1493        })
1494      })
1495
1496    normalPage.value = 1
1497
1498    // Show results immediately; excerpts fill in below once built
1499    results.value = toRows(_result)
1500
1501    await nextTick()
1502    if (canceled) return
1503    await highlight()
1504    await nextTick()
1505    await nextFrame()
1506    if (canceled) return
1507
1508    if (resultsEl.value) {
1509      resultsEl.value.scrollTop = 0
1510    }
1511    centerExcerptsUntilSettled()
1512
1513    if (showDetailedListValue) {
1514      await buildVisibleExcerpts()
1515      if (canceled) return
1516    }
1517    textSearchLoading.value = false
1518  },
1519  { debounce: 80, immediate: true }
1520)
1521
1522function centerExcerpts() {
1523  const excerpts = el.value?.querySelectorAll('.result .excerpt') ?? []
1524  for (let i = 0; i < excerpts.length; i++) {
1525    const excerptElement = excerpts[i] as HTMLElement
1526
1527    const markNode = excerptElement.querySelector(
1528      'mark[data-markjs="true"]'
1529    ) as HTMLElement | null
1530    if (!markNode) continue
1531
1532    const viewportHeight = excerptElement.clientHeight || 84
1533
1534    let offset = 0
1535    let node: HTMLElement | null = markNode
1536    while (node && node !== excerptElement) {
1537      offset += node.offsetTop
1538      node = node.offsetParent as HTMLElement | null
1539    }
1540
1541    const targetScrollTop = offset - viewportHeight / 2 +
1542      markNode.offsetHeight / 2
1543    excerptElement.scrollTop = Math.max(0, targetScrollTop)
1544  }
1545}
1546
1547let centerHandle = 0
1548
1549function centerExcerptsUntilSettled(
1550  duration = searchAnimationsEnabled.value ? 450 : 0
1551) {
1552  if (centerHandle) cancelAnimationFrame(centerHandle)
1553
1554  if (duration <= 0) {
1555    centerHandle = requestAnimationFrame(() => {
1556      centerExcerpts()
1557      centerHandle = 0
1558    })
1559    return
1560  }
1561
1562  const start = performance.now()
1563  const tick = () => {
1564    centerExcerpts()
1565    if (performance.now() - start < duration) {
1566      centerHandle = requestAnimationFrame(tick)
1567    } else {
1568      centerHandle = 0
1569    }
1570  }
1571  centerHandle = requestAnimationFrame(tick)
1572}
1573
1574onBeforeUnmount(() => {
1575  if (centerHandle) cancelAnimationFrame(centerHandle)
1576  if (ribbonAnimHandle) cancelAnimationFrame(ribbonAnimHandle)
1577})
1578
1579const excerptCache = new LRUCache<string, unknown>(24)
1580
1581async function fetchExcerpt(id: string) {
1582  const docId = getDocId(id)
1583
1584  const cached = excerptCache.get(docId)
1585  if (cached) return { id, mod: cached }
1586
1587  const file = pathToFile(docId)
1588  try {
1589    if (!file) throw new Error(`Cannot find file for id: ${id}`)
1590    const mod = await import(/*@vite-ignore*/ file)
1591
1592    excerptCache.set(docId, mod)
1593
1594    return { id, mod }
1595  } catch (e) {
1596    console.error(e)
1597    return { id, mod: {} }
1598  }
1599}
1600
1601const nextFrame = () =>
1602  new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
1603
1604function hasExcerptPreview(html?: string) {
1605  if (!html) return false
1606  for (let i = 0; i < html.length; i++) {
1607    const ch = html[i]
1608    if (ch === '<') {
1609      const close = html.indexOf('>', i + 1)
1610      if (close === -1) return false
1611      i = close
1612      continue
1613    }
1614    if (ch === '&') {
1615      const entity = html.slice(i, i + 6).toLowerCase()
1616      if (entity === '&nbsp;' || entity === '&#160;') {
1617        i += 5
1618        continue
1619      }
1620      return true
1621    }
1622    if (!/\s/.test(ch)) return true
1623  }
1624  return false
1625}
1626
1627/* Search input focus */
1628
1629const searchInput = ref<HTMLInputElement>()
1630const disableReset = computed(() => {
1631  return filterText.value?.length <= 0
1632})
1633function focusSearchInput(select = true) {
1634  searchInput.value?.focus()
1635  select && searchInput.value?.select()
1636}
1637
1638onMounted(() => {
1639  focusSearchInput()
1640})
1641
1642function onSearchBarClick(event: PointerEvent) {
1643  if (event.pointerType === 'mouse') {
1644    focusSearchInput()
1645  }
1646}
1647
1648/* Search keyboard selection */
1649
1650const selectedIndex = ref(-1)
1651const disableMouseOver = ref(true)
1652
1653// Active result list length (URL mode vs normal mode) — current page only
1654const activeResultsLength = computed(() =>
1655  urlSearchMode.value
1656    ? filteredUrlResults.value.length
1657    : pagedResults.value.length
1658)
1659
1660watch(pagedResults, (r) => {
1661  if (!urlSearchMode.value) {
1662    selectedIndex.value = r.length ? 0 : -1
1663    scrollToSelectedResult()
1664  }
1665})
1666
1667watch(filteredUrlResults, (r) => {
1668  if (urlSearchMode.value) {
1669    selectedIndex.value = r.length ? 0 : -1
1670    scrollToSelectedResult()
1671  }
1672})
1673
1674function scrollToSelectedResult() {
1675  nextTick(() => {
1676    const selectedEl = document.querySelector('.result.selected')
1677    selectedEl?.scrollIntoView({ block: 'nearest' })
1678  })
1679}
1680
1681function goToSearchPageDelta(delta: number) {
1682  if (urlSearchMode.value) {
1683    const target = urlCurrentPage.value + delta
1684    if (target < 1 || target > urlTotalPages.value) return false
1685    goToUrlPage(target)
1686    return true
1687  }
1688
1689  const target = normalCurrentPage.value + delta
1690  if (target < 1 || target > normalTotalPages.value) return false
1691  goToNormalPage(target)
1692  return true
1693}
1694
1695function cyclePageTab(delta: number) {
1696  if (urlSearchMode.value) {
1697    if (urlPageGroups.value.length <= 1) return false
1698    const keys = [null, ...urlPageGroups.value.map((group) => group.key)]
1699    const current = keys.indexOf(urlActivePageFilter.value)
1700    const next = (current + delta + keys.length) % keys.length
1701    setUrlPageFilter(keys[next])
1702    scrollActivePagePillIntoView(delta)
1703    return true
1704  }
1705
1706  if (pageGroups.value.length <= 1) return false
1707  const keys = [null, ...pageGroups.value.map((group) => group.key)]
1708  const current = keys.indexOf(activePageFilter.value)
1709  const next = (current + delta + keys.length) % keys.length
1710  setPageFilter(keys[next])
1711  scrollActivePagePillIntoView(delta)
1712  return true
1713}
1714
1715onKeyStroke('ArrowUp', (event) => {
1716  event.preventDefault()
1717  selectedIndex.value--
1718  if (selectedIndex.value < 0) {
1719    selectedIndex.value = activeResultsLength.value - 1
1720  }
1721  disableMouseOver.value = true
1722  scrollToSelectedResult()
1723})
1724
1725onKeyStroke('ArrowDown', (event) => {
1726  event.preventDefault()
1727  selectedIndex.value++
1728  if (selectedIndex.value >= activeResultsLength.value + 1) {
1729    selectedIndex.value = 0
1730  }
1731  disableMouseOver.value = true
1732  scrollToSelectedResult()
1733})
1734
1735onKeyStroke('ArrowLeft', (event) => {
1736  if (!goToSearchPageDelta(-1)) return
1737  event.preventDefault()
1738  disableMouseOver.value = true
1739})
1740
1741onKeyStroke('ArrowRight', (event) => {
1742  if (!goToSearchPageDelta(1)) return
1743  event.preventDefault()
1744  disableMouseOver.value = true
1745})
1746
1747onKeyStroke('Tab', (event) => {
1748  if (!showSearch.value) return
1749  if (!cyclePageTab(event.shiftKey ? -1 : 1)) return
1750  event.preventDefault()
1751  disableMouseOver.value = true
1752})
1753
1754const router = useRouter()
1755
1756function buildResultHref(pageId: string, tabs?: string[], anchor = '') {
1757  const params: string[] = []
1758  if (tabs?.length) {
1759    params.push(`t=${tabs.map((tab) => encodeURIComponent(tab)).join(',')}`)
1760  }
1761
1762  let hash = ''
1763  if (anchor.startsWith('collapsible-')) {
1764    const collapsible = anchor.slice('collapsible-'.length)
1765    if (collapsible) params.push(`c=${encodeURIComponent(collapsible)}`)
1766  } else {
1767    const lastTab = tabs?.length ? tabs[tabs.length - 1] : ''
1768    const isRedundantTabHeading = Boolean(anchor) && anchor === `tab-${lastTab}`
1769    if (anchor && !isRedundantTabHeading) {
1770      hash = `#${encodeURIComponent(anchor)}`
1771    }
1772  }
1773
1774  const query = params.length ? `?${params.join('&')}` : ''
1775  return `${pageId}${query}${hash}`
1776}
1777
1778function getSearchResultHref(item: SearchResult & Result) {
1779  const id = String(item.id)
1780  const hashIndex = id.indexOf('#')
1781  if (hashIndex < 0) return buildResultHref(id, item.tabs)
1782
1783  return buildResultHref(
1784    id.slice(0, hashIndex),
1785    item.tabs,
1786    id.slice(hashIndex + 1)
1787  )
1788}
1789
1790function navigateToUrlResult(item: UrlResult) {
1791  saveToHistory(filterText.value, searchMode.value, [getPageLabel(item.pageId), ...item.titles, item.linkText].map(toHistoryPathHtml).filter(Boolean), buildResultHref(item.pageId, item.tabs, item.anchor))
1792  window.dispatchEvent(
1793    new CustomEvent('search-nav', { detail: { query: filterText.value } })
1794  )
1795  router.go(buildResultHref(item.pageId, item.tabs, item.anchor))
1796  showSearch.value = false
1797}
1798
1799onKeyStroke('Enter', (e) => {
1800  if (e.isComposing) return
1801
1802  if (e.target instanceof HTMLButtonElement && e.target.type !== 'submit') {
1803    return
1804  }
1805
1806  const index = selectedIndex.value - 1
1807
1808  if (index === -1) {
1809    // @ts-ignore
1810    window.toggleAI({ value: filterText.value })
1811    showSearch.value = false
1812    return
1813  }
1814
1815  // URL search mode: navigate to the page containing the link (like normal search)
1816  if (urlSearchMode.value) {
1817    const selectedUrl = filteredUrlResults.value[index]
1818    if (selectedUrl) {
1819      navigateToUrlResult(selectedUrl)
1820    }
1821    return
1822  }
1823
1824  const selectedPackage = pagedResults.value[index]
1825  if (e.target instanceof HTMLInputElement && !selectedPackage) {
1826    e.preventDefault()
1827    return
1828  }
1829
1830  if (selectedPackage) {
1831    saveToHistory(filterText.value, searchMode.value, [getPageLabel(getPageKey(String(selectedPackage.id))), ...selectedPackage.titles, selectedPackage.title].map(toHistoryPathHtml).filter(Boolean), getSearchResultHref(selectedPackage))
1832    window.dispatchEvent(
1833      new CustomEvent('search-nav', {
1834        detail: { query: filterText.value }
1835      })
1836    )
1837    router.go(getSearchResultHref(selectedPackage))
1838    showSearch.value = false
1839  }
1840})
1841
1842function onResultClick(item: SearchResult & Result) {
1843  saveToHistory(filterText.value, searchMode.value, [getPageLabel(getPageKey(String(item.id))), ...item.titles, item.title].map(toHistoryPathHtml).filter(Boolean), getSearchResultHref(item))
1844  window.dispatchEvent(
1845    new CustomEvent('search-nav', {
1846      detail: { query: filterText.value }
1847    })
1848  )
1849  showSearch.value = false
1850}
1851
1852onKeyStroke('Escape', () => {
1853  if (showSettingsPopup.value) {
1854    showSettingsPopup.value = false
1855    return
1856  }
1857  showSearch.value = false
1858})
1859
1860// Translations
1861const defaultTranslations = {
1862  modal: {
1863    displayDetails: 'Display detailed list',
1864    exactMatchTitle: 'Exact search',
1865    resetButtonTitle: 'Reset search',
1866    backButtonTitle: 'Close search',
1867    noResultsText: 'No results for',
1868    footer: {
1869      selectText: 'select',
1870      selectKeyAriaLabel: 'enter',
1871      navigateText: 'navigate',
1872      navigateUpKeyAriaLabel: 'up arrow',
1873      navigateDownKeyAriaLabel: 'down arrow',
1874      switchTabsText: 'switch tabs',
1875      switchTabsKeyAriaLabel: 'shift tab and tab',
1876      switchPagesText: 'switch pages',
1877      switchPagesKeyAriaLabel: 'left and right arrow',
1878      closeText: 'close',
1879      closeKeyAriaLabel: 'escape'
1880    }
1881  }
1882}
1883
1884const translate = createSearchTranslate(defaultTranslations)
1885
1886// Back
1887
1888onMounted(() => {
1889  // Prevents going to previous site
1890  window.history.pushState(null, '', null)
1891})
1892
1893useEventListener('popstate', (event) => {
1894  event.preventDefault()
1895  showSearch.value = false
1896})
1897
1898/** Lock body */
1899const isLocked = useScrollLock(inBrowser ? document.body : null)
1900
1901watch(
1902  () => showSearch.value,
1903  (val) => {
1904    if (!val) {
1905      isLocked.value = false
1906      return
1907    }
1908
1909    nextTick(() => {
1910      isLocked.value = true
1911      nextTick().then(() => {
1912        activate()
1913        updateRibbonOverflow()
1914      })
1915    })
1916  }
1917)
1918
1919function formMarkRegex(terms: Set<string>) {
1920  return new RegExp(
1921    [...terms]
1922      .sort((a, b) => b.length - a.length)
1923      .map((term) => `(${escapeRegExp(term)})`)
1924      .join('|'),
1925    'gi'
1926  )
1927}
1928
1929function decodeHtml(html: string): string {
1930  const txt = document.createElement('textarea')
1931  txt.innerHTML = html
1932  return txt.value
1933}
1934
1935function toHistoryPathHtml(html: string): string {
1936  const stripped = decodeHtml(html.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim())
1937  if (stripped) return escapeHtml(stripped)
1938  return html.trim()
1939}
1940
1941function resetSearch() {
1942  filterText.value = ''
1943  nextTick().then(() => focusSearchInput(false))
1944}
1945
1946function onMouseMove(e: MouseEvent) {
1947  if (!disableMouseOver.value) return
1948  const el = (e.target as HTMLElement)?.closest<HTMLAnchorElement>('.result')
1949  const index = Number.parseInt(el?.dataset.index!)
1950  if (index >= 0 && index !== selectedIndex.value) {
1951    selectedIndex.value = index
1952  }
1953  disableMouseOver.value = false
1954}
1955</script>
1956
1957<template>
1958  <Teleport to="body">
1959    <div
1960      ref="el"
1961      role="button"
1962      :aria-owns="results?.length ? 'localsearch-list' : undefined"
1963      aria-expanded="true"
1964      aria-haspopup="listbox"
1965      aria-labelledby="localsearch-label"
1966      class="VPLocalSearchBox"
1967      :class="{ 'pointer-events-none': !showSearch }"
1968    >
1969      <AnimatePresence>
1970        <component
1971          :is="searchMotionDiv"
1972          v-if="showSearch"
1973          class="backdrop"
1974          @click="showSearch = false"
1975          v-bind="backdropMotion"
1976        />
1977      </AnimatePresence>
1978
1979      <AnimatePresence>
1980        <component
1981          :is="searchMotionDiv"
1982          v-if="showSearch"
1983          class="shell"
1984          v-bind="shellMotion"
1985        >
1986          <component
1987            :is="searchMotionForm"
1988            class="search-bar"
1989            v-bind="formMotion"
1990            @pointerup="onSearchBarClick($event)"
1991            @submit.prevent=""
1992          >
1993            <label
1994              :title="buttonText"
1995              id="localsearch-label"
1996              for="localsearch-input"
1997            >
1998              <span
1999                aria-hidden="true"
2000                class="vpi-search search-icon local-search-icon"
2001              />
2002            </label>
2003            <div class="search-actions before">
2004              <button
2005                class="back-button"
2006                :title="translate('modal.backButtonTitle')"
2007                @click="showSearch = false"
2008              >
2009                <span class="vpi-arrow-left local-search-icon" />
2010              </button>
2011            </div>
2012            <input
2013              ref="searchInput"
2014              v-model="filterText"
2015              :aria-activedescendant="selectedIndex > -1
2016              ? 'localsearch-item-' + selectedIndex
2017              : undefined"
2018              aria-autocomplete="both"
2019              :aria-controls="results?.length ? 'localsearch-list' : undefined"
2020              aria-labelledby="localsearch-label"
2021              autocapitalize="off"
2022              autocomplete="off"
2023              autocorrect="off"
2024              class="search-input"
2025              id="localsearch-input"
2026              enterkeyhint="go"
2027              maxlength="64"
2028              :placeholder="buttonText"
2029              spellcheck="false"
2030              type="search"
2031            />
2032            <div class="search-actions">
2033              <button
2034                v-if="searchLoading"
2035                class="search-loading-button"
2036                type="button"
2037              >
2038                <img
2039                  class="search-loading-bubba"
2040                  src="/bubba.webp"
2041                  alt="Bubba loading"
2042                />
2043              </button>
2044              <div
2045                v-if="!disableDetailedView && searchMode !== 'url'"
2046                class="view-group toolbar-group"
2047              >
2048                <button
2049                  type="button"
2050                  class="mode-btn"
2051                  :class="{ 'mode-active': showDetailedList }"
2052                  title="Detail view (Consumes more RAM)"
2053                  @click="showDetailedList
2054                  ? showDetailedList = false
2055                  : showDetailedList = true"
2056                >
2057                  <TextAlignStart :size="18" stroke-width="2" />
2058                </button>
2059                <button
2060                  type="button"
2061                  class="mode-btn"
2062                  :class="{ 'mode-active': !showDetailedList }"
2063                  title="List view (Consumes less RAM)"
2064                  @click="!showDetailedList
2065                  ? showDetailedList = true
2066                  : showDetailedList = false"
2067                >
2068                  <List :size="18" stroke-width="2" />
2069                </button>
2070              </div>
2071              <div class="search-mode-group toolbar-group">
2072                <button
2073                  type="button"
2074                  class="mode-btn"
2075                  :class="{ 'mode-active': searchMode === 'exact' }"
2076                  title="Exact search"
2077                  @click="searchMode === 'exact'
2078                  ? cycleSearchMode()
2079                  : searchMode = 'exact'"
2080                >
2081                  <Regex :size="18" stroke-width="2" />
2082                </button>
2083                <button
2084                  type="button"
2085                  class="mode-btn"
2086                  :class="{ 'mode-active': searchMode === 'fuzzy' }"
2087                  title="Fuzzy search"
2088                  @click="searchMode === 'fuzzy'
2089                  ? cycleSearchMode()
2090                  : searchMode = 'fuzzy'"
2091                >
2092                  <LocateOff :size="18" stroke-width="2" />
2093                </button>
2094                <button
2095                  type="button"
2096                  class="mode-btn"
2097                  :class="{ 'mode-active': searchMode === 'url' }"
2098                  title="URL search"
2099                  @click="searchMode === 'url'
2100                  ? cycleSearchMode()
2101                  : searchMode = 'url'"
2102                >
2103                  <Globe :size="18" stroke-width="2" />
2104                </button>
2105              </div>
2106              <button
2107                ref="settingsButtonRef"
2108                type="button"
2109                class="mode-btn settings-toggle-btn"
2110                :class="{ 'mode-active': showSettingsPopup }"
2111                title="Search settings"
2112                @click.stop="showSettingsPopup = !showSettingsPopup"
2113              >
2114                <Settings :size="18" stroke-width="2" />
2115              </button>
2116              <button
2117                class="clear-button"
2118                type="reset"
2119                :disabled="disableReset"
2120                :title="translate('modal.resetButtonTitle')"
2121                @click="resetSearch"
2122              >
2123                <X :size="18" stroke-width="2" />
2124              </button>
2125            </div>
2126          </component>
2127
2128          <AnimatePresence>
2129            <component
2130              :is="searchMotionDiv"
2131              v-if="urlSearchMode
2132              ? urlPageGroups.length > 1
2133              : pageGroups.length > 1"
2134              class="page-ribbon"
2135              :class="{
2136                'can-scroll-left': ribbonCanScrollLeft,
2137                'can-scroll-right': ribbonCanScrollRight
2138              }"
2139              v-bind="ribbonMotion"
2140            >
2141              <button
2142                v-if="ribbonCanScrollLeft"
2143                type="button"
2144                class="page-ribbon-arrow left"
2145                aria-label="Scroll filters left"
2146                @click="scrollRibbon(-1)"
2147              >
2148                <ChevronRight :size="18" stroke-width="1.75" />
2149              </button>
2150              <div
2151                ref="ribbonTrack"
2152                class="page-ribbon-track"
2153                @scroll="updateRibbonOverflow"
2154              >
2155                <!-- URL mode tabs -->
2156                <template v-if="urlSearchMode">
2157                  <button
2158                    type="button"
2159                    class="page-pill"
2160                    :class="{
2161                      active: urlActivePageFilter === null
2162                    }"
2163                    @click="setUrlPageFilter(null)"
2164                  >
2165                    All
2166                    <span class="page-pill-count">{{ urlMatches.length }}</span>
2167                  </button>
2168                  <button
2169                    v-for="group in urlPageGroups"
2170                    :key="group.key"
2171                    type="button"
2172                    class="page-pill"
2173                    :class="{
2174                      active:
2175                        urlActivePageFilter === group.key
2176                    }"
2177                    @click="setUrlPageFilter(group.key)"
2178                  >
2179                    <span class="page-pill-label">{{ group.label }}</span>
2180                    <span class="page-pill-count">{{ group.count }}</span>
2181                  </button>
2182                </template>
2183                <!-- Normal mode tabs -->
2184                <template v-else>
2185                  <button
2186                    type="button"
2187                    class="page-pill"
2188                    :class="{ active: activePageFilter === null }"
2189                    @click="setPageFilter(null)"
2190                  >
2191                    All
2192                    <span class="page-pill-count">{{ results.length }}</span>
2193                  </button>
2194                  <button
2195                    v-for="group in pageGroups"
2196                    :key="group.key"
2197                    type="button"
2198                    class="page-pill"
2199                    :class="{
2200                      active: activePageFilter === group.key
2201                    }"
2202                    @click="setPageFilter(group.key)"
2203                  >
2204                    <span class="page-pill-label">{{ group.label }}</span>
2205                    <span class="page-pill-count">{{ group.count }}</span>
2206                  </button>
2207                </template>
2208              </div>
2209              <button
2210                v-if="ribbonCanScrollRight"
2211                type="button"
2212                class="page-ribbon-arrow right"
2213                aria-label="Scroll filters right"
2214                @click="scrollRibbon(1)"
2215              >
2216                <ChevronRight :size="18" stroke-width="1.75" />
2217              </button>
2218            </component>
2219          </AnimatePresence>
2220
2221          <ul
2222            ref="resultsEl"
2223            :id="results?.length ? 'localsearch-list' : undefined"
2224            :role="results?.length ? 'listbox' : undefined"
2225            :aria-labelledby="results?.length ? 'localsearch-label' : undefined"
2226            class="results"
2227            @mousemove="onMouseMove"
2228          >
2229            <!-- Empty state (shared) -->
2230            <AnimatePresence>
2231              <component
2232                :is="searchMotionDiv"
2233                v-if="!showHistory && (urlSearchMode
2234                ? (!filterText || !urlMatches.length)
2235                : (!filterText || !filteredResults.length))"
2236                class="flex flex-1 flex-col justify-center items-center w-full min-h-full gap-2 font-medium text-sm text-center text-gray-500 dark:text-gray-300 m-auto opacity-90"
2237                v-bind="emptyStateMotion"
2238              >
2239                <img
2240                  class="h-40 object-contain object-center"
2241                  src="/asset/smolame.png"
2242                  alt="Smol ame"
2243                />
2244                <h1 v-if="filterText">Couldn't find anything, try again?</h1>
2245                <h1 v-else>Looking for something?</h1>
2246              </component>
2247            </AnimatePresence>
2248
2249            <!-- Search history -->
2250            <AnimatePresence>
2251              <component
2252                :is="searchMotionDiv"
2253                v-if="showHistory"
2254                class="history-list"
2255                v-bind="emptyStateMotion"
2256              >
2257                <div class="history-header">
2258                  <span>Recent searches</span>
2259                  <button
2260                    class="history-clear-all"
2261                    title="Clear all history"
2262                    @click.stop="searchHistory = []"
2263                  >
2264                    <X :size="16" stroke-width="2" />
2265                  </button>
2266                </div>
2267                <ul class="history-items">
2268                  <li
2269                    v-for="(entry, index) in searchHistory"
2270                    :key="index"
2271                    class="history-item"
2272                    @click="applyHistory(entry)"
2273                  >
2274                    <div class="history-main">
2275                      <span class="history-query">{{ entry.query }}</span>
2276                      <template v-if="entry.path?.length">
2277                        <ArrowRight :size="13" stroke-width="1.5" class="history-arrow" />
2278                        <template v-for="(seg, si) in entry.path" :key="si">
2279                          <span
2280                            class="history-path-seg"
2281                            :class="{
2282                              'history-path-end': si === entry.path.length - 1,
2283                              'history-path-only': entry.path.length === 1
2284                            }"
2285                            v-html="seg"
2286                          />
2287                          <span v-if="si < entry.path.length - 1" class="history-path-sep">›</span>
2288                        </template>
2289                      </template>
2290                    </div>
2291                    <component
2292                      :is="entry.mode === 'exact' ? Regex : entry.mode === 'fuzzy' ? LocateOff : Globe"
2293                      :size="14"
2294                      stroke-width="2"
2295                      class="history-mode-icon"
2296                    />
2297                    <button
2298                      class="history-remove"
2299                      :title="'Remove \'' + entry.query + '\' from history'"
2300                      @click.stop="removeFromHistory(index)"
2301                    >
2302                      <X :size="16" stroke-width="2" />
2303                    </button>
2304                  </li>
2305                </ul>
2306              </component>
2307            </AnimatePresence>
2308
2309            <!-- URL search results -->
2310            <template v-if="urlSearchMode">
2311              <AnimatePresence>
2312                <component
2313                  :is="searchMotionLi"
2314                  v-for="(item, index) in filteredUrlResults"
2315                  :key="'url-' + urlCurrentPage + '-' +
2316                  item.pageId + '-' +
2317                  item.anchor + '-' + index"
2318                  class="result-layout"
2319                  :id="'localsearch-item-' + (index + 1)"
2320                  :aria-selected="selectedIndex === index + 1
2321                  ? 'true'
2322                  : 'false'"
2323                  role="option"
2324                  v-bind="resultMotion(index)"
2325                >
2326                  <div
2327                    class="result url-result-card"
2328                    :class="{
2329                      selected: selectedIndex === index + 1
2330                    }"
2331                    :aria-label="item.href"
2332                    role="button"
2333                    @mouseenter="!disableMouseOver &&
2334                    (selectedIndex = index + 1)"
2335                    @focusin="selectedIndex = index + 1"
2336                    @click="navigateToUrlResult(item)"
2337                    :data-index="index + 1"
2338                  >
2339                    <div class="url-result-body">
2340                      <div class="url-path">
2341                        <Hash
2342                          v-if="item.anchor ||
2343                          item.titles.length > 0"
2344                          stroke-width="2"
2345                          :size="18"
2346                        />
2347                        <File v-else stroke-width="2" :size="18" />
2348                        <span
2349                          v-for="(t, ti) in item.titles"
2350                          :key="ti"
2351                          class="url-path-segment"
2352                        >
2353                          <span class="text" v-html="t" />
2354                          <ArrowRight
2355                            stroke-width="2"
2356                            :size="18"
2357                            class="mx-0.5"
2358                          />
2359                        </span>
2360                        <span
2361                          v-if="item.linkText"
2362                          class="url-path-current"
2363                          v-html="item.linkText"
2364                        />
2365                      </div>
2366                      <a
2367                        :href="item.href"
2368                        target="_blank"
2369                        rel="noopener noreferrer"
2370                        class="url-link"
2371                        :title="item.href"
2372                        @click.stop
2373                        v-html="item.highlighted"
2374                      >
2375                      </a>
2376                    </div>
2377                  </div>
2378                </component>
2379              </AnimatePresence>
2380            </template>
2381
2382            <!-- Normal search results -->
2383            <template v-else>
2384              <AnimatePresence>
2385                <component
2386                  :is="searchMotionLi"
2387                  v-for="(p, index) in pagedResults"
2388                  :key="'normal-' + normalCurrentPage + '-' + p.id"
2389                  class="result-layout"
2390                  :id="'localsearch-item-' + (index + 1)"
2391                  :aria-selected="selectedIndex === index + 1
2392                  ? 'true'
2393                  : 'false'"
2394                  role="option"
2395                  v-bind="resultMotion(index)"
2396                >
2397                  <a
2398                    :href="getSearchResultHref(p)"
2399                    class="result"
2400                    :class="{
2401                      selected: selectedIndex === index + 1
2402                    }"
2403                    :aria-label="[...p.titles, p.title].join(' > ')"
2404                    @mouseenter="!disableMouseOver &&
2405                    (selectedIndex = index + 1)"
2406                    @focusin="selectedIndex = index + 1"
2407                    @click="onResultClick(p)"
2408                    :data-index="index + 1"
2409                  >
2410                    <div>
2411                      <div class="titles">
2412                        <Hash
2413                          v-if="getDocAnchor(p.id) ||
2414                          p.titles.length > 0"
2415                          stroke-width="2"
2416                          :size="18"
2417                        />
2418                        <File v-else stroke-width="2" :size="18" />
2419                        <span
2420                          v-for="(t, index) in p.titles"
2421                          :key="index"
2422                          class="title"
2423                        >
2424                          <span class="text" v-html="t" />
2425                          <ArrowRight
2426                            stroke-width="2"
2427                            :size="18"
2428                            class="mx-0.5"
2429                          />
2430                        </span>
2431                        <span class="title main">
2432                          <span class="text" v-html="p.title" />
2433                        </span>
2434                      </div>
2435
2436                      <div
2437                        v-if="showDetailedList &&
2438                        hasExcerptPreview(p.text)"
2439                        class="excerpt-wrapper"
2440                      >
2441                        <component
2442                          :is="searchMotionDiv"
2443                          class="excerpt"
2444                          inert
2445                          v-bind="excerptMotion"
2446                        >
2447                          <div class="vp-doc" v-html="p.text" />
2448                        </component>
2449                        <div class="excerpt-gradient-bottom" />
2450                        <div class="excerpt-gradient-top" />
2451                      </div>
2452                    </div>
2453                  </a>
2454                </component>
2455              </AnimatePresence>
2456            </template>
2457          </ul>
2458
2459          <!-- Bottom section: pagination (when needed). Always rendered so the
2460             shell's rounded bottom edge stays consistent. -->
2461          <nav
2462            class="url-pagination"
2463            aria-label="Search result pages"
2464          >
2465            <div
2466              v-if="(urlSearchMode
2467              ? urlTotalPages
2468              : normalTotalPages) > 1"
2469              class="url-pagination-segment"
2470            >
2471              <button
2472                type="button"
2473                class="url-page-btn url-page-nav"
2474                :disabled="(urlSearchMode
2475                ? urlCurrentPage
2476                : normalCurrentPage) <= 1"
2477                aria-label="Previous page"
2478                @click="urlSearchMode
2479                ? goToUrlPage(urlCurrentPage - 1)
2480                : goToNormalPage(normalCurrentPage - 1)"
2481              >
2482                <ChevronRight
2483                  :size="14"
2484                  stroke-width="2"
2485                  style="transform: rotate(180deg)"
2486                />
2487              </button>
2488
2489              <template
2490                v-for="(p, pi) in urlSearchMode ? urlPageList : normalPageList"
2491                :key="pi"
2492              >
2493                <span v-if="p === '…'" class="url-page-ellipsis">…</span>
2494                <button
2495                  v-else
2496                  type="button"
2497                  class="url-page-btn"
2498                  :class="{
2499                    active: p === (urlSearchMode
2500                      ? urlCurrentPage
2501                      : normalCurrentPage)
2502                  }"
2503                  :aria-current="p === (urlSearchMode
2504                    ? urlCurrentPage
2505                    : normalCurrentPage)
2506                  ? 'page'
2507                  : undefined"
2508                  @click="urlSearchMode
2509                  ? goToUrlPage(p as number)
2510                  : goToNormalPage(p as number)"
2511                >
2512                  {{ p }}
2513                </button>
2514              </template>
2515
2516              <button
2517                type="button"
2518                class="url-page-btn url-page-nav"
2519                :disabled="(urlSearchMode
2520                ? urlCurrentPage
2521                : normalCurrentPage) >=
2522                (urlSearchMode
2523                  ? urlTotalPages
2524                  : normalTotalPages)"
2525                aria-label="Next page"
2526                @click="urlSearchMode
2527                ? goToUrlPage(urlCurrentPage + 1)
2528                : goToNormalPage(normalCurrentPage + 1)"
2529              >
2530                <ChevronRight :size="14" stroke-width="2" />
2531              </button>
2532            </div>
2533          </nav>
2534
2535          <component
2536            :is="searchMotionDiv"
2537            v-if="showKeyboardShortcuts"
2538            class="search-keyboard-shortcuts"
2539            v-bind="footerMotion"
2540          >
2541            <span>
2542              <kbd
2543                :aria-label="translate(
2544                  'modal.footer.navigateUpKeyAriaLabel'
2545                )"
2546              >
2547                <span class="vpi-arrow-up navigate-icon" />
2548              </kbd>
2549              <kbd
2550                :aria-label="translate(
2551                  'modal.footer.navigateDownKeyAriaLabel'
2552                )"
2553              >
2554                <span class="vpi-arrow-down navigate-icon" />
2555              </kbd>
2556              {{ translate('modal.footer.navigateText') }}
2557            </span>
2558            <span>
2559              <kbd :aria-label="translate('modal.footer.switchTabsKeyAriaLabel')">
2560                <ArrowLeftToLine class="navigate-icon" :size="14" stroke-width="2" />
2561              </kbd>
2562              <kbd :aria-label="translate('modal.footer.switchTabsKeyAriaLabel')">
2563                <ArrowRightToLine class="navigate-icon" :size="14" stroke-width="2" />
2564              </kbd>
2565              {{ translate('modal.footer.switchTabsText') }}
2566            </span>
2567            <span>
2568              <kbd :aria-label="translate('modal.footer.switchPagesKeyAriaLabel')">
2569                <ArrowLeft class="navigate-icon" :size="14" stroke-width="2" />
2570              </kbd>
2571              <kbd :aria-label="translate('modal.footer.switchPagesKeyAriaLabel')">
2572                <ArrowRight class="navigate-icon" :size="14" stroke-width="2" />
2573              </kbd>
2574              {{ translate('modal.footer.switchPagesText') }}
2575            </span>
2576            <span>
2577              <kbd :aria-label="translate('modal.footer.selectKeyAriaLabel')">
2578                <span class="vpi-corner-down-left navigate-icon" />
2579              </kbd>
2580              {{ translate('modal.footer.selectText') }}
2581            </span>
2582            <span>
2583              <kbd :aria-label="translate('modal.footer.closeKeyAriaLabel')">
2584                esc
2585              </kbd>
2586              {{ translate('modal.footer.closeText') }}
2587            </span>
2588          </component>
2589          <Teleport to="body">
2590            <Transition name="settings-popup">
2591              <div
2592                v-if="showSettingsPopup"
2593                ref="settingsPopupRef"
2594                class="search-settings-popup"
2595                :style="settingsPopupStyle"
2596                @click="activeHelpSection = null"
2597              >
2598                <div class="settings-section">
2599                  <div class="settings-section-header">
2600                    <div class="settings-section-label">
2601                      <Search :size="14" stroke-width="1.75" />
2602                      Search
2603                    </div>
2604                    <button
2605                      type="button"
2606                      class="settings-help-btn"
2607                      :class="{ active: activeHelpSection === 'search' }"
2608                      aria-label="Search mode help"
2609                      @click.stop="toggleHelpSection('search', $event)"
2610                      @mouseenter="onHelpEnter('search', $event)"
2611                      @mouseleave="onHelpLeave"
2612                    >
2613                      <span class="i-carbon:help-filled settings-help-icon" />
2614                    </button>
2615                  </div>
2616                  <div
2617                    class="settings-options"
2618                    :class="{ 'is-highlighted': activeHelpSection === 'search' }"
2619                  >
2620                    <button
2621                      type="button"
2622                      class="settings-option"
2623                      :class="{ active: searchMode === 'exact' }"
2624                      @click="searchMode = 'exact'"
2625                    >
2626                      <span>Exact</span>
2627                    </button>
2628                    <button
2629                      type="button"
2630                      class="settings-option"
2631                      :class="{ active: searchMode === 'fuzzy' }"
2632                      @click="searchMode = 'fuzzy'"
2633                    >
2634                      <span>Fuzzy</span>
2635                    </button>
2636                    <button
2637                      type="button"
2638                      class="settings-option"
2639                      :class="{ active: searchMode === 'url' }"
2640                      @click="searchMode = 'url'"
2641                    >
2642                      <span>URL</span>
2643                    </button>
2644                  </div>
2645                </div>
2646                <div
2647                  v-if="!disableDetailedView && searchMode !== 'url'"
2648                  class="settings-section"
2649                >
2650                  <div class="settings-section-header">
2651                    <div class="settings-section-label">
2652                      <LayoutList :size="14" stroke-width="1.75" />
2653                      View
2654                    </div>
2655                    <button
2656                      type="button"
2657                      class="settings-help-btn"
2658                      :class="{ active: activeHelpSection === 'view' }"
2659                      aria-label="Result view help"
2660                      @click.stop="toggleHelpSection('view', $event)"
2661                      @mouseenter="onHelpEnter('view', $event)"
2662                      @mouseleave="onHelpLeave"
2663                    >
2664                      <span class="i-carbon:help-filled settings-help-icon" />
2665                    </button>
2666                  </div>
2667                  <div
2668                    class="settings-options"
2669                    :class="{ 'is-highlighted': activeHelpSection === 'view' }"
2670                  >
2671                    <button
2672                      type="button"
2673                      class="settings-option"
2674                      :class="{ active: showDetailedList }"
2675                      @click="showDetailedList = true"
2676                    >
2677                      <span>Detail</span>
2678                    </button>
2679                    <button
2680                      type="button"
2681                      class="settings-option"
2682                      :class="{ active: !showDetailedList }"
2683                      @click="showDetailedList = false"
2684                    >
2685                      <span>List</span>
2686                    </button>
2687                  </div>
2688                </div>
2689                <div
2690                  v-if="!disableDetailedView && searchMode !== 'url' &&
2691                  showDetailedList"
2692                  class="settings-section"
2693                >
2694                  <div class="settings-section-header">
2695                    <div class="settings-section-label">
2696                      <Layers :size="14" stroke-width="1.75" />
2697                      Preload
2698                    </div>
2699                    <button
2700                      type="button"
2701                      class="settings-help-btn"
2702                      :class="{ active: activeHelpSection === 'preload' }"
2703                      aria-label="Excerpt preload help"
2704                      @click.stop="toggleHelpSection('preload', $event)"
2705                      @mouseenter="onHelpEnter('preload', $event)"
2706                      @mouseleave="onHelpLeave"
2707                    >
2708                      <span class="i-carbon:help-filled settings-help-icon" />
2709                    </button>
2710                  </div>
2711                  <div
2712                    class="settings-options"
2713                    :class="{ 'is-highlighted': activeHelpSection === 'preload' }"
2714                  >
2715                    <button
2716                      type="button"
2717                      class="settings-option"
2718                      :class="{ active: excerptPreload === 'all' }"
2719                      @click="excerptPreload = 'all'"
2720                    >
2721                      <span>All</span>
2722                    </button>
2723                    <button
2724                      type="button"
2725                      class="settings-option"
2726                      :class="{ active: excerptPreload === 'next' }"
2727                      @click="excerptPreload = 'next'"
2728                    >
2729                      <span>Next</span>
2730                    </button>
2731                    <button
2732                      type="button"
2733                      class="settings-option"
2734                      :class="{ active: excerptPreload === 'off' }"
2735                      @click="excerptPreload = 'off'"
2736                    >
2737                      <span>Off</span>
2738                    </button>
2739                  </div>
2740                </div>
2741                <div class="settings-section">
2742                  <div class="settings-section-header">
2743                    <div class="settings-section-label">
2744                      <Clock :size="14" stroke-width="1.75" />
2745                      History
2746                    </div>
2747                    <button
2748                      type="button"
2749                      class="settings-help-btn"
2750                      :class="{ active: activeHelpSection === 'history' }"
2751                      aria-label="Search history help"
2752                      @click.stop="toggleHelpSection('history', $event)"
2753                      @mouseenter="onHelpEnter('history', $event)"
2754                      @mouseleave="onHelpLeave"
2755                    >
2756                      <span class="i-carbon:help-filled settings-help-icon" />
2757                    </button>
2758                  </div>
2759                  <div
2760                    class="settings-options"
2761                    :class="{ 'is-highlighted': activeHelpSection === 'history' }"
2762                  >
2763                    <button
2764                      type="button"
2765                      class="settings-option"
2766                      :class="{ active: saveHistoryEnabled }"
2767                      @click="saveHistoryEnabled = true"
2768                    >
2769                      <span>On</span>
2770                    </button>
2771                    <button
2772                      type="button"
2773                      class="settings-option"
2774                      :class="{ active: !saveHistoryEnabled }"
2775                      @click="saveHistoryEnabled = false"
2776                    >
2777                      <span>Off</span>
2778                    </button>
2779                  </div>
2780                </div>
2781              </div>
2782            </Transition>
2783            <Transition name="help-popup-fade">
2784              <div
2785                v-if="activeHelpSection && showSettingsPopup"
2786                ref="helpPopupEl"
2787                class="search-help-popup"
2788                :style="{ top: helpPopupPos.top + 'px', left: helpPopupPos.left + 'px' }"
2789              >
2790                <template v-if="activeHelpSection === 'search'">
2791                  <h4 class="sh-title">
2792                    <Search :size="16" stroke-width="1.75" class="sh-title-icon" />
2793                    Search Mode
2794                  </h4>
2795                  <p class="sh-desc">Choose how queries are matched against content.</p>
2796                  <div class="sh-options">
2797                    <div class="sh-option">
2798                      <strong>
2799                        <Regex :size="14" stroke-width="1.5" />
2800                        Exact
2801                      </strong>
2802                      <span>Matches the exact phrase you type</span>
2803                    </div>
2804                    <div class="sh-option">
2805                      <strong>
2806                        <LocateOff :size="14" stroke-width="1.5" />
2807                        Fuzzy
2808                      </strong>
2809                      <span>Approximate matching that tolerates typos</span>
2810                    </div>
2811                    <div class="sh-option">
2812                      <strong>
2813                        <Globe :size="14" stroke-width="1.5" />
2814                        URL
2815                      </strong>
2816                      <span>Searches through hyperlinks</span>
2817                    </div>
2818                  </div>
2819                </template>
2820                <template v-else-if="activeHelpSection === 'view'">
2821                  <h4 class="sh-title">
2822                    <LayoutList :size="16" stroke-width="1.75" class="sh-title-icon" />
2823                    Result View
2824                  </h4>
2825                  <p class="sh-desc">Controls how search results are displayed.</p>
2826                  <div class="sh-options">
2827                    <div class="sh-option">
2828                      <strong>
2829                        <TextAlignStart :size="14" stroke-width="1.5" />
2830                        Detail
2831                      </strong>
2832                      <span>Shows a content excerpt below each result. Uses more memory.</span>
2833                    </div>
2834                    <div class="sh-option">
2835                      <strong>
2836                        <List :size="14" stroke-width="1.5" />
2837                        List
2838                      </strong>
2839                      <span>Compact list of titles only. Uses less memory.</span>
2840                    </div>
2841                  </div>
2842                </template>
2843                <template v-else-if="activeHelpSection === 'preload'">
2844                  <h4 class="sh-title">
2845                    <Layers :size="16" stroke-width="1.75" class="sh-title-icon" />
2846                    Excerpt Preload
2847                  </h4>
2848                  <p class="sh-desc">Renders excerpts for upcoming result pages ahead of time in Detail view.</p>
2849                  <div class="sh-options">
2850                    <div class="sh-option">
2851                      <strong>All</strong>
2852                      <span>Prepares every result page. Uses more memory.</span>
2853                    </div>
2854                    <div class="sh-option">
2855                      <strong>Next</strong>
2856                      <span>Also prepares the next page so flipping forward is instant</span>
2857                    </div>
2858                    <div class="sh-option">
2859                      <strong>Off</strong>
2860                      <span>Only the visible page. Uses the least memory.</span>
2861                    </div>
2862                  </div>
2863                </template>
2864                <template v-else-if="activeHelpSection === 'history'">
2865                  <h4 class="sh-title">
2866                    <Clock :size="16" stroke-width="1.75" class="sh-title-icon" />
2867                    Search History
2868                  </h4>
2869                  <p class="sh-desc">Saves recent searches and shows them when the search bar is empty.</p>
2870                </template>
2871              </div>
2872            </Transition>
2873          </Teleport>
2874        </component>
2875      </AnimatePresence>
2876
2877      <button v-if="!showSearch" />
2878    </div>
2879  </Teleport>
2880</template>
2881
2882<style scoped>
2883.VPLocalSearchBox {
2884  position: fixed;
2885  z-index: 100;
2886  inset: 0;
2887  display: flex;
2888  align-items: flex-start;
2889}
2890
2891@media (max-width: 767px) {
2892  .VPLocalSearchBox {
2893    align-items: stretch;
2894  }
2895}
2896
2897.backdrop {
2898  position: absolute;
2899  inset: 0;
2900  background: var(--vp-backdrop-bg-color);
2901}
2902
2903.shell {
2904  position: relative;
2905  box-sizing: border-box;
2906  padding: 12px 12px 8px;
2907  margin: 64px auto;
2908  display: flex;
2909  flex-direction: column;
2910  gap: 16px;
2911  background: var(--vp-local-search-bg);
2912  width: min(100vw - 60px, 700px);
2913  height: 100%;
2914  max-height: min(100vh - 128px, 680px);
2915  border-radius: 6px;
2916}
2917
2918@media (max-width: 767px) {
2919  .shell {
2920    margin: 0;
2921    width: 100vw;
2922    height: 100vh;
2923    height: 100dvh;
2924    max-height: none;
2925    border-radius: 0;
2926    overflow: hidden;
2927    gap: 8px;
2928  }
2929}
2930
2931.search-bar {
2932  flex: 0 0 auto !important;
2933  min-height: 44px !important;
2934  border: 1px solid var(--vp-c-divider);
2935  border-radius: 4px;
2936  display: flex;
2937  align-items: center;
2938  padding: 0 12px;
2939  cursor: text;
2940}
2941
2942@media (max-width: 767px) {
2943  .search-bar {
2944    padding: 0 8px;
2945    min-height: 40px !important;
2946  }
2947}
2948
2949.search-bar:focus-within {
2950  border-color: var(--vp-c-brand-1);
2951}
2952
2953.page-ribbon {
2954  display: flex;
2955  align-items: center;
2956  padding: 12px 0 4px;
2957  padding-inline: calc(var(--spacing) * 3);
2958  position: relative;
2959  min-width: 0;
2960  flex: none;
2961  overflow: hidden;
2962  transition: padding-inline 0.15s;
2963}
2964
2965.page-ribbon.can-scroll-left {
2966  padding-left: 42px;
2967}
2968
2969.page-ribbon.can-scroll-right {
2970  padding-right: 42px;
2971}
2972
2973.page-ribbon-track {
2974  display: flex;
2975  flex-wrap: nowrap;
2976  gap: 8px;
2977  min-width: 0;
2978  flex: 1;
2979  overflow-x: auto;
2980  overflow-y: hidden;
2981  scrollbar-width: none;
2982  -ms-overflow-style: none;
2983  overscroll-behavior-x: contain;
2984}
2985
2986.page-ribbon-track::-webkit-scrollbar {
2987  display: none;
2988  width: 0;
2989  height: 0;
2990}
2991
2992.page-ribbon-arrow {
2993  position: absolute;
2994  top: 12px;
2995  bottom: 4px;
2996  z-index: 2;
2997  display: inline-flex;
2998  align-items: center;
2999  justify-content: center;
3000  width: 48px;
3001  border: none;
3002  background: transparent;
3003  color: var(--vp-c-text-2);
3004  cursor: pointer;
3005  transition: color 0.15s;
3006}
3007
3008.page-ribbon-arrow:hover {
3009  color: var(--vp-c-text-1);
3010}
3011
3012.page-ribbon-arrow.right {
3013  right: 0;
3014  justify-content: flex-end;
3015  padding-right: 6px;
3016}
3017
3018.page-ribbon-arrow.left {
3019  left: 0;
3020  justify-content: flex-start;
3021  padding-left: 6px;
3022}
3023
3024.page-ribbon-arrow.left svg {
3025  transform: rotate(180deg);
3026}
3027
3028.page-pill {
3029  flex: none;
3030  display: inline-flex;
3031  align-items: center;
3032  gap: 6px;
3033  padding: 6px 10px;
3034  font-size: 0.8rem;
3035  line-height: 1.2;
3036  white-space: nowrap;
3037  border-radius: 8px;
3038  border: 1.5px solid var(--vp-c-divider);
3039  background: var(--vp-c-bg-soft);
3040  color: var(--vp-c-text-2);
3041  cursor: pointer;
3042  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
3043}
3044
3045.page-pill:hover {
3046  color: var(--vp-c-text-1);
3047  border-color: var(--vp-c-brand-1);
3048}
3049
3050.page-pill.active {
3051  color: var(--vp-c-brand-1);
3052  border: 1.5px solid var(--vp-c-brand-1);
3053  background: color-mix(in srgb, var(--vp-c-brand-1) 12%, transparent);
3054  box-shadow: none;
3055}
3056
3057.page-pill-label {
3058  max-width: 180px;
3059  overflow: hidden;
3060  text-overflow: ellipsis;
3061}
3062
3063.page-pill-count {
3064  font-variant-numeric: tabular-nums;
3065  font-size: 0.7rem;
3066  padding: 1px 6px;
3067  border-radius: 4px;
3068  background: rgba(128, 128, 128, 0.15);
3069  color: inherit;
3070}
3071
3072.page-pill.active .page-pill-count {
3073  background: color-mix(in srgb, var(--vp-c-brand-1) 18%, transparent);
3074}
3075
3076@media (max-width: 767px) {
3077  .page-ribbon {
3078    padding: 14px 12px 4px;
3079  }
3080
3081  .page-pill {
3082    padding: 7px 14px;
3083    font-size: 0.82rem;
3084    background: var(--vp-c-bg-elv, var(--vp-c-bg-soft));
3085    border-color: var(--vp-c-divider);
3086    color: var(--vp-c-text-1);
3087  }
3088}
3089
3090.local-search-icon {
3091  display: block;
3092  font-size: 18px;
3093}
3094
3095.navigate-icon {
3096  display: block;
3097  font-size: 14px;
3098}
3099
3100.search-icon {
3101  margin: 8px;
3102}
3103
3104@media (max-width: 767px) {
3105  .search-icon {
3106    display: none;
3107  }
3108}
3109
3110.search-input {
3111  flex: 1 1 auto;
3112  min-width: 0;
3113  padding: 6px 12px;
3114  font-size: inherit;
3115  width: 100%;
3116}
3117
3118.search-input::-webkit-search-cancel-button {
3119  display: none;
3120}
3121
3122@media (max-width: 767px) {
3123  .search-input {
3124    padding: 6px 4px;
3125  }
3126}
3127
3128.search-actions {
3129  flex: 0 0 auto;
3130  display: flex;
3131  align-items: center;
3132  gap: 4px;
3133}
3134
3135.search-loading-button {
3136  display: inline-flex;
3137  align-items: center;
3138  justify-content: center;
3139  padding: 0 !important;
3140  margin-inline-end: 6px;
3141  border: 0;
3142  background: transparent;
3143  cursor: pointer;
3144}
3145
3146.search-loading-bubba {
3147  width: 32px;
3148  height: 28px;
3149  object-fit: contain;
3150  image-rendering: pixelated;
3151  user-select: none;
3152}
3153
3154@media (any-pointer: coarse) {
3155  .search-actions {
3156    gap: 8px;
3157  }
3158}
3159
3160@media (min-width: 769px) {
3161  .search-actions.before {
3162    display: none;
3163  }
3164}
3165
3166.search-actions button {
3167  padding: 8px;
3168}
3169
3170.search-actions button:not([disabled]):hover,
3171.toggle-layout-button.detailed-list {
3172  color: var(--vp-c-brand-1);
3173}
3174
3175.search-actions button.clear-button:disabled {
3176  opacity: 0.37;
3177}
3178
3179.search-keyboard-shortcuts {
3180  font-size: 0.8rem;
3181  opacity: 75%;
3182  display: flex;
3183  flex-wrap: wrap;
3184  gap: 16px;
3185  line-height: 14px;
3186}
3187
3188.search-keyboard-shortcuts span {
3189  display: flex;
3190  align-items: center;
3191  gap: 4px;
3192}
3193
3194@media (max-width: 767px) {
3195  .search-keyboard-shortcuts {
3196    display: none;
3197  }
3198}
3199
3200.search-keyboard-shortcuts kbd {
3201  background: rgba(128, 128, 128, 0.1);
3202  border-radius: 4px;
3203  padding: 3px 6px;
3204  min-width: 24px;
3205  display: inline-block;
3206  text-align: center;
3207  vertical-align: middle;
3208  border: 1px solid rgba(128, 128, 128, 0.15);
3209  box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.1);
3210}
3211
3212.results {
3213  display: flex;
3214  flex-direction: column;
3215  gap: 6px;
3216  flex: 1 1 auto;
3217  min-height: 0 !important;
3218  overflow-x: hidden;
3219  overflow-y: auto;
3220  overscroll-behavior: contain;
3221}
3222
3223.result-layout {
3224  will-change: transform, opacity, height;
3225}
3226
3227.result {
3228  display: flex;
3229  align-items: center;
3230  gap: 8px;
3231  border-radius: 4px;
3232  transition: none;
3233  line-height: 1rem;
3234  border: solid 2px var(--vp-local-search-result-border);
3235  outline: none;
3236}
3237
3238.result > div {
3239  margin: 12px;
3240  width: 100%;
3241  overflow: hidden;
3242}
3243
3244@media (max-width: 767px) {
3245  .result > div {
3246    margin: 8px;
3247  }
3248}
3249
3250.titles {
3251  display: flex;
3252  flex-wrap: wrap;
3253  gap: 4px;
3254  position: relative;
3255  z-index: 1001;
3256  padding: 2px 0;
3257  align-items: center;
3258}
3259
3260.url-result-card {
3261  cursor: pointer;
3262}
3263
3264.url-result-body {
3265  display: flex;
3266  flex-direction: column;
3267  gap: 6px;
3268}
3269
3270.url-path {
3271  display: flex;
3272  align-items: center;
3273  flex-wrap: wrap;
3274  gap: 4px;
3275  color: var(--vp-c-text-3);
3276  font-size: 0.78rem;
3277  line-height: 1.2;
3278}
3279
3280.url-path > svg,
3281.url-path-segment svg {
3282  flex-shrink: 0;
3283  width: 1em;
3284  height: 1em;
3285  margin-top: -1px;
3286  opacity: 0.55;
3287}
3288
3289.url-path > svg {
3290  margin-top: -2px;
3291}
3292
3293.url-path-segment {
3294  display: flex;
3295  align-items: center;
3296  min-width: 0;
3297}
3298
3299.url-path-current {
3300  display: inline-flex;
3301  align-items: center;
3302  color: var(--vp-c-text-2);
3303}
3304
3305.url-path :deep(.icon-tip) {
3306  display: inline-flex;
3307  align-items: center;
3308  line-height: 1;
3309  vertical-align: middle;
3310}
3311
3312.url-path :deep(.icon-tip > span) {
3313  width: 1em;
3314  height: 1em;
3315  min-width: 1em;
3316}
3317
3318.url-link {
3319  align-self: flex-start;
3320  max-width: 100%;
3321  color: var(--vp-c-text-1);
3322  font-size: 0.95rem;
3323  font-weight: 500;
3324  line-height: 1.35;
3325  overflow-wrap: anywhere;
3326  word-break: break-word;
3327}
3328
3329.url-link:hover {
3330  color: var(--vp-c-brand-1);
3331  text-decoration: underline;
3332  text-underline-offset: 2px;
3333}
3334
3335.result.selected .url-link {
3336  color: var(--vp-c-brand-1);
3337}
3338
3339.titles > svg {
3340  flex-shrink: 0;
3341  align-self: center;
3342}
3343
3344.title {
3345  display: flex;
3346  align-items: center;
3347  gap: 4px;
3348}
3349
3350.title.main {
3351  font-weight: 500;
3352}
3353
3354.title-icon {
3355  opacity: 1;
3356  font-weight: 500;
3357}
3358
3359.title svg {
3360  opacity: 0.5;
3361}
3362
3363.result.selected {
3364  --vp-local-search-result-bg: var(--vp-local-search-result-selected-bg);
3365  border-color: var(--vp-local-search-result-selected-border);
3366}
3367
3368.excerpt-wrapper {
3369  position: relative;
3370}
3371
3372.excerpt {
3373  opacity: 50%;
3374  pointer-events: none;
3375  height: 84px;
3376  max-height: 84px;
3377  overflow: hidden;
3378  position: relative;
3379  margin-top: 4px;
3380  contain: layout paint;
3381}
3382
3383.result.selected .excerpt {
3384  opacity: 1;
3385}
3386
3387.excerpt :deep(*) {
3388  font-size: 0.8rem !important;
3389  line-height: 130% !important;
3390}
3391
3392.titles :deep(mark),
3393.excerpt :deep(mark) {
3394  background-color: var(--vp-local-search-highlight-bg);
3395  color: var(--vp-local-search-highlight-text);
3396  border-radius: 2px;
3397  padding: 0 2px;
3398}
3399
3400.excerpt :deep(.vp-code-group) .tabs {
3401  display: none;
3402}
3403
3404.excerpt :deep(.vp-code-group) div[class*="language-"] {
3405  border-radius: 8px !important;
3406}
3407
3408.excerpt > .vp-doc > *:first-child {
3409  margin-top: 6px !important;
3410}
3411
3412.excerpt-gradient-bottom {
3413  position: absolute;
3414  bottom: -1px;
3415  left: 0;
3416  width: 100%;
3417  height: 8px;
3418  background: linear-gradient(transparent, var(--vp-local-search-result-bg));
3419  z-index: 1000;
3420}
3421
3422.excerpt-gradient-top {
3423  position: absolute;
3424  top: -1px;
3425  left: 0;
3426  width: 100%;
3427  height: 8px;
3428  background: linear-gradient(var(--vp-local-search-result-bg), transparent);
3429  z-index: 1000;
3430}
3431
3432.result.selected .titles,
3433.result.selected .title-icon {
3434  color: var(--vp-c-brand-1) !important;
3435}
3436
3437.no-results {
3438  font-size: 0.9rem;
3439  text-align: center;
3440  padding: 12px;
3441}
3442
3443svg {
3444  flex: none;
3445}
3446
3447.exact-match-button.exact-match-active {
3448  color: var(--vp-c-brand-1);
3449  background-color: color-mix(in srgb, var(--vp-c-brand-1) 10%, transparent);
3450  border-radius: 4px;
3451}
3452
3453.toolbar-group + .toolbar-group {
3454  margin-left: 6px;
3455}
3456
3457.search-mode-group,
3458.view-group {
3459  display: none;
3460}
3461
3462.mode-btn {
3463  display: flex;
3464  align-items: center;
3465  justify-content: center;
3466  padding: 5px 7px;
3467  color: var(--vp-c-text-2);
3468  background: transparent;
3469  border: none;
3470  cursor: pointer;
3471  transition: color 0.15s, background-color 0.15s;
3472  border-radius: 0;
3473}
3474
3475.mode-btn + .mode-btn {
3476  border-left: 1px solid var(--vp-c-divider);
3477}
3478
3479.mode-btn:hover {
3480  color: var(--vp-c-text-1);
3481  background: var(--vp-c-default-soft);
3482}
3483
3484.mode-btn.mode-active {
3485  color: var(--vp-c-brand-1);
3486  background: color-mix(in srgb, var(--vp-c-brand-1) 10%, transparent);
3487}
3488
3489:deep(.url-highlight) {
3490  background-color: var(--vp-local-search-highlight-bg);
3491  color: var(--vp-local-search-highlight-text);
3492  border-radius: 2px;
3493  padding: 0 2px;
3494  font-style: normal;
3495}
3496
3497/* Bottom-strip pagination. The <nav> is always rendered (empty when only one
3498   page) but collapses to zero height in that case so the shell's bottom
3499   rounded edge sits flush against the results. */
3500.url-pagination {
3501  display: flex;
3502  align-items: center;
3503  justify-content: center;
3504  flex: 0 0 auto !important;
3505}
3506
3507.url-pagination:has(.url-pagination-segment) {
3508  padding-top: 8px;
3509}
3510
3511.url-pagination-segment {
3512  display: flex;
3513  align-items: center;
3514  border: 1px solid var(--vp-c-divider);
3515  border-radius: 5px;
3516  overflow: hidden;
3517  background: transparent;
3518}
3519
3520.url-page-btn {
3521  display: flex;
3522  align-items: center;
3523  justify-content: center;
3524  min-width: 32px;
3525  height: 28px;
3526  padding: 0 8px;
3527  border: none;
3528  background: transparent;
3529  color: var(--vp-c-text-2);
3530  font-size: 0.82rem;
3531  cursor: pointer;
3532  transition: color 0.15s, background-color 0.15s;
3533  border-radius: 0;
3534}
3535
3536.url-page-btn + .url-page-btn,
3537.url-page-ellipsis + .url-page-btn,
3538.url-page-btn + .url-page-ellipsis {
3539  border-left: 1px solid var(--vp-c-divider);
3540}
3541
3542.url-page-btn:hover:not(:disabled):not(.active) {
3543  color: var(--vp-c-text-1);
3544  background: var(--vp-c-default-soft);
3545}
3546
3547.url-page-btn.active {
3548  color: var(--vp-c-brand-1);
3549  background: color-mix(in srgb, var(--vp-c-brand-1) 10%, transparent);
3550  font-weight: 500;
3551  cursor: default;
3552}
3553
3554.url-page-btn:disabled {
3555  opacity: 0.25;
3556  cursor: not-allowed;
3557  background: transparent;
3558}
3559
3560.url-page-nav {
3561  padding: 0 6px;
3562}
3563
3564.url-page-ellipsis {
3565  display: flex;
3566  align-items: center;
3567  justify-content: center;
3568  min-width: 28px;
3569  height: 28px;
3570  color: var(--vp-c-text-3);
3571  font-size: 0.8rem;
3572  user-select: none;
3573  background: transparent;
3574}
3575
3576/* Settings gear + clear (X) buttons — nav-bar style */
3577.search-actions .settings-toggle-btn,
3578.search-actions .clear-button {
3579  display: flex;
3580  border: none;
3581  border-radius: 0;
3582  background: transparent;
3583  color: var(--vp-c-text-1);
3584  opacity: 0.55;
3585  padding: 8px 4px;
3586  transition:
3587    opacity 0.25s,
3588    transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
3589}
3590
3591.search-actions button.settings-toggle-btn:not([disabled]):hover,
3592.search-actions button.clear-button:not([disabled]):hover,
3593.settings-toggle-btn.mode-active {
3594  color: var(--vp-c-text-1);
3595  opacity: 1;
3596  background: transparent;
3597}
3598
3599.settings-toggle-btn:active,
3600.clear-button:not([disabled]):active {
3601  transform: scale(0.94);
3602}
3603
3604/* Respect the "effects off" preference */
3605html.effects-disabled .settings-toggle-btn,
3606html.effects-disabled .clear-button {
3607  transition: none;
3608}
3609
3610html.effects-disabled .settings-toggle-btn:active,
3611html.effects-disabled .clear-button:active {
3612  transform: none;
3613}
3614
3615/* Settings popup card */
3616.search-settings-popup {
3617  --seg-track: var(--wk-c-menu-bg);
3618  --seg-pill-bg: var(--vp-c-bg);
3619  --seg-pill-text: var(--vp-c-text-1);
3620  --seg-pill-shadow: 0 2px 4px 0 #bababa8c;
3621  position: fixed;
3622  z-index: 200;
3623  background: var(--vp-c-bg-elv);
3624  border: 1px solid var(--vp-c-divider);
3625  border-radius: 12px;
3626  padding: 12px;
3627  box-shadow: var(--vp-shadow-3);
3628  display: flex;
3629  flex-direction: column;
3630  min-width: 196px;
3631}
3632
3633.dark .search-settings-popup {
3634  --seg-track: var(--wk-c-menu-bg);
3635  --seg-pill-bg: var(--vp-c-text-1);
3636  --seg-pill-text: var(--vp-c-bg-elv);
3637  --seg-pill-shadow: 0 2px 4px 0 #535353db;
3638}
3639
3640.settings-section {
3641  display: flex;
3642  flex-direction: column;
3643  gap: 0;
3644}
3645
3646.settings-section + .settings-section {
3647  border-top: 1px solid var(--vp-c-divider);
3648  margin-top: 8px;
3649  padding-top: 8px;
3650}
3651
3652.settings-section-header {
3653  display: flex;
3654  align-items: center;
3655  justify-content: space-between;
3656  margin-bottom: 6px;
3657}
3658
3659.settings-section-label {
3660  display: flex;
3661  align-items: center;
3662  gap: 6px;
3663  font-size: 14px;
3664  font-weight: 500;
3665  color: var(--vp-c-text-1);
3666}
3667
3668.settings-help-btn {
3669  display: flex;
3670  align-items: center;
3671  justify-content: center;
3672  padding: 3px;
3673  background: transparent;
3674  border: none;
3675  cursor: pointer;
3676  color: var(--vp-c-text-3);
3677  opacity: 0.5;
3678  transition: opacity 0.15s, color 0.15s;
3679  border-radius: 3px;
3680  line-height: 1;
3681}
3682
3683.settings-help-btn:hover,
3684.settings-help-btn.active {
3685  opacity: 1;
3686  color: var(--vp-c-text-1);
3687}
3688
3689.settings-help-icon {
3690  display: block;
3691  width: 16px;
3692  height: 16px;
3693}
3694
3695/* Help popup */
3696.search-help-popup {
3697  position: fixed;
3698  z-index: 9999;
3699  width: 280px;
3700  background: var(--vp-c-bg-elv);
3701  border: 1px solid var(--vp-c-divider);
3702  border-radius: 12px;
3703  padding: 16px;
3704  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
3705  pointer-events: none;
3706}
3707
3708.help-popup-fade-enter-active,
3709.help-popup-fade-leave-active {
3710  transition: opacity 0.15s ease;
3711}
3712
3713.help-popup-fade-enter-from,
3714.help-popup-fade-leave-to {
3715  opacity: 0;
3716}
3717
3718.sh-title {
3719  display: flex;
3720  align-items: center;
3721  gap: 6px;
3722  font-size: 1rem;
3723  font-weight: 600;
3724  color: var(--vp-c-text-1);
3725  margin: 0 0 4px;
3726}
3727
3728.sh-title-icon {
3729  flex-shrink: 0;
3730  opacity: 0.8;
3731  width: 16px;
3732  height: 16px;
3733}
3734
3735.sh-desc {
3736  font-size: 0.875rem;
3737  color: var(--vp-c-text-2);
3738  margin: 0 0 6px;
3739  line-height: 1.5;
3740}
3741
3742.sh-options {
3743  display: flex;
3744  flex-direction: column;
3745  gap: 5px;
3746}
3747
3748.sh-option {
3749  display: flex;
3750  flex-direction: column;
3751  gap: 4px;
3752  background: var(--wk-c-menu-bg);
3753  border-radius: 12px;
3754  padding: 10px 12px;
3755}
3756
3757.dark .sh-option {
3758  background: var(--wk-c-menu-bg);
3759}
3760
3761.sh-option strong {
3762  display: flex;
3763  align-items: center;
3764  gap: 4px;
3765  font-size: 0.875rem;
3766  font-weight: 600;
3767  color: var(--vp-c-text-1);
3768}
3769
3770.sh-option span {
3771  font-size: 0.875rem;
3772  color: var(--vp-c-text-2);
3773  line-height: 1.4;
3774}
3775
3776.settings-options {
3777  display: flex;
3778  gap: 4px;
3779  background: var(--seg-track);
3780  border-radius: 8px;
3781  padding: 4px;
3782  outline: 2px dashed transparent;
3783  outline-offset: 4px;
3784  transition: outline-color 0.2s ease;
3785}
3786
3787.settings-options.is-highlighted {
3788  outline-color: var(--vp-c-brand-1);
3789}
3790
3791.settings-option {
3792  display: flex;
3793  align-items: center;
3794  justify-content: center;
3795  gap: 5px;
3796  padding: 5px 6px;
3797  background: transparent;
3798  border: none;
3799  border-radius: 6px;
3800  cursor: pointer;
3801  color: var(--vp-c-text-1);
3802  font-size: 14px;
3803  font-weight: 500;
3804  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
3805  flex: 1;
3806}
3807
3808.settings-option:hover,
3809.settings-option.active {
3810  color: var(--seg-pill-text);
3811  background: var(--seg-pill-bg);
3812  box-shadow: var(--seg-pill-shadow);
3813}
3814
3815.settings-option.active {
3816  font-weight: 700;
3817}
3818
3819.settings-popup-enter-active,
3820.settings-popup-leave-active {
3821  transition: opacity 0.15s ease, transform 0.15s ease;
3822  transform-origin: top right;
3823}
3824
3825.settings-popup-enter-from,
3826.settings-popup-leave-to {
3827  opacity: 0;
3828  transform: scale(0.92) translateY(-4px);
3829}
3830
3831.history-list {
3832  display: flex;
3833  flex-direction: column;
3834  width: 100%;
3835  padding: 4px 0;
3836}
3837
3838.history-header {
3839  font-size: 0.7rem;
3840  font-weight: 600;
3841  text-transform: uppercase;
3842  letter-spacing: 0.06em;
3843  color: var(--vp-c-text-3);
3844  padding: 4px 12px 8px;
3845  display: flex;
3846  align-items: center;
3847  justify-content: space-between;
3848}
3849
3850.history-clear-all {
3851  display: flex;
3852  align-items: center;
3853  justify-content: center;
3854  flex-shrink: 0;
3855  padding: 0;
3856  border: none;
3857  background: transparent;
3858  color: var(--vp-c-text-3);
3859  cursor: pointer;
3860  opacity: 0.7;
3861  transition: color 0.15s;
3862}
3863
3864.history-clear-all:hover {
3865  color: var(--vp-c-text-1);
3866  opacity: 1;
3867}
3868
3869.history-items {
3870  display: flex;
3871  flex-direction: column;
3872  list-style: none;
3873  margin: 0;
3874  padding: 0;
3875}
3876
3877.history-item {
3878  display: flex;
3879  align-items: center;
3880  gap: 8px;
3881  padding: 8px 12px;
3882  cursor: pointer;
3883  border-radius: 4px;
3884  transition: background-color 0.15s;
3885}
3886
3887.history-item:hover {
3888  background: var(--vp-c-default-soft);
3889}
3890
3891.history-main {
3892  flex: 1;
3893  min-width: 0;
3894  display: flex;
3895  align-items: center;
3896  gap: 6px;
3897  overflow: hidden;
3898}
3899
3900.history-query {
3901  flex-shrink: 0;
3902  font-size: 0.9rem;
3903  color: var(--vp-c-text-1);
3904  white-space: nowrap;
3905}
3906
3907.history-arrow {
3908  flex-shrink: 0;
3909  opacity: 0.5;
3910  color: var(--vp-c-text-3);
3911}
3912
3913.history-path-seg {
3914  min-width: 0;
3915  overflow: hidden;
3916  text-overflow: ellipsis;
3917  white-space: nowrap;
3918  font-size: 0.78rem;
3919  font-weight: 500;
3920  color: var(--vp-c-text-3);
3921}
3922
3923.history-path-sep {
3924  flex-shrink: 0;
3925  font-size: 0.78rem;
3926  color: var(--vp-c-text-3);
3927}
3928
3929.history-path-end {
3930  flex-shrink: 0;
3931  white-space: nowrap;
3932  font-size: 0.78rem;
3933  font-weight: 500;
3934  color: var(--vp-c-text-3);
3935}
3936
3937.history-path-only {
3938  flex-shrink: 1;
3939  min-width: 0;
3940  overflow: hidden;
3941  text-overflow: ellipsis;
3942}
3943
3944.history-mode-icon {
3945  flex-shrink: 0;
3946  color: var(--vp-c-text-3);
3947  opacity: 0.7;
3948}
3949
3950.history-remove {
3951  display: flex;
3952  align-items: center;
3953  justify-content: center;
3954  flex-shrink: 0;
3955  padding: 0;
3956  border: none;
3957  background: transparent;
3958  color: var(--vp-c-text-3);
3959  cursor: pointer;
3960  opacity: 0.7;
3961  transition: color 0.15s;
3962}
3963
3964.history-remove:hover {
3965  color: var(--vp-c-text-1);
3966  opacity: 1;
3967}
3968</style>