import electron from 'electron';
import type { CaptureService } from '../services/CaptureService.js';
import type { BrowserWindow } from 'electron';
const { ipcMain } = electron;

export function registerCaptureApi(
  captureService: CaptureService,
  getQuickCaptureWindow: () => BrowserWindow | null
): void {
  ipcMain.handle('capture:submit', async (_e, payload: { text: string; images: ArrayBuffer[] }) => {
    return captureService.submit(payload);
  });
  ipcMain.on('capture:hide', () => {
    getQuickCaptureWindow()?.hide();
  });
}
