stormcloud-video-player 0.8.18 → 0.8.19

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.
Files changed (34) hide show
  1. package/README.md +67 -83
  2. package/dist/stormcloud-vp.min.js +1 -1
  3. package/lib/index.cjs +635 -346
  4. package/lib/index.cjs.map +1 -1
  5. package/lib/index.d.cts +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/index.js +635 -346
  8. package/lib/index.js.map +1 -1
  9. package/lib/player/AdBreakOrchestrator.cjs +11 -11
  10. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  11. package/lib/player/AdBreakOrchestrator.d.cts +3 -3
  12. package/lib/player/{VmapManager.cjs → AdConfigManager.cjs} +503 -214
  13. package/lib/player/AdConfigManager.cjs.map +1 -0
  14. package/lib/player/{VmapManager.d.cts → AdConfigManager.d.cts} +2 -2
  15. package/lib/player/StormcloudVideoPlayer.cjs +635 -346
  16. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  17. package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
  18. package/lib/players/HlsPlayer.cjs +635 -346
  19. package/lib/players/HlsPlayer.cjs.map +1 -1
  20. package/lib/players/index.cjs +635 -346
  21. package/lib/players/index.cjs.map +1 -1
  22. package/lib/ui/StormcloudVideoPlayer.cjs +635 -346
  23. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  24. package/lib/utils/ctvVastSignals.cjs +92 -33
  25. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  26. package/lib/utils/ctvVastSignals.d.cts +1 -13
  27. package/lib/utils/vastEnvironmentSignals.cjs +439 -0
  28. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -0
  29. package/lib/utils/vastEnvironmentSignals.d.cts +16 -0
  30. package/lib/utils/vastMacros.cjs +299 -25
  31. package/lib/utils/vastMacros.cjs.map +1 -1
  32. package/lib/utils/vastMacros.d.cts +3 -1
  33. package/package.json +1 -1
  34. package/lib/player/VmapManager.cjs.map +0 -1
@@ -2322,22 +2322,326 @@ function initializePolyfills() {
2322
2322
  polyfillTextEncoder();
2323
2323
  polyfillPromiseFinally();
2324
2324
  }
2325
- // src/utils/vastMacros.ts
2326
- function generateCorrelator() {
2327
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2325
+ // src/utils/vastEnvironmentSignals.ts
2326
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2327
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
2328
+ var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
2329
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2330
+ var DEVICE_ID_STORAGE_KEYS = [
2331
+ "rdid",
2332
+ "ifa",
2333
+ "advertisingId",
2334
+ "advertising_id",
2335
+ "deviceAdvertisingId",
2336
+ "aaid",
2337
+ "adid",
2338
+ "rida",
2339
+ "tifa",
2340
+ "lgudid"
2341
+ ];
2342
+ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
2343
+ "aaid",
2344
+ "adid"
2345
+ ]);
2346
+ function resolveVastEnvironmentSignals(isCtv) {
2347
+ var _ref, _bridgeSignals_limitAdTracking;
2348
+ var bridgeSignals = readNativeBridgeSignals();
2349
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
2350
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || inferDeviceIdType();
2351
+ var limitAdTracking = deviceId != null ? (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false : void 0;
2352
+ if (isCtv) {
2353
+ return _object_spread_props(_object_spread({
2354
+ isCtv: true,
2355
+ contentUrl: bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL,
2356
+ appId: bridgeSignals.appId || readStoredString("appId") || readStoredString("msid") || AIRY_ANDROID_APP_ID,
2357
+ appName: bridgeSignals.appName || readStoredString("appName") || readStoredString("an") || AIRY_APP_NAME,
2358
+ sessionId: getOrCreateCtvSessionId()
2359
+ }, deviceId ? {
2360
+ deviceId: deviceId
2361
+ } : {}, deviceIdType ? {
2362
+ deviceIdType: deviceIdType
2363
+ } : {}, limitAdTracking != null ? {
2364
+ limitAdTracking: limitAdTracking
2365
+ } : {}), {
2366
+ deviceTypeHint: 5
2367
+ });
2368
+ }
2369
+ return _object_spread({
2370
+ isCtv: false
2371
+ }, deviceId ? {
2372
+ deviceId: deviceId
2373
+ } : {}, deviceIdType ? {
2374
+ deviceIdType: deviceIdType
2375
+ } : {}, limitAdTracking != null ? {
2376
+ limitAdTracking: limitAdTracking
2377
+ } : {});
2378
+ }
2379
+ function inferDeviceIdType() {
2380
+ if (typeof navigator === "undefined") {
2381
+ return void 0;
2382
+ }
2383
+ var ua = navigator.userAgent;
2384
+ if (/Roku/i.test(ua)) return "rida";
2385
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
2386
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
2387
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
2388
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
2389
+ if (/Android|Google TV/i.test(ua)) return "aaid";
2390
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
2391
+ return void 0;
2392
+ }
2393
+ function isEquivalentDeviceIdType(tagType, runtimeType) {
2394
+ if (!tagType || !runtimeType) return false;
2395
+ var tag = tagType.toLowerCase();
2396
+ var runtime = runtimeType.toLowerCase();
2397
+ if (tag === runtime) return true;
2398
+ return ANDROID_ID_TYPES.has(tag) && ANDROID_ID_TYPES.has(runtime);
2399
+ }
2400
+ function getOrCreateCtvSessionId() {
2401
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2402
+ if (existing) {
2403
+ return existing;
2404
+ }
2405
+ var sessionId = createUuid();
2406
+ try {
2407
+ var _window_localStorage;
2408
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2409
+ } catch (unused) {}
2410
+ return sessionId;
2411
+ }
2412
+ function createUuid() {
2413
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2414
+ return crypto.randomUUID();
2415
+ }
2416
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2417
+ var value = Math.floor(Math.random() * 16);
2418
+ var nibble = char === "x" ? value : value & 3 | 8;
2419
+ return nibble.toString(16);
2420
+ });
2421
+ }
2422
+ function readNativeBridgeSignals() {
2423
+ if (typeof window === "undefined") {
2424
+ return {};
2425
+ }
2426
+ var candidates = [
2427
+ window.__STORMCLOUD_CTV_AD_INFO__,
2428
+ window.__STORMCLOUD_CTV__,
2429
+ window.stormcloudCtv,
2430
+ window.AiryTV,
2431
+ window.Android,
2432
+ window.webOS,
2433
+ window.tizen,
2434
+ window.amazon
2435
+ ].filter(Boolean);
2436
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2437
+ try {
2438
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2439
+ var source = _step.value;
2440
+ var contentUrl = readBridgeValue(source, [
2441
+ "contentUrl",
2442
+ "url",
2443
+ "videoUrl",
2444
+ "canonicalUrl"
2445
+ ]) || void 0;
2446
+ var appId = readBridgeValue(source, [
2447
+ "appId",
2448
+ "msid",
2449
+ "applicationId",
2450
+ "packageName"
2451
+ ]) || void 0;
2452
+ var appName = readBridgeValue(source, [
2453
+ "appName",
2454
+ "an",
2455
+ "applicationName"
2456
+ ]) || void 0;
2457
+ var deviceId = readBridgeValue(source, [
2458
+ "rdid",
2459
+ "ifa",
2460
+ "advertisingId",
2461
+ "adId",
2462
+ "deviceId",
2463
+ "lgudid",
2464
+ "LGUDID",
2465
+ "tifa",
2466
+ "rida",
2467
+ "afai",
2468
+ "aaid"
2469
+ ]) || void 0;
2470
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
2471
+ var deviceIdType = readBridgeValue(source, [
2472
+ "idtype",
2473
+ "deviceIdType",
2474
+ "advertisingIdType",
2475
+ "idType"
2476
+ ]) || inferDeviceIdType();
2477
+ var limitAdTracking = readBridgeBoolean(source, [
2478
+ "is_lat",
2479
+ "limitAdTracking",
2480
+ "limitedAdTracking",
2481
+ "lat"
2482
+ ]);
2483
+ return _object_spread({}, contentUrl ? {
2484
+ contentUrl: contentUrl
2485
+ } : {}, appId ? {
2486
+ appId: appId
2487
+ } : {}, appName ? {
2488
+ appName: appName
2489
+ } : {}, deviceId ? {
2490
+ deviceId: deviceId
2491
+ } : {}, deviceId && deviceIdType ? {
2492
+ deviceIdType: deviceIdType
2493
+ } : {}, deviceId && limitAdTracking != null ? {
2494
+ limitAdTracking: limitAdTracking
2495
+ } : {});
2496
+ }
2497
+ } catch (err) {
2498
+ _didIteratorError = true;
2499
+ _iteratorError = err;
2500
+ } finally{
2328
2501
  try {
2329
- var _buf_, _buf_1;
2330
- var buf = new Uint32Array(2);
2331
- crypto.getRandomValues(buf);
2332
- var value = ((_buf_ = buf[0]) !== null && _buf_ !== void 0 ? _buf_ : 0) * 2097152 + (((_buf_1 = buf[1]) !== null && _buf_1 !== void 0 ? _buf_1 : 0) & 2097151);
2333
- if (value > 0) {
2334
- return String(value);
2502
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2503
+ _iterator.return();
2335
2504
  }
2336
- } catch (unused) {}
2505
+ } finally{
2506
+ if (_didIteratorError) {
2507
+ throw _iteratorError;
2508
+ }
2509
+ }
2510
+ }
2511
+ return {};
2512
+ }
2513
+ function readBridgeValue(source, keys) {
2514
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2515
+ try {
2516
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2517
+ var key = _step.value;
2518
+ var value = source === null || source === void 0 ? void 0 : source[key];
2519
+ if (typeof value === "string" && value) {
2520
+ return value;
2521
+ }
2522
+ if (typeof value === "function") {
2523
+ try {
2524
+ var result = value.call(source);
2525
+ if (typeof result === "string" && result) {
2526
+ return result;
2527
+ }
2528
+ } catch (unused) {}
2529
+ }
2530
+ }
2531
+ } catch (err) {
2532
+ _didIteratorError = true;
2533
+ _iteratorError = err;
2534
+ } finally{
2535
+ try {
2536
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2537
+ _iterator.return();
2538
+ }
2539
+ } finally{
2540
+ if (_didIteratorError) {
2541
+ throw _iteratorError;
2542
+ }
2543
+ }
2544
+ }
2545
+ return void 0;
2546
+ }
2547
+ function readBridgeBoolean(source, keys) {
2548
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2549
+ try {
2550
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2551
+ var key = _step.value;
2552
+ var value = source === null || source === void 0 ? void 0 : source[key];
2553
+ var normalized = normalizeBoolean(value);
2554
+ if (normalized != null) {
2555
+ return normalized;
2556
+ }
2557
+ if (typeof value === "function") {
2558
+ try {
2559
+ var result = normalizeBoolean(value.call(source));
2560
+ if (result != null) {
2561
+ return result;
2562
+ }
2563
+ } catch (unused) {}
2564
+ }
2565
+ }
2566
+ } catch (err) {
2567
+ _didIteratorError = true;
2568
+ _iteratorError = err;
2569
+ } finally{
2570
+ try {
2571
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2572
+ _iterator.return();
2573
+ }
2574
+ } finally{
2575
+ if (_didIteratorError) {
2576
+ throw _iteratorError;
2577
+ }
2578
+ }
2579
+ }
2580
+ return void 0;
2581
+ }
2582
+ function readStoredDeviceId() {
2583
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2584
+ try {
2585
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2586
+ var key = _step.value;
2587
+ var value = readStoredString(key);
2588
+ if (value) {
2589
+ return value;
2590
+ }
2591
+ }
2592
+ } catch (err) {
2593
+ _didIteratorError = true;
2594
+ _iteratorError = err;
2595
+ } finally{
2596
+ try {
2597
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2598
+ _iterator.return();
2599
+ }
2600
+ } finally{
2601
+ if (_didIteratorError) {
2602
+ throw _iteratorError;
2603
+ }
2604
+ }
2605
+ }
2606
+ return void 0;
2607
+ }
2608
+ function readStoredString(key) {
2609
+ if (typeof window === "undefined") {
2610
+ return void 0;
2611
+ }
2612
+ try {
2613
+ var _window_localStorage;
2614
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2615
+ return value || void 0;
2616
+ } catch (unused) {
2617
+ return void 0;
2337
2618
  }
2338
- return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2339
2619
  }
2620
+ function readStoredLimitAdTracking() {
2621
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2622
+ }
2623
+ function normalizeBoolean(value) {
2624
+ if (typeof value === "boolean") {
2625
+ return value;
2626
+ }
2627
+ if (typeof value === "number") {
2628
+ return value === 1;
2629
+ }
2630
+ if (typeof value === "string") {
2631
+ var normalized = value.toLowerCase();
2632
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
2633
+ return true;
2634
+ }
2635
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
2636
+ return false;
2637
+ }
2638
+ }
2639
+ return void 0;
2640
+ }
2641
+ // src/utils/vastMacros.ts
2340
2642
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
2643
+ var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
2644
+ var EXAMPLE_COM_URL = /example\.com/i;
2341
2645
  var CTV_UNSUPPORTED_PARAMS = [
2342
2646
  "description_url",
2343
2647
  "tfcd",
@@ -2352,14 +2656,265 @@ var CTV_UNSUPPORTED_PARAMS = [
2352
2656
  "gdpr_consent",
2353
2657
  "us_privacy"
2354
2658
  ];
2659
+ var INLINE_DEVICE_MACRO_REPLACEMENTS = [
2660
+ {
2661
+ pattern: /\[RDID\]/gi,
2662
+ getValue: function getValue(ctx) {
2663
+ return ctx.deviceId;
2664
+ }
2665
+ },
2666
+ {
2667
+ pattern: /\[IFA\]/gi,
2668
+ getValue: function getValue(ctx) {
2669
+ return ctx.deviceId;
2670
+ }
2671
+ },
2672
+ {
2673
+ pattern: /\[ADVERTISING[_-]?ID(?:ENTIFIER)?\]/gi,
2674
+ getValue: function getValue(ctx) {
2675
+ return ctx.deviceId;
2676
+ }
2677
+ },
2678
+ {
2679
+ pattern: /\[DEVICE[_-]?ID\]/gi,
2680
+ getValue: function getValue(ctx) {
2681
+ return ctx.deviceId;
2682
+ }
2683
+ },
2684
+ {
2685
+ pattern: /\[IDTYPE\]/gi,
2686
+ getValue: function getValue(ctx) {
2687
+ return ctx.deviceIdType;
2688
+ }
2689
+ },
2690
+ {
2691
+ pattern: /\{rdid\}/gi,
2692
+ getValue: function getValue(ctx) {
2693
+ return ctx.deviceId;
2694
+ }
2695
+ },
2696
+ {
2697
+ pattern: /\{device[_-]?id\}/gi,
2698
+ getValue: function getValue(ctx) {
2699
+ return ctx.deviceId;
2700
+ }
2701
+ },
2702
+ {
2703
+ pattern: /\{idtype\}/gi,
2704
+ getValue: function getValue(ctx) {
2705
+ return ctx.deviceIdType;
2706
+ }
2707
+ },
2708
+ {
2709
+ pattern: /%%ADVERTISING_IDENTIFIER_PLAIN%%/gi,
2710
+ getValue: function getValue(ctx) {
2711
+ return ctx.deviceId;
2712
+ }
2713
+ },
2714
+ {
2715
+ pattern: /%%ADVERTISING_ID_OPT_OUT%%/gi,
2716
+ getValue: function getValue(ctx) {
2717
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2718
+ }
2719
+ },
2720
+ {
2721
+ pattern: /%%ADVERTISING_ID_TYPE%%/gi,
2722
+ getValue: function getValue(ctx) {
2723
+ return ctx.deviceIdType;
2724
+ }
2725
+ },
2726
+ {
2727
+ pattern: /%%ADVERTISING_ID%%/gi,
2728
+ getValue: function getValue(ctx) {
2729
+ return ctx.deviceId;
2730
+ }
2731
+ },
2732
+ {
2733
+ pattern: /%%LIMIT_AD_TRACKING%%/gi,
2734
+ getValue: function getValue(ctx) {
2735
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2736
+ }
2737
+ },
2738
+ {
2739
+ pattern: /%%MSID%%/gi,
2740
+ getValue: function getValue(ctx) {
2741
+ return ctx.appId;
2742
+ }
2743
+ },
2744
+ {
2745
+ pattern: /%%APP_NAME%%/gi,
2746
+ getValue: function getValue(ctx) {
2747
+ return ctx.appName;
2748
+ }
2749
+ },
2750
+ {
2751
+ pattern: /%%SESSION_ID%%/gi,
2752
+ getValue: function getValue(ctx) {
2753
+ return ctx.sessionId;
2754
+ }
2755
+ },
2756
+ {
2757
+ pattern: /%%CORRELATOR%%/gi,
2758
+ getValue: function getValue(ctx) {
2759
+ return ctx.correlator;
2760
+ }
2761
+ }
2762
+ ];
2763
+ function isMacroPlaceholder(value) {
2764
+ if (value == null) return true;
2765
+ var trimmed = value.trim();
2766
+ if (!trimmed) return true;
2767
+ if (UNEXPANDED_MACRO_PATTERN.test(trimmed)) return true;
2768
+ return /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(trimmed);
2769
+ }
2770
+ function generateCorrelator() {
2771
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2772
+ try {
2773
+ var _buf_, _buf_1;
2774
+ var buf = new Uint32Array(2);
2775
+ crypto.getRandomValues(buf);
2776
+ var value = ((_buf_ = buf[0]) !== null && _buf_ !== void 0 ? _buf_ : 0) * 2097152 + (((_buf_1 = buf[1]) !== null && _buf_1 !== void 0 ? _buf_1 : 0) & 2097151);
2777
+ if (value > 0) {
2778
+ return String(value);
2779
+ }
2780
+ } catch (unused) {}
2781
+ }
2782
+ return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2783
+ }
2784
+ function expandInlineMacroPlaceholders(baseUrl, ctx) {
2785
+ var url = baseUrl;
2786
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2787
+ try {
2788
+ for(var _iterator = INLINE_DEVICE_MACRO_REPLACEMENTS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2789
+ var _step_value = _step.value, pattern = _step_value.pattern, getValue = _step_value.getValue;
2790
+ var value = getValue(ctx);
2791
+ if (value != null && value !== "") {
2792
+ url = url.replace(pattern, encodeURIComponent(value));
2793
+ }
2794
+ }
2795
+ } catch (err) {
2796
+ _didIteratorError = true;
2797
+ _iteratorError = err;
2798
+ } finally{
2799
+ try {
2800
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2801
+ _iterator.return();
2802
+ }
2803
+ } finally{
2804
+ if (_didIteratorError) {
2805
+ throw _iteratorError;
2806
+ }
2807
+ }
2808
+ }
2809
+ return url;
2810
+ }
2811
+ function applyDeviceIdentityParams(params, ctx) {
2812
+ var _ctx_deviceId, _ctx_deviceIdType;
2813
+ var runtimeId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
2814
+ var runtimeType = ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType();
2815
+ var tagRdid = params.get("rdid");
2816
+ var tagType = params.get("idtype");
2817
+ var tagLat = params.get("is_lat");
2818
+ var latValue = ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2819
+ if (runtimeId) {
2820
+ params.set("rdid", runtimeId);
2821
+ params.set("idtype", runtimeType || tagType || "aaid");
2822
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : isMacroPlaceholder(tagLat) ? "0" : tagLat);
2823
+ return;
2824
+ }
2825
+ var tagRdidValid = Boolean(tagRdid && !isMacroPlaceholder(tagRdid));
2826
+ var tagTypeValid = Boolean(tagType && !isMacroPlaceholder(tagType));
2827
+ if (tagRdidValid && tagTypeValid && runtimeType && !isEquivalentDeviceIdType(tagType, runtimeType)) {
2828
+ params.delete("rdid");
2829
+ params.delete("idtype");
2830
+ params.delete("is_lat");
2831
+ return;
2832
+ }
2833
+ if (tagRdidValid) {
2834
+ if (isMacroPlaceholder(tagType) && runtimeType) {
2835
+ params.set("idtype", runtimeType);
2836
+ }
2837
+ if (isMacroPlaceholder(tagLat)) {
2838
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : "0");
2839
+ }
2840
+ return;
2841
+ }
2842
+ params.delete("rdid");
2843
+ params.delete("idtype");
2844
+ params.delete("is_lat");
2845
+ }
2846
+ function removeBrokenAppNameOrphans(params, appName) {
2847
+ var toDelete = [];
2848
+ params.forEach(function(_value, key) {
2849
+ if (!key || INVALID_VAST_PARAM_KEY.test(key)) {
2850
+ toDelete.push(key);
2851
+ }
2852
+ });
2853
+ if (appName && appName.includes("&")) {
2854
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2855
+ try {
2856
+ for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2857
+ var suffix = _step.value;
2858
+ var trimmed = suffix.trimStart();
2859
+ if (!trimmed) continue;
2860
+ toDelete.push(suffix, " ".concat(trimmed), trimmed);
2861
+ }
2862
+ } catch (err) {
2863
+ _didIteratorError = true;
2864
+ _iteratorError = err;
2865
+ } finally{
2866
+ try {
2867
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2868
+ _iterator.return();
2869
+ }
2870
+ } finally{
2871
+ if (_didIteratorError) {
2872
+ throw _iteratorError;
2873
+ }
2874
+ }
2875
+ }
2876
+ }
2877
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2878
+ try {
2879
+ for(var _iterator1 = new Set(toDelete)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2880
+ var key = _step1.value;
2881
+ if (key) params.delete(key);
2882
+ }
2883
+ } catch (err) {
2884
+ _didIteratorError1 = true;
2885
+ _iteratorError1 = err;
2886
+ } finally{
2887
+ try {
2888
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2889
+ _iterator1.return();
2890
+ }
2891
+ } finally{
2892
+ if (_didIteratorError1) {
2893
+ throw _iteratorError1;
2894
+ }
2895
+ }
2896
+ }
2897
+ }
2898
+ function normalizeVastTagUrl(raw) {
2899
+ if (!raw) return raw;
2900
+ try {
2901
+ var url = new URL(raw);
2902
+ removeBrokenAppNameOrphans(url.searchParams);
2903
+ return url.toString();
2904
+ } catch (unused) {
2905
+ return raw;
2906
+ }
2907
+ }
2355
2908
  function applyVastMacros(baseUrl, ctx) {
2909
+ var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
2356
2910
  var url;
2357
2911
  try {
2358
- url = new URL(baseUrl);
2912
+ url = new URL(normalizeVastTagUrl(expandedUrl));
2359
2913
  } catch (unused) {
2360
- return replaceCorrelatorFallback(baseUrl, ctx.correlator);
2914
+ return replaceCorrelatorFallback(expandedUrl, ctx.correlator);
2361
2915
  }
2362
2916
  var params = url.searchParams;
2917
+ removeBrokenAppNameOrphans(params, ctx.appName);
2363
2918
  params.set("correlator", ctx.correlator);
2364
2919
  if (ctx.isCtv) {
2365
2920
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2397,6 +2952,12 @@ function applyVastMacros(baseUrl, ctx) {
2397
2952
  if (!ctx.isCtv) {
2398
2953
  params.set("description_url", requestUrl);
2399
2954
  }
2955
+ } else {
2956
+ var existingUrl = params.get("url") || "";
2957
+ if (EXAMPLE_COM_URL.test(existingUrl)) {
2958
+ params.delete("url");
2959
+ params.delete("description_url");
2960
+ }
2400
2961
  }
2401
2962
  if (ctx.adWillPlayMuted != null) {
2402
2963
  params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
@@ -2408,6 +2969,7 @@ function applyVastMacros(baseUrl, ctx) {
2408
2969
  params.set("msid", ctx.appId);
2409
2970
  }
2410
2971
  if (ctx.appName) {
2972
+ removeBrokenAppNameOrphans(params, ctx.appName);
2411
2973
  params.set("an", ctx.appName);
2412
2974
  }
2413
2975
  if (ctx.sessionId) {
@@ -2418,15 +2980,7 @@ function applyVastMacros(baseUrl, ctx) {
2418
2980
  } else if (ctx.isCtv) {
2419
2981
  params.set("dth", "5");
2420
2982
  }
2421
- if (ctx.deviceId && ctx.deviceIdType) {
2422
- params.set("rdid", ctx.deviceId);
2423
- params.set("idtype", ctx.deviceIdType);
2424
- params.set("is_lat", ctx.limitAdTracking ? "1" : "0");
2425
- } else {
2426
- params.delete("rdid");
2427
- params.delete("idtype");
2428
- params.delete("is_lat");
2429
- }
2983
+ applyDeviceIdentityParams(params, ctx);
2430
2984
  if (!ctx.isCtv) {
2431
2985
  var consent = ctx.consent;
2432
2986
  if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
@@ -2444,7 +2998,7 @@ function applyVastMacros(baseUrl, ctx) {
2444
2998
  }
2445
2999
  var staleKeys = [];
2446
3000
  params.forEach(function(value, key) {
2447
- if (UNEXPANDED_MACRO_PATTERN.test(value)) {
3001
+ if (isMacroPlaceholder(value)) {
2448
3002
  staleKeys.push(key);
2449
3003
  }
2450
3004
  });
@@ -2468,6 +3022,7 @@ function applyVastMacros(baseUrl, ctx) {
2468
3022
  }
2469
3023
  }
2470
3024
  }
3025
+ removeBrokenAppNameOrphans(params, ctx.appName);
2471
3026
  return url.toString();
2472
3027
  }
2473
3028
  function replaceCorrelatorFallback(baseUrl, correlator) {
@@ -3718,276 +4273,10 @@ var Scte35CueManager = /*#__PURE__*/ function() {
3718
4273
  ]);
3719
4274
  return Scte35CueManager;
3720
4275
  }();
3721
- // src/utils/ctvVastSignals.ts
3722
- var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
3723
- var AIRY_APP_NAME = "AiryTV Movies & TV";
3724
- var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
3725
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
3726
- var DEVICE_ID_STORAGE_KEYS = [
3727
- "rdid",
3728
- "ifa",
3729
- "advertisingId",
3730
- "advertising_id",
3731
- "deviceAdvertisingId",
3732
- "aaid",
3733
- "adid",
3734
- "rida",
3735
- "tifa"
3736
- ];
3737
- function resolveCtvVastSignals() {
3738
- var _ref, _bridgeSignals_limitAdTracking;
3739
- var bridgeSignals = readNativeBridgeSignals();
3740
- var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
3741
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || inferDeviceIdType();
3742
- var contentUrl = bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL;
3743
- return _object_spread_props(_object_spread({
3744
- contentUrl: contentUrl,
3745
- appId: AIRY_ANDROID_APP_ID,
3746
- appName: AIRY_APP_NAME,
3747
- sessionId: getOrCreateCtvSessionId()
3748
- }, deviceId ? {
3749
- deviceId: deviceId
3750
- } : {}, deviceId && deviceIdType ? {
3751
- deviceIdType: deviceIdType
3752
- } : {}, deviceId ? {
3753
- limitAdTracking: (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false
3754
- } : {}), {
3755
- deviceTypeHint: 5
3756
- });
3757
- }
3758
- function getOrCreateCtvSessionId() {
3759
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
3760
- if (existing) {
3761
- return existing;
3762
- }
3763
- var sessionId = createUuid();
3764
- try {
3765
- var _window_localStorage;
3766
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
3767
- } catch (unused) {}
3768
- return sessionId;
3769
- }
3770
- function createUuid() {
3771
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
3772
- return crypto.randomUUID();
3773
- }
3774
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
3775
- var value = Math.floor(Math.random() * 16);
3776
- var nibble = char === "x" ? value : value & 3 | 8;
3777
- return nibble.toString(16);
3778
- });
3779
- }
3780
- function readNativeBridgeSignals() {
3781
- if (typeof window === "undefined") {
3782
- return {};
3783
- }
3784
- var candidates = [
3785
- window.__STORMCLOUD_CTV_AD_INFO__,
3786
- window.__STORMCLOUD_CTV__,
3787
- window.stormcloudCtv,
3788
- window.AiryTV,
3789
- window.Android
3790
- ].filter(Boolean);
3791
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3792
- try {
3793
- for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3794
- var source = _step.value;
3795
- var contentUrl = readBridgeValue(source, [
3796
- "contentUrl",
3797
- "url",
3798
- "videoUrl",
3799
- "canonicalUrl"
3800
- ]) || void 0;
3801
- var deviceId = readBridgeValue(source, [
3802
- "rdid",
3803
- "ifa",
3804
- "advertisingId",
3805
- "adId",
3806
- "deviceId"
3807
- ]) || void 0;
3808
- if (!contentUrl && !deviceId) continue;
3809
- var deviceIdType = readBridgeValue(source, [
3810
- "idtype",
3811
- "deviceIdType",
3812
- "advertisingIdType"
3813
- ]) || inferDeviceIdType();
3814
- var limitAdTracking = readBridgeBoolean(source, [
3815
- "is_lat",
3816
- "limitAdTracking",
3817
- "limitedAdTracking",
3818
- "lat"
3819
- ]);
3820
- return _object_spread({}, contentUrl ? {
3821
- contentUrl: contentUrl
3822
- } : {}, deviceId ? {
3823
- deviceId: deviceId
3824
- } : {}, deviceId && deviceIdType ? {
3825
- deviceIdType: deviceIdType
3826
- } : {}, deviceId && limitAdTracking != null ? {
3827
- limitAdTracking: limitAdTracking
3828
- } : {});
3829
- }
3830
- } catch (err) {
3831
- _didIteratorError = true;
3832
- _iteratorError = err;
3833
- } finally{
3834
- try {
3835
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3836
- _iterator.return();
3837
- }
3838
- } finally{
3839
- if (_didIteratorError) {
3840
- throw _iteratorError;
3841
- }
3842
- }
3843
- }
3844
- return {};
3845
- }
3846
- function readBridgeValue(source, keys) {
3847
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3848
- try {
3849
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3850
- var key = _step.value;
3851
- var value = source === null || source === void 0 ? void 0 : source[key];
3852
- if (typeof value === "string" && value) {
3853
- return value;
3854
- }
3855
- if (typeof value === "function") {
3856
- try {
3857
- var result = value.call(source);
3858
- if (typeof result === "string" && result) {
3859
- return result;
3860
- }
3861
- } catch (unused) {}
3862
- }
3863
- }
3864
- } catch (err) {
3865
- _didIteratorError = true;
3866
- _iteratorError = err;
3867
- } finally{
3868
- try {
3869
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3870
- _iterator.return();
3871
- }
3872
- } finally{
3873
- if (_didIteratorError) {
3874
- throw _iteratorError;
3875
- }
3876
- }
3877
- }
3878
- return void 0;
3879
- }
3880
- function readBridgeBoolean(source, keys) {
3881
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3882
- try {
3883
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3884
- var key = _step.value;
3885
- var value = source === null || source === void 0 ? void 0 : source[key];
3886
- var normalized = normalizeBoolean(value);
3887
- if (normalized != null) {
3888
- return normalized;
3889
- }
3890
- if (typeof value === "function") {
3891
- try {
3892
- var result = normalizeBoolean(value.call(source));
3893
- if (result != null) {
3894
- return result;
3895
- }
3896
- } catch (unused) {}
3897
- }
3898
- }
3899
- } catch (err) {
3900
- _didIteratorError = true;
3901
- _iteratorError = err;
3902
- } finally{
3903
- try {
3904
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3905
- _iterator.return();
3906
- }
3907
- } finally{
3908
- if (_didIteratorError) {
3909
- throw _iteratorError;
3910
- }
3911
- }
3912
- }
3913
- return void 0;
3914
- }
3915
- function readStoredDeviceId() {
3916
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3917
- try {
3918
- for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3919
- var key = _step.value;
3920
- var value = readStoredString(key);
3921
- if (value) {
3922
- return value;
3923
- }
3924
- }
3925
- } catch (err) {
3926
- _didIteratorError = true;
3927
- _iteratorError = err;
3928
- } finally{
3929
- try {
3930
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3931
- _iterator.return();
3932
- }
3933
- } finally{
3934
- if (_didIteratorError) {
3935
- throw _iteratorError;
3936
- }
3937
- }
3938
- }
3939
- return void 0;
3940
- }
3941
- function readStoredString(key) {
3942
- if (typeof window === "undefined") {
3943
- return void 0;
3944
- }
3945
- try {
3946
- var _window_localStorage;
3947
- var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
3948
- return value || void 0;
3949
- } catch (unused) {
3950
- return void 0;
3951
- }
3952
- }
3953
- function readStoredLimitAdTracking() {
3954
- return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
3955
- }
3956
- function normalizeBoolean(value) {
3957
- if (typeof value === "boolean") {
3958
- return value;
3959
- }
3960
- if (typeof value === "number") {
3961
- return value === 1;
3962
- }
3963
- if (typeof value === "string") {
3964
- var normalized = value.toLowerCase();
3965
- if (normalized === "1" || normalized === "true" || normalized === "yes") {
3966
- return true;
3967
- }
3968
- if (normalized === "0" || normalized === "false" || normalized === "no") {
3969
- return false;
3970
- }
3971
- }
3972
- return void 0;
3973
- }
3974
- function inferDeviceIdType() {
3975
- if (typeof navigator === "undefined") {
3976
- return void 0;
3977
- }
3978
- var ua = navigator.userAgent;
3979
- if (/Roku/i.test(ua)) return "rida";
3980
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
3981
- if (/AppleTV/i.test(ua)) return "tvOS";
3982
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
3983
- if (/Web0S|webOS|LG/i.test(ua)) return "lgudid";
3984
- if (/Android|Google TV/i.test(ua)) return "aaid";
3985
- return void 0;
3986
- }
3987
- // src/player/VmapManager.ts
3988
- var VmapManager = /*#__PURE__*/ function() {
3989
- function VmapManager(config, video) {
3990
- _class_call_check(this, VmapManager);
4276
+ // src/player/AdConfigManager.ts
4277
+ var AdConfigManager = /*#__PURE__*/ function() {
4278
+ function AdConfigManager(config, video) {
4279
+ _class_call_check(this, AdConfigManager);
3991
4280
  this.vmapBreaks = [];
3992
4281
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
3993
4282
  this.streamCorrelator = generateCorrelator();
@@ -3999,7 +4288,7 @@ var VmapManager = /*#__PURE__*/ function() {
3999
4288
  this.config = config;
4000
4289
  this.video = video;
4001
4290
  }
4002
- _create_class(VmapManager, [
4291
+ _create_class(AdConfigManager, [
4003
4292
  {
4004
4293
  key: "debug",
4005
4294
  get: function get() {
@@ -4061,7 +4350,7 @@ var VmapManager = /*#__PURE__*/ function() {
4061
4350
  ];
4062
4351
  }
4063
4352
  if (this.config.vastTagUrl) {
4064
- this.apiVastTagUrl = this.config.vastTagUrl;
4353
+ this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
4065
4354
  if (this.debug) {
4066
4355
  console.log("[StormcloudVideoPlayer] Using custom VAST tag URL:", this.apiVastTagUrl);
4067
4356
  }
@@ -4101,7 +4390,7 @@ var VmapManager = /*#__PURE__*/ function() {
4101
4390
  data = _state.sent();
4102
4391
  imaPayload = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : (_data_response_ima = _data_response.ima) === null || _data_response_ima === void 0 ? void 0 : (_data_response_ima_publisherdeskima = _data_response_ima["publisherdesk.ima"]) === null || _data_response_ima_publisherdeskima === void 0 ? void 0 : _data_response_ima_publisherdeskima.payload;
4103
4392
  if (imaPayload) {
4104
- this.apiVastTagUrl = decodeURIComponent(imaPayload);
4393
+ this.apiVastTagUrl = normalizeVastTagUrl(imaPayload);
4105
4394
  if (this.debug) {
4106
4395
  console.log("[StormcloudVideoPlayer] Extracted VAST tag URL from /ads/web:", this.apiVastTagUrl);
4107
4396
  }
@@ -4416,24 +4705,24 @@ var VmapManager = /*#__PURE__*/ function() {
4416
4705
  for(var i = 0; i < count; i++){
4417
4706
  this.adRequestPositionInBreak++;
4418
4707
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
4419
- var ctvSignals = this.config.ctvAdRequest ? resolveCtvVastSignals() : void 0;
4708
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
4420
4709
  var urlWithMacros = applyVastMacros(baseUrl, {
4421
4710
  correlator: generateCorrelator(),
4422
4711
  streamCorrelator: this.streamCorrelator,
4423
4712
  pod: this.podCounter > 0 ? this.podCounter : void 0,
4424
4713
  adPosition: this.adRequestPositionInBreak,
4425
- isCtv: this.config.ctvAdRequest,
4426
- contentUrl: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.contentUrl,
4427
- pageUrl: !this.config.ctvAdRequest && typeof window !== "undefined" ? window.location.href : void 0,
4714
+ isCtv: envSignals.isCtv,
4715
+ contentUrl: envSignals.contentUrl,
4716
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
4428
4717
  adWillPlayMuted: adWillPlayMuted,
4429
4718
  adWillAutoPlay: !!this.config.autoplay,
4430
- appId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appId,
4431
- appName: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appName,
4432
- sessionId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.sessionId,
4433
- deviceId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceId,
4434
- deviceIdType: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceIdType,
4435
- limitAdTracking: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.limitAdTracking,
4436
- deviceTypeHint: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceTypeHint,
4719
+ appId: envSignals.appId,
4720
+ appName: envSignals.appName,
4721
+ sessionId: envSignals.sessionId,
4722
+ deviceId: envSignals.deviceId,
4723
+ deviceIdType: envSignals.deviceIdType,
4724
+ limitAdTracking: envSignals.limitAdTracking,
4725
+ deviceTypeHint: envSignals.deviceTypeHint,
4437
4726
  adTest: this.config.adTest,
4438
4727
  consent: this.consentSignals
4439
4728
  });
@@ -4486,7 +4775,7 @@ var VmapManager = /*#__PURE__*/ function() {
4486
4775
  }
4487
4776
  }
4488
4777
  ]);
4489
- return VmapManager;
4778
+ return AdConfigManager;
4490
4779
  }();
4491
4780
  // src/player/AdTimingService.ts
4492
4781
  var AdTimingService = /*#__PURE__*/ function() {
@@ -6213,7 +6502,7 @@ function resizePlayer(video, adPlayer, debug) {
6213
6502
  }
6214
6503
  // src/player/AdBreakOrchestrator.ts
6215
6504
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
6216
- function AdBreakOrchestrator(host, timing, preloadPool, vmap, cueManager, placeholder) {
6505
+ function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6217
6506
  _class_call_check(this, AdBreakOrchestrator);
6218
6507
  this.inAdBreak = false;
6219
6508
  this.showAds = false;
@@ -6228,7 +6517,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6228
6517
  this.host = host;
6229
6518
  this.timing = timing;
6230
6519
  this.preloadPool = preloadPool;
6231
- this.vmap = vmap;
6520
+ this.adConfig = adConfig;
6232
6521
  this.cueManager = cueManager;
6233
6522
  this.placeholder = placeholder;
6234
6523
  }
@@ -6394,7 +6683,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6394
6683
  }
6395
6684
  this.pendingAdBreak = null;
6396
6685
  this.cueManager.pendingScte35CueKey = void 0;
6397
- this.vmap.podAssignedByPrefetch = false;
6686
+ this.adConfig.podAssignedByPrefetch = false;
6398
6687
  }
6399
6688
  },
6400
6689
  {
@@ -6408,15 +6697,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6408
6697
  return _ts_generator(this, function(_state) {
6409
6698
  switch(_state.label){
6410
6699
  case 0:
6411
- scheduled = this.vmap.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6700
+ scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6412
6701
  if (scheduled) {
6413
- this.vmap.consumedVmapBreakIds.add(this.vmap.getAdBreakKey(scheduled));
6702
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
6414
6703
  }
6415
- tags = this.vmap.selectVastTagsForBreak(scheduled);
6704
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6416
6705
  if (tags && tags.length > 0 && tags[0]) {
6417
6706
  baseVastUrl = tags[0];
6418
- } else if (this.vmap.apiVastTagUrl) {
6419
- baseVastUrl = this.vmap.apiVastTagUrl;
6707
+ } else if (this.adConfig.apiVastTagUrl) {
6708
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6420
6709
  } else {
6421
6710
  this.clearPendingAdBreak();
6422
6711
  return [
@@ -6434,10 +6723,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6434
6723
  this.continuousFetchingActive = true;
6435
6724
  this.isShowingPlaceholder = false;
6436
6725
  this.timing.totalAdRequestsInBreak = 0;
6437
- if (this.vmap.podAssignedByPrefetch) {
6438
- this.vmap.podAssignedByPrefetch = false;
6726
+ if (this.adConfig.podAssignedByPrefetch) {
6727
+ this.adConfig.podAssignedByPrefetch = false;
6439
6728
  } else {
6440
- this.vmap.beginNewAdPod();
6729
+ this.adConfig.beginNewAdPod();
6441
6730
  }
6442
6731
  currentMuted = this.host.video.muted;
6443
6732
  currentVolume = this.host.video.volume;
@@ -7709,7 +7998,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7709
7998
  return _this.adBreak.inAdBreak;
7710
7999
  }
7711
8000
  });
7712
- this.vmap = new VmapManager(this.config, this.video);
8001
+ this.adConfig = new AdConfigManager(this.config, this.video);
7713
8002
  this.timing = new AdTimingService(this.config, this.video, {
7714
8003
  onAdStopTimerFired: function onAdStopTimerFired() {
7715
8004
  return _this.onAdStopTimerFired();
@@ -7789,7 +8078,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7789
8078
  generateVastUrls: function generateVastUrls(base, count) {
7790
8079
  return _this.generateVastUrls(base, count);
7791
8080
  }
7792
- }, this.timing, this.preloadPool, this.vmap, this.cueManager, this.placeholder);
8081
+ }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7793
8082
  }
7794
8083
  _create_class(StormcloudVideoPlayer, [
7795
8084
  {
@@ -7817,7 +8106,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7817
8106
  {
7818
8107
  key: "generateVastUrls",
7819
8108
  value: function generateVastUrls(baseUrl, count) {
7820
- return this.vmap.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8109
+ return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
7821
8110
  }
7822
8111
  },
7823
8112
  {
@@ -7845,7 +8134,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7845
8134
  ]);
7846
8135
  return [
7847
8136
  4,
7848
- this.vmap.fetchAdConfiguration()
8137
+ this.adConfig.fetchAdConfiguration()
7849
8138
  ];
7850
8139
  case 2:
7851
8140
  _state.sent();
@@ -7872,9 +8161,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7872
8161
  continuousPlayback: (_this_config_lowLatencyMode = this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
7873
8162
  }).catch(function() {});
7874
8163
  fetchConsentSignals().then(function(signals) {
7875
- _this.vmap.consentSignals = signals;
8164
+ _this.adConfig.consentSignals = signals;
7876
8165
  }).catch(function() {});
7877
- this.vmap.initializeTracking();
8166
+ this.adConfig.initializeTracking();
7878
8167
  if (!this.hlsEngine.shouldUseNativeHls(function() {
7879
8168
  return _this.getStreamType();
7880
8169
  })) return [
@@ -7909,14 +8198,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7909
8198
  return _async_to_generator(function() {
7910
8199
  var prerollKey, adBehavior;
7911
8200
  return _ts_generator(this, function(_state) {
7912
- if (!this.vmap.isVmapEnabled() && !isLive && this.vmap.vmapBreaks.length === 0 && this.vmap.apiVastTagUrl) {
8201
+ if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
7913
8202
  prerollKey = "synthetic-vod-preroll";
7914
- if (!this.vmap.consumedVmapBreakIds.has(prerollKey)) {
7915
- this.vmap.vmapBreaks = [
8203
+ if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
8204
+ this.adConfig.vmapBreaks = [
7916
8205
  {
7917
8206
  id: prerollKey,
7918
8207
  startTimeMs: 0,
7919
- vastTagUrl: this.vmap.apiVastTagUrl
8208
+ vastTagUrl: this.adConfig.apiVastTagUrl
7920
8209
  }
7921
8210
  ];
7922
8211
  if (this.debug) {
@@ -8183,19 +8472,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8183
8472
  key: "startAdPrefetch",
8184
8473
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
8185
8474
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
8186
- var scheduled = this.vmap.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8187
- var tags = this.vmap.selectVastTagsForBreak(scheduled);
8475
+ var scheduled = this.adConfig.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8476
+ var tags = this.adConfig.selectVastTagsForBreak(scheduled);
8188
8477
  var baseVastUrl;
8189
8478
  if (tags && tags.length > 0 && tags[0]) {
8190
8479
  baseVastUrl = tags[0];
8191
- } else if (this.vmap.apiVastTagUrl) {
8192
- baseVastUrl = this.vmap.apiVastTagUrl;
8480
+ } else if (this.adConfig.apiVastTagUrl) {
8481
+ baseVastUrl = this.adConfig.apiVastTagUrl;
8193
8482
  } else {
8194
8483
  if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
8195
8484
  return;
8196
8485
  }
8197
- this.vmap.beginNewAdPod();
8198
- this.vmap.podAssignedByPrefetch = true;
8486
+ this.adConfig.beginNewAdPod();
8487
+ this.adConfig.podAssignedByPrefetch = true;
8199
8488
  var generatedUrls = this.generateVastUrls(baseVastUrl, 1);
8200
8489
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
8201
8490
  marker: marker
@@ -8230,10 +8519,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8230
8519
  key: "onTimeUpdate",
8231
8520
  value: function onTimeUpdate(currentTimeSec) {
8232
8521
  var _this = this;
8233
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8522
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8234
8523
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8235
8524
  var nowMs = currentTimeSec * 1e3;
8236
- var breakToPlay = this.vmap.findBreakForTime(nowMs);
8525
+ var breakToPlay = this.adConfig.findBreakForTime(nowMs);
8237
8526
  if (breakToPlay) {
8238
8527
  void this.handleVmapAdBreak(breakToPlay, nowMs).catch(function(error) {
8239
8528
  if (_this.debug) {
@@ -8247,11 +8536,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8247
8536
  key: "onVideoEnded",
8248
8537
  value: function onVideoEnded() {
8249
8538
  var _this = this;
8250
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8539
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8251
8540
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8252
8541
  var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
8253
- var postroll = this.vmap.vmapBreaks.find(function(b) {
8254
- return b.startTimeMs === -1 && !_this.vmap.consumedVmapBreakIds.has(_this.vmap.getAdBreakKey(b));
8542
+ var postroll = this.adConfig.vmapBreaks.find(function(b) {
8543
+ return b.startTimeMs === -1 && !_this.adConfig.consumedVmapBreakIds.has(_this.adConfig.getAdBreakKey(b));
8255
8544
  });
8256
8545
  if (postroll) {
8257
8546
  void this.handleVmapAdBreak(postroll, durationMs).catch(function(error) {
@@ -8270,11 +8559,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8270
8559
  return _ts_generator(this, function(_state) {
8271
8560
  switch(_state.label){
8272
8561
  case 0:
8273
- key = this.vmap.getAdBreakKey(adBreak);
8274
- if (this.vmap.consumedVmapBreakIds.has(key)) return [
8562
+ key = this.adConfig.getAdBreakKey(adBreak);
8563
+ if (this.adConfig.consumedVmapBreakIds.has(key)) return [
8275
8564
  2
8276
8565
  ];
8277
- breakStartMs = this.vmap.resolveBreakStartMs(adBreak);
8566
+ breakStartMs = this.adConfig.resolveBreakStartMs(adBreak);
8278
8567
  if (breakStartMs == null) return [
8279
8568
  2
8280
8569
  ];
@@ -8285,8 +8574,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8285
8574
  3,
8286
8575
  4
8287
8576
  ];
8288
- this.vmap.consumedVmapBreakIds.add(key);
8289
- tags = this.vmap.selectVastTagsForBreak(adBreak);
8577
+ this.adConfig.consumedVmapBreakIds.add(key);
8578
+ tags = this.adConfig.selectVastTagsForBreak(adBreak);
8290
8579
  if (!tags || tags.length === 0) return [
8291
8580
  2
8292
8581
  ];
@@ -8478,7 +8767,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8478
8767
  this.video.removeEventListener("emptied", this.emptiedHandler);
8479
8768
  delete this.emptiedHandler;
8480
8769
  }
8481
- this.vmap.destroyTracking();
8770
+ this.adConfig.destroyTracking();
8482
8771
  this.hlsEngine.destroy();
8483
8772
  (_this_adPlayer = this.adPlayer) === null || _this_adPlayer === void 0 ? void 0 : _this_adPlayer.destroy();
8484
8773
  if (this.palPlaybackStarted) {