import { defineClientAppSetup } from "@vuepress/client" ; import { onMounted , onUnmounted } from "vue" ; import { useRouter } from "vue-router" ; import type { CodeEnhanceOptions } from "../shared" ; import "./style.css" ; declare const __CODE_ENHANCE_OPTIONS__ ; const options = __CODE_ENHANCE_OPTIONS__ ; export default defineClientAppSetup ( ( ) => { let unregisterRouterHook ; /**
     * Make the code block full-screen.
     */ const fullScreen = ( block ) : void => { const HTMLDom = document . querySelector < HTMLElement > ( "html" ) ; if ( block . classList . contains ( "fullscreen-mode" ) ) { block . classList . remove ( "fullscreen-mode" ) ; HTMLDom ?. classList . remove ( "fixed" ) ; } else { block . classList . add ( "fullscreen-mode" ) ; HTMLDom ?. classList . add ( "fixed" ) ; } } ; /**
     * Add buttons to full screen the code blocks.
     */ const insertFullScreenButtons = ( block ) : void => { if ( block . hasAttribute ( "fullscreen-code-inserted" ) ) return ; const btn = document . createElement ( "div" ) ; btn . classList . add ( "fullscreen-code-button" ) ; btn . addEventListener ( "click" , ( ) => fullScreen ( block ) ) ; block . appendChild ( btn ) ; block . setAttribute ( "fullscreen-code-inserted" , "" ) ; } ; const insertButtons = ( ) : void => { const selector = options . selector || "div[class*='language-']" ; setTimeout ( ( ) => { document . querySelectorAll < HTMLElement > ( selector ) . forEach ( ( block ) => { if ( options . fullScreen !== false ) insertFullScreenButtons ( block ) ; } ) ; } , options . delay || 500 ) ; } ; onMounted ( ( ) => { insertButtons ( ) ; const router = useRouter ( ) ; unregisterRouterHook = router . afterEach ( ( ) => { insertButtons ( ) ; } ) ; } ) ; onUnmounted ( ( ) => { unregisterRouterHook ( ) ; } ) ; } ) ;