/**
 * @lastid/lastid-sdk — unified entry point.
 *
 * Tries native addon first (fastest, WebSocket support).
 * Falls back to WASM if no native binary for this platform.
 *
 * Native: Node.js/Bun with napi-rs (.node addon)
 * WASM: Browser, Deno, or unsupported native platforms
 */

'use strict';

// Try native first
const native = require('./native.js');

if (native) {
  // Native addon loaded — export NapiClient as the primary client
  module.exports = native;
} else {
  // No native binary — fall back to WASM
  // This works in Node.js 18+ with WASM support
  try {
    const wasm = require('./wasm/lastid_sdk.js');
    module.exports = wasm;
  } catch (e) {
    throw new Error(
      '@lastid/lastid-sdk: Failed to load both native addon and WASM fallback. ' +
      'Install the correct platform package or ensure WASM support is available.\n' +
      `Native error: no platform package for ${process.platform}-${process.arch}\n` +
      `WASM error: ${e.message}`
    );
  }
}
