"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require("../../../../../Class/$");
const Functional_1 = require("../../../../../Class/Functional");
const _ids_1 = require("../../../../_ids");
class BluetoothServer extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['device'],
            o: ['server'],
        }, {
            input: {
                device: {
                    ref: true,
                },
            },
            output: {
                server: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_BLUETOOTH_SERVER);
    }
    async f({ device }, done, fail) {
        let _server;
        try {
            _server = await device.getServer();
        }
        catch (err) {
            fail(err.message.toLowerCase());
            return;
        }
        const server = new (class _BluetoothDevice extends _1.$ {
            getPrimaryService(name) {
                return _server.getPrimaryService(name);
            }
        })(this.__system);
        done({ server });
    }
    getPrimaryService(uuid) {
        return this._server.getPrimaryService(uuid);
    }
    d() { }
}
exports.default = BluetoothServer;
//# sourceMappingURL=index.js.map