@liquidcommercedev/rmn-sdk 1.4.6-beta.4 → 1.4.6-beta.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +463 -152
- package/dist/index.esm.js +463 -152
- package/dist/types/enums.d.ts +2 -0
- package/dist/types/modules/element/component/carousel/carousel.interface.d.ts +3 -3
- package/dist/types/modules/element/component/utils.d.ts +1 -0
- package/dist/types/modules/element/element.interface.d.ts +2 -0
- package/dist/types/modules/element/template/template.service.d.ts +4 -3
- package/dist/types/modules/event/event.interface.d.ts +53 -0
- package/dist/types/modules/event/event.service.d.ts +27 -2
- package/dist/types/modules/event/index.d.ts +1 -0
- package/dist/types/modules/event/pubsub.d.ts +67 -0
- package/dist/types/modules/selection/selection.interface.d.ts +1 -0
- package/dist/types/rmn-client.d.ts +9 -0
- package/dist/types/types.d.ts +4 -1
- package/package.json +1 -1
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
package/dist/index.cjs
CHANGED
@@ -56,6 +56,8 @@ exports.RMN_FILTER_PROPERTIES = void 0;
|
|
56
56
|
})(exports.RMN_FILTER_PROPERTIES || (exports.RMN_FILTER_PROPERTIES = {}));
|
57
57
|
exports.RMN_SPOT_EVENT = void 0;
|
58
58
|
(function (RMN_SPOT_EVENT) {
|
59
|
+
RMN_SPOT_EVENT["MOUNTED"] = "MOUNTED";
|
60
|
+
RMN_SPOT_EVENT["UNMOUNTED"] = "UNMOUNTED";
|
59
61
|
RMN_SPOT_EVENT["IMPRESSION"] = "IMPRESSION";
|
60
62
|
RMN_SPOT_EVENT["CLICK"] = "CLICK";
|
61
63
|
RMN_SPOT_EVENT["PURCHASE"] = "PURCHASE";
|
@@ -15164,6 +15166,46 @@ const GFONT_CORMORANT = `
|
|
15164
15166
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap">
|
15165
15167
|
`;
|
15166
15168
|
|
15169
|
+
class IntersectionObserverService {
|
15170
|
+
constructor(defaultOptions = {}) {
|
15171
|
+
this.observers = new Map();
|
15172
|
+
this.defaultOptions = {
|
15173
|
+
root: null,
|
15174
|
+
rootMargin: '0px',
|
15175
|
+
threshold: 0.5,
|
15176
|
+
...defaultOptions,
|
15177
|
+
};
|
15178
|
+
}
|
15179
|
+
observe(element, callback, options = {}) {
|
15180
|
+
const mergedOptions = { ...this.defaultOptions, ...options };
|
15181
|
+
const ioCallback = (entries) => {
|
15182
|
+
entries.forEach((entry) => {
|
15183
|
+
if (entry.isIntersecting) {
|
15184
|
+
callback(entry);
|
15185
|
+
}
|
15186
|
+
});
|
15187
|
+
};
|
15188
|
+
const observer = new IntersectionObserver(ioCallback, mergedOptions);
|
15189
|
+
this.observers.set(element, observer);
|
15190
|
+
observer.observe(element);
|
15191
|
+
}
|
15192
|
+
unobserve(element) {
|
15193
|
+
const observer = this.observers.get(element);
|
15194
|
+
if (observer) {
|
15195
|
+
observer.unobserve(element);
|
15196
|
+
observer.disconnect();
|
15197
|
+
this.observers.delete(element);
|
15198
|
+
}
|
15199
|
+
}
|
15200
|
+
unobserveAll() {
|
15201
|
+
this.observers.forEach((observer, element) => {
|
15202
|
+
observer.unobserve(element);
|
15203
|
+
observer.disconnect();
|
15204
|
+
});
|
15205
|
+
this.observers.clear();
|
15206
|
+
}
|
15207
|
+
}
|
15208
|
+
|
15167
15209
|
class ResizeObserverService {
|
15168
15210
|
constructor({ element, maxSize, minScale }) {
|
15169
15211
|
this.element = element;
|
@@ -15203,9 +15245,9 @@ class ResizeObserverService {
|
|
15203
15245
|
newWidth = Math.min(containerWidth, this.maxSize.width);
|
15204
15246
|
newHeight = newWidth / this.aspectRatio;
|
15205
15247
|
// If the height exceeds the container, adjust based on height
|
15206
|
-
if (
|
15207
|
-
|
15208
|
-
|
15248
|
+
if (newWidth > containerWidth) {
|
15249
|
+
newWidth = containerWidth;
|
15250
|
+
newHeight = containerHeight * this.aspectRatio;
|
15209
15251
|
}
|
15210
15252
|
// Ensure we're not going below minimum dimensions
|
15211
15253
|
newWidth = Math.max(newWidth, this.minSize.width);
|
@@ -15232,6 +15274,36 @@ class ResizeObserverService {
|
|
15232
15274
|
}
|
15233
15275
|
}
|
15234
15276
|
|
15277
|
+
function calculateScaleFactor(elementScale) {
|
15278
|
+
// Step 1: Apply square root for non-linear scaling
|
15279
|
+
// This creates a more gradual scaling effect, especially for larger changes
|
15280
|
+
// For example:
|
15281
|
+
// - elementScale of 0.25 (1/4 size) becomes 0.5
|
15282
|
+
// - elementScale of 1 (unchanged) remains 1
|
15283
|
+
// - elementScale of 4 (4x size) becomes 2
|
15284
|
+
const baseFactor = Math.sqrt(elementScale);
|
15285
|
+
// Step 2: Apply additional dampening to further soften the scaling effect
|
15286
|
+
// The dampening factor (0.5) can be adjusted:
|
15287
|
+
// - Lower values (closer to 0) make scaling more subtle
|
15288
|
+
// - Higher values (closer to 1) make scaling more pronounced
|
15289
|
+
const dampening = 0.35;
|
15290
|
+
// Calculate the scaleFactor:
|
15291
|
+
// 1. (baseFactor - 1) represents the change from the original size
|
15292
|
+
// 2. Multiply by dampening to reduce the effect
|
15293
|
+
// 3. Add 1 to center the scaling around the original size
|
15294
|
+
// For example, if baseFactor is 2:
|
15295
|
+
// scaleFactor = 1 + (2 - 1) * 0.5 = 1.5
|
15296
|
+
const scaleFactor = 1 + (baseFactor - 1) * dampening;
|
15297
|
+
// Step 3: Define the allowed range for the scale factor
|
15298
|
+
// This ensures that the font size never changes too drastically
|
15299
|
+
const minScale = 0.35; // Font will never be smaller than 50% of original
|
15300
|
+
const maxScale = 1.5; // Font will never be larger than 150% of original
|
15301
|
+
// Step 4: Clamp the scale factor to the defined range
|
15302
|
+
// Math.min ensures the value doesn't exceed maxScale
|
15303
|
+
// Math.max ensures the value isn't less than minScale
|
15304
|
+
return Math.max(minScale, Math.min(maxScale, scaleFactor));
|
15305
|
+
}
|
15306
|
+
|
15235
15307
|
const CAROUSEL_COMPONENT_STYLE = ({ width, height, fluid }) => `
|
15236
15308
|
:host {
|
15237
15309
|
position: relative;
|
@@ -15419,6 +15491,7 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15419
15491
|
this.autoplayInterval = null;
|
15420
15492
|
this.useDots = false;
|
15421
15493
|
this.useButtons = false;
|
15494
|
+
this.originalFontSizes = new Map();
|
15422
15495
|
this.attachShadow({ mode: 'open' });
|
15423
15496
|
}
|
15424
15497
|
connectedCallback() {
|
@@ -15457,7 +15530,7 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15457
15530
|
this.validateOptions();
|
15458
15531
|
}
|
15459
15532
|
setupResizeObserver() {
|
15460
|
-
if (this.data) {
|
15533
|
+
if (this.data && !this.data.fluid) {
|
15461
15534
|
this.resizeObserver = new ResizeObserverService({
|
15462
15535
|
element: this,
|
15463
15536
|
maxSize: {
|
@@ -15470,7 +15543,28 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15470
15543
|
}
|
15471
15544
|
}
|
15472
15545
|
handleCarouselSizeChanged(event) {
|
15473
|
-
|
15546
|
+
const isRBSpot = 'rbHeroadaksda'.startsWith('rb');
|
15547
|
+
if (!isRBSpot) {
|
15548
|
+
// Adjust text elements font size based on the scale factor
|
15549
|
+
this.adjustFontSize(event.detail.scale);
|
15550
|
+
}
|
15551
|
+
}
|
15552
|
+
adjustFontSize(elementScale) {
|
15553
|
+
var _a;
|
15554
|
+
const scaleFactor = calculateScaleFactor(elementScale);
|
15555
|
+
// Find all text elements within the shadow root
|
15556
|
+
const elements = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('h1, h2, h3, h4, p, span');
|
15557
|
+
elements === null || elements === void 0 ? void 0 : elements.forEach((element) => {
|
15558
|
+
if (element instanceof HTMLElement) {
|
15559
|
+
if (!this.originalFontSizes.has(element)) {
|
15560
|
+
const originalSize = parseFloat(window.getComputedStyle(element).fontSize);
|
15561
|
+
this.originalFontSizes.set(element, originalSize);
|
15562
|
+
}
|
15563
|
+
const originalSize = this.originalFontSizes.get(element);
|
15564
|
+
const newFontSize = originalSize * scaleFactor;
|
15565
|
+
element.style.fontSize = `${newFontSize}px`;
|
15566
|
+
}
|
15567
|
+
});
|
15474
15568
|
}
|
15475
15569
|
render() {
|
15476
15570
|
var _a;
|
@@ -15679,7 +15773,7 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15679
15773
|
* #########################################################
|
15680
15774
|
*/
|
15681
15775
|
setupResizeObserver() {
|
15682
|
-
if (this.data) {
|
15776
|
+
if (this.data && !this.data.fluid) {
|
15683
15777
|
this.resizeObserver = new ResizeObserverService({
|
15684
15778
|
element: this,
|
15685
15779
|
maxSize: {
|
@@ -15696,20 +15790,23 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15696
15790
|
* #########################################################
|
15697
15791
|
*/
|
15698
15792
|
handleSpotSizeChanged(event) {
|
15699
|
-
|
15700
|
-
|
15701
|
-
|
15793
|
+
var _a, _b, _c;
|
15794
|
+
const isRBSpot = (_c = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.spot) === null || _b === void 0 ? void 0 : _b.startsWith('rb')) !== null && _c !== void 0 ? _c : false;
|
15795
|
+
if (!isRBSpot) {
|
15796
|
+
// Adjust text elements font size based on the scale factor
|
15797
|
+
this.adjustFontSize(event.detail.scale);
|
15798
|
+
}
|
15702
15799
|
}
|
15703
15800
|
adjustFontSize(elementScale) {
|
15704
15801
|
var _a;
|
15705
|
-
const scaleFactor =
|
15802
|
+
const scaleFactor = calculateScaleFactor(elementScale);
|
15706
15803
|
// Find all text elements within the shadow root
|
15707
15804
|
const elements = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('h1, h2, h3, h4, p, span');
|
15708
15805
|
elements === null || elements === void 0 ? void 0 : elements.forEach((element) => {
|
15709
15806
|
if (element instanceof HTMLElement) {
|
15710
15807
|
if (!this.originalFontSizes.has(element)) {
|
15711
|
-
const
|
15712
|
-
this.originalFontSizes.set(element,
|
15808
|
+
const originalSize = parseFloat(window.getComputedStyle(element).fontSize);
|
15809
|
+
this.originalFontSizes.set(element, originalSize);
|
15713
15810
|
}
|
15714
15811
|
const originalSize = this.originalFontSizes.get(element);
|
15715
15812
|
const newFontSize = originalSize * scaleFactor;
|
@@ -15717,35 +15814,6 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
15717
15814
|
}
|
15718
15815
|
});
|
15719
15816
|
}
|
15720
|
-
calculateScaleFactor(elementScale) {
|
15721
|
-
// Step 1: Apply square root for non-linear scaling
|
15722
|
-
// This creates a more gradual scaling effect, especially for larger changes
|
15723
|
-
// For example:
|
15724
|
-
// - elementScale of 0.25 (1/4 size) becomes 0.5
|
15725
|
-
// - elementScale of 1 (unchanged) remains 1
|
15726
|
-
// - elementScale of 4 (4x size) becomes 2
|
15727
|
-
const baseFactor = Math.sqrt(elementScale);
|
15728
|
-
// Step 2: Apply additional dampening to further soften the scaling effect
|
15729
|
-
// The dampening factor (0.5) can be adjusted:
|
15730
|
-
// - Lower values (closer to 0) make scaling more subtle
|
15731
|
-
// - Higher values (closer to 1) make scaling more pronounced
|
15732
|
-
const dampening = 0.5;
|
15733
|
-
// Calculate the scaleFactor:
|
15734
|
-
// 1. (baseFactor - 1) represents the change from the original size
|
15735
|
-
// 2. Multiply by dampening to reduce the effect
|
15736
|
-
// 3. Add 1 to center the scaling around the original size
|
15737
|
-
// For example, if baseFactor is 2:
|
15738
|
-
// scaleFactor = 1 + (2 - 1) * 0.5 = 1.5
|
15739
|
-
const scaleFactor = 1 + (baseFactor - 1) * dampening;
|
15740
|
-
// Step 3: Define the allowed range for the scale factor
|
15741
|
-
// This ensures that the font size never changes too drastically
|
15742
|
-
const minScale = 0.5; // Font will never be smaller than 90% of original
|
15743
|
-
const maxScale = 1.5; // Font will never be larger than 110% of original
|
15744
|
-
// Step 4: Clamp the scale factor to the defined range
|
15745
|
-
// Math.min ensures the value doesn't exceed maxScale
|
15746
|
-
// Math.max ensures the value isn't less than minScale
|
15747
|
-
return Math.max(minScale, Math.min(maxScale, scaleFactor));
|
15748
|
-
}
|
15749
15817
|
/**
|
15750
15818
|
* Spot element rendering
|
15751
15819
|
* #########################################################
|
@@ -15796,6 +15864,7 @@ class ElementService {
|
|
15796
15864
|
}
|
15797
15865
|
const spot = document.createElement(SPOT_ELEMENT_TAG);
|
15798
15866
|
spot.data = {
|
15867
|
+
spot: config === null || config === void 0 ? void 0 : config.spot,
|
15799
15868
|
fluid: (_a = config === null || config === void 0 ? void 0 : config.fluid) !== null && _a !== void 0 ? _a : false,
|
15800
15869
|
...config,
|
15801
15870
|
};
|
@@ -15817,6 +15886,7 @@ class ElementService {
|
|
15817
15886
|
}
|
15818
15887
|
const carousel = document.createElement(CAROUSEL_ELEMENT_TAG);
|
15819
15888
|
carousel.data = {
|
15889
|
+
spot: config === null || config === void 0 ? void 0 : config.spot,
|
15820
15890
|
fluid: false,
|
15821
15891
|
...config,
|
15822
15892
|
};
|
@@ -16701,12 +16771,7 @@ function wideSkyscraperV1Template(spot) {
|
|
16701
16771
|
|
16702
16772
|
const STYLES$7 = ({ primaryImage, mobilePrimaryImage = primaryImage }, { prefix }) => `
|
16703
16773
|
<style>
|
16704
|
-
|
16705
|
-
min-width: 320px;
|
16706
|
-
min-height: 223px;
|
16707
|
-
}
|
16708
|
-
|
16709
|
-
.${prefix}__content {
|
16774
|
+
.${prefix} {
|
16710
16775
|
display: block;
|
16711
16776
|
width: 100%;
|
16712
16777
|
height: 100%;
|
@@ -16715,10 +16780,11 @@ const STYLES$7 = ({ primaryImage, mobilePrimaryImage = primaryImage }, { prefix
|
|
16715
16780
|
background-repeat: no-repeat;
|
16716
16781
|
background-position: center;
|
16717
16782
|
cursor: pointer;
|
16783
|
+
container-type: inline-size;
|
16718
16784
|
}
|
16719
16785
|
|
16720
|
-
@
|
16721
|
-
.${prefix}
|
16786
|
+
@container (min-width: 640px) {
|
16787
|
+
.${prefix} {
|
16722
16788
|
background-image: url("${primaryImage}");
|
16723
16789
|
}
|
16724
16790
|
}
|
@@ -16728,7 +16794,7 @@ function rbCollectionBannerWithoutTextBlockTemplate(spot, config) {
|
|
16728
16794
|
const { prefix = '' } = config;
|
16729
16795
|
return `
|
16730
16796
|
${STYLES$7(spot, config)}
|
16731
|
-
<div class="${prefix}
|
16797
|
+
<div class="${prefix}"></div>
|
16732
16798
|
`;
|
16733
16799
|
}
|
16734
16800
|
|
@@ -16737,16 +16803,6 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
16737
16803
|
return `
|
16738
16804
|
<style>
|
16739
16805
|
.${prefix} {
|
16740
|
-
min-width: 320px;
|
16741
|
-
min-height: 388px;
|
16742
|
-
width: 100%;
|
16743
|
-
height: 100%;
|
16744
|
-
display: block;
|
16745
|
-
position: relative;
|
16746
|
-
container-type: inline-size;
|
16747
|
-
}
|
16748
|
-
|
16749
|
-
.${prefix}__content {
|
16750
16806
|
display: flex;
|
16751
16807
|
flex-direction: column;
|
16752
16808
|
justify-content: flex-end;
|
@@ -16761,6 +16817,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
16761
16817
|
box-sizing: border-box;
|
16762
16818
|
color: ${textColor};
|
16763
16819
|
cursor: pointer;
|
16820
|
+
container-type: inline-size;
|
16764
16821
|
}
|
16765
16822
|
|
16766
16823
|
.${prefix}__text {
|
@@ -16805,17 +16862,17 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
16805
16862
|
transition: background-color 0.3s ease;
|
16806
16863
|
}
|
16807
16864
|
|
16808
|
-
.${prefix}
|
16865
|
+
.${prefix}:hover .cta-button {
|
16809
16866
|
background-color: ${ctaBorderColor.length === 7 ? `${ctaBorderColor}15` : `${ctaBorderColor}`};
|
16810
16867
|
}
|
16811
16868
|
|
16812
|
-
@
|
16813
|
-
.${prefix}
|
16869
|
+
@container (min-width: 640px) {
|
16870
|
+
.${prefix} {
|
16814
16871
|
background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
|
16815
16872
|
}
|
16816
16873
|
}
|
16817
16874
|
|
16818
|
-
@
|
16875
|
+
@container (min-width: 768px) {
|
16819
16876
|
.${prefix}__primary-image {
|
16820
16877
|
width: 66.66666%;
|
16821
16878
|
height: 100%;
|
@@ -16826,7 +16883,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
16826
16883
|
height: 100%;
|
16827
16884
|
width: 33.33333%;
|
16828
16885
|
}
|
16829
|
-
|
16886
|
+
|
16830
16887
|
.${prefix}__secondary-image {
|
16831
16888
|
width: 100%;
|
16832
16889
|
height: 50%;
|
@@ -16835,7 +16892,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
16835
16892
|
.${prefix}__header {
|
16836
16893
|
font-size: 22px;
|
16837
16894
|
}
|
16838
|
-
|
16895
|
+
|
16839
16896
|
.${prefix}__description {
|
16840
16897
|
font-size: 12px;
|
16841
16898
|
}
|
@@ -16845,7 +16902,7 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
16845
16902
|
}
|
16846
16903
|
}
|
16847
16904
|
|
16848
|
-
@
|
16905
|
+
@container (min-width: 1024px) {
|
16849
16906
|
.${prefix}__header {
|
16850
16907
|
font-size: 24px;
|
16851
16908
|
}
|
@@ -16859,11 +16916,11 @@ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
16859
16916
|
}
|
16860
16917
|
}
|
16861
16918
|
|
16862
|
-
@
|
16919
|
+
@container (min-width: 1280px) {
|
16863
16920
|
.${prefix}__header {
|
16864
16921
|
font-size: 28px;
|
16865
16922
|
}
|
16866
|
-
|
16923
|
+
|
16867
16924
|
.${prefix}__description {
|
16868
16925
|
font-size: 14px;
|
16869
16926
|
}
|
@@ -16883,13 +16940,11 @@ function rbHomepageHeroFullImageTemplate(spot, config) {
|
|
16883
16940
|
${GFONT_CORMORANT}
|
16884
16941
|
${STYLES$6(spot, config)}
|
16885
16942
|
<div class="${prefix}">
|
16886
|
-
|
16887
|
-
|
16888
|
-
|
16889
|
-
|
16890
|
-
|
16891
|
-
</div>
|
16892
|
-
</div>
|
16943
|
+
<div class="${prefix}__text">
|
16944
|
+
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
16945
|
+
${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
|
16946
|
+
${spot.ctaText ? `<span class="${prefix}__cta-button">${spot.ctaText}</span>` : ''}
|
16947
|
+
</div>
|
16893
16948
|
</div>
|
16894
16949
|
`;
|
16895
16950
|
}
|
@@ -16897,8 +16952,6 @@ function rbHomepageHeroFullImageTemplate(spot, config) {
|
|
16897
16952
|
const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextColor = textColor, primaryImage, mobilePrimaryImage = primaryImage, secondaryImage, mobileSecondaryImage = secondaryImage, }, { prefix }) => `
|
16898
16953
|
<style>
|
16899
16954
|
.${prefix} {
|
16900
|
-
min-width: 320px;
|
16901
|
-
min-height: 388px;
|
16902
16955
|
width: 100%;
|
16903
16956
|
height: 100%;
|
16904
16957
|
display: block;
|
@@ -16910,7 +16963,7 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
16910
16963
|
width: 100%;
|
16911
16964
|
height: 100%;
|
16912
16965
|
display: flex;
|
16913
|
-
flex-direction: column;
|
16966
|
+
flex-direction: column;
|
16914
16967
|
background-color: transparent;
|
16915
16968
|
gap: 5px;
|
16916
16969
|
color: inherit;
|
@@ -16997,7 +17050,7 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
16997
17050
|
opacity: 0.8;
|
16998
17051
|
}
|
16999
17052
|
|
17000
|
-
@
|
17053
|
+
@container (min-width: 640px) {
|
17001
17054
|
.${prefix}__primary-image {
|
17002
17055
|
background-image: url("${primaryImage}");
|
17003
17056
|
}
|
@@ -17007,7 +17060,7 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
17007
17060
|
}
|
17008
17061
|
}
|
17009
17062
|
|
17010
|
-
@
|
17063
|
+
@container (min-width: 768px) {
|
17011
17064
|
.${prefix}__content {
|
17012
17065
|
flex-direction: row;
|
17013
17066
|
}
|
@@ -17032,6 +17085,39 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
17032
17085
|
width: 100%;
|
17033
17086
|
height: 50%;
|
17034
17087
|
}
|
17088
|
+
.${prefix}__header {
|
17089
|
+
font-size: 22px;
|
17090
|
+
}
|
17091
|
+
.${prefix}__description {
|
17092
|
+
font-size: 12px;
|
17093
|
+
}
|
17094
|
+
.${prefix}__cta-button {
|
17095
|
+
font-size: 12px;
|
17096
|
+
}
|
17097
|
+
}
|
17098
|
+
|
17099
|
+
@container (min-width: 1024px) {
|
17100
|
+
.${prefix}__header {
|
17101
|
+
font-size: 24px;
|
17102
|
+
}
|
17103
|
+
.${prefix}__description {
|
17104
|
+
font-size: 13px;
|
17105
|
+
}
|
17106
|
+
.${prefix}__cta-button {
|
17107
|
+
font-size: 13px;
|
17108
|
+
}
|
17109
|
+
}
|
17110
|
+
|
17111
|
+
@container (min-width: 1280px) {
|
17112
|
+
.${prefix}__header {
|
17113
|
+
font-size: 28px;
|
17114
|
+
}
|
17115
|
+
.${prefix}__description {
|
17116
|
+
font-size: 14px;
|
17117
|
+
}
|
17118
|
+
.${prefix}__cta-button {
|
17119
|
+
font-size: 14px;
|
17120
|
+
}
|
17035
17121
|
}
|
17036
17122
|
</style>
|
17037
17123
|
`;
|
@@ -17061,23 +17147,15 @@ function rbHomepageHeroThreeTileTemplate(spot, config) {
|
|
17061
17147
|
const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextColor = textColor, primaryImage, mobilePrimaryImage = primaryImage, }, { prefix }) => `
|
17062
17148
|
<style>
|
17063
17149
|
.${prefix} {
|
17064
|
-
min-width: 320px;
|
17065
|
-
min-height: 388px;
|
17066
|
-
width: 100%;
|
17067
|
-
height: 100%;
|
17068
|
-
display: block;
|
17069
|
-
position: relative;
|
17070
|
-
container-type: inline-size;
|
17071
|
-
}
|
17072
|
-
|
17073
|
-
.${prefix}__content {
|
17074
17150
|
width: 100%;
|
17075
17151
|
height: 100%;
|
17076
17152
|
display: flex;
|
17077
|
-
flex-direction: column-reverse;
|
17153
|
+
flex-direction: column-reverse;
|
17078
17154
|
background-color: transparent;
|
17079
17155
|
gap: 5px;
|
17080
17156
|
cursor: pointer;
|
17157
|
+
container-type: inline-size;
|
17158
|
+
position: relative;
|
17081
17159
|
}
|
17082
17160
|
|
17083
17161
|
.${prefix}__image {
|
@@ -17122,7 +17200,7 @@ const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
17122
17200
|
font-style: normal;
|
17123
17201
|
font-weight: 400;
|
17124
17202
|
}
|
17125
|
-
|
17203
|
+
|
17126
17204
|
.${prefix}__cta-button {
|
17127
17205
|
color: ${ctaTextColor};
|
17128
17206
|
background-color: transparent;
|
@@ -17143,25 +17221,57 @@ const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
17143
17221
|
opacity: 0.8;
|
17144
17222
|
}
|
17145
17223
|
|
17146
|
-
@
|
17224
|
+
@container (min-width: 640px) {
|
17147
17225
|
.${prefix}__image {
|
17148
17226
|
background-image: url("${primaryImage}");
|
17149
17227
|
}
|
17150
17228
|
}
|
17151
|
-
|
17152
|
-
|
17229
|
+
|
17230
|
+
@container (min-width: 768px) {
|
17231
|
+
.${prefix} {
|
17153
17232
|
flex-direction: row;
|
17154
17233
|
}
|
17155
|
-
|
17156
17234
|
.${prefix}__image {
|
17157
17235
|
width: 66.66666%;
|
17158
17236
|
height: 100%;
|
17159
17237
|
}
|
17160
|
-
|
17161
17238
|
.${prefix}__text {
|
17162
17239
|
width: 33.33333%;
|
17163
17240
|
height: 100%;
|
17164
17241
|
}
|
17242
|
+
.${prefix}__header {
|
17243
|
+
font-size: 22px;
|
17244
|
+
}
|
17245
|
+
.${prefix}__description {
|
17246
|
+
font-size: 12px;
|
17247
|
+
}
|
17248
|
+
.${prefix}__cta-button {
|
17249
|
+
font-size: 12px;
|
17250
|
+
}
|
17251
|
+
}
|
17252
|
+
|
17253
|
+
@container (min-width: 1024px) {
|
17254
|
+
.${prefix}__header {
|
17255
|
+
font-size: 24px;
|
17256
|
+
}
|
17257
|
+
.${prefix}__description {
|
17258
|
+
font-size: 13px;
|
17259
|
+
}
|
17260
|
+
.${prefix}__cta-button {
|
17261
|
+
font-size: 13px;
|
17262
|
+
}
|
17263
|
+
}
|
17264
|
+
|
17265
|
+
@container (min-width: 1280px) {
|
17266
|
+
.${prefix}__header {
|
17267
|
+
font-size: 28px;
|
17268
|
+
}
|
17269
|
+
.${prefix}__description {
|
17270
|
+
font-size: 14px;
|
17271
|
+
}
|
17272
|
+
.${prefix}__cta-button {
|
17273
|
+
font-size: 14px;
|
17274
|
+
}
|
17165
17275
|
}
|
17166
17276
|
</style>
|
17167
17277
|
`;
|
@@ -17173,14 +17283,12 @@ function rbHomepageHeroTwoTileTemplate(spot, config) {
|
|
17173
17283
|
${GFONT_CORMORANT}
|
17174
17284
|
${STYLES$4(spot, config)}
|
17175
17285
|
<div class="${prefix}">
|
17176
|
-
<div class="${prefix}
|
17177
|
-
|
17178
|
-
|
17179
|
-
|
17180
|
-
${spot.ctaText ? `<span class="${prefix}__cta-button">${spot.ctaText}</span>` : ''}
|
17181
|
-
</div>
|
17182
|
-
<div class="${prefix}__image"></div>
|
17286
|
+
<div class="${prefix}__text">
|
17287
|
+
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
17288
|
+
${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
|
17289
|
+
${spot.ctaText ? `<span class="${prefix}__cta-button">${spot.ctaText}</span>` : ''}
|
17183
17290
|
</div>
|
17291
|
+
<div class="${prefix}__image"></div>
|
17184
17292
|
</div>
|
17185
17293
|
`;
|
17186
17294
|
}
|
@@ -17189,12 +17297,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17189
17297
|
const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%');
|
17190
17298
|
return `
|
17191
17299
|
<style>
|
17192
|
-
|
17193
|
-
min-width: 320px;
|
17194
|
-
min-height: 334px;
|
17195
|
-
}
|
17196
|
-
|
17197
|
-
.${prefix}__content {
|
17300
|
+
.${prefix} {
|
17198
17301
|
width: 100%;
|
17199
17302
|
height: 100%;
|
17200
17303
|
display: flex;
|
@@ -17208,6 +17311,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17208
17311
|
overflow: hidden;
|
17209
17312
|
cursor: pointer;
|
17210
17313
|
color: ${textColor};
|
17314
|
+
container-type: inline-size;
|
17211
17315
|
}
|
17212
17316
|
|
17213
17317
|
.${prefix}__text {
|
@@ -17254,17 +17358,17 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17254
17358
|
font-weight: 400;
|
17255
17359
|
}
|
17256
17360
|
|
17257
|
-
.${prefix}
|
17361
|
+
.${prefix}:hover .${prefix}__cta-button {
|
17258
17362
|
background-color: ${ctaBorderColor.length === 7 ? `${ctaBorderColor}15` : `${ctaBorderColor}`};
|
17259
17363
|
}
|
17260
17364
|
|
17261
|
-
@
|
17262
|
-
.${prefix}
|
17365
|
+
@container (min-width: 640px) {
|
17366
|
+
.${prefix} {
|
17263
17367
|
background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
|
17264
17368
|
}
|
17265
17369
|
}
|
17266
17370
|
|
17267
|
-
@
|
17371
|
+
@container (min-width: 768px) {
|
17268
17372
|
.${prefix}__text {
|
17269
17373
|
padding: 25px;
|
17270
17374
|
}
|
@@ -17283,7 +17387,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17283
17387
|
}
|
17284
17388
|
}
|
17285
17389
|
|
17286
|
-
@
|
17390
|
+
@container (min-width: 1024px) {
|
17287
17391
|
.${prefix}__text {
|
17288
17392
|
padding: 30px;
|
17289
17393
|
}
|
@@ -17301,7 +17405,7 @@ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderCo
|
|
17301
17405
|
}
|
17302
17406
|
}
|
17303
17407
|
|
17304
|
-
@
|
17408
|
+
@container (min-width: 1280px) {
|
17305
17409
|
.${prefix}__cta-button {
|
17306
17410
|
font-size: 14px;
|
17307
17411
|
}
|
@@ -17316,7 +17420,7 @@ function rbLargeCategoryImageToutTemplate(spot, config) {
|
|
17316
17420
|
${GFONT_SOURCE_SANS_3}
|
17317
17421
|
${GFONT_CORMORANT}
|
17318
17422
|
${STYLES$3(spot, config)}
|
17319
|
-
<div class="${prefix}
|
17423
|
+
<div class="${prefix}">
|
17320
17424
|
<div class="${prefix}__text">
|
17321
17425
|
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
17322
17426
|
${spot.description ? `<p class="${prefix}__description">${spot.description}</p>` : ''}
|
@@ -17330,12 +17434,7 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17330
17434
|
const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%');
|
17331
17435
|
return `
|
17332
17436
|
<style>
|
17333
|
-
|
17334
|
-
min-width: 320px;
|
17335
|
-
min-height: 150px;
|
17336
|
-
}
|
17337
|
-
|
17338
|
-
.${prefix}__content {
|
17437
|
+
.${prefix} {
|
17339
17438
|
width: 100%;
|
17340
17439
|
height: 100%;
|
17341
17440
|
display: flex;
|
@@ -17348,6 +17447,7 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17348
17447
|
background-size: cover;
|
17349
17448
|
background-position: center;
|
17350
17449
|
background-repeat: no-repeat;
|
17450
|
+
container-type: inline-size;
|
17351
17451
|
}
|
17352
17452
|
|
17353
17453
|
.${prefix}__text {
|
@@ -17365,25 +17465,25 @@ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17365
17465
|
margin: 0;
|
17366
17466
|
}
|
17367
17467
|
|
17368
|
-
@
|
17369
|
-
.${prefix}
|
17468
|
+
@container (min-width: 640px) {
|
17469
|
+
.${prefix} {
|
17370
17470
|
background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
|
17371
17471
|
}
|
17372
17472
|
}
|
17373
17473
|
|
17374
|
-
@
|
17474
|
+
@container (min-width: 768px) {
|
17375
17475
|
.${prefix}__header {
|
17376
17476
|
font-size: 22px;
|
17377
17477
|
}
|
17378
17478
|
}
|
17379
17479
|
|
17380
|
-
@
|
17480
|
+
@container (min-width: 1024px) {
|
17381
17481
|
.${prefix}__header {
|
17382
17482
|
font-size: 24px;
|
17383
17483
|
}
|
17384
17484
|
}
|
17385
17485
|
|
17386
|
-
@
|
17486
|
+
@container (min-width: 1280px) {
|
17387
17487
|
.${prefix}__header {
|
17388
17488
|
font-size: 28px;
|
17389
17489
|
}
|
@@ -17397,7 +17497,7 @@ function rbNavigationBannerTemplate(spot, config) {
|
|
17397
17497
|
${GFONT_PRECONNECT}
|
17398
17498
|
${GFONT_SOURCE_SANS_3}
|
17399
17499
|
${STYLES$2(spot, config)}
|
17400
|
-
<div class="${prefix}
|
17500
|
+
<div class="${prefix}">
|
17401
17501
|
<div class="${prefix}__text">
|
17402
17502
|
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
17403
17503
|
</div>
|
@@ -17409,12 +17509,7 @@ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17409
17509
|
const linearGradient = linearGradientColorStop(overlay || [], 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%');
|
17410
17510
|
return `
|
17411
17511
|
<style>
|
17412
|
-
|
17413
|
-
min-width: 165px;
|
17414
|
-
min-height: 300px;
|
17415
|
-
}
|
17416
|
-
|
17417
|
-
.${prefix}__content {
|
17512
|
+
.${prefix} {
|
17418
17513
|
width: 100%;
|
17419
17514
|
height: 100%;
|
17420
17515
|
display: flex;
|
@@ -17427,6 +17522,7 @@ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17427
17522
|
border-radius: 5px;
|
17428
17523
|
overflow: hidden;
|
17429
17524
|
cursor: pointer;
|
17525
|
+
container-type: inline-size;
|
17430
17526
|
}
|
17431
17527
|
|
17432
17528
|
.${prefix}__text {
|
@@ -17441,12 +17537,11 @@ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = pr
|
|
17441
17537
|
font-family: "Source Sans 3", system-ui;
|
17442
17538
|
font-style: normal;
|
17443
17539
|
font-weight: 400;
|
17444
|
-
line-height: normal;
|
17445
17540
|
margin: 0;
|
17446
17541
|
}
|
17447
17542
|
|
17448
|
-
@
|
17449
|
-
.${prefix}
|
17543
|
+
@container (min-width: 640px) {
|
17544
|
+
.${prefix} {
|
17450
17545
|
background-image: linear-gradient(to top, ${linearGradient}), url("${primaryImage}");
|
17451
17546
|
}
|
17452
17547
|
}
|
@@ -17459,7 +17554,7 @@ function rbSmallCategoryImageToutTemplate(spot, config) {
|
|
17459
17554
|
${GFONT_PRECONNECT}
|
17460
17555
|
${GFONT_CORMORANT}
|
17461
17556
|
${STYLES$1(spot, config)}
|
17462
|
-
<div class="${prefix}
|
17557
|
+
<div class="${prefix}">
|
17463
17558
|
<div class="${prefix}__text">
|
17464
17559
|
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
17465
17560
|
</div>
|
@@ -17469,12 +17564,7 @@ function rbSmallCategoryImageToutTemplate(spot, config) {
|
|
17469
17564
|
|
17470
17565
|
const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }, { prefix }) => `
|
17471
17566
|
<style>
|
17472
|
-
|
17473
|
-
min-width: 165px;
|
17474
|
-
min-height: 250px;
|
17475
|
-
}
|
17476
|
-
|
17477
|
-
.${prefix}__content {
|
17567
|
+
.${prefix} {
|
17478
17568
|
width: 100%;
|
17479
17569
|
height: 100%;
|
17480
17570
|
background-color: ${backgroundColor};
|
@@ -17482,6 +17572,7 @@ const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primar
|
|
17482
17572
|
display: flex;
|
17483
17573
|
flex-direction: column;
|
17484
17574
|
border-radius: 5px;
|
17575
|
+
container-type: inline-size;
|
17485
17576
|
}
|
17486
17577
|
|
17487
17578
|
.${prefix}__image {
|
@@ -17513,11 +17604,10 @@ const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primar
|
|
17513
17604
|
font-family: "Source Sans 3", system-ui;
|
17514
17605
|
font-style: normal;
|
17515
17606
|
font-weight: 400;
|
17516
|
-
line-height: normal;
|
17517
17607
|
margin: 0;
|
17518
17608
|
}
|
17519
17609
|
|
17520
|
-
@
|
17610
|
+
@container (min-width: 640px) {
|
17521
17611
|
.${prefix}__image {
|
17522
17612
|
background-image: url("${primaryImage}");
|
17523
17613
|
}
|
@@ -17530,7 +17620,7 @@ function rbSmallDiscoverToutTemplate(spot, config) {
|
|
17530
17620
|
${GFONT_PRECONNECT}
|
17531
17621
|
${GFONT_CORMORANT}
|
17532
17622
|
${STYLES(spot, config)}
|
17533
|
-
<div class="${prefix}
|
17623
|
+
<div class="${prefix}">
|
17534
17624
|
<div class="${prefix}__image"></div>
|
17535
17625
|
<div class="${prefix}__text">
|
17536
17626
|
${spot.header ? `<h2 class="${prefix}__header">${spot.header}</h2>` : ''}
|
@@ -17540,11 +17630,12 @@ function rbSmallDiscoverToutTemplate(spot, config) {
|
|
17540
17630
|
}
|
17541
17631
|
|
17542
17632
|
/**
|
17543
|
-
*
|
17633
|
+
* Returns the HTML element for the given spot.
|
17544
17634
|
*
|
17545
|
-
* @param {ISpot} spot - The spot
|
17635
|
+
* @param {ISpot} spot - The spot object.
|
17636
|
+
* @param {ISpotTemplateConfig} config - The spot template configuration.
|
17546
17637
|
*
|
17547
|
-
* @return {
|
17638
|
+
* @return {HTMLElement | null} - The HTML element for the given spot or null if the spot template is not found.
|
17548
17639
|
*/
|
17549
17640
|
const SPOT_TEMPLATE_HTML_ELEMENT = (spot, config) => {
|
17550
17641
|
const templates = {
|
@@ -17617,6 +17708,197 @@ const SPOT_TEMPLATE_HTML_ELEMENT = (spot, config) => {
|
|
17617
17708
|
return spotHtmlStringToElement(spotHtmlString);
|
17618
17709
|
};
|
17619
17710
|
|
17711
|
+
/**
|
17712
|
+
* PubSub class
|
17713
|
+
* Manages event subscriptions and publications
|
17714
|
+
* @template IEventMap A record type defining the structure of events and their data
|
17715
|
+
*/
|
17716
|
+
class PubSub {
|
17717
|
+
constructor() {
|
17718
|
+
/**
|
17719
|
+
* Object to store subscribers for each event type
|
17720
|
+
*/
|
17721
|
+
this.subscribers = {};
|
17722
|
+
}
|
17723
|
+
/**
|
17724
|
+
* Subscribe to an event
|
17725
|
+
* @param eventType - The type of event to subscribe to
|
17726
|
+
* @param callback - The function to be called when the event is published
|
17727
|
+
* @returns A function to unsubscribe from the event
|
17728
|
+
*
|
17729
|
+
* @Example:
|
17730
|
+
* const unsubscribe = pubSub.subscribe('userLogin', (data) => {
|
17731
|
+
* console.log(`User ${data.username} logged in`);
|
17732
|
+
* });
|
17733
|
+
*/
|
17734
|
+
subscribe(eventType, callback) {
|
17735
|
+
if (!this.subscribers[eventType]) {
|
17736
|
+
this.subscribers[eventType] = [];
|
17737
|
+
}
|
17738
|
+
this.subscribers[eventType].push(callback);
|
17739
|
+
// Return an unsubscribe function
|
17740
|
+
return () => {
|
17741
|
+
this.subscribers[eventType] = this.subscribers[eventType].filter((cb) => cb !== callback);
|
17742
|
+
};
|
17743
|
+
}
|
17744
|
+
/**
|
17745
|
+
* Publish an event
|
17746
|
+
* @param eventType - The type of event to publish
|
17747
|
+
* @param data - The data to be passed to the event subscribers
|
17748
|
+
*
|
17749
|
+
* @Example:
|
17750
|
+
* pubSub.publish('userLogin', { username: 'john_doe', timestamp: Date.now() });
|
17751
|
+
*/
|
17752
|
+
publish(eventType, data) {
|
17753
|
+
if (!this.subscribers[eventType]) {
|
17754
|
+
return;
|
17755
|
+
}
|
17756
|
+
this.subscribers[eventType].forEach((callback) => callback(data));
|
17757
|
+
}
|
17758
|
+
}
|
17759
|
+
/**
|
17760
|
+
* Usage Example:
|
17761
|
+
*
|
17762
|
+
* interface IEventMap {
|
17763
|
+
* userLogin: { username: string; timestamp: number };
|
17764
|
+
* pageView: { url: string; timestamp: number };
|
17765
|
+
* }
|
17766
|
+
*
|
17767
|
+
* const pubSub = new PubSub<IEventMap>();
|
17768
|
+
*
|
17769
|
+
* // Subscribe to events
|
17770
|
+
* const unsubscribeLogin = pubSub.subscribe('userLogin', (data) => {
|
17771
|
+
* console.log(`User ${data.username} logged in at ${new Date(data.timestamp)}`);
|
17772
|
+
* });
|
17773
|
+
*
|
17774
|
+
* pubSub.subscribe('pageView', (data) => {
|
17775
|
+
* console.log(`Page ${data.url} viewed at ${new Date(data.timestamp)}`);
|
17776
|
+
* });
|
17777
|
+
*
|
17778
|
+
* // Publish events
|
17779
|
+
* pubSub.publish('userLogin', { username: 'john_doe', timestamp: Date.now() });
|
17780
|
+
* pubSub.publish('pageView', { url: '/home', timestamp: Date.now() });
|
17781
|
+
*
|
17782
|
+
* // Unsubscribe from an event
|
17783
|
+
* unsubscribeLogin();
|
17784
|
+
*/
|
17785
|
+
|
17786
|
+
class EventService {
|
17787
|
+
constructor() {
|
17788
|
+
this.pubSub = new PubSub();
|
17789
|
+
this.activeSpots = new Map();
|
17790
|
+
this.intersectionObserver = new IntersectionObserverService();
|
17791
|
+
}
|
17792
|
+
static getInstance() {
|
17793
|
+
if (!EventService.instance) {
|
17794
|
+
EventService.instance = new EventService();
|
17795
|
+
}
|
17796
|
+
return EventService.instance;
|
17797
|
+
}
|
17798
|
+
registerSpot({ placementId, element, spot }) {
|
17799
|
+
this.activeSpots.set(spot.id, {
|
17800
|
+
placementId,
|
17801
|
+
element,
|
17802
|
+
impressionTracked: false,
|
17803
|
+
});
|
17804
|
+
// Handle intersection observer
|
17805
|
+
this.handleIntersectionObserver(placementId, spot, element);
|
17806
|
+
// Attach click event listener
|
17807
|
+
element.addEventListener('click', async () => {
|
17808
|
+
var _a, _b;
|
17809
|
+
this.pubSub.publish(exports.RMN_SPOT_EVENT.CLICK, {
|
17810
|
+
placementId,
|
17811
|
+
spotId: spot.id,
|
17812
|
+
element,
|
17813
|
+
});
|
17814
|
+
// Fire click event
|
17815
|
+
await this.fireEvent({
|
17816
|
+
event: exports.RMN_SPOT_EVENT.CLICK,
|
17817
|
+
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 : '',
|
17818
|
+
});
|
17819
|
+
});
|
17820
|
+
// Publish spot created event
|
17821
|
+
this.pubSub.publish(exports.RMN_SPOT_EVENT.MOUNTED, {
|
17822
|
+
placementId,
|
17823
|
+
spotId: spot.id,
|
17824
|
+
spotType: spot.spot,
|
17825
|
+
spotVariant: spot.variant,
|
17826
|
+
element,
|
17827
|
+
});
|
17828
|
+
}
|
17829
|
+
unregisterSpot(spotId) {
|
17830
|
+
const spotData = this.activeSpots.get(spotId);
|
17831
|
+
if (spotData) {
|
17832
|
+
this.intersectionObserver.unobserve(spotData.element);
|
17833
|
+
// this.resizeObserver?.disconnect();
|
17834
|
+
this.pubSub.publish(exports.RMN_SPOT_EVENT.UNMOUNTED, {
|
17835
|
+
placementId: spotData.placementId,
|
17836
|
+
spotId,
|
17837
|
+
});
|
17838
|
+
this.activeSpots.delete(spotId);
|
17839
|
+
}
|
17840
|
+
}
|
17841
|
+
handleIntersectionObserver(placementId, spot, element) {
|
17842
|
+
const spotIsVisibleCb = async () => {
|
17843
|
+
var _a, _b;
|
17844
|
+
this.pubSub.publish(exports.RMN_SPOT_EVENT.IMPRESSION, {
|
17845
|
+
placementId,
|
17846
|
+
spotId: spot.id,
|
17847
|
+
element,
|
17848
|
+
});
|
17849
|
+
this.intersectionObserver.unobserve(element);
|
17850
|
+
this.activeSpots.set(spot.id, {
|
17851
|
+
placementId,
|
17852
|
+
element,
|
17853
|
+
impressionTracked: true,
|
17854
|
+
});
|
17855
|
+
// Fire impression event
|
17856
|
+
await this.fireEvent({
|
17857
|
+
event: exports.RMN_SPOT_EVENT.IMPRESSION,
|
17858
|
+
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 : '',
|
17859
|
+
});
|
17860
|
+
};
|
17861
|
+
this.intersectionObserver.observe(element, spotIsVisibleCb);
|
17862
|
+
}
|
17863
|
+
subscribe(eventType, callback) {
|
17864
|
+
return this.pubSub.subscribe(eventType, callback);
|
17865
|
+
}
|
17866
|
+
publish(eventType, data) {
|
17867
|
+
this.pubSub.publish(eventType, data);
|
17868
|
+
}
|
17869
|
+
/**
|
17870
|
+
* Fires an event using the navigator.sendBeacon method and redirects the user if the event is a click event.
|
17871
|
+
*
|
17872
|
+
* @param {IFireEventParams} params - The parameters for firing the event.
|
17873
|
+
* @param {RMN_SPOT_EVENT} params.event - The event type.
|
17874
|
+
* @param {string} params.eventUrl - The URL to which the event is sent.
|
17875
|
+
* @returns {Promise<void>} - A promise that resolves when the event is fired.
|
17876
|
+
*/
|
17877
|
+
async fireEvent({ event, eventUrl }) {
|
17878
|
+
const didFireEvent = navigator.sendBeacon(eventUrl);
|
17879
|
+
if (didFireEvent && event === exports.RMN_SPOT_EVENT.CLICK) {
|
17880
|
+
window.location.href = this.getRedirectUrlFromPayload(eventUrl);
|
17881
|
+
}
|
17882
|
+
}
|
17883
|
+
/**
|
17884
|
+
* Extracts and decodes a URL from a base64-encoded query parameter.
|
17885
|
+
*
|
17886
|
+
* @param {string} url - The URL containing the base64-encoded query parameter.
|
17887
|
+
* @returns {string} - The decoded URL or an empty string if decoding fails.
|
17888
|
+
*/
|
17889
|
+
getRedirectUrlFromPayload(url) {
|
17890
|
+
var _a, _b;
|
17891
|
+
const base64String = (_a = new URL(url).searchParams.get('e')) !== null && _a !== void 0 ? _a : '';
|
17892
|
+
try {
|
17893
|
+
const data = JSON.parse(atob(base64String));
|
17894
|
+
return (_b = data.ur) !== null && _b !== void 0 ? _b : '';
|
17895
|
+
}
|
17896
|
+
catch (_c) {
|
17897
|
+
return '';
|
17898
|
+
}
|
17899
|
+
}
|
17900
|
+
}
|
17901
|
+
|
17620
17902
|
const SELECTION_API_PATH = '/spots/selection';
|
17621
17903
|
|
17622
17904
|
class SelectionService extends BaseApi {
|
@@ -17651,6 +17933,7 @@ class LiquidCommerceRmnClient {
|
|
17651
17933
|
constructor(auth) {
|
17652
17934
|
this.selectionService = SelectionService.getInstance(auth);
|
17653
17935
|
this.elementService = ElementService.getInstance();
|
17936
|
+
this.eventService = EventService.getInstance();
|
17654
17937
|
}
|
17655
17938
|
/**
|
17656
17939
|
* Makes a selection request on our server based on the provided data.
|
@@ -17701,6 +17984,14 @@ class LiquidCommerceRmnClient {
|
|
17701
17984
|
}
|
17702
17985
|
}
|
17703
17986
|
}
|
17987
|
+
/**
|
17988
|
+
* Returns the event manager instance.
|
17989
|
+
*
|
17990
|
+
* @return {EventService} - The event manager instance.
|
17991
|
+
*/
|
17992
|
+
eventManager() {
|
17993
|
+
return this.eventService;
|
17994
|
+
}
|
17704
17995
|
/**
|
17705
17996
|
* Makes a selection request on our server based on the provided data.
|
17706
17997
|
*
|
@@ -17741,6 +18032,11 @@ class LiquidCommerceRmnClient {
|
|
17741
18032
|
console.warn(`RmnSdk: Failed to inject carousel spot element. Could not create element for type "${spot.spot}".`);
|
17742
18033
|
return;
|
17743
18034
|
}
|
18035
|
+
this.eventSpotElement({
|
18036
|
+
spot,
|
18037
|
+
placementId: placement.id,
|
18038
|
+
element: content,
|
18039
|
+
});
|
17744
18040
|
carouselSlides.push(content);
|
17745
18041
|
}
|
17746
18042
|
const { maxWidth, maxHeight } = spots.reduce((max, spot) => ({
|
@@ -17750,6 +18046,7 @@ class LiquidCommerceRmnClient {
|
|
17750
18046
|
const carouselElement = this.elementService.createCarouselElement({
|
17751
18047
|
slides: carouselSlides,
|
17752
18048
|
config: {
|
18049
|
+
fluid: config === null || config === void 0 ? void 0 : config.fluid,
|
17753
18050
|
width: maxWidth,
|
17754
18051
|
height: maxHeight,
|
17755
18052
|
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
|
@@ -17783,6 +18080,8 @@ class LiquidCommerceRmnClient {
|
|
17783
18080
|
const spotElement = this.elementService.createSpotElement({
|
17784
18081
|
content,
|
17785
18082
|
config: {
|
18083
|
+
fluid: config === null || config === void 0 ? void 0 : config.fluid,
|
18084
|
+
spot: spot.spot,
|
17786
18085
|
width: spot.width,
|
17787
18086
|
height: spot.height,
|
17788
18087
|
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
|
@@ -17792,8 +18091,20 @@ class LiquidCommerceRmnClient {
|
|
17792
18091
|
console.warn(`RmnSdk: Failed to inject spot element. Could not create element for type "${injectItem.spotType}".`);
|
17793
18092
|
return;
|
17794
18093
|
}
|
18094
|
+
this.eventSpotElement({
|
18095
|
+
spot,
|
18096
|
+
placementId: injectItem.placementId,
|
18097
|
+
element: spotElement,
|
18098
|
+
});
|
17795
18099
|
placement.replaceChildren(spotElement);
|
17796
18100
|
}
|
18101
|
+
eventSpotElement({ spot, placementId, element, }) {
|
18102
|
+
this.eventService.registerSpot({
|
18103
|
+
placementId,
|
18104
|
+
element,
|
18105
|
+
spot,
|
18106
|
+
});
|
18107
|
+
}
|
17797
18108
|
/**
|
17798
18109
|
* Prevents duplicate placement ids in the inject data.
|
17799
18110
|
*
|