#!/usr/bin/env node
/** Copyright (C) 2020-2026 Kedron Holdings LLC, All Rights Reserved. This file is part of Reactor.
 *  For info and license terms please see https://reactor.toggledbits.com/
 *  ------------------------------------------------------------------------------
*/
const a0_0x433d0a = a0_0x4338;
(function (_0x244d6c, _0x5a278f) {
    const _0x23634e = a0_0x4338, _0xaf01a2 = _0x244d6c();
    while (!![]) {
        try {
            const _0x26dd6e = -parseInt(_0x23634e(0xa7)) / 0x1 * (parseInt(_0x23634e(0x154)) / 0x2) + parseInt(_0x23634e(0xc6)) / 0x3 + parseInt(_0x23634e(0x15d)) / 0x4 + parseInt(_0x23634e(0xf4)) / 0x5 * (parseInt(_0x23634e(0x118)) / 0x6) + parseInt(_0x23634e(0x12e)) / 0x7 + -parseInt(_0x23634e(0x13d)) / 0x8 * (-parseInt(_0x23634e(0x163)) / 0x9) + parseInt(_0x23634e(0x107)) / 0xa * (-parseInt(_0x23634e(0x9a)) / 0xb);
            if (_0x26dd6e === _0x5a278f)
                break;
            else
                _0xaf01a2['push'](_0xaf01a2['shift']());
        } catch (_0x60ee69) {
            _0xaf01a2['push'](_0xaf01a2['shift']());
        }
    }
}(a0_0x2097, 0x9f411));
const version = 0x6666, BUILD_VERSION = 'latest-26214-86a3f502', MIN_NODE_MAJOR = 0x14, NODE_VERSIONS = {
        0x12: { 'eol': 0x1968a005600 },
        0x14: { 'eol': 0x19de1b18200 },
        0x16: { 'eol': 0x1a53962ae00 },
        0x18: { 'eol': 0x1ac963a3600 },
        0x1a: { 'eol': 0x1b3edeb6200 }
    }, NODE_EOL_WARNING = 0x3c;
if (parseInt(process[a0_0x433d0a(0xc9)]['node'][a0_0x433d0a(0xbd)]('.')[0x0]) < MIN_NODE_MAJOR) {
    console[a0_0x433d0a(0x85)](a0_0x433d0a(0x8b), process['versions'][a0_0x433d0a(0x94)], '(not\x20supported)');
    throw new Error(a0_0x433d0a(0x159) + process[a0_0x433d0a(0xc9)]['node']);
}
const path = require(a0_0x433d0a(0x117)), os = require('os'), fs = require('fs');
function make_dir(_0xf077a2) {
    const _0x19abfd = a0_0x433d0a;
    if (!fs[_0x19abfd(0xe9)](_0xf077a2))
        return fs[_0x19abfd(0xf3)](_0xf077a2), !![];
    return ![];
}
function checkConfigDir(_0xc49d94, _0x32596e) {
    const _0x1ea08d = a0_0x433d0a;
    make_dir(_0xc49d94) && fs['readdirSync'](_0x32596e)[_0x1ea08d(0xd3)](_0x3cc426 => {
        const _0xfe1bd2 = _0x1ea08d;
        if (_0x3cc426[_0xfe1bd2(0x91)](/\.(yaml|yml|json)(-dist)?$/i)) {
            const _0x2a90cc = path['resolve'](_0xc49d94, _0x3cc426);
            if (!fs[_0xfe1bd2(0xe9)](_0x2a90cc))
                try {
                    fs[_0xfe1bd2(0xa6)](path[_0xfe1bd2(0x15c)](_0x32596e, _0x3cc426), _0x2a90cc);
                } catch (_0x9a066e) {
                    console[_0xfe1bd2(0x111)](_0x9a066e);
                }
        }
    });
}
let opts = {
        'noengine': ![],
        'repl': ![],
        'pidfile': ![],
        'basedir': process['env'][a0_0x433d0a(0x95)] || process[a0_0x433d0a(0x119)](),
        'opterr': ![]
    }, argv = process[a0_0x433d0a(0x11a)][a0_0x433d0a(0x9c)](0x2);
while (argv[a0_0x433d0a(0xa0)] > 0x0) {
    let arg = argv[a0_0x433d0a(0x112)]();
    switch (arg) {
    case '-R':
        opts[a0_0x433d0a(0xb2)] = !![];
        break;
    case '-N':
        opts['noengine'] = !![];
        break;
    case '-d':
        opts[a0_0x433d0a(0x12a)] = argv[a0_0x433d0a(0x112)]() || opts[a0_0x433d0a(0x12a)];
        break;
    case '-c':
        opts[a0_0x433d0a(0x113)] = argv['shift']() || opts[a0_0x433d0a(0x113)];
        break;
    case '-p':
        opts[a0_0x433d0a(0x90)] = argv['shift']() || 'reactor.pid';
        break;
    default:
        opts['opterr'] = !![], console[a0_0x433d0a(0x111)]('Invalid\x20command\x20line\x20argument:', arg);
    }
}
opts[a0_0x433d0a(0xda)] && process[a0_0x433d0a(0xe6)](0xff);
function a0_0x4338(_0x51c230, _0x411b27) {
    _0x51c230 = _0x51c230 - 0x84;
    const _0x209720 = a0_0x2097();
    let _0x4338fc = _0x209720[_0x51c230];
    return _0x4338fc;
}
const express = require(a0_0x433d0a(0xcf)), repl = require(a0_0x433d0a(0xb2)), basedir = path[a0_0x433d0a(0x15c)](opts[a0_0x433d0a(0x12a)] || process[a0_0x433d0a(0xa8)][a0_0x433d0a(0x95)] || __dirname), confdir = opts[a0_0x433d0a(0x113)] ? path[a0_0x433d0a(0x15c)](opts[a0_0x433d0a(0x113)]) : path['resolve'](process[a0_0x433d0a(0xa8)]['REACTOR_CONFIG_PREFIX'] ? process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xe5)] : process['env'][a0_0x433d0a(0xce)] ? path['resolve'](process['env'][a0_0x433d0a(0xce)], a0_0x433d0a(0x161)) : path[a0_0x433d0a(0x131)](basedir, 'config'));
console['log']('Reactor', BUILD_VERSION, a0_0x433d0a(0xef), version, a0_0x433d0a(0xae), confdir), checkConfigDir(confdir, path[a0_0x433d0a(0x131)](basedir, a0_0x433d0a(0xec)));
const Configuration = require(a0_0x433d0a(0x9f)), rcf = path[a0_0x433d0a(0x15c)](confdir, a0_0x433d0a(0x143));
let valid_config = ![], c;
try {
    c = Configuration[a0_0x433d0a(0x114)](a0_0x433d0a(0xfa), rcf)['getConfig'](a0_0x433d0a(0xfa), 'object');
    if (!c)
        throw new Error(a0_0x433d0a(0xdf) + rcf + a0_0x433d0a(0x84));
    valid_config = !![];
} catch (a0_0x37f25f) {
    console['error']('Unable\x20to\x20load\x20configuration\x20from', rcf, ':', a0_0x37f25f), console['log']('A\x20default\x20(empty)\x20configuration\x20with\x20the\x20Engine\x20disabled\x20will\x20be\x20used.'), c = Configuration[a0_0x433d0a(0x114)](a0_0x433d0a(0xfa), { 'reactor': { 'engine': { 'enabled': ![] } } })[a0_0x433d0a(0x133)](a0_0x433d0a(0xfa), 'object');
}
c['basedir'] = basedir, c['confdir'] = confdir, c[a0_0x433d0a(0xa3)] = c[a0_0x433d0a(0xa3)] || path[a0_0x433d0a(0x15c)](process[a0_0x433d0a(0xa8)][a0_0x433d0a(0x141)] ? process[a0_0x433d0a(0xa8)][a0_0x433d0a(0x141)] : path[a0_0x433d0a(0x15c)](process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xce)] || basedir, 'storage')), c['logsdir'] = c[a0_0x433d0a(0xc5)] || path['resolve'](process[a0_0x433d0a(0xa8)]['REACTOR_LOG_PREFIX'] ? process['env'][a0_0x433d0a(0xc3)] : path[a0_0x433d0a(0x15c)](process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xce)] || basedir, 'logs')), c['plugindir'] = c['plugindir'] || path['resolve'](process[a0_0x433d0a(0xa8)][a0_0x433d0a(0x102)] ? process[a0_0x433d0a(0xa8)]['REACTOR_PLUGIN_PREFIX'] : path['resolve'](process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xce)] || basedir, a0_0x433d0a(0xb3))), c[a0_0x433d0a(0xdc)] = c[a0_0x433d0a(0xdc)] || path[a0_0x433d0a(0x15c)](process['env'][a0_0x433d0a(0x102)] ? process[a0_0x433d0a(0xa8)]['REACTOR_PLUGIN_PREFIX'] : path[a0_0x433d0a(0x15c)](process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xce)] || basedir, a0_0x433d0a(0x92))), console[a0_0x433d0a(0x111)](a0_0x433d0a(0xba), process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xba)]);
const is_docker = fs['existsSync'](a0_0x433d0a(0xc8));
c[a0_0x433d0a(0x13e)] = is_docker, c[a0_0x433d0a(0xcd)] = a0_0x433d0a(0x104) === process[a0_0x433d0a(0x157)];
if (is_docker && fs['existsSync']('/var/reactor/.docker-image-volume') && !![] !== c[a0_0x433d0a(0xb0)]) {
    console[a0_0x433d0a(0x85)](a0_0x433d0a(0xac));
    throw new Error(a0_0x433d0a(0x121));
}
opts[a0_0x433d0a(0x13a)] = opts['noengine'] || fs['existsSync'](path[a0_0x433d0a(0x15c)](confdir, a0_0x433d0a(0x13a)));
if (c['experimental_check_uidgid']) {
    if (c[a0_0x433d0a(0xb4)] && process[a0_0x433d0a(0xfd)]() !== c[a0_0x433d0a(0xb4)])
        try {
            process['setgid'](c[a0_0x433d0a(0xb4)]);
        } catch (a0_0x12b14a) {
            console[a0_0x433d0a(0x85)](a0_0x433d0a(0xf0) + a0_0x12b14a);
        }
    if (c[a0_0x433d0a(0x101)] && process[a0_0x433d0a(0x88)]() !== c['uid'])
        try {
            process[a0_0x433d0a(0x11c)](c[a0_0x433d0a(0x101)]);
        } catch (a0_0x297be5) {
            console[a0_0x433d0a(0x85)]('Failed\x20to\x20set\x20the\x20UID\x20of\x20the\x20Reactor\x20process:\x20' + a0_0x297be5);
            throw a0_0x297be5;
        }
}
if (opts[a0_0x433d0a(0x90)]) {
    opts['pidfile'] = path[a0_0x433d0a(0x15c)](c[a0_0x433d0a(0xa3)], opts[a0_0x433d0a(0x90)]);
    try {
        fs[a0_0x433d0a(0x12f)](opts['pidfile'], String(process[a0_0x433d0a(0xfb)]));
    } catch (a0_0x58c724) {
        console[a0_0x433d0a(0x85)](a0_0x433d0a(0xd1) + opts[a0_0x433d0a(0x90)] + ':\x20' + a0_0x58c724);
    }
}
make_dir(c[a0_0x433d0a(0xa3)]), make_dir(c[a0_0x433d0a(0xc5)]), Configuration['getInstance'](a0_0x433d0a(0xb1), path[a0_0x433d0a(0x131)](confdir, a0_0x433d0a(0x14c)));
const Logger = require(a0_0x433d0a(0xd2)), log = Logger[a0_0x433d0a(0xf2)](a0_0x433d0a(0xef)), sys_locale = process[a0_0x433d0a(0xa8)]['LC_ALL'] || process[a0_0x433d0a(0xa8)]['LANG'] || process[a0_0x433d0a(0xa8)][a0_0x433d0a(0x13c)];
log[a0_0x433d0a(0x10f)](a0_0x433d0a(0xbe), BUILD_VERSION, process[a0_0x433d0a(0x106)], process[a0_0x433d0a(0x12b)]), log[a0_0x433d0a(0x10f)](a0_0x433d0a(0x127), process[a0_0x433d0a(0xfb)], process[a0_0x433d0a(0x88)] ? process[a0_0x433d0a(0x88)]() : '-', process[a0_0x433d0a(0xfd)] ? process['getgid']() : '-', is_docker ? a0_0x433d0a(0x156) : a0_0x433d0a(0x137), process[a0_0x433d0a(0x157)], process['arch'], os[a0_0x433d0a(0x106)](), sys_locale), log['always'](a0_0x433d0a(0xca), c[a0_0x433d0a(0x12a)], c[a0_0x433d0a(0xa3)]), log[a0_0x433d0a(0x10f)](a0_0x433d0a(0xa5), process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xba)]);
if ('' === (process[a0_0x433d0a(0xa8)]['NODE_PATH'] || '')) {
    log[a0_0x433d0a(0xab)](a0_0x433d0a(0xd7));
    throw new Error(a0_0x433d0a(0x15b));
} else {
    let paths = process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xba)]['split'](path[a0_0x433d0a(0x115)]), found = ![];
    for (let p of paths) {
        if ('' !== p && fs['existsSync'](path[a0_0x433d0a(0x131)](p, a0_0x433d0a(0x96)))) {
            log[a0_0x433d0a(0x158)](0x5, a0_0x433d0a(0x8f), p), found = !![];
            break;
        }
        log[a0_0x433d0a(0x116)](a0_0x433d0a(0xc1));
    }
    if (!found) {
        log[a0_0x433d0a(0xab)]('NODE_PATH\x20does\x20not\x20seem\x20to\x20include\x20Reactor\x20install\x20directory\x20as\x20first\x20element:\x20%1', process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xba)]);
        throw new Error(a0_0x433d0a(0x12d));
    }
}
const hasICU = a0_0x433d0a(0x9d) === typeof Intl;
try {
    const ICUTZ = hasICU ? Intl[a0_0x433d0a(0xf6)]()[a0_0x433d0a(0x130)]()['timeZone'] : a0_0x433d0a(0x144), now = new Date();
    log[a0_0x433d0a(0x10f)](a0_0x433d0a(0x15e), ICUTZ, process[a0_0x433d0a(0xa8)]['TZ'], -now[a0_0x433d0a(0x11f)]());
} catch (a0_0x1ba239) {
    log[a0_0x433d0a(0x103)]('app:\x20can\x27t\x20get\x20locale\x20timezone:\x20%1', a0_0x1ba239);
}
const i18n = require('server/lib/i18n');
let locale = c[a0_0x433d0a(0x139)] || sys_locale || 'en-US.UTF-8';
log[a0_0x433d0a(0x10f)]('Configured\x20locale\x20%1;\x20selected\x20locale(s)\x20%2', c[a0_0x433d0a(0x139)], locale), locale = locale[a0_0x433d0a(0xbd)](/ *, */);
let loaded = ![];
for (let l of locale) {
    let m = l[a0_0x433d0a(0xbd)](/\./);
    m[0x0] = (m[0x0] || '??')['replace']('_', '-'), m[0x1] = (m[0x1] || a0_0x433d0a(0xc4))[a0_0x433d0a(0x14f)]();
    if (a0_0x433d0a(0xc4) !== m[0x1]) {
        log[a0_0x433d0a(0x103)](a0_0x433d0a(0xe7) + l + a0_0x433d0a(0x151));
        continue;
    }
    try {
        log[a0_0x433d0a(0x158)](0x5, 'attempting\x20load\x20of\x20locale\x20%1', m[0x0]);
        if (i18n['setLocale'](m[0x0], ![])) {
            log[a0_0x433d0a(0x10f)](a0_0x433d0a(0x153), i18n[a0_0x433d0a(0xb8)](), m[0x0]), loaded = !![];
            break;
        }
    } catch (a0_0x26042b) {
        log['notice'](a0_0x433d0a(0x11b), m[0x0], a0_0x26042b);
    }
}
if (!loaded) {
    let m = locale[0x0]['split'](/\./);
    m[0x0] = (m[0x0] || '??')[a0_0x433d0a(0x98)]('_', '-'), m[0x1] = (m[0x1] || a0_0x433d0a(0xc4))[a0_0x433d0a(0x14f)]();
    try {
        i18n[a0_0x433d0a(0xff)](m[0x0], a0_0x433d0a(0xbf)) && (log['always'](a0_0x433d0a(0x153), i18n[a0_0x433d0a(0xb8)](), m[0x0]), loaded = !![]);
    } catch (a0_0x58984b) {
        log[a0_0x433d0a(0xed)](a0_0x433d0a(0x11b), m[0x0], a0_0x58984b);
    }
}
!loaded && (log[a0_0x433d0a(0x116)]('Loading\x20default\x20en-US\x20as\x20locale\x20and\x20translation\x20(fallback)'), i18n[a0_0x433d0a(0xff)](a0_0x433d0a(0xbf)));
log[a0_0x433d0a(0x10f)](a0_0x433d0a(0xeb), new Date()[a0_0x433d0a(0x8a)]());
function a0_0x2097() {
    const _0x211a9c = [
        '126606mhDChP',
        'cwd',
        'argv',
        'Failed\x20to\x20load\x20locale\x20%1:\x20%2',
        'setuid',
        'The\x20version\x20of\x20nodejs\x20you\x20are\x20using\x20({0})\x20is\x20approaching\x20end-of-life.\x20Please\x20upgrade\x20nodejs\x20to\x20the\x20latest\x20LTS\x20version\x20as\x20soon\x20as\x20possible.',
        'reactor-root-priv',
        'getTimezoneOffset',
        '/proc/1/mountinfo',
        'Invalid\x20volume\x20configuration',
        'All\x20logs\x20closed',
        'stop',
        'shutdown',
        'Stopping\x20timers...',
        'Please\x20refer\x20to\x20the\x20console\x20log\x20for\x20trace',
        'Process\x20ID\x20%1\x20user/group\x20%2/%3;\x20%4;\x20platform\x20%5/%6\x20%7;\x20locale\x20%8',
        'server/lib/AlertManager',
        'reactor.http_proxy_enabled',
        'basedir',
        'execPath',
        'Failed\x20to\x20start\x20HTTP\x20API:\x20%1',
        'Environment\x20NODE_PATH\x20does\x20not\x20include\x20the\x20Reactor\x20install\x20directory',
        '3243331pZJprb',
        'writeFileSync',
        'resolvedOptions',
        'join',
        'Shutdown\x20signal\x20(%1)\x20received.\x20Stopping\x20Reaction\x20Engine...',
        'getConfig',
        'Starting\x20HTTP\x20server\x20and\x20API...',
        'unhandled.json',
        'engine-disabled',
        'bare-metal',
        'received\x20message:\x20%1',
        'locale',
        'noengine',
        'unlinkSync',
        'LANGUAGE',
        '8FPNJeG',
        'is_docker',
        'invalid-config-',
        'server/wsapi/wsapi',
        'REACTOR_STORAGE_PREFIX',
        'SIGHUP',
        'reactor.yaml',
        '(no\x20ICU)',
        'WARN',
        'isLastKnownGood',
        'addAlert',
        'Controller\x20%1\x20failed\x20to\x20start:\x20%2',
        'unhandledRejection',
        '/var/reactor',
        'kill',
        'logging.yaml',
        'waitAllControllers',
        'Reload\x20message\x20received\x20(handling\x20as\x20SIGQUIT)',
        'toUpperCase',
        'All\x20%1\x20controllers\x20successfully\x20started.',
        '\x20cannot\x20be\x20used;\x20encodings\x20other\x20than\x20UTF-8\x20are\x20not\x20supported',
        'reason',
        'Loaded\x20locale\x20%1\x20for\x20%2',
        '47522JhLTHZ',
        'TimedPromise',
        'docker',
        'platform',
        'debug',
        'Unsupported\x20nodejs\x20version\x20',
        'includes',
        'Required\x20environment\x20variable\x20NODE_PATH\x20is\x20not\x20set',
        'resolve',
        '1172756lGXEzU',
        'Resolved\x20timezone=%1,\x20environment\x20TZ=%2;\x20offset\x20minutes\x20from\x20UTC=%3',
        'tools',
        'accept_nodejs_version',
        'config',
        'boolean',
        '10529721rKWUpF',
        'Exiting...',
        '\x20unreadable\x20or\x20empty',
        'error',
        'server/lib/i18n',
        'SIGQUIT',
        'getuid',
        'readFileSync',
        'toLocaleString',
        'Detected\x20nodejs',
        'dist-config',
        'exception',
        'The\x20version\x20of\x20nodejs\x20you\x20are\x20using\x20({0})\x20is\x20now\x20end-of-life,\x20and\x20so\x20is\x20deprecated\x20for\x20use\x20with\x20Reactor.\x20Please\x20upgrade\x20nodejs\x20to\x20the\x20latest\x20LTS\x20version\x20as\x20soon\x20as\x20possible.',
        'app:\x20NODE_PATH\x20component\x20%1\x20seems\x20to\x20be\x20Reactor\x20install\x20dir',
        'pidfile',
        'match',
        'locales',
        'Shutting\x20down\x20logs:',
        'node',
        'REACTOR_HOME',
        'server/lib/Logger.js',
        'FORCED\x20EXIT',
        'replace',
        'SIGTERM',
        '17590111lyaGiv',
        'The\x20following\x20configurations\x20were\x20valid\x20and\x20loaded\x20during\x20startup:\x20%1',
        'slice',
        'object',
        'Configuration\x20file\x20%1\x20could\x20not\x20be\x20loaded;\x20a\x20last-known-good\x20version\x20of\x20the\x20file\x20has\x20been\x20loaded\x20instead.\x20See\x20Troubleshooting\x20Startup\x20in\x20the\x20documentation.',
        './server/lib/Configuration',
        'length',
        '#warn-lkg-config',
        'context',
        'datadir',
        'NOTICE',
        'NODE_PATH=%1',
        'copyFileSync',
        '46NykIst',
        'env',
        'Waiting\x20%1\x20seconds\x20before\x20continuing\x20(startup\x20delay)',
        'Starting\x20WSAPI...',
        'crit',
        'The\x20data\x20volume\x20has\x20not\x20been\x20correctly\x20configured\x20and\x20mounted.\x20Stopping\x20container.\x20Please\x20refer\x20to\x20the\x20installation\x20instructions\x20for\x20your\x20docker\x20image.',
        'EADDRINUSE',
        'configuration\x20from',
        './server/lib/TimerBroker.js',
        'suppress_docker_volume_check',
        'logging',
        'repl',
        'ext',
        'gid',
        'reactor.engine.enabled',
        'trace',
        'Trapped\x20unhandled\x20Promise\x20rejection',
        'getLoadedLocale',
        'sysconfig-invalid',
        'NODE_PATH',
        'now',
        'Container\x20has\x20no\x20identifiable\x20mount\x20for\x20/var/reactor.',
        'split',
        'Reactor\x20build\x20%1\x20starting\x20on\x20%2\x20%3',
        'en-US',
        'reload',
        'Warning:\x20NODE_PATH\x20does\x20not\x20have\x20Reactor\x20directory\x20as\x20first\x20element!',
        './server/lib/httpproxy',
        'REACTOR_LOG_PREFIX',
        'UTF-8',
        'logsdir',
        '835401zCFSMQ',
        'writeReport',
        '/opt/reactor/.reactor-docker',
        'versions',
        'Basedir\x20%1;\x20data\x20in\x20%2',
        'Trapped\x20unhandled\x20exception:',
        'then',
        'is_windows',
        'REACTOR_DATA_PREFIX',
        'express',
        'Shutdown\x20complete,\x20process\x20ID\x20%1',
        'Failed\x20to\x20write\x20',
        './server/lib/Logger',
        'forEach',
        'code',
        'struct',
        'enumConfig',
        'NODE_PATH\x20required\x20environment\x20variable\x20is\x20not\x20set;\x20can\x27t\x20continue',
        'SIGINT',
        'The\x20version\x20of\x20nodejs\x20you\x20are\x20using\x20({0})\x20is\x20not\x20an\x20LTS\x20version,\x20or\x20has\x20not\x20been\x20tested\x20with\x20Reactor.\x20This\x20is\x20not\x20recommended.',
        'opterr',
        'find',
        'localesdir',
        'Stopping\x20Engine...',
        'toLocaleDateString',
        'Configuration\x20file\x20',
        'nodejs\x20major\x20version\x20%1\x20accepted\x20(by\x20configuration\x20exception)',
        'report',
        'The\x20engine\x20has\x20been\x20disabled\x20and\x20is\x20not\x20running\x20(rules\x20are\x20not\x20being\x20processed).',
        'dismissTag',
        'Closing\x20APIs...',
        'REACTOR_CONFIG_PREFIX',
        'exit',
        'Locale\x20',
        'Shutdown\x20message\x20received\x20(handling\x20as\x20SIGINT)',
        'existsSync',
        'eol',
        'Local\x20date/time\x20using\x20configured\x20timezone\x20and\x20locale\x20formatting\x20is\x20%1',
        './dist-config',
        'notice',
        'catch',
        'app',
        'Failed\x20to\x20set\x20the\x20GID\x20of\x20the\x20Reactor\x20process:\x20',
        'info',
        'getLogger',
        'mkdirSync',
        '270AueQZJ',
        'INVALID\x20CONFIGURATION!\x20Configuration\x20file\x20{0:q}\x20contains\x20an\x20error\x20and\x20could\x20not\x20be\x20loaded.\x20The\x20last-known-good\x20version\x20was\x20loaded\x20instead.\x20Check\x20this\x20file\x20using\x20available\x20syntax-checking\x20tools,\x20correct\x20all\x20errors,\x20and\x20restart.\x20See\x20the\x20Troubleshooting\x20Startup\x20section\x20of\x20the\x20documentation\x20for\x20more\x20help.',
        'DateTimeFormat',
        'nodejs-version',
        'toString',
        'server/lib/httpapi',
        'reactor',
        'pid',
        'reactor.engine.wait_all_controllers',
        'getgid',
        '.yaml',
        'setLocale',
        'Failed\x20to\x20start\x20engine:\x20%1',
        'uid',
        'REACTOR_PLUGIN_PREFIX',
        'err',
        'win32',
        'Closing\x20logs...',
        'version',
        '10vXpIND',
        'ERROR',
        'Trapped\x20unhandled\x20exception:\x20%1',
        'server/lib/Structure',
        'HTTP\x20server\x20running;\x20registering\x20proxy\x20endpoints.',
        'Closing\x20Structure...',
        'notifyStartup',
        'start',
        'always',
        'Starting\x20Structure...',
        'log',
        'shift',
        'confdir',
        'getInstance',
        'delimiter',
        'warn',
        'path'
    ];
    a0_0x2097 = function () {
        return _0x211a9c;
    };
    return a0_0x2097();
}
if (is_docker) {
    try {
        const sp = path[a0_0x433d0a(0x15c)](basedir, a0_0x433d0a(0x8c)), tp = path[a0_0x433d0a(0x15c)](process[a0_0x433d0a(0xa8)]['REACTOR_DATA_PREFIX'] || a0_0x433d0a(0x14a), a0_0x433d0a(0x8c));
        fs['cpSync'](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x5610e1) {
        log[a0_0x433d0a(0x8d)](a0_0x5610e1);
    }
    try {
        const sp = path[a0_0x433d0a(0x15c)](basedir, a0_0x433d0a(0x15f)), tp = path[a0_0x433d0a(0x15c)](process[a0_0x433d0a(0xa8)][a0_0x433d0a(0xce)] || a0_0x433d0a(0x14a), 'tools');
        fs['cpSync'](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x3edbe7) {
        log[a0_0x433d0a(0x8d)](a0_0x3edbe7);
    }
    try {
        const ll = fs[a0_0x433d0a(0x89)](a0_0x433d0a(0x120))[a0_0x433d0a(0xf8)]('utf-8')[a0_0x433d0a(0xbd)](os['EOL']), ee = ll[a0_0x433d0a(0xdb)](_0x44eb34 => _0x44eb34[a0_0x433d0a(0x15a)]('/var/reactor'));
        ee ? log[a0_0x433d0a(0xf1)]('Container\x20mount\x20for\x20/var/reactor:\x20%1', ee) : log[a0_0x433d0a(0x116)](a0_0x433d0a(0xbc));
    } catch (a0_0x402f98) {
        log[a0_0x433d0a(0x8d)](a0_0x402f98);
    }
}
const app = express(), struct = require(a0_0x433d0a(0x10a)), Engine = require('server/lib/Engine'), httpapi = require(a0_0x433d0a(0xf9)), wsapi = require(a0_0x433d0a(0x140)), AlertManager = require(a0_0x433d0a(0x128));
process['on'](a0_0x433d0a(0x149), (_0xdfd0fe, _0xfbf2e8) => {
    const _0x193db4 = a0_0x433d0a;
    console['log'](_0x193db4(0xb7), _0xdfd0fe), console[_0x193db4(0x85)](_0xdfd0fe), console[_0x193db4(0x85)](_0xfbf2e8), console['trace']();
    try {
        process[_0x193db4(0xe1)][_0x193db4(0xc7)](path[_0x193db4(0x15c)](c[_0x193db4(0xc5)], _0x193db4(0x135)), _0xdfd0fe), log[_0x193db4(0x85)]('Trapped\x20unhandled\x20Promise\x20rejection:\x20%1', _0xdfd0fe), log[_0x193db4(0x8d)](_0xdfd0fe), log[_0x193db4(0x85)](_0x193db4(0x126));
    } catch (_0x2a9883) {
    }
}), process['on']('uncaughtException', _0x26f9c8 => {
    const _0x29ec89 = a0_0x433d0a;
    console[_0x29ec89(0x85)](_0x29ec89(0xcb), _0x26f9c8), console[_0x29ec89(0xb6)](_0x26f9c8);
    try {
        process[_0x29ec89(0xe1)][_0x29ec89(0xc7)](path[_0x29ec89(0x15c)](c['logsdir'], 'unhandled.json'), _0x26f9c8), log[_0x29ec89(0x85)](_0x29ec89(0x109), _0x26f9c8), log['error'](_0x29ec89(0x126));
    } catch (_0x4f8815) {
    }
    'EADDRINUSE' === _0x26f9c8[_0x29ec89(0xd4)] && setTimeout(function () {
        process['exit'](0x1);
    }, 0xfa);
}), log[a0_0x433d0a(0xed)](a0_0x433d0a(0x110)), struct[a0_0x433d0a(0x10e)](c[a0_0x433d0a(0x12a)])[a0_0x433d0a(0xcc)](async () => {
    const _0x515587 = a0_0x433d0a, _0x503478 = Engine[_0x515587(0x114)]();
    try {
        const _0x429a0d = parseInt(process[_0x515587(0xc9)][_0x515587(0x94)][_0x515587(0xbd)]('.')[0x0]);
        let _0x296f6c = !![];
        if (!isNaN(_0x429a0d)) {
            const _0x5f5d6b = NODE_VERSIONS[_0x429a0d];
            if (c?.['accept_nodejs_version'] && c[_0x515587(0x160)] == _0x429a0d)
                log[_0x515587(0x158)](0x5, _0x515587(0xe0), _0x429a0d);
            else {
                if (_0x5f5d6b) {
                    log['info']('nodejs\x20v%1\x20known,\x20supported\x20through\x20%2', _0x429a0d, new Date(_0x5f5d6b[_0x515587(0xea)])[_0x515587(0xde)]());
                    const _0xfa3e30 = _0x5f5d6b[_0x515587(0xea)] - NODE_EOL_WARNING * 0x5265c00;
                    if (Date[_0x515587(0xbb)]() >= _0x5f5d6b[_0x515587(0xea)])
                        AlertManager[_0x515587(0x147)](AlertManager[_0x515587(0x145)], _0x515587(0x8e), { 'tag': 'nodejs-version' }, process[_0x515587(0xc9)]['node']), _0x296f6c = ![];
                    else
                        Date['now']() >= _0xfa3e30 && (AlertManager['addAlert'](AlertManager[_0x515587(0xa4)], _0x515587(0x11d), { 'tag': _0x515587(0xf7) }, process['versions']['node']), _0x296f6c = ![]);
                } else
                    AlertManager[_0x515587(0x147)](AlertManager[_0x515587(0x145)], _0x515587(0xd9), { 'tag': _0x515587(0xf7) }, process['versions'][_0x515587(0x94)]), _0x296f6c = ![];
            }
        }
        _0x296f6c && AlertManager[_0x515587(0xe3)](_0x515587(0xf7)), process[_0x515587(0x88)] && 0x0 === process[_0x515587(0x88)]() && !is_docker ? AlertManager[_0x515587(0x147)](AlertManager[_0x515587(0x145)], 'Reactor\x20is\x20running\x20as\x20root!\x20This\x20is\x20a\x20very\x20high\x20security\x20risk\x20and\x20not\x20recommended.\x20Please\x20run\x20Reactor\x20as\x20an\x20unprivileged\x20user\x20only.\x20Refer\x20to\x20the\x20installation\x20instructions.', { 'tag': 'reactor-root-priv' }) : AlertManager[_0x515587(0xe3)](_0x515587(0x11e));
    } catch (_0x1dfdc2) {
        log[_0x515587(0x8d)](_0x1dfdc2);
    }
    !valid_config ? AlertManager[_0x515587(0x147)](AlertManager['ERROR'], 'The\x20Reactor\x20configuration\x20in\x20{0:q}\x20could\x20not\x20be\x20read;\x20the\x20system\x20has\x20started\x20with\x20an\x20empty\x20configuration.', { 'tag': _0x515587(0xb9) }, rcf) : AlertManager[_0x515587(0xe3)](_0x515587(0xb9));
    if (!![] === Configuration[_0x515587(0x133)](_0x515587(0xfc), _0x515587(0x162), ![])) {
        log[_0x515587(0xed)]('Waiting\x20for\x20controllers\x20to\x20start\x20up...');
        const _0x2a0cba = Date[_0x515587(0xbb)]();
        let _0x164e2d = await struct[_0x515587(0x14d)](Configuration[_0x515587(0x133)]('reactor.engine.startup_wait', 'number', 0xea60));
        log[_0x515587(0xf1)]('Startup\x20was\x20delayed\x20%1ms', Date['now']() - _0x2a0cba);
        let _0x30701c = 0x0;
        for (let _0x54501f of _0x164e2d) {
            !_0x54501f['status'] && (log[_0x515587(0xed)](_0x515587(0x148), _0x54501f['id'], _0x54501f[_0x515587(0x152)]), ++_0x30701c);
        }
        0x0 === _0x30701c && log[_0x515587(0xed)](_0x515587(0x150), _0x164e2d[_0x515587(0xa0)]);
    }
    var _0x320209 = ![], _0x307473 = async function (_0x3a3b6f) {
            const _0x53eabf = _0x515587;
            if (_0x320209)
                return;
            _0x320209 = !![], log['always'](_0x53eabf(0x132), _0x3a3b6f);
            try {
                log[_0x53eabf(0xed)](_0x53eabf(0xdd)), await _0x503478[_0x53eabf(0x123)]();
            } catch (_0x2b2c0b) {
                log[_0x53eabf(0x8d)](_0x2b2c0b);
            }
            try {
                log['notice'](_0x53eabf(0x10c)), await struct[_0x53eabf(0x123)]();
            } catch (_0x293c3d) {
                log[_0x53eabf(0x8d)](_0x293c3d), console[_0x53eabf(0x85)](_0x293c3d);
            }
            try {
                log[_0x53eabf(0xed)](_0x53eabf(0xe4)), await wsapi['stop'](), await httpapi[_0x53eabf(0x123)]();
            } catch (_0x20d39d) {
                log['exception'](_0x20d39d), console[_0x53eabf(0x85)](_0x20d39d);
            }
            try {
                log[_0x53eabf(0xed)](_0x53eabf(0x125));
                let _0x38afee = require(_0x53eabf(0xaf));
                _0x38afee[_0x53eabf(0x123)]();
            } catch (_0xcc5e52) {
                log[_0x53eabf(0x8d)](_0xcc5e52), console[_0x53eabf(0x85)](_0xcc5e52);
            }
            log[_0x53eabf(0x10f)](_0x53eabf(0xd0), process[_0x53eabf(0xfb)]);
            try {
                log[_0x53eabf(0x10f)](_0x53eabf(0x105)), await Logger[_0x53eabf(0x124)](), console[_0x53eabf(0x111)](_0x53eabf(0x122));
            } catch (_0x9df5c0) {
                console[_0x53eabf(0x85)](_0x53eabf(0x93), _0x9df5c0);
            }
            try {
                opts[_0x53eabf(0x90)] && fs[_0x53eabf(0x13b)](opts[_0x53eabf(0x90)]);
            } catch (_0x57a4b1) {
                console[_0x53eabf(0x85)](_0x57a4b1);
            }
            setTimeout(() => {
                const _0xd5f507 = _0x53eabf;
                console[_0xd5f507(0x85)](_0xd5f507(0x97)), process['exit'](_0xd5f507(0x87) === _0x3a3b6f ? 0x1 : 0x7f);
            }, 0x7d0), process[_0x53eabf(0xe6)](_0x53eabf(0x87) === _0x3a3b6f ? 0x1 : 0x7f);
        };
    process['on'](_0x515587(0xd8), _0x307473), process['on'](_0x515587(0x99), _0x307473), process['on'](_0x515587(0x87), _0x307473), process['on'](_0x515587(0x142), _0x307473), process['on']('message', _0x16d48a => {
        const _0x2fe295 = _0x515587;
        log['debug'](0x5, _0x2fe295(0x138), _0x16d48a);
        if (_0x2fe295(0x124) === _0x16d48a)
            log[_0x2fe295(0xed)](_0x2fe295(0xe8)), _0x307473(_0x2fe295(0xd8));
        else
            _0x2fe295(0xc0) === _0x16d48a && (log['notice'](_0x2fe295(0x14e)), _0x307473(_0x2fe295(0x87)));
    }), process['on'](_0x515587(0xe6), function () {
        const _0x2e704d = _0x515587;
        console['log'](_0x2e704d(0x164));
    }), log[_0x515587(0xed)](_0x515587(0x134)), httpapi[_0x515587(0x10e)](app, c[_0x515587(0x12a)])[_0x515587(0xcc)](_0x3ef484 => {
        const _0x430dd2 = _0x515587;
        if (Configuration[_0x430dd2(0x133)](_0x430dd2(0x129), _0x430dd2(0x162), ![])) {
            const _0x64fd0c = require(_0x430dd2(0xc2));
            log[_0x430dd2(0xed)](_0x430dd2(0x10b)), _0x64fd0c['start'](app);
        }
        log[_0x430dd2(0xed)](_0x430dd2(0xaa)), wsapi['start'](app, _0x3ef484)[_0x430dd2(0xcc)](async () => {
            const _0x20c247 = _0x430dd2;
            wsapi[_0x20c247(0x10d)]();
        });
    })[_0x515587(0xee)](_0x3f4ca6 => {
        const _0x571cad = _0x515587;
        log[_0x571cad(0x103)](_0x571cad(0x12c), _0x3f4ca6), _0x571cad(0xad) === _0x3f4ca6[_0x571cad(0xd4)] && (log[_0x571cad(0x103)]('Stopping\x20service;\x20another\x20instance\x20may\x20be\x20running.'), process[_0x571cad(0x14b)](process[_0x571cad(0xfb)], _0x571cad(0x87)));
    });
    if (opts[_0x515587(0x13a)] || ![] === Configuration['getConfig'](_0x515587(0xb5), 'boolean', !![])) {
        const _0xf3e2e5 = require(_0x515587(0x86));
        log[_0x515587(0xab)]('Engine\x20startup\x20suppressed;\x20no\x20rules\x20will\x20be\x20processed.'), AlertManager['addAlert'](AlertManager[_0x515587(0x108)], _0xf3e2e5['_T'](_0x515587(0xe2)), { 'tag': _0x515587(0x136) });
    } else {
        let _0x297e1d = Configuration[_0x515587(0x133)]('reactor.engine.startup_delay', 'number', 0x0);
        if (_0x297e1d > 0x0) {
            const _0x4de537 = require('server/lib/util');
            await _0x4de537[_0x515587(0x155)](() => {
                const _0x5d6fab = _0x515587;
                log[_0x5d6fab(0x10f)](_0x5d6fab(0xa9), _0x297e1d / 0x3e8);
            }, _0x297e1d)[_0x515587(0xee)](_0x284b6f => {
            });
        }
        log[_0x515587(0xed)]('Starting\x20Reaction\x20Engine...'), struct['subscribe'](_0x503478);
        try {
            _0x503478[_0x515587(0x10e)](), AlertManager[_0x515587(0xe3)](_0x515587(0x136));
        } catch (_0x28db62) {
            log[_0x515587(0x103)](_0x515587(0x100), _0x28db62), log['exception'](_0x28db62);
        }
    }
    try {
        const _0x502433 = Configuration[_0x515587(0xd6)]();
        let _0x3dc76a = !![];
        for (const _0x5b3c1d of _0x502433) {
            const _0x461c96 = Configuration[_0x515587(0x114)](_0x5b3c1d), _0x4ab83b = _0x461c96 && _0x461c96[_0x515587(0x146)]();
            _0x4ab83b ? (AlertManager[_0x515587(0x147)](AlertManager[_0x515587(0x108)], [
                _0x515587(0xa1),
                _0x515587(0xf5)
            ], { 'tag': _0x515587(0x13f) + _0x5b3c1d }, _0x5b3c1d + _0x515587(0xfe)), log[_0x515587(0xab)](_0x515587(0x9e), _0x5b3c1d + _0x515587(0xfe)), _0x3dc76a = ![]) : AlertManager[_0x515587(0xe3)](_0x515587(0x13f) + _0x5b3c1d);
        }
        _0x3dc76a && log[_0x515587(0xed)](_0x515587(0x9b), _0x502433);
    } catch (_0x39bb0c) {
        log[_0x515587(0x8d)](_0x39bb0c);
    }
    log[_0x515587(0xed)]('app\x20startup\x20complete');
});
if (opts[a0_0x433d0a(0xb2)]) {
    let r = repl[a0_0x433d0a(0x10e)]('>\x20'), ctx = r[a0_0x433d0a(0xa2)];
    ctx[a0_0x433d0a(0xd5)] = struct, ctx['engine'] = Engine[a0_0x433d0a(0x114)](struct), r['on']('exit', () => {
        const _0x19a280 = a0_0x433d0a;
        Engine[_0x19a280(0x114)](struct)[_0x19a280(0x123)](), struct[_0x19a280(0x123)](), process[_0x19a280(0xe6)](0x1);
    });
}