"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 _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
    _ref$instances = _ref.instances,
    instances = _ref$instances === void 0 ? [] : _ref$instances,
    _ref$response = _ref.response,
    _ref$response2 = _ref$response === void 0 ? {} : _ref$response,
    _ref$response2$tracki = _ref$response2.tracking,
    tracking = _ref$response2$tracki === void 0 ? {} : _ref$response2$tracki,
    _ref$store = _ref.store,
    _ref$store2 = _ref$store === void 0 ? {} : _ref$store,
    _ref$store2$finder = _ref$store2.finder,
    finder = _ref$store2$finder === void 0 ? {} : _ref$store2$finder,
    id = _ref$store2.id,
    type = _ref$store2.type;
  // ! -- TODO: use of tracking should be a temporary approach ---------------------------------------------------------
  const _tracking$hotelInfo = tracking.hotelInfo,
    hotelInfo = _tracking$hotelInfo === void 0 ? {} : _tracking$hotelInfo,
    _tracking$reservedExt = tracking.reservedExtras,
    reservedExtras = _tracking$reservedExt === void 0 ? {} : _tracking$reservedExt,
    _tracking$reservedRoo = tracking.reservedRooms,
    reservedRooms = _tracking$reservedRoo === void 0 ? [] : _tracking$reservedRoo,
    totalPriceWithoutTaxes = tracking.totalPriceWithoutTaxes;
  const _finder$promocode = finder.promocode,
    promocode = _finder$promocode === void 0 ? '' : _finder$promocode;
  const value = {
    coupon: promocode,
    items: (0, _helpers.parseItems)({
      finder,
      hotelInfo,
      id,
      reservedExtras,
      reservedRooms,
      type
    }),
    send_to: instances.map(function () {
      let _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
        idAnalytics = _ref2.idAnalytics;
      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