"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpaceV2 = void 0;
const tslib_1 = require("tslib");
const constants_1 = require("../payloads/constants");
class SpaceV2 {
    constructor({ spaceV1Instance, spaceInfo, }) {
        this.spaceV1Instance = spaceV1Instance;
        this.spaceInfo = spaceInfo;
    }
    activateUserAudio() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.createAudioStream();
        });
    }
    start() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.start();
        });
    }
    join() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.join();
        });
    }
    update(updateSpaceOptions) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.update(updateSpaceOptions);
        });
    }
    leave() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.leave();
        });
    }
    stop() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.stop();
        });
    }
    requestForMic() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.requestToBePromoted({
                role: constants_1.SPACE_INVITE_ROLES.SPEAKER,
                promotorAddress: this.spaceInfo.spaceCreator,
            });
        });
    }
    acceptMicRequest({ address, signal, }) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.acceptPromotionRequest({
                promoteeAddress: address,
                spaceId: this.spaceInfo.spaceId,
                role: constants_1.SPACE_INVITE_ROLES.SPEAKER,
                signalData: signal,
            });
        });
    }
    rejectMicRequest({ address }) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.rejectPromotionRequest({
                promoteeAddress: address,
            });
        });
    }
    inviteToPromote({ address }) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.inviteToPromote({
                inviteeAddress: address,
                role: constants_1.SPACE_INVITE_ROLES.SPEAKER,
            });
        });
    }
    acceptPromotionInvite({ signal }) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.acceptPromotionInvite({
                invitorAddress: this.spaceInfo.spaceCreator,
                spaceId: this.spaceInfo.spaceId,
                signalData: signal,
            });
        });
    }
    rejectPromotionInvite() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.spaceV1Instance.rejectPromotionInvite({
                invitorAddress: this.spaceInfo.spaceCreator,
            });
        });
    }
    config({ video, audio }) {
        if (typeof video === 'boolean') {
            this.spaceV1Instance.enableVideo({ state: video });
        }
        if (typeof audio === 'boolean') {
            this.spaceV1Instance.enableAudio({ state: audio });
        }
    }
}
exports.SpaceV2 = SpaceV2;
//# sourceMappingURL=SpaceV2.js.map