/**
 * @highflame/overwatch-linux-arm64
 * Platform-specific binaries for Linux ARM64
 */

const path = require('path');
const fs = require('fs');

const PLATFORM = 'linux';
const ARCH = 'arm64';
const RUST_TARGET = 'aarch64-unknown-linux-gnu';

/**
 * Get the path to the ramparts binary
 * @returns {string|null} Path to binary or null if not found
 */
function getRampartsBinaryPath() {
  const binaryName = `ramparts-${RUST_TARGET}`;
  const binaryPath = path.join(__dirname, 'bin', binaryName);

  if (fs.existsSync(binaryPath)) {
    return binaryPath;
  }

  // Also check for generic name
  const genericPath = path.join(__dirname, 'bin', 'ramparts');
  if (fs.existsSync(genericPath)) {
    return genericPath;
  }

  return null;
}

/**
 * Check if this platform package matches the current runtime
 * @returns {boolean}
 */
function isCurrentPlatform() {
  return process.platform === PLATFORM && process.arch === ARCH;
}

module.exports = {
  platform: PLATFORM,
  arch: ARCH,
  rustTarget: RUST_TARGET,
  getRampartsBinaryPath,
  isCurrentPlatform,
};
