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
@@ -2271,22 +2271,326 @@ function initializePolyfills() {
2271
2271
  polyfillTextEncoder();
2272
2272
  polyfillPromiseFinally();
2273
2273
  }
2274
- // src/utils/vastMacros.ts
2275
- function generateCorrelator() {
2276
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2274
+ // src/utils/vastEnvironmentSignals.ts
2275
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2276
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
2277
+ var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
2278
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2279
+ var DEVICE_ID_STORAGE_KEYS = [
2280
+ "rdid",
2281
+ "ifa",
2282
+ "advertisingId",
2283
+ "advertising_id",
2284
+ "deviceAdvertisingId",
2285
+ "aaid",
2286
+ "adid",
2287
+ "rida",
2288
+ "tifa",
2289
+ "lgudid"
2290
+ ];
2291
+ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
2292
+ "aaid",
2293
+ "adid"
2294
+ ]);
2295
+ function resolveVastEnvironmentSignals(isCtv) {
2296
+ var _ref, _bridgeSignals_limitAdTracking;
2297
+ var bridgeSignals = readNativeBridgeSignals();
2298
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
2299
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || inferDeviceIdType();
2300
+ 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;
2301
+ if (isCtv) {
2302
+ return _object_spread_props(_object_spread({
2303
+ isCtv: true,
2304
+ contentUrl: bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL,
2305
+ appId: bridgeSignals.appId || readStoredString("appId") || readStoredString("msid") || AIRY_ANDROID_APP_ID,
2306
+ appName: bridgeSignals.appName || readStoredString("appName") || readStoredString("an") || AIRY_APP_NAME,
2307
+ sessionId: getOrCreateCtvSessionId()
2308
+ }, deviceId ? {
2309
+ deviceId: deviceId
2310
+ } : {}, deviceIdType ? {
2311
+ deviceIdType: deviceIdType
2312
+ } : {}, limitAdTracking != null ? {
2313
+ limitAdTracking: limitAdTracking
2314
+ } : {}), {
2315
+ deviceTypeHint: 5
2316
+ });
2317
+ }
2318
+ return _object_spread({
2319
+ isCtv: false
2320
+ }, deviceId ? {
2321
+ deviceId: deviceId
2322
+ } : {}, deviceIdType ? {
2323
+ deviceIdType: deviceIdType
2324
+ } : {}, limitAdTracking != null ? {
2325
+ limitAdTracking: limitAdTracking
2326
+ } : {});
2327
+ }
2328
+ function inferDeviceIdType() {
2329
+ if (typeof navigator === "undefined") {
2330
+ return void 0;
2331
+ }
2332
+ var ua = navigator.userAgent;
2333
+ if (/Roku/i.test(ua)) return "rida";
2334
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
2335
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
2336
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
2337
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
2338
+ if (/Android|Google TV/i.test(ua)) return "aaid";
2339
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
2340
+ return void 0;
2341
+ }
2342
+ function isEquivalentDeviceIdType(tagType, runtimeType) {
2343
+ if (!tagType || !runtimeType) return false;
2344
+ var tag = tagType.toLowerCase();
2345
+ var runtime = runtimeType.toLowerCase();
2346
+ if (tag === runtime) return true;
2347
+ return ANDROID_ID_TYPES.has(tag) && ANDROID_ID_TYPES.has(runtime);
2348
+ }
2349
+ function getOrCreateCtvSessionId() {
2350
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2351
+ if (existing) {
2352
+ return existing;
2353
+ }
2354
+ var sessionId = createUuid();
2355
+ try {
2356
+ var _window_localStorage;
2357
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2358
+ } catch (unused) {}
2359
+ return sessionId;
2360
+ }
2361
+ function createUuid() {
2362
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2363
+ return crypto.randomUUID();
2364
+ }
2365
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2366
+ var value = Math.floor(Math.random() * 16);
2367
+ var nibble = char === "x" ? value : value & 3 | 8;
2368
+ return nibble.toString(16);
2369
+ });
2370
+ }
2371
+ function readNativeBridgeSignals() {
2372
+ if (typeof window === "undefined") {
2373
+ return {};
2374
+ }
2375
+ var candidates = [
2376
+ window.__STORMCLOUD_CTV_AD_INFO__,
2377
+ window.__STORMCLOUD_CTV__,
2378
+ window.stormcloudCtv,
2379
+ window.AiryTV,
2380
+ window.Android,
2381
+ window.webOS,
2382
+ window.tizen,
2383
+ window.amazon
2384
+ ].filter(Boolean);
2385
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2386
+ try {
2387
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2388
+ var source = _step.value;
2389
+ var contentUrl = readBridgeValue(source, [
2390
+ "contentUrl",
2391
+ "url",
2392
+ "videoUrl",
2393
+ "canonicalUrl"
2394
+ ]) || void 0;
2395
+ var appId = readBridgeValue(source, [
2396
+ "appId",
2397
+ "msid",
2398
+ "applicationId",
2399
+ "packageName"
2400
+ ]) || void 0;
2401
+ var appName = readBridgeValue(source, [
2402
+ "appName",
2403
+ "an",
2404
+ "applicationName"
2405
+ ]) || void 0;
2406
+ var deviceId = readBridgeValue(source, [
2407
+ "rdid",
2408
+ "ifa",
2409
+ "advertisingId",
2410
+ "adId",
2411
+ "deviceId",
2412
+ "lgudid",
2413
+ "LGUDID",
2414
+ "tifa",
2415
+ "rida",
2416
+ "afai",
2417
+ "aaid"
2418
+ ]) || void 0;
2419
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
2420
+ var deviceIdType = readBridgeValue(source, [
2421
+ "idtype",
2422
+ "deviceIdType",
2423
+ "advertisingIdType",
2424
+ "idType"
2425
+ ]) || inferDeviceIdType();
2426
+ var limitAdTracking = readBridgeBoolean(source, [
2427
+ "is_lat",
2428
+ "limitAdTracking",
2429
+ "limitedAdTracking",
2430
+ "lat"
2431
+ ]);
2432
+ return _object_spread({}, contentUrl ? {
2433
+ contentUrl: contentUrl
2434
+ } : {}, appId ? {
2435
+ appId: appId
2436
+ } : {}, appName ? {
2437
+ appName: appName
2438
+ } : {}, deviceId ? {
2439
+ deviceId: deviceId
2440
+ } : {}, deviceId && deviceIdType ? {
2441
+ deviceIdType: deviceIdType
2442
+ } : {}, deviceId && limitAdTracking != null ? {
2443
+ limitAdTracking: limitAdTracking
2444
+ } : {});
2445
+ }
2446
+ } catch (err) {
2447
+ _didIteratorError = true;
2448
+ _iteratorError = err;
2449
+ } finally{
2277
2450
  try {
2278
- var _buf_, _buf_1;
2279
- var buf = new Uint32Array(2);
2280
- crypto.getRandomValues(buf);
2281
- 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);
2282
- if (value > 0) {
2283
- return String(value);
2451
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2452
+ _iterator.return();
2284
2453
  }
2285
- } catch (unused) {}
2454
+ } finally{
2455
+ if (_didIteratorError) {
2456
+ throw _iteratorError;
2457
+ }
2458
+ }
2286
2459
  }
2287
- return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2460
+ return {};
2461
+ }
2462
+ function readBridgeValue(source, keys) {
2463
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2464
+ try {
2465
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2466
+ var key = _step.value;
2467
+ var value = source === null || source === void 0 ? void 0 : source[key];
2468
+ if (typeof value === "string" && value) {
2469
+ return value;
2470
+ }
2471
+ if (typeof value === "function") {
2472
+ try {
2473
+ var result = value.call(source);
2474
+ if (typeof result === "string" && result) {
2475
+ return result;
2476
+ }
2477
+ } catch (unused) {}
2478
+ }
2479
+ }
2480
+ } catch (err) {
2481
+ _didIteratorError = true;
2482
+ _iteratorError = err;
2483
+ } finally{
2484
+ try {
2485
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2486
+ _iterator.return();
2487
+ }
2488
+ } finally{
2489
+ if (_didIteratorError) {
2490
+ throw _iteratorError;
2491
+ }
2492
+ }
2493
+ }
2494
+ return void 0;
2495
+ }
2496
+ function readBridgeBoolean(source, keys) {
2497
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2498
+ try {
2499
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2500
+ var key = _step.value;
2501
+ var value = source === null || source === void 0 ? void 0 : source[key];
2502
+ var normalized = normalizeBoolean(value);
2503
+ if (normalized != null) {
2504
+ return normalized;
2505
+ }
2506
+ if (typeof value === "function") {
2507
+ try {
2508
+ var result = normalizeBoolean(value.call(source));
2509
+ if (result != null) {
2510
+ return result;
2511
+ }
2512
+ } catch (unused) {}
2513
+ }
2514
+ }
2515
+ } catch (err) {
2516
+ _didIteratorError = true;
2517
+ _iteratorError = err;
2518
+ } finally{
2519
+ try {
2520
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2521
+ _iterator.return();
2522
+ }
2523
+ } finally{
2524
+ if (_didIteratorError) {
2525
+ throw _iteratorError;
2526
+ }
2527
+ }
2528
+ }
2529
+ return void 0;
2530
+ }
2531
+ function readStoredDeviceId() {
2532
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2533
+ try {
2534
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2535
+ var key = _step.value;
2536
+ var value = readStoredString(key);
2537
+ if (value) {
2538
+ return value;
2539
+ }
2540
+ }
2541
+ } catch (err) {
2542
+ _didIteratorError = true;
2543
+ _iteratorError = err;
2544
+ } finally{
2545
+ try {
2546
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2547
+ _iterator.return();
2548
+ }
2549
+ } finally{
2550
+ if (_didIteratorError) {
2551
+ throw _iteratorError;
2552
+ }
2553
+ }
2554
+ }
2555
+ return void 0;
2288
2556
  }
2557
+ function readStoredString(key) {
2558
+ if (typeof window === "undefined") {
2559
+ return void 0;
2560
+ }
2561
+ try {
2562
+ var _window_localStorage;
2563
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2564
+ return value || void 0;
2565
+ } catch (unused) {
2566
+ return void 0;
2567
+ }
2568
+ }
2569
+ function readStoredLimitAdTracking() {
2570
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2571
+ }
2572
+ function normalizeBoolean(value) {
2573
+ if (typeof value === "boolean") {
2574
+ return value;
2575
+ }
2576
+ if (typeof value === "number") {
2577
+ return value === 1;
2578
+ }
2579
+ if (typeof value === "string") {
2580
+ var normalized = value.toLowerCase();
2581
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
2582
+ return true;
2583
+ }
2584
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
2585
+ return false;
2586
+ }
2587
+ }
2588
+ return void 0;
2589
+ }
2590
+ // src/utils/vastMacros.ts
2289
2591
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
2592
+ var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
2593
+ var EXAMPLE_COM_URL = /example\.com/i;
2290
2594
  var CTV_UNSUPPORTED_PARAMS = [
2291
2595
  "description_url",
2292
2596
  "tfcd",
@@ -2301,14 +2605,265 @@ var CTV_UNSUPPORTED_PARAMS = [
2301
2605
  "gdpr_consent",
2302
2606
  "us_privacy"
2303
2607
  ];
2608
+ var INLINE_DEVICE_MACRO_REPLACEMENTS = [
2609
+ {
2610
+ pattern: /\[RDID\]/gi,
2611
+ getValue: function getValue(ctx) {
2612
+ return ctx.deviceId;
2613
+ }
2614
+ },
2615
+ {
2616
+ pattern: /\[IFA\]/gi,
2617
+ getValue: function getValue(ctx) {
2618
+ return ctx.deviceId;
2619
+ }
2620
+ },
2621
+ {
2622
+ pattern: /\[ADVERTISING[_-]?ID(?:ENTIFIER)?\]/gi,
2623
+ getValue: function getValue(ctx) {
2624
+ return ctx.deviceId;
2625
+ }
2626
+ },
2627
+ {
2628
+ pattern: /\[DEVICE[_-]?ID\]/gi,
2629
+ getValue: function getValue(ctx) {
2630
+ return ctx.deviceId;
2631
+ }
2632
+ },
2633
+ {
2634
+ pattern: /\[IDTYPE\]/gi,
2635
+ getValue: function getValue(ctx) {
2636
+ return ctx.deviceIdType;
2637
+ }
2638
+ },
2639
+ {
2640
+ pattern: /\{rdid\}/gi,
2641
+ getValue: function getValue(ctx) {
2642
+ return ctx.deviceId;
2643
+ }
2644
+ },
2645
+ {
2646
+ pattern: /\{device[_-]?id\}/gi,
2647
+ getValue: function getValue(ctx) {
2648
+ return ctx.deviceId;
2649
+ }
2650
+ },
2651
+ {
2652
+ pattern: /\{idtype\}/gi,
2653
+ getValue: function getValue(ctx) {
2654
+ return ctx.deviceIdType;
2655
+ }
2656
+ },
2657
+ {
2658
+ pattern: /%%ADVERTISING_IDENTIFIER_PLAIN%%/gi,
2659
+ getValue: function getValue(ctx) {
2660
+ return ctx.deviceId;
2661
+ }
2662
+ },
2663
+ {
2664
+ pattern: /%%ADVERTISING_ID_OPT_OUT%%/gi,
2665
+ getValue: function getValue(ctx) {
2666
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2667
+ }
2668
+ },
2669
+ {
2670
+ pattern: /%%ADVERTISING_ID_TYPE%%/gi,
2671
+ getValue: function getValue(ctx) {
2672
+ return ctx.deviceIdType;
2673
+ }
2674
+ },
2675
+ {
2676
+ pattern: /%%ADVERTISING_ID%%/gi,
2677
+ getValue: function getValue(ctx) {
2678
+ return ctx.deviceId;
2679
+ }
2680
+ },
2681
+ {
2682
+ pattern: /%%LIMIT_AD_TRACKING%%/gi,
2683
+ getValue: function getValue(ctx) {
2684
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2685
+ }
2686
+ },
2687
+ {
2688
+ pattern: /%%MSID%%/gi,
2689
+ getValue: function getValue(ctx) {
2690
+ return ctx.appId;
2691
+ }
2692
+ },
2693
+ {
2694
+ pattern: /%%APP_NAME%%/gi,
2695
+ getValue: function getValue(ctx) {
2696
+ return ctx.appName;
2697
+ }
2698
+ },
2699
+ {
2700
+ pattern: /%%SESSION_ID%%/gi,
2701
+ getValue: function getValue(ctx) {
2702
+ return ctx.sessionId;
2703
+ }
2704
+ },
2705
+ {
2706
+ pattern: /%%CORRELATOR%%/gi,
2707
+ getValue: function getValue(ctx) {
2708
+ return ctx.correlator;
2709
+ }
2710
+ }
2711
+ ];
2712
+ function isMacroPlaceholder(value) {
2713
+ if (value == null) return true;
2714
+ var trimmed = value.trim();
2715
+ if (!trimmed) return true;
2716
+ if (UNEXPANDED_MACRO_PATTERN.test(trimmed)) return true;
2717
+ return /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(trimmed);
2718
+ }
2719
+ function generateCorrelator() {
2720
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2721
+ try {
2722
+ var _buf_, _buf_1;
2723
+ var buf = new Uint32Array(2);
2724
+ crypto.getRandomValues(buf);
2725
+ 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);
2726
+ if (value > 0) {
2727
+ return String(value);
2728
+ }
2729
+ } catch (unused) {}
2730
+ }
2731
+ return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2732
+ }
2733
+ function expandInlineMacroPlaceholders(baseUrl, ctx) {
2734
+ var url = baseUrl;
2735
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2736
+ try {
2737
+ for(var _iterator = INLINE_DEVICE_MACRO_REPLACEMENTS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2738
+ var _step_value = _step.value, pattern = _step_value.pattern, getValue = _step_value.getValue;
2739
+ var value = getValue(ctx);
2740
+ if (value != null && value !== "") {
2741
+ url = url.replace(pattern, encodeURIComponent(value));
2742
+ }
2743
+ }
2744
+ } catch (err) {
2745
+ _didIteratorError = true;
2746
+ _iteratorError = err;
2747
+ } finally{
2748
+ try {
2749
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2750
+ _iterator.return();
2751
+ }
2752
+ } finally{
2753
+ if (_didIteratorError) {
2754
+ throw _iteratorError;
2755
+ }
2756
+ }
2757
+ }
2758
+ return url;
2759
+ }
2760
+ function applyDeviceIdentityParams(params, ctx) {
2761
+ var _ctx_deviceId, _ctx_deviceIdType;
2762
+ var runtimeId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
2763
+ var runtimeType = ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType();
2764
+ var tagRdid = params.get("rdid");
2765
+ var tagType = params.get("idtype");
2766
+ var tagLat = params.get("is_lat");
2767
+ var latValue = ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2768
+ if (runtimeId) {
2769
+ params.set("rdid", runtimeId);
2770
+ params.set("idtype", runtimeType || tagType || "aaid");
2771
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : isMacroPlaceholder(tagLat) ? "0" : tagLat);
2772
+ return;
2773
+ }
2774
+ var tagRdidValid = Boolean(tagRdid && !isMacroPlaceholder(tagRdid));
2775
+ var tagTypeValid = Boolean(tagType && !isMacroPlaceholder(tagType));
2776
+ if (tagRdidValid && tagTypeValid && runtimeType && !isEquivalentDeviceIdType(tagType, runtimeType)) {
2777
+ params.delete("rdid");
2778
+ params.delete("idtype");
2779
+ params.delete("is_lat");
2780
+ return;
2781
+ }
2782
+ if (tagRdidValid) {
2783
+ if (isMacroPlaceholder(tagType) && runtimeType) {
2784
+ params.set("idtype", runtimeType);
2785
+ }
2786
+ if (isMacroPlaceholder(tagLat)) {
2787
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : "0");
2788
+ }
2789
+ return;
2790
+ }
2791
+ params.delete("rdid");
2792
+ params.delete("idtype");
2793
+ params.delete("is_lat");
2794
+ }
2795
+ function removeBrokenAppNameOrphans(params, appName) {
2796
+ var toDelete = [];
2797
+ params.forEach(function(_value, key) {
2798
+ if (!key || INVALID_VAST_PARAM_KEY.test(key)) {
2799
+ toDelete.push(key);
2800
+ }
2801
+ });
2802
+ if (appName && appName.includes("&")) {
2803
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2804
+ try {
2805
+ for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2806
+ var suffix = _step.value;
2807
+ var trimmed = suffix.trimStart();
2808
+ if (!trimmed) continue;
2809
+ toDelete.push(suffix, " ".concat(trimmed), trimmed);
2810
+ }
2811
+ } catch (err) {
2812
+ _didIteratorError = true;
2813
+ _iteratorError = err;
2814
+ } finally{
2815
+ try {
2816
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2817
+ _iterator.return();
2818
+ }
2819
+ } finally{
2820
+ if (_didIteratorError) {
2821
+ throw _iteratorError;
2822
+ }
2823
+ }
2824
+ }
2825
+ }
2826
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2827
+ try {
2828
+ for(var _iterator1 = new Set(toDelete)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2829
+ var key = _step1.value;
2830
+ if (key) params.delete(key);
2831
+ }
2832
+ } catch (err) {
2833
+ _didIteratorError1 = true;
2834
+ _iteratorError1 = err;
2835
+ } finally{
2836
+ try {
2837
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2838
+ _iterator1.return();
2839
+ }
2840
+ } finally{
2841
+ if (_didIteratorError1) {
2842
+ throw _iteratorError1;
2843
+ }
2844
+ }
2845
+ }
2846
+ }
2847
+ function normalizeVastTagUrl(raw) {
2848
+ if (!raw) return raw;
2849
+ try {
2850
+ var url = new URL(raw);
2851
+ removeBrokenAppNameOrphans(url.searchParams);
2852
+ return url.toString();
2853
+ } catch (unused) {
2854
+ return raw;
2855
+ }
2856
+ }
2304
2857
  function applyVastMacros(baseUrl, ctx) {
2858
+ var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
2305
2859
  var url;
2306
2860
  try {
2307
- url = new URL(baseUrl);
2861
+ url = new URL(normalizeVastTagUrl(expandedUrl));
2308
2862
  } catch (unused) {
2309
- return replaceCorrelatorFallback(baseUrl, ctx.correlator);
2863
+ return replaceCorrelatorFallback(expandedUrl, ctx.correlator);
2310
2864
  }
2311
2865
  var params = url.searchParams;
2866
+ removeBrokenAppNameOrphans(params, ctx.appName);
2312
2867
  params.set("correlator", ctx.correlator);
2313
2868
  if (ctx.isCtv) {
2314
2869
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2346,6 +2901,12 @@ function applyVastMacros(baseUrl, ctx) {
2346
2901
  if (!ctx.isCtv) {
2347
2902
  params.set("description_url", requestUrl);
2348
2903
  }
2904
+ } else {
2905
+ var existingUrl = params.get("url") || "";
2906
+ if (EXAMPLE_COM_URL.test(existingUrl)) {
2907
+ params.delete("url");
2908
+ params.delete("description_url");
2909
+ }
2349
2910
  }
2350
2911
  if (ctx.adWillPlayMuted != null) {
2351
2912
  params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
@@ -2357,6 +2918,7 @@ function applyVastMacros(baseUrl, ctx) {
2357
2918
  params.set("msid", ctx.appId);
2358
2919
  }
2359
2920
  if (ctx.appName) {
2921
+ removeBrokenAppNameOrphans(params, ctx.appName);
2360
2922
  params.set("an", ctx.appName);
2361
2923
  }
2362
2924
  if (ctx.sessionId) {
@@ -2367,15 +2929,7 @@ function applyVastMacros(baseUrl, ctx) {
2367
2929
  } else if (ctx.isCtv) {
2368
2930
  params.set("dth", "5");
2369
2931
  }
2370
- if (ctx.deviceId && ctx.deviceIdType) {
2371
- params.set("rdid", ctx.deviceId);
2372
- params.set("idtype", ctx.deviceIdType);
2373
- params.set("is_lat", ctx.limitAdTracking ? "1" : "0");
2374
- } else {
2375
- params.delete("rdid");
2376
- params.delete("idtype");
2377
- params.delete("is_lat");
2378
- }
2932
+ applyDeviceIdentityParams(params, ctx);
2379
2933
  if (!ctx.isCtv) {
2380
2934
  var consent = ctx.consent;
2381
2935
  if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
@@ -2393,7 +2947,7 @@ function applyVastMacros(baseUrl, ctx) {
2393
2947
  }
2394
2948
  var staleKeys = [];
2395
2949
  params.forEach(function(value, key) {
2396
- if (UNEXPANDED_MACRO_PATTERN.test(value)) {
2950
+ if (isMacroPlaceholder(value)) {
2397
2951
  staleKeys.push(key);
2398
2952
  }
2399
2953
  });
@@ -2417,6 +2971,7 @@ function applyVastMacros(baseUrl, ctx) {
2417
2971
  }
2418
2972
  }
2419
2973
  }
2974
+ removeBrokenAppNameOrphans(params, ctx.appName);
2420
2975
  return url.toString();
2421
2976
  }
2422
2977
  function replaceCorrelatorFallback(baseUrl, correlator) {
@@ -3667,276 +4222,10 @@ var Scte35CueManager = /*#__PURE__*/ function() {
3667
4222
  ]);
3668
4223
  return Scte35CueManager;
3669
4224
  }();
3670
- // src/utils/ctvVastSignals.ts
3671
- var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
3672
- var AIRY_APP_NAME = "AiryTV Movies & TV";
3673
- var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
3674
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
3675
- var DEVICE_ID_STORAGE_KEYS = [
3676
- "rdid",
3677
- "ifa",
3678
- "advertisingId",
3679
- "advertising_id",
3680
- "deviceAdvertisingId",
3681
- "aaid",
3682
- "adid",
3683
- "rida",
3684
- "tifa"
3685
- ];
3686
- function resolveCtvVastSignals() {
3687
- var _ref, _bridgeSignals_limitAdTracking;
3688
- var bridgeSignals = readNativeBridgeSignals();
3689
- var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
3690
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || inferDeviceIdType();
3691
- var contentUrl = bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL;
3692
- return _object_spread_props(_object_spread({
3693
- contentUrl: contentUrl,
3694
- appId: AIRY_ANDROID_APP_ID,
3695
- appName: AIRY_APP_NAME,
3696
- sessionId: getOrCreateCtvSessionId()
3697
- }, deviceId ? {
3698
- deviceId: deviceId
3699
- } : {}, deviceId && deviceIdType ? {
3700
- deviceIdType: deviceIdType
3701
- } : {}, deviceId ? {
3702
- limitAdTracking: (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false
3703
- } : {}), {
3704
- deviceTypeHint: 5
3705
- });
3706
- }
3707
- function getOrCreateCtvSessionId() {
3708
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
3709
- if (existing) {
3710
- return existing;
3711
- }
3712
- var sessionId = createUuid();
3713
- try {
3714
- var _window_localStorage;
3715
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
3716
- } catch (unused) {}
3717
- return sessionId;
3718
- }
3719
- function createUuid() {
3720
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
3721
- return crypto.randomUUID();
3722
- }
3723
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
3724
- var value = Math.floor(Math.random() * 16);
3725
- var nibble = char === "x" ? value : value & 3 | 8;
3726
- return nibble.toString(16);
3727
- });
3728
- }
3729
- function readNativeBridgeSignals() {
3730
- if (typeof window === "undefined") {
3731
- return {};
3732
- }
3733
- var candidates = [
3734
- window.__STORMCLOUD_CTV_AD_INFO__,
3735
- window.__STORMCLOUD_CTV__,
3736
- window.stormcloudCtv,
3737
- window.AiryTV,
3738
- window.Android
3739
- ].filter(Boolean);
3740
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3741
- try {
3742
- for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3743
- var source = _step.value;
3744
- var contentUrl = readBridgeValue(source, [
3745
- "contentUrl",
3746
- "url",
3747
- "videoUrl",
3748
- "canonicalUrl"
3749
- ]) || void 0;
3750
- var deviceId = readBridgeValue(source, [
3751
- "rdid",
3752
- "ifa",
3753
- "advertisingId",
3754
- "adId",
3755
- "deviceId"
3756
- ]) || void 0;
3757
- if (!contentUrl && !deviceId) continue;
3758
- var deviceIdType = readBridgeValue(source, [
3759
- "idtype",
3760
- "deviceIdType",
3761
- "advertisingIdType"
3762
- ]) || inferDeviceIdType();
3763
- var limitAdTracking = readBridgeBoolean(source, [
3764
- "is_lat",
3765
- "limitAdTracking",
3766
- "limitedAdTracking",
3767
- "lat"
3768
- ]);
3769
- return _object_spread({}, contentUrl ? {
3770
- contentUrl: contentUrl
3771
- } : {}, deviceId ? {
3772
- deviceId: deviceId
3773
- } : {}, deviceId && deviceIdType ? {
3774
- deviceIdType: deviceIdType
3775
- } : {}, deviceId && limitAdTracking != null ? {
3776
- limitAdTracking: limitAdTracking
3777
- } : {});
3778
- }
3779
- } catch (err) {
3780
- _didIteratorError = true;
3781
- _iteratorError = err;
3782
- } finally{
3783
- try {
3784
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3785
- _iterator.return();
3786
- }
3787
- } finally{
3788
- if (_didIteratorError) {
3789
- throw _iteratorError;
3790
- }
3791
- }
3792
- }
3793
- return {};
3794
- }
3795
- function readBridgeValue(source, keys) {
3796
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3797
- try {
3798
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3799
- var key = _step.value;
3800
- var value = source === null || source === void 0 ? void 0 : source[key];
3801
- if (typeof value === "string" && value) {
3802
- return value;
3803
- }
3804
- if (typeof value === "function") {
3805
- try {
3806
- var result = value.call(source);
3807
- if (typeof result === "string" && result) {
3808
- return result;
3809
- }
3810
- } catch (unused) {}
3811
- }
3812
- }
3813
- } catch (err) {
3814
- _didIteratorError = true;
3815
- _iteratorError = err;
3816
- } finally{
3817
- try {
3818
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3819
- _iterator.return();
3820
- }
3821
- } finally{
3822
- if (_didIteratorError) {
3823
- throw _iteratorError;
3824
- }
3825
- }
3826
- }
3827
- return void 0;
3828
- }
3829
- function readBridgeBoolean(source, keys) {
3830
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3831
- try {
3832
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3833
- var key = _step.value;
3834
- var value = source === null || source === void 0 ? void 0 : source[key];
3835
- var normalized = normalizeBoolean(value);
3836
- if (normalized != null) {
3837
- return normalized;
3838
- }
3839
- if (typeof value === "function") {
3840
- try {
3841
- var result = normalizeBoolean(value.call(source));
3842
- if (result != null) {
3843
- return result;
3844
- }
3845
- } catch (unused) {}
3846
- }
3847
- }
3848
- } catch (err) {
3849
- _didIteratorError = true;
3850
- _iteratorError = err;
3851
- } finally{
3852
- try {
3853
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3854
- _iterator.return();
3855
- }
3856
- } finally{
3857
- if (_didIteratorError) {
3858
- throw _iteratorError;
3859
- }
3860
- }
3861
- }
3862
- return void 0;
3863
- }
3864
- function readStoredDeviceId() {
3865
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3866
- try {
3867
- for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3868
- var key = _step.value;
3869
- var value = readStoredString(key);
3870
- if (value) {
3871
- return value;
3872
- }
3873
- }
3874
- } catch (err) {
3875
- _didIteratorError = true;
3876
- _iteratorError = err;
3877
- } finally{
3878
- try {
3879
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3880
- _iterator.return();
3881
- }
3882
- } finally{
3883
- if (_didIteratorError) {
3884
- throw _iteratorError;
3885
- }
3886
- }
3887
- }
3888
- return void 0;
3889
- }
3890
- function readStoredString(key) {
3891
- if (typeof window === "undefined") {
3892
- return void 0;
3893
- }
3894
- try {
3895
- var _window_localStorage;
3896
- var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
3897
- return value || void 0;
3898
- } catch (unused) {
3899
- return void 0;
3900
- }
3901
- }
3902
- function readStoredLimitAdTracking() {
3903
- return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
3904
- }
3905
- function normalizeBoolean(value) {
3906
- if (typeof value === "boolean") {
3907
- return value;
3908
- }
3909
- if (typeof value === "number") {
3910
- return value === 1;
3911
- }
3912
- if (typeof value === "string") {
3913
- var normalized = value.toLowerCase();
3914
- if (normalized === "1" || normalized === "true" || normalized === "yes") {
3915
- return true;
3916
- }
3917
- if (normalized === "0" || normalized === "false" || normalized === "no") {
3918
- return false;
3919
- }
3920
- }
3921
- return void 0;
3922
- }
3923
- function inferDeviceIdType() {
3924
- if (typeof navigator === "undefined") {
3925
- return void 0;
3926
- }
3927
- var ua = navigator.userAgent;
3928
- if (/Roku/i.test(ua)) return "rida";
3929
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
3930
- if (/AppleTV/i.test(ua)) return "tvOS";
3931
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
3932
- if (/Web0S|webOS|LG/i.test(ua)) return "lgudid";
3933
- if (/Android|Google TV/i.test(ua)) return "aaid";
3934
- return void 0;
3935
- }
3936
- // src/player/VmapManager.ts
3937
- var VmapManager = /*#__PURE__*/ function() {
3938
- function VmapManager(config, video) {
3939
- _class_call_check(this, VmapManager);
4225
+ // src/player/AdConfigManager.ts
4226
+ var AdConfigManager = /*#__PURE__*/ function() {
4227
+ function AdConfigManager(config, video) {
4228
+ _class_call_check(this, AdConfigManager);
3940
4229
  this.vmapBreaks = [];
3941
4230
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
3942
4231
  this.streamCorrelator = generateCorrelator();
@@ -3948,7 +4237,7 @@ var VmapManager = /*#__PURE__*/ function() {
3948
4237
  this.config = config;
3949
4238
  this.video = video;
3950
4239
  }
3951
- _create_class(VmapManager, [
4240
+ _create_class(AdConfigManager, [
3952
4241
  {
3953
4242
  key: "debug",
3954
4243
  get: function get() {
@@ -4010,7 +4299,7 @@ var VmapManager = /*#__PURE__*/ function() {
4010
4299
  ];
4011
4300
  }
4012
4301
  if (this.config.vastTagUrl) {
4013
- this.apiVastTagUrl = this.config.vastTagUrl;
4302
+ this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
4014
4303
  if (this.debug) {
4015
4304
  console.log("[StormcloudVideoPlayer] Using custom VAST tag URL:", this.apiVastTagUrl);
4016
4305
  }
@@ -4050,7 +4339,7 @@ var VmapManager = /*#__PURE__*/ function() {
4050
4339
  data = _state.sent();
4051
4340
  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;
4052
4341
  if (imaPayload) {
4053
- this.apiVastTagUrl = decodeURIComponent(imaPayload);
4342
+ this.apiVastTagUrl = normalizeVastTagUrl(imaPayload);
4054
4343
  if (this.debug) {
4055
4344
  console.log("[StormcloudVideoPlayer] Extracted VAST tag URL from /ads/web:", this.apiVastTagUrl);
4056
4345
  }
@@ -4365,24 +4654,24 @@ var VmapManager = /*#__PURE__*/ function() {
4365
4654
  for(var i = 0; i < count; i++){
4366
4655
  this.adRequestPositionInBreak++;
4367
4656
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
4368
- var ctvSignals = this.config.ctvAdRequest ? resolveCtvVastSignals() : void 0;
4657
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
4369
4658
  var urlWithMacros = applyVastMacros(baseUrl, {
4370
4659
  correlator: generateCorrelator(),
4371
4660
  streamCorrelator: this.streamCorrelator,
4372
4661
  pod: this.podCounter > 0 ? this.podCounter : void 0,
4373
4662
  adPosition: this.adRequestPositionInBreak,
4374
- isCtv: this.config.ctvAdRequest,
4375
- contentUrl: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.contentUrl,
4376
- pageUrl: !this.config.ctvAdRequest && typeof window !== "undefined" ? window.location.href : void 0,
4663
+ isCtv: envSignals.isCtv,
4664
+ contentUrl: envSignals.contentUrl,
4665
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
4377
4666
  adWillPlayMuted: adWillPlayMuted,
4378
4667
  adWillAutoPlay: !!this.config.autoplay,
4379
- appId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appId,
4380
- appName: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appName,
4381
- sessionId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.sessionId,
4382
- deviceId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceId,
4383
- deviceIdType: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceIdType,
4384
- limitAdTracking: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.limitAdTracking,
4385
- deviceTypeHint: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceTypeHint,
4668
+ appId: envSignals.appId,
4669
+ appName: envSignals.appName,
4670
+ sessionId: envSignals.sessionId,
4671
+ deviceId: envSignals.deviceId,
4672
+ deviceIdType: envSignals.deviceIdType,
4673
+ limitAdTracking: envSignals.limitAdTracking,
4674
+ deviceTypeHint: envSignals.deviceTypeHint,
4386
4675
  adTest: this.config.adTest,
4387
4676
  consent: this.consentSignals
4388
4677
  });
@@ -4435,7 +4724,7 @@ var VmapManager = /*#__PURE__*/ function() {
4435
4724
  }
4436
4725
  }
4437
4726
  ]);
4438
- return VmapManager;
4727
+ return AdConfigManager;
4439
4728
  }();
4440
4729
  // src/player/AdTimingService.ts
4441
4730
  var AdTimingService = /*#__PURE__*/ function() {
@@ -6162,7 +6451,7 @@ function resizePlayer(video, adPlayer, debug) {
6162
6451
  }
6163
6452
  // src/player/AdBreakOrchestrator.ts
6164
6453
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
6165
- function AdBreakOrchestrator(host, timing, preloadPool, vmap, cueManager, placeholder) {
6454
+ function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6166
6455
  _class_call_check(this, AdBreakOrchestrator);
6167
6456
  this.inAdBreak = false;
6168
6457
  this.showAds = false;
@@ -6177,7 +6466,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6177
6466
  this.host = host;
6178
6467
  this.timing = timing;
6179
6468
  this.preloadPool = preloadPool;
6180
- this.vmap = vmap;
6469
+ this.adConfig = adConfig;
6181
6470
  this.cueManager = cueManager;
6182
6471
  this.placeholder = placeholder;
6183
6472
  }
@@ -6343,7 +6632,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6343
6632
  }
6344
6633
  this.pendingAdBreak = null;
6345
6634
  this.cueManager.pendingScte35CueKey = void 0;
6346
- this.vmap.podAssignedByPrefetch = false;
6635
+ this.adConfig.podAssignedByPrefetch = false;
6347
6636
  }
6348
6637
  },
6349
6638
  {
@@ -6357,15 +6646,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6357
6646
  return _ts_generator(this, function(_state) {
6358
6647
  switch(_state.label){
6359
6648
  case 0:
6360
- scheduled = this.vmap.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6649
+ scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6361
6650
  if (scheduled) {
6362
- this.vmap.consumedVmapBreakIds.add(this.vmap.getAdBreakKey(scheduled));
6651
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
6363
6652
  }
6364
- tags = this.vmap.selectVastTagsForBreak(scheduled);
6653
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6365
6654
  if (tags && tags.length > 0 && tags[0]) {
6366
6655
  baseVastUrl = tags[0];
6367
- } else if (this.vmap.apiVastTagUrl) {
6368
- baseVastUrl = this.vmap.apiVastTagUrl;
6656
+ } else if (this.adConfig.apiVastTagUrl) {
6657
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6369
6658
  } else {
6370
6659
  this.clearPendingAdBreak();
6371
6660
  return [
@@ -6383,10 +6672,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6383
6672
  this.continuousFetchingActive = true;
6384
6673
  this.isShowingPlaceholder = false;
6385
6674
  this.timing.totalAdRequestsInBreak = 0;
6386
- if (this.vmap.podAssignedByPrefetch) {
6387
- this.vmap.podAssignedByPrefetch = false;
6675
+ if (this.adConfig.podAssignedByPrefetch) {
6676
+ this.adConfig.podAssignedByPrefetch = false;
6388
6677
  } else {
6389
- this.vmap.beginNewAdPod();
6678
+ this.adConfig.beginNewAdPod();
6390
6679
  }
6391
6680
  currentMuted = this.host.video.muted;
6392
6681
  currentVolume = this.host.video.volume;
@@ -7658,7 +7947,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7658
7947
  return _this.adBreak.inAdBreak;
7659
7948
  }
7660
7949
  });
7661
- this.vmap = new VmapManager(this.config, this.video);
7950
+ this.adConfig = new AdConfigManager(this.config, this.video);
7662
7951
  this.timing = new AdTimingService(this.config, this.video, {
7663
7952
  onAdStopTimerFired: function onAdStopTimerFired() {
7664
7953
  return _this.onAdStopTimerFired();
@@ -7738,7 +8027,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7738
8027
  generateVastUrls: function generateVastUrls(base, count) {
7739
8028
  return _this.generateVastUrls(base, count);
7740
8029
  }
7741
- }, this.timing, this.preloadPool, this.vmap, this.cueManager, this.placeholder);
8030
+ }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7742
8031
  }
7743
8032
  _create_class(StormcloudVideoPlayer, [
7744
8033
  {
@@ -7766,7 +8055,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7766
8055
  {
7767
8056
  key: "generateVastUrls",
7768
8057
  value: function generateVastUrls(baseUrl, count) {
7769
- return this.vmap.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8058
+ return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
7770
8059
  }
7771
8060
  },
7772
8061
  {
@@ -7794,7 +8083,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7794
8083
  ]);
7795
8084
  return [
7796
8085
  4,
7797
- this.vmap.fetchAdConfiguration()
8086
+ this.adConfig.fetchAdConfiguration()
7798
8087
  ];
7799
8088
  case 2:
7800
8089
  _state.sent();
@@ -7821,9 +8110,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7821
8110
  continuousPlayback: (_this_config_lowLatencyMode = this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
7822
8111
  }).catch(function() {});
7823
8112
  fetchConsentSignals().then(function(signals) {
7824
- _this.vmap.consentSignals = signals;
8113
+ _this.adConfig.consentSignals = signals;
7825
8114
  }).catch(function() {});
7826
- this.vmap.initializeTracking();
8115
+ this.adConfig.initializeTracking();
7827
8116
  if (!this.hlsEngine.shouldUseNativeHls(function() {
7828
8117
  return _this.getStreamType();
7829
8118
  })) return [
@@ -7858,14 +8147,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7858
8147
  return _async_to_generator(function() {
7859
8148
  var prerollKey, adBehavior;
7860
8149
  return _ts_generator(this, function(_state) {
7861
- if (!this.vmap.isVmapEnabled() && !isLive && this.vmap.vmapBreaks.length === 0 && this.vmap.apiVastTagUrl) {
8150
+ if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
7862
8151
  prerollKey = "synthetic-vod-preroll";
7863
- if (!this.vmap.consumedVmapBreakIds.has(prerollKey)) {
7864
- this.vmap.vmapBreaks = [
8152
+ if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
8153
+ this.adConfig.vmapBreaks = [
7865
8154
  {
7866
8155
  id: prerollKey,
7867
8156
  startTimeMs: 0,
7868
- vastTagUrl: this.vmap.apiVastTagUrl
8157
+ vastTagUrl: this.adConfig.apiVastTagUrl
7869
8158
  }
7870
8159
  ];
7871
8160
  if (this.debug) {
@@ -8132,19 +8421,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8132
8421
  key: "startAdPrefetch",
8133
8422
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
8134
8423
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
8135
- var scheduled = this.vmap.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8136
- var tags = this.vmap.selectVastTagsForBreak(scheduled);
8424
+ var scheduled = this.adConfig.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8425
+ var tags = this.adConfig.selectVastTagsForBreak(scheduled);
8137
8426
  var baseVastUrl;
8138
8427
  if (tags && tags.length > 0 && tags[0]) {
8139
8428
  baseVastUrl = tags[0];
8140
- } else if (this.vmap.apiVastTagUrl) {
8141
- baseVastUrl = this.vmap.apiVastTagUrl;
8429
+ } else if (this.adConfig.apiVastTagUrl) {
8430
+ baseVastUrl = this.adConfig.apiVastTagUrl;
8142
8431
  } else {
8143
8432
  if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
8144
8433
  return;
8145
8434
  }
8146
- this.vmap.beginNewAdPod();
8147
- this.vmap.podAssignedByPrefetch = true;
8435
+ this.adConfig.beginNewAdPod();
8436
+ this.adConfig.podAssignedByPrefetch = true;
8148
8437
  var generatedUrls = this.generateVastUrls(baseVastUrl, 1);
8149
8438
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
8150
8439
  marker: marker
@@ -8179,10 +8468,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8179
8468
  key: "onTimeUpdate",
8180
8469
  value: function onTimeUpdate(currentTimeSec) {
8181
8470
  var _this = this;
8182
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8471
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8183
8472
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8184
8473
  var nowMs = currentTimeSec * 1e3;
8185
- var breakToPlay = this.vmap.findBreakForTime(nowMs);
8474
+ var breakToPlay = this.adConfig.findBreakForTime(nowMs);
8186
8475
  if (breakToPlay) {
8187
8476
  void this.handleVmapAdBreak(breakToPlay, nowMs).catch(function(error) {
8188
8477
  if (_this.debug) {
@@ -8196,11 +8485,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8196
8485
  key: "onVideoEnded",
8197
8486
  value: function onVideoEnded() {
8198
8487
  var _this = this;
8199
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8488
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8200
8489
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8201
8490
  var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
8202
- var postroll = this.vmap.vmapBreaks.find(function(b) {
8203
- return b.startTimeMs === -1 && !_this.vmap.consumedVmapBreakIds.has(_this.vmap.getAdBreakKey(b));
8491
+ var postroll = this.adConfig.vmapBreaks.find(function(b) {
8492
+ return b.startTimeMs === -1 && !_this.adConfig.consumedVmapBreakIds.has(_this.adConfig.getAdBreakKey(b));
8204
8493
  });
8205
8494
  if (postroll) {
8206
8495
  void this.handleVmapAdBreak(postroll, durationMs).catch(function(error) {
@@ -8219,11 +8508,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8219
8508
  return _ts_generator(this, function(_state) {
8220
8509
  switch(_state.label){
8221
8510
  case 0:
8222
- key = this.vmap.getAdBreakKey(adBreak);
8223
- if (this.vmap.consumedVmapBreakIds.has(key)) return [
8511
+ key = this.adConfig.getAdBreakKey(adBreak);
8512
+ if (this.adConfig.consumedVmapBreakIds.has(key)) return [
8224
8513
  2
8225
8514
  ];
8226
- breakStartMs = this.vmap.resolveBreakStartMs(adBreak);
8515
+ breakStartMs = this.adConfig.resolveBreakStartMs(adBreak);
8227
8516
  if (breakStartMs == null) return [
8228
8517
  2
8229
8518
  ];
@@ -8234,8 +8523,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8234
8523
  3,
8235
8524
  4
8236
8525
  ];
8237
- this.vmap.consumedVmapBreakIds.add(key);
8238
- tags = this.vmap.selectVastTagsForBreak(adBreak);
8526
+ this.adConfig.consumedVmapBreakIds.add(key);
8527
+ tags = this.adConfig.selectVastTagsForBreak(adBreak);
8239
8528
  if (!tags || tags.length === 0) return [
8240
8529
  2
8241
8530
  ];
@@ -8427,7 +8716,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8427
8716
  this.video.removeEventListener("emptied", this.emptiedHandler);
8428
8717
  delete this.emptiedHandler;
8429
8718
  }
8430
- this.vmap.destroyTracking();
8719
+ this.adConfig.destroyTracking();
8431
8720
  this.hlsEngine.destroy();
8432
8721
  (_this_adPlayer = this.adPlayer) === null || _this_adPlayer === void 0 ? void 0 : _this_adPlayer.destroy();
8433
8722
  if (this.palPlaybackStarted) {