var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
const devtool = require('./devtool');
const config = require('./config');
const IP = require('ip');
const startDevtoolServer = (entrys, options) => __awaiter(this, void 0, void 0, function* () {
    new Promise((resolve, reject) => {
        if (options) {
            config.ip = options.ip || IP.address();
            config.port = options.port || 8089;
            config.manual = options.manual || false;
            config.CHANNELID = options.CHANNELID || options.channelId;
            config.REMOTE_DEBUG_PORT = options.REMOTE_DEBUG_PORT || options.remoteDebugPort || 9222;
            config.ENABLE_HEADLESS = typeof options.ENABLE_HEADLESS === 'boolean' ? options.ENABLE_HEADLESS : typeof options.enableHeadless === 'boolean' ? options.enableHeadless : true;
        }
        devtool.start(entrys, config, (data) => {
            resolve(data);
        });
    });
});
const api = {
    startDevtoolServer: startDevtoolServer,
    reload: devtool.reload
};
module.exports = {
    api
};
