<?php

declare(strict_types=1);





if (PHP_VERSION_ID < 70400) {
    throw new RuntimeException('PhpWA requires PHP 7.4 or newer.');
}

$phpwaComposerAutoload = __DIR__ . '/vendor/autoload.php';
if (!is_file($phpwaComposerAutoload)) {
    throw new RuntimeException(
        'PhpWA dependencies are missing. Run Composer install or use the shared-hosting release archive.'
    );
}

$phpwaLoader = require $phpwaComposerAutoload;

 
 
 
 
$phpwaCompactClassmap = __DIR__ . '/compact-classmap.php';
if (is_file($phpwaCompactClassmap)) {
    $phpwaCompactClasses = require $phpwaCompactClassmap;
    if (!is_array($phpwaCompactClasses)) {
        throw new RuntimeException('PhpWA compact classmap is invalid.');
    }
    foreach ($phpwaCompactClasses as $phpwaCompactClass => $phpwaCompactPath) {
        if (!is_string($phpwaCompactClass) || preg_match('/^[A-Za-z_][A-Za-z0-9_\\\\]*$/D', $phpwaCompactClass) !== 1
            || !is_string($phpwaCompactPath) || preg_match('#^c/[a-f0-9]{16}\\.php$#D', $phpwaCompactPath) !== 1) {
            throw new RuntimeException('PhpWA compact classmap entry is invalid.');
        }
    }
    spl_autoload_register(static function (string $class) use ($phpwaCompactClasses): void {
        if (!isset($phpwaCompactClasses[$class])) {
            return;
        }
        require_once __DIR__ . '/' . $phpwaCompactClasses[$class];
    }, true, true);
}

return $phpwaLoader;
