import { defineStore } from 'pinia';
import { ref } from 'vue';

export const userSplitScreenFullScreen = defineStore('userSplitScreenFullScreen', () => {
  const isFullScreen = ref(false);
  const curFullScreenType = ref('single');

  function fullScreen(elementId, fullScreenType) {
    curFullScreenType.value = fullScreenType;
    const element = document.getElementById(elementId);
    if (element?.requestFullscreen) element.requestFullscreen();
    isFullScreen.value = true;
  }
  function exitFullscreen() {
    if (document.fullscreenElement && document.exitFullscreen) document.exitFullscreen();
    isFullScreen.value = false;
  }
  return { isFullScreen, curFullScreenType, fullScreen, exitFullscreen };
});

export default userSplitScreenFullScreen;
