#!/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_0x4a7cf6 = a0_0x1413;
(function (_0x1c509d, _0xb4a2a1) {
    const _0x42b6d7 = a0_0x1413, _0x3f7930 = _0x1c509d();
    while (!![]) {
        try {
            const _0x41a6d4 = -parseInt(_0x42b6d7(0x194)) / 0x1 * (parseInt(_0x42b6d7(0x1e0)) / 0x2) + parseInt(_0x42b6d7(0x1bb)) / 0x3 + -parseInt(_0x42b6d7(0x1c5)) / 0x4 + -parseInt(_0x42b6d7(0x148)) / 0x5 + -parseInt(_0x42b6d7(0x17e)) / 0x6 + -parseInt(_0x42b6d7(0x1b0)) / 0x7 + parseInt(_0x42b6d7(0x137)) / 0x8 * (parseInt(_0x42b6d7(0x1f4)) / 0x9);
            if (_0x41a6d4 === _0xb4a2a1)
                break;
            else
                _0x3f7930['push'](_0x3f7930['shift']());
        } catch (_0x2e6d18) {
            _0x3f7930['push'](_0x3f7930['shift']());
        }
    }
}(a0_0x1416, 0x36de0));
function a0_0x1416() {
    const _0x422215 = [
        'Failed\x20to\x20write\x20',
        'getLoadedLocale',
        'is_windows',
        'now',
        'reactor',
        '1123332jeaiIV',
        'delimiter',
        'reactor.engine.startup_delay',
        'locale',
        'unlinkSync',
        '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.',
        'Closing\x20APIs...',
        'getgid',
        'versions',
        'catch',
        'unhandled.json',
        '1075866HCrOBt',
        'server/lib/i18n',
        'readFileSync',
        'resolve',
        'server/wsapi/wsapi',
        'Loaded\x20locale\x20%1\x20for\x20%2',
        'accept_nodejs_version',
        'stop',
        'UTF-8',
        'Unsupported\x20nodejs\x20version\x20',
        '1731816pTuSFq',
        'number',
        'Waiting\x20for\x20controllers\x20to\x20start\x20up...',
        'shift',
        'Shutdown\x20complete,\x20process\x20ID\x20%1',
        'WARN',
        'pidfile',
        'waitAllControllers',
        'logsdir',
        'cpSync',
        'notifyStartup',
        'exception',
        'experimental_check_uidgid',
        'ext',
        'length',
        'toLocaleString',
        'reactor.engine.enabled',
        'REACTOR_PLUGIN_PREFIX',
        'Shutdown\x20signal\x20(%1)\x20received.\x20Stopping\x20Reaction\x20Engine...',
        'Failed\x20to\x20set\x20the\x20GID\x20of\x20the\x20Reactor\x20process:\x20',
        'notice',
        'dist-config',
        'context',
        'SIGHUP',
        'Shutting\x20down\x20logs:',
        'toString',
        'Shutdown\x20message\x20received\x20(handling\x20as\x20SIGINT)',
        '4JchYTn',
        'Reload\x20message\x20received\x20(handling\x20as\x20SIGQUIT)',
        'attempting\x20load\x20of\x20locale\x20%1',
        'toUpperCase',
        'setuid',
        'Local\x20date/time\x20using\x20configured\x20timezone\x20and\x20locale\x20formatting\x20is\x20%1',
        'LANGUAGE',
        '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.',
        'Starting\x20Reaction\x20Engine...',
        'storage',
        'unhandledRejection',
        'boolean',
        'LANG',
        'getConfig',
        'report',
        'Controller\x20%1\x20failed\x20to\x20start:\x20%2',
        'noengine',
        'All\x20logs\x20closed',
        'reactor.engine.wait_all_controllers',
        'received\x20message:\x20%1',
        '9uLbxEl',
        'node',
        'always',
        'engine',
        'opterr',
        'copyFileSync',
        'writeReport',
        'Failed\x20to\x20start\x20HTTP\x20API:\x20%1',
        '/opt/reactor/.reactor-docker',
        'crit',
        'Invalid\x20volume\x20configuration',
        'EOL',
        'getTimezoneOffset',
        'sysconfig-invalid',
        'addAlert',
        'gid',
        'warn',
        'existsSync',
        'getLogger',
        'docker',
        'forEach',
        'config',
        'A\x20default\x20(empty)\x20configuration\x20with\x20the\x20Engine\x20disabled\x20will\x20be\x20used.',
        'platform',
        'reactor-root-priv',
        '10936616rJHniR',
        'Environment\x20NODE_PATH\x20does\x20not\x20include\x20the\x20Reactor\x20install\x20directory',
        'REACTOR_LOG_PREFIX',
        'writeFileSync',
        'split',
        'server/lib/Engine',
        'Closing\x20Structure...',
        'plugindir',
        '\x20cannot\x20be\x20used;\x20encodings\x20other\x20than\x20UTF-8\x20are\x20not\x20supported',
        'slice',
        'log',
        'Trapped\x20unhandled\x20Promise\x20rejection:\x20%1',
        'FORCED\x20EXIT',
        'REACTOR_HOME',
        'Container\x20mount\x20for\x20/var/reactor:\x20%1',
        'server/lib/httpapi',
        'en-US',
        '2082145NjIrEI',
        'Detected\x20nodejs',
        'err',
        'en-US.UTF-8',
        'env',
        'logging',
        './server/lib/TimerBroker.js',
        'shutdown',
        'message',
        'localesdir',
        'setLocale',
        'code',
        'Reactor',
        'then',
        'reload',
        'tools',
        'SIGQUIT',
        'REACTOR_CONFIG_PREFIX',
        'status',
        'readdirSync',
        'NODE_PATH\x20does\x20not\x20seem\x20to\x20include\x20Reactor\x20install\x20directory\x20as\x20first\x20element:\x20%1',
        'engine-disabled',
        'setgid',
        'pid',
        'version',
        'uid',
        'Process\x20ID\x20%1\x20user/group\x20%2/%3;\x20%4;\x20platform\x20%5/%6\x20%7;\x20locale\x20%8',
        'execPath',
        'server/lib/Structure',
        'debug',
        'reactor.http_proxy_enabled',
        'kill',
        'win32',
        'Please\x20refer\x20to\x20the\x20console\x20log\x20for\x20trace',
        './dist-config',
        'utf-8',
        'Required\x20environment\x20variable\x20NODE_PATH\x20is\x20not\x20set',
        '(not\x20supported)',
        'subscribe',
        'Failed\x20to\x20start\x20engine:\x20%1',
        'arch',
        'basedir',
        'getInstance',
        'suppress_docker_volume_check',
        'error',
        'trace',
        'Basedir\x20%1;\x20data\x20in\x20%2',
        '(no\x20ICU)',
        'Trapped\x20unhandled\x20exception:\x20%1',
        'Configuration\x20file\x20',
        'DateTimeFormat',
        '/var/reactor',
        'confdir',
        'Configured\x20locale\x20%1;\x20selected\x20locale(s)\x20%2',
        '2350800nroHAq',
        'nodejs-version',
        'Engine\x20startup\x20suppressed;\x20no\x20rules\x20will\x20be\x20processed.',
        'uncaughtException',
        'join',
        'cwd',
        'dismissTag',
        'Invalid\x20command\x20line\x20argument:',
        'logging.yaml',
        'SIGINT',
        'exit',
        'Exiting...',
        'TimedPromise',
        'timeZone',
        'NODE_PATH',
        'HTTP\x20server\x20running;\x20registering\x20proxy\x20endpoints.',
        'The\x20engine\x20has\x20been\x20disabled\x20and\x20is\x20not\x20running\x20(rules\x20are\x20not\x20being\x20processed).',
        'ERROR',
        'app',
        'repl',
        'REACTOR_STORAGE_PREFIX',
        './server/lib/httpproxy',
        '49652YVZcqX',
        './server/lib/Logger',
        '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.',
        'Closing\x20logs...',
        'struct',
        'getuid',
        'Failed\x20to\x20set\x20the\x20UID\x20of\x20the\x20Reactor\x20process:\x20',
        'The\x20Reactor\x20configuration\x20in\x20{0:q}\x20could\x20not\x20be\x20read;\x20the\x20system\x20has\x20started\x20with\x20an\x20empty\x20configuration.',
        'object',
        'datadir',
        'bare-metal',
        'info',
        'app:\x20NODE_PATH\x20component\x20%1\x20seems\x20to\x20be\x20Reactor\x20install\x20dir',
        'eol',
        'EADDRINUSE',
        'REACTOR_DATA_PREFIX',
        'Waiting\x20%1\x20seconds\x20before\x20continuing\x20(startup\x20delay)',
        'Loading\x20default\x20en-US\x20as\x20locale\x20and\x20translation\x20(fallback)',
        'reactor.pid',
        'toLocaleDateString',
        'start',
        'configuration\x20from',
        'Warning:\x20NODE_PATH\x20does\x20not\x20have\x20Reactor\x20directory\x20as\x20first\x20element!'
    ];
    a0_0x1416 = function () {
        return _0x422215;
    };
    return a0_0x1416();
}
const version = 0x6604, BUILD_VERSION = 'latest-26116-7f34907a', 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[a0_0x4a7cf6(0x1b8)][a0_0x4a7cf6(0x1f5)][a0_0x4a7cf6(0x13b)]('.')[0x0]) < MIN_NODE_MAJOR) {
    console[a0_0x4a7cf6(0x174)](a0_0x4a7cf6(0x149), process[a0_0x4a7cf6(0x1b8)][a0_0x4a7cf6(0x1f5)], a0_0x4a7cf6(0x16d));
    throw new Error(a0_0x4a7cf6(0x1c4) + process[a0_0x4a7cf6(0x1b8)][a0_0x4a7cf6(0x1f5)]);
}
const path = require('path'), os = require('os'), fs = require('fs');
function make_dir(_0x4a80b7) {
    const _0x49bf54 = a0_0x4a7cf6;
    if (!fs[_0x49bf54(0x205)](_0x4a80b7))
        return fs['mkdirSync'](_0x4a80b7), !![];
    return ![];
}
function checkConfigDir(_0x4e5c3c, _0x32eb49) {
    const _0xd58bed = a0_0x4a7cf6;
    make_dir(_0x4e5c3c) && fs[_0xd58bed(0x15b)](_0x32eb49)[_0xd58bed(0x208)](_0x4c3926 => {
        const _0x575e99 = _0xd58bed;
        if (_0x4c3926['match'](/\.(yaml|yml|json)(-dist)?$/i)) {
            const _0x4eccd9 = path[_0x575e99(0x1be)](_0x4e5c3c, _0x4c3926);
            if (!fs[_0x575e99(0x205)](_0x4eccd9))
                try {
                    fs[_0x575e99(0x1f9)](path['resolve'](_0x32eb49, _0x4c3926), _0x4eccd9);
                } catch (_0xea9744) {
                    console[_0x575e99(0x141)](_0xea9744);
                }
        }
    });
}
let opts = {
        'noengine': ![],
        'repl': ![],
        'pidfile': ![],
        'basedir': process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x144)] || process[a0_0x4a7cf6(0x183)](),
        'opterr': ![]
    }, argv = process['argv'][a0_0x4a7cf6(0x140)](0x2);
while (argv[a0_0x4a7cf6(0x1d3)] > 0x0) {
    let arg = argv[a0_0x4a7cf6(0x1c8)]();
    switch (arg) {
    case '-R':
        opts[a0_0x4a7cf6(0x191)] = !![];
        break;
    case '-N':
        opts[a0_0x4a7cf6(0x1f0)] = !![];
        break;
    case '-d':
        opts[a0_0x4a7cf6(0x171)] = argv[a0_0x4a7cf6(0x1c8)]() || opts[a0_0x4a7cf6(0x171)];
        break;
    case '-c':
        opts[a0_0x4a7cf6(0x17c)] = argv[a0_0x4a7cf6(0x1c8)]() || opts[a0_0x4a7cf6(0x17c)];
        break;
    case '-p':
        opts[a0_0x4a7cf6(0x1cb)] = argv['shift']() || a0_0x4a7cf6(0x1a6);
        break;
    default:
        opts[a0_0x4a7cf6(0x1f8)] = !![], console[a0_0x4a7cf6(0x141)](a0_0x4a7cf6(0x185), arg);
    }
}
opts[a0_0x4a7cf6(0x1f8)] && process[a0_0x4a7cf6(0x188)](0xff);
const express = require('express'), repl = require(a0_0x4a7cf6(0x191)), basedir = path[a0_0x4a7cf6(0x1be)](opts['basedir'] || process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x144)] || __dirname), confdir = opts['confdir'] ? path[a0_0x4a7cf6(0x1be)](opts[a0_0x4a7cf6(0x17c)]) : path['resolve'](process[a0_0x4a7cf6(0x14c)]['REACTOR_CONFIG_PREFIX'] ? process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x159)] : process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x1a3)] ? path[a0_0x4a7cf6(0x1be)](process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x1a3)], a0_0x4a7cf6(0x209)) : path[a0_0x4a7cf6(0x182)](basedir, a0_0x4a7cf6(0x209)));
function a0_0x1413(_0x45123c, _0x453fd5) {
    _0x45123c = _0x45123c - 0x135;
    const _0x141632 = a0_0x1416();
    let _0x1413f4 = _0x141632[_0x45123c];
    return _0x1413f4;
}
console[a0_0x4a7cf6(0x141)](a0_0x4a7cf6(0x154), BUILD_VERSION, a0_0x4a7cf6(0x190), version, a0_0x4a7cf6(0x1a9), confdir), checkConfigDir(confdir, path['join'](basedir, a0_0x4a7cf6(0x16a)));
const Configuration = require('./server/lib/Configuration'), rcf = path['resolve'](confdir, 'reactor.yaml');
let valid_config = ![], c;
try {
    c = Configuration[a0_0x4a7cf6(0x172)](a0_0x4a7cf6(0x1af), rcf)[a0_0x4a7cf6(0x1ed)]('reactor', a0_0x4a7cf6(0x19c));
    if (!c)
        throw new Error(a0_0x4a7cf6(0x179) + rcf + '\x20unreadable\x20or\x20empty');
    valid_config = !![];
} catch (a0_0x44ebe5) {
    console[a0_0x4a7cf6(0x174)]('Unable\x20to\x20load\x20configuration\x20from', rcf, ':', a0_0x44ebe5), console[a0_0x4a7cf6(0x141)](a0_0x4a7cf6(0x20a)), c = Configuration[a0_0x4a7cf6(0x172)](a0_0x4a7cf6(0x1af), { 'reactor': { 'engine': { 'enabled': ![] } } })['getConfig'](a0_0x4a7cf6(0x1af), a0_0x4a7cf6(0x19c));
}
c[a0_0x4a7cf6(0x171)] = basedir, c[a0_0x4a7cf6(0x17c)] = confdir, c[a0_0x4a7cf6(0x19d)] = c[a0_0x4a7cf6(0x19d)] || path[a0_0x4a7cf6(0x1be)](process['env'][a0_0x4a7cf6(0x192)] ? process['env'][a0_0x4a7cf6(0x192)] : path[a0_0x4a7cf6(0x1be)](process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x1a3)] || basedir, a0_0x4a7cf6(0x1e9))), c[a0_0x4a7cf6(0x1cd)] = c[a0_0x4a7cf6(0x1cd)] || path[a0_0x4a7cf6(0x1be)](process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x139)] ? process['env'][a0_0x4a7cf6(0x139)] : path[a0_0x4a7cf6(0x1be)](process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x1a3)] || basedir, 'logs')), c['plugindir'] = c[a0_0x4a7cf6(0x13e)] || path[a0_0x4a7cf6(0x1be)](process[a0_0x4a7cf6(0x14c)]['REACTOR_PLUGIN_PREFIX'] ? process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x1d6)] : path[a0_0x4a7cf6(0x1be)](process['env'][a0_0x4a7cf6(0x1a3)] || basedir, a0_0x4a7cf6(0x1d2))), c[a0_0x4a7cf6(0x151)] = c[a0_0x4a7cf6(0x151)] || path[a0_0x4a7cf6(0x1be)](process[a0_0x4a7cf6(0x14c)]['REACTOR_PLUGIN_PREFIX'] ? process[a0_0x4a7cf6(0x14c)]['REACTOR_PLUGIN_PREFIX'] : path[a0_0x4a7cf6(0x1be)](process[a0_0x4a7cf6(0x14c)]['REACTOR_DATA_PREFIX'] || basedir, 'locales')), console['log']('NODE_PATH', process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x18c)]);
const is_docker = fs['existsSync'](a0_0x4a7cf6(0x1fc));
c['is_docker'] = is_docker, c[a0_0x4a7cf6(0x1ad)] = a0_0x4a7cf6(0x168) === process['platform'];
if (is_docker && fs[a0_0x4a7cf6(0x205)]('/var/reactor/.docker-image-volume') && !![] !== c[a0_0x4a7cf6(0x173)]) {
    console['error']('The\x20data\x20volume\x20has\x20not\x20been\x20correctly\x20configured\x20and\x20mounted.\x20Stopping\x20container.\x20Please\x20refer\x20to\x20the\x20installation\x20instructions\x20for\x20your\x20docker\x20image.');
    throw new Error(a0_0x4a7cf6(0x1fe));
}
opts[a0_0x4a7cf6(0x1f0)] = opts[a0_0x4a7cf6(0x1f0)] || fs[a0_0x4a7cf6(0x205)](path[a0_0x4a7cf6(0x1be)](confdir, 'noengine'));
if (c[a0_0x4a7cf6(0x1d1)]) {
    if (c[a0_0x4a7cf6(0x203)] && process[a0_0x4a7cf6(0x1b7)]() !== c[a0_0x4a7cf6(0x203)])
        try {
            process[a0_0x4a7cf6(0x15e)](c[a0_0x4a7cf6(0x203)]);
        } catch (a0_0x2a93b8) {
            console[a0_0x4a7cf6(0x174)](a0_0x4a7cf6(0x1d8) + a0_0x2a93b8);
        }
    if (c[a0_0x4a7cf6(0x161)] && process[a0_0x4a7cf6(0x199)]() !== c['uid'])
        try {
            process[a0_0x4a7cf6(0x1e4)](c['uid']);
        } catch (a0_0x4fc2a5) {
            console['error'](a0_0x4a7cf6(0x19a) + a0_0x4fc2a5);
            throw a0_0x4fc2a5;
        }
}
if (opts[a0_0x4a7cf6(0x1cb)]) {
    opts[a0_0x4a7cf6(0x1cb)] = path[a0_0x4a7cf6(0x1be)](c[a0_0x4a7cf6(0x19d)], opts[a0_0x4a7cf6(0x1cb)]);
    try {
        fs[a0_0x4a7cf6(0x13a)](opts[a0_0x4a7cf6(0x1cb)], String(process[a0_0x4a7cf6(0x15f)]));
    } catch (a0_0x27a627) {
        console[a0_0x4a7cf6(0x174)](a0_0x4a7cf6(0x1ab) + opts[a0_0x4a7cf6(0x1cb)] + ':\x20' + a0_0x27a627);
    }
}
make_dir(c[a0_0x4a7cf6(0x19d)]), make_dir(c[a0_0x4a7cf6(0x1cd)]), Configuration[a0_0x4a7cf6(0x172)](a0_0x4a7cf6(0x14d), path[a0_0x4a7cf6(0x182)](confdir, a0_0x4a7cf6(0x186)));
const Logger = require(a0_0x4a7cf6(0x195)), log = Logger[a0_0x4a7cf6(0x206)]('app'), sys_locale = process[a0_0x4a7cf6(0x14c)]['LC_ALL'] || process['env'][a0_0x4a7cf6(0x1ec)] || process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x1e6)];
log[a0_0x4a7cf6(0x1f6)]('Reactor\x20build\x20%1\x20starting\x20on\x20%2\x20%3', BUILD_VERSION, process[a0_0x4a7cf6(0x160)], process[a0_0x4a7cf6(0x163)]), log['always'](a0_0x4a7cf6(0x162), process[a0_0x4a7cf6(0x15f)], process['getuid'] ? process[a0_0x4a7cf6(0x199)]() : '-', process[a0_0x4a7cf6(0x1b7)] ? process[a0_0x4a7cf6(0x1b7)]() : '-', is_docker ? a0_0x4a7cf6(0x207) : a0_0x4a7cf6(0x19e), process[a0_0x4a7cf6(0x135)], process[a0_0x4a7cf6(0x170)], os[a0_0x4a7cf6(0x160)](), sys_locale), log['always'](a0_0x4a7cf6(0x176), c[a0_0x4a7cf6(0x171)], c[a0_0x4a7cf6(0x19d)]), log['always']('NODE_PATH=%1', process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x18c)]);
if ('' === (process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x18c)] || '')) {
    log[a0_0x4a7cf6(0x1fd)]('NODE_PATH\x20required\x20environment\x20variable\x20is\x20not\x20set;\x20can\x27t\x20continue');
    throw new Error(a0_0x4a7cf6(0x16c));
} else {
    let paths = process[a0_0x4a7cf6(0x14c)]['NODE_PATH'][a0_0x4a7cf6(0x13b)](path[a0_0x4a7cf6(0x1b1)]), found = ![];
    for (let p of paths) {
        if ('' !== p && fs[a0_0x4a7cf6(0x205)](path['join'](p, 'server/lib/Logger.js'))) {
            log[a0_0x4a7cf6(0x165)](0x5, a0_0x4a7cf6(0x1a0), p), found = !![];
            break;
        }
        log[a0_0x4a7cf6(0x204)](a0_0x4a7cf6(0x1aa));
    }
    if (!found) {
        log[a0_0x4a7cf6(0x1fd)](a0_0x4a7cf6(0x15c), process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x18c)]);
        throw new Error(a0_0x4a7cf6(0x138));
    }
}
const hasICU = a0_0x4a7cf6(0x19c) === typeof Intl;
try {
    const ICUTZ = hasICU ? Intl[a0_0x4a7cf6(0x17a)]()['resolvedOptions']()[a0_0x4a7cf6(0x18b)] : a0_0x4a7cf6(0x177), now = new Date();
    log['always']('Resolved\x20timezone=%1,\x20environment\x20TZ=%2;\x20offset\x20minutes\x20from\x20UTC=%3', ICUTZ, process[a0_0x4a7cf6(0x14c)]['TZ'], -now[a0_0x4a7cf6(0x200)]());
} catch (a0_0x3a5811) {
    log[a0_0x4a7cf6(0x14a)]('app:\x20can\x27t\x20get\x20locale\x20timezone:\x20%1', a0_0x3a5811);
}
const i18n = require(a0_0x4a7cf6(0x1bc));
let locale = c[a0_0x4a7cf6(0x1b3)] || sys_locale || a0_0x4a7cf6(0x14b);
log['always'](a0_0x4a7cf6(0x17d), c[a0_0x4a7cf6(0x1b3)], locale), locale = locale['split'](/ *, */);
let loaded = ![];
for (let l of locale) {
    let m = l[a0_0x4a7cf6(0x13b)](/\./);
    m[0x0] = (m[0x0] || '??')['replace']('_', '-'), m[0x1] = (m[0x1] || a0_0x4a7cf6(0x1c3))['toUpperCase']();
    if (a0_0x4a7cf6(0x1c3) !== m[0x1]) {
        log[a0_0x4a7cf6(0x14a)]('Locale\x20' + l + a0_0x4a7cf6(0x13f));
        continue;
    }
    try {
        log[a0_0x4a7cf6(0x165)](0x5, a0_0x4a7cf6(0x1e2), m[0x0]);
        if (i18n[a0_0x4a7cf6(0x152)](m[0x0], ![])) {
            log[a0_0x4a7cf6(0x1f6)](a0_0x4a7cf6(0x1c0), i18n[a0_0x4a7cf6(0x1ac)](), m[0x0]), loaded = !![];
            break;
        }
    } catch (a0_0x696603) {
        log['notice']('Failed\x20to\x20load\x20locale\x20%1:\x20%2', m[0x0], a0_0x696603);
    }
}
if (!loaded) {
    let m = locale[0x0][a0_0x4a7cf6(0x13b)](/\./);
    m[0x0] = (m[0x0] || '??')['replace']('_', '-'), m[0x1] = (m[0x1] || a0_0x4a7cf6(0x1c3))[a0_0x4a7cf6(0x1e3)]();
    try {
        i18n[a0_0x4a7cf6(0x152)](m[0x0], 'en-US') && (log[a0_0x4a7cf6(0x1f6)](a0_0x4a7cf6(0x1c0), i18n['getLoadedLocale'](), m[0x0]), loaded = !![]);
    } catch (a0_0x56a072) {
        log[a0_0x4a7cf6(0x1d9)]('Failed\x20to\x20load\x20locale\x20%1:\x20%2', m[0x0], a0_0x56a072);
    }
}
!loaded && (log[a0_0x4a7cf6(0x204)](a0_0x4a7cf6(0x1a5)), i18n[a0_0x4a7cf6(0x152)](a0_0x4a7cf6(0x147)));
log[a0_0x4a7cf6(0x1f6)](a0_0x4a7cf6(0x1e5), new Date()[a0_0x4a7cf6(0x1d4)]());
if (is_docker) {
    try {
        const sp = path[a0_0x4a7cf6(0x1be)](basedir, a0_0x4a7cf6(0x1da)), tp = path[a0_0x4a7cf6(0x1be)](process[a0_0x4a7cf6(0x14c)][a0_0x4a7cf6(0x1a3)] || a0_0x4a7cf6(0x17b), a0_0x4a7cf6(0x1da));
        fs['cpSync'](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x55b73e) {
        log['exception'](a0_0x55b73e);
    }
    try {
        const sp = path['resolve'](basedir, 'tools'), tp = path[a0_0x4a7cf6(0x1be)](process['env']['REACTOR_DATA_PREFIX'] || a0_0x4a7cf6(0x17b), a0_0x4a7cf6(0x157));
        fs[a0_0x4a7cf6(0x1ce)](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x1552c9) {
        log[a0_0x4a7cf6(0x1d0)](a0_0x1552c9);
    }
    try {
        const ll = fs[a0_0x4a7cf6(0x1bd)]('/proc/1/mountinfo')[a0_0x4a7cf6(0x1de)](a0_0x4a7cf6(0x16b))[a0_0x4a7cf6(0x13b)](os[a0_0x4a7cf6(0x1ff)]), ee = ll['find'](_0xeeb315 => _0xeeb315['includes'](a0_0x4a7cf6(0x17b)));
        ee ? log[a0_0x4a7cf6(0x19f)](a0_0x4a7cf6(0x145), ee) : log[a0_0x4a7cf6(0x204)]('Container\x20has\x20no\x20identifiable\x20mount\x20for\x20/var/reactor.');
    } catch (a0_0x18d0bd) {
        log['exception'](a0_0x18d0bd);
    }
}
const app = express(), struct = require(a0_0x4a7cf6(0x164)), Engine = require(a0_0x4a7cf6(0x13c)), httpapi = require(a0_0x4a7cf6(0x146)), wsapi = require(a0_0x4a7cf6(0x1bf)), AlertManager = require('server/lib/AlertManager');
process['on'](a0_0x4a7cf6(0x1ea), (_0x529152, _0x4cf468) => {
    const _0x4ab72f = a0_0x4a7cf6;
    console[_0x4ab72f(0x141)]('Trapped\x20unhandled\x20Promise\x20rejection', _0x529152), console[_0x4ab72f(0x174)](_0x529152), console[_0x4ab72f(0x174)](_0x4cf468), console[_0x4ab72f(0x175)]();
    try {
        process[_0x4ab72f(0x1ee)][_0x4ab72f(0x1fa)](path['resolve'](c['logsdir'], _0x4ab72f(0x1ba)), _0x529152), log[_0x4ab72f(0x174)](_0x4ab72f(0x142), _0x529152), log[_0x4ab72f(0x1d0)](_0x529152), log[_0x4ab72f(0x174)](_0x4ab72f(0x169));
    } catch (_0xe30bb8) {
    }
}), process['on'](a0_0x4a7cf6(0x181), _0x23ce8e => {
    const _0x3be72d = a0_0x4a7cf6;
    console['error']('Trapped\x20unhandled\x20exception:', _0x23ce8e), console[_0x3be72d(0x175)](_0x23ce8e);
    try {
        process['report']['writeReport'](path['resolve'](c[_0x3be72d(0x1cd)], 'unhandled.json'), _0x23ce8e), log[_0x3be72d(0x174)](_0x3be72d(0x178), _0x23ce8e), log['error'](_0x3be72d(0x169));
    } catch (_0x449ac7) {
    }
    _0x3be72d(0x1a2) === _0x23ce8e[_0x3be72d(0x153)] && setTimeout(function () {
        const _0xec7997 = _0x3be72d;
        process[_0xec7997(0x188)](0x1);
    }, 0xfa);
}), log[a0_0x4a7cf6(0x1d9)]('Starting\x20Structure...'), struct[a0_0x4a7cf6(0x1a8)](c[a0_0x4a7cf6(0x171)])[a0_0x4a7cf6(0x155)](async () => {
    const _0x13f1c6 = a0_0x4a7cf6, _0x5ce258 = Engine[_0x13f1c6(0x172)]();
    try {
        const _0x591711 = parseInt(process[_0x13f1c6(0x1b8)][_0x13f1c6(0x1f5)][_0x13f1c6(0x13b)]('.')[0x0]);
        let _0x411c12 = !![];
        if (!isNaN(_0x591711)) {
            const _0x5ed0c1 = NODE_VERSIONS[_0x591711];
            if (c?.[_0x13f1c6(0x1c1)] && c[_0x13f1c6(0x1c1)] == _0x591711)
                log[_0x13f1c6(0x165)](0x5, 'nodejs\x20major\x20version\x20%1\x20accepted\x20(by\x20configuration\x20exception)', _0x591711);
            else {
                if (_0x5ed0c1) {
                    log['info']('nodejs\x20v%1\x20known,\x20supported\x20through\x20%2', _0x591711, new Date(_0x5ed0c1[_0x13f1c6(0x1a1)])[_0x13f1c6(0x1a7)]());
                    const _0x4272ff = _0x5ed0c1[_0x13f1c6(0x1a1)] - NODE_EOL_WARNING * 0x5265c00;
                    if (Date[_0x13f1c6(0x1ae)]() >= _0x5ed0c1['eol'])
                        AlertManager[_0x13f1c6(0x202)](AlertManager[_0x13f1c6(0x1ca)], '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.', { 'tag': _0x13f1c6(0x17f) }, process[_0x13f1c6(0x1b8)][_0x13f1c6(0x1f5)]), _0x411c12 = ![];
                    else
                        Date['now']() >= _0x4272ff && (AlertManager[_0x13f1c6(0x202)](AlertManager['NOTICE'], _0x13f1c6(0x196), { 'tag': _0x13f1c6(0x17f) }, process[_0x13f1c6(0x1b8)]['node']), _0x411c12 = ![]);
                } else
                    AlertManager['addAlert'](AlertManager['WARN'], _0x13f1c6(0x1e7), { 'tag': _0x13f1c6(0x17f) }, process[_0x13f1c6(0x1b8)][_0x13f1c6(0x1f5)]), _0x411c12 = ![];
            }
        }
        _0x411c12 && AlertManager['dismissTag'](_0x13f1c6(0x17f)), process[_0x13f1c6(0x199)] && 0x0 === process[_0x13f1c6(0x199)]() && !is_docker ? AlertManager[_0x13f1c6(0x202)](AlertManager[_0x13f1c6(0x1ca)], _0x13f1c6(0x1b5), { 'tag': _0x13f1c6(0x136) }) : AlertManager[_0x13f1c6(0x184)](_0x13f1c6(0x136));
    } catch (_0xf1e104) {
        log[_0x13f1c6(0x1d0)](_0xf1e104);
    }
    !valid_config ? AlertManager[_0x13f1c6(0x202)](AlertManager[_0x13f1c6(0x18f)], _0x13f1c6(0x19b), { 'tag': _0x13f1c6(0x201) }, rcf) : AlertManager['dismissTag'](_0x13f1c6(0x201));
    if (!![] === Configuration[_0x13f1c6(0x1ed)](_0x13f1c6(0x1f2), _0x13f1c6(0x1eb), ![])) {
        log['notice'](_0x13f1c6(0x1c7));
        const _0x59f9ba = Date['now']();
        let _0x69f69a = await struct[_0x13f1c6(0x1cc)](Configuration[_0x13f1c6(0x1ed)]('reactor.engine.startup_wait', _0x13f1c6(0x1c6), 0xea60));
        log[_0x13f1c6(0x19f)]('Startup\x20was\x20delayed\x20%1ms', Date['now']() - _0x59f9ba);
        let _0x3314bc = 0x0;
        for (let _0xe37f62 of _0x69f69a) {
            !_0xe37f62[_0x13f1c6(0x15a)] && (log[_0x13f1c6(0x1d9)](_0x13f1c6(0x1ef), _0xe37f62['id'], _0xe37f62['reason']), ++_0x3314bc);
        }
        0x0 === _0x3314bc && log[_0x13f1c6(0x1d9)]('All\x20%1\x20controllers\x20successfully\x20started.', _0x69f69a['length']);
    }
    var _0x1a3e4e = ![], _0x319a33 = async function (_0x3de76f) {
            const _0x52a37e = _0x13f1c6;
            if (_0x1a3e4e)
                return;
            _0x1a3e4e = !![], log[_0x52a37e(0x1f6)](_0x52a37e(0x1d7), _0x3de76f);
            try {
                log[_0x52a37e(0x1d9)]('Stopping\x20Engine...'), await _0x5ce258[_0x52a37e(0x1c2)]();
            } catch (_0x7b9292) {
                log[_0x52a37e(0x1d0)](_0x7b9292);
            }
            try {
                log[_0x52a37e(0x1d9)](_0x52a37e(0x13d)), await struct['stop']();
            } catch (_0x21d8b0) {
                log[_0x52a37e(0x1d0)](_0x21d8b0), console['error'](_0x21d8b0);
            }
            try {
                log[_0x52a37e(0x1d9)](_0x52a37e(0x1b6)), await wsapi[_0x52a37e(0x1c2)](), await httpapi[_0x52a37e(0x1c2)]();
            } catch (_0x586724) {
                log[_0x52a37e(0x1d0)](_0x586724), console[_0x52a37e(0x174)](_0x586724);
            }
            try {
                log['notice']('Stopping\x20timers...');
                let _0x3478a8 = require(_0x52a37e(0x14e));
                _0x3478a8[_0x52a37e(0x1c2)]();
            } catch (_0x2bad3d) {
                log[_0x52a37e(0x1d0)](_0x2bad3d), console[_0x52a37e(0x174)](_0x2bad3d);
            }
            log['always'](_0x52a37e(0x1c9), process[_0x52a37e(0x15f)]);
            try {
                log[_0x52a37e(0x1f6)](_0x52a37e(0x197)), await Logger[_0x52a37e(0x14f)](), console[_0x52a37e(0x141)](_0x52a37e(0x1f1));
            } catch (_0x24c752) {
                console[_0x52a37e(0x174)](_0x52a37e(0x1dd), _0x24c752);
            }
            try {
                opts[_0x52a37e(0x1cb)] && fs[_0x52a37e(0x1b4)](opts[_0x52a37e(0x1cb)]);
            } catch (_0x110f37) {
                console['error'](_0x110f37);
            }
            setTimeout(() => {
                const _0x1a3018 = _0x52a37e;
                console[_0x1a3018(0x174)](_0x1a3018(0x143)), process[_0x1a3018(0x188)]('SIGQUIT' === _0x3de76f ? 0x1 : 0x7f);
            }, 0x7d0), process[_0x52a37e(0x188)]('SIGQUIT' === _0x3de76f ? 0x1 : 0x7f);
        };
    process['on'](_0x13f1c6(0x187), _0x319a33), process['on']('SIGTERM', _0x319a33), process['on'](_0x13f1c6(0x158), _0x319a33), process['on'](_0x13f1c6(0x1dc), _0x319a33), process['on'](_0x13f1c6(0x150), _0x24b276 => {
        const _0x2bf36b = _0x13f1c6;
        log[_0x2bf36b(0x165)](0x5, _0x2bf36b(0x1f3), _0x24b276);
        if (_0x2bf36b(0x14f) === _0x24b276)
            log[_0x2bf36b(0x1d9)](_0x2bf36b(0x1df)), _0x319a33('SIGINT');
        else
            _0x2bf36b(0x156) === _0x24b276 && (log[_0x2bf36b(0x1d9)](_0x2bf36b(0x1e1)), _0x319a33('SIGQUIT'));
    }), process['on'](_0x13f1c6(0x188), function () {
        const _0x2a8c7c = _0x13f1c6;
        console[_0x2a8c7c(0x141)](_0x2a8c7c(0x189));
    }), log[_0x13f1c6(0x1d9)]('Starting\x20HTTP\x20server\x20and\x20API...'), httpapi[_0x13f1c6(0x1a8)](app, c[_0x13f1c6(0x171)])['then'](_0x4b3ce3 => {
        const _0x214e26 = _0x13f1c6;
        if (Configuration[_0x214e26(0x1ed)](_0x214e26(0x166), _0x214e26(0x1eb), ![])) {
            const _0x226cea = require(_0x214e26(0x193));
            log[_0x214e26(0x1d9)](_0x214e26(0x18d)), _0x226cea[_0x214e26(0x1a8)](app);
        }
        log[_0x214e26(0x1d9)]('Starting\x20WSAPI...'), wsapi[_0x214e26(0x1a8)](app, _0x4b3ce3)[_0x214e26(0x155)](async () => {
            const _0x348343 = _0x214e26;
            wsapi[_0x348343(0x1cf)]();
        });
    })[_0x13f1c6(0x1b9)](_0x1caea6 => {
        const _0x3ed628 = _0x13f1c6;
        log[_0x3ed628(0x14a)](_0x3ed628(0x1fb), _0x1caea6), 'EADDRINUSE' === _0x1caea6[_0x3ed628(0x153)] && (log[_0x3ed628(0x14a)]('Stopping\x20service;\x20another\x20instance\x20may\x20be\x20running.'), process[_0x3ed628(0x167)](process[_0x3ed628(0x15f)], _0x3ed628(0x158)));
    });
    if (opts[_0x13f1c6(0x1f0)] || ![] === Configuration[_0x13f1c6(0x1ed)](_0x13f1c6(0x1d5), _0x13f1c6(0x1eb), !![])) {
        const _0x190566 = require(_0x13f1c6(0x1bc));
        log[_0x13f1c6(0x1fd)](_0x13f1c6(0x180)), AlertManager[_0x13f1c6(0x202)](AlertManager[_0x13f1c6(0x18f)], _0x190566['_T'](_0x13f1c6(0x18e)), { 'tag': _0x13f1c6(0x15d) });
    } else {
        let _0x36629c = Configuration[_0x13f1c6(0x1ed)](_0x13f1c6(0x1b2), _0x13f1c6(0x1c6), 0x0);
        if (_0x36629c > 0x0) {
            const _0x23d250 = require('server/lib/util');
            await _0x23d250[_0x13f1c6(0x18a)](() => {
                const _0x30f8d6 = _0x13f1c6;
                log[_0x30f8d6(0x1f6)](_0x30f8d6(0x1a4), _0x36629c / 0x3e8);
            }, _0x36629c)[_0x13f1c6(0x1b9)](_0x27b870 => {
            });
        }
        log[_0x13f1c6(0x1d9)](_0x13f1c6(0x1e8)), struct[_0x13f1c6(0x16e)](_0x5ce258);
        try {
            _0x5ce258[_0x13f1c6(0x1a8)](), AlertManager[_0x13f1c6(0x184)](_0x13f1c6(0x15d));
        } catch (_0x52a978) {
            log[_0x13f1c6(0x14a)](_0x13f1c6(0x16f), _0x52a978), log[_0x13f1c6(0x1d0)](_0x52a978);
        }
    }
});
if (opts[a0_0x4a7cf6(0x191)]) {
    let r = repl[a0_0x4a7cf6(0x1a8)]('>\x20'), ctx = r[a0_0x4a7cf6(0x1db)];
    ctx[a0_0x4a7cf6(0x198)] = struct, ctx[a0_0x4a7cf6(0x1f7)] = Engine[a0_0x4a7cf6(0x172)](struct), r['on'](a0_0x4a7cf6(0x188), () => {
        const _0x284e86 = a0_0x4a7cf6;
        Engine[_0x284e86(0x172)](struct)['stop'](), struct['stop'](), process[_0x284e86(0x188)](0x1);
    });
}