const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('api', {
  checkDependencies: () => ipcRenderer.invoke('check-dependencies'),
  onDependencyStatus: (callback) => ipcRenderer.on('dependency-status', (_, data) => callback(data)),
  getVideoInfo: (url, browser) => ipcRenderer.invoke('get-video-info', { url, browser }),
  downloadMedia: (items, browser) => ipcRenderer.invoke('download-media', { items, browser }),
  pauseDownload: () => ipcRenderer.invoke('pause-download'),
  resumeDownload: () => ipcRenderer.invoke('resume-download'),
  stopDownload: () => ipcRenderer.invoke('stop-download'),
  onDownloadProgress: (callback) => ipcRenderer.on('download-progress', (_, data) => callback(data)),
  selectDirectory: () => ipcRenderer.invoke('select-directory'),
  getDownloadsFolder: () => ipcRenderer.invoke('get-downloads-folder'),
  openPath: (path) => ipcRenderer.invoke('open-path', path),
  minimizeWindow: () => ipcRenderer.send('window-minimize'),
  closeWindow: () => ipcRenderer.send('window-close')
});
