import { i as isFirefox } from './browser-24d8ab3e.js';

const SOUNDS = {
    joined: 'https://rtk-uploads.realtime.cloudflare.com/notification_join.mp3',
    left: 'https://rtk-uploads.realtime.cloudflare.com/notification_join.mp3',
    message: 'https://rtk-uploads.realtime.cloudflare.com/notification_message.mp3',
};
/**
 * Handles notification sounds in a meeting
 */
class RTKNotificationsAudio {
    constructor(meeting) {
        this.meeting = meeting;
        this.audio = document.createElement('audio');
        this.audio.volume = 0.3;
    }
    play(sound, duration = 3000) {
        var _a;
        if (this.playing)
            return;
        this.playing = true;
        this.audio.src = SOUNDS[sound];
        this.audio.volume = 0.3;
        (_a = this.audio.play()) === null || _a === void 0 ? void 0 : _a.catch((_) => { });
        setTimeout(() => {
            this.playing = false;
        }, duration);
    }
    async setDevice(id) {
        var _a, _b, _c;
        if (isFirefox(this.meeting))
            return;
        await ((_c = (_b = (_a = this.audio) === null || _a === void 0 ? void 0 : _a.setSinkId) === null || _b === void 0 ? void 0 : _b.call(_a, id)) === null || _c === void 0 ? void 0 : _c.catch((_) => { }));
    }
}

export { RTKNotificationsAudio as R };
