// @ts-nocheck
import { Platform, } from 'react-native';
'use strict';
const _InCallManager = require('react-native').NativeModules.InCallManager;
class InCallManager {
    constructor() {
        this.vibrate = false;
        this.audioUriMap = {
            ringtone: { _BUNDLE_: null, _DEFAULT_: null },
            ringback: { _BUNDLE_: null, _DEFAULT_: null },
            busytone: { _BUNDLE_: null, _DEFAULT_: null },
        };
    }
    start(setup) {
        setup = (setup === undefined) ? {} : setup;
        const auto = setup.auto !== false;
        const media = (setup.media === 'video') ? 'video' : 'audio';
        const ringback = (setup.ringback) ? (typeof setup.ringback === 'string') ? setup.ringback : '' : '';
        _InCallManager.start(media, auto, ringback);
    }
    stop(setup) {
        setup = (setup === undefined) ? {} : setup;
        const busytone = (setup.busytone) ? (typeof setup.busytone === 'string') ? setup.busytone : '' : '';
        _InCallManager.stop(busytone);
    }
    async getIsWiredHeadsetPluggedIn() {
        try {
            return await _InCallManager.getIsWiredHeadsetPluggedIn();
        }
        catch (e) {
            throw new Error('Incall Manager Error getting wired headset');
        }
    }
    setKeepScreenOn(enable) {
        enable = (enable === true);
        _InCallManager.setKeepScreenOn(enable);
    }
    setSpeakerphoneOn(enable) {
        enable = (enable === true);
        _InCallManager.setSpeakerphoneOn(enable);
    }
    setForceSpeakerphoneOn(_flag) {
        const flag = (typeof _flag === 'boolean') ? (_flag) ? 1 : -1 : 0;
        _InCallManager.setForceSpeakerphoneOn(flag);
    }
    setMicrophoneMute(enable) {
        enable = (enable === true);
        _InCallManager.setMicrophoneMute(enable);
    }
    async getAudioUri(audioType, fileType) {
        if (typeof this.audioUriMap[audioType] === 'undefined') {
            return null;
        }
        if (this.audioUriMap[audioType][fileType]) {
            return this.audioUriMap[audioType][fileType];
        }
        try {
            const result = await _InCallManager.getAudioUriJS(audioType, fileType);
            if (typeof result === 'string' && result.length > 0) {
                this.audioUriMap[audioType][fileType] = result;
                return result;
            }
            return null;
        }
        catch (err) {
            return null;
        }
    }
    async chooseAudioRoute(route) {
        const result = await _InCallManager.chooseAudioRoute(route);
        return result;
    }
    async requestAudioFocus() {
        if (Platform.OS === 'android') {
            return await _InCallManager.requestAudioFocusJS();
        }
        else {
            console.log("ios doesn't support requestAudioFocus()");
        }
    }
    async abandonAudioFocus() {
        if (Platform.OS === 'android') {
            return await _InCallManager.abandonAudioFocusJS();
        }
        else {
            console.log("ios doesn't support requestAudioFocus()");
        }
    }
}
export default new InCallManager();
//# sourceMappingURL=RNInCallManager.js.map