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
@@ -1247,6 +1247,319 @@ function normalizeBoolean(value) {
1247
1247
  }
1248
1248
  return void 0;
1249
1249
  }
1250
+ // src/utils/contentMetadata.ts
1251
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1252
+ var BRIDGE_KEYS = {
1253
+ channelName: [
1254
+ "channelName",
1255
+ "ct_ch"
1256
+ ],
1257
+ programTitle: [
1258
+ "programTitle",
1259
+ "ct_ti"
1260
+ ],
1261
+ contentNetwork: [
1262
+ "contentNetwork",
1263
+ "ct_ne"
1264
+ ],
1265
+ contentType: [
1266
+ "contentType",
1267
+ "ctt"
1268
+ ],
1269
+ contentCategory: [
1270
+ "contentCategory",
1271
+ "ctc"
1272
+ ],
1273
+ contentGenre: [
1274
+ "contentGenre",
1275
+ "ctgr"
1276
+ ],
1277
+ contentLanguage: [
1278
+ "contentLanguage",
1279
+ "ctlg"
1280
+ ],
1281
+ contentDuration: [
1282
+ "contentDuration",
1283
+ "ctd"
1284
+ ],
1285
+ contentSeason: [
1286
+ "contentSeason",
1287
+ "cts"
1288
+ ],
1289
+ contentEpisode: [
1290
+ "contentEpisode",
1291
+ "cte"
1292
+ ],
1293
+ contentRating: [
1294
+ "contentRating",
1295
+ "ctr",
1296
+ "programRating",
1297
+ "rating"
1298
+ ],
1299
+ contentId: [
1300
+ "contentId",
1301
+ "ctid"
1302
+ ]
1303
+ };
1304
+ function sanitizeContentValue(value) {
1305
+ if (typeof value !== "string") return void 0;
1306
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1307
+ if (!cleaned) return void 0;
1308
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1309
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1310
+ return void 0;
1311
+ }
1312
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1313
+ }
1314
+ function sanitizeContentScalar(value) {
1315
+ if (typeof value === "number") {
1316
+ return Number.isFinite(value) ? String(value) : void 0;
1317
+ }
1318
+ return sanitizeContentValue(value);
1319
+ }
1320
+ function normalizeContentLanguage(value) {
1321
+ var cleaned = sanitizeContentValue(value);
1322
+ if (!cleaned) return void 0;
1323
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1324
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1325
+ }
1326
+ function normalizeContentDuration(value) {
1327
+ var raw = sanitizeContentScalar(value);
1328
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1329
+ var seconds = Number(raw);
1330
+ if (seconds === -1) return -1;
1331
+ return seconds > 0 ? Math.round(seconds) : void 0;
1332
+ }
1333
+ function bridgeSources() {
1334
+ if (typeof window === "undefined") return [];
1335
+ var w = window;
1336
+ return [
1337
+ w.__STORMCLOUD_CTV__,
1338
+ w.__STORMCLOUD_CTV_AD_INFO__,
1339
+ w.stormcloudCtv
1340
+ ].filter(Boolean);
1341
+ }
1342
+ function readBridgeValue2(keys, sanitize) {
1343
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1344
+ try {
1345
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1346
+ var source = _step.value;
1347
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1348
+ try {
1349
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1350
+ var key = _step1.value;
1351
+ var value = void 0;
1352
+ try {
1353
+ value = source === null || source === void 0 ? void 0 : source[key];
1354
+ if (typeof value === "function") value = value.call(source);
1355
+ } catch (unused) {
1356
+ value = void 0;
1357
+ }
1358
+ var sanitized = sanitize(value);
1359
+ if (sanitized != null) return sanitized;
1360
+ }
1361
+ } catch (err) {
1362
+ _didIteratorError1 = true;
1363
+ _iteratorError1 = err;
1364
+ } finally{
1365
+ try {
1366
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1367
+ _iterator1.return();
1368
+ }
1369
+ } finally{
1370
+ if (_didIteratorError1) {
1371
+ throw _iteratorError1;
1372
+ }
1373
+ }
1374
+ }
1375
+ }
1376
+ } catch (err) {
1377
+ _didIteratorError = true;
1378
+ _iteratorError = err;
1379
+ } finally{
1380
+ try {
1381
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1382
+ _iterator.return();
1383
+ }
1384
+ } finally{
1385
+ if (_didIteratorError) {
1386
+ throw _iteratorError;
1387
+ }
1388
+ }
1389
+ }
1390
+ return void 0;
1391
+ }
1392
+ function readBridgeContentValue(keys) {
1393
+ return readBridgeValue2(keys, sanitizeContentValue);
1394
+ }
1395
+ function resolveContentMetadata(config) {
1396
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1397
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1398
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1399
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1400
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1401
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1402
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1403
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1404
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1405
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1406
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1407
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1408
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1409
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1410
+ return _object_spread({}, channelName ? {
1411
+ channelName: channelName
1412
+ } : {}, programTitle ? {
1413
+ programTitle: programTitle
1414
+ } : {}, contentNetwork ? {
1415
+ contentNetwork: contentNetwork
1416
+ } : {}, contentType ? {
1417
+ contentType: contentType
1418
+ } : {}, contentCategory ? {
1419
+ contentCategory: contentCategory
1420
+ } : {}, contentGenre ? {
1421
+ contentGenre: contentGenre
1422
+ } : {}, contentLanguage ? {
1423
+ contentLanguage: contentLanguage
1424
+ } : {}, contentDurationSeconds != null ? {
1425
+ contentDurationSeconds: contentDurationSeconds
1426
+ } : {}, contentSeason ? {
1427
+ contentSeason: contentSeason
1428
+ } : {}, contentEpisode ? {
1429
+ contentEpisode: contentEpisode
1430
+ } : {}, contentRating ? {
1431
+ contentRating: contentRating
1432
+ } : {}, contentId ? {
1433
+ contentId: contentId
1434
+ } : {});
1435
+ }
1436
+ function applyContentMetadataUpdate(target, meta) {
1437
+ var _target_contentDetails;
1438
+ var apply = function apply(key, value) {
1439
+ if (value === void 0) return;
1440
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1441
+ if (clean) target[key] = clean;
1442
+ else delete target[key];
1443
+ };
1444
+ apply("channelName", meta.channelName);
1445
+ apply("programTitle", meta.programTitle);
1446
+ apply("contentNetwork", meta.contentNetwork);
1447
+ if (meta.details === null) delete target.contentDetails;
1448
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1449
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1450
+ if (rating === void 0) return;
1451
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1452
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1453
+ if (cleanRating) details.rating = cleanRating;
1454
+ else delete details.rating;
1455
+ target.contentDetails = details;
1456
+ }
1457
+ function appendMissingContentParams(url, meta) {
1458
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1459
+ try {
1460
+ var parsed = new URL(url);
1461
+ var add = function add(key, value) {
1462
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1463
+ };
1464
+ add("ct_ch", meta.channelName);
1465
+ add("ct_ti", meta.programTitle);
1466
+ add("ct_ne", meta.contentNetwork);
1467
+ return parsed.toString();
1468
+ } catch (unused) {
1469
+ return url;
1470
+ }
1471
+ }
1472
+ // src/utils/partnerSignals.ts
1473
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1474
+ "aaid",
1475
+ "adid",
1476
+ "afai",
1477
+ "idfa",
1478
+ "lgudid",
1479
+ "msai",
1480
+ "rida",
1481
+ "tifa",
1482
+ "tvos",
1483
+ "vaid",
1484
+ "vida"
1485
+ ]);
1486
+ function toIabIfaType(deviceIdType, source) {
1487
+ if (!deviceIdType) return void 0;
1488
+ var type = deviceIdType.trim().toLowerCase();
1489
+ if (source === "generated") return "sessionid";
1490
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1491
+ if (source === "platform") return "dpid";
1492
+ return "ppid";
1493
+ }
1494
+ function playbackMethodCode(autoPlay, muted) {
1495
+ if (autoPlay === false) return 3;
1496
+ if (autoPlay !== true || muted == null) return void 0;
1497
+ return muted ? 2 : 1;
1498
+ }
1499
+ function resolvePlayerSize(video) {
1500
+ var width = video ? video.clientWidth : 0;
1501
+ var height = video ? video.clientHeight : 0;
1502
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1503
+ width = window.innerWidth;
1504
+ height = window.innerHeight;
1505
+ }
1506
+ if (!(width > 0 && height > 0)) return {};
1507
+ return {
1508
+ width: Math.round(width),
1509
+ height: Math.round(height)
1510
+ };
1511
+ }
1512
+ function sanitizeUserId(value) {
1513
+ var cleaned = sanitizeContentValue(value);
1514
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1515
+ return cleaned;
1516
+ }
1517
+ function isPublicIpv4(ip) {
1518
+ var parts = ip.split(".");
1519
+ if (parts.length !== 4) return false;
1520
+ var nums = parts.map(function(p) {
1521
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1522
+ });
1523
+ if (nums.some(function(n) {
1524
+ return !(n >= 0 && n <= 255);
1525
+ })) return false;
1526
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1527
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1528
+ if (a === 100 && b >= 64 && b <= 127) return false;
1529
+ if (a === 169 && b === 254) return false;
1530
+ if (a === 172 && b >= 16 && b <= 31) return false;
1531
+ if (a === 192 && b === 168) return false;
1532
+ return true;
1533
+ }
1534
+ function isPublicIpv6(ip) {
1535
+ var lower = ip.toLowerCase();
1536
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1537
+ if (lower === "::" || lower === "::1") return false;
1538
+ if (/^fe[89ab]/.test(lower)) return false;
1539
+ if (/^f[cd]/.test(lower)) return false;
1540
+ return true;
1541
+ }
1542
+ function sanitizePublicIp(value) {
1543
+ var cleaned = sanitizeContentValue(value);
1544
+ if (!cleaned) return void 0;
1545
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1546
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1547
+ }
1548
+ function resolveUserId(configValue) {
1549
+ var _sanitizeUserId;
1550
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1551
+ "userId",
1552
+ "uid"
1553
+ ], sanitizeUserId);
1554
+ }
1555
+ function resolveClientIp(configValue) {
1556
+ var _sanitizePublicIp;
1557
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1558
+ "ipAddress",
1559
+ "clientIp",
1560
+ "ip"
1561
+ ], sanitizePublicIp);
1562
+ }
1250
1563
  // src/utils/vastMacros.ts
1251
1564
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1252
1565
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1564,7 +1877,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1564
1877
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1565
1878
  "PMND",
1566
1879
  "PMXD",
1567
- "PMAD"
1880
+ "PMAD",
1881
+ "MABD"
1568
1882
  ]);
1569
1883
  function hasScvpMacros(url) {
1570
1884
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1609,6 +1923,8 @@ function resolveScvpMacroValues(ctx) {
1609
1923
  set("RDID", deviceId);
1610
1924
  set("IDTYPE", deviceIdType);
1611
1925
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1926
+ set("IFA", deviceId);
1927
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1612
1928
  }
1613
1929
  set("SID", ctx.sessionId);
1614
1930
  set("DTH", ctx.deviceTypeHint);
@@ -1626,6 +1942,26 @@ function resolveScvpMacroValues(ctx) {
1626
1942
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1627
1943
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1628
1944
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1945
+ set("PLAYER-WIDTH", ctx.playerWidth);
1946
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1947
+ set("TIMESTAMP", ctx.timestamp);
1948
+ set("LIVE", toFlag(ctx.isLive));
1949
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1950
+ set("DEVICE-MAKE", ctx.deviceMake);
1951
+ set("DEVICE-MODEL", ctx.deviceModel);
1952
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
1953
+ set("UA", ctx.userAgent);
1954
+ set("IP", ctx.ipAddress);
1955
+ set("UID", ctx.userId);
1956
+ set("CT-TYPE", ctx.contentType);
1957
+ set("CT-CATEGORY", ctx.contentCategory);
1958
+ set("CT-GENRE", ctx.contentGenre);
1959
+ set("CT-LANGUAGE", ctx.contentLanguage);
1960
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
1961
+ set("CT-SEASON", ctx.contentSeason);
1962
+ set("CT-EPISODE", ctx.contentEpisode);
1963
+ set("CT-RATING", ctx.contentRating);
1964
+ set("CT-ID", ctx.contentId);
1629
1965
  return values;
1630
1966
  }
1631
1967
  var keepNone = function keepNone() {
@@ -2512,9 +2848,30 @@ function detectBrowser() {
2512
2848
  };
2513
2849
  }
2514
2850
  var singleDecoderOverride;
2851
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
2852
+ var learnedSingleDecoder;
2515
2853
  function setSingleDecoderOverride(value) {
2516
2854
  singleDecoderOverride = value;
2517
2855
  }
2856
+ function readLearnedSingleDecoder() {
2857
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
2858
+ try {
2859
+ var _window_localStorage;
2860
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
2861
+ } catch (unused) {
2862
+ learnedSingleDecoder = false;
2863
+ }
2864
+ return learnedSingleDecoder;
2865
+ }
2866
+ function markSingleDecoderLearned() {
2867
+ if (readLearnedSingleDecoder()) return false;
2868
+ learnedSingleDecoder = true;
2869
+ try {
2870
+ var _window_localStorage;
2871
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
2872
+ } catch (unused) {}
2873
+ return true;
2874
+ }
2518
2875
  function requiresMediaPipelineResetAfterAds() {
2519
2876
  var _browser_tizenVersion;
2520
2877
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -2522,6 +2879,7 @@ function requiresMediaPipelineResetAfterAds() {
2522
2879
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2523
2880
  if (typeof globalOverride === "boolean") return globalOverride;
2524
2881
  } catch (unused) {}
2882
+ if (readLearnedSingleDecoder()) return true;
2525
2883
  var browser = detectBrowser();
2526
2884
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2527
2885
  }
@@ -2841,15 +3199,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2841
3199
  values.set("PMND", String(pod.pmnd));
2842
3200
  values.set("PMXD", String(pod.pmxd));
2843
3201
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3202
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2844
3203
  }
2845
3204
  var substituted = substituteScvpMacros(rawUrl, values);
2846
3205
  var finalUrl;
2847
3206
  try {
2848
3207
  var url = new URL(normalizeVastTagUrl(substituted.url));
3208
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3209
+ var setPodParam = function setPodParam(key, value) {
3210
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3211
+ };
2849
3212
  if (pod) {
2850
- url.searchParams.set("pmnd", String(pod.pmnd));
2851
- url.searchParams.set("pmxd", String(pod.pmxd));
2852
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3213
+ setPodParam("pmnd", pod.pmnd);
3214
+ setPodParam("pmxd", pod.pmxd);
3215
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2853
3216
  else url.searchParams.delete("pmad");
2854
3217
  } else {
2855
3218
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2915,7 +3278,9 @@ function validateGamRequestUrl(url, expect) {
2915
3278
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2916
3279
  var params;
2917
3280
  try {
2918
- params = new URL(url).searchParams;
3281
+ var parsed = new URL(url);
3282
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3283
+ params = parsed.searchParams;
2919
3284
  } catch (unused) {
2920
3285
  return problems.concat("URL could not be parsed");
2921
3286
  }
@@ -6336,7 +6701,7 @@ function safeCall2(fn, thisArg) {
6336
6701
  function userAgent() {
6337
6702
  return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6338
6703
  }
6339
- function bridgeSources() {
6704
+ function bridgeSources2() {
6340
6705
  if (typeof window === "undefined") return [];
6341
6706
  var w = window;
6342
6707
  return [
@@ -6348,7 +6713,7 @@ function bridgeSources() {
6348
6713
  function readBridge(keys) {
6349
6714
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6350
6715
  try {
6351
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6716
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6352
6717
  var source = _step.value;
6353
6718
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6354
6719
  try {
@@ -6395,6 +6760,11 @@ function readBridge(keys) {
6395
6760
  }
6396
6761
  return void 0;
6397
6762
  }
6763
+ function makeForCategory(category) {
6764
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6765
+ if (category === "Samsung TV") return "Samsung";
6766
+ return void 0;
6767
+ }
6398
6768
  function normalizeCategory(value) {
6399
6769
  var v = cleanString(value);
6400
6770
  if (!v) return void 0;
@@ -6542,7 +6912,7 @@ function primeDeviceInfo() {
6542
6912
  return primePromise;
6543
6913
  }
6544
6914
  function getDeviceInfo() {
6545
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
6915
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6546
6916
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6547
6917
  if (primePromise && !platformCache) {} else {
6548
6918
  platformCache = platform;
@@ -6565,7 +6935,14 @@ function getDeviceInfo() {
6565
6935
  ]),
6566
6936
  category: normalizeCategory(readBridge([
6567
6937
  "deviceCategory"
6568
- ]))
6938
+ ])),
6939
+ make: readBridge([
6940
+ "deviceMake"
6941
+ ]),
6942
+ hardwareVersion: readBridge([
6943
+ "deviceHardwareVersion",
6944
+ "hardwareVersion"
6945
+ ])
6569
6946
  };
6570
6947
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6571
6948
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -6578,7 +6955,9 @@ function getDeviceInfo() {
6578
6955
  bridge.internalDeviceId,
6579
6956
  bridge.model,
6580
6957
  bridge.firmware,
6581
- bridge.category
6958
+ bridge.category,
6959
+ bridge.make,
6960
+ bridge.hardwareVersion
6582
6961
  ];
6583
6962
  if (bridgeValues.some(function(v) {
6584
6963
  return v !== void 0;
@@ -6586,12 +6965,18 @@ function getDeviceInfo() {
6586
6965
  if (hostDeviceInfo) sources.unshift("host");
6587
6966
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6588
6967
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
6968
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
6969
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6589
6970
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6590
6971
  return _object_spread_props(_object_spread({
6591
6972
  category: category,
6592
6973
  categoryCode: CATEGORY_CODES[category]
6593
- }, model ? {
6974
+ }, make ? {
6975
+ make: make
6976
+ } : {}, model ? {
6594
6977
  model: model
6978
+ } : {}, hardwareVersion ? {
6979
+ hardwareVersion: hardwareVersion
6595
6980
  } : {}, sonifiModel ? {
6596
6981
  sonifiModel: sonifiModel
6597
6982
  } : {}, firmware ? {
@@ -6682,117 +7067,6 @@ function deviceInfoAnalyticsFields(info) {
6682
7067
  terminal_id: info.terminalId
6683
7068
  } : {});
6684
7069
  }
6685
- // src/utils/contentMetadata.ts
6686
- var MAX_CONTENT_VALUE_LENGTH = 128;
6687
- var BRIDGE_KEYS = {
6688
- channelName: [
6689
- "channelName",
6690
- "ct_ch"
6691
- ],
6692
- programTitle: [
6693
- "programTitle",
6694
- "ct_ti"
6695
- ],
6696
- contentNetwork: [
6697
- "contentNetwork",
6698
- "ct_ne"
6699
- ]
6700
- };
6701
- function sanitizeContentValue(value) {
6702
- if (typeof value !== "string") return void 0;
6703
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6704
- if (!cleaned) return void 0;
6705
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6706
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6707
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6708
- }
6709
- function bridgeSources2() {
6710
- if (typeof window === "undefined") return [];
6711
- var w = window;
6712
- return [
6713
- w.__STORMCLOUD_CTV__,
6714
- w.__STORMCLOUD_CTV_AD_INFO__,
6715
- w.stormcloudCtv
6716
- ].filter(Boolean);
6717
- }
6718
- function readBridgeContentValue(keys) {
6719
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6720
- try {
6721
- for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6722
- var source = _step.value;
6723
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6724
- try {
6725
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6726
- var key = _step1.value;
6727
- var value = void 0;
6728
- try {
6729
- value = source === null || source === void 0 ? void 0 : source[key];
6730
- if (typeof value === "function") value = value.call(source);
6731
- } catch (unused) {
6732
- value = void 0;
6733
- }
6734
- var sanitized = sanitizeContentValue(value);
6735
- if (sanitized) return sanitized;
6736
- }
6737
- } catch (err) {
6738
- _didIteratorError1 = true;
6739
- _iteratorError1 = err;
6740
- } finally{
6741
- try {
6742
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6743
- _iterator1.return();
6744
- }
6745
- } finally{
6746
- if (_didIteratorError1) {
6747
- throw _iteratorError1;
6748
- }
6749
- }
6750
- }
6751
- }
6752
- } catch (err) {
6753
- _didIteratorError = true;
6754
- _iteratorError = err;
6755
- } finally{
6756
- try {
6757
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6758
- _iterator.return();
6759
- }
6760
- } finally{
6761
- if (_didIteratorError) {
6762
- throw _iteratorError;
6763
- }
6764
- }
6765
- }
6766
- return void 0;
6767
- }
6768
- function resolveContentMetadata(config) {
6769
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
6770
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
6771
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
6772
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
6773
- return _object_spread({}, channelName ? {
6774
- channelName: channelName
6775
- } : {}, programTitle ? {
6776
- programTitle: programTitle
6777
- } : {}, contentNetwork ? {
6778
- contentNetwork: contentNetwork
6779
- } : {});
6780
- }
6781
- function appendMissingContentParams(url, meta) {
6782
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
6783
- try {
6784
- var parsed = new URL(url);
6785
- var add = function add(key, value) {
6786
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
6787
- };
6788
- add("ct_ch", meta.channelName);
6789
- add("ct_ti", meta.programTitle);
6790
- add("ct_ne", meta.contentNetwork);
6791
- return parsed.toString();
6792
- } catch (unused) {
6793
- return url;
6794
- }
6795
- }
6796
7070
  // src/utils/screenActivity.ts
6797
7071
  var hostStandby = false;
6798
7072
  function setHostStandby(standby) {
@@ -8794,6 +9068,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
8794
9068
  return Scte35CueManager;
8795
9069
  }();
8796
9070
  // src/player/AdConfigManager.ts
9071
+ function isGamAdUrl(rawUrl) {
9072
+ try {
9073
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9074
+ } catch (unused) {
9075
+ return false;
9076
+ }
9077
+ }
8797
9078
  function withDeferredPodParams(rawUrl, deferNonce) {
8798
9079
  try {
8799
9080
  var url = new URL(rawUrl);
@@ -8811,11 +9092,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
8811
9092
  }
8812
9093
  var AdConfigManager = /*#__PURE__*/ function() {
8813
9094
  function AdConfigManager(config, video) {
9095
+ var _this = this;
8814
9096
  _class_call_check(this, AdConfigManager);
8815
9097
  this.vmapBreaks = [];
8816
9098
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
8817
9099
  this.streamCorrelator = generateCorrelator();
8818
9100
  this.consentSignals = {};
9101
+ this.isLiveStream = function() {
9102
+ return !!_this.config.isLiveStream;
9103
+ };
8819
9104
  this.podCounter = 0;
8820
9105
  this.podAssignedByPrefetch = false;
8821
9106
  this.lastHeartbeatTime = 0;
@@ -9266,13 +9551,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
9266
9551
  {
9267
9552
  key: "generatePodVastUrl",
9268
9553
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9554
+ var _content_contentDurationSeconds;
9269
9555
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9270
9556
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9271
9557
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9272
9558
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9273
9559
  });
9274
9560
  var content = resolveContentMetadata(this.config);
9275
- var macroContext = _object_spread_props(_object_spread({
9561
+ var isLive = this.isLiveStream();
9562
+ var device = getDeviceInfo();
9563
+ var playerSize = resolvePlayerSize(this.video);
9564
+ var videoDuration = this.video.duration;
9565
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9566
+ var userId = resolveUserId(this.config.adUserId);
9567
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9568
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9569
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
9276
9570
  correlator: this.viewCorrelator,
9277
9571
  streamCorrelator: this.streamCorrelator,
9278
9572
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -9294,8 +9588,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
9294
9588
  contentNetwork: content.contentNetwork
9295
9589
  } : {}), {
9296
9590
  consent: this.consentSignals,
9297
- palNonce: palNonce.getCurrentNonce() || void 0
9298
- });
9591
+ palNonce: palNonce.getCurrentNonce() || void 0,
9592
+ deviceIdSource: envSignals.deviceIdSource,
9593
+ isLive: isLive
9594
+ }), playerSize.width ? {
9595
+ playerWidth: playerSize.width
9596
+ } : {}, playerSize.height ? {
9597
+ playerHeight: playerSize.height
9598
+ } : {}), {
9599
+ timestamp: String(Date.now())
9600
+ }), device.make ? {
9601
+ deviceMake: device.make
9602
+ } : {}, device.model ? {
9603
+ deviceModel: device.model
9604
+ } : {}, device.hardwareVersion ? {
9605
+ deviceHardwareVersion: device.hardwareVersion
9606
+ } : {}, userAgent2 ? {
9607
+ userAgent: userAgent2
9608
+ } : {}, ipAddress ? {
9609
+ ipAddress: ipAddress
9610
+ } : {}, userId ? {
9611
+ userId: userId
9612
+ } : {}, content.contentType ? {
9613
+ contentType: content.contentType
9614
+ } : {}, content.contentCategory ? {
9615
+ contentCategory: content.contentCategory
9616
+ } : {}, content.contentGenre ? {
9617
+ contentGenre: content.contentGenre
9618
+ } : {}, content.contentLanguage ? {
9619
+ contentLanguage: content.contentLanguage
9620
+ } : {}, contentDurationSeconds != null ? {
9621
+ contentDurationSeconds: contentDurationSeconds
9622
+ } : {}, content.contentSeason ? {
9623
+ contentSeason: content.contentSeason
9624
+ } : {}, content.contentEpisode ? {
9625
+ contentEpisode: content.contentEpisode
9626
+ } : {}, content.contentRating ? {
9627
+ contentRating: content.contentRating
9628
+ } : {}, content.contentId ? {
9629
+ contentId: content.contentId
9630
+ } : {});
9299
9631
  var nonceReady = !!macroContext.palNonce;
9300
9632
  var finalUrl;
9301
9633
  if (hasScvpMacros(baseUrl)) {
@@ -9309,9 +9641,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9309
9641
  } else {
9310
9642
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
9311
9643
  }
9312
- finalUrl = appendMissingContentParams(finalUrl, content);
9313
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9314
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9644
+ if (isGamAdUrl(finalUrl)) {
9645
+ finalUrl = appendMissingContentParams(finalUrl, content);
9646
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9647
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9648
+ }
9315
9649
  }
9316
9650
  if (this.debug) {
9317
9651
  var id = envSignals.deviceId;
@@ -9324,7 +9658,13 @@ var AdConfigManager = /*#__PURE__*/ function() {
9324
9658
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9325
9659
  ct_ch: content.channelName,
9326
9660
  ct_ti: content.programTitle,
9327
- ct_ne: content.contentNetwork
9661
+ ct_ne: content.contentNetwork,
9662
+ rating: content.contentRating,
9663
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9664
+ live: isLive,
9665
+ player: playerSize,
9666
+ make: device.make,
9667
+ model: device.model
9328
9668
  });
9329
9669
  }
9330
9670
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
@@ -11003,6 +11343,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11003
11343
  this.adDetectSentForCurrentBreak = false;
11004
11344
  this.slotState = "IDLE";
11005
11345
  this.unusableResponsesInBreak = 0;
11346
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11006
11347
  this.controllerGeneration = 0;
11007
11348
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11008
11349
  this.breakFunnel = {};
@@ -11099,6 +11440,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11099
11440
  _this.recordRequestDiagnostic(payload);
11100
11441
  });
11101
11442
  adPlayer.on("ad_impression", function() {
11443
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11444
+ 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);
11445
+ if (impressionAdId != null && impressionAdId !== "") {
11446
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11447
+ }
11102
11448
  _this.timing.consecutiveFailures = 0;
11103
11449
  _this.setSlotState("PLAYING", "impression");
11104
11450
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11290,6 +11636,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11290
11636
  this.resetEdgeStateForBreak();
11291
11637
  this.followUpBaseVastUrl = void 0;
11292
11638
  this.unusableResponsesInBreak = 0;
11639
+ this.playedAdIdsInBreak.clear();
11293
11640
  this.timing.totalAdRequestsInBreak = 0;
11294
11641
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11295
11642
  this.noteOpportunity("vmap", breakKey, position);
@@ -11340,6 +11687,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11340
11687
  this.breakSource = "scte35";
11341
11688
  this.followUpBaseVastUrl = baseVastUrl;
11342
11689
  this.unusableResponsesInBreak = 0;
11690
+ this.playedAdIdsInBreak.clear();
11343
11691
  this.resetEdgeStateForBreak();
11344
11692
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11345
11693
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12179,6 +12527,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12179
12527
  var outcome;
12180
12528
  if (message.includes("ad_duration_exceeds_budget")) {
12181
12529
  outcome = "discarded_budget";
12530
+ } else if (message.includes("ad_repeated_in_break")) {
12531
+ outcome = "discarded_duplicate";
12182
12532
  } else if (message.includes("VAST fill rejected")) {
12183
12533
  outcome = "fill_rejected";
12184
12534
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12193,7 +12543,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12193
12543
  outcome = "request_failed";
12194
12544
  }
12195
12545
  this.timing.consecutiveFailures++;
12196
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12546
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12197
12547
  this.unusableResponsesInBreak++;
12198
12548
  }
12199
12549
  if (outcome === "no_fill") {
@@ -12207,7 +12557,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12207
12557
  }) ? diag.dispatchedUrl : vastTagUrl;
12208
12558
  if (this.timing.isTemporaryAdError(error)) {
12209
12559
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12210
- } else if (outcome !== "discarded_budget") {
12560
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12211
12561
  this.timing.failedVastUrls.add(failureKey);
12212
12562
  }
12213
12563
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -12579,7 +12929,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12579
12929
  value: function playSingleAd(vastTagUrl) {
12580
12930
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
12581
12931
  return _async_to_generator(function() {
12582
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12932
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12583
12933
  return _ts_generator(this, function(_state) {
12584
12934
  switch(_state.label){
12585
12935
  case 0:
@@ -12692,6 +13042,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12692
13042
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
12693
13043
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12694
13044
  }, this.analyticsContext).catch(function() {});
13045
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13046
+ 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))) {
13047
+ if (this.debug) {
13048
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13049
+ }
13050
+ this.logOrchestratorFunnel("discarded_duplicate", {
13051
+ adId: String(loadedAdId)
13052
+ });
13053
+ throw new Error("ad_repeated_in_break");
13054
+ }
12695
13055
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
12696
13056
  ;
12697
13057
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -12745,6 +13105,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12745
13105
  this.recordRequestFailure(error, vastTagUrl);
12746
13106
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
12747
13107
  this.recreateAdController("discarded_budget");
13108
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13109
+ this.recreateAdController("discarded_duplicate");
12748
13110
  }
12749
13111
  throw error;
12750
13112
  case 10:
@@ -12818,6 +13180,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12818
13180
  tagAllowsAudio: count("tag_allows_audio"),
12819
13181
  missingImpression: count("vast_missing_impression"),
12820
13182
  discardedBudget: count("discarded_budget"),
13183
+ discardedDuplicate: count("discarded_duplicate"),
12821
13184
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
12822
13185
  mediaRejected: count("media_candidate:rejected"),
12823
13186
  mediaFallbacks: count("media_fallback"),
@@ -12893,6 +13256,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12893
13256
  this.breakSource = void 0;
12894
13257
  this.followUpBaseVastUrl = void 0;
12895
13258
  this.unusableResponsesInBreak = 0;
13259
+ this.playedAdIdsInBreak.clear();
12896
13260
  this.resetEdgeStateForBreak();
12897
13261
  adPlayer.stop().catch(function() {});
12898
13262
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -12993,9 +13357,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12993
13357
  var maxMonitorMs = 45e3;
12994
13358
  var startTime = Date.now();
12995
13359
  var baseline = resumeBaseline;
13360
+ var lastSeenTime = resumeBaseline;
12996
13361
  var recoveries = 0;
12997
13362
  var lastRecoveryAt = 0;
12998
13363
  var video = this.host.video;
13364
+ var onDecodeError = function onDecodeError() {
13365
+ var _video_error;
13366
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13367
+ if (markSingleDecoderLearned() && _this.debug) {
13368
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13369
+ }
13370
+ };
13371
+ video.addEventListener("error", onDecodeError);
12999
13372
  var listenersAttached = false;
13000
13373
  var onMediaEvent;
13001
13374
  var diagEvents = [
@@ -13045,6 +13418,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13045
13418
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13046
13419
  }
13047
13420
  var cleanup = function cleanup() {
13421
+ video.removeEventListener("error", onDecodeError);
13048
13422
  if (listenersAttached && onMediaEvent) {
13049
13423
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13050
13424
  try {
@@ -13075,6 +13449,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13075
13449
  return;
13076
13450
  }
13077
13451
  var currentTime = video.currentTime;
13452
+ if (currentTime + 1 < lastSeenTime) {
13453
+ baseline = currentTime;
13454
+ }
13455
+ lastSeenTime = currentTime;
13078
13456
  var advanced = currentTime > baseline + 0.5;
13079
13457
  var playing = !video.paused && video.readyState >= 3;
13080
13458
  if (advanced && playing) {
@@ -13495,6 +13873,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13495
13873
  return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
13496
13874
  }
13497
13875
  });
13876
+ this.adConfig.isLiveStream = function() {
13877
+ return _this.hlsEngine.isLiveStream;
13878
+ };
13498
13879
  this.adBreak = new AdBreakOrchestrator({
13499
13880
  config: this.config,
13500
13881
  video: this.video,
@@ -13856,16 +14237,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13856
14237
  {
13857
14238
  key: "setContentMetadata",
13858
14239
  value: function setContentMetadata(meta) {
13859
- var _this = this;
13860
- var apply = function apply(key, value) {
13861
- if (value === void 0) return;
13862
- var clean = value === null ? void 0 : sanitizeContentValue(value);
13863
- if (clean) _this.config[key] = clean;
13864
- else delete _this.config[key];
13865
- };
13866
- apply("channelName", meta.channelName);
13867
- apply("programTitle", meta.programTitle);
13868
- apply("contentNetwork", meta.contentNetwork);
14240
+ applyContentMetadataUpdate(this.config, meta);
14241
+ }
14242
+ },
14243
+ {
14244
+ key: "setRequestSignals",
14245
+ value: function setRequestSignals(signals) {
14246
+ if (signals.userId !== void 0) {
14247
+ if (signals.userId) this.config.adUserId = signals.userId;
14248
+ else delete this.config.adUserId;
14249
+ }
14250
+ if (signals.ipAddress !== void 0) {
14251
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14252
+ else delete this.config.clientIpAddress;
14253
+ }
13869
14254
  }
13870
14255
  },
13871
14256
  {
@@ -14581,7 +14966,7 @@ var CRITICAL_PROPS = [
14581
14966
  var CONTROLS_HIDE_DELAY = 3e3;
14582
14967
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
14583
14968
  var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
14584
- 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, [
14969
+ 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, [
14585
14970
  "src",
14586
14971
  "autoplay",
14587
14972
  "muted",
@@ -14615,6 +15000,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
14615
15000
  "programTitle",
14616
15001
  "channelName",
14617
15002
  "contentNetwork",
15003
+ "contentDetails",
15004
+ "adUserId",
15005
+ "clientIpAddress",
14618
15006
  "minRemainingMsToStartAd",
14619
15007
  "minRemainingMsToRequestAd",
14620
15008
  "maxNoFillsPerBreak",
@@ -14823,6 +15211,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
14823
15211
  if (programTitle !== void 0) cfg.programTitle = programTitle;
14824
15212
  if (channelName !== void 0) cfg.channelName = channelName;
14825
15213
  if (contentNetwork !== void 0) cfg.contentNetwork = contentNetwork;
15214
+ if (contentDetails !== void 0) cfg.contentDetails = contentDetails;
15215
+ if (adUserId !== void 0) cfg.adUserId = adUserId;
15216
+ if (clientIpAddress !== void 0) cfg.clientIpAddress = clientIpAddress;
14826
15217
  if (minRemainingMsToStartAd !== void 0) cfg.minRemainingMsToStartAd = minRemainingMsToStartAd;
14827
15218
  if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
14828
15219
  if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;
@@ -14891,6 +15282,25 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
14891
15282
  programTitle,
14892
15283
  contentNetwork
14893
15284
  ]);
15285
+ var contentDetailsKey = contentDetails ? JSON.stringify(contentDetails) : "";
15286
+ (0, import_react.useEffect)(function() {
15287
+ var _playerRef_current;
15288
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15289
+ details: contentDetailsKey ? JSON.parse(contentDetailsKey) : null
15290
+ });
15291
+ }, [
15292
+ contentDetailsKey
15293
+ ]);
15294
+ (0, import_react.useEffect)(function() {
15295
+ var _playerRef_current;
15296
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setRequestSignals({
15297
+ userId: adUserId !== null && adUserId !== void 0 ? adUserId : null,
15298
+ ipAddress: clientIpAddress !== null && clientIpAddress !== void 0 ? clientIpAddress : null
15299
+ });
15300
+ }, [
15301
+ adUserId,
15302
+ clientIpAddress
15303
+ ]);
14894
15304
  var lastAdDeviceIdRef = (0, import_react.useRef)(void 0);
14895
15305
  (0, import_react.useEffect)(function() {
14896
15306
  var player = playerRef.current;