import { contextBridge, ipcRenderer } from 'electron'

const api = {
  platform: process.platform,
  gitea: {
    /** Whether the main process has a gitea token + target repo configured. */
    status: () => ipcRenderer.invoke('gitea:status'),
    /** Full read of the managed repo — every issue + milestone. */
    reconcile: () => ipcRenderer.invoke('gitea:reconcile'),
    /** One issue by index, normalized (or null if unconfigured). */
    getIssue: (index: number) => ipcRenderer.invoke('gitea:getIssue', index),
  },
}

export type CommiteaApi = typeof api

contextBridge.exposeInMainWorld('commitea', api)
