"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const node_process_1 = __importDefault(require("node:process"));
const commander_1 = require("commander");
const semver_1 = require("semver");
let homebridge;
class HomebridgeUi {
    constructor(log, config) {
        this.log = log;
        node_process_1.default.env.UIX_CONFIG_PATH = homebridge.user.configPath();
        node_process_1.default.env.UIX_STORAGE_PATH = homebridge.user.storagePath();
        node_process_1.default.env.UIX_PLUGIN_NAME = config.name || 'homebridge-config-ui-x';
        const program = new commander_1.Command();
        program
            .allowUnknownOption()
            .allowExcessArguments()
            .option('-P, --plugin-path [path]', '', p => node_process_1.default.env.UIX_CUSTOM_PLUGIN_PATH = p)
            .option('-I, --insecure', '', () => node_process_1.default.env.UIX_INSECURE_MODE = '1')
            .option('-T, --no-timestamp', '', () => node_process_1.default.env.UIX_LOG_NO_TIMESTAMPS = '1')
            .parse(node_process_1.default.argv);
        if (!(0, semver_1.satisfies)(node_process_1.default.version, '>=20.19.0')) {
            const msg = `Node.js v20.19.0 higher is required. You may experience issues running this plugin running on ${node_process_1.default.version}.`;
            log.error(msg);
            log.warn(msg);
        }
    }
    accessories(callback) {
        const accessories = [];
        callback(accessories);
    }
}
module.exports = (api) => {
    homebridge = api;
    homebridge.registerPlatform('homebridge-config-ui-x', 'config', HomebridgeUi);
    node_process_1.default.on('disconnect', () => node_process_1.default.exit());
};
//# sourceMappingURL=index.js.map