"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Analytics = void 0;
/**
 * Abstract class used to transform roomstay data into either GA4 or UA analytics events
 *
 * All logging still happens from the {@link DataLayer} class.
 */
class Analytics {
    constructor() {
        this.currency = { original: '', current: '' };
        this.itemListName = '';
        /**
         * Merges the current user's data (user_id) into the provided input object.
         * Ensures the resulting object always includes user_id when available.
         */
        this.withUserData = (input) => {
            return Object.assign(Object.assign({}, input), (('ecommerce' in input || input.event === 'login') && Object.assign({}, this.getUserData())));
        };
    }
    initialise(company, hotel) {
        this.company = company;
        this.hotel = hotel;
    }
    setUserId(id) {
        this.userId = id;
    }
    setItemListName(itemListName) {
        this.itemListName = itemListName || '';
    }
    // Returns an object containing the current user_id if available.
    getUserData() {
        return this.userId ? { user_id: this.userId } : {};
    }
    updateCurrency(current, original) {
        this.currency = { current, original };
    }
    generateRefundMessageObjectByReservationNumber(reservationNumber) {
        return {
            event: 'refund',
            ecommerce: {
                refund: {
                    actionField: {
                        id: reservationNumber,
                    },
                },
            },
        };
    }
}
exports.Analytics = Analytics;
//# sourceMappingURL=Analytics.js.map