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

contextBridge.exposeInMainWorld("api", {
  getProjectPath: () => ipcRenderer.invoke("get-project-path"),
  setProjectPath: () => ipcRenderer.invoke("set-project-path"),
  loadPaintings: () => ipcRenderer.invoke("load-paintings"),
  savePaintings: (data) => ipcRenderer.invoke("save-paintings", data),
  loadEvents: () => ipcRenderer.invoke("load-events"),
  saveEvents: (data) => ipcRenderer.invoke("save-events", data),
  loadConfig: () => ipcRenderer.invoke("load-config"),
  saveConfig: (data) => ipcRenderer.invoke("save-config", data),
  uploadImage: (targetDir) => ipcRenderer.invoke("upload-image", targetDir),
  runCommand: (cmd, args) => ipcRenderer.invoke("run-command", cmd, args),
  onCommandOutput: (cb) => ipcRenderer.on("command-output", (_, text) => cb(text)),
  activateLicense: (key) => ipcRenderer.invoke("activate-license", key),
  validateLicense: () => ipcRenderer.invoke("validate-license"),
  getLicenseStatus: () => ipcRenderer.invoke("get-license-status"),
  deactivateLicense: () => ipcRenderer.invoke("deactivate-license"),
  isSetupComplete: () => ipcRenderer.invoke("is-setup-complete"),
  scaffoldProject: (opts) => ipcRenderer.invoke("scaffold-project", opts),
  deploySite: (opts) => ipcRenderer.invoke("deploy-site", opts),
  selectFolder: () => ipcRenderer.invoke("select-folder"),
});
