/**
 * Electron Forge Configuration — Bradly Desktop App
 *
 * Handles packaging and creating distributable installers.
 * Targets: macOS (.dmg) and Windows (.exe)
 */
import type { ForgeConfig } from '@electron-forge/shared-types';
import { MakerDMG } from '@electron-forge/maker-dmg';
import { MakerSquirrel } from '@electron-forge/maker-squirrel';

const config: ForgeConfig = {
  packagerConfig: {
    name: 'Bradly',
    executableName: 'bradly',
    icon: './assets/icon', // .icns for macOS, .ico for Windows (auto-resolved)
    asar: {
      // Remotion compositor binaries MUST be outside app.asar
      // because they are native executables that need direct filesystem access
      unpack: '{**/node_modules/@remotion/compositor-*/**,**/node_modules/@remotion/renderer/**}',
    },
    // Include the built renderer and Remotion bundle as extra resources
    extraResource: [
      './out/renderer',
      './out/remotion-bundle',
    ],
    // Ignore development files during packaging
    ignore: [
      /^\/src$/,
      /^\/scripts$/,
      /^\/uploads$/,
      /^\/renders$/,
      /^\/\.vscode$/,
      /^\/\.git$/,
      /^\/\.env/,
      /^\/\.antigravity$/,
      /^\/vite\.config\.ts$/,
      /^\/electron\.vite\.config\.ts$/,
      /^\/tsconfig\.json$/,
      /^\/ABOUT\.md$/,
      /^\/AGENTS\.md$/,
      /^\/README\.md$/,
      /^\/schema\.sql$/,
      /^\/backend_endpoint\.py$/,
    ],
  },
  makers: [
    // macOS installer
    new MakerDMG({
      format: 'ULFO',
    }),
    // Windows installer (.exe)
    new MakerSquirrel({
      name: 'Bradly',
      setupIcon: './assets/icon.ico',
      iconUrl: 'https://raw.githubusercontent.com/kevdevg/Bradly/main/assets/icon.ico',
    }),
  ],
};

export default config;
