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

contextBridge.exposeInMainWorld("api", {
  getSettings: () => ipcRenderer.invoke("settings:get"),
  saveSettings: (settings) => ipcRenderer.invoke("settings:save", settings),
  listAccounts: () => ipcRenderer.invoke("accounts:list"),
  resetAccountCooldown: (accountId) => ipcRenderer.invoke("accounts:resetCooldown", accountId),
  listAccountEvents: (limit) => ipcRenderer.invoke("accounts:events", limit),
  deleteAccount: (accountId) => ipcRenderer.invoke("accounts:delete", accountId),
  refreshAccountIdentity: () => ipcRenderer.invoke("accounts:refreshIdentity"),
  startLogin: (payload) => ipcRenderer.invoke("accounts:startLogin", payload),
  completeLogin: (payload) => ipcRenderer.invoke("accounts:completeLogin", payload),
  importTdata: (payload) => ipcRenderer.invoke("accounts:importTdata", payload),
  clearDatabase: () => ipcRenderer.invoke("db:clear"),
  listLogs: (payload) => ipcRenderer.invoke("logs:list", payload),
  listInvites: (payload) => ipcRenderer.invoke("invites:list", payload),
  clearLogs: (taskId) => ipcRenderer.invoke("logs:clear", taskId),
  clearInvites: (taskId) => ipcRenderer.invoke("invites:clear", taskId),
  exportLogs: (taskId) => ipcRenderer.invoke("logs:export", taskId),
  exportInvites: (taskId) => ipcRenderer.invoke("invites:export", taskId),
  clearQueue: (taskId) => ipcRenderer.invoke("queue:clear", taskId),
  startTask: () => ipcRenderer.invoke("task:start"),
  stopTask: () => ipcRenderer.invoke("task:stop"),
  getStatus: () => ipcRenderer.invoke("status:get"),
  parseHistory: (limit) => ipcRenderer.invoke("task:parseHistory", limit),
  getMembershipStatus: () => ipcRenderer.invoke("accounts:membershipStatus"),
  checkGroupAccess: () => ipcRenderer.invoke("groups:checkAccess"),
  listTasks: () => ipcRenderer.invoke("tasks:list"),
  getTask: (id) => ipcRenderer.invoke("tasks:get", id),
  saveTask: (payload) => ipcRenderer.invoke("tasks:save", payload),
  deleteTask: (id) => ipcRenderer.invoke("tasks:delete", id),
  startTaskById: (id) => ipcRenderer.invoke("tasks:start", id),
  stopTaskById: (id) => ipcRenderer.invoke("tasks:stop", id),
  listAccountAssignments: () => ipcRenderer.invoke("tasks:accountAssignments"),
  appendTaskAccounts: (payload) => ipcRenderer.invoke("tasks:appendAccounts", payload),
  removeTaskAccount: (payload) => ipcRenderer.invoke("tasks:removeAccount", payload),
  startAllTasks: () => ipcRenderer.invoke("tasks:startAll"),
  stopAllTasks: () => ipcRenderer.invoke("tasks:stopAll"),
  taskStatus: (id) => ipcRenderer.invoke("tasks:status", id),
  parseHistoryByTask: (id) => ipcRenderer.invoke("tasks:parseHistory", id),
  checkAccessByTask: (id) => ipcRenderer.invoke("tasks:checkAccess", id),
  membershipStatusByTask: (id) => ipcRenderer.invoke("tasks:membershipStatus", id)
});
