#!/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_0x15f8c1 = a0_0x1bfc;
(function (_0x23f9fb, _0x54c8f7) {
    const _0x33b35f = a0_0x1bfc, _0x2249db = _0x23f9fb();
    while (!![]) {
        try {
            const _0x5b1c8e = -parseInt(_0x33b35f(0xeb)) / 0x1 * (parseInt(_0x33b35f(0xca)) / 0x2) + parseInt(_0x33b35f(0xb5)) / 0x3 + -parseInt(_0x33b35f(0xa8)) / 0x4 + parseInt(_0x33b35f(0xcf)) / 0x5 + parseInt(_0x33b35f(0xc5)) / 0x6 * (-parseInt(_0x33b35f(0x144)) / 0x7) + -parseInt(_0x33b35f(0x71)) / 0x8 * (-parseInt(_0x33b35f(0x8b)) / 0x9) + parseInt(_0x33b35f(0xa0)) / 0xa;
            if (_0x5b1c8e === _0x54c8f7)
                break;
            else
                _0x2249db['push'](_0x2249db['shift']());
        } catch (_0x48b011) {
            _0x2249db['push'](_0x2249db['shift']());
        }
    }
}(a0_0x28c0, 0x9fde6));
const version = 0x6608, BUILD_VERSION = 'latest-26120-d2e50474', MIN_NODE_MAJOR = 0x12, NODE_VERSIONS = {
        0x12: { 'eol': 0x1968a005600 },
        0x14: { 'eol': 0x19de1b18200 },
        0x16: { 'eol': 0x1a53962ae00 },
        0x18: { 'eol': 0x1b049cc5600 }
    }, NODE_EOL_WARNING = 0x3c;
if (parseInt(process['versions'][a0_0x15f8c1(0xe1)]['split']('.')[0x0]) < MIN_NODE_MAJOR) {
    console[a0_0x15f8c1(0x12c)](a0_0x15f8c1(0xea), process[a0_0x15f8c1(0xf5)][a0_0x15f8c1(0xe1)], '(not\x20supported)');
    throw new Error(a0_0x15f8c1(0xa5) + process[a0_0x15f8c1(0xf5)][a0_0x15f8c1(0xe1)]);
}
const path = require(a0_0x15f8c1(0x117)), os = require('os'), fs = require('fs');
function make_dir(_0x431539) {
    const _0x4bae7c = a0_0x15f8c1;
    if (!fs[_0x4bae7c(0x8e)](_0x431539))
        return fs[_0x4bae7c(0xee)](_0x431539), !![];
    return ![];
}
function checkConfigDir(_0x56a927, _0x8ed769) {
    const _0x34a1e8 = a0_0x15f8c1;
    make_dir(_0x56a927) && fs['readdirSync'](_0x8ed769)[_0x34a1e8(0x12a)](_0x31aed1 => {
        const _0x292043 = _0x34a1e8;
        if (_0x31aed1[_0x292043(0x10f)](/\.(yaml|yml|json)(-dist)?$/i)) {
            const _0x3fa63c = path[_0x292043(0x68)](_0x56a927, _0x31aed1);
            if (!fs[_0x292043(0x8e)](_0x3fa63c))
                try {
                    fs['copyFileSync'](path['resolve'](_0x8ed769, _0x31aed1), _0x3fa63c);
                } catch (_0x1c9b9c) {
                    console[_0x292043(0x129)](_0x1c9b9c);
                }
        }
    });
}
let opts = {
        'noengine': ![],
        'repl': ![],
        'pidfile': ![],
        'basedir': process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0xbe)] || process['cwd'](),
        'opterr': ![]
    }, argv = process[a0_0x15f8c1(0x147)][a0_0x15f8c1(0xc6)](0x2);
while (argv[a0_0x15f8c1(0xa7)] > 0x0) {
    let arg = argv['shift']();
    switch (arg) {
    case '-R':
        opts['repl'] = !![];
        break;
    case '-N':
        opts['noengine'] = !![];
        break;
    case '-d':
        opts['basedir'] = argv[a0_0x15f8c1(0xb7)]() || opts[a0_0x15f8c1(0x84)];
        break;
    case '-c':
        opts['confdir'] = argv[a0_0x15f8c1(0xb7)]() || opts[a0_0x15f8c1(0xa3)];
        break;
    case '-p':
        opts[a0_0x15f8c1(0xfb)] = argv[a0_0x15f8c1(0xb7)]() || a0_0x15f8c1(0xcd);
        break;
    default:
        opts['opterr'] = !![], console[a0_0x15f8c1(0x129)](a0_0x15f8c1(0x119), arg);
    }
}
opts['opterr'] && process[a0_0x15f8c1(0xc7)](0xff);
const express = require(a0_0x15f8c1(0x9e)), repl = require(a0_0x15f8c1(0xd7)), basedir = path['resolve'](opts[a0_0x15f8c1(0x84)] || process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0xbe)] || __dirname), confdir = opts['confdir'] ? path[a0_0x15f8c1(0x68)](opts[a0_0x15f8c1(0xa3)]) : path[a0_0x15f8c1(0x68)](process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x112)] ? process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x112)] : process['env'][a0_0x15f8c1(0x139)] ? path['resolve'](process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x139)], a0_0x15f8c1(0x9c)) : path[a0_0x15f8c1(0xe9)](basedir, a0_0x15f8c1(0x9c)));
console[a0_0x15f8c1(0x129)]('Reactor', BUILD_VERSION, a0_0x15f8c1(0x142), version, a0_0x15f8c1(0x11a), confdir), checkConfigDir(confdir, path['join'](basedir, a0_0x15f8c1(0xf7)));
function a0_0x1bfc(_0x23f6ac, _0x5dbf0b) {
    _0x23f6ac = _0x23f6ac - 0x64;
    const _0x28c0e5 = a0_0x28c0();
    let _0x1bfc8b = _0x28c0e5[_0x23f6ac];
    return _0x1bfc8b;
}
const Configuration = require(a0_0x15f8c1(0x9f)), rcf = path[a0_0x15f8c1(0x68)](confdir, a0_0x15f8c1(0x6f));
let valid_config = ![], c;
try {
    c = Configuration[a0_0x15f8c1(0x126)]('reactor', rcf)[a0_0x15f8c1(0xd5)](a0_0x15f8c1(0x80), 'object');
    if (!c)
        throw new Error(a0_0x15f8c1(0xd1) + rcf + a0_0x15f8c1(0x103));
    valid_config = !![];
} catch (a0_0x32a8c0) {
    console['error'](a0_0x15f8c1(0x141), rcf, ':', a0_0x32a8c0), console['log'](a0_0x15f8c1(0x105)), c = Configuration[a0_0x15f8c1(0x126)]('reactor', { 'reactor': { 'engine': { 'enabled': ![] } } })[a0_0x15f8c1(0xd5)](a0_0x15f8c1(0x80), a0_0x15f8c1(0x6d));
}
c['basedir'] = basedir, c[a0_0x15f8c1(0xa3)] = confdir, c['datadir'] = c['datadir'] || path['resolve'](process[a0_0x15f8c1(0x6b)]['REACTOR_STORAGE_PREFIX'] ? process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x116)] : path[a0_0x15f8c1(0x68)](process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x139)] || basedir, 'storage')), c['logsdir'] = c['logsdir'] || path[a0_0x15f8c1(0x68)](process['env'][a0_0x15f8c1(0x72)] ? process[a0_0x15f8c1(0x6b)]['REACTOR_LOG_PREFIX'] : path[a0_0x15f8c1(0x68)](process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x139)] || basedir, a0_0x15f8c1(0x66))), c[a0_0x15f8c1(0x7a)] = c[a0_0x15f8c1(0x7a)] || path[a0_0x15f8c1(0x68)](process[a0_0x15f8c1(0x6b)]['REACTOR_PLUGIN_PREFIX'] ? process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x87)] : path[a0_0x15f8c1(0x68)](process[a0_0x15f8c1(0x6b)]['REACTOR_DATA_PREFIX'] || basedir, a0_0x15f8c1(0xd4))), c[a0_0x15f8c1(0x12d)] = c[a0_0x15f8c1(0x12d)] || path['resolve'](process['env'][a0_0x15f8c1(0x87)] ? process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x87)] : path['resolve'](process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x139)] || basedir, a0_0x15f8c1(0xad))), console[a0_0x15f8c1(0x129)](a0_0x15f8c1(0xd0), process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0xd0)]);
const is_docker = fs[a0_0x15f8c1(0x8e)](a0_0x15f8c1(0x96));
c[a0_0x15f8c1(0x107)] = is_docker, c[a0_0x15f8c1(0x10e)] = a0_0x15f8c1(0xdf) === process[a0_0x15f8c1(0x104)];
if (is_docker && fs[a0_0x15f8c1(0x8e)]('/var/reactor/.docker-image-volume') && !![] !== c[a0_0x15f8c1(0x114)]) {
    console['error'](a0_0x15f8c1(0x146));
    throw new Error(a0_0x15f8c1(0xff));
}
opts[a0_0x15f8c1(0xd6)] = opts[a0_0x15f8c1(0xd6)] || fs[a0_0x15f8c1(0x8e)](path[a0_0x15f8c1(0x68)](confdir, a0_0x15f8c1(0xd6)));
if (c[a0_0x15f8c1(0x11b)]) {
    if (c['gid'] && process['getgid']() !== c[a0_0x15f8c1(0x10b)])
        try {
            process[a0_0x15f8c1(0x111)](c[a0_0x15f8c1(0x10b)]);
        } catch (a0_0x21470c) {
            console[a0_0x15f8c1(0x12c)](a0_0x15f8c1(0x67) + a0_0x21470c);
        }
    if (c[a0_0x15f8c1(0x65)] && process[a0_0x15f8c1(0x7d)]() !== c[a0_0x15f8c1(0x65)])
        try {
            process[a0_0x15f8c1(0xd2)](c[a0_0x15f8c1(0x65)]);
        } catch (a0_0x1d1265) {
            console[a0_0x15f8c1(0x12c)](a0_0x15f8c1(0x109) + a0_0x1d1265);
            throw a0_0x1d1265;
        }
}
function a0_0x28c0() {
    const _0x245de7 = [
        'Exiting...',
        'confdir',
        'pid',
        'Unsupported\x20nodejs\x20version\x20',
        'Starting\x20Reaction\x20Engine...',
        'length',
        '4931316kytHZK',
        'utf-8',
        'Container\x20mount\x20for\x20/var/reactor:\x20%1',
        'Required\x20environment\x20variable\x20NODE_PATH\x20is\x20not\x20set',
        'Closing\x20APIs...',
        'locales',
        'uncaughtException',
        'subscribe',
        'All\x20logs\x20closed',
        'writeFileSync',
        'Shutdown\x20signal\x20(%1)\x20received.\x20Stopping\x20Reaction\x20Engine...',
        'reactor.engine.startup_wait',
        'LANG',
        '578976TXUvVh',
        'Waiting\x20for\x20controllers\x20to\x20start\x20up...',
        'shift',
        'reactor.engine.startup_delay',
        'unhandled.json',
        'The\x20Reactor\x20configuration\x20in\x20{0:q}\x20could\x20not\x20be\x20read;\x20the\x20system\x20has\x20started\x20with\x20an\x20empty\x20configuration.',
        'sysconfig-invalid',
        'code',
        '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.',
        'REACTOR_HOME',
        'now',
        'status',
        'server/lib/Logger.js',
        'shutdown',
        'arch',
        'dismissTag',
        '82860ryHWuB',
        'slice',
        'exit',
        'kill',
        'warn',
        '114616uabHap',
        'WARN',
        'accept_nodejs_version',
        'reactor.pid',
        '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.',
        '3278145wZUBKm',
        'NODE_PATH',
        'Configuration\x20file\x20',
        'setuid',
        'Warning:\x20NODE_PATH\x20does\x20not\x20have\x20Reactor\x20directory\x20as\x20first\x20element!',
        'ext',
        'getConfig',
        'noengine',
        'repl',
        'crit',
        'server/wsapi/wsapi',
        'Waiting\x20%1\x20seconds\x20before\x20continuing\x20(startup\x20delay)',
        'Reload\x20message\x20received\x20(handling\x20as\x20SIGQUIT)',
        'datadir',
        'The\x20engine\x20has\x20been\x20disabled\x20and\x20is\x20not\x20running\x20(rules\x20are\x20not\x20being\x20processed).',
        'nodejs\x20v%1\x20known,\x20supported\x20through\x20%2',
        'win32',
        'struct',
        'node',
        'Trapped\x20unhandled\x20exception:\x20%1',
        'Failed\x20to\x20start\x20HTTP\x20API:\x20%1',
        'app:\x20can\x27t\x20get\x20locale\x20timezone:\x20%1',
        'SIGQUIT',
        'setLocale',
        'Trapped\x20unhandled\x20exception:',
        'notifyStartup',
        'join',
        'Detected\x20nodejs',
        '2VEWWyc',
        'context',
        'getgid',
        'mkdirSync',
        'Engine\x20startup\x20suppressed;\x20no\x20rules\x20will\x20be\x20processed.',
        'Stopping\x20Engine...',
        'NODE_PATH\x20required\x20environment\x20variable\x20is\x20not\x20set;\x20can\x27t\x20continue',
        'server/lib/AlertManager',
        'locale',
        'then',
        'versions',
        'Process\x20ID\x20%1\x20user/group\x20%2/%3;\x20%4;\x20platform\x20%5/%6\x20%7;\x20locale\x20%8',
        './dist-config',
        'Locale\x20',
        '\x20cannot\x20be\x20used;\x20encodings\x20other\x20than\x20UTF-8\x20are\x20not\x20supported',
        'find',
        'pidfile',
        'EOL',
        'Stopping\x20service;\x20another\x20instance\x20may\x20be\x20running.',
        'FORCED\x20EXIT',
        'Invalid\x20volume\x20configuration',
        'UTF-8',
        'execPath',
        'Trapped\x20unhandled\x20Promise\x20rejection:\x20%1',
        '\x20unreadable\x20or\x20empty',
        'platform',
        'A\x20default\x20(empty)\x20configuration\x20with\x20the\x20Engine\x20disabled\x20will\x20be\x20used.',
        'waitAllControllers',
        'is_docker',
        'LC_ALL',
        'Failed\x20to\x20set\x20the\x20UID\x20of\x20the\x20Reactor\x20process:\x20',
        'boolean',
        'gid',
        './server/lib/TimerBroker.js',
        'Container\x20has\x20no\x20identifiable\x20mount\x20for\x20/var/reactor.',
        'is_windows',
        'match',
        'reactor.http_proxy_enabled',
        'setgid',
        'REACTOR_CONFIG_PREFIX',
        'tools',
        'suppress_docker_volume_check',
        'split',
        'REACTOR_STORAGE_PREFIX',
        'path',
        'received\x20message:\x20%1',
        'Invalid\x20command\x20line\x20argument:',
        'configuration\x20from',
        'experimental_check_uidgid',
        'Please\x20refer\x20to\x20the\x20console\x20log\x20for\x20trace',
        'ERROR',
        'getLoadedLocale',
        'engine-disabled',
        'TimedPromise',
        'nodejs-version',
        'info',
        'NODE_PATH=%1',
        'All\x20%1\x20controllers\x20successfully\x20started.',
        'reactor.engine.wait_all_controllers',
        'getInstance',
        'includes',
        'addAlert',
        'log',
        'forEach',
        'replace',
        'error',
        'localesdir',
        'always',
        'logging',
        'report',
        'Failed\x20to\x20load\x20locale\x20%1:\x20%2',
        'Reactor\x20build\x20%1\x20starting\x20on\x20%2\x20%3',
        'SIGINT',
        'server/lib/i18n',
        'trace',
        'getTimezoneOffset',
        'Failed\x20to\x20write\x20',
        'SIGTERM',
        'REACTOR_DATA_PREFIX',
        'Failed\x20to\x20start\x20engine:\x20%1',
        'app:\x20NODE_PATH\x20component\x20%1\x20seems\x20to\x20be\x20Reactor\x20install\x20dir',
        'Closing\x20Structure...',
        'debug',
        'readFileSync',
        'dist-config',
        'reason',
        'Unable\x20to\x20load\x20configuration\x20from',
        'app',
        'reload',
        '196HocJEt',
        'exception',
        'The\x20data\x20volume\x20has\x20not\x20been\x20correctly\x20configured\x20and\x20mounted.\x20Stopping\x20container.\x20Please\x20refer\x20to\x20the\x20installation\x20instructions\x20for\x20your\x20docker\x20image.',
        'argv',
        'docker',
        'delimiter',
        '(no\x20ICU)',
        'uid',
        'logs',
        'Failed\x20to\x20set\x20the\x20GID\x20of\x20the\x20Reactor\x20process:\x20',
        'resolve',
        'logsdir',
        '/var/reactor',
        'env',
        'Starting\x20HTTP\x20server\x20and\x20API...',
        'object',
        'version',
        'reactor.yaml',
        'cpSync',
        '6032SKdqZS',
        'REACTOR_LOG_PREFIX',
        'Closing\x20logs...',
        'en-US.UTF-8',
        'Environment\x20NODE_PATH\x20does\x20not\x20include\x20the\x20Reactor\x20install\x20directory',
        '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.',
        './server/lib/httpproxy',
        'Stopping\x20timers...',
        'NODE_PATH\x20does\x20not\x20seem\x20to\x20include\x20Reactor\x20install\x20directory\x20as\x20first\x20element:\x20%1',
        'plugindir',
        'start',
        'attempting\x20load\x20of\x20locale\x20%1',
        'getuid',
        'Shutdown\x20message\x20received\x20(handling\x20as\x20SIGINT)',
        'DateTimeFormat',
        'reactor',
        'Starting\x20Structure...',
        'toLocaleDateString',
        'engine',
        'basedir',
        'resolvedOptions',
        'stop',
        'REACTOR_PLUGIN_PREFIX',
        'catch',
        'EADDRINUSE',
        'err',
        '11601WwZlQu',
        'unlinkSync',
        'timeZone',
        'existsSync',
        'server/lib/Structure',
        'bare-metal',
        'notice',
        'number',
        'en-US',
        'server/lib/util',
        './server/lib/Logger',
        '/opt/reactor/.reactor-docker',
        'LANGUAGE',
        'reactor-root-priv',
        'Local\x20date/time\x20using\x20configured\x20timezone\x20and\x20locale\x20formatting\x20is\x20%1',
        'Configured\x20locale\x20%1;\x20selected\x20locale(s)\x20%2',
        'toUpperCase',
        'config',
        'eol',
        'express',
        './server/lib/Configuration',
        '5684200AUTpGg',
        'writeReport'
    ];
    a0_0x28c0 = function () {
        return _0x245de7;
    };
    return a0_0x28c0();
}
if (opts['pidfile']) {
    opts['pidfile'] = path[a0_0x15f8c1(0x68)](c[a0_0x15f8c1(0xdc)], opts[a0_0x15f8c1(0xfb)]);
    try {
        fs[a0_0x15f8c1(0xb1)](opts[a0_0x15f8c1(0xfb)], String(process['pid']));
    } catch (a0_0x398d69) {
        console[a0_0x15f8c1(0x12c)](a0_0x15f8c1(0x137) + opts[a0_0x15f8c1(0xfb)] + ':\x20' + a0_0x398d69);
    }
}
make_dir(c[a0_0x15f8c1(0xdc)]), make_dir(c[a0_0x15f8c1(0x69)]), Configuration['getInstance'](a0_0x15f8c1(0x12f), path[a0_0x15f8c1(0xe9)](confdir, 'logging.yaml'));
const Logger = require(a0_0x15f8c1(0x95)), log = Logger['getLogger']('app'), sys_locale = process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x108)] || process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0xb4)] || process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0x97)];
log[a0_0x15f8c1(0x12e)](a0_0x15f8c1(0x132), BUILD_VERSION, process[a0_0x15f8c1(0x6e)], process[a0_0x15f8c1(0x101)]), log['always'](a0_0x15f8c1(0xf6), process[a0_0x15f8c1(0xa4)], process[a0_0x15f8c1(0x7d)] ? process[a0_0x15f8c1(0x7d)]() : '-', process[a0_0x15f8c1(0xed)] ? process[a0_0x15f8c1(0xed)]() : '-', is_docker ? a0_0x15f8c1(0x148) : a0_0x15f8c1(0x90), process['platform'], process[a0_0x15f8c1(0xc3)], os['version'](), sys_locale), log['always']('Basedir\x20%1;\x20data\x20in\x20%2', c['basedir'], c['datadir']), log[a0_0x15f8c1(0x12e)](a0_0x15f8c1(0x123), process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0xd0)]);
if ('' === (process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0xd0)] || '')) {
    log['crit'](a0_0x15f8c1(0xf1));
    throw new Error(a0_0x15f8c1(0xab));
} else {
    let paths = process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0xd0)][a0_0x15f8c1(0x115)](path[a0_0x15f8c1(0x149)]), found = ![];
    for (let p of paths) {
        if ('' !== p && fs[a0_0x15f8c1(0x8e)](path['join'](p, a0_0x15f8c1(0xc1)))) {
            log['debug'](0x5, a0_0x15f8c1(0x13b), p), found = !![];
            break;
        }
        log[a0_0x15f8c1(0xc9)](a0_0x15f8c1(0xd3));
    }
    if (!found) {
        log['crit'](a0_0x15f8c1(0x79), process[a0_0x15f8c1(0x6b)][a0_0x15f8c1(0xd0)]);
        throw new Error(a0_0x15f8c1(0x75));
    }
}
const hasICU = a0_0x15f8c1(0x6d) === typeof Intl;
try {
    const ICUTZ = hasICU ? Intl[a0_0x15f8c1(0x7f)]()[a0_0x15f8c1(0x85)]()[a0_0x15f8c1(0x8d)] : a0_0x15f8c1(0x64), now = new Date();
    log['always']('Resolved\x20timezone=%1,\x20environment\x20TZ=%2;\x20offset\x20minutes\x20from\x20UTC=%3', ICUTZ, process[a0_0x15f8c1(0x6b)]['TZ'], -now[a0_0x15f8c1(0x136)]());
} catch (a0_0x4af96e) {
    log['err'](a0_0x15f8c1(0xe4), a0_0x4af96e);
}
const i18n = require('server/lib/i18n');
let locale = c['locale'] || sys_locale || a0_0x15f8c1(0x74);
log[a0_0x15f8c1(0x12e)](a0_0x15f8c1(0x9a), c[a0_0x15f8c1(0xf3)], locale), locale = locale['split'](/ *, */);
let loaded = ![];
for (let l of locale) {
    let m = l[a0_0x15f8c1(0x115)](/\./);
    m[0x0] = (m[0x0] || '??')[a0_0x15f8c1(0x12b)]('_', '-'), m[0x1] = (m[0x1] || a0_0x15f8c1(0x100))[a0_0x15f8c1(0x9b)]();
    if (a0_0x15f8c1(0x100) !== m[0x1]) {
        log['err'](a0_0x15f8c1(0xf8) + l + a0_0x15f8c1(0xf9));
        continue;
    }
    try {
        log[a0_0x15f8c1(0x13d)](0x5, a0_0x15f8c1(0x7c), m[0x0]);
        if (i18n[a0_0x15f8c1(0xe6)](m[0x0], ![])) {
            log[a0_0x15f8c1(0x12e)]('Loaded\x20locale\x20%1\x20for\x20%2', i18n[a0_0x15f8c1(0x11e)](), m[0x0]), loaded = !![];
            break;
        }
    } catch (a0_0x258ab1) {
        log['notice'](a0_0x15f8c1(0x131), m[0x0], a0_0x258ab1);
    }
}
if (!loaded) {
    let m = locale[0x0][a0_0x15f8c1(0x115)](/\./);
    m[0x0] = (m[0x0] || '??')[a0_0x15f8c1(0x12b)]('_', '-'), m[0x1] = (m[0x1] || a0_0x15f8c1(0x100))[a0_0x15f8c1(0x9b)]();
    try {
        i18n['setLocale'](m[0x0], a0_0x15f8c1(0x93)) && (log[a0_0x15f8c1(0x12e)]('Loaded\x20locale\x20%1\x20for\x20%2', i18n['getLoadedLocale'](), m[0x0]), loaded = !![]);
    } catch (a0_0x228008) {
        log[a0_0x15f8c1(0x91)](a0_0x15f8c1(0x131), m[0x0], a0_0x228008);
    }
}
!loaded && (log['warn']('Loading\x20default\x20en-US\x20as\x20locale\x20and\x20translation\x20(fallback)'), i18n[a0_0x15f8c1(0xe6)](a0_0x15f8c1(0x93)));
log[a0_0x15f8c1(0x12e)](a0_0x15f8c1(0x99), new Date()['toLocaleString']());
if (is_docker) {
    try {
        const sp = path['resolve'](basedir, a0_0x15f8c1(0x13f)), tp = path['resolve'](process['env']['REACTOR_DATA_PREFIX'] || a0_0x15f8c1(0x6a), a0_0x15f8c1(0x13f));
        fs[a0_0x15f8c1(0x70)](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x4e1ccf) {
        log[a0_0x15f8c1(0x145)](a0_0x4e1ccf);
    }
    try {
        const sp = path[a0_0x15f8c1(0x68)](basedir, a0_0x15f8c1(0x113)), tp = path['resolve'](process['env'][a0_0x15f8c1(0x139)] || '/var/reactor', a0_0x15f8c1(0x113));
        fs[a0_0x15f8c1(0x70)](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x208139) {
        log[a0_0x15f8c1(0x145)](a0_0x208139);
    }
    try {
        const ll = fs[a0_0x15f8c1(0x13e)]('/proc/1/mountinfo')['toString'](a0_0x15f8c1(0xa9))[a0_0x15f8c1(0x115)](os[a0_0x15f8c1(0xfc)]), ee = ll[a0_0x15f8c1(0xfa)](_0x791325 => _0x791325[a0_0x15f8c1(0x127)](a0_0x15f8c1(0x6a)));
        ee ? log['info'](a0_0x15f8c1(0xaa), ee) : log[a0_0x15f8c1(0xc9)](a0_0x15f8c1(0x10d));
    } catch (a0_0x43ace9) {
        log[a0_0x15f8c1(0x145)](a0_0x43ace9);
    }
}
const app = express(), struct = require(a0_0x15f8c1(0x8f)), Engine = require('server/lib/Engine'), httpapi = require('server/lib/httpapi'), wsapi = require(a0_0x15f8c1(0xd9)), AlertManager = require(a0_0x15f8c1(0xf2));
process['on']('unhandledRejection', (_0x2b7592, _0x5e345b) => {
    const _0x41a9cb = a0_0x15f8c1;
    console['log']('Trapped\x20unhandled\x20Promise\x20rejection', _0x2b7592), console[_0x41a9cb(0x12c)](_0x2b7592), console[_0x41a9cb(0x12c)](_0x5e345b), console[_0x41a9cb(0x135)]();
    try {
        process[_0x41a9cb(0x130)][_0x41a9cb(0xa1)](path[_0x41a9cb(0x68)](c[_0x41a9cb(0x69)], _0x41a9cb(0xb9)), _0x2b7592), log[_0x41a9cb(0x12c)](_0x41a9cb(0x102), _0x2b7592), log['exception'](_0x2b7592), log[_0x41a9cb(0x12c)](_0x41a9cb(0x11c));
    } catch (_0x437201) {
    }
}), process['on'](a0_0x15f8c1(0xae), _0x18fc6d => {
    const _0x23461c = a0_0x15f8c1;
    console[_0x23461c(0x12c)](_0x23461c(0xe7), _0x18fc6d), console[_0x23461c(0x135)](_0x18fc6d);
    try {
        process[_0x23461c(0x130)][_0x23461c(0xa1)](path['resolve'](c[_0x23461c(0x69)], 'unhandled.json'), _0x18fc6d), log['error'](_0x23461c(0xe2), _0x18fc6d), log[_0x23461c(0x12c)]('Please\x20refer\x20to\x20the\x20console\x20log\x20for\x20trace');
    } catch (_0x4b84d9) {
    }
    _0x23461c(0x89) === _0x18fc6d['code'] && setTimeout(function () {
        const _0xa36305 = _0x23461c;
        process[_0xa36305(0xc7)](0x1);
    }, 0xfa);
}), log['notice'](a0_0x15f8c1(0x81)), struct[a0_0x15f8c1(0x7b)](c['basedir'])[a0_0x15f8c1(0xf4)](async () => {
    const _0x12ea5b = a0_0x15f8c1, _0x1dd511 = Engine[_0x12ea5b(0x126)]();
    try {
        const _0x40585a = parseInt(process['versions'][_0x12ea5b(0xe1)]['split']('.')[0x0]);
        let _0x4be2b1 = !![];
        if (!isNaN(_0x40585a)) {
            const _0x514348 = NODE_VERSIONS[_0x40585a];
            if (c?.[_0x12ea5b(0xcc)] && c[_0x12ea5b(0xcc)] == _0x40585a)
                log[_0x12ea5b(0x13d)](0x5, 'nodejs\x20major\x20version\x20%1\x20accepted\x20(by\x20configuration\x20exception)', _0x40585a);
            else {
                if (_0x514348) {
                    log[_0x12ea5b(0x122)](_0x12ea5b(0xde), _0x40585a, new Date(_0x514348[_0x12ea5b(0x9d)])[_0x12ea5b(0x82)]());
                    const _0x1a6219 = _0x514348['eol'] - NODE_EOL_WARNING * 0x5265c00;
                    if (Date[_0x12ea5b(0xbf)]() >= _0x514348[_0x12ea5b(0x9d)])
                        AlertManager[_0x12ea5b(0x128)](AlertManager['WARN'], _0x12ea5b(0xce), { 'tag': 'nodejs-version' }, process[_0x12ea5b(0xf5)][_0x12ea5b(0xe1)]), _0x4be2b1 = ![];
                    else
                        Date[_0x12ea5b(0xbf)]() >= _0x1a6219 && (AlertManager[_0x12ea5b(0x128)](AlertManager['NOTICE'], '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.', { 'tag': _0x12ea5b(0x121) }, process[_0x12ea5b(0xf5)][_0x12ea5b(0xe1)]), _0x4be2b1 = ![]);
                } else
                    AlertManager[_0x12ea5b(0x128)](AlertManager[_0x12ea5b(0xcb)], _0x12ea5b(0xbd), { 'tag': _0x12ea5b(0x121) }, process[_0x12ea5b(0xf5)]['node']), _0x4be2b1 = ![];
            }
        }
        _0x4be2b1 && AlertManager[_0x12ea5b(0xc4)](_0x12ea5b(0x121)), process[_0x12ea5b(0x7d)] && 0x0 === process[_0x12ea5b(0x7d)]() && !is_docker ? AlertManager[_0x12ea5b(0x128)](AlertManager[_0x12ea5b(0xcb)], _0x12ea5b(0x76), { 'tag': _0x12ea5b(0x98) }) : AlertManager[_0x12ea5b(0xc4)](_0x12ea5b(0x98));
    } catch (_0x3881de) {
        log[_0x12ea5b(0x145)](_0x3881de);
    }
    !valid_config ? AlertManager[_0x12ea5b(0x128)](AlertManager['ERROR'], _0x12ea5b(0xba), { 'tag': 'sysconfig-invalid' }, rcf) : AlertManager[_0x12ea5b(0xc4)](_0x12ea5b(0xbb));
    if (!![] === Configuration[_0x12ea5b(0xd5)](_0x12ea5b(0x125), _0x12ea5b(0x10a), ![])) {
        log[_0x12ea5b(0x91)](_0x12ea5b(0xb6));
        const _0x16e7c3 = Date[_0x12ea5b(0xbf)]();
        let _0x3038a0 = await struct[_0x12ea5b(0x106)](Configuration['getConfig'](_0x12ea5b(0xb3), 'number', 0xea60));
        log[_0x12ea5b(0x122)]('Startup\x20was\x20delayed\x20%1ms', Date[_0x12ea5b(0xbf)]() - _0x16e7c3);
        let _0x26e6bd = 0x0;
        for (let _0x1ac42a of _0x3038a0) {
            !_0x1ac42a[_0x12ea5b(0xc0)] && (log[_0x12ea5b(0x91)]('Controller\x20%1\x20failed\x20to\x20start:\x20%2', _0x1ac42a['id'], _0x1ac42a[_0x12ea5b(0x140)]), ++_0x26e6bd);
        }
        0x0 === _0x26e6bd && log[_0x12ea5b(0x91)](_0x12ea5b(0x124), _0x3038a0['length']);
    }
    var _0xbbb216 = ![], _0x4bda15 = async function (_0x7df2d6) {
            const _0x3e6efc = _0x12ea5b;
            if (_0xbbb216)
                return;
            _0xbbb216 = !![], log[_0x3e6efc(0x12e)](_0x3e6efc(0xb2), _0x7df2d6);
            try {
                log[_0x3e6efc(0x91)](_0x3e6efc(0xf0)), await _0x1dd511[_0x3e6efc(0x86)]();
            } catch (_0x5635e0) {
                log['exception'](_0x5635e0);
            }
            try {
                log[_0x3e6efc(0x91)](_0x3e6efc(0x13c)), await struct[_0x3e6efc(0x86)]();
            } catch (_0x4f1915) {
                log[_0x3e6efc(0x145)](_0x4f1915), console[_0x3e6efc(0x12c)](_0x4f1915);
            }
            try {
                log[_0x3e6efc(0x91)](_0x3e6efc(0xac)), await wsapi[_0x3e6efc(0x86)](), await httpapi[_0x3e6efc(0x86)]();
            } catch (_0x57ec57) {
                log[_0x3e6efc(0x145)](_0x57ec57), console[_0x3e6efc(0x12c)](_0x57ec57);
            }
            try {
                log['notice'](_0x3e6efc(0x78));
                let _0x34b3cf = require(_0x3e6efc(0x10c));
                _0x34b3cf[_0x3e6efc(0x86)]();
            } catch (_0x1d0f17) {
                log['exception'](_0x1d0f17), console[_0x3e6efc(0x12c)](_0x1d0f17);
            }
            log[_0x3e6efc(0x12e)]('Shutdown\x20complete,\x20process\x20ID\x20%1', process[_0x3e6efc(0xa4)]);
            try {
                log[_0x3e6efc(0x12e)](_0x3e6efc(0x73)), await Logger[_0x3e6efc(0xc2)](), console[_0x3e6efc(0x129)](_0x3e6efc(0xb0));
            } catch (_0x561689) {
                console['error']('Shutting\x20down\x20logs:', _0x561689);
            }
            try {
                opts['pidfile'] && fs[_0x3e6efc(0x8c)](opts[_0x3e6efc(0xfb)]);
            } catch (_0x203a82) {
                console[_0x3e6efc(0x12c)](_0x203a82);
            }
            setTimeout(() => {
                const _0x13ba4a = _0x3e6efc;
                console[_0x13ba4a(0x12c)](_0x13ba4a(0xfe)), process[_0x13ba4a(0xc7)](_0x13ba4a(0xe5) === _0x7df2d6 ? 0x1 : 0x7f);
            }, 0x7d0), process[_0x3e6efc(0xc7)](_0x3e6efc(0xe5) === _0x7df2d6 ? 0x1 : 0x7f);
        };
    process['on'](_0x12ea5b(0x133), _0x4bda15), process['on'](_0x12ea5b(0x138), _0x4bda15), process['on'](_0x12ea5b(0xe5), _0x4bda15), process['on']('SIGHUP', _0x4bda15), process['on']('message', _0x388696 => {
        const _0x211a5a = _0x12ea5b;
        log[_0x211a5a(0x13d)](0x5, _0x211a5a(0x118), _0x388696);
        if (_0x211a5a(0xc2) === _0x388696)
            log[_0x211a5a(0x91)](_0x211a5a(0x7e)), _0x4bda15(_0x211a5a(0x133));
        else
            _0x211a5a(0x143) === _0x388696 && (log['notice'](_0x211a5a(0xdb)), _0x4bda15(_0x211a5a(0xe5)));
    }), process['on'](_0x12ea5b(0xc7), function () {
        const _0x439805 = _0x12ea5b;
        console['log'](_0x439805(0xa2));
    }), log[_0x12ea5b(0x91)](_0x12ea5b(0x6c)), httpapi['start'](app, c['basedir'])[_0x12ea5b(0xf4)](_0x4fe432 => {
        const _0x27f678 = _0x12ea5b;
        if (Configuration[_0x27f678(0xd5)](_0x27f678(0x110), _0x27f678(0x10a), ![])) {
            const _0x52a014 = require(_0x27f678(0x77));
            log[_0x27f678(0x91)]('HTTP\x20server\x20running;\x20registering\x20proxy\x20endpoints.'), _0x52a014[_0x27f678(0x7b)](app);
        }
        log['notice']('Starting\x20WSAPI...'), wsapi['start'](app, _0x4fe432)['then'](async () => {
            const _0x271446 = _0x27f678;
            wsapi[_0x271446(0xe8)]();
        });
    })['catch'](_0x2de39e => {
        const _0x2150ca = _0x12ea5b;
        log[_0x2150ca(0x8a)](_0x2150ca(0xe3), _0x2de39e), _0x2150ca(0x89) === _0x2de39e[_0x2150ca(0xbc)] && (log['err'](_0x2150ca(0xfd)), process[_0x2150ca(0xc8)](process[_0x2150ca(0xa4)], _0x2150ca(0xe5)));
    });
    if (opts['noengine'] || ![] === Configuration[_0x12ea5b(0xd5)]('reactor.engine.enabled', _0x12ea5b(0x10a), !![])) {
        const _0x4958c0 = require(_0x12ea5b(0x134));
        log[_0x12ea5b(0xd8)](_0x12ea5b(0xef)), AlertManager['addAlert'](AlertManager[_0x12ea5b(0x11d)], _0x4958c0['_T'](_0x12ea5b(0xdd)), { 'tag': 'engine-disabled' });
    } else {
        let _0x2f5948 = Configuration['getConfig'](_0x12ea5b(0xb8), _0x12ea5b(0x92), 0x0);
        if (_0x2f5948 > 0x0) {
            const _0x1042b4 = require(_0x12ea5b(0x94));
            await _0x1042b4[_0x12ea5b(0x120)](() => {
                const _0x139fdb = _0x12ea5b;
                log['always'](_0x139fdb(0xda), _0x2f5948 / 0x3e8);
            }, _0x2f5948)[_0x12ea5b(0x88)](_0x530dda => {
            });
        }
        log[_0x12ea5b(0x91)](_0x12ea5b(0xa6)), struct[_0x12ea5b(0xaf)](_0x1dd511);
        try {
            _0x1dd511[_0x12ea5b(0x7b)](), AlertManager[_0x12ea5b(0xc4)](_0x12ea5b(0x11f));
        } catch (_0x4ed22c) {
            log['err'](_0x12ea5b(0x13a), _0x4ed22c), log[_0x12ea5b(0x145)](_0x4ed22c);
        }
    }
});
if (opts['repl']) {
    let r = repl['start']('>\x20'), ctx = r[a0_0x15f8c1(0xec)];
    ctx[a0_0x15f8c1(0xe0)] = struct, ctx[a0_0x15f8c1(0x83)] = Engine['getInstance'](struct), r['on'](a0_0x15f8c1(0xc7), () => {
        const _0x24c1b8 = a0_0x15f8c1;
        Engine[_0x24c1b8(0x126)](struct)[_0x24c1b8(0x86)](), struct['stop'](), process[_0x24c1b8(0xc7)](0x1);
    });
}