import ComPDFKitViewer from '../../lib/webview.min.js'
const documentViewerMap = new Map()

export const setDocumentViewer = (number, documentViewer, options) => {
  if (documentViewer) {
    documentViewerMap.set(number, documentViewer)
  } else {
    const viewer = new ComPDFKitViewer(options)
    documentViewerMap.set(number, viewer)
  }
}

export const deleteDocumentViewer = (number) => {
  documentViewerMap.delete(number)
}

export const getDocumentViewer = (number = 1) => {
  return documentViewerMap.get(number)
}

export const getDocumentViewers = () => {
  return Array.from(documentViewerMap.values())
}
