/**
 * Sorts the captions and real time texts based on their timestamp.
 *
 * @private
 */
export function sortCaptionsAndRealTimeTexts(captions, realTimeTexts) {
    const combinedList = [...(Array.isArray(captions) ? captions.map(caption => (Object.assign({}, caption))) : []), ...(realTimeTexts ? realTimeTexts.map(realTimeText => (Object.assign({}, realTimeText))) : [])];
    // Sort the combined list by comparing caption's timestamp with realTimeText's updatedTimestamp
    combinedList.sort((a, b) => {
        var _a, _b;
        const timestampA = 'captionText' in a ? new Date((_a = a.createdTimeStamp) !== null && _a !== void 0 ? _a : 0).getTime() : new Date(a.finalizedTimeStamp).getTime();
        const timestampB = 'captionText' in b ? new Date((_b = b.createdTimeStamp) !== null && _b !== void 0 ? _b : 0).getTime() : new Date(b.finalizedTimeStamp).getTime();
        return timestampA - timestampB;
    });
    return combinedList;
}
//# sourceMappingURL=sortCaptionsAndRealTimeTexts.js.map