import { contextBridge, ipcRenderer } from "electron";

// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld("electronAPI", {
  onIPCData: (channel, callback) => {
    ipcRenderer.on(channel, (event, data) => callback(data));
  },
  // Send messages to main process
  sendIPC: (channel, data) => {
    console.log("SEND IPC", channel);
    ipcRenderer.send(channel, data);
  },
  // Window management
  minimize: () => ipcRenderer.send("window-minimize"),
  maximize: () => ipcRenderer.send("window-maximize"),
  close: () => ipcRenderer.send("window-close"),
  removeAllListeners: (channel) => {
    ipcRenderer.removeAllListeners(channel);
  },
});
