const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('desktop', Object.freeze({
  platform: process.platform,
  licenseStatus: () => ipcRenderer.invoke('license:status'),
  openLicenseAccount: () => ipcRenderer.invoke('license:account'),
  activateLicense: link => ipcRenderer.invoke('license:activate', link),
  licensePublisherToken: () => ipcRenderer.invoke('license:connect'),
  deactivateLicense: () => ipcRenderer.invoke('license:deactivate'),
  diskSpace: () => ipcRenderer.invoke('disk:space'),
  version: process.argv.find(value => value.startsWith('--relio-version='))?.slice('--relio-version='.length) || '0.3.0',
  copyLink: value => ipcRenderer.invoke('clipboard:link', value),
  openSink: metadata => ipcRenderer.invoke('sink:open', metadata),
  writeSink: (id, bytes) => ipcRenderer.invoke('sink:write', id, bytes),
  closeSink: id => ipcRenderer.invoke('sink:close', id),
  abortSink: id => ipcRenderer.invoke('sink:abort', id),
  setKeepAwake: enabled => ipcRenderer.invoke('power:awake', enabled),
}));
