import { useSyncExternalStore } from 'react';
import { isViewerFullscreen } from '@/pages/viewer/utils/viewerFullscreen';

function subscribeFullscreen(callback: () => void) {
  document.addEventListener('fullscreenchange', callback);
  return () => document.removeEventListener('fullscreenchange', callback);
}

export function useIsBrowserFullscreen() {
  return useSyncExternalStore(subscribeFullscreen, isViewerFullscreen, () => false);
}
