"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.SuggestionsBIReporter = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _bi = require("@wix/bex-core/bi");
var _http = require("@wix/bex-utils/@wix/ambassador-dealer-v1-offer-event/http");
var _types = require("@wix/bex-utils/@wix/ambassador-dealer-v1-offer-event/types");
class SuggestionsBIReporter {
  constructor(params) {
    (0, _defineProperty2.default)(this, "reportBI", void 0);
    (0, _defineProperty2.default)(this, "httpClient", void 0);
    (0, _defineProperty2.default)(this, "realEstateId", void 0);
    this.reportBI = params.reportBI;
    this.realEstateId = params.realEstateId;
    this.httpClient = params.httpClient;
  }
  loadStart() {
    this.reportBI((0, _bi.loadStart)({}));
  }
  loadEnd(startTime) {
    this.reportBI((0, _bi.loadEnd)({
      loadingTime: Math.round(performance.now() - startTime)
    }));
  }
  reportOfferViewed(offerId) {
    this.httpClient.request((0, _http.reportEvent)({
      event: {
        type: _types.EventType.VIEW,
        offerId,
        realEstateId: this.realEstateId
      }
    }));
  }
  reportOfferClicked(offerId, targetUrl) {
    this.httpClient.request((0, _http.reportEvent)({
      event: {
        type: _types.EventType.MAIN_CTA_CLICK,
        offerId,
        realEstateId: this.realEstateId,
        mainCtaClick: {
          targetUrl: targetUrl ?? ''
        }
      }
    }));
  }
}
exports.SuggestionsBIReporter = SuggestionsBIReporter;
//# sourceMappingURL=SuggestionsBIReporter.js.map