@brndts/brndts-ads 1.13.16 → 1.13.17

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.mjs CHANGED
@@ -67891,6 +67891,7 @@ var AdsConfigsClass = /*#__PURE__*/ function(BRNDTSConfig) {
67891
67891
  adStrategies: strategies
67892
67892
  };
67893
67893
  _this.merge();
67894
+ console.log("Ads strategies fetched", _this.remote.adStrategies);
67894
67895
  })
67895
67896
  ];
67896
67897
  case 1:
@@ -71435,16 +71436,20 @@ var RegionBorderPlugin = /*#__PURE__*/ function() {
71435
71436
  {
71436
71437
  key: "beforeShow",
71437
71438
  value: function beforeShow(region) {
71438
- var _this_options;
71439
- if (!region.hasContent) {
71440
- return Promise.resolve();
71441
- }
71442
- if ((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.useFeather) {
71443
- region.content.view.classList.toggle("BRNDTS_R_FTH", true);
71444
- } else {
71445
- region.content.view.classList.toggle("BRNDTS_R_B", true);
71446
- }
71447
- return Promise.resolve();
71439
+ var _this = this;
71440
+ if (!region.hasContent) return Promise.resolve();
71441
+ return new Promise(function(resolve) {
71442
+ requestAnimationFrame(function() {
71443
+ var _this_options;
71444
+ var view = region.content.view;
71445
+ if ((_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.useFeather) {
71446
+ view.classList.toggle("BRNDTS_R_FTH", true);
71447
+ } else {
71448
+ view.classList.toggle("BRNDTS_R_B", true);
71449
+ }
71450
+ resolve();
71451
+ });
71452
+ });
71448
71453
  }
71449
71454
  },
71450
71455
  {
@@ -72918,10 +72923,15 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement) {
72918
72923
  key: "assurePlaybackState",
72919
72924
  value: function assurePlaybackState(play) {
72920
72925
  if (this.media && this.media.hasPlayed) {
72921
- var _this__source;
72922
- if (((_this__source = this._source) === null || _this__source === void 0 ? void 0 : _this__source.videoId) && this.videoId && this.videoId.length > 0 && this._source.videoId !== this.videoId) {
72923
- this._source.videoId = this.videoId;
72924
- this.emit("UPDATED_SOURCE", this._source.videoId);
72926
+ var _this_instance;
72927
+ var newVideoIndex = (_this_instance = this.instance) === null || _this_instance === void 0 ? void 0 : _this_instance.getPlaylistIndex();
72928
+ if (newVideoIndex !== this.currentVideoIndex) {
72929
+ this.currentVideoIndex = newVideoIndex;
72930
+ if (this._source && this._source.type === "playlist") {
72931
+ var _this__source;
72932
+ this._source.videoId = this.videoId;
72933
+ this.emit("UPDATED_SOURCE", (_this__source = this._source) === null || _this__source === void 0 ? void 0 : _this__source.videoId);
72934
+ }
72925
72935
  }
72926
72936
  }
72927
72937
  if (this.media && play && !this.media.hasPlayed) {
@@ -72957,11 +72967,13 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement) {
72957
72967
  key: "handleYTPlayerReady",
72958
72968
  value: function handleYTPlayerReady(event) {
72959
72969
  var _this = this;
72970
+ var _this_instance;
72960
72971
  if (this.instance) {
72961
72972
  this.context.logger.warn("Instance already found!");
72962
72973
  return;
72963
72974
  }
72964
72975
  this.instance = event.target;
72976
+ this.currentVideoIndex = (_this_instance = this.instance) === null || _this_instance === void 0 ? void 0 : _this_instance.getPlaylistIndex();
72965
72977
  this.ready = true;
72966
72978
  this.observeResize();
72967
72979
  this.context.store.dispatch({
@@ -75523,236 +75535,6 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
75523
75535
  ]);
75524
75536
  return VideoRegionsDataManager;
75525
75537
  }(import_events4.EventEmitter);
75526
- // src/Ads/VideoAds/VideoRegionsData/VideoRegionsDataManagerDecorator.ts
75527
- var VideoRegionsDataManagerDecorator = /*#__PURE__*/ function() {
75528
- "use strict";
75529
- function VideoRegionsDataManagerDecorator(component) {
75530
- _class_call_check(this, VideoRegionsDataManagerDecorator);
75531
- this.component = component;
75532
- }
75533
- _create_class(VideoRegionsDataManagerDecorator, [
75534
- {
75535
- key: "data",
75536
- get: function get() {
75537
- return this.component.data;
75538
- }
75539
- },
75540
- {
75541
- key: "on",
75542
- value: function on(event, handler) {
75543
- return this.component.on(event, handler);
75544
- }
75545
- },
75546
- {
75547
- key: "fetch",
75548
- value: function fetch1() {
75549
- return this.component.fetch();
75550
- }
75551
- },
75552
- {
75553
- key: "seek",
75554
- value: function seek(timestamp) {
75555
- return this.component.seek(timestamp);
75556
- }
75557
- },
75558
- {
75559
- key: "check",
75560
- value: function check(timestamp) {
75561
- return this.component.check(timestamp);
75562
- }
75563
- },
75564
- {
75565
- key: "get",
75566
- value: function get(timestamp) {
75567
- return this.component.get(timestamp);
75568
- }
75569
- },
75570
- {
75571
- key: "destroy",
75572
- value: function destroy() {
75573
- return this.component.destroy();
75574
- }
75575
- },
75576
- {
75577
- key: "dumps",
75578
- value: function dumps(from, to) {
75579
- return this.component.dumps(from, to);
75580
- }
75581
- },
75582
- {
75583
- key: "loads",
75584
- value: function loads() {
75585
- return this.component.loads();
75586
- }
75587
- }
75588
- ]);
75589
- return VideoRegionsDataManagerDecorator;
75590
- }();
75591
- // src/Ads/VideoAds/VideoRegionsDurationDecorator.ts
75592
- var VideoRegionsDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataManagerDecorator) {
75593
- "use strict";
75594
- _inherits(VideoRegionsDurationDecorator, VideoRegionsDataManagerDecorator);
75595
- function VideoRegionsDurationDecorator(component, params) {
75596
- _class_call_check(this, VideoRegionsDurationDecorator);
75597
- var _this;
75598
- _this = _call_super(this, VideoRegionsDurationDecorator, [
75599
- component
75600
- ]);
75601
- _this.params = params;
75602
- return _this;
75603
- }
75604
- _create_class(VideoRegionsDurationDecorator, [
75605
- {
75606
- key: "check",
75607
- value: function check(timestamp) {
75608
- var totalDuration = 0;
75609
- var last;
75610
- var result;
75611
- var workingTimestamp = timestamp;
75612
- while(totalDuration < this.params.duration){
75613
- var regions2 = this.component.get(workingTimestamp);
75614
- if (!regions2 || !regions2.regions) {
75615
- return null;
75616
- }
75617
- if (!last) {
75618
- last = regions2.regions.map(function(r3) {
75619
- return r3.id;
75620
- });
75621
- result = _to_consumable_array(regions2.regions);
75622
- return {
75623
- timestamp_start: timestamp,
75624
- timestamp_end: timestamp + totalDuration,
75625
- regions: result
75626
- };
75627
- }
75628
- var validRegions = regions2.regions.filter(function(reg) {
75629
- return last === null || last === void 0 ? void 0 : last.includes(reg.id);
75630
- });
75631
- if (validRegions.length <= 0) {
75632
- return null;
75633
- }
75634
- var duration = 0;
75635
- if (regions2.timestamp_start < workingTimestamp) {
75636
- duration = regions2.timestamp_end - workingTimestamp;
75637
- } else {
75638
- duration = regions2.timestamp_end - regions2.timestamp_start;
75639
- }
75640
- totalDuration += duration;
75641
- workingTimestamp = regions2.timestamp_end + 1e-3 + 1e3;
75642
- last = validRegions.map(function(r3) {
75643
- return r3.id;
75644
- });
75645
- result = _to_consumable_array(validRegions);
75646
- }
75647
- if (!result) {
75648
- return null;
75649
- }
75650
- return {
75651
- timestamp_start: timestamp,
75652
- timestamp_end: timestamp + totalDuration,
75653
- regions: result
75654
- };
75655
- }
75656
- }
75657
- ]);
75658
- return VideoRegionsDurationDecorator;
75659
- }(VideoRegionsDataManagerDecorator);
75660
- var VideoRegionsMaxDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataManagerDecorator) {
75661
- "use strict";
75662
- _inherits(VideoRegionsMaxDurationDecorator, VideoRegionsDataManagerDecorator);
75663
- function VideoRegionsMaxDurationDecorator(component, params) {
75664
- _class_call_check(this, VideoRegionsMaxDurationDecorator);
75665
- var _this;
75666
- _this = _call_super(this, VideoRegionsMaxDurationDecorator, [
75667
- component
75668
- ]);
75669
- _this.params = params;
75670
- return _this;
75671
- }
75672
- _create_class(VideoRegionsMaxDurationDecorator, [
75673
- {
75674
- key: "check",
75675
- value: function check(timestamp) {
75676
- var totalDuration = 0;
75677
- var last;
75678
- var result;
75679
- var workingTimestamp = timestamp;
75680
- var filteredRegions = [];
75681
- do {
75682
- var regions2 = this.component.get(workingTimestamp);
75683
- if (!regions2 || !regions2.regions) {
75684
- break;
75685
- }
75686
- if (!last) {
75687
- last = regions2.regions.map(function(r3) {
75688
- return r3.id;
75689
- });
75690
- result = _to_consumable_array(regions2.regions);
75691
- continue;
75692
- }
75693
- filteredRegions = regions2.regions.filter(function(reg) {
75694
- if (last.includes(reg.id)) {
75695
- return true;
75696
- }
75697
- return false;
75698
- });
75699
- if (filteredRegions.length <= 0) {
75700
- break;
75701
- }
75702
- var duration = 0;
75703
- if (regions2.timestamp_start < workingTimestamp) {
75704
- duration = regions2.timestamp_end - workingTimestamp;
75705
- } else {
75706
- duration = regions2.timestamp_end - regions2.timestamp_start;
75707
- }
75708
- totalDuration += duration;
75709
- workingTimestamp = regions2.timestamp_end + 1e-3 + 1e3;
75710
- last = filteredRegions.map(function(r3) {
75711
- return r3.id;
75712
- });
75713
- result = _to_consumable_array(filteredRegions);
75714
- }while (true);
75715
- if (!result || totalDuration < this.params.minDuration) {
75716
- return null;
75717
- }
75718
- return {
75719
- timestamp_start: timestamp,
75720
- timestamp_end: timestamp + totalDuration,
75721
- regions: result
75722
- };
75723
- }
75724
- }
75725
- ]);
75726
- return VideoRegionsMaxDurationDecorator;
75727
- }(VideoRegionsDataManagerDecorator);
75728
- var VideoRegionsDecoratorFactory = /*#__PURE__*/ function() {
75729
- "use strict";
75730
- function VideoRegionsDecoratorFactory() {
75731
- _class_call_check(this, VideoRegionsDecoratorFactory);
75732
- }
75733
- _create_class(VideoRegionsDecoratorFactory, null, [
75734
- {
75735
- key: "decorate",
75736
- value: function decorate(component, params) {
75737
- if (!params) {
75738
- return component;
75739
- }
75740
- if (params.visibility_duration) {
75741
- return new VideoRegionsDurationDecorator(component, {
75742
- duration: params.visibility_duration.value
75743
- });
75744
- }
75745
- if (params.minimum_display_time) {
75746
- return new VideoRegionsMaxDurationDecorator(component, {
75747
- minDuration: params.minimum_display_time.value
75748
- });
75749
- }
75750
- return component;
75751
- }
75752
- }
75753
- ]);
75754
- return VideoRegionsDecoratorFactory;
75755
- }();
75756
75538
  // src/Ads/VideoAds/State/Store.ts
75757
75539
  function reducer(state, action) {
75758
75540
  switch(action.type){
@@ -76286,10 +76068,9 @@ var DynamicDurationPresentation = /*#__PURE__*/ function(AbstractPresentation) {
76286
76068
  this.stopRetry();
76287
76069
  this.startPacing();
76288
76070
  if (opts.expectedDuration && !this.presentationTimer.isPaused) {
76289
- this.presentationTimer.setDuration(opts.expectedDuration);
76290
- } else {
76291
- this.presentationTimer.resume();
76071
+ this.presentationTimer.setDuration(opts.expectedDuration * 1e3);
76292
76072
  }
76073
+ this.presentationTimer.resume();
76293
76074
  }
76294
76075
  },
76295
76076
  {
@@ -79818,6 +79599,8 @@ var Controls = /*#__PURE__*/ function() {
79818
79599
  this.context = context;
79819
79600
  this.container = document.createElement("div");
79820
79601
  this.container.id = "BRNDTS_CTL";
79602
+ this.container.style.width = "100%";
79603
+ this.container.style.height = "100%";
79821
79604
  this.buildControls();
79822
79605
  }
79823
79606
  _create_class(Controls, [
@@ -79919,6 +79702,8 @@ var Backdrop = /*#__PURE__*/ function() {
79919
79702
  this.context = context;
79920
79703
  this.container = document.createElement("div");
79921
79704
  this.container.id = "BRNDTS_BKD";
79705
+ this.container.style.width = "100%";
79706
+ this.container.style.height = "100%";
79922
79707
  }
79923
79708
  _create_class(Backdrop, [
79924
79709
  {
@@ -81749,7 +81534,6 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
81749
81534
  var _this_adPresentationStrategy, _this_regionsRenderer;
81750
81535
  (_this_adPresentationStrategy = this.adPresentationStrategy) === null || _this_adPresentationStrategy === void 0 ? void 0 : _this_adPresentationStrategy.stop();
81751
81536
  (_this_regionsRenderer = this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.clear();
81752
- this.context.logger.info("NotBasicPresentationMode has been stopped.");
81753
81537
  }
81754
81538
  },
81755
81539
  {
@@ -81859,6 +81643,7 @@ var RegionFactory = /*#__PURE__*/ function() {
81859
81643
  }));
81860
81644
  }
81861
81645
  plugins2.push(new RegionMaskPlugin());
81646
+ plugins2.push(new RegionAnimationPlugin("OPACITY"));
81862
81647
  }
81863
81648
  if (!((_this_deps2 = this.deps) === null || _this_deps2 === void 0 ? void 0 : (_this_deps_config1 = _this_deps2.config) === null || _this_deps_config1 === void 0 ? void 0 : (_this_deps_config_getAdsConfig_general1 = _this_deps_config1.getAdsConfig().general) === null || _this_deps_config_getAdsConfig_general1 === void 0 ? void 0 : (_this_deps_config_getAdsConfig_general_debug_mode1 = _this_deps_config_getAdsConfig_general1.debug_mode) === null || _this_deps_config_getAdsConfig_general_debug_mode1 === void 0 ? void 0 : _this_deps_config_getAdsConfig_general_debug_mode1.value) && (this.deps.strategy === "banner" || this.deps.strategy === "bannerv2" || this.deps.strategy === "bannerv2_ocr" || this.deps.strategy === "test")) {
81864
81649
  plugins2.push(new RegionBorderPlugin(), new RegionAnimationPlugin());
@@ -82448,8 +82233,10 @@ var NotBasicPresentationMode = /*#__PURE__*/ function() {
82448
82233
  expectedDuration: regions2.timestamp_end - regions2.timestamp_start
82449
82234
  });
82450
82235
  } else {
82451
- var _this_adPresentationStrategy1;
82236
+ var _this_adPresentationStrategy1, _this_regionsRenderer, _this_auxElementsRenderer;
82452
82237
  (_this_adPresentationStrategy1 = _this.adPresentationStrategy) === null || _this_adPresentationStrategy1 === void 0 ? void 0 : _this_adPresentationStrategy1.endedPresentation();
82238
+ (_this_regionsRenderer = _this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.clear();
82239
+ (_this_auxElementsRenderer = _this.auxElementsRenderer) === null || _this_auxElementsRenderer === void 0 ? void 0 : _this_auxElementsRenderer.clear();
82453
82240
  }
82454
82241
  }).on("pace", function() {
82455
82242
  try {
@@ -82502,7 +82289,6 @@ var NotBasicPresentationMode = /*#__PURE__*/ function() {
82502
82289
  (_this_adPresentationStrategy = this.adPresentationStrategy) === null || _this_adPresentationStrategy === void 0 ? void 0 : _this_adPresentationStrategy.stop();
82503
82290
  (_this_regionsRenderer = this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.clear();
82504
82291
  (_this_auxElementsRenderer = this.auxElementsRenderer) === null || _this_auxElementsRenderer === void 0 ? void 0 : _this_auxElementsRenderer.clear();
82505
- this.context.logger.info("NotBasicPresentationMode has been stopped.");
82506
82292
  }
82507
82293
  },
82508
82294
  {
@@ -82541,30 +82327,304 @@ var PresentationModeFactory = /*#__PURE__*/ function() {
82541
82327
  ]);
82542
82328
  return PresentationModeFactory;
82543
82329
  }();
82544
- // src/Ads/VideoAds/VideoAd.ts
82545
- var VideoAd = /*#__PURE__*/ function() {
82330
+ // src/Ads/VideoAds/VideoRegionsData/VideoRegionsDataManagerDecorator.ts
82331
+ var VideoRegionsDataManagerDecorator = /*#__PURE__*/ function() {
82546
82332
  "use strict";
82547
- function VideoAd(context, target) {
82548
- _class_call_check(this, VideoAd);
82549
- this.handleInfo = this.handleInfo.bind(this);
82550
- this.context = context;
82551
- var videoAdContext = {
82552
- config: context.config,
82553
- elements: {
82554
- container: null,
82555
- original: null,
82556
- fullscreen: null
82557
- },
82558
- store: new Store(void 0, this.context.logger),
82559
- user: context.user,
82560
- location: context.location,
82561
- device: context.device,
82562
- consent: context.consent,
82563
- logger: context.logger,
82564
- service: context.service
82565
- };
82566
- var media = MediaElementFactory.get(videoAdContext, target);
82567
- if (!media) {
82333
+ function VideoRegionsDataManagerDecorator(component) {
82334
+ _class_call_check(this, VideoRegionsDataManagerDecorator);
82335
+ this.component = component;
82336
+ }
82337
+ _create_class(VideoRegionsDataManagerDecorator, [
82338
+ {
82339
+ key: "data",
82340
+ get: function get() {
82341
+ return this.component.data;
82342
+ }
82343
+ },
82344
+ {
82345
+ key: "on",
82346
+ value: function on(event, handler) {
82347
+ return this.component.on(event, handler);
82348
+ }
82349
+ },
82350
+ {
82351
+ key: "fetch",
82352
+ value: function fetch1() {
82353
+ return this.component.fetch();
82354
+ }
82355
+ },
82356
+ {
82357
+ key: "seek",
82358
+ value: function seek(timestamp) {
82359
+ return this.component.seek(timestamp);
82360
+ }
82361
+ },
82362
+ {
82363
+ key: "check",
82364
+ value: function check(timestamp) {
82365
+ return this.component.check(timestamp);
82366
+ }
82367
+ },
82368
+ {
82369
+ key: "get",
82370
+ value: function get(timestamp) {
82371
+ return this.component.get(timestamp);
82372
+ }
82373
+ },
82374
+ {
82375
+ key: "destroy",
82376
+ value: function destroy() {
82377
+ return this.component.destroy();
82378
+ }
82379
+ },
82380
+ {
82381
+ key: "dumps",
82382
+ value: function dumps(from, to) {
82383
+ return this.component.dumps(from, to);
82384
+ }
82385
+ },
82386
+ {
82387
+ key: "loads",
82388
+ value: function loads() {
82389
+ return this.component.loads();
82390
+ }
82391
+ }
82392
+ ]);
82393
+ return VideoRegionsDataManagerDecorator;
82394
+ }();
82395
+ // src/Ads/VideoAds/VideoRegionsData/VideoRegionsDecorators.ts
82396
+ var VideoRegionsDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataManagerDecorator) {
82397
+ "use strict";
82398
+ _inherits(VideoRegionsDurationDecorator, VideoRegionsDataManagerDecorator);
82399
+ function VideoRegionsDurationDecorator(component, params) {
82400
+ _class_call_check(this, VideoRegionsDurationDecorator);
82401
+ var _this;
82402
+ _this = _call_super(this, VideoRegionsDurationDecorator, [
82403
+ component
82404
+ ]);
82405
+ _this.params = params;
82406
+ return _this;
82407
+ }
82408
+ _create_class(VideoRegionsDurationDecorator, [
82409
+ {
82410
+ key: "check",
82411
+ value: function check(timestamp) {
82412
+ var totalDuration = 0;
82413
+ var last;
82414
+ var result;
82415
+ var workingTimestamp = timestamp;
82416
+ while(totalDuration < this.params.duration){
82417
+ var regions2 = this.component.get(workingTimestamp);
82418
+ if (!regions2 || !regions2.regions) {
82419
+ return null;
82420
+ }
82421
+ if (!last) {
82422
+ last = regions2.regions.map(function(r3) {
82423
+ return r3.id;
82424
+ });
82425
+ result = _to_consumable_array(regions2.regions);
82426
+ }
82427
+ var validRegions = regions2.regions.filter(function(reg) {
82428
+ return last === null || last === void 0 ? void 0 : last.includes(reg.id);
82429
+ });
82430
+ if (validRegions.length <= 0) {
82431
+ return null;
82432
+ }
82433
+ var duration = 0;
82434
+ if (regions2.timestamp_start < workingTimestamp) {
82435
+ duration = regions2.timestamp_end - workingTimestamp;
82436
+ } else {
82437
+ duration = regions2.timestamp_end - regions2.timestamp_start;
82438
+ }
82439
+ totalDuration += duration;
82440
+ workingTimestamp = regions2.timestamp_end + 0.01;
82441
+ last = validRegions.map(function(r3) {
82442
+ return r3.id;
82443
+ });
82444
+ result = _to_consumable_array(validRegions);
82445
+ }
82446
+ if (!result) {
82447
+ return null;
82448
+ }
82449
+ return {
82450
+ timestamp_start: timestamp,
82451
+ timestamp_end: timestamp + totalDuration,
82452
+ regions: result
82453
+ };
82454
+ }
82455
+ }
82456
+ ]);
82457
+ return VideoRegionsDurationDecorator;
82458
+ }(VideoRegionsDataManagerDecorator);
82459
+ var VideoRegionsMaxDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataManagerDecorator) {
82460
+ "use strict";
82461
+ _inherits(VideoRegionsMaxDurationDecorator, VideoRegionsDataManagerDecorator);
82462
+ function VideoRegionsMaxDurationDecorator(component, params) {
82463
+ _class_call_check(this, VideoRegionsMaxDurationDecorator);
82464
+ var _this;
82465
+ _this = _call_super(this, VideoRegionsMaxDurationDecorator, [
82466
+ component
82467
+ ]);
82468
+ _this.params = params;
82469
+ return _this;
82470
+ }
82471
+ _create_class(VideoRegionsMaxDurationDecorator, [
82472
+ {
82473
+ key: "check",
82474
+ value: function check(timestamp) {
82475
+ var totalDuration = 0;
82476
+ var last;
82477
+ var result;
82478
+ var workingTimestamp = timestamp;
82479
+ do {
82480
+ var regions2 = this.component.get(workingTimestamp);
82481
+ if (!regions2 || !regions2.regions) {
82482
+ break;
82483
+ }
82484
+ if (!last) {
82485
+ last = regions2.regions.map(function(r3) {
82486
+ return r3.id;
82487
+ });
82488
+ result = _to_consumable_array(regions2.regions);
82489
+ }
82490
+ var validRegions = regions2.regions.filter(function(reg) {
82491
+ return last === null || last === void 0 ? void 0 : last.includes(reg.id);
82492
+ });
82493
+ if (validRegions.length <= 0) {
82494
+ break;
82495
+ }
82496
+ var duration = 0;
82497
+ if (regions2.timestamp_start < workingTimestamp) {
82498
+ duration = regions2.timestamp_end - workingTimestamp;
82499
+ } else {
82500
+ duration = regions2.timestamp_end - regions2.timestamp_start;
82501
+ }
82502
+ totalDuration += duration;
82503
+ workingTimestamp = regions2.timestamp_end + 0.01;
82504
+ last = validRegions.map(function(r3) {
82505
+ return r3.id;
82506
+ });
82507
+ result = _to_consumable_array(validRegions);
82508
+ }while (true);
82509
+ if (!result || totalDuration < this.params.minDuration) {
82510
+ return null;
82511
+ }
82512
+ return {
82513
+ timestamp_start: timestamp,
82514
+ timestamp_end: timestamp + totalDuration,
82515
+ regions: result
82516
+ };
82517
+ }
82518
+ }
82519
+ ]);
82520
+ return VideoRegionsMaxDurationDecorator;
82521
+ }(VideoRegionsDataManagerDecorator);
82522
+ var VideoRegionsTypeFilterDecorator = /*#__PURE__*/ function(VideoRegionsDataManagerDecorator) {
82523
+ "use strict";
82524
+ _inherits(VideoRegionsTypeFilterDecorator, VideoRegionsDataManagerDecorator);
82525
+ function VideoRegionsTypeFilterDecorator(component, params) {
82526
+ _class_call_check(this, VideoRegionsTypeFilterDecorator);
82527
+ var _this;
82528
+ _this = _call_super(this, VideoRegionsTypeFilterDecorator, [
82529
+ component
82530
+ ]);
82531
+ if (params && params.value && Array.isArray(params.value)) {
82532
+ var _params_setting_constraints;
82533
+ var regionsMap = ((_params_setting_constraints = params.setting.constraints) === null || _params_setting_constraints === void 0 ? void 0 : _params_setting_constraints.mapped_allowed_values_ids) || {};
82534
+ _this.allowedRegions = params.value.map(function(r3) {
82535
+ return regionsMap[r3];
82536
+ }).filter(Boolean);
82537
+ }
82538
+ return _this;
82539
+ }
82540
+ _create_class(VideoRegionsTypeFilterDecorator, [
82541
+ {
82542
+ key: "check",
82543
+ value: function check(timestamp) {
82544
+ var _this = this;
82545
+ var data = this.component.check(timestamp);
82546
+ if (this.allowedRegions !== void 0 && data && data.regions) {
82547
+ data.regions = data.regions.filter(function(region) {
82548
+ var _this_allowedRegions;
82549
+ return (_this_allowedRegions = _this.allowedRegions) === null || _this_allowedRegions === void 0 ? void 0 : _this_allowedRegions.includes(region.id);
82550
+ });
82551
+ }
82552
+ return data;
82553
+ }
82554
+ },
82555
+ {
82556
+ key: "get",
82557
+ value: function get(timestamp) {
82558
+ var _this = this;
82559
+ var data = this.component.get(timestamp);
82560
+ if (this.allowedRegions !== void 0 && data && data.regions) {
82561
+ data.regions = data.regions.filter(function(region) {
82562
+ var _this_allowedRegions;
82563
+ return (_this_allowedRegions = _this.allowedRegions) === null || _this_allowedRegions === void 0 ? void 0 : _this_allowedRegions.includes(region.id);
82564
+ });
82565
+ }
82566
+ return data;
82567
+ }
82568
+ }
82569
+ ]);
82570
+ return VideoRegionsTypeFilterDecorator;
82571
+ }(VideoRegionsDataManagerDecorator);
82572
+ var VideoRegionsDecoratorFactory = /*#__PURE__*/ function() {
82573
+ "use strict";
82574
+ function VideoRegionsDecoratorFactory() {
82575
+ _class_call_check(this, VideoRegionsDecoratorFactory);
82576
+ }
82577
+ _create_class(VideoRegionsDecoratorFactory, null, [
82578
+ {
82579
+ key: "decorate",
82580
+ value: function decorate(component, params) {
82581
+ var _params_visibility_duration, _params_minimum_display_time, _params_ad_placements_and_sizes;
82582
+ var target = component;
82583
+ if (!params) {
82584
+ return target;
82585
+ }
82586
+ if ((_params_visibility_duration = params.visibility_duration) === null || _params_visibility_duration === void 0 ? void 0 : _params_visibility_duration.value) {
82587
+ target = new VideoRegionsDurationDecorator(target, {
82588
+ duration: params.visibility_duration.value
82589
+ });
82590
+ } else if ((_params_minimum_display_time = params.minimum_display_time) === null || _params_minimum_display_time === void 0 ? void 0 : _params_minimum_display_time.value) {
82591
+ target = new VideoRegionsMaxDurationDecorator(target, {
82592
+ minDuration: params.minimum_display_time.value
82593
+ });
82594
+ }
82595
+ if ((_params_ad_placements_and_sizes = params.ad_placements_and_sizes) === null || _params_ad_placements_and_sizes === void 0 ? void 0 : _params_ad_placements_and_sizes.value) {
82596
+ target = new VideoRegionsTypeFilterDecorator(target, params.ad_placements_and_sizes);
82597
+ }
82598
+ return target;
82599
+ }
82600
+ }
82601
+ ]);
82602
+ return VideoRegionsDecoratorFactory;
82603
+ }();
82604
+ // src/Ads/VideoAds/VideoAd.ts
82605
+ var VideoAd = /*#__PURE__*/ function() {
82606
+ "use strict";
82607
+ function VideoAd(context, target) {
82608
+ _class_call_check(this, VideoAd);
82609
+ this.handleInfo = this.handleInfo.bind(this);
82610
+ this.context = context;
82611
+ var videoAdContext = {
82612
+ config: context.config,
82613
+ elements: {
82614
+ container: null,
82615
+ original: null,
82616
+ fullscreen: null
82617
+ },
82618
+ store: new Store(void 0, this.context.logger),
82619
+ user: context.user,
82620
+ location: context.location,
82621
+ device: context.device,
82622
+ consent: context.consent,
82623
+ logger: context.logger,
82624
+ service: context.service
82625
+ };
82626
+ var media = MediaElementFactory.get(videoAdContext, target);
82627
+ if (!media) {
82568
82628
  throw new Error("No media element found!");
82569
82629
  }
82570
82630
  videoAdContext.media = media;
@@ -82618,7 +82678,8 @@ var VideoAd = /*#__PURE__*/ function() {
82618
82678
  }, {
82619
82679
  logger: this.videoAdContext.logger,
82620
82680
  // @ts-expect-error
82621
- service: this.videoAdContext.service.join("".concat(data.video, "-").concat(this.videoAdContext.config.getStrategy().code))
82681
+ service: this.videoAdContext.service.join("".concat(data.video, "-").concat(this.videoAdContext.config.getStrategy().code)),
82682
+ config: this.videoAdContext.config
82622
82683
  });
82623
82684
  this.videoAdContext.store.dispatch({
82624
82685
  type: "UPDATE_VIDEO_INFO",
@@ -82683,6 +82744,7 @@ var VideoAd = /*#__PURE__*/ function() {
82683
82744
  key: "updateRegionData",
82684
82745
  value: function updateRegionData() {
82685
82746
  var _this = this;
82747
+ var _this_presentation;
82686
82748
  if (this.videoRegions) {
82687
82749
  var _this_videoRegions;
82688
82750
  (_this_videoRegions = this.videoRegions) === null || _this_videoRegions === void 0 ? void 0 : _this_videoRegions.destroy();
@@ -82691,10 +82753,7 @@ var VideoAd = /*#__PURE__*/ function() {
82691
82753
  this.videoAdContext.recorder.destroy();
82692
82754
  this.videoAdContext.recorder = void 0;
82693
82755
  }
82694
- if (this.presentation) {
82695
- this.presentation.destroy();
82696
- this.presentation = void 0;
82697
- }
82756
+ (_this_presentation = this.presentation) === null || _this_presentation === void 0 ? void 0 : _this_presentation.stop();
82698
82757
  this.context.service.send("hs", {
82699
82758
  source: this.videoAdContext.media.source,
82700
82759
  strategy: this.videoAdContext.config.getStrategy().code
@@ -82712,7 +82771,8 @@ var VideoAd = /*#__PURE__*/ function() {
82712
82771
  }
82713
82772
  }, {
82714
82773
  logger: _this.videoAdContext.logger,
82715
- service: _this.context.service.join("".concat(data.video, "-").concat(_this.videoAdContext.config.getStrategy().code))
82774
+ service: _this.context.service.join("".concat(data.video, "-").concat(_this.videoAdContext.config.getStrategy().code)),
82775
+ config: _this.videoAdContext.config
82716
82776
  });
82717
82777
  _this.videoAdContext.store.dispatch({
82718
82778
  type: "UPDATE_VIDEO_INFO",
@@ -82723,15 +82783,12 @@ var VideoAd = /*#__PURE__*/ function() {
82723
82783
  }
82724
82784
  });
82725
82785
  _this.videoRegions = VideoRegionsDecoratorFactory.decorate(videoRegions, _this.videoAdContext.config.getStrategySettings());
82726
- _this.presentation = _this.presentationFactory.get({
82727
- strategy: _this.videoAdContext.config.getStrategy().code
82728
- });
82729
82786
  _this.videoAdContext.data = _this.videoRegions;
82730
82787
  _this.videoAdContext.recorder = _this.recorderFactory.create(_this.videoAdContext.media, {
82731
82788
  id: data.video,
82732
82789
  ts: 0
82733
82790
  });
82734
- (_this_presentation = _this.presentation) === null || _this_presentation === void 0 ? void 0 : _this_presentation.setup();
82791
+ (_this_presentation = _this.presentation) === null || _this_presentation === void 0 ? void 0 : _this_presentation.start();
82735
82792
  });
82736
82793
  }
82737
82794
  },
@@ -83247,8 +83304,157 @@ var Location = /*#__PURE__*/ function() {
83247
83304
  ]);
83248
83305
  return Location;
83249
83306
  }();
83250
- // src/Service/Realtime.ts
83307
+ // src/Service/LocalRealtime.ts
83251
83308
  var import_events10 = __toESM(require_events());
83309
+ var DATA_STORE = {
83310
+ "video1": {}
83311
+ };
83312
+ var VIDEO_LIBRARY = {
83313
+ "video1": {
83314
+ source: ""
83315
+ }
83316
+ };
83317
+ var BRNDTSLocalRealtime = /*#__PURE__*/ function(_import_events10_default) {
83318
+ "use strict";
83319
+ _inherits(BRNDTSLocalRealtime, _import_events10_default);
83320
+ function BRNDTSLocalRealtime(options, deps) {
83321
+ _class_call_check(this, BRNDTSLocalRealtime);
83322
+ var _this;
83323
+ _this = _call_super(this, BRNDTSLocalRealtime);
83324
+ _this.connected = new Changeable(false);
83325
+ _this.handlers = {
83326
+ info: [],
83327
+ result: [],
83328
+ completed: [],
83329
+ aborted: []
83330
+ };
83331
+ _this.options = options;
83332
+ _this.logger = deps.logger;
83333
+ if (!_this.options.ns) {
83334
+ window.__brndts_local_realtime = _this;
83335
+ }
83336
+ return _this;
83337
+ }
83338
+ _create_class(BRNDTSLocalRealtime, [
83339
+ {
83340
+ key: "handleOpen",
83341
+ value: function handleOpen() {
83342
+ this.connected.value = true;
83343
+ this.emit("connected");
83344
+ }
83345
+ },
83346
+ {
83347
+ key: "handleClose",
83348
+ value: function handleClose() {
83349
+ this.connected.value = false;
83350
+ this.emit("disconnected");
83351
+ }
83352
+ },
83353
+ {
83354
+ key: "connect",
83355
+ value: function connect() {
83356
+ this.handleOpen();
83357
+ }
83358
+ },
83359
+ {
83360
+ key: "respond",
83361
+ value: function respond(event, payload) {
83362
+ if (this.handlers[event]) {
83363
+ this.handlers[event].forEach(function(handler) {
83364
+ handler(payload);
83365
+ });
83366
+ }
83367
+ }
83368
+ },
83369
+ {
83370
+ key: "loads",
83371
+ value: function loads(videoId) {
83372
+ var _this = this;
83373
+ var _this_logger;
83374
+ (_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.log("[REALTIME LOCAL] Loading data for :", videoId);
83375
+ var input = document.createElement("input");
83376
+ input.type = "file";
83377
+ input === null || input === void 0 ? void 0 : input.addEventListener("change", function(event) {
83378
+ var _input_files;
83379
+ var file = input === null || input === void 0 ? void 0 : (_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files[0];
83380
+ if (!file) {
83381
+ console.log("No file selected.");
83382
+ return;
83383
+ }
83384
+ var reader = new FileReader();
83385
+ reader.onload = function(event2) {
83386
+ var _event2_target;
83387
+ var fileContent = event2 === null || event2 === void 0 ? void 0 : (_event2_target = event2.target) === null || _event2_target === void 0 ? void 0 : _event2_target.result;
83388
+ if (fileContent) {
83389
+ var _this_logger;
83390
+ var parsedData = JSON.parse(fileContent);
83391
+ DATA_STORE[videoId] = parsedData;
83392
+ (_this_logger = _this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.log("[REALTIME LOCAL] Loaded data for :", videoId);
83393
+ _this.respond("result", DATA_STORE[videoId]);
83394
+ }
83395
+ };
83396
+ reader.readAsText(file);
83397
+ });
83398
+ input.click();
83399
+ }
83400
+ },
83401
+ {
83402
+ key: "send",
83403
+ value: function send(event) {
83404
+ for(var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
83405
+ payload[_key - 1] = arguments[_key];
83406
+ }
83407
+ var _this_logger;
83408
+ (_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.log("[REALTIME LOCAL] Received event :", event, payload);
83409
+ if (event === "hs") {
83410
+ var _this_logger1;
83411
+ (_this_logger1 = this.logger) === null || _this_logger1 === void 0 ? void 0 : _this_logger1.log("[REALTIME LOCAL] handling event :", event, payload);
83412
+ var _payload = _sliced_to_array(payload, 2), data = _payload[0], cb = _payload[1];
83413
+ var videoId = "video1";
83414
+ VIDEO_LIBRARY[videoId] = {
83415
+ // @ts-expect-error
83416
+ source: data.source
83417
+ };
83418
+ cb === null || cb === void 0 ? void 0 : cb({
83419
+ video: videoId
83420
+ });
83421
+ }
83422
+ }
83423
+ },
83424
+ {
83425
+ key: "handle",
83426
+ value: function handle(event, handler) {
83427
+ if (!this.handlers[event]) {
83428
+ this.handlers[event] = [];
83429
+ }
83430
+ this.handlers[event].push(handler);
83431
+ }
83432
+ },
83433
+ {
83434
+ key: "join",
83435
+ value: function join(ns) {
83436
+ var _this = this;
83437
+ setTimeout(function() {
83438
+ var _ref = _sliced_to_array(ns.match(/^([^-]+)-(.+)$/) || [], 2), video = _ref[0], strategy = _ref[1];
83439
+ if (video && DATA_STORE[video]) {
83440
+ var regions2 = DATA_STORE[video];
83441
+ _this.respond("result", regions2);
83442
+ }
83443
+ }, 150);
83444
+ return this;
83445
+ }
83446
+ },
83447
+ {
83448
+ key: "destroy",
83449
+ value: function destroy() {
83450
+ this.handleClose();
83451
+ }
83452
+ }
83453
+ ]);
83454
+ return BRNDTSLocalRealtime;
83455
+ }(import_events10.default);
83456
+ // src/Service/Realtime.ts
83457
+ var import_events11 = __toESM(require_events());
83252
83458
  // node_modules/engine.io-parser/build/esm/commons.js
83253
83459
  var PACKET_TYPES = /* @__PURE__ */ Object.create(null);
83254
83460
  PACKET_TYPES["open"] = "0";
@@ -87113,9 +87319,9 @@ Object.assign(lookup2, {
87113
87319
  connect: lookup2
87114
87320
  });
87115
87321
  // src/Service/Realtime.ts
87116
- var BRNDTSRealtime = /*#__PURE__*/ function(_import_events10_default) {
87322
+ var BRNDTSRealtime = /*#__PURE__*/ function(_import_events11_default) {
87117
87323
  "use strict";
87118
- _inherits(_BRNDTSRealtime, _import_events10_default);
87324
+ _inherits(_BRNDTSRealtime, _import_events11_default);
87119
87325
  function _BRNDTSRealtime(options, deps) {
87120
87326
  _class_call_check(this, _BRNDTSRealtime);
87121
87327
  var _this;
@@ -87213,9 +87419,37 @@ var BRNDTSRealtime = /*#__PURE__*/ function(_import_events10_default) {
87213
87419
  }
87214
87420
  ]);
87215
87421
  return _BRNDTSRealtime;
87216
- }(import_events10.default);
87217
- // src/Service/LocalRealtime.ts
87218
- var import_events11 = __toESM(require_events());
87422
+ }(import_events11.default);
87423
+ // src/Service/ServiceFactory.ts
87424
+ var ServiceFactory = /*#__PURE__*/ function() {
87425
+ "use strict";
87426
+ function ServiceFactory() {
87427
+ _class_call_check(this, ServiceFactory);
87428
+ }
87429
+ _create_class(ServiceFactory, null, [
87430
+ {
87431
+ key: "createService",
87432
+ value: function createService(context) {
87433
+ var serviceType = "remote";
87434
+ if (serviceType === "local") {
87435
+ return new BRNDTSLocalRealtime({
87436
+ host: context.config.get("host"),
87437
+ key: context.config.get("key")
87438
+ }, {
87439
+ logger: context.logger
87440
+ });
87441
+ }
87442
+ return new BRNDTSRealtime({
87443
+ host: context.config.get("host"),
87444
+ key: context.config.get("key")
87445
+ }, {
87446
+ logger: context.logger
87447
+ });
87448
+ }
87449
+ }
87450
+ ]);
87451
+ return ServiceFactory;
87452
+ }();
87219
87453
  // src/index.ts
87220
87454
  var BrndtsAds = /*#__PURE__*/ function() {
87221
87455
  "use strict";
@@ -87268,10 +87502,16 @@ var BrndtsAds = /*#__PURE__*/ function() {
87268
87502
  case 1:
87269
87503
  _state.trys.push([
87270
87504
  1,
87271
- 3,
87505
+ 4,
87272
87506
  ,
87273
- 4
87507
+ 5
87274
87508
  ]);
87509
+ if (!this.context.config.get("enabled")) {
87510
+ this.context.logger.error("Setup failed: disabled by config");
87511
+ return [
87512
+ 2
87513
+ ];
87514
+ }
87275
87515
  this.context.location = new Location();
87276
87516
  this.context.consent = ConsentFactory.get(this.context.logger);
87277
87517
  return [
@@ -87282,35 +87522,30 @@ var BrndtsAds = /*#__PURE__*/ function() {
87282
87522
  _state.sent();
87283
87523
  this.context.user = new User(this.context.config, this.context.consent);
87284
87524
  this.context.device = new Device();
87285
- this.context.device.collect();
87286
- if (!this.context.config.get("enabled")) {
87287
- this.context.logger.error("Setup failed: disabled by config");
87288
- return [
87289
- 2
87290
- ];
87291
- }
87292
- this.context.service = new BRNDTSRealtime({
87293
- host: this.context.config.get("host"),
87294
- key: this.context.config.get("key")
87295
- }, {
87296
- logger: this.context.logger
87297
- });
87525
+ return [
87526
+ 4,
87527
+ this.context.device.collect()
87528
+ ];
87529
+ case 3:
87530
+ _state.sent();
87531
+ console.log("BRNDTS Ads Presenter started with config");
87532
+ this.context.service = ServiceFactory.createService(this.context);
87298
87533
  this.context.service.on("connected", this.handleConnected);
87299
87534
  this.context.service.connect();
87300
87535
  return [
87301
87536
  3,
87302
- 4
87537
+ 5
87303
87538
  ];
87304
- case 3:
87539
+ case 4:
87305
87540
  error = _state.sent();
87306
87541
  if (_instanceof(error, Error)) {
87307
- this.context.logger.warn("Setup failed: no media element found!");
87542
+ console.log("Error during setup: ", error);
87308
87543
  }
87309
87544
  return [
87310
87545
  3,
87311
- 4
87546
+ 5
87312
87547
  ];
87313
- case 4:
87548
+ case 5:
87314
87549
  return [
87315
87550
  2
87316
87551
  ];