@everymatrix/lottery-oddsbom-ticket-bet 0.7.26 → 0.7.27

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const lotteryOddsbomTicketBet = require('./lottery-oddsbom-ticket-bet-6aa76dcd.js');
5
+ const lotteryOddsbomTicketBet = require('./lottery-oddsbom-ticket-bet-886fd964.js');
6
6
  require('./index-b8e9c8e4.js');
7
7
 
8
8
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-b8e9c8e4.js');
6
- const lotteryOddsbomTicketBet = require('./lottery-oddsbom-ticket-bet-6aa76dcd.js');
6
+ const lotteryOddsbomTicketBet = require('./lottery-oddsbom-ticket-bet-886fd964.js');
7
7
 
8
8
  // This icon file is generated automatically.
9
9
  var ArrowUpOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M868 545.5L536.1 163a31.96 31.96 0 00-48.3 0L156 545.5a7.97 7.97 0 006 13.2h81c4.6 0 9-2 12.1-5.5L474 300.9V864c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V300.9l218.9 252.3c3 3.5 7.4 5.5 12.1 5.5h81c6.8 0 10.5-8 6-13.2z" } }] }, "name": "arrow-up", "theme": "outlined" };
@@ -111,13 +111,13 @@ const LotteryOddsbomBullet = class {
111
111
  }
112
112
  handleMbSourceChange(newValue, oldValue) {
113
113
  if (newValue != oldValue) {
114
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
114
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
115
115
  }
116
116
  }
117
117
  componentDidLoad() {
118
118
  if (this.stylingContainer) {
119
119
  if (this.mbSource)
120
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
120
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
121
121
  if (this.clientStyling)
122
122
  lotteryOddsbomTicketBet.setClientStyling(this.stylingContainer, this.clientStyling);
123
123
  if (this.clientStylingUrl)
@@ -208,7 +208,7 @@ const LotteryOddsbomBulletGroup = class {
208
208
  }
209
209
  handleMbSourceChange(newValue, oldValue) {
210
210
  if (newValue != oldValue) {
211
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
211
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
212
212
  }
213
213
  }
214
214
  oddsbomBulletToggleHandler(event) {
@@ -251,7 +251,7 @@ const LotteryOddsbomBulletGroup = class {
251
251
  componentDidLoad() {
252
252
  if (this.stylingContainer) {
253
253
  if (this.mbSource)
254
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
254
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
255
255
  if (this.clientStyling)
256
256
  lotteryOddsbomTicketBet.setClientStyling(this.stylingContainer, this.clientStyling);
257
257
  if (this.clientStylingUrl)
@@ -415,7 +415,7 @@ const LotteryOddsbomOddschart = class {
415
415
  }
416
416
  handleMbSourceChange(newValue, oldValue) {
417
417
  if (newValue != oldValue) {
418
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
418
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
419
419
  }
420
420
  }
421
421
  handleMatchInfoChange(newValue) {
@@ -429,7 +429,7 @@ const LotteryOddsbomOddschart = class {
429
429
  componentDidLoad() {
430
430
  if (this.stylingContainer) {
431
431
  if (this.mbSource)
432
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
432
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
433
433
  if (this.clientStyling)
434
434
  lotteryOddsbomTicketBet.setClientStyling(this.stylingContainer, this.clientStyling);
435
435
  if (this.clientStylingUrl)
@@ -541,13 +541,13 @@ const LotteryOddsbomOddschartInput = class {
541
541
  }
542
542
  handleMbSourceChange(newValue, oldValue) {
543
543
  if (newValue != oldValue) {
544
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
544
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
545
545
  }
546
546
  }
547
547
  componentDidLoad() {
548
548
  if (this.stylingContainer) {
549
549
  if (this.mbSource)
550
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
550
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
551
551
  if (this.clientStyling)
552
552
  lotteryOddsbomTicketBet.setClientStyling(this.stylingContainer, this.clientStyling);
553
553
  if (this.clientStylingUrl)
@@ -606,7 +606,7 @@ const LotteryOddsbomTicketBoard = class {
606
606
  }
607
607
  handleMbSourceChange(newValue, oldValue) {
608
608
  if (newValue != oldValue) {
609
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
609
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
610
610
  }
611
611
  }
612
612
  componentWillLoad() {
@@ -677,7 +677,7 @@ const LotteryOddsbomTicketBoard = class {
677
677
  componentDidLoad() {
678
678
  if (this.stylingContainer) {
679
679
  if (this.mbSource)
680
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
680
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
681
681
  if (this.clientStyling)
682
682
  lotteryOddsbomTicketBet.setClientStyling(this.stylingContainer, this.clientStyling);
683
683
  if (this.clientStylingUrl)
@@ -756,7 +756,7 @@ const LotteryOddsbomTicketButton = class {
756
756
  }
757
757
  handleMbSourceChange(newValue, oldValue) {
758
758
  if (newValue != oldValue) {
759
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
759
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
760
760
  }
761
761
  }
762
762
  disconnectedCallback() {
@@ -823,7 +823,7 @@ const LotteryOddsbomTicketSelection = class {
823
823
  }
824
824
  handleMbSourceChange(newValue, oldValue) {
825
825
  if (newValue != oldValue) {
826
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
826
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
827
827
  }
828
828
  }
829
829
  componentWillLoad() {
@@ -832,7 +832,7 @@ const LotteryOddsbomTicketSelection = class {
832
832
  componentDidLoad() {
833
833
  if (this.stylingContainer) {
834
834
  if (this.mbSource)
835
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
835
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
836
836
  if (this.clientStyling)
837
837
  lotteryOddsbomTicketBet.setClientStyling(this.stylingContainer, this.clientStyling);
838
838
  if (this.clientStylingUrl)
@@ -990,7 +990,7 @@ const LotteryTippingDialog = class {
990
990
  }
991
991
  handleMbSourceChange(newValue, oldValue) {
992
992
  if (newValue != oldValue) {
993
- lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
993
+ lotteryOddsbomTicketBet.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
994
994
  }
995
995
  }
996
996
  componentWillLoad() {
@@ -2,6 +2,8 @@
2
2
 
3
3
  const index = require('./index-b8e9c8e4.js');
4
4
 
5
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
6
+
5
7
  /**
6
8
  * @name setClientStyling
7
9
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -47,18 +49,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
47
49
  * @param {HTMLElement} stylingContainer The highest element of the widget
48
50
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
49
51
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
52
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
50
53
  */
51
- function setStreamStyling(stylingContainer, domain, subscription) {
52
- if (window.emMessageBus) {
53
- const sheet = document.createElement('style');
54
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
55
+ if (!window.emMessageBus) return;
54
56
 
55
- window.emMessageBus.subscribe(domain, (data) => {
56
- sheet.innerHTML = data;
57
- if (stylingContainer) {
58
- stylingContainer.appendChild(sheet);
59
- }
60
- });
57
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
58
+
59
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
60
+ subscription = getStyleTagSubscription(stylingContainer, domain);
61
+
62
+ return subscription;
61
63
  }
64
+
65
+ if (!window[StyleCacheKey]) {
66
+ window[StyleCacheKey] = {};
67
+ }
68
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
69
+
70
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
71
+ const wrappedUnsubscribe = () => {
72
+ if (window[StyleCacheKey][domain]) {
73
+ const cachedObject = window[StyleCacheKey][domain];
74
+ cachedObject.refCount > 1
75
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
76
+ : delete window[StyleCacheKey][domain];
77
+ }
78
+
79
+ originalUnsubscribe();
80
+ };
81
+ subscription.unsubscribe = wrappedUnsubscribe;
82
+
83
+ return subscription;
84
+ }
85
+
86
+ function getStyleTagSubscription(stylingContainer, domain) {
87
+ const sheet = document.createElement('style');
88
+
89
+ return window.emMessageBus.subscribe(domain, (data) => {
90
+ if (stylingContainer) {
91
+ sheet.innerHTML = data;
92
+ stylingContainer.appendChild(sheet);
93
+ }
94
+ });
95
+ }
96
+
97
+ function getAdoptStyleSubscription(stylingContainer, domain) {
98
+ return window.emMessageBus.subscribe(domain, (data) => {
99
+ if (!stylingContainer) return;
100
+
101
+ const shadowRoot = stylingContainer.getRootNode();
102
+ const cacheStyleObject = window[StyleCacheKey];
103
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
104
+
105
+ if (!cachedStyle) {
106
+ cachedStyle = new CSSStyleSheet();
107
+ cachedStyle.replaceSync(data);
108
+ cacheStyleObject[domain] = {
109
+ sheet: cachedStyle,
110
+ refCount: 1
111
+ };
112
+ } else {
113
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
114
+ }
115
+
116
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
117
+ if (!currentSheets.includes(cachedStyle)) {
118
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
119
+ }
120
+ });
62
121
  }
63
122
 
64
123
  function _typeof(o) {
@@ -9644,7 +9703,7 @@ const LotteryOddsbomTicketBet = class {
9644
9703
  }
9645
9704
  handleMbSourceChange(newValue, oldValue) {
9646
9705
  if (newValue != oldValue) {
9647
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
9706
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
9648
9707
  }
9649
9708
  }
9650
9709
  componentWillLoad() {
@@ -9687,7 +9746,7 @@ const LotteryOddsbomTicketBet = class {
9687
9746
  async componentDidLoad() {
9688
9747
  if (this.stylingContainer) {
9689
9748
  if (this.mbSource)
9690
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
9749
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
9691
9750
  if (this.clientStyling)
9692
9751
  setClientStyling(this.stylingContainer, this.clientStyling);
9693
9752
  if (this.clientStylingUrl)
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { L as LotteryOddsbomTicketBet } from './lottery-oddsbom-ticket-bet-32060989.js';
1
+ export { L as LotteryOddsbomTicketBet } from './lottery-oddsbom-ticket-bet-1e36d8ab.js';
2
2
  import './index-9dee9d86.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-9dee9d86.js';
2
- import { s as setClientStyling, a as setClientStylingURL, b as setStreamStyling, c as showNotification, t as translate$1, d as stringToBase64, r as resolveTranslationUrl$1, f as formatNumber, g as getTranslations$1, M as MAX_DISPLAY_OPTION_NUM } from './lottery-oddsbom-ticket-bet-32060989.js';
3
- export { L as lottery_oddsbom_ticket_bet } from './lottery-oddsbom-ticket-bet-32060989.js';
2
+ import { s as setClientStyling, a as setClientStylingURL, b as setStreamStyling, c as showNotification, t as translate$1, d as stringToBase64, r as resolveTranslationUrl$1, f as formatNumber, g as getTranslations$1, M as MAX_DISPLAY_OPTION_NUM } from './lottery-oddsbom-ticket-bet-1e36d8ab.js';
3
+ export { L as lottery_oddsbom_ticket_bet } from './lottery-oddsbom-ticket-bet-1e36d8ab.js';
4
4
 
5
5
  // This icon file is generated automatically.
6
6
  var ArrowUpOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M868 545.5L536.1 163a31.96 31.96 0 00-48.3 0L156 545.5a7.97 7.97 0 006 13.2h81c4.6 0 9-2 12.1-5.5L474 300.9V864c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V300.9l218.9 252.3c3 3.5 7.4 5.5 12.1 5.5h81c6.8 0 10.5-8 6-13.2z" } }] }, "name": "arrow-up", "theme": "outlined" };
@@ -108,13 +108,13 @@ const LotteryOddsbomBullet = class {
108
108
  }
109
109
  handleMbSourceChange(newValue, oldValue) {
110
110
  if (newValue != oldValue) {
111
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
111
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
112
112
  }
113
113
  }
114
114
  componentDidLoad() {
115
115
  if (this.stylingContainer) {
116
116
  if (this.mbSource)
117
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
117
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
118
118
  if (this.clientStyling)
119
119
  setClientStyling(this.stylingContainer, this.clientStyling);
120
120
  if (this.clientStylingUrl)
@@ -205,7 +205,7 @@ const LotteryOddsbomBulletGroup = class {
205
205
  }
206
206
  handleMbSourceChange(newValue, oldValue) {
207
207
  if (newValue != oldValue) {
208
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
208
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
209
209
  }
210
210
  }
211
211
  oddsbomBulletToggleHandler(event) {
@@ -248,7 +248,7 @@ const LotteryOddsbomBulletGroup = class {
248
248
  componentDidLoad() {
249
249
  if (this.stylingContainer) {
250
250
  if (this.mbSource)
251
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
251
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
252
252
  if (this.clientStyling)
253
253
  setClientStyling(this.stylingContainer, this.clientStyling);
254
254
  if (this.clientStylingUrl)
@@ -412,7 +412,7 @@ const LotteryOddsbomOddschart = class {
412
412
  }
413
413
  handleMbSourceChange(newValue, oldValue) {
414
414
  if (newValue != oldValue) {
415
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
415
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
416
416
  }
417
417
  }
418
418
  handleMatchInfoChange(newValue) {
@@ -426,7 +426,7 @@ const LotteryOddsbomOddschart = class {
426
426
  componentDidLoad() {
427
427
  if (this.stylingContainer) {
428
428
  if (this.mbSource)
429
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
429
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
430
430
  if (this.clientStyling)
431
431
  setClientStyling(this.stylingContainer, this.clientStyling);
432
432
  if (this.clientStylingUrl)
@@ -538,13 +538,13 @@ const LotteryOddsbomOddschartInput = class {
538
538
  }
539
539
  handleMbSourceChange(newValue, oldValue) {
540
540
  if (newValue != oldValue) {
541
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
541
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
542
542
  }
543
543
  }
544
544
  componentDidLoad() {
545
545
  if (this.stylingContainer) {
546
546
  if (this.mbSource)
547
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
547
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
548
548
  if (this.clientStyling)
549
549
  setClientStyling(this.stylingContainer, this.clientStyling);
550
550
  if (this.clientStylingUrl)
@@ -603,7 +603,7 @@ const LotteryOddsbomTicketBoard = class {
603
603
  }
604
604
  handleMbSourceChange(newValue, oldValue) {
605
605
  if (newValue != oldValue) {
606
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
606
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
607
607
  }
608
608
  }
609
609
  componentWillLoad() {
@@ -674,7 +674,7 @@ const LotteryOddsbomTicketBoard = class {
674
674
  componentDidLoad() {
675
675
  if (this.stylingContainer) {
676
676
  if (this.mbSource)
677
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
677
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
678
678
  if (this.clientStyling)
679
679
  setClientStyling(this.stylingContainer, this.clientStyling);
680
680
  if (this.clientStylingUrl)
@@ -753,7 +753,7 @@ const LotteryOddsbomTicketButton = class {
753
753
  }
754
754
  handleMbSourceChange(newValue, oldValue) {
755
755
  if (newValue != oldValue) {
756
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
756
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
757
757
  }
758
758
  }
759
759
  disconnectedCallback() {
@@ -820,7 +820,7 @@ const LotteryOddsbomTicketSelection = class {
820
820
  }
821
821
  handleMbSourceChange(newValue, oldValue) {
822
822
  if (newValue != oldValue) {
823
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
823
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
824
824
  }
825
825
  }
826
826
  componentWillLoad() {
@@ -829,7 +829,7 @@ const LotteryOddsbomTicketSelection = class {
829
829
  componentDidLoad() {
830
830
  if (this.stylingContainer) {
831
831
  if (this.mbSource)
832
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
832
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
833
833
  if (this.clientStyling)
834
834
  setClientStyling(this.stylingContainer, this.clientStyling);
835
835
  if (this.clientStylingUrl)
@@ -987,7 +987,7 @@ const LotteryTippingDialog = class {
987
987
  }
988
988
  handleMbSourceChange(newValue, oldValue) {
989
989
  if (newValue != oldValue) {
990
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
990
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
991
991
  }
992
992
  }
993
993
  componentWillLoad() {
@@ -1,5 +1,7 @@
1
1
  import { r as registerInstance, h } from './index-9dee9d86.js';
2
2
 
3
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
4
+
3
5
  /**
4
6
  * @name setClientStyling
5
7
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -45,18 +47,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
45
47
  * @param {HTMLElement} stylingContainer The highest element of the widget
46
48
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
47
49
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
50
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
48
51
  */
49
- function setStreamStyling(stylingContainer, domain, subscription) {
50
- if (window.emMessageBus) {
51
- const sheet = document.createElement('style');
52
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
53
+ if (!window.emMessageBus) return;
52
54
 
53
- window.emMessageBus.subscribe(domain, (data) => {
54
- sheet.innerHTML = data;
55
- if (stylingContainer) {
56
- stylingContainer.appendChild(sheet);
57
- }
58
- });
55
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
56
+
57
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
58
+ subscription = getStyleTagSubscription(stylingContainer, domain);
59
+
60
+ return subscription;
59
61
  }
62
+
63
+ if (!window[StyleCacheKey]) {
64
+ window[StyleCacheKey] = {};
65
+ }
66
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
67
+
68
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
69
+ const wrappedUnsubscribe = () => {
70
+ if (window[StyleCacheKey][domain]) {
71
+ const cachedObject = window[StyleCacheKey][domain];
72
+ cachedObject.refCount > 1
73
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
74
+ : delete window[StyleCacheKey][domain];
75
+ }
76
+
77
+ originalUnsubscribe();
78
+ };
79
+ subscription.unsubscribe = wrappedUnsubscribe;
80
+
81
+ return subscription;
82
+ }
83
+
84
+ function getStyleTagSubscription(stylingContainer, domain) {
85
+ const sheet = document.createElement('style');
86
+
87
+ return window.emMessageBus.subscribe(domain, (data) => {
88
+ if (stylingContainer) {
89
+ sheet.innerHTML = data;
90
+ stylingContainer.appendChild(sheet);
91
+ }
92
+ });
93
+ }
94
+
95
+ function getAdoptStyleSubscription(stylingContainer, domain) {
96
+ return window.emMessageBus.subscribe(domain, (data) => {
97
+ if (!stylingContainer) return;
98
+
99
+ const shadowRoot = stylingContainer.getRootNode();
100
+ const cacheStyleObject = window[StyleCacheKey];
101
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
102
+
103
+ if (!cachedStyle) {
104
+ cachedStyle = new CSSStyleSheet();
105
+ cachedStyle.replaceSync(data);
106
+ cacheStyleObject[domain] = {
107
+ sheet: cachedStyle,
108
+ refCount: 1
109
+ };
110
+ } else {
111
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
112
+ }
113
+
114
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
115
+ if (!currentSheets.includes(cachedStyle)) {
116
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
117
+ }
118
+ });
60
119
  }
61
120
 
62
121
  function _typeof(o) {
@@ -9642,7 +9701,7 @@ const LotteryOddsbomTicketBet = class {
9642
9701
  }
9643
9702
  handleMbSourceChange(newValue, oldValue) {
9644
9703
  if (newValue != oldValue) {
9645
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
9704
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
9646
9705
  }
9647
9706
  }
9648
9707
  componentWillLoad() {
@@ -9685,7 +9744,7 @@ const LotteryOddsbomTicketBet = class {
9685
9744
  async componentDidLoad() {
9686
9745
  if (this.stylingContainer) {
9687
9746
  if (this.mbSource)
9688
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
9747
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
9689
9748
  if (this.clientStyling)
9690
9749
  setClientStyling(this.stylingContainer, this.clientStyling);
9691
9750
  if (this.clientStylingUrl)
@@ -1 +1 @@
1
- export{L as LotteryOddsbomTicketBet}from"./lottery-oddsbom-ticket-bet-32060989.js";import"./index-9dee9d86.js";
1
+ export{L as LotteryOddsbomTicketBet}from"./lottery-oddsbom-ticket-bet-1e36d8ab.js";import"./index-9dee9d86.js";