import { ref , Ref , computed } from 'vue' ; import { useDocumentManager } from '../model/document/document-manager' ; const casState = ref ( 'disconnected' ) ; const docManager = useDocumentManager ( ) ; const fileNewModal = ref ( false ) ; const fileSaveModal = ref ( false ) ; const fileOpenModal = ref ( false ) ; const documentPrefsModal = ref ( false ) ; const fileConfirmClose = ref ( false ) ; const serializedDocument = ref ( '' ) ; function useUIPreferences ( ) { } function useCasStatus ( ) { function setStatus ( s ) { casState . value = s ; } function setReady ( ) { casState . value = 'ready' ; } function setLoading ( ) { casState . value = 'loading' ; } function setDisconnected ( ) { casState . value = 'disconnected' ; } function setError ( ) { casState . value = 'error' ; } return { casState , setStatus , setReady , setLoading , setDisconnected , setError , } ; } function useFileInterface ( ) { function promptNewFile ( ) { fileNewModal . value = true ; } function promptCloseFile ( ) { fileConfirmClose . value = true ; } function openFileSaveModal ( ) { console . log ( 'Saving: ' , docManager . currentDocument . value ) ; serializedDocument . value = docManager . saveDocument ( ) ; fileSaveModal . value = true ; } function closeFileSaveModal ( ) { fileSaveModal . value = false ; } function openFileOpenModal ( ) { serializedDocument . value = '' ; fileOpenModal . value = true ; } function confirmFileOpenModal ( ) { docManager . loadDocument ( serializedDocument . value ) ; fileOpenModal . value = false ; } function closeDocPrefsModal ( ) { documentPrefsModal . value = false ; } return { serializedDocument , fileNewModal , fileSaveModal , fileOpenModal , documentPrefsModal , fileConfirmClose , promptNewFile , promptCloseFile , openFileSaveModal , closeFileSaveModal , openFileOpenModal , confirmFileOpenModal , closeDocPrefsModal , } ; } const casStatus = useCasStatus ( ) ; const fileInterface = useFileInterface ( ) ; export { fileInterface , casStatus } ;