// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { getDeviceManager, getIncomingCalls, getRemovedIncomingCalls } from './baseSelectors';
import { createSelector } from 'reselect';
import { isPhoneNumberIdentifier } from '@azure/communication-common';
/**
 * Select the active and removed incoming calls from the stateful client for the IncomingCallNotificationStackComponent.
 * @public
 */
export const incomingCallStackSelector = createSelector([getIncomingCalls, getRemovedIncomingCalls, getDeviceManager], (incomingCalls, removedIncomingCalls, deviceManager) => {
    // Convert incoming call state to active incoming call
    const componentIncomingCalls = incomingCalls.map((incomingCall) => {
        return Object.assign(Object.assign({}, incomingCall), { callerInfo: {
                displayName: incomingCall.callerInfo.displayName || 'Unknown Caller'
            }, videoAvailable: incomingCall.callerInfo.identifier && isPhoneNumberIdentifier(incomingCall.callerInfo.identifier) || (deviceManager === null || deviceManager === void 0 ? void 0 : deviceManager.cameras.length) === 0 ? false : true });
    });
    const componentRemovedIncomingCalls = removedIncomingCalls.map((incomingCall) => {
        return Object.assign(Object.assign({}, incomingCall), { callerInfo: {
                displayName: incomingCall.callerInfo.displayName || 'Unknown Caller'
            }, videoAvailable: incomingCall.callerInfo.identifier && isPhoneNumberIdentifier(incomingCall.callerInfo.identifier) || (deviceManager === null || deviceManager === void 0 ? void 0 : deviceManager.cameras.length) === 0 ? false : true });
    });
    return {
        activeIncomingCalls: componentIncomingCalls,
        removedIncomingCalls: componentRemovedIncomingCalls
    };
});
//# sourceMappingURL=incomingCallStackSelector.js.map