"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SCRIPTS = void 0;
var _helpers = require("./helpers");
var _Core = require("../../Core.constants");
const SCRIPTS = exports.SCRIPTS = {
  [_Core.PERFORMANCE.AFFILIRED]: {
    components: ['booking'],
    init: () => ({
      src: 'https://scripts.affilired.com/v2/tracking.php'
    }),
    once: true
  },
  [_Core.PERFORMANCE.ANALYTICS]: {
    init: function () {
      let {
        idAnalytics,
        index,
        gtgEnabled
      } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      return {
        src: gtgEnabled ? (0, _helpers.gtgSrc)('ga4', index) : "https://www.googletagmanager.com/gtag/js?id=".concat(idAnalytics),
        onLoad: () => {
          window.dataLayer = window.dataLayer || [];
          window.gtag = function () {
            window.dataLayer.push(arguments);
          };
          window.gtag('js', new Date());
          window.gtag('config', idAnalytics, {
            linker: {
              accept_incoming: true
            }
          });
        }
      };
    }
  },
  [_Core.PERFORMANCE.BING]: {
    init: _ref => {
      let {
        idBing
      } = _ref;
      return {
        src: '//bat.bing.com/bat.js',
        onLoad: () => {
          const uetq = "uetq_".concat(idBing);
          // eslint-disable-next-line no-undef
          window[uetq] = new UET({
            ti: idBing,
            q: window[uetq] || []
          });
          window[uetq].push('consent', 'update', {
            ad_storage: 'granted'
          });
          window[uetq].push('pageLoad');
        }
      };
    }
  },
  [_Core.PERFORMANCE.COMPARE]: {
    components: ['rates', 'checkout', 'booking'],
    init: () => ({
      src: 'https://static.hotelmonitor.info/CmprmInit-min.js',
      onLoad: () => {
        document.addEventListener('CmprmInitLoaded', window.CmprmInit.InitMirai, false);
      }
    }),
    once: true
  },
  [_Core.PERFORMANCE.GOOGLE_ADS]: {
    init: function () {
      let {
        cookiePrefix,
        idAdwords,
        index,
        gtgEnabled,
        loadedComponents = []
      } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      return {
        src: gtgEnabled ? (0, _helpers.gtgSrc)('ads', index) : "https://www.googletagmanager.com/gtag/js?id=AW-".concat(idAdwords),
        onLoad: () => {
          window.dataLayer = window.dataLayer || [];
          window.gtag = function () {
            window.dataLayer.push(arguments);
          };
          window.gtag('config', "AW-".concat(idAdwords), {
            conversion_cookie_prefix: cookiePrefix,
            allow_enhanced_conversions: loadedComponents.includes('booking')
          });
        }
      };
    }
  },
  [_Core.PERFORMANCE.GTM]: {
    init: function () {
      let {
        idGTM: id,
        index,
        gtgEnabled
      } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      return {
        src: gtgEnabled ? (0, _helpers.gtgSrc)('gtm', index) : "https://www.googletagmanager.com/gtm.js?id=".concat(id),
        onLoad: () => {
          window.dataLayer = window.dataLayer || [];
          (0, _helpers.dataLayerPush)({
            event: 'gtm.js',
            'gtm.start': new Date().getTime()
          });
        }
      };
    }
  },
  [_Core.PERFORMANCE.FACEBOOK]: {
    components: ['rates', 'checkout', 'booking']
  },
  [_Core.PERFORMANCE.MIRAI]: {
    init: function () {
      let {
        hotel: {
          id
        } = {},
        instanceId,
        loadedComponents,
        place: {
          id: [hotelId] = [],
          isHotel
        } = {}
      } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      return {
        src: "https://metas.mirai.com/connectivity/gtag/b2c?hotelId=".concat(isHotel && hotelId && !loadedComponents.includes('finder') ? hotelId : id || instanceId)
      };
    },
    once: true
  },
  [_Core.PERFORMANCE.THE_HOTEL_NETWORK]: {
    init: _ref2 => {
      let {
        id = '7'
      } = _ref2;
      return {
        src: "https://www.thehotelsnetwork.com/js/hotel_price_widget.js?partnership_id=".concat(id)
      };
    }
  }
};
//# sourceMappingURL=PerformanceManager.scripts.js.map