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
@@ -2308,22 +2308,326 @@ function initializePolyfills() {
2308
2308
  polyfillTextEncoder();
2309
2309
  polyfillPromiseFinally();
2310
2310
  }
2311
- // src/utils/vastMacros.ts
2312
- function generateCorrelator() {
2313
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2311
+ // src/utils/vastEnvironmentSignals.ts
2312
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2313
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
2314
+ var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
2315
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2316
+ var DEVICE_ID_STORAGE_KEYS = [
2317
+ "rdid",
2318
+ "ifa",
2319
+ "advertisingId",
2320
+ "advertising_id",
2321
+ "deviceAdvertisingId",
2322
+ "aaid",
2323
+ "adid",
2324
+ "rida",
2325
+ "tifa",
2326
+ "lgudid"
2327
+ ];
2328
+ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
2329
+ "aaid",
2330
+ "adid"
2331
+ ]);
2332
+ function resolveVastEnvironmentSignals(isCtv) {
2333
+ var _ref, _bridgeSignals_limitAdTracking;
2334
+ var bridgeSignals = readNativeBridgeSignals();
2335
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
2336
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || inferDeviceIdType();
2337
+ 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;
2338
+ if (isCtv) {
2339
+ return _object_spread_props(_object_spread({
2340
+ isCtv: true,
2341
+ contentUrl: bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL,
2342
+ appId: bridgeSignals.appId || readStoredString("appId") || readStoredString("msid") || AIRY_ANDROID_APP_ID,
2343
+ appName: bridgeSignals.appName || readStoredString("appName") || readStoredString("an") || AIRY_APP_NAME,
2344
+ sessionId: getOrCreateCtvSessionId()
2345
+ }, deviceId ? {
2346
+ deviceId: deviceId
2347
+ } : {}, deviceIdType ? {
2348
+ deviceIdType: deviceIdType
2349
+ } : {}, limitAdTracking != null ? {
2350
+ limitAdTracking: limitAdTracking
2351
+ } : {}), {
2352
+ deviceTypeHint: 5
2353
+ });
2354
+ }
2355
+ return _object_spread({
2356
+ isCtv: false
2357
+ }, deviceId ? {
2358
+ deviceId: deviceId
2359
+ } : {}, deviceIdType ? {
2360
+ deviceIdType: deviceIdType
2361
+ } : {}, limitAdTracking != null ? {
2362
+ limitAdTracking: limitAdTracking
2363
+ } : {});
2364
+ }
2365
+ function inferDeviceIdType() {
2366
+ if (typeof navigator === "undefined") {
2367
+ return void 0;
2368
+ }
2369
+ var ua = navigator.userAgent;
2370
+ if (/Roku/i.test(ua)) return "rida";
2371
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
2372
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
2373
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
2374
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
2375
+ if (/Android|Google TV/i.test(ua)) return "aaid";
2376
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
2377
+ return void 0;
2378
+ }
2379
+ function isEquivalentDeviceIdType(tagType, runtimeType) {
2380
+ if (!tagType || !runtimeType) return false;
2381
+ var tag = tagType.toLowerCase();
2382
+ var runtime = runtimeType.toLowerCase();
2383
+ if (tag === runtime) return true;
2384
+ return ANDROID_ID_TYPES.has(tag) && ANDROID_ID_TYPES.has(runtime);
2385
+ }
2386
+ function getOrCreateCtvSessionId() {
2387
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2388
+ if (existing) {
2389
+ return existing;
2390
+ }
2391
+ var sessionId = createUuid();
2392
+ try {
2393
+ var _window_localStorage;
2394
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2395
+ } catch (unused) {}
2396
+ return sessionId;
2397
+ }
2398
+ function createUuid() {
2399
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2400
+ return crypto.randomUUID();
2401
+ }
2402
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2403
+ var value = Math.floor(Math.random() * 16);
2404
+ var nibble = char === "x" ? value : value & 3 | 8;
2405
+ return nibble.toString(16);
2406
+ });
2407
+ }
2408
+ function readNativeBridgeSignals() {
2409
+ if (typeof window === "undefined") {
2410
+ return {};
2411
+ }
2412
+ var candidates = [
2413
+ window.__STORMCLOUD_CTV_AD_INFO__,
2414
+ window.__STORMCLOUD_CTV__,
2415
+ window.stormcloudCtv,
2416
+ window.AiryTV,
2417
+ window.Android,
2418
+ window.webOS,
2419
+ window.tizen,
2420
+ window.amazon
2421
+ ].filter(Boolean);
2422
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2423
+ try {
2424
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2425
+ var source = _step.value;
2426
+ var contentUrl = readBridgeValue(source, [
2427
+ "contentUrl",
2428
+ "url",
2429
+ "videoUrl",
2430
+ "canonicalUrl"
2431
+ ]) || void 0;
2432
+ var appId = readBridgeValue(source, [
2433
+ "appId",
2434
+ "msid",
2435
+ "applicationId",
2436
+ "packageName"
2437
+ ]) || void 0;
2438
+ var appName = readBridgeValue(source, [
2439
+ "appName",
2440
+ "an",
2441
+ "applicationName"
2442
+ ]) || void 0;
2443
+ var deviceId = readBridgeValue(source, [
2444
+ "rdid",
2445
+ "ifa",
2446
+ "advertisingId",
2447
+ "adId",
2448
+ "deviceId",
2449
+ "lgudid",
2450
+ "LGUDID",
2451
+ "tifa",
2452
+ "rida",
2453
+ "afai",
2454
+ "aaid"
2455
+ ]) || void 0;
2456
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
2457
+ var deviceIdType = readBridgeValue(source, [
2458
+ "idtype",
2459
+ "deviceIdType",
2460
+ "advertisingIdType",
2461
+ "idType"
2462
+ ]) || inferDeviceIdType();
2463
+ var limitAdTracking = readBridgeBoolean(source, [
2464
+ "is_lat",
2465
+ "limitAdTracking",
2466
+ "limitedAdTracking",
2467
+ "lat"
2468
+ ]);
2469
+ return _object_spread({}, contentUrl ? {
2470
+ contentUrl: contentUrl
2471
+ } : {}, appId ? {
2472
+ appId: appId
2473
+ } : {}, appName ? {
2474
+ appName: appName
2475
+ } : {}, deviceId ? {
2476
+ deviceId: deviceId
2477
+ } : {}, deviceId && deviceIdType ? {
2478
+ deviceIdType: deviceIdType
2479
+ } : {}, deviceId && limitAdTracking != null ? {
2480
+ limitAdTracking: limitAdTracking
2481
+ } : {});
2482
+ }
2483
+ } catch (err) {
2484
+ _didIteratorError = true;
2485
+ _iteratorError = err;
2486
+ } finally{
2314
2487
  try {
2315
- var _buf_, _buf_1;
2316
- var buf = new Uint32Array(2);
2317
- crypto.getRandomValues(buf);
2318
- 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);
2319
- if (value > 0) {
2320
- return String(value);
2488
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2489
+ _iterator.return();
2321
2490
  }
2322
- } catch (unused) {}
2491
+ } finally{
2492
+ if (_didIteratorError) {
2493
+ throw _iteratorError;
2494
+ }
2495
+ }
2323
2496
  }
2324
- return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2497
+ return {};
2498
+ }
2499
+ function readBridgeValue(source, keys) {
2500
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2501
+ try {
2502
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2503
+ var key = _step.value;
2504
+ var value = source === null || source === void 0 ? void 0 : source[key];
2505
+ if (typeof value === "string" && value) {
2506
+ return value;
2507
+ }
2508
+ if (typeof value === "function") {
2509
+ try {
2510
+ var result = value.call(source);
2511
+ if (typeof result === "string" && result) {
2512
+ return result;
2513
+ }
2514
+ } catch (unused) {}
2515
+ }
2516
+ }
2517
+ } catch (err) {
2518
+ _didIteratorError = true;
2519
+ _iteratorError = err;
2520
+ } finally{
2521
+ try {
2522
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2523
+ _iterator.return();
2524
+ }
2525
+ } finally{
2526
+ if (_didIteratorError) {
2527
+ throw _iteratorError;
2528
+ }
2529
+ }
2530
+ }
2531
+ return void 0;
2532
+ }
2533
+ function readBridgeBoolean(source, keys) {
2534
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2535
+ try {
2536
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2537
+ var key = _step.value;
2538
+ var value = source === null || source === void 0 ? void 0 : source[key];
2539
+ var normalized = normalizeBoolean(value);
2540
+ if (normalized != null) {
2541
+ return normalized;
2542
+ }
2543
+ if (typeof value === "function") {
2544
+ try {
2545
+ var result = normalizeBoolean(value.call(source));
2546
+ if (result != null) {
2547
+ return result;
2548
+ }
2549
+ } catch (unused) {}
2550
+ }
2551
+ }
2552
+ } catch (err) {
2553
+ _didIteratorError = true;
2554
+ _iteratorError = err;
2555
+ } finally{
2556
+ try {
2557
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2558
+ _iterator.return();
2559
+ }
2560
+ } finally{
2561
+ if (_didIteratorError) {
2562
+ throw _iteratorError;
2563
+ }
2564
+ }
2565
+ }
2566
+ return void 0;
2567
+ }
2568
+ function readStoredDeviceId() {
2569
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2570
+ try {
2571
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2572
+ var key = _step.value;
2573
+ var value = readStoredString(key);
2574
+ if (value) {
2575
+ return value;
2576
+ }
2577
+ }
2578
+ } catch (err) {
2579
+ _didIteratorError = true;
2580
+ _iteratorError = err;
2581
+ } finally{
2582
+ try {
2583
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2584
+ _iterator.return();
2585
+ }
2586
+ } finally{
2587
+ if (_didIteratorError) {
2588
+ throw _iteratorError;
2589
+ }
2590
+ }
2591
+ }
2592
+ return void 0;
2325
2593
  }
2594
+ function readStoredString(key) {
2595
+ if (typeof window === "undefined") {
2596
+ return void 0;
2597
+ }
2598
+ try {
2599
+ var _window_localStorage;
2600
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2601
+ return value || void 0;
2602
+ } catch (unused) {
2603
+ return void 0;
2604
+ }
2605
+ }
2606
+ function readStoredLimitAdTracking() {
2607
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2608
+ }
2609
+ function normalizeBoolean(value) {
2610
+ if (typeof value === "boolean") {
2611
+ return value;
2612
+ }
2613
+ if (typeof value === "number") {
2614
+ return value === 1;
2615
+ }
2616
+ if (typeof value === "string") {
2617
+ var normalized = value.toLowerCase();
2618
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
2619
+ return true;
2620
+ }
2621
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
2622
+ return false;
2623
+ }
2624
+ }
2625
+ return void 0;
2626
+ }
2627
+ // src/utils/vastMacros.ts
2326
2628
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
2629
+ var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
2630
+ var EXAMPLE_COM_URL = /example\.com/i;
2327
2631
  var CTV_UNSUPPORTED_PARAMS = [
2328
2632
  "description_url",
2329
2633
  "tfcd",
@@ -2338,14 +2642,265 @@ var CTV_UNSUPPORTED_PARAMS = [
2338
2642
  "gdpr_consent",
2339
2643
  "us_privacy"
2340
2644
  ];
2645
+ var INLINE_DEVICE_MACRO_REPLACEMENTS = [
2646
+ {
2647
+ pattern: /\[RDID\]/gi,
2648
+ getValue: function getValue(ctx) {
2649
+ return ctx.deviceId;
2650
+ }
2651
+ },
2652
+ {
2653
+ pattern: /\[IFA\]/gi,
2654
+ getValue: function getValue(ctx) {
2655
+ return ctx.deviceId;
2656
+ }
2657
+ },
2658
+ {
2659
+ pattern: /\[ADVERTISING[_-]?ID(?:ENTIFIER)?\]/gi,
2660
+ getValue: function getValue(ctx) {
2661
+ return ctx.deviceId;
2662
+ }
2663
+ },
2664
+ {
2665
+ pattern: /\[DEVICE[_-]?ID\]/gi,
2666
+ getValue: function getValue(ctx) {
2667
+ return ctx.deviceId;
2668
+ }
2669
+ },
2670
+ {
2671
+ pattern: /\[IDTYPE\]/gi,
2672
+ getValue: function getValue(ctx) {
2673
+ return ctx.deviceIdType;
2674
+ }
2675
+ },
2676
+ {
2677
+ pattern: /\{rdid\}/gi,
2678
+ getValue: function getValue(ctx) {
2679
+ return ctx.deviceId;
2680
+ }
2681
+ },
2682
+ {
2683
+ pattern: /\{device[_-]?id\}/gi,
2684
+ getValue: function getValue(ctx) {
2685
+ return ctx.deviceId;
2686
+ }
2687
+ },
2688
+ {
2689
+ pattern: /\{idtype\}/gi,
2690
+ getValue: function getValue(ctx) {
2691
+ return ctx.deviceIdType;
2692
+ }
2693
+ },
2694
+ {
2695
+ pattern: /%%ADVERTISING_IDENTIFIER_PLAIN%%/gi,
2696
+ getValue: function getValue(ctx) {
2697
+ return ctx.deviceId;
2698
+ }
2699
+ },
2700
+ {
2701
+ pattern: /%%ADVERTISING_ID_OPT_OUT%%/gi,
2702
+ getValue: function getValue(ctx) {
2703
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2704
+ }
2705
+ },
2706
+ {
2707
+ pattern: /%%ADVERTISING_ID_TYPE%%/gi,
2708
+ getValue: function getValue(ctx) {
2709
+ return ctx.deviceIdType;
2710
+ }
2711
+ },
2712
+ {
2713
+ pattern: /%%ADVERTISING_ID%%/gi,
2714
+ getValue: function getValue(ctx) {
2715
+ return ctx.deviceId;
2716
+ }
2717
+ },
2718
+ {
2719
+ pattern: /%%LIMIT_AD_TRACKING%%/gi,
2720
+ getValue: function getValue(ctx) {
2721
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2722
+ }
2723
+ },
2724
+ {
2725
+ pattern: /%%MSID%%/gi,
2726
+ getValue: function getValue(ctx) {
2727
+ return ctx.appId;
2728
+ }
2729
+ },
2730
+ {
2731
+ pattern: /%%APP_NAME%%/gi,
2732
+ getValue: function getValue(ctx) {
2733
+ return ctx.appName;
2734
+ }
2735
+ },
2736
+ {
2737
+ pattern: /%%SESSION_ID%%/gi,
2738
+ getValue: function getValue(ctx) {
2739
+ return ctx.sessionId;
2740
+ }
2741
+ },
2742
+ {
2743
+ pattern: /%%CORRELATOR%%/gi,
2744
+ getValue: function getValue(ctx) {
2745
+ return ctx.correlator;
2746
+ }
2747
+ }
2748
+ ];
2749
+ function isMacroPlaceholder(value) {
2750
+ if (value == null) return true;
2751
+ var trimmed = value.trim();
2752
+ if (!trimmed) return true;
2753
+ if (UNEXPANDED_MACRO_PATTERN.test(trimmed)) return true;
2754
+ return /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(trimmed);
2755
+ }
2756
+ function generateCorrelator() {
2757
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2758
+ try {
2759
+ var _buf_, _buf_1;
2760
+ var buf = new Uint32Array(2);
2761
+ crypto.getRandomValues(buf);
2762
+ 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);
2763
+ if (value > 0) {
2764
+ return String(value);
2765
+ }
2766
+ } catch (unused) {}
2767
+ }
2768
+ return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2769
+ }
2770
+ function expandInlineMacroPlaceholders(baseUrl, ctx) {
2771
+ var url = baseUrl;
2772
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2773
+ try {
2774
+ for(var _iterator = INLINE_DEVICE_MACRO_REPLACEMENTS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2775
+ var _step_value = _step.value, pattern = _step_value.pattern, getValue = _step_value.getValue;
2776
+ var value = getValue(ctx);
2777
+ if (value != null && value !== "") {
2778
+ url = url.replace(pattern, encodeURIComponent(value));
2779
+ }
2780
+ }
2781
+ } catch (err) {
2782
+ _didIteratorError = true;
2783
+ _iteratorError = err;
2784
+ } finally{
2785
+ try {
2786
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2787
+ _iterator.return();
2788
+ }
2789
+ } finally{
2790
+ if (_didIteratorError) {
2791
+ throw _iteratorError;
2792
+ }
2793
+ }
2794
+ }
2795
+ return url;
2796
+ }
2797
+ function applyDeviceIdentityParams(params, ctx) {
2798
+ var _ctx_deviceId, _ctx_deviceIdType;
2799
+ var runtimeId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
2800
+ var runtimeType = ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType();
2801
+ var tagRdid = params.get("rdid");
2802
+ var tagType = params.get("idtype");
2803
+ var tagLat = params.get("is_lat");
2804
+ var latValue = ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2805
+ if (runtimeId) {
2806
+ params.set("rdid", runtimeId);
2807
+ params.set("idtype", runtimeType || tagType || "aaid");
2808
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : isMacroPlaceholder(tagLat) ? "0" : tagLat);
2809
+ return;
2810
+ }
2811
+ var tagRdidValid = Boolean(tagRdid && !isMacroPlaceholder(tagRdid));
2812
+ var tagTypeValid = Boolean(tagType && !isMacroPlaceholder(tagType));
2813
+ if (tagRdidValid && tagTypeValid && runtimeType && !isEquivalentDeviceIdType(tagType, runtimeType)) {
2814
+ params.delete("rdid");
2815
+ params.delete("idtype");
2816
+ params.delete("is_lat");
2817
+ return;
2818
+ }
2819
+ if (tagRdidValid) {
2820
+ if (isMacroPlaceholder(tagType) && runtimeType) {
2821
+ params.set("idtype", runtimeType);
2822
+ }
2823
+ if (isMacroPlaceholder(tagLat)) {
2824
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : "0");
2825
+ }
2826
+ return;
2827
+ }
2828
+ params.delete("rdid");
2829
+ params.delete("idtype");
2830
+ params.delete("is_lat");
2831
+ }
2832
+ function removeBrokenAppNameOrphans(params, appName) {
2833
+ var toDelete = [];
2834
+ params.forEach(function(_value, key) {
2835
+ if (!key || INVALID_VAST_PARAM_KEY.test(key)) {
2836
+ toDelete.push(key);
2837
+ }
2838
+ });
2839
+ if (appName && appName.includes("&")) {
2840
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2841
+ try {
2842
+ for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2843
+ var suffix = _step.value;
2844
+ var trimmed = suffix.trimStart();
2845
+ if (!trimmed) continue;
2846
+ toDelete.push(suffix, " ".concat(trimmed), trimmed);
2847
+ }
2848
+ } catch (err) {
2849
+ _didIteratorError = true;
2850
+ _iteratorError = err;
2851
+ } finally{
2852
+ try {
2853
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2854
+ _iterator.return();
2855
+ }
2856
+ } finally{
2857
+ if (_didIteratorError) {
2858
+ throw _iteratorError;
2859
+ }
2860
+ }
2861
+ }
2862
+ }
2863
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2864
+ try {
2865
+ for(var _iterator1 = new Set(toDelete)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2866
+ var key = _step1.value;
2867
+ if (key) params.delete(key);
2868
+ }
2869
+ } catch (err) {
2870
+ _didIteratorError1 = true;
2871
+ _iteratorError1 = err;
2872
+ } finally{
2873
+ try {
2874
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2875
+ _iterator1.return();
2876
+ }
2877
+ } finally{
2878
+ if (_didIteratorError1) {
2879
+ throw _iteratorError1;
2880
+ }
2881
+ }
2882
+ }
2883
+ }
2884
+ function normalizeVastTagUrl(raw) {
2885
+ if (!raw) return raw;
2886
+ try {
2887
+ var url = new URL(raw);
2888
+ removeBrokenAppNameOrphans(url.searchParams);
2889
+ return url.toString();
2890
+ } catch (unused) {
2891
+ return raw;
2892
+ }
2893
+ }
2341
2894
  function applyVastMacros(baseUrl, ctx) {
2895
+ var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
2342
2896
  var url;
2343
2897
  try {
2344
- url = new URL(baseUrl);
2898
+ url = new URL(normalizeVastTagUrl(expandedUrl));
2345
2899
  } catch (unused) {
2346
- return replaceCorrelatorFallback(baseUrl, ctx.correlator);
2900
+ return replaceCorrelatorFallback(expandedUrl, ctx.correlator);
2347
2901
  }
2348
2902
  var params = url.searchParams;
2903
+ removeBrokenAppNameOrphans(params, ctx.appName);
2349
2904
  params.set("correlator", ctx.correlator);
2350
2905
  if (ctx.isCtv) {
2351
2906
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2383,6 +2938,12 @@ function applyVastMacros(baseUrl, ctx) {
2383
2938
  if (!ctx.isCtv) {
2384
2939
  params.set("description_url", requestUrl);
2385
2940
  }
2941
+ } else {
2942
+ var existingUrl = params.get("url") || "";
2943
+ if (EXAMPLE_COM_URL.test(existingUrl)) {
2944
+ params.delete("url");
2945
+ params.delete("description_url");
2946
+ }
2386
2947
  }
2387
2948
  if (ctx.adWillPlayMuted != null) {
2388
2949
  params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
@@ -2394,6 +2955,7 @@ function applyVastMacros(baseUrl, ctx) {
2394
2955
  params.set("msid", ctx.appId);
2395
2956
  }
2396
2957
  if (ctx.appName) {
2958
+ removeBrokenAppNameOrphans(params, ctx.appName);
2397
2959
  params.set("an", ctx.appName);
2398
2960
  }
2399
2961
  if (ctx.sessionId) {
@@ -2404,15 +2966,7 @@ function applyVastMacros(baseUrl, ctx) {
2404
2966
  } else if (ctx.isCtv) {
2405
2967
  params.set("dth", "5");
2406
2968
  }
2407
- if (ctx.deviceId && ctx.deviceIdType) {
2408
- params.set("rdid", ctx.deviceId);
2409
- params.set("idtype", ctx.deviceIdType);
2410
- params.set("is_lat", ctx.limitAdTracking ? "1" : "0");
2411
- } else {
2412
- params.delete("rdid");
2413
- params.delete("idtype");
2414
- params.delete("is_lat");
2415
- }
2969
+ applyDeviceIdentityParams(params, ctx);
2416
2970
  if (!ctx.isCtv) {
2417
2971
  var consent = ctx.consent;
2418
2972
  if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
@@ -2430,7 +2984,7 @@ function applyVastMacros(baseUrl, ctx) {
2430
2984
  }
2431
2985
  var staleKeys = [];
2432
2986
  params.forEach(function(value, key) {
2433
- if (UNEXPANDED_MACRO_PATTERN.test(value)) {
2987
+ if (isMacroPlaceholder(value)) {
2434
2988
  staleKeys.push(key);
2435
2989
  }
2436
2990
  });
@@ -2454,6 +3008,7 @@ function applyVastMacros(baseUrl, ctx) {
2454
3008
  }
2455
3009
  }
2456
3010
  }
3011
+ removeBrokenAppNameOrphans(params, ctx.appName);
2457
3012
  return url.toString();
2458
3013
  }
2459
3014
  function replaceCorrelatorFallback(baseUrl, correlator) {
@@ -3704,276 +4259,10 @@ var Scte35CueManager = /*#__PURE__*/ function() {
3704
4259
  ]);
3705
4260
  return Scte35CueManager;
3706
4261
  }();
3707
- // src/utils/ctvVastSignals.ts
3708
- var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
3709
- var AIRY_APP_NAME = "AiryTV Movies & TV";
3710
- var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
3711
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
3712
- var DEVICE_ID_STORAGE_KEYS = [
3713
- "rdid",
3714
- "ifa",
3715
- "advertisingId",
3716
- "advertising_id",
3717
- "deviceAdvertisingId",
3718
- "aaid",
3719
- "adid",
3720
- "rida",
3721
- "tifa"
3722
- ];
3723
- function resolveCtvVastSignals() {
3724
- var _ref, _bridgeSignals_limitAdTracking;
3725
- var bridgeSignals = readNativeBridgeSignals();
3726
- var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
3727
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || inferDeviceIdType();
3728
- var contentUrl = bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL;
3729
- return _object_spread_props(_object_spread({
3730
- contentUrl: contentUrl,
3731
- appId: AIRY_ANDROID_APP_ID,
3732
- appName: AIRY_APP_NAME,
3733
- sessionId: getOrCreateCtvSessionId()
3734
- }, deviceId ? {
3735
- deviceId: deviceId
3736
- } : {}, deviceId && deviceIdType ? {
3737
- deviceIdType: deviceIdType
3738
- } : {}, deviceId ? {
3739
- limitAdTracking: (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false
3740
- } : {}), {
3741
- deviceTypeHint: 5
3742
- });
3743
- }
3744
- function getOrCreateCtvSessionId() {
3745
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
3746
- if (existing) {
3747
- return existing;
3748
- }
3749
- var sessionId = createUuid();
3750
- try {
3751
- var _window_localStorage;
3752
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
3753
- } catch (unused) {}
3754
- return sessionId;
3755
- }
3756
- function createUuid() {
3757
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
3758
- return crypto.randomUUID();
3759
- }
3760
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
3761
- var value = Math.floor(Math.random() * 16);
3762
- var nibble = char === "x" ? value : value & 3 | 8;
3763
- return nibble.toString(16);
3764
- });
3765
- }
3766
- function readNativeBridgeSignals() {
3767
- if (typeof window === "undefined") {
3768
- return {};
3769
- }
3770
- var candidates = [
3771
- window.__STORMCLOUD_CTV_AD_INFO__,
3772
- window.__STORMCLOUD_CTV__,
3773
- window.stormcloudCtv,
3774
- window.AiryTV,
3775
- window.Android
3776
- ].filter(Boolean);
3777
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3778
- try {
3779
- for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3780
- var source = _step.value;
3781
- var contentUrl = readBridgeValue(source, [
3782
- "contentUrl",
3783
- "url",
3784
- "videoUrl",
3785
- "canonicalUrl"
3786
- ]) || void 0;
3787
- var deviceId = readBridgeValue(source, [
3788
- "rdid",
3789
- "ifa",
3790
- "advertisingId",
3791
- "adId",
3792
- "deviceId"
3793
- ]) || void 0;
3794
- if (!contentUrl && !deviceId) continue;
3795
- var deviceIdType = readBridgeValue(source, [
3796
- "idtype",
3797
- "deviceIdType",
3798
- "advertisingIdType"
3799
- ]) || inferDeviceIdType();
3800
- var limitAdTracking = readBridgeBoolean(source, [
3801
- "is_lat",
3802
- "limitAdTracking",
3803
- "limitedAdTracking",
3804
- "lat"
3805
- ]);
3806
- return _object_spread({}, contentUrl ? {
3807
- contentUrl: contentUrl
3808
- } : {}, deviceId ? {
3809
- deviceId: deviceId
3810
- } : {}, deviceId && deviceIdType ? {
3811
- deviceIdType: deviceIdType
3812
- } : {}, deviceId && limitAdTracking != null ? {
3813
- limitAdTracking: limitAdTracking
3814
- } : {});
3815
- }
3816
- } catch (err) {
3817
- _didIteratorError = true;
3818
- _iteratorError = err;
3819
- } finally{
3820
- try {
3821
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3822
- _iterator.return();
3823
- }
3824
- } finally{
3825
- if (_didIteratorError) {
3826
- throw _iteratorError;
3827
- }
3828
- }
3829
- }
3830
- return {};
3831
- }
3832
- function readBridgeValue(source, keys) {
3833
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3834
- try {
3835
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3836
- var key = _step.value;
3837
- var value = source === null || source === void 0 ? void 0 : source[key];
3838
- if (typeof value === "string" && value) {
3839
- return value;
3840
- }
3841
- if (typeof value === "function") {
3842
- try {
3843
- var result = value.call(source);
3844
- if (typeof result === "string" && result) {
3845
- return result;
3846
- }
3847
- } catch (unused) {}
3848
- }
3849
- }
3850
- } catch (err) {
3851
- _didIteratorError = true;
3852
- _iteratorError = err;
3853
- } finally{
3854
- try {
3855
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3856
- _iterator.return();
3857
- }
3858
- } finally{
3859
- if (_didIteratorError) {
3860
- throw _iteratorError;
3861
- }
3862
- }
3863
- }
3864
- return void 0;
3865
- }
3866
- function readBridgeBoolean(source, keys) {
3867
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3868
- try {
3869
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3870
- var key = _step.value;
3871
- var value = source === null || source === void 0 ? void 0 : source[key];
3872
- var normalized = normalizeBoolean(value);
3873
- if (normalized != null) {
3874
- return normalized;
3875
- }
3876
- if (typeof value === "function") {
3877
- try {
3878
- var result = normalizeBoolean(value.call(source));
3879
- if (result != null) {
3880
- return result;
3881
- }
3882
- } catch (unused) {}
3883
- }
3884
- }
3885
- } catch (err) {
3886
- _didIteratorError = true;
3887
- _iteratorError = err;
3888
- } finally{
3889
- try {
3890
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3891
- _iterator.return();
3892
- }
3893
- } finally{
3894
- if (_didIteratorError) {
3895
- throw _iteratorError;
3896
- }
3897
- }
3898
- }
3899
- return void 0;
3900
- }
3901
- function readStoredDeviceId() {
3902
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3903
- try {
3904
- for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3905
- var key = _step.value;
3906
- var value = readStoredString(key);
3907
- if (value) {
3908
- return value;
3909
- }
3910
- }
3911
- } catch (err) {
3912
- _didIteratorError = true;
3913
- _iteratorError = err;
3914
- } finally{
3915
- try {
3916
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3917
- _iterator.return();
3918
- }
3919
- } finally{
3920
- if (_didIteratorError) {
3921
- throw _iteratorError;
3922
- }
3923
- }
3924
- }
3925
- return void 0;
3926
- }
3927
- function readStoredString(key) {
3928
- if (typeof window === "undefined") {
3929
- return void 0;
3930
- }
3931
- try {
3932
- var _window_localStorage;
3933
- var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
3934
- return value || void 0;
3935
- } catch (unused) {
3936
- return void 0;
3937
- }
3938
- }
3939
- function readStoredLimitAdTracking() {
3940
- return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
3941
- }
3942
- function normalizeBoolean(value) {
3943
- if (typeof value === "boolean") {
3944
- return value;
3945
- }
3946
- if (typeof value === "number") {
3947
- return value === 1;
3948
- }
3949
- if (typeof value === "string") {
3950
- var normalized = value.toLowerCase();
3951
- if (normalized === "1" || normalized === "true" || normalized === "yes") {
3952
- return true;
3953
- }
3954
- if (normalized === "0" || normalized === "false" || normalized === "no") {
3955
- return false;
3956
- }
3957
- }
3958
- return void 0;
3959
- }
3960
- function inferDeviceIdType() {
3961
- if (typeof navigator === "undefined") {
3962
- return void 0;
3963
- }
3964
- var ua = navigator.userAgent;
3965
- if (/Roku/i.test(ua)) return "rida";
3966
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
3967
- if (/AppleTV/i.test(ua)) return "tvOS";
3968
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
3969
- if (/Web0S|webOS|LG/i.test(ua)) return "lgudid";
3970
- if (/Android|Google TV/i.test(ua)) return "aaid";
3971
- return void 0;
3972
- }
3973
- // src/player/VmapManager.ts
3974
- var VmapManager = /*#__PURE__*/ function() {
3975
- function VmapManager(config, video) {
3976
- _class_call_check(this, VmapManager);
4262
+ // src/player/AdConfigManager.ts
4263
+ var AdConfigManager = /*#__PURE__*/ function() {
4264
+ function AdConfigManager(config, video) {
4265
+ _class_call_check(this, AdConfigManager);
3977
4266
  this.vmapBreaks = [];
3978
4267
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
3979
4268
  this.streamCorrelator = generateCorrelator();
@@ -3985,7 +4274,7 @@ var VmapManager = /*#__PURE__*/ function() {
3985
4274
  this.config = config;
3986
4275
  this.video = video;
3987
4276
  }
3988
- _create_class(VmapManager, [
4277
+ _create_class(AdConfigManager, [
3989
4278
  {
3990
4279
  key: "debug",
3991
4280
  get: function get() {
@@ -4047,7 +4336,7 @@ var VmapManager = /*#__PURE__*/ function() {
4047
4336
  ];
4048
4337
  }
4049
4338
  if (this.config.vastTagUrl) {
4050
- this.apiVastTagUrl = this.config.vastTagUrl;
4339
+ this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
4051
4340
  if (this.debug) {
4052
4341
  console.log("[StormcloudVideoPlayer] Using custom VAST tag URL:", this.apiVastTagUrl);
4053
4342
  }
@@ -4087,7 +4376,7 @@ var VmapManager = /*#__PURE__*/ function() {
4087
4376
  data = _state.sent();
4088
4377
  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;
4089
4378
  if (imaPayload) {
4090
- this.apiVastTagUrl = decodeURIComponent(imaPayload);
4379
+ this.apiVastTagUrl = normalizeVastTagUrl(imaPayload);
4091
4380
  if (this.debug) {
4092
4381
  console.log("[StormcloudVideoPlayer] Extracted VAST tag URL from /ads/web:", this.apiVastTagUrl);
4093
4382
  }
@@ -4402,24 +4691,24 @@ var VmapManager = /*#__PURE__*/ function() {
4402
4691
  for(var i = 0; i < count; i++){
4403
4692
  this.adRequestPositionInBreak++;
4404
4693
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
4405
- var ctvSignals = this.config.ctvAdRequest ? resolveCtvVastSignals() : void 0;
4694
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
4406
4695
  var urlWithMacros = applyVastMacros(baseUrl, {
4407
4696
  correlator: generateCorrelator(),
4408
4697
  streamCorrelator: this.streamCorrelator,
4409
4698
  pod: this.podCounter > 0 ? this.podCounter : void 0,
4410
4699
  adPosition: this.adRequestPositionInBreak,
4411
- isCtv: this.config.ctvAdRequest,
4412
- contentUrl: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.contentUrl,
4413
- pageUrl: !this.config.ctvAdRequest && typeof window !== "undefined" ? window.location.href : void 0,
4700
+ isCtv: envSignals.isCtv,
4701
+ contentUrl: envSignals.contentUrl,
4702
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
4414
4703
  adWillPlayMuted: adWillPlayMuted,
4415
4704
  adWillAutoPlay: !!this.config.autoplay,
4416
- appId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appId,
4417
- appName: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appName,
4418
- sessionId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.sessionId,
4419
- deviceId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceId,
4420
- deviceIdType: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceIdType,
4421
- limitAdTracking: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.limitAdTracking,
4422
- deviceTypeHint: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceTypeHint,
4705
+ appId: envSignals.appId,
4706
+ appName: envSignals.appName,
4707
+ sessionId: envSignals.sessionId,
4708
+ deviceId: envSignals.deviceId,
4709
+ deviceIdType: envSignals.deviceIdType,
4710
+ limitAdTracking: envSignals.limitAdTracking,
4711
+ deviceTypeHint: envSignals.deviceTypeHint,
4423
4712
  adTest: this.config.adTest,
4424
4713
  consent: this.consentSignals
4425
4714
  });
@@ -4472,7 +4761,7 @@ var VmapManager = /*#__PURE__*/ function() {
4472
4761
  }
4473
4762
  }
4474
4763
  ]);
4475
- return VmapManager;
4764
+ return AdConfigManager;
4476
4765
  }();
4477
4766
  // src/player/AdTimingService.ts
4478
4767
  var AdTimingService = /*#__PURE__*/ function() {
@@ -6199,7 +6488,7 @@ function resizePlayer(video, adPlayer, debug) {
6199
6488
  }
6200
6489
  // src/player/AdBreakOrchestrator.ts
6201
6490
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
6202
- function AdBreakOrchestrator(host, timing, preloadPool, vmap, cueManager, placeholder) {
6491
+ function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6203
6492
  _class_call_check(this, AdBreakOrchestrator);
6204
6493
  this.inAdBreak = false;
6205
6494
  this.showAds = false;
@@ -6214,7 +6503,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6214
6503
  this.host = host;
6215
6504
  this.timing = timing;
6216
6505
  this.preloadPool = preloadPool;
6217
- this.vmap = vmap;
6506
+ this.adConfig = adConfig;
6218
6507
  this.cueManager = cueManager;
6219
6508
  this.placeholder = placeholder;
6220
6509
  }
@@ -6380,7 +6669,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6380
6669
  }
6381
6670
  this.pendingAdBreak = null;
6382
6671
  this.cueManager.pendingScte35CueKey = void 0;
6383
- this.vmap.podAssignedByPrefetch = false;
6672
+ this.adConfig.podAssignedByPrefetch = false;
6384
6673
  }
6385
6674
  },
6386
6675
  {
@@ -6394,15 +6683,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6394
6683
  return _ts_generator(this, function(_state) {
6395
6684
  switch(_state.label){
6396
6685
  case 0:
6397
- scheduled = this.vmap.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6686
+ scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6398
6687
  if (scheduled) {
6399
- this.vmap.consumedVmapBreakIds.add(this.vmap.getAdBreakKey(scheduled));
6688
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
6400
6689
  }
6401
- tags = this.vmap.selectVastTagsForBreak(scheduled);
6690
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6402
6691
  if (tags && tags.length > 0 && tags[0]) {
6403
6692
  baseVastUrl = tags[0];
6404
- } else if (this.vmap.apiVastTagUrl) {
6405
- baseVastUrl = this.vmap.apiVastTagUrl;
6693
+ } else if (this.adConfig.apiVastTagUrl) {
6694
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6406
6695
  } else {
6407
6696
  this.clearPendingAdBreak();
6408
6697
  return [
@@ -6420,10 +6709,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6420
6709
  this.continuousFetchingActive = true;
6421
6710
  this.isShowingPlaceholder = false;
6422
6711
  this.timing.totalAdRequestsInBreak = 0;
6423
- if (this.vmap.podAssignedByPrefetch) {
6424
- this.vmap.podAssignedByPrefetch = false;
6712
+ if (this.adConfig.podAssignedByPrefetch) {
6713
+ this.adConfig.podAssignedByPrefetch = false;
6425
6714
  } else {
6426
- this.vmap.beginNewAdPod();
6715
+ this.adConfig.beginNewAdPod();
6427
6716
  }
6428
6717
  currentMuted = this.host.video.muted;
6429
6718
  currentVolume = this.host.video.volume;
@@ -7695,7 +7984,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7695
7984
  return _this.adBreak.inAdBreak;
7696
7985
  }
7697
7986
  });
7698
- this.vmap = new VmapManager(this.config, this.video);
7987
+ this.adConfig = new AdConfigManager(this.config, this.video);
7699
7988
  this.timing = new AdTimingService(this.config, this.video, {
7700
7989
  onAdStopTimerFired: function onAdStopTimerFired() {
7701
7990
  return _this.onAdStopTimerFired();
@@ -7775,7 +8064,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7775
8064
  generateVastUrls: function generateVastUrls(base, count) {
7776
8065
  return _this.generateVastUrls(base, count);
7777
8066
  }
7778
- }, this.timing, this.preloadPool, this.vmap, this.cueManager, this.placeholder);
8067
+ }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7779
8068
  }
7780
8069
  _create_class(StormcloudVideoPlayer, [
7781
8070
  {
@@ -7803,7 +8092,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7803
8092
  {
7804
8093
  key: "generateVastUrls",
7805
8094
  value: function generateVastUrls(baseUrl, count) {
7806
- return this.vmap.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8095
+ return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
7807
8096
  }
7808
8097
  },
7809
8098
  {
@@ -7831,7 +8120,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7831
8120
  ]);
7832
8121
  return [
7833
8122
  4,
7834
- this.vmap.fetchAdConfiguration()
8123
+ this.adConfig.fetchAdConfiguration()
7835
8124
  ];
7836
8125
  case 2:
7837
8126
  _state.sent();
@@ -7858,9 +8147,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7858
8147
  continuousPlayback: (_this_config_lowLatencyMode = this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
7859
8148
  }).catch(function() {});
7860
8149
  fetchConsentSignals().then(function(signals) {
7861
- _this.vmap.consentSignals = signals;
8150
+ _this.adConfig.consentSignals = signals;
7862
8151
  }).catch(function() {});
7863
- this.vmap.initializeTracking();
8152
+ this.adConfig.initializeTracking();
7864
8153
  if (!this.hlsEngine.shouldUseNativeHls(function() {
7865
8154
  return _this.getStreamType();
7866
8155
  })) return [
@@ -7895,14 +8184,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7895
8184
  return _async_to_generator(function() {
7896
8185
  var prerollKey, adBehavior;
7897
8186
  return _ts_generator(this, function(_state) {
7898
- if (!this.vmap.isVmapEnabled() && !isLive && this.vmap.vmapBreaks.length === 0 && this.vmap.apiVastTagUrl) {
8187
+ if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
7899
8188
  prerollKey = "synthetic-vod-preroll";
7900
- if (!this.vmap.consumedVmapBreakIds.has(prerollKey)) {
7901
- this.vmap.vmapBreaks = [
8189
+ if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
8190
+ this.adConfig.vmapBreaks = [
7902
8191
  {
7903
8192
  id: prerollKey,
7904
8193
  startTimeMs: 0,
7905
- vastTagUrl: this.vmap.apiVastTagUrl
8194
+ vastTagUrl: this.adConfig.apiVastTagUrl
7906
8195
  }
7907
8196
  ];
7908
8197
  if (this.debug) {
@@ -8169,19 +8458,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8169
8458
  key: "startAdPrefetch",
8170
8459
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
8171
8460
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
8172
- var scheduled = this.vmap.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8173
- var tags = this.vmap.selectVastTagsForBreak(scheduled);
8461
+ var scheduled = this.adConfig.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8462
+ var tags = this.adConfig.selectVastTagsForBreak(scheduled);
8174
8463
  var baseVastUrl;
8175
8464
  if (tags && tags.length > 0 && tags[0]) {
8176
8465
  baseVastUrl = tags[0];
8177
- } else if (this.vmap.apiVastTagUrl) {
8178
- baseVastUrl = this.vmap.apiVastTagUrl;
8466
+ } else if (this.adConfig.apiVastTagUrl) {
8467
+ baseVastUrl = this.adConfig.apiVastTagUrl;
8179
8468
  } else {
8180
8469
  if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
8181
8470
  return;
8182
8471
  }
8183
- this.vmap.beginNewAdPod();
8184
- this.vmap.podAssignedByPrefetch = true;
8472
+ this.adConfig.beginNewAdPod();
8473
+ this.adConfig.podAssignedByPrefetch = true;
8185
8474
  var generatedUrls = this.generateVastUrls(baseVastUrl, 1);
8186
8475
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
8187
8476
  marker: marker
@@ -8216,10 +8505,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8216
8505
  key: "onTimeUpdate",
8217
8506
  value: function onTimeUpdate(currentTimeSec) {
8218
8507
  var _this = this;
8219
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8508
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8220
8509
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8221
8510
  var nowMs = currentTimeSec * 1e3;
8222
- var breakToPlay = this.vmap.findBreakForTime(nowMs);
8511
+ var breakToPlay = this.adConfig.findBreakForTime(nowMs);
8223
8512
  if (breakToPlay) {
8224
8513
  void this.handleVmapAdBreak(breakToPlay, nowMs).catch(function(error) {
8225
8514
  if (_this.debug) {
@@ -8233,11 +8522,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8233
8522
  key: "onVideoEnded",
8234
8523
  value: function onVideoEnded() {
8235
8524
  var _this = this;
8236
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8525
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8237
8526
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8238
8527
  var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
8239
- var postroll = this.vmap.vmapBreaks.find(function(b) {
8240
- return b.startTimeMs === -1 && !_this.vmap.consumedVmapBreakIds.has(_this.vmap.getAdBreakKey(b));
8528
+ var postroll = this.adConfig.vmapBreaks.find(function(b) {
8529
+ return b.startTimeMs === -1 && !_this.adConfig.consumedVmapBreakIds.has(_this.adConfig.getAdBreakKey(b));
8241
8530
  });
8242
8531
  if (postroll) {
8243
8532
  void this.handleVmapAdBreak(postroll, durationMs).catch(function(error) {
@@ -8256,11 +8545,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8256
8545
  return _ts_generator(this, function(_state) {
8257
8546
  switch(_state.label){
8258
8547
  case 0:
8259
- key = this.vmap.getAdBreakKey(adBreak);
8260
- if (this.vmap.consumedVmapBreakIds.has(key)) return [
8548
+ key = this.adConfig.getAdBreakKey(adBreak);
8549
+ if (this.adConfig.consumedVmapBreakIds.has(key)) return [
8261
8550
  2
8262
8551
  ];
8263
- breakStartMs = this.vmap.resolveBreakStartMs(adBreak);
8552
+ breakStartMs = this.adConfig.resolveBreakStartMs(adBreak);
8264
8553
  if (breakStartMs == null) return [
8265
8554
  2
8266
8555
  ];
@@ -8271,8 +8560,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8271
8560
  3,
8272
8561
  4
8273
8562
  ];
8274
- this.vmap.consumedVmapBreakIds.add(key);
8275
- tags = this.vmap.selectVastTagsForBreak(adBreak);
8563
+ this.adConfig.consumedVmapBreakIds.add(key);
8564
+ tags = this.adConfig.selectVastTagsForBreak(adBreak);
8276
8565
  if (!tags || tags.length === 0) return [
8277
8566
  2
8278
8567
  ];
@@ -8464,7 +8753,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8464
8753
  this.video.removeEventListener("emptied", this.emptiedHandler);
8465
8754
  delete this.emptiedHandler;
8466
8755
  }
8467
- this.vmap.destroyTracking();
8756
+ this.adConfig.destroyTracking();
8468
8757
  this.hlsEngine.destroy();
8469
8758
  (_this_adPlayer = this.adPlayer) === null || _this_adPlayer === void 0 ? void 0 : _this_adPlayer.destroy();
8470
8759
  if (this.palPlaybackStarted) {