@liquidcommercedev/rmn-sdk 1.5.0-beta.34 → 1.5.0-beta.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -84,38 +84,6 @@ exports.RMN_ENV = void 0;
84
84
  RMN_ENV["PRODUCTION"] = "production";
85
85
  })(exports.RMN_ENV || (exports.RMN_ENV = {}));
86
86
 
87
- /******************************************************************************
88
- Copyright (c) Microsoft Corporation.
89
-
90
- Permission to use, copy, modify, and/or distribute this software for any
91
- purpose with or without fee is hereby granted.
92
-
93
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
94
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
95
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
96
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
97
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
98
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
99
- PERFORMANCE OF THIS SOFTWARE.
100
- ***************************************************************************** */
101
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
102
-
103
-
104
- function __awaiter(thisArg, _arguments, P, generator) {
105
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
106
- return new (P || (P = Promise))(function (resolve, reject) {
107
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
108
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
109
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
110
- step((generator = generator.apply(thisArg, _arguments || [])).next());
111
- });
112
- }
113
-
114
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
115
- var e = new Error(message);
116
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
117
- };
118
-
119
87
  const REQUEST_CLOUD_PARTNER_SITE = 'X-Liquid-Partner-Site';
120
88
  const REQUEST_CLOUD_PROTECTED_KEY = 'X-Liquid-Protected';
121
89
  const REQUEST_CLOUD_PROTECTED_TIMESTAMP = 'X-Liquid-Timestamp';
@@ -7405,22 +7373,53 @@ const GENERAL_PUNCTUATION_MAP = {
7405
7373
  const OTHERS_MAP = {
7406
7374
  Nº: 'No',
7407
7375
  };
7408
- const SPECIAL_CHARS_MAP = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, LATIN_MAP), SYMBOLS_MAP), GREEK_MAP), TURKISH_MAP), GERMAN_MAP), ROMANIAN_MAP), RUSSIAN_MAP), UKRAINIAN_MAP), CZECH_MAP), GEORGIAN_MAP), ITALIAN_MAP), FRENCH_MAP), PORTUGUESE_MAP), NORDIC_MAP), HUNGARIAN_MAP), VIETNAMESE_MAP), CROATIOAN_SEERBIAN_MAP), BALLTIC_MAP), CHINESE_JAPANESE_PUNCTUATION_MAP), SPANISH_MAP), SLOVAK_MAP), POLISH_MAP), LATVIAN_MAP), ARABIC_MAP), LITHUANIAN_MAP), SERBIAN_MAP), AZERBAIJANI_MAP), GEORGIAN_MAP), GEOMETRIC_SHAPES_MAP), BLOCK_ELEMENTS_MAP), BOX_DRAWING_MAP), OPTICAL_CHARACTER_RECOGNITION_MAP), CONTROL_PICTURES_MAP), MISCELLANEOUS_TECHNICAL_MAP), MATHEMATICAL_OPERATORS_MAP), SUBSCRIPTS_AND_SUPERSCRIPTS_MAP), NUMBER_FORMS_MAP), LETTERLIKE_SYMBOLS_MAP), CURRENCY_SYMBOLS_MAP), COMBINING_DIACRITICAL_MARKS_MAP), GENERAL_PUNCTUATION_MAP), OTHERS_MAP);
7376
+ const SPECIAL_CHARS_MAP = {
7377
+ ...LATIN_MAP,
7378
+ ...SYMBOLS_MAP,
7379
+ ...GREEK_MAP,
7380
+ ...TURKISH_MAP,
7381
+ ...GERMAN_MAP,
7382
+ ...ROMANIAN_MAP,
7383
+ ...RUSSIAN_MAP,
7384
+ ...UKRAINIAN_MAP,
7385
+ ...CZECH_MAP,
7386
+ ...GEORGIAN_MAP,
7387
+ ...ITALIAN_MAP,
7388
+ ...FRENCH_MAP,
7389
+ ...PORTUGUESE_MAP,
7390
+ ...NORDIC_MAP,
7391
+ ...HUNGARIAN_MAP,
7392
+ ...VIETNAMESE_MAP,
7393
+ ...CROATIOAN_SEERBIAN_MAP,
7394
+ ...BALLTIC_MAP,
7395
+ ...CHINESE_JAPANESE_PUNCTUATION_MAP,
7396
+ ...SPANISH_MAP,
7397
+ ...SLOVAK_MAP,
7398
+ ...POLISH_MAP,
7399
+ ...LATVIAN_MAP,
7400
+ ...ARABIC_MAP,
7401
+ ...LITHUANIAN_MAP,
7402
+ ...SERBIAN_MAP,
7403
+ ...AZERBAIJANI_MAP,
7404
+ ...GEORGIAN_MAP,
7405
+ ...GEOMETRIC_SHAPES_MAP,
7406
+ ...BLOCK_ELEMENTS_MAP,
7407
+ ...BOX_DRAWING_MAP,
7408
+ ...OPTICAL_CHARACTER_RECOGNITION_MAP,
7409
+ ...CONTROL_PICTURES_MAP,
7410
+ ...MISCELLANEOUS_TECHNICAL_MAP,
7411
+ ...MATHEMATICAL_OPERATORS_MAP,
7412
+ ...SUBSCRIPTS_AND_SUPERSCRIPTS_MAP,
7413
+ ...NUMBER_FORMS_MAP,
7414
+ ...LETTERLIKE_SYMBOLS_MAP,
7415
+ ...CURRENCY_SYMBOLS_MAP,
7416
+ ...COMBINING_DIACRITICAL_MARKS_MAP,
7417
+ ...GENERAL_PUNCTUATION_MAP,
7418
+ ...OTHERS_MAP,
7419
+ };
7409
7420
 
7410
7421
  class NormalizeStringHelper {
7411
7422
  constructor() {
7412
- Object.defineProperty(this, "characterMaps", {
7413
- enumerable: true,
7414
- configurable: true,
7415
- writable: true,
7416
- value: void 0
7417
- });
7418
- Object.defineProperty(this, "regex", {
7419
- enumerable: true,
7420
- configurable: true,
7421
- writable: true,
7422
- value: void 0
7423
- });
7424
7423
  this.characterMaps = SPECIAL_CHARS_MAP;
7425
7424
  this.regex = new RegExp(Object.keys(this.characterMaps).join('|'), 'g');
7426
7425
  }
@@ -7486,12 +7485,7 @@ class SingletonManager {
7486
7485
  return instance;
7487
7486
  }
7488
7487
  }
7489
- Object.defineProperty(SingletonManager, "instances", {
7490
- enumerable: true,
7491
- configurable: true,
7492
- writable: true,
7493
- value: new Map()
7494
- });
7488
+ SingletonManager.instances = new Map();
7495
7489
 
7496
7490
  class ObjectHelper {
7497
7491
  /**
@@ -7619,7 +7613,7 @@ class ObjectHelper {
7619
7613
  this.innerMerge(targetValue, value);
7620
7614
  return targetValue;
7621
7615
  }
7622
- return value ? Object.assign({}, value) : value;
7616
+ return value ? { ...value } : value;
7623
7617
  }
7624
7618
  /**
7625
7619
  * Merges the properties of the source object into the target object.
@@ -7637,31 +7631,29 @@ class ObjectHelper {
7637
7631
  }
7638
7632
 
7639
7633
  // Fallback method using fetch if sendBeacon isn't available
7640
- function fallbackEventFire(url) {
7641
- return __awaiter(this, void 0, void 0, function* () {
7642
- try {
7643
- const racePromise = Promise.race([
7644
- // Promise #1: The fetch request
7645
- fetch(url, {
7646
- method: 'POST',
7647
- keepalive: true,
7648
- }),
7649
- // Promise #2: The timeout
7650
- new Promise((_, reject) => setTimeout(() => reject(new Error('Request timeout')), 2000)),
7651
- ]);
7652
- /**
7653
- * Prevent requests from hanging indefinitely
7654
- * Improve user experience by failing fast
7655
- * Handle slow network conditions gracefully
7656
- * Ensure resources are freed up in a timely manner
7657
- */
7658
- const response = yield racePromise;
7659
- return response.ok;
7660
- }
7661
- catch (_a) {
7662
- return false;
7663
- }
7664
- });
7634
+ async function fallbackEventFire(url) {
7635
+ try {
7636
+ const racePromise = Promise.race([
7637
+ // Promise #1: The fetch request
7638
+ fetch(url, {
7639
+ method: 'POST',
7640
+ keepalive: true,
7641
+ }),
7642
+ // Promise #2: The timeout
7643
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Request timeout')), 2000)),
7644
+ ]);
7645
+ /**
7646
+ * Prevent requests from hanging indefinitely
7647
+ * Improve user experience by failing fast
7648
+ * Handle slow network conditions gracefully
7649
+ * Ensure resources are freed up in a timely manner
7650
+ */
7651
+ const response = await racePromise;
7652
+ return response.ok;
7653
+ }
7654
+ catch (_a) {
7655
+ return false;
7656
+ }
7665
7657
  }
7666
7658
  /**
7667
7659
  * Helper function to decode base64 string and parse JSON
@@ -7718,26 +7710,24 @@ function getRedirectUrlFromPayload(url) {
7718
7710
  * @param {string} params.eventUrl - The URL to which the event is sent.
7719
7711
  * @returns {Promise<void>} - A promise that resolves when the event is fired.
7720
7712
  */
7721
- function fireEvent(_a) {
7722
- return __awaiter(this, arguments, void 0, function* ({ spotType, event, eventUrl }) {
7723
- var _b;
7724
- try {
7725
- const didFireEvent = ((_b = navigator === null || navigator === void 0 ? void 0 : navigator.sendBeacon) === null || _b === void 0 ? void 0 : _b.call(navigator, eventUrl)) || (yield fallbackEventFire(eventUrl));
7726
- if (!didFireEvent) {
7727
- return;
7728
- }
7729
- // Redirect user if the event is a click event
7730
- if (event === exports.RMN_SPOT_EVENT.CLICK && spotType !== exports.RMN_SPOT_TYPE.RB_VIDEO_PLAYER) {
7731
- const redirectUrl = getRedirectUrlFromPayload(eventUrl);
7732
- if (redirectUrl) {
7733
- window.location.href = redirectUrl;
7734
- }
7735
- }
7713
+ async function fireEvent({ spotType, event, eventUrl }) {
7714
+ var _a;
7715
+ try {
7716
+ const didFireEvent = ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.sendBeacon) === null || _a === void 0 ? void 0 : _a.call(navigator, eventUrl)) || (await fallbackEventFire(eventUrl));
7717
+ if (!didFireEvent) {
7718
+ return;
7736
7719
  }
7737
- catch (_c) {
7738
- // Handle errors silently
7720
+ // Redirect user if the event is a click event
7721
+ if (event === exports.RMN_SPOT_EVENT.CLICK && spotType !== exports.RMN_SPOT_TYPE.RB_VIDEO_PLAYER) {
7722
+ const redirectUrl = getRedirectUrlFromPayload(eventUrl);
7723
+ if (redirectUrl) {
7724
+ window.location.href = redirectUrl;
7725
+ }
7739
7726
  }
7740
- });
7727
+ }
7728
+ catch (_b) {
7729
+ // Handle errors silently
7730
+ }
7741
7731
  }
7742
7732
  function calculateScaleFactor(elementScale) {
7743
7733
  // Step 1: Apply square root for non-linear scaling
@@ -7912,44 +7902,14 @@ class UniqueIdGenerator {
7912
7902
  }
7913
7903
  }
7914
7904
  // Constants for bit manipulation
7915
- Object.defineProperty(UniqueIdGenerator, "epoch", {
7916
- enumerable: true,
7917
- configurable: true,
7918
- writable: true,
7919
- value: 1577836800000
7920
- }); // 2020-01-01 as epoch
7921
- Object.defineProperty(UniqueIdGenerator, "nodeBits", {
7922
- enumerable: true,
7923
- configurable: true,
7924
- writable: true,
7925
- value: 10
7926
- });
7927
- Object.defineProperty(UniqueIdGenerator, "sequenceBits", {
7928
- enumerable: true,
7929
- configurable: true,
7930
- writable: true,
7931
- value: 12
7932
- });
7905
+ UniqueIdGenerator.epoch = 1577836800000; // 2020-01-01 as epoch
7906
+ UniqueIdGenerator.nodeBits = 10;
7907
+ UniqueIdGenerator.sequenceBits = 12;
7933
7908
  // Instance variables
7934
- Object.defineProperty(UniqueIdGenerator, "lastTimestamp", {
7935
- enumerable: true,
7936
- configurable: true,
7937
- writable: true,
7938
- value: -1
7939
- });
7940
- Object.defineProperty(UniqueIdGenerator, "sequence", {
7941
- enumerable: true,
7942
- configurable: true,
7943
- writable: true,
7944
- value: 0
7945
- });
7909
+ UniqueIdGenerator.lastTimestamp = -1;
7910
+ UniqueIdGenerator.sequence = 0;
7946
7911
  // Character set for base32 encoding (excluding similar looking characters)
7947
- Object.defineProperty(UniqueIdGenerator, "base32Chars", {
7948
- enumerable: true,
7949
- configurable: true,
7950
- writable: true,
7951
- value: '0123456789ABCDEFGHJKMNPQRSTVWXYZ'
7952
- });
7912
+ UniqueIdGenerator.base32Chars = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
7953
7913
 
7954
7914
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
7955
7915
 
@@ -16698,18 +16658,6 @@ class SignJWT extends ProduceJWT {
16698
16658
  class ApiError {
16699
16659
  constructor(error) {
16700
16660
  var _a, _b, _c, _d, _e, _f, _g;
16701
- Object.defineProperty(this, "cause", {
16702
- enumerable: true,
16703
- configurable: true,
16704
- writable: true,
16705
- value: void 0
16706
- });
16707
- Object.defineProperty(this, "errorMessage", {
16708
- enumerable: true,
16709
- configurable: true,
16710
- writable: true,
16711
- value: void 0
16712
- });
16713
16661
  const e = error;
16714
16662
  this.cause = (_d = (_b = (_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.data.statusCode) !== null && _b !== void 0 ? _b : (_c = e === null || e === void 0 ? void 0 : e.response) === null || _c === void 0 ? void 0 : _c.status) !== null && _d !== void 0 ? _d : 0;
16715
16663
  this.errorMessage =
@@ -16719,12 +16667,6 @@ class ApiError {
16719
16667
 
16720
16668
  class EncryptedApi {
16721
16669
  constructor(apiKey) {
16722
- Object.defineProperty(this, "apiKey", {
16723
- enumerable: true,
16724
- configurable: true,
16725
- writable: true,
16726
- value: void 0
16727
- });
16728
16670
  this.apiKey = apiKey;
16729
16671
  }
16730
16672
  /**
@@ -16742,19 +16684,17 @@ class EncryptedApi {
16742
16684
  * @param {number} LT - The LT (Lifetime) value used for encryption.
16743
16685
  * @returns {Promise<string | undefined>} - The encrypted data as a string, or undefined if encryption fails.
16744
16686
  */
16745
- handleEncryption(data, LT) {
16746
- return __awaiter(this, void 0, void 0, function* () {
16747
- const key = this.getKey(LT);
16748
- try {
16749
- return this.joseEncrypt(data, key, this.forwardInMinutes(30, LT));
16750
- }
16751
- catch (_a) {
16752
- this.handleError({
16753
- cause: 'Payload decryption error',
16754
- message: 'The decryption of the payload failed',
16755
- });
16756
- }
16757
- });
16687
+ async handleEncryption(data, LT) {
16688
+ const key = this.getKey(LT);
16689
+ try {
16690
+ return this.joseEncrypt(data, key, this.forwardInMinutes(30, LT));
16691
+ }
16692
+ catch (_a) {
16693
+ this.handleError({
16694
+ cause: 'Payload decryption error',
16695
+ message: 'The decryption of the payload failed',
16696
+ });
16697
+ }
16758
16698
  }
16759
16699
  /**
16760
16700
  * Decrypts the given data using a key generated based on LT.
@@ -16763,11 +16703,9 @@ class EncryptedApi {
16763
16703
  * @param {number} LT - The LT value used to generate the decryption key.
16764
16704
  * @return {Promise<JWTVerifyResult>} A promise that resolves with the decrypted data.
16765
16705
  */
16766
- handleDecryption(data, LT) {
16767
- return __awaiter(this, void 0, void 0, function* () {
16768
- const key = this.getKey(LT);
16769
- return this.joseDecrypt(data, key);
16770
- });
16706
+ async handleDecryption(data, LT) {
16707
+ const key = this.getKey(LT);
16708
+ return this.joseDecrypt(data, key);
16771
16709
  }
16772
16710
  /**
16773
16711
  * Returns the key based on the given LT value.
@@ -16796,13 +16734,11 @@ class EncryptedApi {
16796
16734
  * @param {string} key - The key used for decryption.
16797
16735
  * @return {Promise<JWTVerifyResult>} A Promise that resolves to the decrypted JWT payload.
16798
16736
  */
16799
- joseDecrypt(data, key) {
16800
- return __awaiter(this, void 0, void 0, function* () {
16801
- // Decrypt and format payload back to string
16802
- const decryptedString = cryptoJsExports.AES.decrypt(data, key).toString(cryptoJsExports.enc.Utf8);
16803
- // Allow decoding only if secret is matching
16804
- return jwtVerify(decryptedString, Buffer.from(key));
16805
- });
16737
+ async joseDecrypt(data, key) {
16738
+ // Decrypt and format payload back to string
16739
+ const decryptedString = cryptoJsExports.AES.decrypt(data, key).toString(cryptoJsExports.enc.Utf8);
16740
+ // Allow decoding only if secret is matching
16741
+ return jwtVerify(decryptedString, Buffer.from(key));
16806
16742
  }
16807
16743
  /**
16808
16744
  * Encrypts and signs the given data using the JOSE encryption standard.
@@ -16811,18 +16747,16 @@ class EncryptedApi {
16811
16747
  * @param {Date | number} exp - The expiration time for the encrypted data.
16812
16748
  * @returns {Promise<string>} - The encrypted and signed data as a string.
16813
16749
  */
16814
- joseEncrypt(data, key, exp) {
16815
- return __awaiter(this, void 0, void 0, function* () {
16816
- // Encode and sign data
16817
- const currentDate = new Date();
16818
- const token = new SignJWT(data)
16819
- .setProtectedHeader({ alg: 'HS256' })
16820
- .setIssuedAt(currentDate.getTime())
16821
- .setExpirationTime(exp);
16822
- const signedToken = yield token.sign(Buffer.from(key));
16823
- // Encrypt and format payload
16824
- return cryptoJsExports.AES.encrypt(signedToken, key).toString();
16825
- });
16750
+ async joseEncrypt(data, key, exp) {
16751
+ // Encode and sign data
16752
+ const currentDate = new Date();
16753
+ const token = new SignJWT(data)
16754
+ .setProtectedHeader({ alg: 'HS256' })
16755
+ .setIssuedAt(currentDate.getTime())
16756
+ .setExpirationTime(exp);
16757
+ const signedToken = await token.sign(Buffer.from(key));
16758
+ // Encrypt and format payload
16759
+ return cryptoJsExports.AES.encrypt(signedToken, key).toString();
16826
16760
  }
16827
16761
  /**
16828
16762
  * Handles the error by throwing an ApiError.
@@ -16839,36 +16773,6 @@ class BaseApi extends BaseApiAbstract {
16839
16773
  constructor(auth) {
16840
16774
  var _a;
16841
16775
  super();
16842
- Object.defineProperty(this, "authInfo", {
16843
- enumerable: true,
16844
- configurable: true,
16845
- writable: true,
16846
- value: void 0
16847
- });
16848
- Object.defineProperty(this, "baseUrl", {
16849
- enumerable: true,
16850
- configurable: true,
16851
- writable: true,
16852
- value: void 0
16853
- });
16854
- Object.defineProperty(this, "objectHelper", {
16855
- enumerable: true,
16856
- configurable: true,
16857
- writable: true,
16858
- value: void 0
16859
- });
16860
- Object.defineProperty(this, "encryptedApi", {
16861
- enumerable: true,
16862
- configurable: true,
16863
- writable: true,
16864
- value: void 0
16865
- });
16866
- Object.defineProperty(this, "client", {
16867
- enumerable: true,
16868
- configurable: true,
16869
- writable: true,
16870
- value: void 0
16871
- });
16872
16776
  this.authInfo = auth;
16873
16777
  this.encryptedApi = EncryptedApi.getInstance(this.authInfo.apiKey);
16874
16778
  this.objectHelper = ObjectHelper.getInstance();
@@ -16881,7 +16785,10 @@ class BaseApi extends BaseApiAbstract {
16881
16785
  if (partnerSite && isPartnerSiteValid) {
16882
16786
  configHeaders[REQUEST_CLOUD_PARTNER_SITE] = partnerSite;
16883
16787
  }
16884
- this.client = axios.create(Object.assign({ baseURL: this.baseUrl }, this.getConfig(configHeaders)));
16788
+ this.client = axios.create({
16789
+ baseURL: this.baseUrl,
16790
+ ...this.getConfig(configHeaders),
16791
+ });
16885
16792
  }
16886
16793
  getPartnerSite() {
16887
16794
  if (typeof window !== 'undefined' && window.location) {
@@ -16897,7 +16804,11 @@ class BaseApi extends BaseApiAbstract {
16897
16804
  */
16898
16805
  getConfig(headers) {
16899
16806
  return {
16900
- headers: Object.assign({ 'Content-Type': 'application/json', [REQUEST_CLOUD_API_ENV]: this.authInfo.env }, headers),
16807
+ headers: {
16808
+ 'Content-Type': 'application/json',
16809
+ [REQUEST_CLOUD_API_ENV]: this.authInfo.env,
16810
+ ...headers,
16811
+ },
16901
16812
  };
16902
16813
  }
16903
16814
  /**
@@ -16907,10 +16818,8 @@ class BaseApi extends BaseApiAbstract {
16907
16818
  * @param {AxiosRequestConfig} configOverrides - Additional configuration options for the request.
16908
16819
  * @returns {Promise<Result<T | null, ApiError>>} A promise that resolves to the result, which can be either data of type T or null, or an error of type ApiError.
16909
16820
  */
16910
- get(path, configOverrides) {
16911
- return __awaiter(this, void 0, void 0, function* () {
16912
- return this.createRequest(path, configOverrides, this.client.get);
16913
- });
16821
+ async get(path, configOverrides) {
16822
+ return this.createRequest(path, configOverrides, this.client.get);
16914
16823
  }
16915
16824
  /**
16916
16825
  * Sends a POST request to the specified path with the given data and configuration overrides.
@@ -16921,18 +16830,24 @@ class BaseApi extends BaseApiAbstract {
16921
16830
  *
16922
16831
  * @returns {Promise<Result<T | null, ApiError>>} - A Promise that resolves to the result of the POST request.
16923
16832
  */
16924
- post(path, data, configOverrides) {
16925
- return __awaiter(this, void 0, void 0, function* () {
16926
- let requestData = data;
16927
- if (![exports.RMN_ENV.LOCAL, exports.RMN_ENV.DEVELOPMENT].includes(this.authInfo.env)) {
16928
- const timestamp = new Date().getTime();
16929
- configOverrides = Object.assign(Object.assign({}, configOverrides), { headers: Object.assign(Object.assign({}, configOverrides === null || configOverrides === void 0 ? void 0 : configOverrides.headers), { [REQUEST_CLOUD_PROTECTED_KEY]: 'true', [REQUEST_CLOUD_PROTECTED_TIMESTAMP]: timestamp, [SDK_CONFIG.apiHeader]: this.authInfo.apiKey }) });
16930
- requestData = {
16931
- t: yield this.encryptedApi.handleEncryption(data, timestamp),
16932
- };
16933
- }
16934
- return this.createRequest(path, configOverrides, (url, config) => this.client.post(url, requestData, config));
16935
- });
16833
+ async post(path, data, configOverrides) {
16834
+ let requestData = data;
16835
+ if (![exports.RMN_ENV.LOCAL, exports.RMN_ENV.DEVELOPMENT].includes(this.authInfo.env)) {
16836
+ const timestamp = new Date().getTime();
16837
+ configOverrides = {
16838
+ ...configOverrides,
16839
+ headers: {
16840
+ ...configOverrides === null || configOverrides === void 0 ? void 0 : configOverrides.headers,
16841
+ [REQUEST_CLOUD_PROTECTED_KEY]: 'true',
16842
+ [REQUEST_CLOUD_PROTECTED_TIMESTAMP]: timestamp,
16843
+ [SDK_CONFIG.apiHeader]: this.authInfo.apiKey,
16844
+ },
16845
+ };
16846
+ requestData = {
16847
+ t: await this.encryptedApi.handleEncryption(data, timestamp),
16848
+ };
16849
+ }
16850
+ return this.createRequest(path, configOverrides, (url, config) => this.client.post(url, requestData, config));
16936
16851
  }
16937
16852
  /**
16938
16853
  * Create a request to the API server.
@@ -16941,18 +16856,16 @@ class BaseApi extends BaseApiAbstract {
16941
16856
  * @param {function} requestFunction - The function to send the request, must accept the URL and config as parameters and return a promise of the Axios response or null.
16942
16857
  * @returns {Promise<Result<T | null, ApiError>>} - A promise that resolves to a Result object containing the response data or null on success, or an ApiError object on failure.
16943
16858
  */
16944
- createRequest(subPath, configOverrides, requestFunction) {
16945
- return __awaiter(this, void 0, void 0, function* () {
16946
- try {
16947
- const url = this.createURL(subPath);
16948
- const fullConfig = this.createFullConfig(configOverrides);
16949
- const response = yield this.sendRequest(url, fullConfig, requestFunction);
16950
- return yield this.getResponse(response);
16951
- }
16952
- catch (error) {
16953
- return { isOk: false, val: null, isErr: new ApiError(error) };
16954
- }
16955
- });
16859
+ async createRequest(subPath, configOverrides, requestFunction) {
16860
+ try {
16861
+ const url = this.createURL(subPath);
16862
+ const fullConfig = this.createFullConfig(configOverrides);
16863
+ const response = await this.sendRequest(url, fullConfig, requestFunction);
16864
+ return await this.getResponse(response);
16865
+ }
16866
+ catch (error) {
16867
+ return { isOk: false, val: null, isErr: new ApiError(error) };
16868
+ }
16956
16869
  }
16957
16870
  /**
16958
16871
  * Private method that creates a full Axios request configuration.
@@ -16973,10 +16886,8 @@ class BaseApi extends BaseApiAbstract {
16973
16886
  * @return {Promise<AxiosResponse | null>} - A Promise that resolves with the response from the request function,
16974
16887
  * or null if the request was unsuccessful.
16975
16888
  */
16976
- sendRequest(url, config, requestFunction) {
16977
- return __awaiter(this, void 0, void 0, function* () {
16978
- return requestFunction(url, config);
16979
- });
16889
+ async sendRequest(url, config, requestFunction) {
16890
+ return requestFunction(url, config);
16980
16891
  }
16981
16892
  /**
16982
16893
  * Gets the response from an Axios response object and handles decryption if necessary.
@@ -16985,36 +16896,34 @@ class BaseApi extends BaseApiAbstract {
16985
16896
  * @param {AxiosResponse | null} response - The Axios response object.
16986
16897
  * @returns {Promise<Result<T | null, ApiError>>} - A promise that resolves to a Result object containing the response data or an ApiError.
16987
16898
  */
16988
- getResponse(response) {
16989
- return __awaiter(this, void 0, void 0, function* () {
16990
- var _a, _b, _c, _d, _e, _f, _g;
16991
- let responseData = (response === null || response === void 0 ? void 0 : response.data) ? response.data : null;
16992
- let isEncrypted = false;
16993
- let timestamp = 0;
16994
- if ((response === null || response === void 0 ? void 0 : response.headers) &&
16995
- ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.has) &&
16996
- ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b.has(REQUEST_CLOUD_PROTECTED_KEY)) &&
16997
- ((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c.has(REQUEST_CLOUD_PROTECTED_TIMESTAMP)) &&
16998
- ((_d = response === null || response === void 0 ? void 0 : response.headers) === null || _d === void 0 ? void 0 : _d.get)) {
16999
- isEncrypted = ((_e = response === null || response === void 0 ? void 0 : response.headers) === null || _e === void 0 ? void 0 : _e.get(REQUEST_CLOUD_PROTECTED_KEY)) === 'true';
17000
- timestamp = ((_f = response === null || response === void 0 ? void 0 : response.headers) === null || _f === void 0 ? void 0 : _f.get(REQUEST_CLOUD_PROTECTED_TIMESTAMP))
17001
- ? Number((_g = response === null || response === void 0 ? void 0 : response.headers) === null || _g === void 0 ? void 0 : _g.get(REQUEST_CLOUD_PROTECTED_TIMESTAMP))
17002
- : 0;
17003
- }
17004
- if (responseData &&
17005
- isEncrypted &&
17006
- this.objectHelper.includes(responseData, 't') &&
17007
- timestamp > 0) {
17008
- const { t: encryptedPayload } = responseData;
17009
- const decryptedData = yield this.encryptedApi.handleDecryption(encryptedPayload, timestamp);
17010
- if (decryptedData === null || decryptedData === void 0 ? void 0 : decryptedData.payload) {
17011
- delete decryptedData.payload.exp;
17012
- delete decryptedData.payload.iat;
17013
- responseData = decryptedData.payload;
17014
- }
16899
+ async getResponse(response) {
16900
+ var _a, _b, _c, _d, _e, _f, _g;
16901
+ let responseData = (response === null || response === void 0 ? void 0 : response.data) ? response.data : null;
16902
+ let isEncrypted = false;
16903
+ let timestamp = 0;
16904
+ if ((response === null || response === void 0 ? void 0 : response.headers) &&
16905
+ ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.has) &&
16906
+ ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b.has(REQUEST_CLOUD_PROTECTED_KEY)) &&
16907
+ ((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c.has(REQUEST_CLOUD_PROTECTED_TIMESTAMP)) &&
16908
+ ((_d = response === null || response === void 0 ? void 0 : response.headers) === null || _d === void 0 ? void 0 : _d.get)) {
16909
+ isEncrypted = ((_e = response === null || response === void 0 ? void 0 : response.headers) === null || _e === void 0 ? void 0 : _e.get(REQUEST_CLOUD_PROTECTED_KEY)) === 'true';
16910
+ timestamp = ((_f = response === null || response === void 0 ? void 0 : response.headers) === null || _f === void 0 ? void 0 : _f.get(REQUEST_CLOUD_PROTECTED_TIMESTAMP))
16911
+ ? Number((_g = response === null || response === void 0 ? void 0 : response.headers) === null || _g === void 0 ? void 0 : _g.get(REQUEST_CLOUD_PROTECTED_TIMESTAMP))
16912
+ : 0;
16913
+ }
16914
+ if (responseData &&
16915
+ isEncrypted &&
16916
+ this.objectHelper.includes(responseData, 't') &&
16917
+ timestamp > 0) {
16918
+ const { t: encryptedPayload } = responseData;
16919
+ const decryptedData = await this.encryptedApi.handleDecryption(encryptedPayload, timestamp);
16920
+ if (decryptedData === null || decryptedData === void 0 ? void 0 : decryptedData.payload) {
16921
+ delete decryptedData.payload.exp;
16922
+ delete decryptedData.payload.iat;
16923
+ responseData = decryptedData.payload;
17015
16924
  }
17016
- return { isOk: true, val: responseData, isErr: false };
17017
- });
16925
+ }
16926
+ return { isOk: true, val: responseData, isErr: false };
17018
16927
  }
17019
16928
  /**
17020
16929
  * Creates a URL by concatenating the base URL with the provided path.
@@ -17055,25 +16964,23 @@ class AuthService extends BaseApi {
17055
16964
  * @returns {Promise<IAuthCredentials>} A Promise that resolves to the authenticated credentials.
17056
16965
  * @throws {Error} If there is an error during authentication or the authentication response is unsuccessful.
17057
16966
  */
17058
- initialize() {
17059
- return __awaiter(this, void 0, void 0, function* () {
17060
- const { isOk, isErr, val } = yield this.get(AUTH_API_PATH, {
17061
- headers: {
17062
- [SDK_CONFIG.apiHeader]: this.authInfo.apiKey,
17063
- },
17064
- });
17065
- if (isErr) {
17066
- throw new Error(`There was an error during authentication: (${isErr === null || isErr === void 0 ? void 0 : isErr.errorMessage})`);
17067
- }
17068
- if (isOk && (val === null || val === void 0 ? void 0 : val.data.token)) {
17069
- this.authInfo.token = val.data.token;
17070
- this.authInfo.authenticated = true;
17071
- }
17072
- else {
17073
- throw new Error('Auth response was not successful');
17074
- }
17075
- return this.authInfo;
16967
+ async initialize() {
16968
+ const { isOk, isErr, val } = await this.get(AUTH_API_PATH, {
16969
+ headers: {
16970
+ [SDK_CONFIG.apiHeader]: this.authInfo.apiKey,
16971
+ },
17076
16972
  });
16973
+ if (isErr) {
16974
+ throw new Error(`There was an error during authentication: (${isErr === null || isErr === void 0 ? void 0 : isErr.errorMessage})`);
16975
+ }
16976
+ if (isOk && (val === null || val === void 0 ? void 0 : val.data.token)) {
16977
+ this.authInfo.token = val.data.token;
16978
+ this.authInfo.authenticated = true;
16979
+ }
16980
+ else {
16981
+ throw new Error('Auth response was not successful');
16982
+ }
16983
+ return this.authInfo;
17077
16984
  }
17078
16985
  }
17079
16986
 
@@ -17126,24 +17033,9 @@ const SPOT_DIMENSIONS = {
17126
17033
 
17127
17034
  class DummyHTMLElement {
17128
17035
  constructor() {
17129
- Object.defineProperty(this, "shadowRoot", {
17130
- enumerable: true,
17131
- configurable: true,
17132
- writable: true,
17133
- value: null
17134
- });
17135
- Object.defineProperty(this, "tagName", {
17136
- enumerable: true,
17137
- configurable: true,
17138
- writable: true,
17139
- value: 'div'
17140
- });
17141
- Object.defineProperty(this, "innerHTML", {
17142
- enumerable: true,
17143
- configurable: true,
17144
- writable: true,
17145
- value: ''
17146
- });
17036
+ this.shadowRoot = null;
17037
+ this.tagName = 'div';
17038
+ this.innerHTML = '';
17147
17039
  }
17148
17040
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
17149
17041
  attachShadow(_options) {
@@ -17158,36 +17050,8 @@ const BaseElement = (isBrowser ? HTMLElement : DummyHTMLElement);
17158
17050
  class BaseSpotComponent extends BaseElement {
17159
17051
  constructor() {
17160
17052
  super();
17161
- Object.defineProperty(this, "initialized", {
17162
- enumerable: true,
17163
- configurable: true,
17164
- writable: true,
17165
- value: false
17166
- });
17167
- Object.defineProperty(this, "dataInitialized", {
17168
- enumerable: true,
17169
- configurable: true,
17170
- writable: true,
17171
- value: false
17172
- });
17173
- Object.defineProperty(this, "_data", {
17174
- enumerable: true,
17175
- configurable: true,
17176
- writable: true,
17177
- value: void 0
17178
- });
17179
- Object.defineProperty(this, "_config", {
17180
- enumerable: true,
17181
- configurable: true,
17182
- writable: true,
17183
- value: void 0
17184
- });
17185
- Object.defineProperty(this, "_container", {
17186
- enumerable: true,
17187
- configurable: true,
17188
- writable: true,
17189
- value: void 0
17190
- });
17053
+ this.initialized = false;
17054
+ this.dataInitialized = false;
17191
17055
  }
17192
17056
  initializeData(data, config) {
17193
17057
  if (this.dataInitialized) {
@@ -17279,12 +17143,6 @@ const SPOT_EVENTS_ARRAY_INDEX = {
17279
17143
  };
17280
17144
  class LocalStorageService {
17281
17145
  constructor() {
17282
- Object.defineProperty(this, "spots", {
17283
- enumerable: true,
17284
- configurable: true,
17285
- writable: true,
17286
- value: void 0
17287
- });
17288
17146
  this.setUserId();
17289
17147
  this.spots = new Map();
17290
17148
  // Sync local storage with the current state
@@ -17517,82 +17375,15 @@ class LocalStorageService {
17517
17375
  return this.unicodeDecode(data);
17518
17376
  }
17519
17377
  }
17520
- Object.defineProperty(LocalStorageService, "localStorageKeyPrefix", {
17521
- enumerable: true,
17522
- configurable: true,
17523
- writable: true,
17524
- value: 'lc_rmn'
17525
- });
17526
- Object.defineProperty(LocalStorageService, "localStorageKey", {
17527
- enumerable: true,
17528
- configurable: true,
17529
- writable: true,
17530
- value: ''
17531
- });
17532
- Object.defineProperty(LocalStorageService, "spotExpirationTime", {
17533
- enumerable: true,
17534
- configurable: true,
17535
- writable: true,
17536
- value: 1000 * 60 * 60 * 24 * 7
17537
- }); // 7 days
17538
- Object.defineProperty(LocalStorageService, "encryptData", {
17539
- enumerable: true,
17540
- configurable: true,
17541
- writable: true,
17542
- value: true
17543
- });
17378
+ LocalStorageService.localStorageKeyPrefix = 'lc_rmn';
17379
+ LocalStorageService.localStorageKey = '';
17380
+ LocalStorageService.spotExpirationTime = 1000 * 60 * 60 * 24 * 7; // 7 days
17381
+ LocalStorageService.encryptData = true;
17544
17382
 
17545
17383
  class ProximityObserver {
17546
17384
  constructor(elementIds, callback, options = {}) {
17547
17385
  var _a, _b;
17548
- Object.defineProperty(this, "intersectionObserver", {
17549
- enumerable: true,
17550
- configurable: true,
17551
- writable: true,
17552
- value: void 0
17553
- });
17554
- Object.defineProperty(this, "mutationObserver", {
17555
- enumerable: true,
17556
- configurable: true,
17557
- writable: true,
17558
- value: void 0
17559
- });
17560
- Object.defineProperty(this, "targetIds", {
17561
- enumerable: true,
17562
- configurable: true,
17563
- writable: true,
17564
- value: void 0
17565
- });
17566
- Object.defineProperty(this, "processedIds", {
17567
- enumerable: true,
17568
- configurable: true,
17569
- writable: true,
17570
- value: void 0
17571
- });
17572
- Object.defineProperty(this, "callback", {
17573
- enumerable: true,
17574
- configurable: true,
17575
- writable: true,
17576
- value: void 0
17577
- });
17578
- Object.defineProperty(this, "proximityThreshold", {
17579
- enumerable: true,
17580
- configurable: true,
17581
- writable: true,
17582
- value: void 0
17583
- });
17584
- Object.defineProperty(this, "intersectionMargin", {
17585
- enumerable: true,
17586
- configurable: true,
17587
- writable: true,
17588
- value: void 0
17589
- });
17590
- Object.defineProperty(this, "maxGroupSize", {
17591
- enumerable: true,
17592
- configurable: true,
17593
- writable: true,
17594
- value: 20
17595
- });
17386
+ this.maxGroupSize = 20;
17596
17387
  this.targetIds = new Set(elementIds);
17597
17388
  this.processedIds = new Set();
17598
17389
  this.callback = callback;
@@ -17729,12 +17520,7 @@ class PubsubService {
17729
17520
  /**
17730
17521
  * Object to store subscribers for each event type
17731
17522
  */
17732
- Object.defineProperty(this, "subscribers", {
17733
- enumerable: true,
17734
- configurable: true,
17735
- writable: true,
17736
- value: {}
17737
- });
17523
+ this.subscribers = {};
17738
17524
  }
17739
17525
  static getInstance() {
17740
17526
  return SingletonManager.getInstance('PubsubService', () => new PubsubService());
@@ -17804,42 +17590,6 @@ class PubsubService {
17804
17590
 
17805
17591
  class ResizeObserverService {
17806
17592
  constructor({ element, maxSize, minScale }) {
17807
- Object.defineProperty(this, "element", {
17808
- enumerable: true,
17809
- configurable: true,
17810
- writable: true,
17811
- value: void 0
17812
- });
17813
- Object.defineProperty(this, "container", {
17814
- enumerable: true,
17815
- configurable: true,
17816
- writable: true,
17817
- value: void 0
17818
- });
17819
- Object.defineProperty(this, "resizeObserver", {
17820
- enumerable: true,
17821
- configurable: true,
17822
- writable: true,
17823
- value: void 0
17824
- });
17825
- Object.defineProperty(this, "maxSize", {
17826
- enumerable: true,
17827
- configurable: true,
17828
- writable: true,
17829
- value: void 0
17830
- });
17831
- Object.defineProperty(this, "minSize", {
17832
- enumerable: true,
17833
- configurable: true,
17834
- writable: true,
17835
- value: void 0
17836
- });
17837
- Object.defineProperty(this, "aspectRatio", {
17838
- enumerable: true,
17839
- configurable: true,
17840
- writable: true,
17841
- value: void 0
17842
- });
17843
17593
  this.element = element;
17844
17594
  if (!element.parentElement) {
17845
17595
  throw new Error('RmnSdk: Spot element must have a parent container.');
@@ -17953,18 +17703,7 @@ function generateGradientColor(overlay, fallback = '') {
17953
17703
  class BillboardV1SE extends BaseSpotComponent {
17954
17704
  constructor() {
17955
17705
  super();
17956
- Object.defineProperty(this, "resizeObserver", {
17957
- enumerable: true,
17958
- configurable: true,
17959
- writable: true,
17960
- value: void 0
17961
- });
17962
- Object.defineProperty(this, "originalFontSizes", {
17963
- enumerable: true,
17964
- configurable: true,
17965
- writable: true,
17966
- value: new Map()
17967
- });
17706
+ this.originalFontSizes = new Map();
17968
17707
  }
17969
17708
  connected() {
17970
17709
  this.setupResizeObserver();
@@ -19448,24 +19187,9 @@ class RbSmallDiscoverToutSE extends BaseSpotComponent {
19448
19187
  class RbVideoPlayerSE extends BaseSpotComponent {
19449
19188
  constructor() {
19450
19189
  super();
19451
- Object.defineProperty(this, "videoSelector", {
19452
- enumerable: true,
19453
- configurable: true,
19454
- writable: true,
19455
- value: () => `.${this._config.prefix}__video-element`
19456
- });
19457
- Object.defineProperty(this, "muteButtonSelector", {
19458
- enumerable: true,
19459
- configurable: true,
19460
- writable: true,
19461
- value: () => `.${this._config.prefix}__mute-button`
19462
- });
19463
- Object.defineProperty(this, "video", {
19464
- enumerable: true,
19465
- configurable: true,
19466
- writable: true,
19467
- value: null
19468
- });
19190
+ this.videoSelector = () => `.${this._config.prefix}__video-element`;
19191
+ this.muteButtonSelector = () => `.${this._config.prefix}__mute-button`;
19192
+ this.video = null;
19469
19193
  this.bindEventHandlers();
19470
19194
  }
19471
19195
  // Initialization Methods
@@ -19694,18 +19418,6 @@ class RbVideoPlayerSE extends BaseSpotComponent {
19694
19418
 
19695
19419
  class SpotTemplateService {
19696
19420
  constructor() {
19697
- Object.defineProperty(this, "rbTemplates", {
19698
- enumerable: true,
19699
- configurable: true,
19700
- writable: true,
19701
- value: void 0
19702
- });
19703
- Object.defineProperty(this, "iabTemplates", {
19704
- enumerable: true,
19705
- configurable: true,
19706
- writable: true,
19707
- value: void 0
19708
- });
19709
19421
  this.rbTemplates = this.initializeRbTemplates();
19710
19422
  this.iabTemplates = this.initializeIabTemplates();
19711
19423
  }
@@ -19992,69 +19704,34 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
19992
19704
  */
19993
19705
  constructor() {
19994
19706
  super();
19995
- /** Public properties that contain carousel configuration and slides */
19996
- Object.defineProperty(this, "data", {
19997
- enumerable: true,
19998
- configurable: true,
19999
- writable: true,
20000
- value: void 0
20001
- });
20002
- Object.defineProperty(this, "slides", {
20003
- enumerable: true,
20004
- configurable: true,
20005
- writable: true,
20006
- value: void 0
20007
- });
20008
- Object.defineProperty(this, "state", {
20009
- enumerable: true,
20010
- configurable: true,
20011
- writable: true,
20012
- value: {
20013
- currentSlide: 0,
20014
- autoplayInterval: null,
20015
- isAutoplayPaused: false,
20016
- useDots: false,
20017
- useButtons: false,
20018
- autoplay: true,
20019
- interval: CustomCarouselElement.defaultConfigs.interval,
20020
- dots: Object.assign({}, CustomCarouselElement.defaultConfigs.dots),
20021
- buttons: Object.assign({}, CustomCarouselElement.defaultConfigs.buttons),
20022
- isDragging: false,
20023
- startX: 0,
20024
- currentX: 0,
20025
- dragStartTime: 0,
20026
- dragDistance: 0,
20027
- containerWidth: 0,
20028
- isTransitioning: false,
20029
- realIndex: 0, // Track the actual slide index
20030
- virtualIndex: 1, // Track the virtual slide position (start at 1 to show clone)
20031
- isVirtualizing: false, // Flag for handling virtual slide transitions
20032
- }
20033
- });
20034
- Object.defineProperty(this, "elements", {
20035
- enumerable: true,
20036
- configurable: true,
20037
- writable: true,
20038
- value: {
20039
- slidesContainer: null,
20040
- dots: [],
20041
- prevButton: null,
20042
- nextButton: null,
20043
- }
20044
- });
20045
- /** Additional services and utilities */
20046
- Object.defineProperty(this, "resizeObserver", {
20047
- enumerable: true,
20048
- configurable: true,
20049
- writable: true,
20050
- value: void 0
20051
- });
20052
- Object.defineProperty(this, "cloneToOriginalMap", {
20053
- enumerable: true,
20054
- configurable: true,
20055
- writable: true,
20056
- value: new WeakMap()
20057
- });
19707
+ this.state = {
19708
+ currentSlide: 0,
19709
+ autoplayInterval: null,
19710
+ isAutoplayPaused: false,
19711
+ useDots: false,
19712
+ useButtons: false,
19713
+ autoplay: true,
19714
+ interval: CustomCarouselElement.defaultConfigs.interval,
19715
+ dots: { ...CustomCarouselElement.defaultConfigs.dots },
19716
+ buttons: { ...CustomCarouselElement.defaultConfigs.buttons },
19717
+ isDragging: false,
19718
+ startX: 0,
19719
+ currentX: 0,
19720
+ dragStartTime: 0,
19721
+ dragDistance: 0,
19722
+ containerWidth: 0,
19723
+ isTransitioning: false,
19724
+ realIndex: 0, // Track the actual slide index
19725
+ virtualIndex: 1, // Track the virtual slide position (start at 1 to show clone)
19726
+ isVirtualizing: false, // Flag for handling virtual slide transitions
19727
+ };
19728
+ this.elements = {
19729
+ slidesContainer: null,
19730
+ dots: [],
19731
+ prevButton: null,
19732
+ nextButton: null,
19733
+ };
19734
+ this.cloneToOriginalMap = new WeakMap();
20058
19735
  this.attachShadow({ mode: 'open' });
20059
19736
  this.handleTransitionEnd = this.handleTransitionEnd.bind(this);
20060
19737
  this.handleTouchStart = this.handleTouchStart.bind(this);
@@ -20112,10 +19789,10 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
20112
19789
  this.state.autoplay = (_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c.autoplay) !== null && _d !== void 0 ? _d : true;
20113
19790
  this.state.interval = (_f = (_e = this.data) === null || _e === void 0 ? void 0 : _e.interval) !== null && _f !== void 0 ? _f : CustomCarouselElement.defaultConfigs.interval;
20114
19791
  if (typeof ((_g = this.data) === null || _g === void 0 ? void 0 : _g.useDots) === 'object') {
20115
- this.state.dots = Object.assign(Object.assign({}, this.state.dots), this.data.useDots);
19792
+ this.state.dots = { ...this.state.dots, ...this.data.useDots };
20116
19793
  }
20117
19794
  if (typeof ((_h = this.data) === null || _h === void 0 ? void 0 : _h.useButtons) === 'object') {
20118
- this.state.buttons = Object.assign(Object.assign({}, this.state.buttons), this.data.useButtons);
19795
+ this.state.buttons = { ...this.state.buttons, ...this.data.useButtons };
20119
19796
  }
20120
19797
  this.validateConfiguration();
20121
19798
  }
@@ -20705,50 +20382,40 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
20705
20382
  }
20706
20383
  }
20707
20384
  /** Core initialization and lifecycle methods */
20708
- Object.defineProperty(CustomCarouselElement, "defaultConfigs", {
20709
- enumerable: true,
20710
- configurable: true,
20711
- writable: true,
20712
- value: {
20713
- interval: 5000,
20714
- touchThreshold: 50, // minimum swipe distance in pixels
20715
- dragThreshold: 0.2, // minimum drag percentage of carousel width
20716
- dots: {
20717
- position: 'bottom-center',
20718
- color: '#d9d9d9',
20719
- activeColor: '#b5914a',
20720
- size: 'base',
20721
- opacity: 1,
20722
- },
20723
- buttons: {
20724
- together: false,
20725
- position: 'middle-sides',
20726
- textColor: '#000000',
20727
- backgroundColor: '#ffffff',
20728
- borderRadius: '50%',
20729
- prev: 'Prev',
20730
- next: 'Next',
20731
- size: 'base',
20732
- opacity: 1,
20733
- },
20734
- }
20735
- });
20736
- Object.defineProperty(CustomCarouselElement, "validPositions", {
20737
- enumerable: true,
20738
- configurable: true,
20739
- writable: true,
20740
- value: new Set([
20741
- 'top-left',
20742
- 'top-center',
20743
- 'top-right',
20744
- 'bottom-left',
20745
- 'bottom-center',
20746
- 'bottom-right',
20747
- 'middle-left',
20748
- 'middle-right',
20749
- 'middle-sides',
20750
- ])
20751
- });
20385
+ CustomCarouselElement.defaultConfigs = {
20386
+ interval: 5000,
20387
+ touchThreshold: 50, // minimum swipe distance in pixels
20388
+ dragThreshold: 0.2, // minimum drag percentage of carousel width
20389
+ dots: {
20390
+ position: 'bottom-center',
20391
+ color: '#d9d9d9',
20392
+ activeColor: '#b5914a',
20393
+ size: 'base',
20394
+ opacity: 1,
20395
+ },
20396
+ buttons: {
20397
+ together: false,
20398
+ position: 'middle-sides',
20399
+ textColor: '#000000',
20400
+ backgroundColor: '#ffffff',
20401
+ borderRadius: '50%',
20402
+ prev: 'Prev',
20403
+ next: 'Next',
20404
+ size: 'base',
20405
+ opacity: 1,
20406
+ },
20407
+ };
20408
+ CustomCarouselElement.validPositions = new Set([
20409
+ 'top-left',
20410
+ 'top-center',
20411
+ 'top-right',
20412
+ 'bottom-left',
20413
+ 'bottom-center',
20414
+ 'bottom-right',
20415
+ 'middle-left',
20416
+ 'middle-right',
20417
+ 'middle-sides',
20418
+ ]);
20752
20419
  CarouselElement = CustomCarouselElement;
20753
20420
  }
20754
20421
 
@@ -20757,12 +20424,6 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
20757
20424
  class CustomSkeletonElement extends HTMLElement {
20758
20425
  constructor() {
20759
20426
  super();
20760
- Object.defineProperty(this, "data", {
20761
- enumerable: true,
20762
- configurable: true,
20763
- writable: true,
20764
- value: void 0
20765
- });
20766
20427
  this.attachShadow({ mode: 'open' });
20767
20428
  }
20768
20429
  connectedCallback() {
@@ -20829,12 +20490,6 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
20829
20490
 
20830
20491
  class ElementService {
20831
20492
  constructor() {
20832
- Object.defineProperty(this, "spotTemplateService", {
20833
- enumerable: true,
20834
- configurable: true,
20835
- writable: true,
20836
- value: void 0
20837
- });
20838
20493
  this.spotTemplateService = SpotTemplateService.getInstance();
20839
20494
  this.defineCustomElements();
20840
20495
  }
@@ -20862,7 +20517,10 @@ class ElementService {
20862
20517
  // Define the custom element with the unique class implementation.
20863
20518
  this.defineSpotCustomElement(elementTagName, elementClass);
20864
20519
  const element = document.createElement(elementTagName);
20865
- element.initializeData(params.spot, Object.assign(Object.assign({}, params.config), { prefix: elementId }));
20520
+ element.initializeData(params.spot, {
20521
+ ...params.config,
20522
+ prefix: elementId,
20523
+ });
20866
20524
  return element;
20867
20525
  }
20868
20526
  /**
@@ -20892,7 +20550,11 @@ class ElementService {
20892
20550
  createSkeletonElement(params) {
20893
20551
  const skeleton = document.createElement(SKELETON_ELEMENT_TAG);
20894
20552
  const dimensions = SPOT_DIMENSIONS[params.spotType];
20895
- skeleton.data = Object.assign({ spotType: params.spotType, fluid: (params === null || params === void 0 ? void 0 : params.fluid) === undefined ? false : params.fluid }, dimensions);
20553
+ skeleton.data = {
20554
+ spotType: params.spotType,
20555
+ fluid: (params === null || params === void 0 ? void 0 : params.fluid) === undefined ? false : params.fluid,
20556
+ ...dimensions,
20557
+ };
20896
20558
  return skeleton;
20897
20559
  }
20898
20560
  /**
@@ -20944,18 +20606,6 @@ var AnalyticsTool;
20944
20606
 
20945
20607
  class DataLayerMonitor {
20946
20608
  constructor() {
20947
- Object.defineProperty(this, "originalPush", {
20948
- enumerable: true,
20949
- configurable: true,
20950
- writable: true,
20951
- value: void 0
20952
- });
20953
- Object.defineProperty(this, "listener", {
20954
- enumerable: true,
20955
- configurable: true,
20956
- writable: true,
20957
- value: void 0
20958
- });
20959
20609
  if (!window.dataLayer) {
20960
20610
  return;
20961
20611
  }
@@ -21031,30 +20681,6 @@ class DataLayerMonitor {
21031
20681
  // window.rmnDataLayer = window.rmnDataLayer || [];
21032
20682
  class MonitorService {
21033
20683
  constructor() {
21034
- Object.defineProperty(this, "implementedMonitor", {
21035
- enumerable: true,
21036
- configurable: true,
21037
- writable: true,
21038
- value: void 0
21039
- });
21040
- Object.defineProperty(this, "pubSubService", {
21041
- enumerable: true,
21042
- configurable: true,
21043
- writable: true,
21044
- value: void 0
21045
- });
21046
- Object.defineProperty(this, "localStorageService", {
21047
- enumerable: true,
21048
- configurable: true,
21049
- writable: true,
21050
- value: void 0
21051
- });
21052
- Object.defineProperty(this, "normalizeStringHelper", {
21053
- enumerable: true,
21054
- configurable: true,
21055
- writable: true,
21056
- value: void 0
21057
- });
21058
20684
  const analyticsTool = this.detectAnalyticsTool();
21059
20685
  switch (analyticsTool) {
21060
20686
  case AnalyticsTool.GoogleAnalytics:
@@ -21079,89 +20705,85 @@ class MonitorService {
21079
20705
  start() {
21080
20706
  if (!this.implementedMonitor)
21081
20707
  return;
21082
- this.implementedMonitor.setListener((eventData) => __awaiter(this, void 0, void 0, function* () {
20708
+ this.implementedMonitor.setListener(async (eventData) => {
21083
20709
  var _a;
21084
- yield this.matchAndFireEvent(eventData, (_a = this.localStorageService) === null || _a === void 0 ? void 0 : _a.getSpots());
21085
- }));
20710
+ await this.matchAndFireEvent(eventData, (_a = this.localStorageService) === null || _a === void 0 ? void 0 : _a.getSpots());
20711
+ });
21086
20712
  this.implementedMonitor.start();
21087
20713
  }
21088
- matchAndFireEvent(eventData, spots) {
21089
- return __awaiter(this, void 0, void 0, function* () {
21090
- var _a, _b, _c, _d;
21091
- if (!spots)
21092
- return;
21093
- for (const spot of Object.values(spots)) {
21094
- if (!spot.productIds.length)
20714
+ async matchAndFireEvent(eventData, spots) {
20715
+ var _a, _b, _c, _d;
20716
+ if (!spots)
20717
+ return;
20718
+ for (const spot of Object.values(spots)) {
20719
+ if (!spot.productIds.length)
20720
+ continue;
20721
+ for (const data of eventData.products) {
20722
+ if (!Object.values(exports.RMN_SPOT_EVENT).includes(eventData.event)) {
21095
20723
  continue;
21096
- for (const data of eventData.products) {
21097
- if (!Object.values(exports.RMN_SPOT_EVENT).includes(eventData.event)) {
21098
- continue;
21099
- }
21100
- const firedEvents = spot.firedEvents || [];
21101
- const eventProductId = (_a = this.normalizeStringHelper) === null || _a === void 0 ? void 0 : _a.normalize(String(data.id));
21102
- const isEventAlreadyFired = firedEvents.some((event) => event.productId === eventProductId && event.event === eventData.event);
21103
- if (isEventAlreadyFired) {
21104
- continue;
21105
- }
21106
- const spotRelatedProductIdsSet = new Set(spot.productIds.map((id) => { var _a; return (_a = this.normalizeStringHelper) === null || _a === void 0 ? void 0 : _a.normalize(String(id)); }));
21107
- const eventProductBrand = (_b = this.normalizeStringHelper) === null || _b === void 0 ? void 0 : _b.normalize(String(data.brand));
21108
- const eventVariantBrand = (_c = this.normalizeStringHelper) === null || _c === void 0 ? void 0 : _c.normalize(String(data.variant));
21109
- const isProductMatch = [eventProductId, eventProductBrand, eventVariantBrand].some((id) => spotRelatedProductIdsSet.has(id));
21110
- if (!isProductMatch) {
21111
- continue;
21112
- }
21113
- const eventPosition = spot.events.findIndex((event) => event.event === eventData.event);
21114
- if (eventPosition === -1)
21115
- continue;
21116
- const eventUrl = spot.events[eventPosition].url;
21117
- let additionalQueryParams = '';
21118
- if (eventData.event === exports.RMN_SPOT_EVENT.PURCHASE) {
21119
- const conversionPrice = data.price && data.quantity ? data.price * data.quantity : undefined;
21120
- additionalQueryParams = objectToQueryParams({
21121
- override: conversionPrice,
21122
- gmv: conversionPrice,
21123
- });
21124
- }
21125
- // Fire the event and publish it to the pubsub service
21126
- yield this.fireAndPublishSpotEvent({
21127
- spotEvent: eventData.event,
21128
- eventUrl: `${eventUrl}${additionalQueryParams ? `&${additionalQueryParams}` : ''}`,
21129
- placementId: spot.placementId,
21130
- spotId: spot.spotId,
21131
- spotType: spot.spotType,
21132
- });
21133
- // Add the fired event of the product to spot fired events
21134
- firedEvents.push({
21135
- productId: eventProductId,
21136
- event: eventData.event,
21137
- });
21138
- // Update the spots in the local storage
21139
- (_d = this.localStorageService) === null || _d === void 0 ? void 0 : _d.setSpot(spot.spotId, {
21140
- placementId: spot.placementId,
21141
- spotId: spot.spotId,
21142
- spotType: spot.spotType,
21143
- events: spot.events,
21144
- firedEvents,
21145
- productIds: spot.productIds,
20724
+ }
20725
+ const firedEvents = spot.firedEvents || [];
20726
+ const eventProductId = (_a = this.normalizeStringHelper) === null || _a === void 0 ? void 0 : _a.normalize(String(data.id));
20727
+ const isEventAlreadyFired = firedEvents.some((event) => event.productId === eventProductId && event.event === eventData.event);
20728
+ if (isEventAlreadyFired) {
20729
+ continue;
20730
+ }
20731
+ const spotRelatedProductIdsSet = new Set(spot.productIds.map((id) => { var _a; return (_a = this.normalizeStringHelper) === null || _a === void 0 ? void 0 : _a.normalize(String(id)); }));
20732
+ const eventProductBrand = (_b = this.normalizeStringHelper) === null || _b === void 0 ? void 0 : _b.normalize(String(data.brand));
20733
+ const eventVariantBrand = (_c = this.normalizeStringHelper) === null || _c === void 0 ? void 0 : _c.normalize(String(data.variant));
20734
+ const isProductMatch = [eventProductId, eventProductBrand, eventVariantBrand].some((id) => spotRelatedProductIdsSet.has(id));
20735
+ if (!isProductMatch) {
20736
+ continue;
20737
+ }
20738
+ const eventPosition = spot.events.findIndex((event) => event.event === eventData.event);
20739
+ if (eventPosition === -1)
20740
+ continue;
20741
+ const eventUrl = spot.events[eventPosition].url;
20742
+ let additionalQueryParams = '';
20743
+ if (eventData.event === exports.RMN_SPOT_EVENT.PURCHASE) {
20744
+ const conversionPrice = data.price && data.quantity ? data.price * data.quantity : undefined;
20745
+ additionalQueryParams = objectToQueryParams({
20746
+ override: conversionPrice,
20747
+ gmv: conversionPrice,
21146
20748
  });
21147
20749
  }
20750
+ // Fire the event and publish it to the pubsub service
20751
+ await this.fireAndPublishSpotEvent({
20752
+ spotEvent: eventData.event,
20753
+ eventUrl: `${eventUrl}${additionalQueryParams ? `&${additionalQueryParams}` : ''}`,
20754
+ placementId: spot.placementId,
20755
+ spotId: spot.spotId,
20756
+ spotType: spot.spotType,
20757
+ });
20758
+ // Add the fired event of the product to spot fired events
20759
+ firedEvents.push({
20760
+ productId: eventProductId,
20761
+ event: eventData.event,
20762
+ });
20763
+ // Update the spots in the local storage
20764
+ (_d = this.localStorageService) === null || _d === void 0 ? void 0 : _d.setSpot(spot.spotId, {
20765
+ placementId: spot.placementId,
20766
+ spotId: spot.spotId,
20767
+ spotType: spot.spotType,
20768
+ events: spot.events,
20769
+ firedEvents,
20770
+ productIds: spot.productIds,
20771
+ });
21148
20772
  }
21149
- });
20773
+ }
21150
20774
  }
21151
- fireAndPublishSpotEvent(_a) {
21152
- return __awaiter(this, arguments, void 0, function* ({ spotEvent, eventUrl, placementId, spotId, spotType, }) {
21153
- yield fireEvent({
21154
- spotType,
21155
- event: spotEvent,
21156
- eventUrl,
21157
- });
21158
- if (!this.pubSubService)
21159
- return;
21160
- this.pubSubService.publish(exports.RMN_EVENT.SPOT_EVENT, {
21161
- eventType: spotEvent,
21162
- placementId,
21163
- spotId,
21164
- });
20775
+ async fireAndPublishSpotEvent({ spotEvent, eventUrl, placementId, spotId, spotType, }) {
20776
+ await fireEvent({
20777
+ spotType,
20778
+ event: spotEvent,
20779
+ eventUrl,
20780
+ });
20781
+ if (!this.pubSubService)
20782
+ return;
20783
+ this.pubSubService.publish(exports.RMN_EVENT.SPOT_EVENT, {
20784
+ eventType: spotEvent,
20785
+ placementId,
20786
+ spotId,
21165
20787
  });
21166
20788
  }
21167
20789
  detectAnalyticsTool() {
@@ -21197,22 +20819,20 @@ class SelectionService extends BaseApi {
21197
20819
  *
21198
20820
  * @return {Promise<ISpots | { error: string }>} - The spots response object.
21199
20821
  */
21200
- spotSelection(data) {
21201
- return __awaiter(this, void 0, void 0, function* () {
21202
- if (data.userId === undefined) {
21203
- data.userId = this.getUserId();
21204
- }
21205
- const { isOk, val, isErr } = yield this.post(SELECTION_API_PATH, data, {});
21206
- if (isErr) {
21207
- return { error: `There was an error during spot selection: (${isErr === null || isErr === void 0 ? void 0 : isErr.errorMessage})` };
21208
- }
21209
- if (isOk && val && val.data && (val === null || val === void 0 ? void 0 : val.refresh.token)) {
21210
- this.authInfo.authenticated = true;
21211
- this.authInfo.token = val.refresh.token;
21212
- return val.data.spots;
21213
- }
21214
- return { error: 'Spot selection response was not successful' };
21215
- });
20822
+ async spotSelection(data) {
20823
+ if (data.userId === undefined) {
20824
+ data.userId = this.getUserId();
20825
+ }
20826
+ const { isOk, val, isErr } = await this.post(SELECTION_API_PATH, data, {});
20827
+ if (isErr) {
20828
+ return { error: `There was an error during spot selection: (${isErr === null || isErr === void 0 ? void 0 : isErr.errorMessage})` };
20829
+ }
20830
+ if (isOk && val && val.data && (val === null || val === void 0 ? void 0 : val.refresh.token)) {
20831
+ this.authInfo.authenticated = true;
20832
+ this.authInfo.token = val.refresh.token;
20833
+ return val.data.spots;
20834
+ }
20835
+ return { error: 'Spot selection response was not successful' };
21216
20836
  }
21217
20837
  getUserId() {
21218
20838
  const isWeb = typeof window !== 'undefined';
@@ -21226,24 +20846,6 @@ class SelectionService extends BaseApi {
21226
20846
 
21227
20847
  class SpotManagerService {
21228
20848
  constructor() {
21229
- Object.defineProperty(this, "pubSubService", {
21230
- enumerable: true,
21231
- configurable: true,
21232
- writable: true,
21233
- value: void 0
21234
- });
21235
- Object.defineProperty(this, "localStorageService", {
21236
- enumerable: true,
21237
- configurable: true,
21238
- writable: true,
21239
- value: void 0
21240
- });
21241
- Object.defineProperty(this, "spotLifecyleState", {
21242
- enumerable: true,
21243
- configurable: true,
21244
- writable: true,
21245
- value: void 0
21246
- });
21247
20849
  this.pubSubService = PubsubService.getInstance();
21248
20850
  this.localStorageService = LocalStorageService.getInstance();
21249
20851
  this.spotLifecyleState = new Map();
@@ -21262,11 +20864,11 @@ class SpotManagerService {
21262
20864
  // Handle Impression Event
21263
20865
  this.handleImpressionEvent(placementId, spot);
21264
20866
  // Handle Click Event
21265
- spotElement.addEventListener('click', () => __awaiter(this, void 0, void 0, function* () {
21266
- yield this.handleClickEvent(params);
20867
+ spotElement.addEventListener('click', async () => {
20868
+ await this.handleClickEvent(params);
21267
20869
  // Save spot to local storage for event tracking
21268
20870
  this.saveSpotDataToLocalStorage(placementId, spot);
21269
- }));
20871
+ });
21270
20872
  }
21271
20873
  unregisterSpot(rawPlacementId) {
21272
20874
  const placementId = rawPlacementId.replace('#', '');
@@ -21343,19 +20945,17 @@ class SpotManagerService {
21343
20945
  productIds: (_a = spot.productIds) !== null && _a !== void 0 ? _a : [],
21344
20946
  });
21345
20947
  }
21346
- handleClickEvent(_a) {
21347
- return __awaiter(this, arguments, void 0, function* ({ placementId, spot }) {
21348
- var _b, _c;
21349
- this.pubSubService.publish(exports.RMN_EVENT.SPOT_EVENT, {
21350
- eventType: exports.RMN_SPOT_EVENT.CLICK,
21351
- placementId,
21352
- spotId: spot.id,
21353
- });
21354
- yield fireEvent({
21355
- spotType: spot.spot,
21356
- event: exports.RMN_SPOT_EVENT.CLICK,
21357
- eventUrl: (_c = (_b = spot.events.find((event) => event.event === exports.RMN_SPOT_EVENT.CLICK)) === null || _b === void 0 ? void 0 : _b.url) !== null && _c !== void 0 ? _c : '',
21358
- });
20948
+ async handleClickEvent({ placementId, spot }) {
20949
+ var _a, _b;
20950
+ this.pubSubService.publish(exports.RMN_EVENT.SPOT_EVENT, {
20951
+ eventType: exports.RMN_SPOT_EVENT.CLICK,
20952
+ placementId,
20953
+ spotId: spot.id,
20954
+ });
20955
+ await fireEvent({
20956
+ spotType: spot.spot,
20957
+ event: exports.RMN_SPOT_EVENT.CLICK,
20958
+ eventUrl: (_b = (_a = spot.events.find((event) => event.event === exports.RMN_SPOT_EVENT.CLICK)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '',
21359
20959
  });
21360
20960
  }
21361
20961
  handleImpressionEvent(placementId, spot) {
@@ -21364,23 +20964,25 @@ class SpotManagerService {
21364
20964
  placementId,
21365
20965
  spotId: spot.id,
21366
20966
  });
21367
- (() => __awaiter(this, void 0, void 0, function* () {
20967
+ (async () => {
21368
20968
  var _a, _b;
21369
- yield fireEvent({
20969
+ await fireEvent({
21370
20970
  spotType: spot.spot,
21371
20971
  event: exports.RMN_SPOT_EVENT.IMPRESSION,
21372
20972
  eventUrl: (_b = (_a = spot.events.find((event) => event.event === exports.RMN_SPOT_EVENT.IMPRESSION)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '',
21373
20973
  });
21374
- }))();
20974
+ })();
21375
20975
  }
21376
20976
  deepMerge(current, updates) {
21377
20977
  return {
21378
20978
  identifier: updates.identifier
21379
- ? Object.assign(Object.assign({}, current.identifier), updates.identifier) : current.identifier,
21380
- dom: updates.dom ? Object.assign(Object.assign({}, current.dom), updates.dom) : current.dom,
21381
- state: updates.state ? Object.assign(Object.assign({}, current.state), updates.state) : current.state,
20979
+ ? { ...current.identifier, ...updates.identifier }
20980
+ : current.identifier,
20981
+ dom: updates.dom ? { ...current.dom, ...updates.dom } : current.dom,
20982
+ state: updates.state ? { ...current.state, ...updates.state } : current.state,
21382
20983
  displayConfig: updates.displayConfig
21383
- ? Object.assign(Object.assign({}, current.displayConfig), updates.displayConfig) : current.displayConfig,
20984
+ ? { ...current.displayConfig, ...updates.displayConfig }
20985
+ : current.displayConfig,
21384
20986
  };
21385
20987
  }
21386
20988
  }
@@ -21474,7 +21076,13 @@ function overrideSpotColors(spot, colors) {
21474
21076
  if (!colors)
21475
21077
  return spot;
21476
21078
  const { textColor, backgroundColor, ctaTextColor, ctaBorderColor } = colors;
21477
- return Object.assign(Object.assign({}, spot), { textColor: textColor !== null && textColor !== void 0 ? textColor : spot.textColor, backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : spot.backgroundColor, ctaTextColor: ctaTextColor !== null && ctaTextColor !== void 0 ? ctaTextColor : spot.ctaTextColor, ctaBorderColor: ctaBorderColor !== null && ctaBorderColor !== void 0 ? ctaBorderColor : spot.ctaBorderColor });
21079
+ return {
21080
+ ...spot,
21081
+ textColor: textColor !== null && textColor !== void 0 ? textColor : spot.textColor,
21082
+ backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : spot.backgroundColor,
21083
+ ctaTextColor: ctaTextColor !== null && ctaTextColor !== void 0 ? ctaTextColor : spot.ctaTextColor,
21084
+ ctaBorderColor: ctaBorderColor !== null && ctaBorderColor !== void 0 ? ctaBorderColor : spot.ctaBorderColor,
21085
+ };
21478
21086
  }
21479
21087
  // Sets the id for the user who is browsing the website
21480
21088
  // This id is used to identify the user and provide personalized content
@@ -21493,24 +21101,6 @@ function setUserId() {
21493
21101
  */
21494
21102
  class BrowserRmnClient {
21495
21103
  constructor(auth) {
21496
- Object.defineProperty(this, "selectionService", {
21497
- enumerable: true,
21498
- configurable: true,
21499
- writable: true,
21500
- value: void 0
21501
- });
21502
- Object.defineProperty(this, "elementService", {
21503
- enumerable: true,
21504
- configurable: true,
21505
- writable: true,
21506
- value: void 0
21507
- });
21508
- Object.defineProperty(this, "spotManagerService", {
21509
- enumerable: true,
21510
- configurable: true,
21511
- writable: true,
21512
- value: void 0
21513
- });
21514
21104
  this.selectionService = SelectionService.getInstance(auth);
21515
21105
  this.elementService = ElementService.getInstance();
21516
21106
  this.spotManagerService = SpotManagerService.getInstance();
@@ -21526,10 +21116,8 @@ class BrowserRmnClient {
21526
21116
  *
21527
21117
  * @return {Promise<ISpots | { error : string }>} - The spots response object.
21528
21118
  */
21529
- spotSelection(params) {
21530
- return __awaiter(this, void 0, void 0, function* () {
21531
- return this.selectionService.spotSelection(params);
21532
- });
21119
+ async spotSelection(params) {
21120
+ return this.selectionService.spotSelection(params);
21533
21121
  }
21534
21122
  /**
21535
21123
  * Publishes the spot data for a given placement ID to the RMN.
@@ -21548,33 +21136,31 @@ class BrowserRmnClient {
21548
21136
  *
21549
21137
  * @return {Promise<void>} - A promise that resolves when the spot elements are injected.
21550
21138
  */
21551
- injectSpotElement(params) {
21552
- return __awaiter(this, void 0, void 0, function* () {
21553
- // Handle no spots error state
21554
- if (!params.inject.length) {
21555
- this.spotManagerService.updateSpotLifecycleState('all', {
21556
- state: {
21557
- error: 'No spot elements provided for injection.',
21558
- },
21559
- });
21560
- return;
21561
- }
21562
- // Validate inject data
21563
- params.inject = validateInjectData(params.inject);
21564
- const placementIds = params.inject.map((item) => item.placementId);
21565
- new ProximityObserver(placementIds, (intersectingPlacementIds) => __awaiter(this, void 0, void 0, function* () {
21566
- /**
21567
- * Called when elements are within range
21568
- *
21569
- * intersectingPlacementIds includes:
21570
- * 1. The element that came within 2000px
21571
- * 2. Any unprocessed elements within 500px of that element
21572
- */
21573
- yield this.processPlacements(params, intersectingPlacementIds);
21574
- }), {
21575
- proximityThreshold: 500,
21576
- intersectionMargin: '2000px',
21139
+ async injectSpotElement(params) {
21140
+ // Handle no spots error state
21141
+ if (!params.inject.length) {
21142
+ this.spotManagerService.updateSpotLifecycleState('all', {
21143
+ state: {
21144
+ error: 'No spot elements provided for injection.',
21145
+ },
21577
21146
  });
21147
+ return;
21148
+ }
21149
+ // Validate inject data
21150
+ params.inject = validateInjectData(params.inject);
21151
+ const placementIds = params.inject.map((item) => item.placementId);
21152
+ new ProximityObserver(placementIds, async (intersectingPlacementIds) => {
21153
+ /**
21154
+ * Called when elements are within range
21155
+ *
21156
+ * intersectingPlacementIds includes:
21157
+ * 1. The element that came within 2000px
21158
+ * 2. Any unprocessed elements within 500px of that element
21159
+ */
21160
+ await this.processPlacements(params, intersectingPlacementIds);
21161
+ }, {
21162
+ proximityThreshold: 500,
21163
+ intersectionMargin: '2000px',
21578
21164
  });
21579
21165
  }
21580
21166
  /**
@@ -21585,104 +21171,105 @@ class BrowserRmnClient {
21585
21171
  *
21586
21172
  * @return {Promise<void>} - A promise that resolves when the spot elements are injected.
21587
21173
  */
21588
- processPlacements(params, placementIds) {
21589
- return __awaiter(this, void 0, void 0, function* () {
21590
- var _a, _b;
21591
- const globalConfig = params.config;
21592
- const injectMap = new Map(params.inject.map((item) => [item.placementId, item]));
21593
- const validPlacements = new Map();
21594
- for (const placementId of placementIds) {
21595
- const placement = document.getElementById(placementId);
21596
- const injectData = injectMap.get(placementId);
21597
- // Handle invalid placement scenarios
21598
- if (!placement || !injectData) {
21599
- this.spotManagerService.updateSpotLifecycleState(placementId, {
21600
- state: {
21601
- error: !placement
21602
- ? `Placement element not found for id "${placementId}".`
21603
- : `Placement not found for id "${placementId}".`,
21604
- mounted: false,
21605
- loading: false,
21606
- },
21607
- });
21608
- continue;
21609
- }
21610
- // Identify the spot element
21611
- this.spotManagerService.updateSpotLifecycleState(injectData.placementId, {
21612
- identifier: {
21613
- placementId: injectData.placementId,
21614
- spotType: injectData.spotType,
21174
+ async processPlacements(params, placementIds) {
21175
+ var _a, _b;
21176
+ const globalConfig = params.config;
21177
+ const injectMap = new Map(params.inject.map((item) => [item.placementId, item]));
21178
+ const validPlacements = new Map();
21179
+ for (const placementId of placementIds) {
21180
+ const placement = document.getElementById(placementId);
21181
+ const injectData = injectMap.get(placementId);
21182
+ // Handle invalid placement scenarios
21183
+ if (!placement || !injectData) {
21184
+ this.spotManagerService.updateSpotLifecycleState(placementId, {
21185
+ state: {
21186
+ error: !placement
21187
+ ? `Placement element not found for id "${placementId}".`
21188
+ : `Placement not found for id "${placementId}".`,
21189
+ mounted: false,
21190
+ loading: false,
21615
21191
  },
21616
- }, false);
21617
- prepareSpotPlacement(placement);
21618
- const skeletonElement = this.elementService.createSkeletonElement({
21619
- fluid: (_b = (_a = injectData === null || injectData === void 0 ? void 0 : injectData.config) === null || _a === void 0 ? void 0 : _a.fluid) !== null && _b !== void 0 ? _b : globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.fluid,
21620
- spotType: injectData.spotType,
21621
21192
  });
21622
- if (!skeletonElement) {
21623
- this.spotManagerService.updateSpotLifecycleState(injectData.placementId, {
21624
- state: {
21625
- error: `Failed to create skeleton loader element.`,
21626
- loading: true,
21627
- },
21628
- });
21629
- }
21630
- if (skeletonElement) {
21631
- placement.replaceChildren(skeletonElement);
21632
- }
21633
- validPlacements.set(placementId, placement);
21193
+ continue;
21194
+ }
21195
+ // Identify the spot element
21196
+ this.spotManagerService.updateSpotLifecycleState(injectData.placementId, {
21197
+ identifier: {
21198
+ placementId: injectData.placementId,
21199
+ spotType: injectData.spotType,
21200
+ },
21201
+ }, false);
21202
+ prepareSpotPlacement(placement);
21203
+ const skeletonElement = this.elementService.createSkeletonElement({
21204
+ fluid: (_b = (_a = injectData === null || injectData === void 0 ? void 0 : injectData.config) === null || _a === void 0 ? void 0 : _a.fluid) !== null && _b !== void 0 ? _b : globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.fluid,
21205
+ spotType: injectData.spotType,
21206
+ });
21207
+ if (!skeletonElement) {
21634
21208
  this.spotManagerService.updateSpotLifecycleState(injectData.placementId, {
21635
- state: { loading: true },
21209
+ state: {
21210
+ error: `Failed to create skeleton loader element.`,
21211
+ loading: true,
21212
+ },
21636
21213
  });
21637
21214
  }
21638
- // If no valid placements were found, return early
21639
- if (validPlacements.size === 0) {
21640
- return;
21215
+ if (skeletonElement) {
21216
+ placement.replaceChildren(skeletonElement);
21641
21217
  }
21642
- // Make the spot selection request only for valid placements
21643
- const validInjectPlacements = Array.from(validPlacements.keys())
21644
- .map((id) => injectMap.get(id))
21645
- .filter(Boolean);
21646
- // Make the spot selection request
21647
- const response = yield this.injectSpotSelectionRequest(Object.assign(Object.assign({}, params), { inject: validInjectPlacements }));
21648
- // Handle request error state
21649
- if (typeof response === 'object' && 'error' in response) {
21650
- this.spotManagerService.updateSpotLifecycleState('all', {
21218
+ validPlacements.set(placementId, placement);
21219
+ this.spotManagerService.updateSpotLifecycleState(injectData.placementId, {
21220
+ state: { loading: true },
21221
+ });
21222
+ }
21223
+ // If no valid placements were found, return early
21224
+ if (validPlacements.size === 0) {
21225
+ return;
21226
+ }
21227
+ // Make the spot selection request only for valid placements
21228
+ const validInjectPlacements = Array.from(validPlacements.keys())
21229
+ .map((id) => injectMap.get(id))
21230
+ .filter(Boolean);
21231
+ // Make the spot selection request
21232
+ const response = await this.injectSpotSelectionRequest({
21233
+ ...params,
21234
+ inject: validInjectPlacements,
21235
+ });
21236
+ // Handle request error state
21237
+ if (typeof response === 'object' && 'error' in response) {
21238
+ this.spotManagerService.updateSpotLifecycleState('all', {
21239
+ state: {
21240
+ error: response.error,
21241
+ mounted: false,
21242
+ loading: false,
21243
+ },
21244
+ });
21245
+ validPlacements.forEach((_, id) => clearPlacement(id));
21246
+ return;
21247
+ }
21248
+ // Process spots for valid placements
21249
+ validPlacements.forEach((placement, placementId) => {
21250
+ var _a;
21251
+ const injectData = injectMap.get(placementId);
21252
+ const itemConfig = (_a = injectData === null || injectData === void 0 ? void 0 : injectData.config) !== null && _a !== void 0 ? _a : globalConfig;
21253
+ const spots = response[placementId];
21254
+ if (!(spots === null || spots === void 0 ? void 0 : spots.length)) {
21255
+ this.spotManagerService.updateSpotLifecycleState(injectData.placementId, {
21651
21256
  state: {
21652
- error: response.error,
21257
+ error: `No spots found for type "${injectData.spotType}".`,
21653
21258
  mounted: false,
21654
21259
  loading: false,
21655
21260
  },
21656
21261
  });
21657
- validPlacements.forEach((_, id) => clearPlacement(id));
21262
+ clearPlacement(injectData.placementId);
21658
21263
  return;
21659
21264
  }
21660
- // Process spots for valid placements
21661
- validPlacements.forEach((placement, placementId) => {
21662
- var _a;
21663
- const injectData = injectMap.get(placementId);
21664
- const itemConfig = (_a = injectData === null || injectData === void 0 ? void 0 : injectData.config) !== null && _a !== void 0 ? _a : globalConfig;
21665
- const spots = response[placementId];
21666
- if (!(spots === null || spots === void 0 ? void 0 : spots.length)) {
21667
- this.spotManagerService.updateSpotLifecycleState(injectData.placementId, {
21668
- state: {
21669
- error: `No spots found for type "${injectData.spotType}".`,
21670
- mounted: false,
21671
- loading: false,
21672
- },
21673
- });
21674
- clearPlacement(injectData.placementId);
21675
- return;
21676
- }
21677
- // Handle single spot
21678
- if (spots.length === 1) {
21679
- this.injectOneSpotElement(placement, spots[0], itemConfig);
21680
- }
21681
- // Handle multiple spots (carousel)
21682
- if (spots.length > 1) {
21683
- this.injectCarouselSpotElement(placement, spots, itemConfig);
21684
- }
21685
- });
21265
+ // Handle single spot
21266
+ if (spots.length === 1) {
21267
+ this.injectOneSpotElement(placement, spots[0], itemConfig);
21268
+ }
21269
+ // Handle multiple spots (carousel)
21270
+ if (spots.length > 1) {
21271
+ this.injectCarouselSpotElement(placement, spots, itemConfig);
21272
+ }
21686
21273
  });
21687
21274
  }
21688
21275
  /**
@@ -21809,7 +21396,13 @@ class BrowserRmnClient {
21809
21396
  // Create the carousel element
21810
21397
  const carouselElement = this.elementService.createCarouselElement({
21811
21398
  slides: carouselSlides,
21812
- config: Object.assign({ fluid: config === null || config === void 0 ? void 0 : config.fluid, width: maxWidth, height: maxHeight, minScale: (_a = config === null || config === void 0 ? void 0 : config.minScale) !== null && _a !== void 0 ? _a : 0.25 }, config === null || config === void 0 ? void 0 : config.carousel),
21399
+ config: {
21400
+ fluid: config === null || config === void 0 ? void 0 : config.fluid,
21401
+ width: maxWidth,
21402
+ height: maxHeight,
21403
+ minScale: (_a = config === null || config === void 0 ? void 0 : config.minScale) !== null && _a !== void 0 ? _a : 0.25, // Scale down to 25% of the original size
21404
+ ...config === null || config === void 0 ? void 0 : config.carousel,
21405
+ },
21813
21406
  });
21814
21407
  if (!carouselElement) {
21815
21408
  this.spotManagerService.updateSpotLifecycleState(placementId, {
@@ -21842,17 +21435,20 @@ class BrowserRmnClient {
21842
21435
  *
21843
21436
  * @return {Promise<ISpots | {error: string}>} - The spots response object.
21844
21437
  */
21845
- injectSpotSelectionRequest(params) {
21846
- return __awaiter(this, void 0, void 0, function* () {
21847
- const { inject, filter, config } = params;
21848
- const spots = inject.map((item) => (Object.assign({ placementId: item.placementId, spot: item.spotType, count: item === null || item === void 0 ? void 0 : item.count }, item === null || item === void 0 ? void 0 : item.filter)));
21849
- const request = {
21850
- url: config === null || config === void 0 ? void 0 : config.url,
21851
- filter,
21852
- spots,
21853
- };
21854
- return this.spotSelection(request);
21855
- });
21438
+ async injectSpotSelectionRequest(params) {
21439
+ const { inject, filter, config } = params;
21440
+ const spots = inject.map((item) => ({
21441
+ placementId: item.placementId,
21442
+ spot: item.spotType,
21443
+ count: item === null || item === void 0 ? void 0 : item.count,
21444
+ ...item === null || item === void 0 ? void 0 : item.filter,
21445
+ }));
21446
+ const request = {
21447
+ url: config === null || config === void 0 ? void 0 : config.url,
21448
+ filter,
21449
+ spots,
21450
+ };
21451
+ return this.spotSelection(request);
21856
21452
  }
21857
21453
  }
21858
21454
  /**
@@ -21863,12 +21459,6 @@ class BrowserRmnClient {
21863
21459
  */
21864
21460
  class ServerRmnClient {
21865
21461
  constructor(auth) {
21866
- Object.defineProperty(this, "selectionService", {
21867
- enumerable: true,
21868
- configurable: true,
21869
- writable: true,
21870
- value: void 0
21871
- });
21872
21462
  this.selectionService = SelectionService.getInstance(auth);
21873
21463
  }
21874
21464
  /**
@@ -21880,10 +21470,8 @@ class ServerRmnClient {
21880
21470
  *
21881
21471
  * @return {Promise<ISpots | { error : string }>} - The spots response object.
21882
21472
  */
21883
- spotSelection(params) {
21884
- return __awaiter(this, void 0, void 0, function* () {
21885
- return this.selectionService.spotSelection(params);
21886
- });
21473
+ async spotSelection(params) {
21474
+ return this.selectionService.spotSelection(params);
21887
21475
  }
21888
21476
  /**
21889
21477
  * Publishes the spot data for a given placement ID to the RMN.
@@ -21904,10 +21492,8 @@ class ServerRmnClient {
21904
21492
  * @return {Promise<void>} - A promise that resolves when the spot elements are injected.
21905
21493
  */
21906
21494
  // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
21907
- injectSpotElement(params) {
21908
- return __awaiter(this, void 0, void 0, function* () {
21909
- console.warn('RmnSdk: Injecting spot elements is not supported in server-side environment.');
21910
- });
21495
+ async injectSpotElement(params) {
21496
+ console.warn('RmnSdk: Injecting spot elements is not supported in server-side environment.');
21911
21497
  }
21912
21498
  }
21913
21499
  /**
@@ -21921,34 +21507,32 @@ class ServerRmnClient {
21921
21507
  *
21922
21508
  * @return {Promise<Partial<IRmnClient>>} - The appropriate RmnClient instance.
21923
21509
  */
21924
- function RmnClient(apiKey, config) {
21925
- return __awaiter(this, void 0, void 0, function* () {
21926
- const initializeServerClient = () => __awaiter(this, void 0, void 0, function* () {
21927
- const authService = AuthService.getInstance(apiKey, config.env);
21928
- const credentials = yield authService.initialize();
21929
- return new ServerRmnClient(credentials);
21930
- });
21931
- const initializeBrowserClient = () => __awaiter(this, void 0, void 0, function* () {
21932
- const authService = AuthService.getInstance(apiKey, config.env);
21933
- const credentials = yield authService.initialize();
21934
- setUserId();
21935
- return new BrowserRmnClient(credentials);
21936
- });
21937
- // For non-browser environment, initialize the server client
21938
- if (typeof window === 'undefined') {
21939
- return initializeServerClient();
21510
+ async function RmnClient(apiKey, config) {
21511
+ const initializeServerClient = async () => {
21512
+ const authService = AuthService.getInstance(apiKey, config.env);
21513
+ const credentials = await authService.initialize();
21514
+ return new ServerRmnClient(credentials);
21515
+ };
21516
+ const initializeBrowserClient = async () => {
21517
+ const authService = AuthService.getInstance(apiKey, config.env);
21518
+ const credentials = await authService.initialize();
21519
+ setUserId();
21520
+ return new BrowserRmnClient(credentials);
21521
+ };
21522
+ // For non-browser environment, initialize the server client
21523
+ if (typeof window === 'undefined') {
21524
+ return initializeServerClient();
21525
+ }
21526
+ // For browser environment, ensure the page is fully loaded before initializing the client
21527
+ return new Promise((resolve) => {
21528
+ if (document.readyState === 'complete') {
21529
+ resolve(initializeBrowserClient());
21940
21530
  }
21941
- // For browser environment, ensure the page is fully loaded before initializing the client
21942
- return new Promise((resolve) => {
21943
- if (document.readyState === 'complete') {
21531
+ else {
21532
+ window.addEventListener('load', () => {
21944
21533
  resolve(initializeBrowserClient());
21945
- }
21946
- else {
21947
- window.addEventListener('load', () => {
21948
- resolve(initializeBrowserClient());
21949
- });
21950
- }
21951
- });
21534
+ });
21535
+ }
21952
21536
  });
21953
21537
  }
21954
21538
  /**