"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.bookingResponse = void 0;
var _helpers = require("../helpers");
var _legacy = require("../helpers/legacy");
const PURCHASE = 'purchase';
const bookingResponse = function () {
  let {
    instances = [],
    response: {
      tracking = {}
    } = {}
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  // ! -- TODO: use of tracking should be a temporary approach ---------------------------------------------------------
  const {
    guestData: {
      email
    } = {},
    hotelInfo: {
      currency: hotelCurrency = {}
    } = {},
    totalPriceWithoutTaxes
  } = tracking;
  const value = {
    event_label: PURCHASE,
    event_category: PURCHASE,
    revenue_value: (0, _legacy.formatPrice)(totalPriceWithoutTaxes, hotelCurrency),
    currency: hotelCurrency.code
  };
  instances.forEach(function () {
    let {
      idBing = ''
    } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    const uetq = "uetq_".concat(idBing);
    window[uetq] = window[uetq] || [];
    window[uetq].push('set', {
      pid: {
        em: (0, _helpers.SHA256)(email)
      }
    });
    window[uetq].push('event', PURCHASE, value);
  });
  return value;
};
exports.bookingResponse = bookingResponse;
//# sourceMappingURL=bookingResponse.js.map