stormcloud-video-player 0.8.78 → 0.8.80

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 (76) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/Player.cjs +6 -0
  3. package/lib/Player.cjs.map +1 -1
  4. package/lib/Player.d.cts +2 -0
  5. package/lib/StormcloudPlayer.cjs +1143 -160
  6. package/lib/StormcloudPlayer.cjs.map +1 -1
  7. package/lib/StormcloudPlayer.d.cts +2 -0
  8. package/lib/index.cjs +1206 -162
  9. package/lib/index.cjs.map +1 -1
  10. package/lib/index.d.cts +2 -0
  11. package/lib/index.d.ts +64 -2
  12. package/lib/index.js +1206 -162
  13. package/lib/index.js.map +1 -1
  14. package/lib/player/AdBreakOrchestrator.cjs +424 -84
  15. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  16. package/lib/player/AdConfigManager.cjs +738 -94
  17. package/lib/player/AdConfigManager.cjs.map +1 -1
  18. package/lib/player/AdTimingService.cjs +0 -9
  19. package/lib/player/AdTimingService.cjs.map +1 -1
  20. package/lib/player/FloorLadder.cjs +3 -0
  21. package/lib/player/FloorLadder.cjs.map +1 -1
  22. package/lib/player/HlsEngine.cjs +7 -1
  23. package/lib/player/HlsEngine.cjs.map +1 -1
  24. package/lib/player/HlsEngine.d.cts +1 -0
  25. package/lib/player/OptimizedPodRequest.cjs +4 -1
  26. package/lib/player/OptimizedPodRequest.cjs.map +1 -1
  27. package/lib/player/OptimizedPodRequest.d.cts +1 -1
  28. package/lib/player/StormcloudVideoPlayer.cjs +1143 -160
  29. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  30. package/lib/player/StormcloudVideoPlayer.d.cts +18 -1
  31. package/lib/players/HlsPlayer.cjs +1143 -160
  32. package/lib/players/HlsPlayer.cjs.map +1 -1
  33. package/lib/players/index.cjs +1143 -160
  34. package/lib/players/index.cjs.map +1 -1
  35. package/lib/props.cjs +6 -0
  36. package/lib/props.cjs.map +1 -1
  37. package/lib/props.d.cts +2 -0
  38. package/lib/sdk/hlsAdPlayer.cjs +32 -3
  39. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  40. package/lib/sdk/pal.cjs +10 -3
  41. package/lib/sdk/pal.cjs.map +1 -1
  42. package/lib/sdk/pal.d.cts +3 -0
  43. package/lib/types.d.cts +24 -1
  44. package/lib/ui/StormcloudVideoPlayer.cjs +1206 -162
  45. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  46. package/lib/ui/StormcloudVideoPlayer.d.cts +2 -0
  47. package/lib/utils/__tests__/adSignals.test.cjs +25662 -0
  48. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -0
  49. package/lib/utils/__tests__/adSignals.test.d.cts +2 -0
  50. package/lib/utils/adIdentity.cjs +421 -0
  51. package/lib/utils/adIdentity.cjs.map +1 -0
  52. package/lib/utils/adIdentity.d.cts +30 -0
  53. package/lib/utils/browserCompat.cjs +13 -0
  54. package/lib/utils/browserCompat.cjs.map +1 -1
  55. package/lib/utils/browserCompat.d.cts +2 -1
  56. package/lib/utils/contentMetadata.cjs +208 -0
  57. package/lib/utils/contentMetadata.cjs.map +1 -0
  58. package/lib/utils/contentMetadata.d.cts +15 -0
  59. package/lib/utils/ctvVastSignals.cjs +250 -181
  60. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  61. package/lib/utils/deviceInfo.cjs +678 -0
  62. package/lib/utils/deviceInfo.cjs.map +1 -0
  63. package/lib/utils/deviceInfo.d.cts +43 -0
  64. package/lib/utils/screenActivity.cjs +125 -0
  65. package/lib/utils/screenActivity.cjs.map +1 -0
  66. package/lib/utils/screenActivity.d.cts +5 -0
  67. package/lib/utils/tracking.cjs +391 -57
  68. package/lib/utils/tracking.cjs.map +1 -1
  69. package/lib/utils/tracking.d.cts +1 -1
  70. package/lib/utils/vastEnvironmentSignals.cjs +255 -85
  71. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  72. package/lib/utils/vastEnvironmentSignals.d.cts +8 -2
  73. package/lib/utils/vastMacros.cjs +7 -0
  74. package/lib/utils/vastMacros.cjs.map +1 -1
  75. package/lib/utils/vastMacros.d.cts +1 -0
  76. package/package.json +1 -1
@@ -344,6 +344,50 @@ __export(AdBreakOrchestrator_exports, {
344
344
  }
345
345
  });
346
346
  module.exports = __toCommonJS(AdBreakOrchestrator_exports);
347
+ // src/utils/adIdentity.ts
348
+ var MAX_SESSION_ID_AGE_MS = 6 * 60 * 60 * 1e3;
349
+ var DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
350
+ var ZEROED_IDS = /* @__PURE__ */ new Set([
351
+ "00000000-0000-0000-0000-000000000000",
352
+ "38400000-8cf0-11bd-b23e-10b96e40000d"
353
+ ]);
354
+ var lgUdidResult;
355
+ function isUsableAdId(value) {
356
+ if (typeof value !== "string") return false;
357
+ var t = value.trim();
358
+ if (!t) return false;
359
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(t)) return false;
360
+ if (/^(unknown|null|undefined|none|n\/a)$/i.test(t)) return false;
361
+ return !ZEROED_IDS.has(t.toLowerCase());
362
+ }
363
+ function isZeroedAdId(value) {
364
+ return typeof value === "string" && ZEROED_IDS.has(value.trim().toLowerCase());
365
+ }
366
+ function readSamsungTifa() {
367
+ try {
368
+ var _window_webapis;
369
+ var adinfo = typeof window !== "undefined" ? (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo : void 0;
370
+ if (!adinfo) return void 0;
371
+ var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
372
+ var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
373
+ if (isZeroedAdId(tifa)) return {
374
+ deviceIdType: "tifa",
375
+ limitAdTracking: true
376
+ };
377
+ if (!isUsableAdId(tifa)) return void 0;
378
+ return _object_spread({
379
+ deviceId: tifa.trim(),
380
+ deviceIdType: "tifa"
381
+ }, typeof lat === "boolean" ? {
382
+ limitAdTracking: lat
383
+ } : {});
384
+ } catch (unused) {
385
+ return void 0;
386
+ }
387
+ }
388
+ function readCachedLgUdid() {
389
+ return lgUdidResult ? _object_spread({}, lgUdidResult) : void 0;
390
+ }
347
391
  // src/utils/vastEnvironmentSignals.ts
348
392
  var PLAYER_ID_STORAGE_KEY = "stormcloud.player.id";
349
393
  var DEVICE_ID_STORAGE_KEYS = [
@@ -384,26 +428,12 @@ var DEVICE_TYPE_HINT_ALIASES = {
384
428
  stb: DEVICE_TYPE_HINT.SET_TOP_BOX,
385
429
  settopbox: DEVICE_TYPE_HINT.SET_TOP_BOX
386
430
  };
387
- function inferDeviceIdType() {
388
- if (typeof navigator === "undefined") {
389
- return void 0;
390
- }
391
- var ua = navigator.userAgent;
392
- if (/Roku/i.test(ua)) return "rida";
393
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
394
- if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
395
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
396
- if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
397
- if (/Android|Google TV/i.test(ua)) return "aaid";
398
- if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
399
- return void 0;
400
- }
401
431
  function resolveNativeDeviceId() {
402
432
  var includeStored = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
403
433
  var bridgeSignals = readNativeBridgeSignals();
404
434
  var platformDevice = readPlatformNativeDeviceId();
405
435
  var deviceId = bridgeSignals.deviceId || (includeStored ? readStoredDeviceId() : void 0) || platformDevice.deviceId;
406
- if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId(deviceId)) {
436
+ if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId2(deviceId)) {
407
437
  return void 0;
408
438
  }
409
439
  return deviceId;
@@ -507,44 +537,10 @@ function performanceNow() {
507
537
  }
508
538
  function readPlatformNativeDeviceId() {
509
539
  if (typeof window === "undefined") return {};
510
- try {
511
- var _window_webapis;
512
- var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
513
- if (adinfo) {
514
- var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
515
- if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
516
- var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
517
- return _object_spread({
518
- deviceId: tifa,
519
- deviceIdType: "tifa"
520
- }, typeof lat === "boolean" ? {
521
- limitAdTracking: lat
522
- } : {});
523
- }
524
- }
525
- } catch (unused) {}
526
- try {
527
- var webOSDev = window.webOSDev;
528
- if (webOSDev) {
529
- var _webOSDev_lgudid;
530
- var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
531
- if (typeof lgudid === "string" && lgudid) {
532
- if (isZeroedAdId(lgudid)) {
533
- return {
534
- deviceIdType: "lgudid",
535
- limitAdTracking: true
536
- };
537
- }
538
- if (!isMacroPlaceholder(lgudid)) {
539
- return {
540
- deviceId: lgudid,
541
- deviceIdType: "lgudid",
542
- limitAdTracking: false
543
- };
544
- }
545
- }
546
- }
547
- } catch (unused) {}
540
+ var tifa = readSamsungTifa();
541
+ if (tifa) return tifa;
542
+ var lgudid = readCachedLgUdid();
543
+ if (lgudid) return lgudid;
548
544
  try {
549
545
  var roku = window.Roku;
550
546
  if (roku) {
@@ -568,7 +564,7 @@ function isMacroPlaceholder(value) {
568
564
  var t = value.trim();
569
565
  return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
570
566
  }
571
- function isZeroedAdId(value) {
567
+ function isZeroedAdId2(value) {
572
568
  return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
573
569
  }
574
570
  function readNativeBridgeSignals() {
@@ -612,7 +608,7 @@ function readNativeBridgeSignals() {
612
608
  "deviceIdType",
613
609
  "advertisingIdType",
614
610
  "idType"
615
- ]) || inferDeviceIdType();
611
+ ]) || void 0;
616
612
  var limitAdTracking = readBridgeBoolean(source, [
617
613
  "is_lat",
618
614
  "limitAdTracking",
@@ -1293,23 +1289,309 @@ function ingestPlayerTracking(licenseKey, channel, body) {
1293
1289
  });
1294
1290
  })();
1295
1291
  }
1292
+ // src/utils/deviceInfo.ts
1293
+ var CATEGORY_CODES = {
1294
+ "LG TV": "lg_tv",
1295
+ "LG Set-Top Box": "lg_stb",
1296
+ "Samsung TV": "samsung_tv",
1297
+ Other: "other"
1298
+ };
1299
+ var DEVICE_CATEGORIES = [
1300
+ "LG TV",
1301
+ "LG Set-Top Box",
1302
+ "Samsung TV",
1303
+ "Other"
1304
+ ];
1305
+ var hostDeviceInfo;
1306
+ var lgDeviceInfo;
1307
+ var platformCache;
1308
+ var primePromise;
1309
+ function cleanString(value) {
1310
+ var maxLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 128;
1311
+ if (typeof value !== "string") return void 0;
1312
+ var t = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1313
+ if (!t || /^(unknown|null|undefined|none|n\/a|-|0)$/i.test(t)) return void 0;
1314
+ return t.length > maxLength ? t.slice(0, maxLength) : t;
1315
+ }
1316
+ function safeCall(fn, thisArg) {
1317
+ if (typeof fn !== "function") return void 0;
1318
+ try {
1319
+ return fn.call(thisArg);
1320
+ } catch (unused) {
1321
+ return void 0;
1322
+ }
1323
+ }
1324
+ function userAgent() {
1325
+ return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
1326
+ }
1327
+ function bridgeSources() {
1328
+ if (typeof window === "undefined") return [];
1329
+ var w = window;
1330
+ return [
1331
+ w.__STORMCLOUD_CTV__,
1332
+ w.__STORMCLOUD_CTV_AD_INFO__,
1333
+ w.stormcloudCtv
1334
+ ].filter(Boolean);
1335
+ }
1336
+ function readBridge(keys) {
1337
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1338
+ try {
1339
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1340
+ var source = _step.value;
1341
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1342
+ try {
1343
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1344
+ var key = _step1.value;
1345
+ var value = void 0;
1346
+ try {
1347
+ value = source === null || source === void 0 ? void 0 : source[key];
1348
+ if (typeof value === "function") value = value.call(source);
1349
+ } catch (unused) {
1350
+ value = void 0;
1351
+ }
1352
+ var clean = cleanString(value);
1353
+ if (clean) return clean;
1354
+ }
1355
+ } catch (err) {
1356
+ _didIteratorError1 = true;
1357
+ _iteratorError1 = err;
1358
+ } finally{
1359
+ try {
1360
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1361
+ _iterator1.return();
1362
+ }
1363
+ } finally{
1364
+ if (_didIteratorError1) {
1365
+ throw _iteratorError1;
1366
+ }
1367
+ }
1368
+ }
1369
+ }
1370
+ } catch (err) {
1371
+ _didIteratorError = true;
1372
+ _iteratorError = err;
1373
+ } finally{
1374
+ try {
1375
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1376
+ _iterator.return();
1377
+ }
1378
+ } finally{
1379
+ if (_didIteratorError) {
1380
+ throw _iteratorError;
1381
+ }
1382
+ }
1383
+ }
1384
+ return void 0;
1385
+ }
1386
+ function normalizeCategory(value) {
1387
+ var v = cleanString(value);
1388
+ if (!v) return void 0;
1389
+ var exact = DEVICE_CATEGORIES.find(function(c) {
1390
+ return c.toLowerCase() === v.toLowerCase();
1391
+ });
1392
+ if (exact) return exact;
1393
+ var code = v.toLowerCase().replace(/[\s-]+/g, "_");
1394
+ var byCode = Object.keys(CATEGORY_CODES).find(function(c) {
1395
+ return CATEGORY_CODES[c] === code;
1396
+ });
1397
+ return byCode;
1398
+ }
1399
+ function parseUserAgentDeviceInfo(ua) {
1400
+ var sources = [];
1401
+ var out = {
1402
+ platform: "other",
1403
+ sources: sources
1404
+ };
1405
+ var chrome = ua.match(/(?:Chrome|PCBR)\/(\d+)\./) || ua.match(/\s(\d{2,3})\.\d+\.\d+\.\d+\/[\d.]+\s+TV\b/);
1406
+ if (chrome && chrome[1]) out.browserMajorVersion = parseInt(chrome[1], 10);
1407
+ if (/Web0S|webOS/i.test(ua)) {
1408
+ out.platform = "webos";
1409
+ var lg = ua.match(/LGE\s*;\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*;\s*(\d{2}\.\d{2}\.\d{2})/);
1410
+ if (lg && lg[1] && lg[2]) {
1411
+ out.model = lg[1];
1412
+ out.firmware = lg[2];
1413
+ sources.push("user_agent");
1414
+ }
1415
+ } else if (/Tizen/i.test(ua)) {
1416
+ out.platform = "tizen";
1417
+ var tizen = ua.match(/Tizen\s+(\d+(?:\.\d+)*)/i);
1418
+ if (tizen && tizen[1]) {
1419
+ out.osVersion = "Tizen ".concat(tizen[1]);
1420
+ sources.push("user_agent");
1421
+ }
1422
+ }
1423
+ return out;
1424
+ }
1425
+ function readSamsungProductInfo() {
1426
+ var _cleanString;
1427
+ var _window_webapis;
1428
+ if (typeof window === "undefined") return void 0;
1429
+ var productinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.productinfo;
1430
+ if (!productinfo) return void 0;
1431
+ var model = (_cleanString = cleanString(safeCall(productinfo.getRealModel, productinfo), 40)) !== null && _cleanString !== void 0 ? _cleanString : cleanString(safeCall(productinfo.getModel, productinfo), 40);
1432
+ var firmware = cleanString(safeCall(productinfo.getFirmware, productinfo), 64);
1433
+ var duid = cleanString(safeCall(productinfo.getDuid, productinfo), 128);
1434
+ if (!model && !firmware && !duid) return void 0;
1435
+ return _object_spread({}, model ? {
1436
+ model: model
1437
+ } : {}, firmware ? {
1438
+ firmware: firmware
1439
+ } : {}, duid ? {
1440
+ internalDeviceId: duid,
1441
+ internalDeviceIdSource: "samsung_duid"
1442
+ } : {});
1443
+ }
1444
+ function computePlatformInfo() {
1445
+ var info = parseUserAgentDeviceInfo(userAgent());
1446
+ var sources = _to_consumable_array(info.sources);
1447
+ var samsung = readSamsungProductInfo();
1448
+ if (samsung) {
1449
+ info.platform = "tizen";
1450
+ if (samsung.model) info.model = samsung.model;
1451
+ if (samsung.firmware) info.firmware = samsung.firmware;
1452
+ if (samsung.internalDeviceId) {
1453
+ info.internalDeviceId = samsung.internalDeviceId;
1454
+ info.internalDeviceIdSource = "samsung_duid";
1455
+ }
1456
+ sources.push("samsung_productinfo");
1457
+ }
1458
+ if (lgDeviceInfo) {
1459
+ info.platform = "webos";
1460
+ if (!info.model && lgDeviceInfo.model) info.model = lgDeviceInfo.model;
1461
+ if (!info.firmware && lgDeviceInfo.firmware) info.firmware = lgDeviceInfo.firmware;
1462
+ if (lgDeviceInfo.sdkVersion) info.osVersion = "webOS TV ".concat(lgDeviceInfo.sdkVersion);
1463
+ sources.push("lg_deviceinfo");
1464
+ }
1465
+ var lgUdid = readCachedLgUdid();
1466
+ if ((lgUdid === null || lgUdid === void 0 ? void 0 : lgUdid.deviceId) && !info.internalDeviceId) {
1467
+ info.internalDeviceId = lgUdid.deviceId;
1468
+ info.internalDeviceIdSource = "lg_udid";
1469
+ sources.push("lg_udid");
1470
+ }
1471
+ info.sources = sources;
1472
+ return info;
1473
+ }
1474
+ function categorize(platform, model) {
1475
+ if (platform === "tizen") return "Samsung TV";
1476
+ if (platform === "webos") {
1477
+ var ua = userAgent();
1478
+ if (model && /^STB-/i.test(model) || /\bSTB-\d{4}|LGSTB/i.test(ua)) return "LG Set-Top Box";
1479
+ return "LG TV";
1480
+ }
1481
+ return "Other";
1482
+ }
1483
+ function getDeviceInfo() {
1484
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
1485
+ var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
1486
+ if (primePromise && !platformCache) {} else {
1487
+ platformCache = platform;
1488
+ }
1489
+ var host = hostDeviceInfo !== null && hostDeviceInfo !== void 0 ? hostDeviceInfo : {};
1490
+ var bridge = {
1491
+ terminalId: readBridge([
1492
+ "terminalId",
1493
+ "terminal_id"
1494
+ ]),
1495
+ internalDeviceId: readBridge([
1496
+ "internalDeviceId",
1497
+ "internal_device_id"
1498
+ ]),
1499
+ model: readBridge([
1500
+ "deviceModel"
1501
+ ]),
1502
+ firmware: readBridge([
1503
+ "firmwareVersion"
1504
+ ]),
1505
+ category: normalizeCategory(readBridge([
1506
+ "deviceCategory"
1507
+ ]))
1508
+ };
1509
+ var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
1510
+ var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
1511
+ var model = (_ref = (_cleanString2 = cleanString(host.model, 40)) !== null && _cleanString2 !== void 0 ? _cleanString2 : bridge.model) !== null && _ref !== void 0 ? _ref : platform.model;
1512
+ var firmware = (_ref1 = (_cleanString3 = cleanString(host.firmware, 64)) !== null && _cleanString3 !== void 0 ? _cleanString3 : bridge.firmware) !== null && _ref1 !== void 0 ? _ref1 : platform.firmware;
1513
+ var category = (_ref2 = (_normalizeCategory = normalizeCategory(host.category)) !== null && _normalizeCategory !== void 0 ? _normalizeCategory : bridge.category) !== null && _ref2 !== void 0 ? _ref2 : categorize(platform.platform, model);
1514
+ var sources = _to_consumable_array(platform.sources);
1515
+ var bridgeValues = [
1516
+ bridge.terminalId,
1517
+ bridge.internalDeviceId,
1518
+ bridge.model,
1519
+ bridge.firmware,
1520
+ bridge.category
1521
+ ];
1522
+ if (bridgeValues.some(function(v) {
1523
+ return v !== void 0;
1524
+ })) sources.unshift("bridge");
1525
+ if (hostDeviceInfo) sources.unshift("host");
1526
+ var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
1527
+ var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
1528
+ var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
1529
+ return _object_spread_props(_object_spread({
1530
+ category: category,
1531
+ categoryCode: CATEGORY_CODES[category]
1532
+ }, model ? {
1533
+ model: model
1534
+ } : {}, sonifiModel ? {
1535
+ sonifiModel: sonifiModel
1536
+ } : {}, firmware ? {
1537
+ firmware: firmware
1538
+ } : {}, platform.osVersion ? {
1539
+ osVersion: platform.osVersion
1540
+ } : {}, platform.browserMajorVersion != null ? {
1541
+ browserMajorVersion: platform.browserMajorVersion
1542
+ } : {}, internalDeviceId ? {
1543
+ internalDeviceId: internalDeviceId
1544
+ } : {}, internalDeviceId && internalDeviceIdSource ? {
1545
+ internalDeviceIdSource: internalDeviceIdSource
1546
+ } : {}, terminalId ? {
1547
+ terminalId: terminalId
1548
+ } : {}), {
1549
+ sources: sources
1550
+ });
1551
+ }
1552
+ function deviceInfoAnalyticsFields(info) {
1553
+ return _object_spread({
1554
+ device_category: info.category
1555
+ }, info.model ? {
1556
+ device_model: info.model
1557
+ } : {}, info.sonifiModel ? {
1558
+ sonifi_model: info.sonifiModel
1559
+ } : {}, info.firmware ? {
1560
+ firmware_version: info.firmware
1561
+ } : {}, info.osVersion ? {
1562
+ os_version: info.osVersion
1563
+ } : {}, info.browserMajorVersion != null ? {
1564
+ browser_major_version: info.browserMajorVersion
1565
+ } : {}, info.internalDeviceId ? {
1566
+ internal_device_id: info.internalDeviceId
1567
+ } : {}, info.internalDeviceIdSource ? {
1568
+ internal_device_id_source: info.internalDeviceIdSource
1569
+ } : {}, info.terminalId ? {
1570
+ terminal_id: info.terminalId
1571
+ } : {});
1572
+ }
1296
1573
  // src/utils/tracking.ts
1297
1574
  var cachedBrowserId = null;
1298
1575
  function buildAnalyticsContext(config) {
1299
- var _config_contentNetwork, _config_channelName, _config_programTitle;
1576
+ var _config_contentNetwork, _config_channelName, _config_programTitle, _config_src;
1300
1577
  var context = {};
1301
1578
  var contentNetwork = (_config_contentNetwork = config.contentNetwork) === null || _config_contentNetwork === void 0 ? void 0 : _config_contentNetwork.trim();
1302
1579
  var contentChannel = (_config_channelName = config.channelName) === null || _config_channelName === void 0 ? void 0 : _config_channelName.trim();
1303
1580
  var contentTitle = (_config_programTitle = config.programTitle) === null || _config_programTitle === void 0 ? void 0 : _config_programTitle.trim();
1581
+ var hlsUrl = (_config_src = config.src) === null || _config_src === void 0 ? void 0 : _config_src.trim();
1304
1582
  if (contentNetwork) context.contentNetwork = contentNetwork;
1305
1583
  if (contentChannel) context.contentChannel = contentChannel;
1306
1584
  if (contentTitle) context.contentTitle = contentTitle;
1585
+ if (hlsUrl) context.hlsUrl = hlsUrl;
1307
1586
  if (config.debugAdTiming) {
1308
1587
  context.debugAdTiming = true;
1309
1588
  }
1310
1589
  if (config.isLiveStream !== void 0) {
1311
1590
  context.inputStreamType = config.isLiveStream ? "live" : "vod";
1312
1591
  }
1592
+ if (config.sendDeviceInfoToAnalytics) {
1593
+ context.includeDeviceInfo = true;
1594
+ }
1313
1595
  return context;
1314
1596
  }
1315
1597
  function getClientInfo() {
@@ -1605,7 +1887,7 @@ function buildPlayerMetricEvent() {
1605
1887
  capture_at: captureAt
1606
1888
  }, context.inputStreamType ? {
1607
1889
  input_stream_type: context.inputStreamType
1608
- } : {})
1890
+ } : {}, context.includeDeviceInfo ? deviceInfoAnalyticsFields(getDeviceInfo()) : {})
1609
1891
  ];
1610
1892
  }
1611
1893
  });
@@ -1708,6 +1990,8 @@ function sendAdImpressionTracking(_0, _1) {
1708
1990
  content_channel: context.contentChannel
1709
1991
  } : {}, context.contentTitle ? {
1710
1992
  content_title: context.contentTitle
1993
+ } : {}, context.hlsUrl ? {
1994
+ hls_url: context.hlsUrl
1711
1995
  } : {})
1712
1996
  ]
1713
1997
  })
@@ -2080,6 +2364,54 @@ function computePodResponseDiagnostics(pmxdSent, vastAdCount, totalVastCreativeD
2080
2364
  function monotonicNow() {
2081
2365
  return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
2082
2366
  }
2367
+ // src/utils/screenActivity.ts
2368
+ var hostStandby = false;
2369
+ function toBoolean(value) {
2370
+ if (typeof value === "boolean") return value;
2371
+ if (typeof value === "number") return value === 1;
2372
+ if (typeof value === "string") {
2373
+ var v = value.trim().toLowerCase();
2374
+ if (v === "true" || v === "1" || v === "yes") return true;
2375
+ if (v === "false" || v === "0" || v === "no") return false;
2376
+ }
2377
+ return void 0;
2378
+ }
2379
+ function bridgeSaysStandby() {
2380
+ if (typeof window === "undefined") return false;
2381
+ var w = window;
2382
+ for(var _i = 0, _iter = [
2383
+ w.__STORMCLOUD_CTV__,
2384
+ w.__STORMCLOUD_CTV_AD_INFO__,
2385
+ w.stormcloudCtv
2386
+ ]; _i < _iter.length; _i++){
2387
+ var source = _iter[_i];
2388
+ if (!source) continue;
2389
+ for(var _i1 = 0, _iter1 = [
2390
+ "standby",
2391
+ "isStandby",
2392
+ "screenOff"
2393
+ ]; _i1 < _iter1.length; _i1++){
2394
+ var key = _iter1[_i1];
2395
+ var value = void 0;
2396
+ try {
2397
+ value = source[key];
2398
+ if (typeof value === "function") value = value.call(source);
2399
+ } catch (unused) {
2400
+ value = void 0;
2401
+ }
2402
+ if (toBoolean(value) === true) return true;
2403
+ }
2404
+ }
2405
+ return false;
2406
+ }
2407
+ function getScreenInactiveReason() {
2408
+ if (hostStandby) return "host_standby";
2409
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
2410
+ return "document_hidden";
2411
+ }
2412
+ if (bridgeSaysStandby()) return "bridge_standby";
2413
+ return void 0;
2414
+ }
2083
2415
  // src/player/AdBreakOrchestrator.ts
2084
2416
  var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
2085
2417
  "no_fill",
@@ -2136,9 +2468,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2136
2468
  }
2137
2469
  },
2138
2470
  {
2139
- // ───────────────────────────────────────────────────────────────
2140
- // IMA event listeners
2141
- // ───────────────────────────────────────────────────────────────
2142
2471
  key: "nextAdRequestUrl",
2143
2472
  value: function nextAdRequestUrl(baseVastUrl) {
2144
2473
  return this.host.generatePodVastUrl(baseVastUrl);
@@ -2374,9 +2703,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2374
2703
  }
2375
2704
  },
2376
2705
  {
2377
- // ───────────────────────────────────────────────────────────────
2378
- // Ad break start
2379
- // ───────────────────────────────────────────────────────────────
2380
2706
  key: "isBreakActive",
2381
2707
  value: function isBreakActive() {
2382
2708
  return this.slotState !== "IDLE";
@@ -2404,7 +2730,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2404
2730
  key: "handleAdStart",
2405
2731
  value: function handleAdStart(marker) {
2406
2732
  return _async_to_generator(function() {
2407
- var baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
2733
+ var screenInactiveReason, baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
2408
2734
  return _ts_generator(this, function(_state) {
2409
2735
  switch(_state.label){
2410
2736
  case 0:
@@ -2417,6 +2743,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2417
2743
  2
2418
2744
  ];
2419
2745
  }
2746
+ screenInactiveReason = getScreenInactiveReason();
2747
+ if (screenInactiveReason) {
2748
+ this.logOrchestratorFunnel("break_skipped_screen_inactive", {
2749
+ reason: screenInactiveReason
2750
+ });
2751
+ this.clearPendingAdBreak();
2752
+ return [
2753
+ 2
2754
+ ];
2755
+ }
2420
2756
  baseVastUrl = this.adConfig.apiVastTagUrl;
2421
2757
  edgeConfigured = !!this.host.getEdgePodBaseUrl();
2422
2758
  if (!baseVastUrl && !edgeConfigured) {
@@ -2577,12 +2913,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2577
2913
  },
2578
2914
  {
2579
2915
  key: "startOptimizedPod",
2580
- value: // ───────────────────────────────────────────────────────────────
2581
- // Optimized pod (single multi-ad request)
2582
- // ───────────────────────────────────────────────────────────────
2583
- function startOptimizedPod(baseVastUrl) {
2916
+ value: function startOptimizedPod(baseVastUrl) {
2584
2917
  return _async_to_generator(function() {
2585
- var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, error;
2918
+ var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, _this_host_config_maxAdBreakExtensionMs, remainingMs, overrunAllowanceMs, maxAdsCap, maxAds, error;
2586
2919
  return _ts_generator(this, function(_state) {
2587
2920
  switch(_state.label){
2588
2921
  case 0:
@@ -2690,6 +3023,26 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2690
3023
  false
2691
3024
  ];
2692
3025
  }
3026
+ if (this.isBreakTimeBounded() && adPlayer.limitPodToBudget) {
3027
+ ;
3028
+ remainingMs = this.timing.getRemainingAdMs();
3029
+ overrunAllowanceMs = Math.max(0, (_this_host_config_maxAdBreakExtensionMs = this.host.config.maxAdBreakExtensionMs) !== null && _this_host_config_maxAdBreakExtensionMs !== void 0 ? _this_host_config_maxAdBreakExtensionMs : 0);
3030
+ maxAdsCap = this.adConfig.resolveAdPodConfig().maxAdsPerBreak;
3031
+ maxAds = maxAdsCap != null ? Math.max(1, maxAdsCap - this.timing.totalAdsInBreak) : Number.MAX_SAFE_INTEGER;
3032
+ if (Number.isFinite(remainingMs)) {
3033
+ podCount = adPlayer.limitPodToBudget(remainingMs + overrunAllowanceMs, maxAds);
3034
+ if (podCount < 1) {
3035
+ if (this.timing.activeAdRequestToken === requestToken) {
3036
+ this.timing.activeAdRequestToken = null;
3037
+ }
3038
+ this.recordRequestFailure(new Error("No GAM ad fits the ".concat(Math.round(remainingMs), "ms left in the break")), podUrl);
3039
+ return [
3040
+ 2,
3041
+ false
3042
+ ];
3043
+ }
3044
+ }
3045
+ }
2693
3046
  this.setSlotState("READY", "vast_ready");
2694
3047
  if (this.debug) {
2695
3048
  console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling pod top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
@@ -2759,9 +3112,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2759
3112
  }
2760
3113
  },
2761
3114
  {
2762
- // ───────────────────────────────────────────────────────────────
2763
- // Edge-first pods (live SCTE-35 only, GAM fallback)
2764
- // ───────────────────────────────────────────────────────────────
2765
3115
  key: "resetEdgeStateForBreak",
2766
3116
  value: function resetEdgeStateForBreak() {
2767
3117
  this.edgeExhaustedForBreak = false;
@@ -2979,9 +3329,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2979
3329
  }
2980
3330
  },
2981
3331
  {
2982
- // ───────────────────────────────────────────────────────────────
2983
- // Next-ad scheduling (single flight)
2984
- // ───────────────────────────────────────────────────────────────
2985
3332
  key: "setSlotState",
2986
3333
  value: function setSlotState(next, reason) {
2987
3334
  if (this.slotState === next) return;
@@ -3031,6 +3378,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3031
3378
  {
3032
3379
  key: "getStopRequestingReason",
3033
3380
  value: function getStopRequestingReason(remainingMs) {
3381
+ var screenInactiveReason = getScreenInactiveReason();
3382
+ if (screenInactiveReason) return "screen_inactive:".concat(screenInactiveReason);
3034
3383
  if (this.breakSource === "vmap") {
3035
3384
  if (this.adPodQueue.length === 0) return "vmap_queue_empty";
3036
3385
  } else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl && !this.canRequestEdge()) {
@@ -3304,9 +3653,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3304
3653
  }
3305
3654
  },
3306
3655
  {
3307
- // ───────────────────────────────────────────────────────────────
3308
- // Per-request diagnostics
3309
- // ───────────────────────────────────────────────────────────────
3310
3656
  key: "recordRequestDiagnostic",
3311
3657
  value: function recordRequestDiagnostic(payload) {
3312
3658
  var requestId = payload.requestId;
@@ -3380,9 +3726,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3380
3726
  }
3381
3727
  },
3382
3728
  {
3383
- // ───────────────────────────────────────────────────────────────
3384
- // Single ad playback
3385
- // ───────────────────────────────────────────────────────────────
3386
3729
  key: "createGamDispatchFinalizer",
3387
3730
  value: function createGamDispatchFinalizer(requestToken) {
3388
3731
  var _this = this;
@@ -3845,9 +4188,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3845
4188
  }
3846
4189
  },
3847
4190
  {
3848
- // ───────────────────────────────────────────────────────────────
3849
- // Ad break completion
3850
- // ───────────────────────────────────────────────────────────────
3851
4191
  key: "logBreakFunnel",
3852
4192
  value: function logBreakFunnel(endReason) {
3853
4193
  var funnel = this.breakFunnel;