{"version":3,"file":"vendors-8f042594.f584a1446b2fc034d810.bundle.js","mappings":"AAKA","sources":["webpack://lernplattform-admin-frontend/./node_modules/amazon-chime-sdk-js/build/voicefocus/LoggerAdapter.js","webpack://lernplattform-admin-frontend/./node_modules/amazon-chime-sdk-js/build/voicefocus/VoiceFocusDeviceTransformer.js","webpack://lernplattform-admin-frontend/./node_modules/amazon-chime-sdk-js/build/voicefocus/VoiceFocusTransformDevice.js","webpack://lernplattform-admin-frontend/./node_modules/amazon-chime-sdk-js/build/voicefocus/VoiceFocusTransformDeviceDelegate.js","webpack://lernplattform-admin-frontend/./node_modules/amazon-chime-sdk-js/build/volumeindicatoradapter/DefaultVolumeIndicatorAdapter.js","webpack://lernplattform-admin-frontend/./node_modules/amazon-chime-sdk-js/build/websocketadapter/DefaultWebSocketAdapter.js","webpack://lernplattform-admin-frontend/./node_modules/amazon-chime-sdk-js/build/websocketadapter/WebSocketReadyState.js"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** @internal */\nfunction stringify(args) {\n    return args\n        .map((v) => {\n        if (typeof v === 'object') {\n            return JSON.stringify(v);\n        }\n        return `${v}`;\n    })\n        .join(' ');\n}\n/** @internal */\nclass LoggerAdapter {\n    constructor(base) {\n        this.base = base;\n    }\n    debug(...args) {\n        this.base.debug(stringify(args));\n    }\n    info(...args) {\n        this.base.info(stringify(args));\n    }\n    warn(...args) {\n        this.base.warn(stringify(args));\n    }\n    error(...args) {\n        this.base.error(stringify(args));\n    }\n}\nexports.default = LoggerAdapter;\n//# sourceMappingURL=LoggerAdapter.js.map","\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VoiceFocusDeviceTransformer = void 0;\nconst voicefocus_1 = require(\"../../libs/voicefocus/voicefocus\");\nconst Utils_1 = require(\"../utils/Utils\");\nconst Versioning_1 = __importDefault(require(\"../versioning/Versioning\"));\nconst LoggerAdapter_1 = __importDefault(require(\"./LoggerAdapter\"));\nconst VoiceFocusTransformDevice_1 = __importDefault(require(\"./VoiceFocusTransformDevice\"));\nconst VoiceFocusTransformDeviceDelegate_1 = __importDefault(require(\"./VoiceFocusTransformDeviceDelegate\"));\n/**\n * `VoiceFocusDeviceTransformer` is used to create {@link VoiceFocusTransformDevice|transform devices}\n * that apply Amazon Voice Focus noise suppression to audio input.\n *\n * This transformer captures relevant configuration. You should check for support, initialize,\n * and then create a device as follows:\n *\n * ```typescript\n * const deviceID = null;\n *\n * // This check for support is cheap and quick, and should be used to gate use\n * // of this feature.\n * if (!(await VoiceFocusDeviceTransformer.isSupported()) {\n *   console.log('Amazon Voice Focus not supported in this browser.');\n *   return deviceID;\n * }\n *\n * let transformer: VoiceFocusDeviceTransformer;\n * try {\n *   // This operation can fail in ways that do not indicate no support,\n *   // but do indicate an inability to apply Amazon Voice Focus. Trying again\n *   // might succeed.\n *   transformer = await VoiceFocusDeviceTransformer.create({});\n * } catch (e) {\n *   // Something went wrong.\n *   console.log('Unable to instantiate Amazon Voice Focus.');\n *   return deviceID;\n * }\n *\n * if (!transformer.isSupported()) {\n *   // The transformer will fall through, but your UI might care.\n *   console.log('Amazon Voice Focus not supported in this browser.');\n * }\n *\n * return await transformer.createTransformDevice(deviceID);\n * ```\n */\nclass VoiceFocusDeviceTransformer {\n    constructor(spec, { preload = true, logger, fetchBehavior = VoiceFocusDeviceTransformer.defaultFetchBehavior(), }, config) {\n        this.spec = spec;\n        this.supported = true;\n        this.logger = logger;\n        this.vfLogger = logger ? new LoggerAdapter_1.default(logger) : undefined;\n        this.preload = preload;\n        this.fetchBehavior = fetchBehavior;\n        // If the user didn't specify one, add the default, which is\n        // identified by the major and minor SDK version.\n        this.spec = VoiceFocusDeviceTransformer.augmentSpec(this.spec);\n        if (config) {\n            this.configuration = Promise.resolve(config);\n        }\n    }\n    /**\n     * Quickly check whether Amazon Voice Focus is supported on this platform.\n     *\n     * This will return `false` if key technologies are absent. A value of `true` does not\n     * necessarily mean that adding Amazon Voice Focus will succeed: it is still possible that the\n     * configuration of the page or the CPU speed of the device are limiting factors.\n     *\n     * {@link VoiceFocusDeviceTransformer.create} will return an instance whose\n     * `isSupported` method more accurately reflects whether Amazon Voice Focus\n     * is supported in the current environment.\n     *\n     * This method will only reject if you provide invalid inputs.\n     *\n     * @param spec An optional asset group and URL paths to use when fetching. You can pass\n     *             a complete {@link VoiceFocusSpec} here for convenience, matching the signature of {@link VoiceFocusDeviceTransformer.create}.\n     * @param options Additional named arguments, including `logger`. Set\n     *                `allowIFrame` to false to cause the support check to fail in\n     *                an iframe.\n     *                Chromium's security model means that audio processing works\n     *                poorly in iframes.\n     */\n    static isSupported(spec, options) {\n        var _a, _b;\n        const fetchBehavior = VoiceFocusDeviceTransformer.defaultFetchBehavior();\n        const logger = (options === null || options === void 0 ? void 0 : options.logger) ? new LoggerAdapter_1.default(options.logger) : undefined;\n        const opts = {\n            fetchBehavior,\n            logger,\n        };\n        // This is impossible to test in Node, so Istanbul ignore.\n        /* istanbul ignore next */\n        if (Utils_1.isIFramed()) {\n            if ((options === null || options === void 0 ? void 0 : options.allowIFrame) === false) {\n                (_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.error('Amazon Voice Focus support check inside iframe: not supported.');\n                return Promise.resolve(false);\n            }\n            else {\n                (_b = options === null || options === void 0 ? void 0 : options.logger) === null || _b === void 0 ? void 0 : _b.warn('Amazon Voice Focus support check inside iframe: not recommended.');\n            }\n        }\n        return voicefocus_1.VoiceFocus.isSupported(VoiceFocusDeviceTransformer.augmentSpec(spec), opts);\n    }\n    /**\n     * Create a transformer that can apply Amazon Voice Focus noise suppression to a device.\n     *\n     * This method will reject if the provided spec is invalid, or if the process of\n     * checking for support or estimating fails (e.g., because the network is unreachable).\n     *\n     * If Amazon Voice Focus is not supported on this device, this call will not reject and\n     * `isSupported` will return `false` on the returned instance. That instance will\n     * pass through devices unmodified.\n     *\n     * @param spec A definition of how you want Amazon Voice Focus to behave. See the declaration of\n     *             {@link VoiceFocusSpec} for details.\n     * @param options Additional named arguments, including `logger` and `preload`.\n     */\n    static create(spec = {}, options = {}, config, \n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    createMeetingResponse, \n    // eslint-disable-next-line\n    createAttendeeResponse) {\n        var _a, _b, _c;\n        return __awaiter(this, void 0, void 0, function* () {\n            if (createMeetingResponse) {\n                if (createMeetingResponse.Meeting.Meeting) {\n                    createMeetingResponse = createMeetingResponse.Meeting;\n                }\n            }\n            const meetingFeaturesAllowsES = ((_c = (_b = (_a = createMeetingResponse === null || createMeetingResponse === void 0 ? void 0 : createMeetingResponse.Meeting) === null || _a === void 0 ? void 0 : _a.MeetingFeatures) === null || _b === void 0 ? void 0 : _b.Audio) === null || _c === void 0 ? void 0 : _c.EchoReduction) === 'AVAILABLE';\n            const forbiddenConfig = config &&\n                config.supported === true &&\n                config.model.name === 'ns_es' &&\n                !meetingFeaturesAllowsES;\n            const forbiddenSpec = spec.name === 'ns_es' && !meetingFeaturesAllowsES;\n            if (forbiddenConfig || forbiddenSpec) {\n                throw new Error('Echo Reduction requested but not enabled.');\n            }\n            const transformer = new VoiceFocusDeviceTransformer(spec, options, config);\n            // This also preps the first `VoiceFocus` instance.\n            yield transformer.init();\n            return transformer;\n        });\n    }\n    /**\n     * Given a spec and options, perform the configuration work that is\n     * ordinarily performed during creation of a transformer.\n     *\n     * The computed configuration is not portable between devices or sessions,\n     * but is useful for 'moving' transformers between windows.\n     *\n     * Pass the returned configuration as the third argument to a call to\n     * {@link VoiceFocusDeviceTransformer.create} with the matching spec.\n     */\n    static configure(spec = {}, options = {}) {\n        return __awaiter(this, void 0, void 0, function* () {\n            const transformer = new VoiceFocusDeviceTransformer(spec, options, undefined);\n            return transformer.configure(true);\n        });\n    }\n    /**\n     * Return the computed configuration for this transformer.\n     */\n    getConfiguration() {\n        return this.configuration;\n    }\n    /**\n     * Return whether this transformer is able to function in this environment.\n     * If not, calls to\n     * {@link VoiceFocusDeviceTransformer.createTransformDevice|createTransformDevice}\n     * will pass through an unmodified device.\n     */\n    isSupported() {\n        return this.supported;\n    }\n    /**\n     * Apply Amazon Voice Focus to the selected {@link Device}.\n     *\n     * If this is a stream, it should be one that does not include other noise suppression features,\n     * and you should consider whether to disable automatic gain control (AGC) on the stream, because\n     * it can interact with noise suppression.\n     *\n     * @returns a device promise. This will always resolve to either a\n     *          {@link VoiceFocusTransformDevice} or undefined; it will never reject.\n     */\n    createTransformDevice(device, nodeOptions) {\n        return __awaiter(this, void 0, void 0, function* () {\n            if (!this.supported) {\n                // Fall back.\n                return undefined;\n            }\n            try {\n                const preload = true;\n                const [vf, delegate] = yield this.allocateVoiceFocus(preload);\n                const options = Object.assign(Object.assign({}, nodeOptions), { es: this.spec.name === 'ns_es' });\n                return new VoiceFocusTransformDevice_1.default(device, vf, delegate, options);\n            }\n            catch (e) {\n                // Fall back.\n                /* istanbul ignore next */\n                return undefined;\n            }\n        });\n    }\n    /**\n     * Destroy the Voice Focus instance and worker thread associated with the transformer.\n     */\n    static destroyVoiceFocus(transformer) {\n        var _a;\n        return __awaiter(this, void 0, void 0, function* () {\n            /* istanbul ignore next */\n            (_a = transformer === null || transformer === void 0 ? void 0 : transformer.vf) === null || _a === void 0 ? void 0 : _a.destroy();\n        });\n    }\n    static augmentSpec(spec) {\n        if (!spec || (!spec.assetGroup && !spec.revisionID)) {\n            return Object.assign(Object.assign({}, spec), { assetGroup: VoiceFocusDeviceTransformer.currentSDKAssetGroup() });\n        }\n        return spec;\n    }\n    configure(preResolve = false) {\n        return __awaiter(this, void 0, void 0, function* () {\n            const options = {\n                fetchBehavior: this.fetchBehavior,\n                preResolve,\n                logger: this.vfLogger,\n            };\n            return voicefocus_1.VoiceFocus.configure(this.spec, options);\n        });\n    }\n    init() {\n        var _a;\n        return __awaiter(this, void 0, void 0, function* () {\n            if (!this.configuration) {\n                this.configuration = this.configure();\n            }\n            const config = yield this.configuration;\n            if (!config.supported) {\n                // No need to init: it won't work.\n                this.supported = false;\n                return;\n            }\n            // We initialize the first one right now, which makes it easier to detect\n            // possible failures.\n            // This can throw for malformed input. Pass that up the chain.\n            this.pendingVoiceFocus = this.createVoiceFocus(config, this.preload);\n            try {\n                yield this.pendingVoiceFocus;\n            }\n            catch (e) {\n                (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`Unable to initialize Amazon Voice Focus: ${e}`);\n                this.supported = false;\n            }\n        });\n    }\n    createVoiceFocus(config, preload) {\n        return __awaiter(this, void 0, void 0, function* () {\n            const delegate = new VoiceFocusTransformDeviceDelegate_1.default();\n            this.vf = yield voicefocus_1.VoiceFocus.init(config, { delegate, preload, logger: this.vfLogger });\n            return [this.vf, delegate];\n        });\n    }\n    allocateVoiceFocus(preload) {\n        return __awaiter(this, void 0, void 0, function* () {\n            // A little safety.\n            /* istanbul ignore next */\n            if (!this.supported) {\n                throw new Error('Not supported.');\n            }\n            if (this.pendingVoiceFocus) {\n                // Use the one we already have, and free the slot for any future execution.\n                const vf = this.pendingVoiceFocus;\n                this.pendingVoiceFocus = undefined;\n                return vf;\n            }\n            return this.createVoiceFocus(yield this.configuration, preload);\n        });\n    }\n    static majorVersion() {\n        return Versioning_1.default.sdkVersion.match(/^[1-9][0-9]*\\.(?:0|[1-9][0-9]*)/)[0];\n    }\n    static majorMinorVersion() {\n        return Versioning_1.default.sdkVersion.match(/^[1-9][0-9]*\\.(?:0|(?:[1-9][0-9]*))\\.(?:0|[1-9][0-9]*)/)[0];\n    }\n    static currentSDKAssetGroup() {\n        // Just on the off chance someone does something silly, handle\n        // malformed version strings here.\n        const v = this.majorVersion();\n        // Just a little safety.\n        /* istanbul ignore next */\n        if (!v) {\n            return `stable-v1`;\n        }\n        return `sdk-${v}`;\n    }\n    // Note that we use query strings here, not headers, in order to make these requests 'simple' and\n    // avoid the need for CORS preflights.\n    // Be very, very careful if you choose to add headers here. You should never need to.\n    static defaultFetchBehavior() {\n        // Just a little safety.\n        /* istanbul ignore next */\n        const version = VoiceFocusDeviceTransformer.majorMinorVersion() || 'unknown';\n        const ua = Versioning_1.default.sdkUserAgentLowResolution;\n        return {\n            escapedQueryString: `sdk=${encodeURIComponent(version)}&ua=${encodeURIComponent(ua)}`,\n        };\n    }\n}\nexports.VoiceFocusDeviceTransformer = VoiceFocusDeviceTransformer;\nexports.default = VoiceFocusDeviceTransformer;\n//# sourceMappingURL=VoiceFocusDeviceTransformer.js.map","\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst DefaultBrowserBehavior_1 = __importDefault(require(\"../browserbehavior/DefaultBrowserBehavior\"));\n/**\n * A device that augments a {@link Device} to apply Amazon Voice Focus\n * noise suppression to an audio input.\n */\nclass VoiceFocusTransformDevice {\n    /** @internal */\n    constructor(device, voiceFocus, delegate, nodeOptions, failed = false, node = undefined, browserBehavior = new DefaultBrowserBehavior_1.default(), \n    /** farEndStreams` maps from a stream that could cause echo or interfere with double talkto an `AudioSourceNode` that we use to mix multiple such streams.*/\n    farEndStreamToAudioSourceNode = new Map(), \n    /** mixDestNode is the Audio Destination Node where farEndStreams got mixed into one stream.*/\n    mixDestNode = undefined, \n    /** mixSourceNode is the Audio Source Node where the stream out of mixDestNode got transferred into Audio Worklet Node for processing.*/\n    mixSourceNode = undefined) {\n        this.device = device;\n        this.voiceFocus = voiceFocus;\n        this.delegate = delegate;\n        this.nodeOptions = nodeOptions;\n        this.failed = failed;\n        this.node = node;\n        this.browserBehavior = browserBehavior;\n        this.farEndStreamToAudioSourceNode = farEndStreamToAudioSourceNode;\n        this.mixDestNode = mixDestNode;\n        this.mixSourceNode = mixSourceNode;\n    }\n    /**\n     * Return the inner device as provided during construction, or updated via\n     * {@link VoiceFocusTransformDevice.chooseNewInnerDevice}. Do not confuse\n     * this method with {@link VoiceFocusTransformDevice.intrinsicDevice}.\n     */\n    getInnerDevice() {\n        return this.device;\n    }\n    /**\n     * Disable the audio node while muted to reduce CPU usage.\n     *\n     * @param muted whether the audio device should be muted.\n     */\n    mute(muted) {\n        return __awaiter(this, void 0, void 0, function* () {\n            if (!this.node) {\n                return;\n            }\n            if (muted) {\n                yield this.node.disable();\n            }\n            else {\n                yield this.node.enable();\n            }\n        });\n    }\n    /**\n     * Dispose of the inner workings of the transform device. After this method is called\n     * you will need to create a new device to use Amazon Voice Focus again.\n     */\n    stop() {\n        return __awaiter(this, void 0, void 0, function* () {\n            if (!this.node) {\n                return;\n            }\n            this.node.disconnect();\n            yield this.node.stop();\n        });\n    }\n    /**\n     * If you wish to choose a different inner device, but continue to use Amazon Voice Focus, you\n     * can use this method to efficiently create a new device that will reuse\n     * the same internal state. Only one of the two devices can be used at a time: switch\n     * between them using {@link DeviceController.startAudioInput}.\n     *\n     * If the same device is passed as is currently in use, `this` is returned.\n     *\n     * @param inner The new inner device to use.\n     */\n    chooseNewInnerDevice(inner) {\n        return __awaiter(this, void 0, void 0, function* () {\n            // If the new device is 'default', always recreate. Chrome can switch out\n            // the real device underneath us.\n            if (this.device === inner && !isDefaultDevice(inner)) {\n                return this;\n            }\n            return new VoiceFocusTransformDevice(inner, this.voiceFocus, this.delegate, this.nodeOptions, this.failed, this.node, this.browserBehavior, this.farEndStreamToAudioSourceNode, this.mixDestNode, this.mixSourceNode);\n        });\n    }\n    intrinsicDevice() {\n        return __awaiter(this, void 0, void 0, function* () {\n            if (this.failed) {\n                return this.device;\n            }\n            const isUsingES = this.nodeOptions.es;\n            // Turn the Device into constraints with appropriate AGC settings.\n            const trackConstraints = {\n                echoCancellation: !isUsingES,\n                // @ts-ignore\n                googEchoCancellation: !isUsingES,\n                // @ts-ignore\n                googEchoCancellation2: !isUsingES,\n                noiseSuppression: false,\n                // @ts-ignore\n                googNoiseSuppression: false,\n                // @ts-ignore\n                googHighpassFilter: false,\n                // @ts-ignore\n                googNoiseSuppression2: false,\n            };\n            let useBuiltInAGC;\n            if (this.nodeOptions && this.nodeOptions.agc !== undefined) {\n                useBuiltInAGC = this.nodeOptions.agc.useBuiltInAGC;\n            }\n            else {\n                useBuiltInAGC = true;\n            }\n            trackConstraints.autoGainControl = useBuiltInAGC;\n            // @ts-ignore\n            trackConstraints.googAutoGainControl = useBuiltInAGC;\n            // @ts-ignore\n            trackConstraints.googAutoGainControl2 = useBuiltInAGC;\n            // Empty string and null.\n            if (!this.device) {\n                return trackConstraints;\n            }\n            // Device ID.\n            if (typeof this.device === 'string') {\n                /* istanbul ignore if */\n                if (this.browserBehavior.requiresNoExactMediaStreamConstraints()) {\n                    trackConstraints.deviceId = this.device;\n                }\n                else {\n                    trackConstraints.deviceId = { exact: this.device };\n                }\n                return trackConstraints;\n            }\n            // It's a stream.\n            if (this.device.id) {\n                // Nothing we can do.\n                return this.device;\n            }\n            // It's constraints.\n            return Object.assign(Object.assign({}, this.device), trackConstraints);\n        });\n    }\n    createAudioNode(context) {\n        var _a, _b;\n        return __awaiter(this, void 0, void 0, function* () {\n            if (((_a = this.node) === null || _a === void 0 ? void 0 : _a.context) === context) {\n                return {\n                    start: this.node,\n                    end: this.node,\n                };\n            }\n            const agc = { useVoiceFocusAGC: false };\n            const options = Object.assign({ enabled: true, agc }, this.nodeOptions);\n            try {\n                (_b = this.node) === null || _b === void 0 ? void 0 : _b.disconnect();\n                this.node = yield this.voiceFocus.createNode(context, options);\n                if (this.nodeOptions.es) {\n                    this.mixDestNode = new MediaStreamAudioDestinationNode(context, {\n                        channelCount: 1,\n                        channelCountMode: 'explicit',\n                    });\n                    for (const stream of this.farEndStreamToAudioSourceNode.keys()) {\n                        this.assignFarEndStreamToAudioSourceNode(stream);\n                    }\n                    this.createMixSourceNode();\n                }\n                const start = this.node;\n                const end = this.node;\n                return { start, end };\n            }\n            catch (e) {\n                // It's better to return some audio stream than nothing.\n                this.failed = true;\n                this.delegate.onFallback(this, e);\n                throw e;\n            }\n        });\n    }\n    observeMeetingAudio(audioVideo) {\n        return __awaiter(this, void 0, void 0, function* () {\n            if (!this.nodeOptions.es) {\n                return;\n            }\n            audioVideo.addAudioMixObserver(this);\n            const stream = yield audioVideo.getCurrentMeetingAudioStream();\n            if (stream) {\n                this.addFarEndStream(stream);\n            }\n        });\n    }\n    unObserveMeetingAudio(audioVideo) {\n        return __awaiter(this, void 0, void 0, function* () {\n            if (!this.nodeOptions.es) {\n                return;\n            }\n            audioVideo.removeAudioMixObserver(this);\n            const stream = yield audioVideo.getCurrentMeetingAudioStream();\n            if (stream) {\n                this.removeFarendStream(stream);\n            }\n        });\n    }\n    /**\n     * Add an observer to receive notifications about Amazon Voice Focus lifecycle events.\n     * See {@link VoiceFocusTransformDeviceObserver} for details.\n     * If the observer has already been added, this method call has no effect.\n     */\n    addObserver(observer) {\n        this.delegate.addObserver(observer);\n    }\n    /**\n     * Remove an existing observer. If the observer has not been previously {@link\n     * VoiceFocusTransformDevice.addObserver|added}, this method call has no effect.\n     */\n    removeObserver(observer) {\n        this.delegate.removeObserver(observer);\n    }\n    addFarEndStream(activeStream) {\n        return __awaiter(this, void 0, void 0, function* () {\n            if (!this.nodeOptions.es ||\n                !activeStream ||\n                this.farEndStreamToAudioSourceNode.has(activeStream)) {\n                return;\n            }\n            if (this.node) {\n                this.assignFarEndStreamToAudioSourceNode(activeStream);\n            }\n            else {\n                this.farEndStreamToAudioSourceNode.set(activeStream, null);\n            }\n        });\n    }\n    removeFarendStream(inactiveStream) {\n        var _a;\n        return __awaiter(this, void 0, void 0, function* () {\n            (_a = this.farEndStreamToAudioSourceNode.get(inactiveStream)) === null || _a === void 0 ? void 0 : _a.disconnect();\n            this.farEndStreamToAudioSourceNode.delete(inactiveStream);\n        });\n    }\n    meetingAudioStreamBecameActive(activeStream) {\n        return __awaiter(this, void 0, void 0, function* () {\n            this.addFarEndStream(activeStream);\n        });\n    }\n    meetingAudioStreamBecameInactive(inactiveStream) {\n        return __awaiter(this, void 0, void 0, function* () {\n            this.removeFarendStream(inactiveStream);\n        });\n    }\n    assignFarEndStreamToAudioSourceNode(streamToAdd) {\n        const streamNodeToAdd = this.node.context.createMediaStreamSource(streamToAdd);\n        streamNodeToAdd.channelCount = 1;\n        streamNodeToAdd.channelCountMode = 'explicit';\n        this.farEndStreamToAudioSourceNode.set(streamToAdd, streamNodeToAdd);\n        streamNodeToAdd.connect(this.mixDestNode, 0);\n    }\n    createMixSourceNode() {\n        this.mixSourceNode = this.node.context.createMediaStreamSource(this.mixDestNode.stream);\n        this.mixSourceNode.channelCount = 1;\n        this.mixSourceNode.channelCountMode = 'explicit';\n        this.mixSourceNode.connect(this.node, 0, 1);\n    }\n}\nfunction isDefaultDevice(device) {\n    if (device === 'default') {\n        return true;\n    }\n    if (!device || typeof device !== 'object') {\n        return false;\n    }\n    if ('deviceId' in device && device.deviceId === 'default') {\n        return true;\n    }\n    if ('id' in device && device.id === 'default') {\n        return true;\n    }\n    return false;\n}\nexports.default = VoiceFocusTransformDevice;\n//# sourceMappingURL=VoiceFocusTransformDevice.js.map","\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** @internal */\nclass VoiceFocusTransformDeviceDelegate {\n    constructor() {\n        this.observers = new Set();\n    }\n    addObserver(observer) {\n        this.observers.add(observer);\n    }\n    removeObserver(observer) {\n        this.observers.delete(observer);\n    }\n    /** @internal */\n    onFallback(device, e) {\n        var _a;\n        for (const observer of this.observers) {\n            (_a = observer.voiceFocusFellBackToInnerStream) === null || _a === void 0 ? void 0 : _a.call(observer, device, e);\n        }\n    }\n    onCPUWarning() {\n        var _a;\n        for (const observer of this.observers) {\n            (_a = observer.voiceFocusInsufficientResources) === null || _a === void 0 ? void 0 : _a.call(observer);\n        }\n    }\n}\nexports.default = VoiceFocusTransformDeviceDelegate;\n//# sourceMappingURL=VoiceFocusTransformDeviceDelegate.js.map","\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nclass DefaultVolumeIndicatorAdapter {\n    constructor(logger, realtimeController, minVolumeDecibels, maxVolumeDecibels, selfAttendeeId) {\n        this.logger = logger;\n        this.realtimeController = realtimeController;\n        this.minVolumeDecibels = minVolumeDecibels;\n        this.maxVolumeDecibels = maxVolumeDecibels;\n        this.selfAttendeeId = selfAttendeeId;\n        this.streamIdToAttendeeId = {};\n        this.streamIdToExternalUserId = {};\n        this.warnedAboutMissingStreamIdMapping = {};\n        this.attendeeIdToStreamId = {};\n        this.sessionReconnected = false;\n    }\n    onReconnect() {\n        this.sessionReconnected = true;\n    }\n    sendRealtimeUpdatesForAudioStreamIdInfo(info) {\n        let streamIndex = 0;\n        for (const stream of info.streams) {\n            const hasAttendeeId = !!stream.attendeeId;\n            const hasExternalUserId = !!stream.externalUserId;\n            const hasMuted = stream.hasOwnProperty('muted');\n            const hasDropped = !!stream.dropped;\n            if (hasAttendeeId) {\n                if (!!this.attendeeIdToStreamId[stream.attendeeId] &&\n                    this.attendeeIdToStreamId[stream.attendeeId] < stream.audioStreamId) {\n                    delete this.attendeeIdToStreamId[stream.attendeeId];\n                }\n                this.streamIdToAttendeeId[stream.audioStreamId] = stream.attendeeId;\n                const externalUserId = hasExternalUserId ? stream.externalUserId : stream.attendeeId;\n                this.streamIdToExternalUserId[stream.audioStreamId] = externalUserId;\n                this.attendeeIdToStreamId[stream.attendeeId] = stream.audioStreamId;\n                this.realtimeController.realtimeSetAttendeeIdPresence(stream.attendeeId, true, externalUserId, false, { attendeeIndex: streamIndex++, attendeesInFrame: info.streams.length });\n            }\n            if (hasMuted) {\n                const attendeeId = this.streamIdToAttendeeId[stream.audioStreamId];\n                const externalUserId = this.streamIdToExternalUserId[stream.audioStreamId];\n                this.realtimeController.realtimeUpdateVolumeIndicator(attendeeId, null, stream.muted, null, externalUserId);\n            }\n            if (!hasAttendeeId && !hasMuted) {\n                const attendeeId = this.streamIdToAttendeeId[stream.audioStreamId];\n                if (attendeeId) {\n                    const externalUserId = this.streamIdToExternalUserId[stream.audioStreamId];\n                    delete this.streamIdToAttendeeId[stream.audioStreamId];\n                    delete this.streamIdToExternalUserId[stream.audioStreamId];\n                    delete this.warnedAboutMissingStreamIdMapping[stream.audioStreamId];\n                    if (this.attendeeIdToStreamId[attendeeId] === stream.audioStreamId) {\n                        delete this.attendeeIdToStreamId[attendeeId];\n                    }\n                    let attendeeHasNewStreamId = false;\n                    for (const otherStreamId of Object.keys(this.streamIdToAttendeeId)) {\n                        const otherStreamIdNumber = parseInt(otherStreamId);\n                        if (otherStreamIdNumber > stream.audioStreamId &&\n                            this.streamIdToAttendeeId[otherStreamIdNumber] === attendeeId) {\n                            attendeeHasNewStreamId = true;\n                            break;\n                        }\n                    }\n                    if (!attendeeHasNewStreamId) {\n                        this.realtimeController.realtimeSetAttendeeIdPresence(attendeeId, false, externalUserId, hasDropped, { attendeeIndex: streamIndex++, attendeesInFrame: info.streams.length });\n                    }\n                }\n            }\n        }\n        if (this.sessionReconnected) {\n            this.cleanUpState(info);\n            this.sessionReconnected = false;\n        }\n    }\n    cleanUpState(info) {\n        const localAttendeeIds = Object.values(this.streamIdToAttendeeId);\n        const remoteAttendeeIds = info.streams.map(stream => stream.attendeeId);\n        const deletedAttendeeIds = localAttendeeIds.filter(id => {\n            return !remoteAttendeeIds.includes(id);\n        });\n        for (const [index, deletedAttendeeId] of deletedAttendeeIds.entries()) {\n            const streamId = this.attendeeIdToStreamId[deletedAttendeeId];\n            const externalUserId = this.streamIdToExternalUserId[streamId];\n            delete this.streamIdToAttendeeId[streamId];\n            delete this.streamIdToExternalUserId[streamId];\n            delete this.warnedAboutMissingStreamIdMapping[streamId];\n            delete this.attendeeIdToStreamId[deletedAttendeeId];\n            // During reconnection, the audio info frame might not include self attendee.\n            // However, if that happens, there would be another audio info frame with the self attendee after reconnection.\n            // So we should not send leave event here for self attendee.\n            if (deletedAttendeeId === this.selfAttendeeId) {\n                this.logger.warn(`the volume indicator adapter cleans up the current attendee (presence = false) after reconnection`);\n                continue;\n            }\n            // The reconnect event does not have information whether the attendee is dropped/left.\n            // Defaulting to attendee leaving the meeting\n            this.realtimeController.realtimeSetAttendeeIdPresence(deletedAttendeeId, false, externalUserId, false, { attendeeIndex: index, attendeesInFrame: deletedAttendeeId.length });\n        }\n    }\n    sendRealtimeUpdatesForAudioMetadata(metadata) {\n        let volumes = null;\n        let signalStrengths = null;\n        for (const state of metadata.attendeeStates) {\n            const attendeeId = this.attendeeIdForStreamId(state.audioStreamId);\n            if (state.hasOwnProperty('volume')) {\n                if (volumes === null) {\n                    volumes = {};\n                }\n                if (attendeeId !== null) {\n                    // @ts-ignore: TODO fix this protobufjs issue\n                    volumes[attendeeId] = this.normalizedVolume(state);\n                }\n            }\n            if (state.hasOwnProperty('signalStrength')) {\n                if (signalStrengths === null) {\n                    signalStrengths = {};\n                }\n                if (attendeeId !== null) {\n                    // @ts-ignore: TODO fix this protobufjs issue\n                    signalStrengths[attendeeId] = this.normalizedSignalStrength(state);\n                }\n            }\n        }\n        this.applyRealtimeUpdatesForAudioMetadata(volumes, signalStrengths);\n    }\n    normalizedVolume(state) {\n        const dBVolume = -state.volume;\n        const normalized = 1.0 - (dBVolume - this.maxVolumeDecibels) / (this.minVolumeDecibels - this.maxVolumeDecibels);\n        const clipped = Math.min(Math.max(normalized, 0.0), 1.0);\n        return clipped;\n    }\n    normalizedSignalStrength(state) {\n        const normalized = state.signalStrength / DefaultVolumeIndicatorAdapter.MAX_SIGNAL_STRENGTH_LEVELS;\n        const clipped = Math.min(Math.max(normalized, 0.0), 1.0);\n        return clipped;\n    }\n    applyRealtimeUpdatesForAudioMetadata(volumes, signalStrengths) {\n        for (const streamId in this.streamIdToAttendeeId) {\n            const attendeeId = this.streamIdToAttendeeId[streamId];\n            const externalUserId = this.streamIdToExternalUserId[streamId];\n            let volumeUpdate = null;\n            let signalStrengthUpdate = null;\n            if (volumes !== null) {\n                if (volumes.hasOwnProperty(attendeeId)) {\n                    volumeUpdate = volumes[attendeeId];\n                }\n                else {\n                    volumeUpdate = DefaultVolumeIndicatorAdapter.IMPLICIT_VOLUME;\n                }\n            }\n            if (signalStrengths !== null) {\n                if (signalStrengths.hasOwnProperty(attendeeId)) {\n                    signalStrengthUpdate = signalStrengths[attendeeId];\n                }\n                else {\n                    signalStrengthUpdate = DefaultVolumeIndicatorAdapter.IMPLICIT_SIGNAL_STRENGTH;\n                }\n            }\n            if (volumeUpdate !== null || signalStrengthUpdate !== null) {\n                this.realtimeController.realtimeUpdateVolumeIndicator(attendeeId, volumeUpdate, null, signalStrengthUpdate, externalUserId);\n            }\n        }\n    }\n    attendeeIdForStreamId(streamId) {\n        if (streamId === 0) {\n            return null;\n        }\n        const attendeeId = this.streamIdToAttendeeId[streamId];\n        if (attendeeId) {\n            return attendeeId;\n        }\n        if (!this.warnedAboutMissingStreamIdMapping[streamId]) {\n            this.warnedAboutMissingStreamIdMapping[streamId] = true;\n            this.logger.warn(`volume indicator stream id ${streamId} seen before being defined`);\n        }\n        return null;\n    }\n}\nexports.default = DefaultVolumeIndicatorAdapter;\nDefaultVolumeIndicatorAdapter.MAX_SIGNAL_STRENGTH_LEVELS = 2;\nDefaultVolumeIndicatorAdapter.IMPLICIT_VOLUME = 0;\nDefaultVolumeIndicatorAdapter.IMPLICIT_SIGNAL_STRENGTH = 1;\n//# sourceMappingURL=DefaultVolumeIndicatorAdapter.js.map","\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst Versioning_1 = __importDefault(require(\"../versioning/Versioning\"));\nconst WebSocketReadyState_1 = __importDefault(require(\"./WebSocketReadyState\"));\nclass DefaultWebSocketAdapter {\n    constructor(logger) {\n        this.logger = logger;\n    }\n    create(url, protocols, isSignedUrl) {\n        this.connection = new WebSocket(isSignedUrl ? url : Versioning_1.default.urlWithVersion(url), protocols);\n        this.connection.binaryType = 'arraybuffer';\n    }\n    send(message) {\n        if (!this.connection) {\n            this.logger.error('WebSocket not yet created or already destroyed.');\n            return false;\n        }\n        try {\n            if (message instanceof Uint8Array) {\n                this.connection.send(message.buffer);\n            }\n            else {\n                this.connection.send(message);\n            }\n            return true;\n        }\n        catch (err) {\n            this.logger.debug(() => `send error: ${err.message}, websocket state=${WebSocketReadyState_1.default[this.readyState()]}`);\n            return false;\n        }\n    }\n    close(code, reason) {\n        var _a;\n        (_a = this.connection) === null || _a === void 0 ? void 0 : _a.close(code, reason);\n    }\n    destroy() {\n        this.connection = undefined;\n    }\n    addEventListener(handler, eventListener) {\n        /* istanbul ignore if */\n        if (!this.connection) {\n            this.logger.warn('Cannot add event listener with no WebSocket connection.');\n            return;\n        }\n        this.connection.addEventListener(handler, eventListener);\n    }\n    removeEventListener(handler, eventListener) {\n        var _a;\n        (_a = this.connection) === null || _a === void 0 ? void 0 : _a.removeEventListener(handler, eventListener);\n    }\n    readyState() {\n        if (!this.connection) {\n            return WebSocketReadyState_1.default.None;\n        }\n        switch (this.connection.readyState) {\n            case WebSocket.CONNECTING:\n                return WebSocketReadyState_1.default.Connecting;\n            case WebSocket.OPEN:\n                return WebSocketReadyState_1.default.Open;\n            case WebSocket.CLOSING:\n                return WebSocketReadyState_1.default.Closing;\n            case WebSocket.CLOSED:\n                return WebSocketReadyState_1.default.Closed;\n        }\n    }\n}\nexports.default = DefaultWebSocketAdapter;\n//# sourceMappingURL=DefaultWebSocketAdapter.js.map","\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.WebSocketReadyState = void 0;\nvar WebSocketReadyState;\n(function (WebSocketReadyState) {\n    WebSocketReadyState[WebSocketReadyState[\"None\"] = 0] = \"None\";\n    WebSocketReadyState[WebSocketReadyState[\"Connecting\"] = 1] = \"Connecting\";\n    WebSocketReadyState[WebSocketReadyState[\"Open\"] = 2] = \"Open\";\n    WebSocketReadyState[WebSocketReadyState[\"Closing\"] = 3] = \"Closing\";\n    WebSocketReadyState[WebSocketReadyState[\"Closed\"] = 4] = \"Closed\";\n})(WebSocketReadyState = exports.WebSocketReadyState || (exports.WebSocketReadyState = {}));\nexports.default = WebSocketReadyState;\n//# sourceMappingURL=WebSocketReadyState.js.map"],"names":[],"sourceRoot":""}