<script setup lang="ts">
import { useNav } from '@slidev/client'
import { onBeforeUnmount, onMounted, watch } from 'vue'

const nav = useNav()

function isInteractiveRoute() {
  if (/(?:^|\/)(?:overview|export|editor|notes|notes-edit|print)(?:\/|$)/.test(window.location.pathname))
    return false
  return nav.isPresenter.value || nav.hasPrimarySlide.value
}

function syncScrollFallback() {
  document.body.classList.toggle('easy-slide-scroll-fallback', isInteractiveRoute())
}

onMounted(syncScrollFallback)

watch(
  [nav.isPresenter, nav.hasPrimarySlide],
  syncScrollFallback,
)

onBeforeUnmount(() => {
  document.body.classList.remove('easy-slide-scroll-fallback')
})
</script>

<template>
  <span hidden aria-hidden="true" />
</template>
