"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const Server_1 = require("../../../../../wrap/Server");
const _ids_1 = require("../../../../_ids");
class CreateServer extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['opt'],
            fo: ['server'],
            i: [],
            o: [],
        }, {}, system, _ids_1.ID_CREATE_SERVER, 'close');
    }
    async f({ opt }, done, fail) {
        const { api: { http: { createServer }, }, } = this.__system;
        let _server;
        try {
            _server = createServer(this.__system, opt, (err) => {
                fail(err);
            });
        }
        catch (err) {
            fail(err.message.toLowerCase());
            return;
        }
        const server = (0, Server_1.wrapHTTPServer)(_server, this.__system);
        done({
            server,
        });
    }
    d() {
        if (this._unlisten) {
            this._unlisten();
            this._unlisten = undefined;
        }
    }
    onIterDataInputData(name, data) {
        super.onIterDataInputData(name, data);
    }
}
exports.default = CreateServer;
//# sourceMappingURL=index.js.map