import os
from .base import BaseEngine

try:
    import numpy as np
except ImportError:
    np = None

class NumpySecureEngine(BaseEngine):
    """High-throughput 32-bit Vectorized OS Entropy."""
    def __init__(self):
        if np is None:
            raise ImportError("NumPy is required. Run: pip install Hyrandom[secure]")
        self._m32 = 2.3283064365386963e-10

    def random(self):
        return int.from_bytes(os.urandom(4), 'big') * self._m32

class NumpyFastEngine(BaseEngine):
    """V18 SFC64: Maximum simulation speed via NumPy."""
    def __init__(self):
        if np is None:
            raise ImportError("NumPy is required. Run: pip install Hyrandom[fast]")
        self._rng = np.random.Generator(np.random.SFC64())

    def random(self):
        return float(self._rng.random())