"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.checkoutForm = void 0;
var _helpers = require("./helpers");
var _legacy = require("../helpers/legacy");
const checkoutForm = function () {
  let {
    instances = [],
    response: {
      tracking = {}
    } = {},
    store: {
      finder = {},
      id,
      type
    } = {}
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  // ! -- TODO: use of tracking should be a temporary approach ---------------------------------------------------------
  const {
    hotelInfo = {},
    reservedExtras = {},
    reservedRooms = [],
    totalPriceWithoutTaxes
  } = tracking;
  const {
    promocode = ''
  } = finder;
  const value = {
    coupon: promocode,
    items: (0, _helpers.parseItems)({
      finder,
      hotelInfo,
      id,
      reservedExtras,
      reservedRooms,
      type
    }),
    send_to: instances.map(function () {
      let {
        idAnalytics
      } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      return idAnalytics;
    }),
    value: (0, _legacy.formatPrice)(totalPriceWithoutTaxes, hotelInfo.currency)
  };
  window.gtag('event', 'add_payment_info', value);
  return value;
};
exports.checkoutForm = checkoutForm;
//# sourceMappingURL=checkoutForm.js.map