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

contextBridge.exposeInMainWorld('realmAPI', {
  loadData: () => ipcRenderer.invoke('data:load'),
  saveData: (data) => ipcRenderer.invoke('data:save', data),
  login: (username, password) => ipcRenderer.invoke('auth:login', username, password),
  register: (username, password, userId, profile) => ipcRenderer.invoke('auth:register', username, password, userId, profile),
  changePassword: (currentPassword, newPassword) => ipcRenderer.invoke('auth:change-password', currentPassword, newPassword),
  resetProfile: (profile) => ipcRenderer.invoke('profile:reset', profile),
  adminGrantResources: (targetUserId, resources) => ipcRenderer.invoke('admin:resources', targetUserId, resources),
  adminGrantInventory: (targetUserId, inventory) => ipcRenderer.invoke('admin:inventory', targetUserId, inventory),
  adminSetAccess: (targetUserId, enabled) => ipcRenderer.invoke('admin:access', targetUserId, enabled),
  marketSendResources: (targetUserId, resources) => ipcRenderer.invoke('market:send-resources', targetUserId, resources),
  getVersion: () => ipcRenderer.invoke('app:version'),
  getDataPath: () => ipcRenderer.invoke('app:data-path'),
  getBackendStatus: () => ipcRenderer.invoke('backend:status'),
  getRanking: () => ipcRenderer.invoke('ranking:list'),
  clearSession: () => ipcRenderer.invoke('auth:clear-session')
});
