stormcloud-video-player 0.8.80 → 0.8.82

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 (64) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/Player.d.cts +1 -0
  3. package/lib/StormcloudPlayer.cjs +527 -142
  4. package/lib/StormcloudPlayer.cjs.map +1 -1
  5. package/lib/StormcloudPlayer.d.cts +1 -0
  6. package/lib/index.cjs +553 -143
  7. package/lib/index.cjs.map +1 -1
  8. package/lib/index.d.cts +1 -0
  9. package/lib/index.d.ts +33 -5
  10. package/lib/index.js +553 -143
  11. package/lib/index.js.map +1 -1
  12. package/lib/player/AdBreakOrchestrator.cjs +100 -12
  13. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  14. package/lib/player/AdBreakOrchestrator.d.cts +2 -0
  15. package/lib/player/AdConfigManager.cjs +413 -123
  16. package/lib/player/AdConfigManager.cjs.map +1 -1
  17. package/lib/player/AdConfigManager.d.cts +2 -0
  18. package/lib/player/AdTimingService.d.cts +1 -0
  19. package/lib/player/EdgePodRequest.d.cts +1 -0
  20. package/lib/player/FloorLadder.d.cts +1 -0
  21. package/lib/player/HlsEngine.d.cts +1 -0
  22. package/lib/player/OptimizedPodRequest.cjs +17 -5
  23. package/lib/player/OptimizedPodRequest.cjs.map +1 -1
  24. package/lib/player/PlayerControls.d.cts +1 -0
  25. package/lib/player/Scte35CueManager.d.cts +1 -0
  26. package/lib/player/Scte35Parser.d.cts +1 -0
  27. package/lib/player/StormcloudVideoPlayer.cjs +527 -142
  28. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  29. package/lib/player/StormcloudVideoPlayer.d.cts +5 -4
  30. package/lib/player/playerTypes.d.cts +1 -0
  31. package/lib/players/HlsPlayer.cjs +527 -142
  32. package/lib/players/HlsPlayer.cjs.map +1 -1
  33. package/lib/players/HlsPlayer.d.cts +1 -0
  34. package/lib/players/index.cjs +527 -142
  35. package/lib/players/index.cjs.map +1 -1
  36. package/lib/props.d.cts +1 -0
  37. package/lib/sdk/hlsAdPlayer.cjs +13 -0
  38. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  39. package/lib/sdk/hlsAdPlayer.d.cts +1 -0
  40. package/lib/types.d.cts +8 -1
  41. package/lib/ui/StormcloudVideoPlayer.cjs +553 -143
  42. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  43. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
  44. package/lib/utils/__tests__/adSignals.test.cjs +174 -15
  45. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -1
  46. package/lib/utils/browserCompat.cjs +33 -0
  47. package/lib/utils/browserCompat.cjs.map +1 -1
  48. package/lib/utils/browserCompat.d.cts +3 -1
  49. package/lib/utils/contentMetadata.cjs +132 -5
  50. package/lib/utils/contentMetadata.cjs.map +1 -1
  51. package/lib/utils/contentMetadata.d.cts +39 -1
  52. package/lib/utils/deviceInfo.cjs +24 -4
  53. package/lib/utils/deviceInfo.cjs.map +1 -1
  54. package/lib/utils/deviceInfo.d.cts +3 -0
  55. package/lib/utils/partnerSignals.cjs +296 -0
  56. package/lib/utils/partnerSignals.cjs.map +1 -0
  57. package/lib/utils/partnerSignals.d.cts +12 -0
  58. package/lib/utils/tracking.cjs +24 -4
  59. package/lib/utils/tracking.cjs.map +1 -1
  60. package/lib/utils/tracking.d.cts +1 -0
  61. package/lib/utils/vastMacros.cjs +51 -1
  62. package/lib/utils/vastMacros.cjs.map +1 -1
  63. package/lib/utils/vastMacros.d.cts +20 -0
  64. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -1450,6 +1450,319 @@ function normalizeBoolean(value) {
1450
1450
  }
1451
1451
  return void 0;
1452
1452
  }
1453
+ // src/utils/contentMetadata.ts
1454
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1455
+ var BRIDGE_KEYS = {
1456
+ channelName: [
1457
+ "channelName",
1458
+ "ct_ch"
1459
+ ],
1460
+ programTitle: [
1461
+ "programTitle",
1462
+ "ct_ti"
1463
+ ],
1464
+ contentNetwork: [
1465
+ "contentNetwork",
1466
+ "ct_ne"
1467
+ ],
1468
+ contentType: [
1469
+ "contentType",
1470
+ "ctt"
1471
+ ],
1472
+ contentCategory: [
1473
+ "contentCategory",
1474
+ "ctc"
1475
+ ],
1476
+ contentGenre: [
1477
+ "contentGenre",
1478
+ "ctgr"
1479
+ ],
1480
+ contentLanguage: [
1481
+ "contentLanguage",
1482
+ "ctlg"
1483
+ ],
1484
+ contentDuration: [
1485
+ "contentDuration",
1486
+ "ctd"
1487
+ ],
1488
+ contentSeason: [
1489
+ "contentSeason",
1490
+ "cts"
1491
+ ],
1492
+ contentEpisode: [
1493
+ "contentEpisode",
1494
+ "cte"
1495
+ ],
1496
+ contentRating: [
1497
+ "contentRating",
1498
+ "ctr",
1499
+ "programRating",
1500
+ "rating"
1501
+ ],
1502
+ contentId: [
1503
+ "contentId",
1504
+ "ctid"
1505
+ ]
1506
+ };
1507
+ function sanitizeContentValue(value) {
1508
+ if (typeof value !== "string") return void 0;
1509
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1510
+ if (!cleaned) return void 0;
1511
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1512
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1513
+ return void 0;
1514
+ }
1515
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1516
+ }
1517
+ function sanitizeContentScalar(value) {
1518
+ if (typeof value === "number") {
1519
+ return Number.isFinite(value) ? String(value) : void 0;
1520
+ }
1521
+ return sanitizeContentValue(value);
1522
+ }
1523
+ function normalizeContentLanguage(value) {
1524
+ var cleaned = sanitizeContentValue(value);
1525
+ if (!cleaned) return void 0;
1526
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1527
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1528
+ }
1529
+ function normalizeContentDuration(value) {
1530
+ var raw = sanitizeContentScalar(value);
1531
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1532
+ var seconds = Number(raw);
1533
+ if (seconds === -1) return -1;
1534
+ return seconds > 0 ? Math.round(seconds) : void 0;
1535
+ }
1536
+ function bridgeSources() {
1537
+ if (typeof window === "undefined") return [];
1538
+ var w = window;
1539
+ return [
1540
+ w.__STORMCLOUD_CTV__,
1541
+ w.__STORMCLOUD_CTV_AD_INFO__,
1542
+ w.stormcloudCtv
1543
+ ].filter(Boolean);
1544
+ }
1545
+ function readBridgeValue2(keys, sanitize) {
1546
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1547
+ try {
1548
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1549
+ var source = _step.value;
1550
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1551
+ try {
1552
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1553
+ var key = _step1.value;
1554
+ var value = void 0;
1555
+ try {
1556
+ value = source === null || source === void 0 ? void 0 : source[key];
1557
+ if (typeof value === "function") value = value.call(source);
1558
+ } catch (unused) {
1559
+ value = void 0;
1560
+ }
1561
+ var sanitized = sanitize(value);
1562
+ if (sanitized != null) return sanitized;
1563
+ }
1564
+ } catch (err) {
1565
+ _didIteratorError1 = true;
1566
+ _iteratorError1 = err;
1567
+ } finally{
1568
+ try {
1569
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1570
+ _iterator1.return();
1571
+ }
1572
+ } finally{
1573
+ if (_didIteratorError1) {
1574
+ throw _iteratorError1;
1575
+ }
1576
+ }
1577
+ }
1578
+ }
1579
+ } catch (err) {
1580
+ _didIteratorError = true;
1581
+ _iteratorError = err;
1582
+ } finally{
1583
+ try {
1584
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1585
+ _iterator.return();
1586
+ }
1587
+ } finally{
1588
+ if (_didIteratorError) {
1589
+ throw _iteratorError;
1590
+ }
1591
+ }
1592
+ }
1593
+ return void 0;
1594
+ }
1595
+ function readBridgeContentValue(keys) {
1596
+ return readBridgeValue2(keys, sanitizeContentValue);
1597
+ }
1598
+ function resolveContentMetadata(config) {
1599
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1600
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1601
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1602
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1603
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1604
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1605
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1606
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1607
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1608
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1609
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1610
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1611
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1612
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1613
+ return _object_spread({}, channelName ? {
1614
+ channelName: channelName
1615
+ } : {}, programTitle ? {
1616
+ programTitle: programTitle
1617
+ } : {}, contentNetwork ? {
1618
+ contentNetwork: contentNetwork
1619
+ } : {}, contentType ? {
1620
+ contentType: contentType
1621
+ } : {}, contentCategory ? {
1622
+ contentCategory: contentCategory
1623
+ } : {}, contentGenre ? {
1624
+ contentGenre: contentGenre
1625
+ } : {}, contentLanguage ? {
1626
+ contentLanguage: contentLanguage
1627
+ } : {}, contentDurationSeconds != null ? {
1628
+ contentDurationSeconds: contentDurationSeconds
1629
+ } : {}, contentSeason ? {
1630
+ contentSeason: contentSeason
1631
+ } : {}, contentEpisode ? {
1632
+ contentEpisode: contentEpisode
1633
+ } : {}, contentRating ? {
1634
+ contentRating: contentRating
1635
+ } : {}, contentId ? {
1636
+ contentId: contentId
1637
+ } : {});
1638
+ }
1639
+ function applyContentMetadataUpdate(target, meta) {
1640
+ var _target_contentDetails;
1641
+ var apply = function apply(key, value) {
1642
+ if (value === void 0) return;
1643
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1644
+ if (clean) target[key] = clean;
1645
+ else delete target[key];
1646
+ };
1647
+ apply("channelName", meta.channelName);
1648
+ apply("programTitle", meta.programTitle);
1649
+ apply("contentNetwork", meta.contentNetwork);
1650
+ if (meta.details === null) delete target.contentDetails;
1651
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1652
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1653
+ if (rating === void 0) return;
1654
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1655
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1656
+ if (cleanRating) details.rating = cleanRating;
1657
+ else delete details.rating;
1658
+ target.contentDetails = details;
1659
+ }
1660
+ function appendMissingContentParams(url, meta) {
1661
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1662
+ try {
1663
+ var parsed = new URL(url);
1664
+ var add = function add(key, value) {
1665
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1666
+ };
1667
+ add("ct_ch", meta.channelName);
1668
+ add("ct_ti", meta.programTitle);
1669
+ add("ct_ne", meta.contentNetwork);
1670
+ return parsed.toString();
1671
+ } catch (unused) {
1672
+ return url;
1673
+ }
1674
+ }
1675
+ // src/utils/partnerSignals.ts
1676
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1677
+ "aaid",
1678
+ "adid",
1679
+ "afai",
1680
+ "idfa",
1681
+ "lgudid",
1682
+ "msai",
1683
+ "rida",
1684
+ "tifa",
1685
+ "tvos",
1686
+ "vaid",
1687
+ "vida"
1688
+ ]);
1689
+ function toIabIfaType(deviceIdType, source) {
1690
+ if (!deviceIdType) return void 0;
1691
+ var type = deviceIdType.trim().toLowerCase();
1692
+ if (source === "generated") return "sessionid";
1693
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1694
+ if (source === "platform") return "dpid";
1695
+ return "ppid";
1696
+ }
1697
+ function playbackMethodCode(autoPlay, muted) {
1698
+ if (autoPlay === false) return 3;
1699
+ if (autoPlay !== true || muted == null) return void 0;
1700
+ return muted ? 2 : 1;
1701
+ }
1702
+ function resolvePlayerSize(video) {
1703
+ var width = video ? video.clientWidth : 0;
1704
+ var height = video ? video.clientHeight : 0;
1705
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1706
+ width = window.innerWidth;
1707
+ height = window.innerHeight;
1708
+ }
1709
+ if (!(width > 0 && height > 0)) return {};
1710
+ return {
1711
+ width: Math.round(width),
1712
+ height: Math.round(height)
1713
+ };
1714
+ }
1715
+ function sanitizeUserId(value) {
1716
+ var cleaned = sanitizeContentValue(value);
1717
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1718
+ return cleaned;
1719
+ }
1720
+ function isPublicIpv4(ip) {
1721
+ var parts = ip.split(".");
1722
+ if (parts.length !== 4) return false;
1723
+ var nums = parts.map(function(p) {
1724
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1725
+ });
1726
+ if (nums.some(function(n) {
1727
+ return !(n >= 0 && n <= 255);
1728
+ })) return false;
1729
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1730
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1731
+ if (a === 100 && b >= 64 && b <= 127) return false;
1732
+ if (a === 169 && b === 254) return false;
1733
+ if (a === 172 && b >= 16 && b <= 31) return false;
1734
+ if (a === 192 && b === 168) return false;
1735
+ return true;
1736
+ }
1737
+ function isPublicIpv6(ip) {
1738
+ var lower = ip.toLowerCase();
1739
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1740
+ if (lower === "::" || lower === "::1") return false;
1741
+ if (/^fe[89ab]/.test(lower)) return false;
1742
+ if (/^f[cd]/.test(lower)) return false;
1743
+ return true;
1744
+ }
1745
+ function sanitizePublicIp(value) {
1746
+ var cleaned = sanitizeContentValue(value);
1747
+ if (!cleaned) return void 0;
1748
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1749
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1750
+ }
1751
+ function resolveUserId(configValue) {
1752
+ var _sanitizeUserId;
1753
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1754
+ "userId",
1755
+ "uid"
1756
+ ], sanitizeUserId);
1757
+ }
1758
+ function resolveClientIp(configValue) {
1759
+ var _sanitizePublicIp;
1760
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1761
+ "ipAddress",
1762
+ "clientIp",
1763
+ "ip"
1764
+ ], sanitizePublicIp);
1765
+ }
1453
1766
  // src/utils/vastMacros.ts
1454
1767
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1455
1768
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1767,7 +2080,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1767
2080
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1768
2081
  "PMND",
1769
2082
  "PMXD",
1770
- "PMAD"
2083
+ "PMAD",
2084
+ "MABD"
1771
2085
  ]);
1772
2086
  function hasScvpMacros(url) {
1773
2087
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1812,6 +2126,8 @@ function resolveScvpMacroValues(ctx) {
1812
2126
  set("RDID", deviceId);
1813
2127
  set("IDTYPE", deviceIdType);
1814
2128
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
2129
+ set("IFA", deviceId);
2130
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1815
2131
  }
1816
2132
  set("SID", ctx.sessionId);
1817
2133
  set("DTH", ctx.deviceTypeHint);
@@ -1829,6 +2145,26 @@ function resolveScvpMacroValues(ctx) {
1829
2145
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1830
2146
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1831
2147
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
2148
+ set("PLAYER-WIDTH", ctx.playerWidth);
2149
+ set("PLAYER-HEIGHT", ctx.playerHeight);
2150
+ set("TIMESTAMP", ctx.timestamp);
2151
+ set("LIVE", toFlag(ctx.isLive));
2152
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
2153
+ set("DEVICE-MAKE", ctx.deviceMake);
2154
+ set("DEVICE-MODEL", ctx.deviceModel);
2155
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
2156
+ set("UA", ctx.userAgent);
2157
+ set("IP", ctx.ipAddress);
2158
+ set("UID", ctx.userId);
2159
+ set("CT-TYPE", ctx.contentType);
2160
+ set("CT-CATEGORY", ctx.contentCategory);
2161
+ set("CT-GENRE", ctx.contentGenre);
2162
+ set("CT-LANGUAGE", ctx.contentLanguage);
2163
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
2164
+ set("CT-SEASON", ctx.contentSeason);
2165
+ set("CT-EPISODE", ctx.contentEpisode);
2166
+ set("CT-RATING", ctx.contentRating);
2167
+ set("CT-ID", ctx.contentId);
1832
2168
  return values;
1833
2169
  }
1834
2170
  var keepNone = function keepNone() {
@@ -2724,9 +3060,30 @@ function detectBrowser() {
2724
3060
  };
2725
3061
  }
2726
3062
  var singleDecoderOverride;
3063
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
3064
+ var learnedSingleDecoder;
2727
3065
  function setSingleDecoderOverride(value) {
2728
3066
  singleDecoderOverride = value;
2729
3067
  }
3068
+ function readLearnedSingleDecoder() {
3069
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
3070
+ try {
3071
+ var _window_localStorage;
3072
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
3073
+ } catch (unused) {
3074
+ learnedSingleDecoder = false;
3075
+ }
3076
+ return learnedSingleDecoder;
3077
+ }
3078
+ function markSingleDecoderLearned() {
3079
+ if (readLearnedSingleDecoder()) return false;
3080
+ learnedSingleDecoder = true;
3081
+ try {
3082
+ var _window_localStorage;
3083
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
3084
+ } catch (unused) {}
3085
+ return true;
3086
+ }
2730
3087
  function requiresMediaPipelineResetAfterAds() {
2731
3088
  var _browser_tizenVersion;
2732
3089
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -2734,6 +3091,7 @@ function requiresMediaPipelineResetAfterAds() {
2734
3091
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2735
3092
  if (typeof globalOverride === "boolean") return globalOverride;
2736
3093
  } catch (unused) {}
3094
+ if (readLearnedSingleDecoder()) return true;
2737
3095
  var browser = detectBrowser();
2738
3096
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2739
3097
  }
@@ -3076,15 +3434,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
3076
3434
  values.set("PMND", String(pod.pmnd));
3077
3435
  values.set("PMXD", String(pod.pmxd));
3078
3436
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3437
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
3079
3438
  }
3080
3439
  var substituted = substituteScvpMacros(rawUrl, values);
3081
3440
  var finalUrl;
3082
3441
  try {
3083
3442
  var url = new URL(normalizeVastTagUrl(substituted.url));
3443
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3444
+ var setPodParam = function setPodParam(key, value) {
3445
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3446
+ };
3084
3447
  if (pod) {
3085
- url.searchParams.set("pmnd", String(pod.pmnd));
3086
- url.searchParams.set("pmxd", String(pod.pmxd));
3087
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3448
+ setPodParam("pmnd", pod.pmnd);
3449
+ setPodParam("pmxd", pod.pmxd);
3450
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
3088
3451
  else url.searchParams.delete("pmad");
3089
3452
  } else {
3090
3453
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -3150,7 +3513,9 @@ function validateGamRequestUrl(url, expect) {
3150
3513
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
3151
3514
  var params;
3152
3515
  try {
3153
- params = new URL(url).searchParams;
3516
+ var parsed = new URL(url);
3517
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3518
+ params = parsed.searchParams;
3154
3519
  } catch (unused) {
3155
3520
  return problems.concat("URL could not be parsed");
3156
3521
  }
@@ -6571,7 +6936,7 @@ function safeCall2(fn, thisArg) {
6571
6936
  function userAgent() {
6572
6937
  return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6573
6938
  }
6574
- function bridgeSources() {
6939
+ function bridgeSources2() {
6575
6940
  if (typeof window === "undefined") return [];
6576
6941
  var w = window;
6577
6942
  return [
@@ -6583,7 +6948,7 @@ function bridgeSources() {
6583
6948
  function readBridge(keys) {
6584
6949
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6585
6950
  try {
6586
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6951
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6587
6952
  var source = _step.value;
6588
6953
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6589
6954
  try {
@@ -6630,6 +6995,11 @@ function readBridge(keys) {
6630
6995
  }
6631
6996
  return void 0;
6632
6997
  }
6998
+ function makeForCategory(category) {
6999
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
7000
+ if (category === "Samsung TV") return "Samsung";
7001
+ return void 0;
7002
+ }
6633
7003
  function normalizeCategory(value) {
6634
7004
  var v = cleanString(value);
6635
7005
  if (!v) return void 0;
@@ -6777,7 +7147,7 @@ function primeDeviceInfo() {
6777
7147
  return primePromise;
6778
7148
  }
6779
7149
  function getDeviceInfo() {
6780
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
7150
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6781
7151
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6782
7152
  if (primePromise && !platformCache) {} else {
6783
7153
  platformCache = platform;
@@ -6800,7 +7170,14 @@ function getDeviceInfo() {
6800
7170
  ]),
6801
7171
  category: normalizeCategory(readBridge([
6802
7172
  "deviceCategory"
6803
- ]))
7173
+ ])),
7174
+ make: readBridge([
7175
+ "deviceMake"
7176
+ ]),
7177
+ hardwareVersion: readBridge([
7178
+ "deviceHardwareVersion",
7179
+ "hardwareVersion"
7180
+ ])
6804
7181
  };
6805
7182
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6806
7183
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -6813,7 +7190,9 @@ function getDeviceInfo() {
6813
7190
  bridge.internalDeviceId,
6814
7191
  bridge.model,
6815
7192
  bridge.firmware,
6816
- bridge.category
7193
+ bridge.category,
7194
+ bridge.make,
7195
+ bridge.hardwareVersion
6817
7196
  ];
6818
7197
  if (bridgeValues.some(function(v) {
6819
7198
  return v !== void 0;
@@ -6821,12 +7200,18 @@ function getDeviceInfo() {
6821
7200
  if (hostDeviceInfo) sources.unshift("host");
6822
7201
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6823
7202
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
7203
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
7204
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6824
7205
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6825
7206
  return _object_spread_props(_object_spread({
6826
7207
  category: category,
6827
7208
  categoryCode: CATEGORY_CODES[category]
6828
- }, model ? {
7209
+ }, make ? {
7210
+ make: make
7211
+ } : {}, model ? {
6829
7212
  model: model
7213
+ } : {}, hardwareVersion ? {
7214
+ hardwareVersion: hardwareVersion
6830
7215
  } : {}, sonifiModel ? {
6831
7216
  sonifiModel: sonifiModel
6832
7217
  } : {}, firmware ? {
@@ -6917,117 +7302,6 @@ function deviceInfoAnalyticsFields(info) {
6917
7302
  terminal_id: info.terminalId
6918
7303
  } : {});
6919
7304
  }
6920
- // src/utils/contentMetadata.ts
6921
- var MAX_CONTENT_VALUE_LENGTH = 128;
6922
- var BRIDGE_KEYS = {
6923
- channelName: [
6924
- "channelName",
6925
- "ct_ch"
6926
- ],
6927
- programTitle: [
6928
- "programTitle",
6929
- "ct_ti"
6930
- ],
6931
- contentNetwork: [
6932
- "contentNetwork",
6933
- "ct_ne"
6934
- ]
6935
- };
6936
- function sanitizeContentValue(value) {
6937
- if (typeof value !== "string") return void 0;
6938
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6939
- if (!cleaned) return void 0;
6940
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6941
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6942
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6943
- }
6944
- function bridgeSources2() {
6945
- if (typeof window === "undefined") return [];
6946
- var w = window;
6947
- return [
6948
- w.__STORMCLOUD_CTV__,
6949
- w.__STORMCLOUD_CTV_AD_INFO__,
6950
- w.stormcloudCtv
6951
- ].filter(Boolean);
6952
- }
6953
- function readBridgeContentValue(keys) {
6954
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6955
- try {
6956
- for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6957
- var source = _step.value;
6958
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6959
- try {
6960
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6961
- var key = _step1.value;
6962
- var value = void 0;
6963
- try {
6964
- value = source === null || source === void 0 ? void 0 : source[key];
6965
- if (typeof value === "function") value = value.call(source);
6966
- } catch (unused) {
6967
- value = void 0;
6968
- }
6969
- var sanitized = sanitizeContentValue(value);
6970
- if (sanitized) return sanitized;
6971
- }
6972
- } catch (err) {
6973
- _didIteratorError1 = true;
6974
- _iteratorError1 = err;
6975
- } finally{
6976
- try {
6977
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6978
- _iterator1.return();
6979
- }
6980
- } finally{
6981
- if (_didIteratorError1) {
6982
- throw _iteratorError1;
6983
- }
6984
- }
6985
- }
6986
- }
6987
- } catch (err) {
6988
- _didIteratorError = true;
6989
- _iteratorError = err;
6990
- } finally{
6991
- try {
6992
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6993
- _iterator.return();
6994
- }
6995
- } finally{
6996
- if (_didIteratorError) {
6997
- throw _iteratorError;
6998
- }
6999
- }
7000
- }
7001
- return void 0;
7002
- }
7003
- function resolveContentMetadata(config) {
7004
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
7005
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
7006
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
7007
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
7008
- return _object_spread({}, channelName ? {
7009
- channelName: channelName
7010
- } : {}, programTitle ? {
7011
- programTitle: programTitle
7012
- } : {}, contentNetwork ? {
7013
- contentNetwork: contentNetwork
7014
- } : {});
7015
- }
7016
- function appendMissingContentParams(url, meta) {
7017
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
7018
- try {
7019
- var parsed = new URL(url);
7020
- var add = function add(key, value) {
7021
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
7022
- };
7023
- add("ct_ch", meta.channelName);
7024
- add("ct_ti", meta.programTitle);
7025
- add("ct_ne", meta.contentNetwork);
7026
- return parsed.toString();
7027
- } catch (unused) {
7028
- return url;
7029
- }
7030
- }
7031
7305
  // src/utils/screenActivity.ts
7032
7306
  var hostStandby = false;
7033
7307
  function setHostStandby(standby) {
@@ -9035,6 +9309,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
9035
9309
  return Scte35CueManager;
9036
9310
  }();
9037
9311
  // src/player/AdConfigManager.ts
9312
+ function isGamAdUrl(rawUrl) {
9313
+ try {
9314
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9315
+ } catch (unused) {
9316
+ return false;
9317
+ }
9318
+ }
9038
9319
  function withDeferredPodParams(rawUrl, deferNonce) {
9039
9320
  try {
9040
9321
  var url = new URL(rawUrl);
@@ -9052,11 +9333,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
9052
9333
  }
9053
9334
  var AdConfigManager = /*#__PURE__*/ function() {
9054
9335
  function AdConfigManager(config, video) {
9336
+ var _this = this;
9055
9337
  _class_call_check(this, AdConfigManager);
9056
9338
  this.vmapBreaks = [];
9057
9339
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
9058
9340
  this.streamCorrelator = generateCorrelator();
9059
9341
  this.consentSignals = {};
9342
+ this.isLiveStream = function() {
9343
+ return !!_this.config.isLiveStream;
9344
+ };
9060
9345
  this.podCounter = 0;
9061
9346
  this.podAssignedByPrefetch = false;
9062
9347
  this.lastHeartbeatTime = 0;
@@ -9507,13 +9792,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
9507
9792
  {
9508
9793
  key: "generatePodVastUrl",
9509
9794
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9795
+ var _content_contentDurationSeconds;
9510
9796
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9511
9797
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9512
9798
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9513
9799
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9514
9800
  });
9515
9801
  var content = resolveContentMetadata(this.config);
9516
- var macroContext = _object_spread_props(_object_spread({
9802
+ var isLive = this.isLiveStream();
9803
+ var device = getDeviceInfo();
9804
+ var playerSize = resolvePlayerSize(this.video);
9805
+ var videoDuration = this.video.duration;
9806
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9807
+ var userId = resolveUserId(this.config.adUserId);
9808
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9809
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9810
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
9517
9811
  correlator: this.viewCorrelator,
9518
9812
  streamCorrelator: this.streamCorrelator,
9519
9813
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -9535,8 +9829,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
9535
9829
  contentNetwork: content.contentNetwork
9536
9830
  } : {}), {
9537
9831
  consent: this.consentSignals,
9538
- palNonce: palNonce.getCurrentNonce() || void 0
9539
- });
9832
+ palNonce: palNonce.getCurrentNonce() || void 0,
9833
+ deviceIdSource: envSignals.deviceIdSource,
9834
+ isLive: isLive
9835
+ }), playerSize.width ? {
9836
+ playerWidth: playerSize.width
9837
+ } : {}, playerSize.height ? {
9838
+ playerHeight: playerSize.height
9839
+ } : {}), {
9840
+ timestamp: String(Date.now())
9841
+ }), device.make ? {
9842
+ deviceMake: device.make
9843
+ } : {}, device.model ? {
9844
+ deviceModel: device.model
9845
+ } : {}, device.hardwareVersion ? {
9846
+ deviceHardwareVersion: device.hardwareVersion
9847
+ } : {}, userAgent2 ? {
9848
+ userAgent: userAgent2
9849
+ } : {}, ipAddress ? {
9850
+ ipAddress: ipAddress
9851
+ } : {}, userId ? {
9852
+ userId: userId
9853
+ } : {}, content.contentType ? {
9854
+ contentType: content.contentType
9855
+ } : {}, content.contentCategory ? {
9856
+ contentCategory: content.contentCategory
9857
+ } : {}, content.contentGenre ? {
9858
+ contentGenre: content.contentGenre
9859
+ } : {}, content.contentLanguage ? {
9860
+ contentLanguage: content.contentLanguage
9861
+ } : {}, contentDurationSeconds != null ? {
9862
+ contentDurationSeconds: contentDurationSeconds
9863
+ } : {}, content.contentSeason ? {
9864
+ contentSeason: content.contentSeason
9865
+ } : {}, content.contentEpisode ? {
9866
+ contentEpisode: content.contentEpisode
9867
+ } : {}, content.contentRating ? {
9868
+ contentRating: content.contentRating
9869
+ } : {}, content.contentId ? {
9870
+ contentId: content.contentId
9871
+ } : {});
9540
9872
  var nonceReady = !!macroContext.palNonce;
9541
9873
  var finalUrl;
9542
9874
  if (hasScvpMacros(baseUrl)) {
@@ -9550,9 +9882,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9550
9882
  } else {
9551
9883
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
9552
9884
  }
9553
- finalUrl = appendMissingContentParams(finalUrl, content);
9554
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9555
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9885
+ if (isGamAdUrl(finalUrl)) {
9886
+ finalUrl = appendMissingContentParams(finalUrl, content);
9887
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9888
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9889
+ }
9556
9890
  }
9557
9891
  if (this.debug) {
9558
9892
  var id = envSignals.deviceId;
@@ -9565,7 +9899,13 @@ var AdConfigManager = /*#__PURE__*/ function() {
9565
9899
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9566
9900
  ct_ch: content.channelName,
9567
9901
  ct_ti: content.programTitle,
9568
- ct_ne: content.contentNetwork
9902
+ ct_ne: content.contentNetwork,
9903
+ rating: content.contentRating,
9904
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9905
+ live: isLive,
9906
+ player: playerSize,
9907
+ make: device.make,
9908
+ model: device.model
9569
9909
  });
9570
9910
  }
9571
9911
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
@@ -11244,6 +11584,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11244
11584
  this.adDetectSentForCurrentBreak = false;
11245
11585
  this.slotState = "IDLE";
11246
11586
  this.unusableResponsesInBreak = 0;
11587
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11247
11588
  this.controllerGeneration = 0;
11248
11589
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11249
11590
  this.breakFunnel = {};
@@ -11340,6 +11681,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11340
11681
  _this.recordRequestDiagnostic(payload);
11341
11682
  });
11342
11683
  adPlayer.on("ad_impression", function() {
11684
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11685
+ var impressionAdId = (_this_host_getAdPlayer_getLoadedAdId = (_this_host_getAdPlayer = _this.host.getAdPlayer()).getLoadedAdId) === null || _this_host_getAdPlayer_getLoadedAdId === void 0 ? void 0 : _this_host_getAdPlayer_getLoadedAdId.call(_this_host_getAdPlayer);
11686
+ if (impressionAdId != null && impressionAdId !== "") {
11687
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11688
+ }
11343
11689
  _this.timing.consecutiveFailures = 0;
11344
11690
  _this.setSlotState("PLAYING", "impression");
11345
11691
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11531,6 +11877,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11531
11877
  this.resetEdgeStateForBreak();
11532
11878
  this.followUpBaseVastUrl = void 0;
11533
11879
  this.unusableResponsesInBreak = 0;
11880
+ this.playedAdIdsInBreak.clear();
11534
11881
  this.timing.totalAdRequestsInBreak = 0;
11535
11882
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11536
11883
  this.noteOpportunity("vmap", breakKey, position);
@@ -11581,6 +11928,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11581
11928
  this.breakSource = "scte35";
11582
11929
  this.followUpBaseVastUrl = baseVastUrl;
11583
11930
  this.unusableResponsesInBreak = 0;
11931
+ this.playedAdIdsInBreak.clear();
11584
11932
  this.resetEdgeStateForBreak();
11585
11933
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11586
11934
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12420,6 +12768,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12420
12768
  var outcome;
12421
12769
  if (message.includes("ad_duration_exceeds_budget")) {
12422
12770
  outcome = "discarded_budget";
12771
+ } else if (message.includes("ad_repeated_in_break")) {
12772
+ outcome = "discarded_duplicate";
12423
12773
  } else if (message.includes("VAST fill rejected")) {
12424
12774
  outcome = "fill_rejected";
12425
12775
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12434,7 +12784,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12434
12784
  outcome = "request_failed";
12435
12785
  }
12436
12786
  this.timing.consecutiveFailures++;
12437
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12787
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12438
12788
  this.unusableResponsesInBreak++;
12439
12789
  }
12440
12790
  if (outcome === "no_fill") {
@@ -12448,7 +12798,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12448
12798
  }) ? diag.dispatchedUrl : vastTagUrl;
12449
12799
  if (this.timing.isTemporaryAdError(error)) {
12450
12800
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12451
- } else if (outcome !== "discarded_budget") {
12801
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12452
12802
  this.timing.failedVastUrls.add(failureKey);
12453
12803
  }
12454
12804
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -12820,7 +13170,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12820
13170
  value: function playSingleAd(vastTagUrl) {
12821
13171
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
12822
13172
  return _async_to_generator(function() {
12823
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
13173
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12824
13174
  return _ts_generator(this, function(_state) {
12825
13175
  switch(_state.label){
12826
13176
  case 0:
@@ -12933,6 +13283,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12933
13283
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
12934
13284
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12935
13285
  }, this.analyticsContext).catch(function() {});
13286
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13287
+ if (!this.host.config.allowRepeatAdsInBreak && loadedAdId != null && loadedAdId !== "" && ((_ref = (_ap_getPodAdCount = ap.getPodAdCount) === null || _ap_getPodAdCount === void 0 ? void 0 : _ap_getPodAdCount.call(ap)) !== null && _ref !== void 0 ? _ref : 1) <= 1 && this.playedAdIdsInBreak.has(String(loadedAdId))) {
13288
+ if (this.debug) {
13289
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13290
+ }
13291
+ this.logOrchestratorFunnel("discarded_duplicate", {
13292
+ adId: String(loadedAdId)
13293
+ });
13294
+ throw new Error("ad_repeated_in_break");
13295
+ }
12936
13296
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
12937
13297
  ;
12938
13298
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -12986,6 +13346,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12986
13346
  this.recordRequestFailure(error, vastTagUrl);
12987
13347
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
12988
13348
  this.recreateAdController("discarded_budget");
13349
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13350
+ this.recreateAdController("discarded_duplicate");
12989
13351
  }
12990
13352
  throw error;
12991
13353
  case 10:
@@ -13059,6 +13421,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13059
13421
  tagAllowsAudio: count("tag_allows_audio"),
13060
13422
  missingImpression: count("vast_missing_impression"),
13061
13423
  discardedBudget: count("discarded_budget"),
13424
+ discardedDuplicate: count("discarded_duplicate"),
13062
13425
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
13063
13426
  mediaRejected: count("media_candidate:rejected"),
13064
13427
  mediaFallbacks: count("media_fallback"),
@@ -13134,6 +13497,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13134
13497
  this.breakSource = void 0;
13135
13498
  this.followUpBaseVastUrl = void 0;
13136
13499
  this.unusableResponsesInBreak = 0;
13500
+ this.playedAdIdsInBreak.clear();
13137
13501
  this.resetEdgeStateForBreak();
13138
13502
  adPlayer.stop().catch(function() {});
13139
13503
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -13234,9 +13598,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13234
13598
  var maxMonitorMs = 45e3;
13235
13599
  var startTime = Date.now();
13236
13600
  var baseline = resumeBaseline;
13601
+ var lastSeenTime = resumeBaseline;
13237
13602
  var recoveries = 0;
13238
13603
  var lastRecoveryAt = 0;
13239
13604
  var video = this.host.video;
13605
+ var onDecodeError = function onDecodeError() {
13606
+ var _video_error;
13607
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13608
+ if (markSingleDecoderLearned() && _this.debug) {
13609
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13610
+ }
13611
+ };
13612
+ video.addEventListener("error", onDecodeError);
13240
13613
  var listenersAttached = false;
13241
13614
  var onMediaEvent;
13242
13615
  var diagEvents = [
@@ -13286,6 +13659,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13286
13659
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13287
13660
  }
13288
13661
  var cleanup = function cleanup() {
13662
+ video.removeEventListener("error", onDecodeError);
13289
13663
  if (listenersAttached && onMediaEvent) {
13290
13664
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13291
13665
  try {
@@ -13316,6 +13690,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13316
13690
  return;
13317
13691
  }
13318
13692
  var currentTime = video.currentTime;
13693
+ if (currentTime + 1 < lastSeenTime) {
13694
+ baseline = currentTime;
13695
+ }
13696
+ lastSeenTime = currentTime;
13319
13697
  var advanced = currentTime > baseline + 0.5;
13320
13698
  var playing = !video.paused && video.readyState >= 3;
13321
13699
  if (advanced && playing) {
@@ -13736,6 +14114,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13736
14114
  return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
13737
14115
  }
13738
14116
  });
14117
+ this.adConfig.isLiveStream = function() {
14118
+ return _this.hlsEngine.isLiveStream;
14119
+ };
13739
14120
  this.adBreak = new AdBreakOrchestrator({
13740
14121
  config: this.config,
13741
14122
  video: this.video,
@@ -14097,16 +14478,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14097
14478
  {
14098
14479
  key: "setContentMetadata",
14099
14480
  value: function setContentMetadata(meta) {
14100
- var _this = this;
14101
- var apply = function apply(key, value) {
14102
- if (value === void 0) return;
14103
- var clean = value === null ? void 0 : sanitizeContentValue(value);
14104
- if (clean) _this.config[key] = clean;
14105
- else delete _this.config[key];
14106
- };
14107
- apply("channelName", meta.channelName);
14108
- apply("programTitle", meta.programTitle);
14109
- apply("contentNetwork", meta.contentNetwork);
14481
+ applyContentMetadataUpdate(this.config, meta);
14482
+ }
14483
+ },
14484
+ {
14485
+ key: "setRequestSignals",
14486
+ value: function setRequestSignals(signals) {
14487
+ if (signals.userId !== void 0) {
14488
+ if (signals.userId) this.config.adUserId = signals.userId;
14489
+ else delete this.config.adUserId;
14490
+ }
14491
+ if (signals.ipAddress !== void 0) {
14492
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14493
+ else delete this.config.clientIpAddress;
14494
+ }
14110
14495
  }
14111
14496
  },
14112
14497
  {
@@ -14822,7 +15207,7 @@ var CRITICAL_PROPS = [
14822
15207
  var CONTROLS_HIDE_DELAY = 3e3;
14823
15208
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
14824
15209
  var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
14825
- var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, isLiveStream = props.isLiveStream, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastTagUrl = props.vastTagUrl, isVmap = props.isVmap, vmapUrl = props.vmapUrl, minSegmentsBeforePlay = props.minSegmentsBeforePlay, ctvAdRequest = props.ctvAdRequest, programTitle = props.programTitle, channelName = props.channelName, contentNetwork = props.contentNetwork, minRemainingMsToStartAd = props.minRemainingMsToStartAd, minRemainingMsToRequestAd = props.minRemainingMsToRequestAd, maxNoFillsPerBreak = props.maxNoFillsPerBreak, maxAdBreakExtensionMs = props.maxAdBreakExtensionMs, adDeviceId = props.adDeviceId, adDeviceIdType = props.adDeviceIdType, adLimitAdTracking = props.adLimitAdTracking, fallbackDeviceIdMaxAgeMs = props.fallbackDeviceIdMaxAgeMs, sessionIdMaxAgeMs = props.sessionIdMaxAgeMs, palIconsSupported = props.palIconsSupported, palSupportedApiFrameworks = props.palSupportedApiFrameworks, palContinuousPlayback = props.palContinuousPlayback, palNonceMaxAgeMs = props.palNonceMaxAgeMs, forceSingleDecoderMode = props.forceSingleDecoderMode, deviceInfo = props.deviceInfo, sendDeviceKeyValues = props.sendDeviceKeyValues, sendDeviceInfoToAnalytics = props.sendDeviceInfoToAnalytics, restVideoAttrs = _object_without_properties(props, [
15210
+ var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, isLiveStream = props.isLiveStream, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastTagUrl = props.vastTagUrl, isVmap = props.isVmap, vmapUrl = props.vmapUrl, minSegmentsBeforePlay = props.minSegmentsBeforePlay, ctvAdRequest = props.ctvAdRequest, programTitle = props.programTitle, channelName = props.channelName, contentNetwork = props.contentNetwork, contentDetails = props.contentDetails, adUserId = props.adUserId, clientIpAddress = props.clientIpAddress, minRemainingMsToStartAd = props.minRemainingMsToStartAd, minRemainingMsToRequestAd = props.minRemainingMsToRequestAd, maxNoFillsPerBreak = props.maxNoFillsPerBreak, maxAdBreakExtensionMs = props.maxAdBreakExtensionMs, adDeviceId = props.adDeviceId, adDeviceIdType = props.adDeviceIdType, adLimitAdTracking = props.adLimitAdTracking, fallbackDeviceIdMaxAgeMs = props.fallbackDeviceIdMaxAgeMs, sessionIdMaxAgeMs = props.sessionIdMaxAgeMs, palIconsSupported = props.palIconsSupported, palSupportedApiFrameworks = props.palSupportedApiFrameworks, palContinuousPlayback = props.palContinuousPlayback, palNonceMaxAgeMs = props.palNonceMaxAgeMs, forceSingleDecoderMode = props.forceSingleDecoderMode, deviceInfo = props.deviceInfo, sendDeviceKeyValues = props.sendDeviceKeyValues, sendDeviceInfoToAnalytics = props.sendDeviceInfoToAnalytics, restVideoAttrs = _object_without_properties(props, [
14826
15211
  "src",
14827
15212
  "autoplay",
14828
15213
  "muted",
@@ -14856,6 +15241,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
14856
15241
  "programTitle",
14857
15242
  "channelName",
14858
15243
  "contentNetwork",
15244
+ "contentDetails",
15245
+ "adUserId",
15246
+ "clientIpAddress",
14859
15247
  "minRemainingMsToStartAd",
14860
15248
  "minRemainingMsToRequestAd",
14861
15249
  "maxNoFillsPerBreak",
@@ -15064,6 +15452,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
15064
15452
  if (programTitle !== void 0) cfg.programTitle = programTitle;
15065
15453
  if (channelName !== void 0) cfg.channelName = channelName;
15066
15454
  if (contentNetwork !== void 0) cfg.contentNetwork = contentNetwork;
15455
+ if (contentDetails !== void 0) cfg.contentDetails = contentDetails;
15456
+ if (adUserId !== void 0) cfg.adUserId = adUserId;
15457
+ if (clientIpAddress !== void 0) cfg.clientIpAddress = clientIpAddress;
15067
15458
  if (minRemainingMsToStartAd !== void 0) cfg.minRemainingMsToStartAd = minRemainingMsToStartAd;
15068
15459
  if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
15069
15460
  if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;
@@ -15132,6 +15523,25 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
15132
15523
  programTitle,
15133
15524
  contentNetwork
15134
15525
  ]);
15526
+ var contentDetailsKey = contentDetails ? JSON.stringify(contentDetails) : "";
15527
+ (0, import_react.useEffect)(function() {
15528
+ var _playerRef_current;
15529
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15530
+ details: contentDetailsKey ? JSON.parse(contentDetailsKey) : null
15531
+ });
15532
+ }, [
15533
+ contentDetailsKey
15534
+ ]);
15535
+ (0, import_react.useEffect)(function() {
15536
+ var _playerRef_current;
15537
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setRequestSignals({
15538
+ userId: adUserId !== null && adUserId !== void 0 ? adUserId : null,
15539
+ ipAddress: clientIpAddress !== null && clientIpAddress !== void 0 ? clientIpAddress : null
15540
+ });
15541
+ }, [
15542
+ adUserId,
15543
+ clientIpAddress
15544
+ ]);
15135
15545
  var lastAdDeviceIdRef = (0, import_react.useRef)(void 0);
15136
15546
  (0, import_react.useEffect)(function() {
15137
15547
  var player = playerRef.current;