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
package/lib/index.js CHANGED
@@ -343,8 +343,264 @@ function _unsupported_iterable_to_array(o, minLen) {
343
343
  }
344
344
  // src/ui/StormcloudVideoPlayer.tsx
345
345
  import React, { useEffect, useRef, useMemo, useCallback } from "react";
346
+ // src/utils/adIdentity.ts
347
+ var GOOGLE_ID_TYPES = [
348
+ "aaid",
349
+ "adid",
350
+ "afai",
351
+ "idfa",
352
+ "lgudid",
353
+ "msai",
354
+ "rida",
355
+ "tifa",
356
+ "tvOS",
357
+ "vaid",
358
+ "vida",
359
+ "dpid"
360
+ ];
361
+ var MAX_SESSION_ID_AGE_MS = 6 * 60 * 60 * 1e3;
362
+ var DEFAULT_SESSION_ID_MAX_AGE_MS = MAX_SESSION_ID_AGE_MS;
363
+ var DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
364
+ var DEFAULT_LGUDID_TIMEOUT_MS = 1500;
365
+ var FALLBACK_DEVICE_ID_KEY = "stormcloud.ad.dpid.v2";
366
+ var SESSION_ID_KEY = "stormcloud.ad.sid.v2";
367
+ var LEGACY_SESSION_KEY = "stormcloud.ctv.sid";
368
+ var ZEROED_IDS = /* @__PURE__ */ new Set([
369
+ "00000000-0000-0000-0000-000000000000",
370
+ "38400000-8cf0-11bd-b23e-10b96e40000d"
371
+ ]);
372
+ var hostIdentity;
373
+ var memoryStore = {};
374
+ var lgUdidResult;
375
+ var lgUdidPromise;
376
+ var legacyCleared = false;
377
+ function isUsableAdId(value) {
378
+ if (typeof value !== "string") return false;
379
+ var t = value.trim();
380
+ if (!t) return false;
381
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(t)) return false;
382
+ if (/^(unknown|null|undefined|none|n\/a)$/i.test(t)) return false;
383
+ return !ZEROED_IDS.has(t.toLowerCase());
384
+ }
385
+ function isZeroedAdId(value) {
386
+ return typeof value === "string" && ZEROED_IDS.has(value.trim().toLowerCase());
387
+ }
388
+ function normalizeIdType(value) {
389
+ if (typeof value !== "string") return void 0;
390
+ var lower = value.trim().toLowerCase();
391
+ if (!lower) return void 0;
392
+ var match = GOOGLE_ID_TYPES.find(function(t) {
393
+ return t.toLowerCase() === lower;
394
+ });
395
+ return match !== null && match !== void 0 ? match : "dpid";
396
+ }
397
+ function createUuid() {
398
+ var _bytes_, _bytes_1, _bytes_i;
399
+ var c = typeof crypto !== "undefined" ? crypto : void 0;
400
+ if (c && typeof c.randomUUID === "function") return c.randomUUID();
401
+ var bytes = new Uint8Array(16);
402
+ if (c && typeof c.getRandomValues === "function") {
403
+ c.getRandomValues(bytes);
404
+ } else {
405
+ for(var i = 0; i < 16; i++)bytes[i] = Math.floor(Math.random() * 256);
406
+ }
407
+ bytes[6] = ((_bytes_ = bytes[6]) !== null && _bytes_ !== void 0 ? _bytes_ : 0) & 15 | 64;
408
+ bytes[8] = ((_bytes_1 = bytes[8]) !== null && _bytes_1 !== void 0 ? _bytes_1 : 0) & 63 | 128;
409
+ var hex = "";
410
+ for(var i1 = 0; i1 < 16; i1++)hex += ((_bytes_i = bytes[i1]) !== null && _bytes_i !== void 0 ? _bytes_i : 0).toString(16).padStart(2, "0");
411
+ return "".concat(hex.slice(0, 8), "-").concat(hex.slice(8, 12), "-").concat(hex.slice(12, 16), "-").concat(hex.slice(16, 20), "-").concat(hex.slice(20));
412
+ }
413
+ function readStored(key) {
414
+ try {
415
+ var _window_localStorage;
416
+ var raw = typeof window !== "undefined" ? (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key) : null;
417
+ if (raw) {
418
+ var parsed = JSON.parse(raw);
419
+ if (parsed && typeof parsed.id === "string" && typeof parsed.createdAt === "number" && isFinite(parsed.createdAt)) {
420
+ return {
421
+ id: parsed.id,
422
+ createdAt: parsed.createdAt
423
+ };
424
+ }
425
+ }
426
+ } catch (unused) {}
427
+ return memoryStore[key];
428
+ }
429
+ function writeStored(key, value) {
430
+ memoryStore[key] = value;
431
+ try {
432
+ if (typeof window !== "undefined") {
433
+ var _window_localStorage;
434
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(key, JSON.stringify(value));
435
+ }
436
+ } catch (unused) {}
437
+ }
438
+ function removeStored(key) {
439
+ delete memoryStore[key];
440
+ try {
441
+ var _window_localStorage;
442
+ if (typeof window !== "undefined") (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.removeItem(key);
443
+ } catch (unused) {}
444
+ }
445
+ function clearLegacyIdsOnce() {
446
+ if (legacyCleared) return;
447
+ legacyCleared = true;
448
+ try {
449
+ var _window_localStorage;
450
+ if (typeof window !== "undefined") (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.removeItem(LEGACY_SESSION_KEY);
451
+ } catch (unused) {}
452
+ try {
453
+ if (typeof document !== "undefined") {
454
+ document.cookie = "".concat(encodeURIComponent(LEGACY_SESSION_KEY), "=;path=/;max-age=0;SameSite=Lax");
455
+ }
456
+ } catch (unused) {}
457
+ }
458
+ function clampAge(value, fallback, max) {
459
+ var v = typeof value === "number" && isFinite(value) && value > 0 ? value : fallback;
460
+ if (max != null) v = Math.min(v, max);
461
+ return v;
462
+ }
463
+ function setHostAdIdentity(identity) {
464
+ var _normalizeIdType;
465
+ if (!identity || !isUsableAdId(identity.deviceId)) {
466
+ hostIdentity = void 0;
467
+ return;
468
+ }
469
+ var deviceId = identity.deviceId.trim();
470
+ var changed = !hostIdentity || hostIdentity.deviceId !== deviceId;
471
+ hostIdentity = _object_spread({
472
+ deviceId: deviceId,
473
+ deviceIdType: (_normalizeIdType = normalizeIdType(identity.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
474
+ }, typeof identity.limitAdTracking === "boolean" ? {
475
+ limitAdTracking: identity.limitAdTracking
476
+ } : {});
477
+ if (changed) {
478
+ removeStored(SESSION_ID_KEY);
479
+ removeStored(FALLBACK_DEVICE_ID_KEY);
480
+ }
481
+ }
482
+ function getHostAdIdentity() {
483
+ return hostIdentity ? _object_spread({}, hostIdentity) : void 0;
484
+ }
485
+ function resetAdIdentity() {
486
+ removeStored(SESSION_ID_KEY);
487
+ removeStored(FALLBACK_DEVICE_ID_KEY);
488
+ }
489
+ function readSamsungTifa() {
490
+ try {
491
+ var _window_webapis;
492
+ var adinfo = typeof window !== "undefined" ? (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo : void 0;
493
+ if (!adinfo) return void 0;
494
+ var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
495
+ var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
496
+ if (isZeroedAdId(tifa)) return {
497
+ deviceIdType: "tifa",
498
+ limitAdTracking: true
499
+ };
500
+ if (!isUsableAdId(tifa)) return void 0;
501
+ return _object_spread({
502
+ deviceId: tifa.trim(),
503
+ deviceIdType: "tifa"
504
+ }, typeof lat === "boolean" ? {
505
+ limitAdTracking: lat
506
+ } : {});
507
+ } catch (unused) {
508
+ return void 0;
509
+ }
510
+ }
511
+ function primeLgUdid() {
512
+ var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_LGUDID_TIMEOUT_MS;
513
+ if (lgUdidResult || lgUdidPromise) return lgUdidPromise !== null && lgUdidPromise !== void 0 ? lgUdidPromise : Promise.resolve();
514
+ var dev = typeof window !== "undefined" ? window.webOSDev : void 0;
515
+ if (!dev) return Promise.resolve();
516
+ if (typeof dev.LGUDID !== "function") {
517
+ var _dev_lgudid;
518
+ var direct = (_dev_lgudid = dev.lgudid) !== null && _dev_lgudid !== void 0 ? _dev_lgudid : dev.LGUDID;
519
+ if (isZeroedAdId(direct)) lgUdidResult = {
520
+ deviceIdType: "lgudid",
521
+ limitAdTracking: true
522
+ };
523
+ else if (isUsableAdId(direct)) {
524
+ lgUdidResult = {
525
+ deviceId: direct.trim(),
526
+ deviceIdType: "lgudid",
527
+ limitAdTracking: false
528
+ };
529
+ }
530
+ return Promise.resolve();
531
+ }
532
+ lgUdidPromise = new Promise(function(resolve) {
533
+ var settled = false;
534
+ var finish = function finish() {
535
+ if (settled) return;
536
+ settled = true;
537
+ clearTimeout(timer);
538
+ resolve();
539
+ };
540
+ var timer = setTimeout(finish, Math.max(0, timeoutMs));
541
+ try {
542
+ dev.LGUDID({
543
+ onSuccess: function onSuccess(res) {
544
+ var id = res === null || res === void 0 ? void 0 : res.id;
545
+ if (isZeroedAdId(id)) {
546
+ lgUdidResult = {
547
+ deviceIdType: "lgudid",
548
+ limitAdTracking: true
549
+ };
550
+ } else if (isUsableAdId(id)) {
551
+ lgUdidResult = {
552
+ deviceId: id.trim(),
553
+ deviceIdType: "lgudid",
554
+ limitAdTracking: false
555
+ };
556
+ }
557
+ finish();
558
+ },
559
+ onFailure: function onFailure() {
560
+ return finish();
561
+ }
562
+ });
563
+ } catch (unused) {
564
+ finish();
565
+ }
566
+ });
567
+ return lgUdidPromise;
568
+ }
569
+ function readCachedLgUdid() {
570
+ return lgUdidResult ? _object_spread({}, lgUdidResult) : void 0;
571
+ }
572
+ function getOrRotateFallbackDeviceId() {
573
+ var maxAgeMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS, now = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Date.now();
574
+ clearLegacyIdsOnce();
575
+ var age = clampAge(maxAgeMs, DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS);
576
+ var stored = readStored(FALLBACK_DEVICE_ID_KEY);
577
+ if (stored && isUsableAdId(stored.id) && now - stored.createdAt >= 0 && now - stored.createdAt < age) {
578
+ return stored.id;
579
+ }
580
+ var id = createUuid();
581
+ writeStored(FALLBACK_DEVICE_ID_KEY, {
582
+ id: id,
583
+ createdAt: now
584
+ });
585
+ return id;
586
+ }
587
+ function getOrRotateSessionId() {
588
+ var maxAgeMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_SESSION_ID_MAX_AGE_MS, avoidValue = arguments.length > 1 ? arguments[1] : void 0, now = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Date.now();
589
+ clearLegacyIdsOnce();
590
+ var age = clampAge(maxAgeMs, DEFAULT_SESSION_ID_MAX_AGE_MS, MAX_SESSION_ID_AGE_MS);
591
+ var stored = readStored(SESSION_ID_KEY);
592
+ if (stored && isUsableAdId(stored.id) && stored.id !== avoidValue && now - stored.createdAt >= 0 && now - stored.createdAt < age) {
593
+ return stored.id;
594
+ }
595
+ var id = createUuid();
596
+ while(id === avoidValue)id = createUuid();
597
+ writeStored(SESSION_ID_KEY, {
598
+ id: id,
599
+ createdAt: now
600
+ });
601
+ return id;
602
+ }
346
603
  // src/utils/vastEnvironmentSignals.ts
347
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
348
604
  var PLAYER_ID_STORAGE_KEY = "stormcloud.player.id";
349
605
  var DEVICE_ID_STORAGE_KEYS = [
350
606
  "rdid",
@@ -363,49 +619,96 @@ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
363
619
  "adid"
364
620
  ]);
365
621
  function resolveVastEnvironmentSignals(isCtv) {
366
- var bridgeSignals = readNativeBridgeSignals();
367
- var platformDevice = readPlatformNativeDeviceId();
368
- var bridgeDeviceId = validDeviceId(bridgeSignals.deviceId);
369
- var realDeviceId = bridgeDeviceId || (isCtv ? validDeviceId(readStoredDeviceId()) : void 0) || validDeviceId(platformDevice.deviceId);
370
- var deviceId = realDeviceId;
371
- var deviceIdType = (bridgeDeviceId ? bridgeSignals.deviceIdType : void 0) || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
372
- var platformLat = bridgeDeviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
373
- var limitAdTracking = deviceId != null ? platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking() : void 0;
374
- if (!deviceId && isCtv) {
375
- var dpid = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
376
- if (dpid) {
377
- deviceId = dpid;
378
- deviceIdType = "dpid";
379
- limitAdTracking = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking();
380
- }
381
- }
622
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
382
623
  var deviceTypeHint = resolveDeviceTypeHint(isCtv);
624
+ var identity = resolveDeviceIdentity(isCtv, options);
625
+ var identityFields = _object_spread({}, identity.deviceId ? {
626
+ deviceId: identity.deviceId
627
+ } : {}, identity.deviceId && identity.deviceIdType ? {
628
+ deviceIdType: identity.deviceIdType
629
+ } : {}, identity.deviceId && identity.limitAdTracking != null ? {
630
+ limitAdTracking: identity.limitAdTracking
631
+ } : {}, identity.source ? {
632
+ deviceIdSource: identity.source
633
+ } : {});
383
634
  if (isCtv) {
384
635
  return _object_spread_props(_object_spread({
385
636
  isCtv: true,
386
- sessionId: getOrCreateCtvSessionId()
387
- }, deviceId ? {
388
- deviceId: deviceId
389
- } : {}, deviceId && deviceIdType ? {
390
- deviceIdType: deviceIdType
391
- } : {}, deviceId && limitAdTracking != null ? {
392
- limitAdTracking: limitAdTracking
393
- } : {}), {
637
+ sessionId: getOrRotateSessionId(options.sessionIdMaxAgeMs, identity.deviceId)
638
+ }, identityFields), {
394
639
  deviceTypeHint: deviceTypeHint
395
640
  });
396
641
  }
397
642
  return _object_spread_props(_object_spread({
398
643
  isCtv: false
399
- }, deviceId ? {
400
- deviceId: deviceId
401
- } : {}, deviceId && deviceIdType ? {
402
- deviceIdType: deviceIdType
403
- } : {}, deviceId && limitAdTracking != null ? {
404
- limitAdTracking: limitAdTracking
405
- } : {}), {
644
+ }, identityFields), {
406
645
  deviceTypeHint: deviceTypeHint
407
646
  });
408
647
  }
648
+ function resolveDeviceIdentity(isCtv, options) {
649
+ var _platform_limitAdTracking;
650
+ var host = getHostAdIdentity();
651
+ if (host) {
652
+ var _host_deviceIdType;
653
+ return _object_spread_props(_object_spread({
654
+ deviceId: host.deviceId,
655
+ deviceIdType: (_host_deviceIdType = host.deviceIdType) !== null && _host_deviceIdType !== void 0 ? _host_deviceIdType : "dpid"
656
+ }, host.limitAdTracking != null ? {
657
+ limitAdTracking: host.limitAdTracking
658
+ } : {}), {
659
+ source: "host"
660
+ });
661
+ }
662
+ var bridge = readNativeBridgeSignals();
663
+ var bridgeDeviceId = validDeviceId(bridge.deviceId);
664
+ if (bridgeDeviceId) {
665
+ var _normalizeIdType;
666
+ return _object_spread_props(_object_spread({
667
+ deviceId: bridgeDeviceId,
668
+ deviceIdType: (_normalizeIdType = normalizeIdType(bridge.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
669
+ }, bridge.limitAdTracking != null ? {
670
+ limitAdTracking: bridge.limitAdTracking
671
+ } : {}), {
672
+ source: "bridge"
673
+ });
674
+ }
675
+ var platform = readPlatformNativeDeviceId();
676
+ var platformDeviceId = validDeviceId(platform.deviceId);
677
+ if (platformDeviceId) {
678
+ var _platform_deviceIdType;
679
+ return _object_spread_props(_object_spread({
680
+ deviceId: platformDeviceId,
681
+ deviceIdType: (_platform_deviceIdType = platform.deviceIdType) !== null && _platform_deviceIdType !== void 0 ? _platform_deviceIdType : "dpid"
682
+ }, platform.limitAdTracking != null ? {
683
+ limitAdTracking: platform.limitAdTracking
684
+ } : {}), {
685
+ source: "platform"
686
+ });
687
+ }
688
+ if (!isCtv) return {};
689
+ var storedDeviceId = validDeviceId(readStoredDeviceId());
690
+ if (storedDeviceId) {
691
+ var _normalizeIdType1;
692
+ var storedLat = readStoredLimitAdTracking();
693
+ return _object_spread_props(_object_spread({
694
+ deviceId: storedDeviceId,
695
+ deviceIdType: (_normalizeIdType1 = normalizeIdType(readStoredString("deviceIdType") || readStoredString("idtype"))) !== null && _normalizeIdType1 !== void 0 ? _normalizeIdType1 : "dpid"
696
+ }, storedLat != null ? {
697
+ limitAdTracking: storedLat
698
+ } : {}), {
699
+ source: "stored"
700
+ });
701
+ }
702
+ var fallbackLat = (_platform_limitAdTracking = platform.limitAdTracking) !== null && _platform_limitAdTracking !== void 0 ? _platform_limitAdTracking : readStoredLimitAdTracking();
703
+ return _object_spread_props(_object_spread({
704
+ deviceId: getOrRotateFallbackDeviceId(options.fallbackDeviceIdMaxAgeMs),
705
+ deviceIdType: "dpid"
706
+ }, fallbackLat != null ? {
707
+ limitAdTracking: fallbackLat
708
+ } : {}), {
709
+ source: "generated"
710
+ });
711
+ }
409
712
  var DEVICE_TYPE_HINT = {
410
713
  FEATURE_PHONE: 1,
411
714
  SMARTPHONE: 2,
@@ -566,7 +869,7 @@ function resolveNativeDeviceId() {
566
869
  var bridgeSignals = readNativeBridgeSignals();
567
870
  var platformDevice = readPlatformNativeDeviceId();
568
871
  var deviceId = bridgeSignals.deviceId || (includeStored ? readStoredDeviceId() : void 0) || platformDevice.deviceId;
569
- if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId(deviceId)) {
872
+ if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId2(deviceId)) {
570
873
  return void 0;
571
874
  }
572
875
  return deviceId;
@@ -580,20 +883,10 @@ function getOrCreateStoredUuid(storageKey) {
580
883
  writePersistentId(storageKey, existing);
581
884
  return existing;
582
885
  }
583
- var id = createUuid();
886
+ var id = createUuid2();
584
887
  writePersistentId(storageKey, id);
585
888
  return id;
586
889
  }
587
- function getOrCreateCtvSessionId() {
588
- var existing = readPersistentId(CTV_SESSION_STORAGE_KEY);
589
- if (existing) {
590
- writePersistentId(CTV_SESSION_STORAGE_KEY, existing);
591
- return existing;
592
- }
593
- var sessionId = createUuid();
594
- writePersistentId(CTV_SESSION_STORAGE_KEY, sessionId);
595
- return sessionId;
596
- }
597
890
  function readPersistentId(storageKey) {
598
891
  return readStoredString(storageKey) || readCookie(storageKey);
599
892
  }
@@ -646,7 +939,7 @@ function writeCookie(name, value) {
646
939
  document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";path=/;max-age=" + PERSISTENT_ID_COOKIE_MAX_AGE + ";SameSite=Lax";
647
940
  } catch (unused) {}
648
941
  }
649
- function createUuid() {
942
+ function createUuid2() {
650
943
  var _bytes_, _bytes_1;
651
944
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
652
945
  return crypto.randomUUID();
@@ -680,44 +973,10 @@ function performanceNow() {
680
973
  }
681
974
  function readPlatformNativeDeviceId() {
682
975
  if (typeof window === "undefined") return {};
683
- try {
684
- var _window_webapis;
685
- var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
686
- if (adinfo) {
687
- var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
688
- if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
689
- var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
690
- return _object_spread({
691
- deviceId: tifa,
692
- deviceIdType: "tifa"
693
- }, typeof lat === "boolean" ? {
694
- limitAdTracking: lat
695
- } : {});
696
- }
697
- }
698
- } catch (unused) {}
699
- try {
700
- var webOSDev = window.webOSDev;
701
- if (webOSDev) {
702
- var _webOSDev_lgudid;
703
- var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
704
- if (typeof lgudid === "string" && lgudid) {
705
- if (isZeroedAdId(lgudid)) {
706
- return {
707
- deviceIdType: "lgudid",
708
- limitAdTracking: true
709
- };
710
- }
711
- if (!isMacroPlaceholder(lgudid)) {
712
- return {
713
- deviceId: lgudid,
714
- deviceIdType: "lgudid",
715
- limitAdTracking: false
716
- };
717
- }
718
- }
719
- }
720
- } catch (unused) {}
976
+ var tifa = readSamsungTifa();
977
+ if (tifa) return tifa;
978
+ var lgudid = readCachedLgUdid();
979
+ if (lgudid) return lgudid;
721
980
  try {
722
981
  var roku = window.Roku;
723
982
  if (roku) {
@@ -744,7 +1003,7 @@ function isMacroPlaceholder(value) {
744
1003
  function validDeviceId(value) {
745
1004
  return value && !isMacroPlaceholder(value) ? value : void 0;
746
1005
  }
747
- function isZeroedAdId(value) {
1006
+ function isZeroedAdId2(value) {
748
1007
  return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
749
1008
  }
750
1009
  function readNativeBridgeSignals() {
@@ -788,7 +1047,7 @@ function readNativeBridgeSignals() {
788
1047
  "deviceIdType",
789
1048
  "advertisingIdType",
790
1049
  "idType"
791
- ]) || inferDeviceIdType();
1050
+ ]) || void 0;
792
1051
  var limitAdTracking = readBridgeBoolean(source, [
793
1052
  "is_lat",
794
1053
  "limitAdTracking",
@@ -1336,6 +1595,7 @@ function resolveScvpMacroValues(ctx) {
1336
1595
  set("GIVN", ctx.palNonce);
1337
1596
  set("CT-TI", ctx.programTitle);
1338
1597
  set("CT-CH", ctx.channelName);
1598
+ set("CT-NE", ctx.contentNetwork);
1339
1599
  set("POD", ctx.pod);
1340
1600
  set("CORRELATOR", ctx.correlator);
1341
1601
  set("SCOR", ctx.streamCorrelator);
@@ -1564,6 +1824,9 @@ function applyVastMacros(baseUrl, ctx) {
1564
1824
  if (ctx.channelName) {
1565
1825
  params.set("ct_ch", ctx.channelName);
1566
1826
  }
1827
+ if (ctx.contentNetwork) {
1828
+ params.set("ct_ne", ctx.contentNetwork);
1829
+ }
1567
1830
  var staleKeys = [];
1568
1831
  params.forEach(function(value, key) {
1569
1832
  if (isMacroPlaceholder2(value)) {
@@ -2238,8 +2501,17 @@ function detectBrowser() {
2238
2501
  chromeVersion: chromeVersionNum
2239
2502
  };
2240
2503
  }
2504
+ var singleDecoderOverride;
2505
+ function setSingleDecoderOverride(value) {
2506
+ singleDecoderOverride = value;
2507
+ }
2241
2508
  function requiresMediaPipelineResetAfterAds() {
2242
2509
  var _browser_tizenVersion;
2510
+ if (singleDecoderOverride != null) return singleDecoderOverride;
2511
+ try {
2512
+ var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2513
+ if (typeof globalOverride === "boolean") return globalOverride;
2514
+ } catch (unused) {}
2243
2515
  var browser = detectBrowser();
2244
2516
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2245
2517
  }
@@ -2422,7 +2694,7 @@ function substituteVastTrackingMacros(url) {
2422
2694
  });
2423
2695
  }
2424
2696
  // src/player/OptimizedPodRequest.ts
2425
- var DEFAULT_REQUEST_SAFETY_MS = 1500;
2697
+ var DEFAULT_REQUEST_SAFETY_MS = 2500;
2426
2698
  var GAM_AD_OPPORTUNITY_DURATION_MS = 3e4;
2427
2699
  var POD_PARAM_KEYS = [
2428
2700
  "pmnd",
@@ -2846,6 +3118,9 @@ function createHlsAdPlayer(contentVideo, options) {
2846
3118
  var mediaCandidateIndex = 0;
2847
3119
  var mediaStartTimerId;
2848
3120
  var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
3121
+ var MAX_MEDIA_START_ATTEMPTS = 2;
3122
+ var MEDIA_START_TOTAL_BUDGET_MS = Math.max(MEDIA_START_TIMEOUT_MS, 1e4);
3123
+ var mediaStartBudgetStartedAt = 0;
2849
3124
  var VAST_ERROR_MEDIA_TIMEOUT = 402;
2850
3125
  var pendingVastRequests = /* @__PURE__ */ new Set();
2851
3126
  var pendingRequestAbortReason;
@@ -4860,12 +5135,14 @@ function createHlsAdPlayer(contentVideo, options) {
4860
5135
  clearMediaStartTimer();
4861
5136
  if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
4862
5137
  var startedAt = Date.now();
5138
+ var budgetLeftMs = mediaStartBudgetStartedAt > 0 ? MEDIA_START_TOTAL_BUDGET_MS - (startedAt - mediaStartBudgetStartedAt) : MEDIA_START_TIMEOUT_MS;
5139
+ var timeoutMs = Math.max(1e3, Math.min(MEDIA_START_TIMEOUT_MS, budgetLeftMs));
4863
5140
  mediaStartTimerId = setTimeout(function() {
4864
5141
  mediaStartTimerId = void 0;
4865
5142
  if (!adPlaying || trackingFired.impression) return;
4866
- console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
5143
+ console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(timeoutMs, "ms"));
4867
5144
  logFunnel("play_resolved_but_never_started", {
4868
- timeoutMs: MEDIA_START_TIMEOUT_MS,
5145
+ timeoutMs: timeoutMs,
4869
5146
  elapsedMs: Date.now() - startedAt,
4870
5147
  readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
4871
5148
  networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
@@ -4874,7 +5151,7 @@ function createHlsAdPlayer(contentVideo, options) {
4874
5151
  vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
4875
5152
  });
4876
5153
  recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
4877
- }, MEDIA_START_TIMEOUT_MS);
5154
+ }, timeoutMs);
4878
5155
  }
4879
5156
  function resetVideoElementForNextSource() {
4880
5157
  clearStallWatchdog();
@@ -4889,6 +5166,20 @@ function createHlsAdPlayer(contentVideo, options) {
4889
5166
  function tryNextMediaCandidate() {
4890
5167
  if (!currentAd || trackingFired.impression) return false;
4891
5168
  if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
5169
+ if (mediaCandidateIndex + 1 >= MAX_MEDIA_START_ATTEMPTS) {
5170
+ logFunnel("media_fallback_capped", {
5171
+ reason: "max_attempts",
5172
+ attempts: mediaCandidateIndex + 1
5173
+ });
5174
+ return false;
5175
+ }
5176
+ if (mediaStartBudgetStartedAt > 0 && Date.now() - mediaStartBudgetStartedAt >= MEDIA_START_TOTAL_BUDGET_MS) {
5177
+ logFunnel("media_fallback_capped", {
5178
+ reason: "time_budget",
5179
+ elapsedMs: Date.now() - mediaStartBudgetStartedAt
5180
+ });
5181
+ return false;
5182
+ }
4892
5183
  var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
4893
5184
  mediaCandidateIndex++;
4894
5185
  var next = mediaCandidates[mediaCandidateIndex];
@@ -4922,6 +5213,7 @@ function createHlsAdPlayer(contentVideo, options) {
4922
5213
  }
4923
5214
  mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
4924
5215
  mediaCandidateIndex = 0;
5216
+ mediaStartBudgetStartedAt = Date.now();
4925
5217
  var mediaFile = mediaCandidates[0];
4926
5218
  if (!mediaFile) {
4927
5219
  logFunnel("media_unsupported", {
@@ -5861,6 +6153,7 @@ function getOrCreateNonceLoader(allowStorage) {
5861
6153
  }
5862
6154
  function createPalNonceManager() {
5863
6155
  var currentNonce = "";
6156
+ var currentNonceCreatedAt = 0;
5864
6157
  var currentNonceManager;
5865
6158
  var pendingNonce;
5866
6159
  return {
@@ -5877,6 +6170,9 @@ function createPalNonceManager() {
5877
6170
  getCurrentNonce: function getCurrentNonce() {
5878
6171
  return currentNonce;
5879
6172
  },
6173
+ getNonceAgeMs: function getNonceAgeMs() {
6174
+ return currentNonce ? Date.now() - currentNonceCreatedAt : void 0;
6175
+ },
5880
6176
  waitForNonce: function waitForNonce(maxWaitMs) {
5881
6177
  if (currentNonce) return Promise.resolve(currentNonce);
5882
6178
  var pending = pendingNonce;
@@ -5929,13 +6225,14 @@ function createPalNonceManager() {
5929
6225
  },
5930
6226
  reset: function reset() {
5931
6227
  currentNonce = "";
6228
+ currentNonceCreatedAt = 0;
5932
6229
  currentNonceManager = void 0;
5933
6230
  pendingNonce = void 0;
5934
6231
  }
5935
6232
  };
5936
6233
  function generate(options) {
5937
6234
  return _async_to_generator(function() {
5938
- var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, loader, goog, request, manager, error;
6235
+ var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, _options_iconsSupported, _options_supportedApiFrameworks, loader, goog, request, apiFrameworks, manager, error;
5939
6236
  return _ts_generator(this, function(_state) {
5940
6237
  switch(_state.label){
5941
6238
  case 0:
@@ -5959,10 +6256,11 @@ function createPalNonceManager() {
5959
6256
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
5960
6257
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
5961
6258
  request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5962
- request.iconsSupported = true;
6259
+ request.iconsSupported = (_options_iconsSupported = options.iconsSupported) !== null && _options_iconsSupported !== void 0 ? _options_iconsSupported : false;
5963
6260
  request.playerType = "StormcloudVideoPlayer";
5964
6261
  request.playerVersion = "1.0";
5965
- request.supportedApiFrameworks = "2,7,9";
6262
+ apiFrameworks = ((_options_supportedApiFrameworks = options.supportedApiFrameworks) !== null && _options_supportedApiFrameworks !== void 0 ? _options_supportedApiFrameworks : "").trim();
6263
+ if (apiFrameworks) request.supportedApiFrameworks = apiFrameworks;
5966
6264
  request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5967
6265
  request.videoWidth = options.videoWidth || 640;
5968
6266
  request.videoHeight = options.videoHeight || 480;
@@ -5992,6 +6290,7 @@ function createPalNonceManager() {
5992
6290
  manager = _state.sent();
5993
6291
  currentNonceManager = manager;
5994
6292
  currentNonce = manager.getNonce();
6293
+ currentNonceCreatedAt = Date.now();
5995
6294
  console.log("[PAL] Nonce generated successfully");
5996
6295
  return [
5997
6296
  2,
@@ -6015,6 +6314,549 @@ function createPalNonceManager() {
6015
6314
  })();
6016
6315
  }
6017
6316
  }
6317
+ // src/utils/deviceInfo.ts
6318
+ var CATEGORY_CODES = {
6319
+ "LG TV": "lg_tv",
6320
+ "LG Set-Top Box": "lg_stb",
6321
+ "Samsung TV": "samsung_tv",
6322
+ Other: "other"
6323
+ };
6324
+ var DEVICE_CATEGORIES = [
6325
+ "LG TV",
6326
+ "LG Set-Top Box",
6327
+ "Samsung TV",
6328
+ "Other"
6329
+ ];
6330
+ var hostDeviceInfo;
6331
+ var lgDeviceInfo;
6332
+ var platformCache;
6333
+ var primePromise;
6334
+ function cleanString(value) {
6335
+ var maxLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 128;
6336
+ if (typeof value !== "string") return void 0;
6337
+ var t = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6338
+ if (!t || /^(unknown|null|undefined|none|n\/a|-|0)$/i.test(t)) return void 0;
6339
+ return t.length > maxLength ? t.slice(0, maxLength) : t;
6340
+ }
6341
+ function safeCall2(fn, thisArg) {
6342
+ if (typeof fn !== "function") return void 0;
6343
+ try {
6344
+ return fn.call(thisArg);
6345
+ } catch (unused) {
6346
+ return void 0;
6347
+ }
6348
+ }
6349
+ function userAgent() {
6350
+ return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6351
+ }
6352
+ function bridgeSources() {
6353
+ if (typeof window === "undefined") return [];
6354
+ var w = window;
6355
+ return [
6356
+ w.__STORMCLOUD_CTV__,
6357
+ w.__STORMCLOUD_CTV_AD_INFO__,
6358
+ w.stormcloudCtv
6359
+ ].filter(Boolean);
6360
+ }
6361
+ function readBridge(keys) {
6362
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6363
+ try {
6364
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6365
+ var source = _step.value;
6366
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6367
+ try {
6368
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6369
+ var key = _step1.value;
6370
+ var value = void 0;
6371
+ try {
6372
+ value = source === null || source === void 0 ? void 0 : source[key];
6373
+ if (typeof value === "function") value = value.call(source);
6374
+ } catch (unused) {
6375
+ value = void 0;
6376
+ }
6377
+ var clean = cleanString(value);
6378
+ if (clean) return clean;
6379
+ }
6380
+ } catch (err) {
6381
+ _didIteratorError1 = true;
6382
+ _iteratorError1 = err;
6383
+ } finally{
6384
+ try {
6385
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6386
+ _iterator1.return();
6387
+ }
6388
+ } finally{
6389
+ if (_didIteratorError1) {
6390
+ throw _iteratorError1;
6391
+ }
6392
+ }
6393
+ }
6394
+ }
6395
+ } catch (err) {
6396
+ _didIteratorError = true;
6397
+ _iteratorError = err;
6398
+ } finally{
6399
+ try {
6400
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
6401
+ _iterator.return();
6402
+ }
6403
+ } finally{
6404
+ if (_didIteratorError) {
6405
+ throw _iteratorError;
6406
+ }
6407
+ }
6408
+ }
6409
+ return void 0;
6410
+ }
6411
+ function normalizeCategory(value) {
6412
+ var v = cleanString(value);
6413
+ if (!v) return void 0;
6414
+ var exact = DEVICE_CATEGORIES.find(function(c) {
6415
+ return c.toLowerCase() === v.toLowerCase();
6416
+ });
6417
+ if (exact) return exact;
6418
+ var code = v.toLowerCase().replace(/[\s-]+/g, "_");
6419
+ var byCode = Object.keys(CATEGORY_CODES).find(function(c) {
6420
+ return CATEGORY_CODES[c] === code;
6421
+ });
6422
+ return byCode;
6423
+ }
6424
+ function parseUserAgentDeviceInfo(ua) {
6425
+ var sources = [];
6426
+ var out = {
6427
+ platform: "other",
6428
+ sources: sources
6429
+ };
6430
+ var chrome = ua.match(/(?:Chrome|PCBR)\/(\d+)\./) || ua.match(/\s(\d{2,3})\.\d+\.\d+\.\d+\/[\d.]+\s+TV\b/);
6431
+ if (chrome && chrome[1]) out.browserMajorVersion = parseInt(chrome[1], 10);
6432
+ if (/Web0S|webOS/i.test(ua)) {
6433
+ out.platform = "webos";
6434
+ var lg = ua.match(/LGE\s*;\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*;\s*(\d{2}\.\d{2}\.\d{2})/);
6435
+ if (lg && lg[1] && lg[2]) {
6436
+ out.model = lg[1];
6437
+ out.firmware = lg[2];
6438
+ sources.push("user_agent");
6439
+ }
6440
+ } else if (/Tizen/i.test(ua)) {
6441
+ out.platform = "tizen";
6442
+ var tizen = ua.match(/Tizen\s+(\d+(?:\.\d+)*)/i);
6443
+ if (tizen && tizen[1]) {
6444
+ out.osVersion = "Tizen ".concat(tizen[1]);
6445
+ sources.push("user_agent");
6446
+ }
6447
+ }
6448
+ return out;
6449
+ }
6450
+ function readSamsungProductInfo() {
6451
+ var _cleanString;
6452
+ var _window_webapis;
6453
+ if (typeof window === "undefined") return void 0;
6454
+ var productinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.productinfo;
6455
+ if (!productinfo) return void 0;
6456
+ var model = (_cleanString = cleanString(safeCall2(productinfo.getRealModel, productinfo), 40)) !== null && _cleanString !== void 0 ? _cleanString : cleanString(safeCall2(productinfo.getModel, productinfo), 40);
6457
+ var firmware = cleanString(safeCall2(productinfo.getFirmware, productinfo), 64);
6458
+ var duid = cleanString(safeCall2(productinfo.getDuid, productinfo), 128);
6459
+ if (!model && !firmware && !duid) return void 0;
6460
+ return _object_spread({}, model ? {
6461
+ model: model
6462
+ } : {}, firmware ? {
6463
+ firmware: firmware
6464
+ } : {}, duid ? {
6465
+ internalDeviceId: duid,
6466
+ internalDeviceIdSource: "samsung_duid"
6467
+ } : {});
6468
+ }
6469
+ function readLgDeviceInfo(timeoutMs) {
6470
+ var webOS = typeof window !== "undefined" ? window.webOS : void 0;
6471
+ if (lgDeviceInfo || !webOS || typeof webOS.deviceInfo !== "function") return Promise.resolve();
6472
+ return new Promise(function(resolve) {
6473
+ var settled = false;
6474
+ var finish = function finish() {
6475
+ if (settled) return;
6476
+ settled = true;
6477
+ clearTimeout(timer);
6478
+ resolve();
6479
+ };
6480
+ var timer = setTimeout(finish, Math.max(0, timeoutMs));
6481
+ try {
6482
+ webOS.deviceInfo(function(info) {
6483
+ var model = cleanString(info === null || info === void 0 ? void 0 : info.modelName, 40);
6484
+ var firmware = cleanString(info === null || info === void 0 ? void 0 : info.version, 64);
6485
+ var sdkVersion = cleanString(info === null || info === void 0 ? void 0 : info.sdkVersion, 32);
6486
+ lgDeviceInfo = _object_spread({}, model ? {
6487
+ model: model
6488
+ } : {}, firmware ? {
6489
+ firmware: firmware
6490
+ } : {}, sdkVersion ? {
6491
+ sdkVersion: sdkVersion
6492
+ } : {});
6493
+ finish();
6494
+ });
6495
+ } catch (unused) {
6496
+ finish();
6497
+ }
6498
+ });
6499
+ }
6500
+ function computePlatformInfo() {
6501
+ var info = parseUserAgentDeviceInfo(userAgent());
6502
+ var sources = _to_consumable_array(info.sources);
6503
+ var samsung = readSamsungProductInfo();
6504
+ if (samsung) {
6505
+ info.platform = "tizen";
6506
+ if (samsung.model) info.model = samsung.model;
6507
+ if (samsung.firmware) info.firmware = samsung.firmware;
6508
+ if (samsung.internalDeviceId) {
6509
+ info.internalDeviceId = samsung.internalDeviceId;
6510
+ info.internalDeviceIdSource = "samsung_duid";
6511
+ }
6512
+ sources.push("samsung_productinfo");
6513
+ }
6514
+ if (lgDeviceInfo) {
6515
+ info.platform = "webos";
6516
+ if (!info.model && lgDeviceInfo.model) info.model = lgDeviceInfo.model;
6517
+ if (!info.firmware && lgDeviceInfo.firmware) info.firmware = lgDeviceInfo.firmware;
6518
+ if (lgDeviceInfo.sdkVersion) info.osVersion = "webOS TV ".concat(lgDeviceInfo.sdkVersion);
6519
+ sources.push("lg_deviceinfo");
6520
+ }
6521
+ var lgUdid = readCachedLgUdid();
6522
+ if ((lgUdid === null || lgUdid === void 0 ? void 0 : lgUdid.deviceId) && !info.internalDeviceId) {
6523
+ info.internalDeviceId = lgUdid.deviceId;
6524
+ info.internalDeviceIdSource = "lg_udid";
6525
+ sources.push("lg_udid");
6526
+ }
6527
+ info.sources = sources;
6528
+ return info;
6529
+ }
6530
+ function categorize(platform, model) {
6531
+ if (platform === "tizen") return "Samsung TV";
6532
+ if (platform === "webos") {
6533
+ var ua = userAgent();
6534
+ if (model && /^STB-/i.test(model) || /\bSTB-\d{4}|LGSTB/i.test(ua)) return "LG Set-Top Box";
6535
+ return "LG TV";
6536
+ }
6537
+ return "Other";
6538
+ }
6539
+ function setHostDeviceInfo(info) {
6540
+ hostDeviceInfo = info ? _object_spread({}, info) : void 0;
6541
+ }
6542
+ function primeDeviceInfo() {
6543
+ var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1500;
6544
+ if (!primePromise) {
6545
+ primePromise = Promise.all([
6546
+ readLgDeviceInfo(timeoutMs),
6547
+ primeLgUdid(timeoutMs)
6548
+ ]).catch(function() {
6549
+ return void 0;
6550
+ }).then(function() {
6551
+ platformCache = computePlatformInfo();
6552
+ return getDeviceInfo();
6553
+ });
6554
+ }
6555
+ return primePromise;
6556
+ }
6557
+ function getDeviceInfo() {
6558
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
6559
+ var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6560
+ if (primePromise && !platformCache) {} else {
6561
+ platformCache = platform;
6562
+ }
6563
+ var host = hostDeviceInfo !== null && hostDeviceInfo !== void 0 ? hostDeviceInfo : {};
6564
+ var bridge = {
6565
+ terminalId: readBridge([
6566
+ "terminalId",
6567
+ "terminal_id"
6568
+ ]),
6569
+ internalDeviceId: readBridge([
6570
+ "internalDeviceId",
6571
+ "internal_device_id"
6572
+ ]),
6573
+ model: readBridge([
6574
+ "deviceModel"
6575
+ ]),
6576
+ firmware: readBridge([
6577
+ "firmwareVersion"
6578
+ ]),
6579
+ category: normalizeCategory(readBridge([
6580
+ "deviceCategory"
6581
+ ]))
6582
+ };
6583
+ var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6584
+ var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
6585
+ var model = (_ref = (_cleanString2 = cleanString(host.model, 40)) !== null && _cleanString2 !== void 0 ? _cleanString2 : bridge.model) !== null && _ref !== void 0 ? _ref : platform.model;
6586
+ var firmware = (_ref1 = (_cleanString3 = cleanString(host.firmware, 64)) !== null && _cleanString3 !== void 0 ? _cleanString3 : bridge.firmware) !== null && _ref1 !== void 0 ? _ref1 : platform.firmware;
6587
+ var category = (_ref2 = (_normalizeCategory = normalizeCategory(host.category)) !== null && _normalizeCategory !== void 0 ? _normalizeCategory : bridge.category) !== null && _ref2 !== void 0 ? _ref2 : categorize(platform.platform, model);
6588
+ var sources = _to_consumable_array(platform.sources);
6589
+ var bridgeValues = [
6590
+ bridge.terminalId,
6591
+ bridge.internalDeviceId,
6592
+ bridge.model,
6593
+ bridge.firmware,
6594
+ bridge.category
6595
+ ];
6596
+ if (bridgeValues.some(function(v) {
6597
+ return v !== void 0;
6598
+ })) sources.unshift("bridge");
6599
+ if (hostDeviceInfo) sources.unshift("host");
6600
+ var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6601
+ var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
6602
+ var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6603
+ return _object_spread_props(_object_spread({
6604
+ category: category,
6605
+ categoryCode: CATEGORY_CODES[category]
6606
+ }, model ? {
6607
+ model: model
6608
+ } : {}, sonifiModel ? {
6609
+ sonifiModel: sonifiModel
6610
+ } : {}, firmware ? {
6611
+ firmware: firmware
6612
+ } : {}, platform.osVersion ? {
6613
+ osVersion: platform.osVersion
6614
+ } : {}, platform.browserMajorVersion != null ? {
6615
+ browserMajorVersion: platform.browserMajorVersion
6616
+ } : {}, internalDeviceId ? {
6617
+ internalDeviceId: internalDeviceId
6618
+ } : {}, internalDeviceId && internalDeviceIdSource ? {
6619
+ internalDeviceIdSource: internalDeviceIdSource
6620
+ } : {}, terminalId ? {
6621
+ terminalId: terminalId
6622
+ } : {}), {
6623
+ sources: sources
6624
+ });
6625
+ }
6626
+ var DEVICE_KEY_VALUE_KEYS = {
6627
+ category: "sc_dev",
6628
+ model: "sc_model",
6629
+ firmware: "sc_fw"
6630
+ };
6631
+ function sanitizeKeyValue(value) {
6632
+ if (typeof value !== "string") return void 0;
6633
+ var v = value.trim().replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "");
6634
+ return v ? v.slice(0, 40) : void 0;
6635
+ }
6636
+ function deviceKeyValuePairs(info) {
6637
+ var pairs = [
6638
+ [
6639
+ DEVICE_KEY_VALUE_KEYS.category,
6640
+ info.categoryCode
6641
+ ]
6642
+ ];
6643
+ var model = sanitizeKeyValue(info.model);
6644
+ var firmware = sanitizeKeyValue(info.firmware);
6645
+ if (model) pairs.push([
6646
+ DEVICE_KEY_VALUE_KEYS.model,
6647
+ model
6648
+ ]);
6649
+ if (firmware) pairs.push([
6650
+ DEVICE_KEY_VALUE_KEYS.firmware,
6651
+ firmware
6652
+ ]);
6653
+ return pairs;
6654
+ }
6655
+ function applyDeviceKeyValues(url, info) {
6656
+ try {
6657
+ var parsed = new URL(url);
6658
+ var pairs = deviceKeyValuePairs(info);
6659
+ var ours = new Set(pairs.map(function(param) {
6660
+ var _param = _sliced_to_array(param, 1), k = _param[0];
6661
+ return k;
6662
+ }));
6663
+ var existing = (parsed.searchParams.get("cust_params") || "").split("&").filter(function(p) {
6664
+ var _p_split_;
6665
+ return p !== "" && !ours.has((_p_split_ = p.split("=")[0]) !== null && _p_split_ !== void 0 ? _p_split_ : "");
6666
+ });
6667
+ var merged = existing.concat(pairs.map(function(param) {
6668
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
6669
+ return "".concat(k, "=").concat(v);
6670
+ })).join("&");
6671
+ parsed.searchParams.set("cust_params", merged);
6672
+ return parsed.toString();
6673
+ } catch (unused) {
6674
+ return url;
6675
+ }
6676
+ }
6677
+ function deviceInfoAnalyticsFields(info) {
6678
+ return _object_spread({
6679
+ device_category: info.category
6680
+ }, info.model ? {
6681
+ device_model: info.model
6682
+ } : {}, info.sonifiModel ? {
6683
+ sonifi_model: info.sonifiModel
6684
+ } : {}, info.firmware ? {
6685
+ firmware_version: info.firmware
6686
+ } : {}, info.osVersion ? {
6687
+ os_version: info.osVersion
6688
+ } : {}, info.browserMajorVersion != null ? {
6689
+ browser_major_version: info.browserMajorVersion
6690
+ } : {}, info.internalDeviceId ? {
6691
+ internal_device_id: info.internalDeviceId
6692
+ } : {}, info.internalDeviceIdSource ? {
6693
+ internal_device_id_source: info.internalDeviceIdSource
6694
+ } : {}, info.terminalId ? {
6695
+ terminal_id: info.terminalId
6696
+ } : {});
6697
+ }
6698
+ // src/utils/contentMetadata.ts
6699
+ var MAX_CONTENT_VALUE_LENGTH = 128;
6700
+ var BRIDGE_KEYS = {
6701
+ channelName: [
6702
+ "channelName",
6703
+ "ct_ch"
6704
+ ],
6705
+ programTitle: [
6706
+ "programTitle",
6707
+ "ct_ti"
6708
+ ],
6709
+ contentNetwork: [
6710
+ "contentNetwork",
6711
+ "ct_ne"
6712
+ ]
6713
+ };
6714
+ function sanitizeContentValue(value) {
6715
+ if (typeof value !== "string") return void 0;
6716
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6717
+ if (!cleaned) return void 0;
6718
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6719
+ if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6720
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6721
+ }
6722
+ function bridgeSources2() {
6723
+ if (typeof window === "undefined") return [];
6724
+ var w = window;
6725
+ return [
6726
+ w.__STORMCLOUD_CTV__,
6727
+ w.__STORMCLOUD_CTV_AD_INFO__,
6728
+ w.stormcloudCtv
6729
+ ].filter(Boolean);
6730
+ }
6731
+ function readBridgeContentValue(keys) {
6732
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6733
+ try {
6734
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6735
+ var source = _step.value;
6736
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6737
+ try {
6738
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6739
+ var key = _step1.value;
6740
+ var value = void 0;
6741
+ try {
6742
+ value = source === null || source === void 0 ? void 0 : source[key];
6743
+ if (typeof value === "function") value = value.call(source);
6744
+ } catch (unused) {
6745
+ value = void 0;
6746
+ }
6747
+ var sanitized = sanitizeContentValue(value);
6748
+ if (sanitized) return sanitized;
6749
+ }
6750
+ } catch (err) {
6751
+ _didIteratorError1 = true;
6752
+ _iteratorError1 = err;
6753
+ } finally{
6754
+ try {
6755
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6756
+ _iterator1.return();
6757
+ }
6758
+ } finally{
6759
+ if (_didIteratorError1) {
6760
+ throw _iteratorError1;
6761
+ }
6762
+ }
6763
+ }
6764
+ }
6765
+ } catch (err) {
6766
+ _didIteratorError = true;
6767
+ _iteratorError = err;
6768
+ } finally{
6769
+ try {
6770
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
6771
+ _iterator.return();
6772
+ }
6773
+ } finally{
6774
+ if (_didIteratorError) {
6775
+ throw _iteratorError;
6776
+ }
6777
+ }
6778
+ }
6779
+ return void 0;
6780
+ }
6781
+ function resolveContentMetadata(config) {
6782
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
6783
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
6784
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
6785
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
6786
+ return _object_spread({}, channelName ? {
6787
+ channelName: channelName
6788
+ } : {}, programTitle ? {
6789
+ programTitle: programTitle
6790
+ } : {}, contentNetwork ? {
6791
+ contentNetwork: contentNetwork
6792
+ } : {});
6793
+ }
6794
+ function appendMissingContentParams(url, meta) {
6795
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
6796
+ try {
6797
+ var parsed = new URL(url);
6798
+ var add = function add(key, value) {
6799
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
6800
+ };
6801
+ add("ct_ch", meta.channelName);
6802
+ add("ct_ti", meta.programTitle);
6803
+ add("ct_ne", meta.contentNetwork);
6804
+ return parsed.toString();
6805
+ } catch (unused) {
6806
+ return url;
6807
+ }
6808
+ }
6809
+ // src/utils/screenActivity.ts
6810
+ var hostStandby = false;
6811
+ function setHostStandby(standby) {
6812
+ hostStandby = !!standby;
6813
+ }
6814
+ function toBoolean(value) {
6815
+ if (typeof value === "boolean") return value;
6816
+ if (typeof value === "number") return value === 1;
6817
+ if (typeof value === "string") {
6818
+ var v = value.trim().toLowerCase();
6819
+ if (v === "true" || v === "1" || v === "yes") return true;
6820
+ if (v === "false" || v === "0" || v === "no") return false;
6821
+ }
6822
+ return void 0;
6823
+ }
6824
+ function bridgeSaysStandby() {
6825
+ if (typeof window === "undefined") return false;
6826
+ var w = window;
6827
+ for(var _i = 0, _iter = [
6828
+ w.__STORMCLOUD_CTV__,
6829
+ w.__STORMCLOUD_CTV_AD_INFO__,
6830
+ w.stormcloudCtv
6831
+ ]; _i < _iter.length; _i++){
6832
+ var source = _iter[_i];
6833
+ if (!source) continue;
6834
+ for(var _i1 = 0, _iter1 = [
6835
+ "standby",
6836
+ "isStandby",
6837
+ "screenOff"
6838
+ ]; _i1 < _iter1.length; _i1++){
6839
+ var key = _iter1[_i1];
6840
+ var value = void 0;
6841
+ try {
6842
+ value = source[key];
6843
+ if (typeof value === "function") value = value.call(source);
6844
+ } catch (unused) {
6845
+ value = void 0;
6846
+ }
6847
+ if (toBoolean(value) === true) return true;
6848
+ }
6849
+ }
6850
+ return false;
6851
+ }
6852
+ function getScreenInactiveReason() {
6853
+ if (hostStandby) return "host_standby";
6854
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
6855
+ return "document_hidden";
6856
+ }
6857
+ if (bridgeSaysStandby()) return "bridge_standby";
6858
+ return void 0;
6859
+ }
6018
6860
  // src/utils/trackingIngest.ts
6019
6861
  var DEFAULT_TRACKING_INGEST_CONFIG = {
6020
6862
  enabled: true,
@@ -6102,20 +6944,25 @@ function ingestPlayerTracking(licenseKey, channel, body) {
6102
6944
  // src/utils/tracking.ts
6103
6945
  var cachedBrowserId = null;
6104
6946
  function buildAnalyticsContext(config) {
6105
- var _config_contentNetwork, _config_channelName, _config_programTitle;
6947
+ var _config_contentNetwork, _config_channelName, _config_programTitle, _config_src;
6106
6948
  var context = {};
6107
6949
  var contentNetwork = (_config_contentNetwork = config.contentNetwork) === null || _config_contentNetwork === void 0 ? void 0 : _config_contentNetwork.trim();
6108
6950
  var contentChannel = (_config_channelName = config.channelName) === null || _config_channelName === void 0 ? void 0 : _config_channelName.trim();
6109
6951
  var contentTitle = (_config_programTitle = config.programTitle) === null || _config_programTitle === void 0 ? void 0 : _config_programTitle.trim();
6952
+ var hlsUrl = (_config_src = config.src) === null || _config_src === void 0 ? void 0 : _config_src.trim();
6110
6953
  if (contentNetwork) context.contentNetwork = contentNetwork;
6111
6954
  if (contentChannel) context.contentChannel = contentChannel;
6112
6955
  if (contentTitle) context.contentTitle = contentTitle;
6956
+ if (hlsUrl) context.hlsUrl = hlsUrl;
6113
6957
  if (config.debugAdTiming) {
6114
6958
  context.debugAdTiming = true;
6115
6959
  }
6116
6960
  if (config.isLiveStream !== void 0) {
6117
6961
  context.inputStreamType = config.isLiveStream ? "live" : "vod";
6118
6962
  }
6963
+ if (config.sendDeviceInfoToAnalytics) {
6964
+ context.includeDeviceInfo = true;
6965
+ }
6119
6966
  return context;
6120
6967
  }
6121
6968
  function getClientInfo() {
@@ -6411,7 +7258,7 @@ function buildPlayerMetricEvent() {
6411
7258
  capture_at: captureAt
6412
7259
  }, context.inputStreamType ? {
6413
7260
  input_stream_type: context.inputStreamType
6414
- } : {})
7261
+ } : {}, context.includeDeviceInfo ? deviceInfoAnalyticsFields(getDeviceInfo()) : {})
6415
7262
  ];
6416
7263
  }
6417
7264
  });
@@ -6615,6 +7462,8 @@ function sendAdImpressionTracking(_0, _1) {
6615
7462
  content_channel: context.contentChannel
6616
7463
  } : {}, context.contentTitle ? {
6617
7464
  content_title: context.contentTitle
7465
+ } : {}, context.hlsUrl ? {
7466
+ hls_url: context.hlsUrl
6618
7467
  } : {})
6619
7468
  ]
6620
7469
  })
@@ -8442,7 +9291,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
8442
9291
  key: "generatePodVastUrl",
8443
9292
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
8444
9293
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
8445
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
9294
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9295
+ fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9296
+ sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9297
+ });
9298
+ var content = resolveContentMetadata(this.config);
8446
9299
  var macroContext = _object_spread_props(_object_spread({
8447
9300
  correlator: this.viewCorrelator,
8448
9301
  streamCorrelator: this.streamCorrelator,
@@ -8457,10 +9310,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
8457
9310
  limitAdTracking: envSignals.limitAdTracking,
8458
9311
  deviceTypeHint: envSignals.deviceTypeHint,
8459
9312
  adTest: this.config.adTest
8460
- }, this.config.programTitle ? {
8461
- programTitle: this.config.programTitle
8462
- } : {}, this.config.channelName ? {
8463
- channelName: this.config.channelName
9313
+ }, content.programTitle ? {
9314
+ programTitle: content.programTitle
9315
+ } : {}, content.channelName ? {
9316
+ channelName: content.channelName
9317
+ } : {}, content.contentNetwork ? {
9318
+ contentNetwork: content.contentNetwork
8464
9319
  } : {}), {
8465
9320
  consent: this.consentSignals,
8466
9321
  palNonce: palNonce.getCurrentNonce() || void 0
@@ -8478,6 +9333,24 @@ var AdConfigManager = /*#__PURE__*/ function() {
8478
9333
  } else {
8479
9334
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
8480
9335
  }
9336
+ finalUrl = appendMissingContentParams(finalUrl, content);
9337
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9338
+ finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9339
+ }
9340
+ if (this.debug) {
9341
+ var id = envSignals.deviceId;
9342
+ console.log("[AD-IDENTITY]", {
9343
+ source: envSignals.deviceIdSource,
9344
+ idtype: envSignals.deviceIdType,
9345
+ rdidTail: id ? id.slice(-4) : void 0,
9346
+ isLat: envSignals.limitAdTracking,
9347
+ dth: envSignals.deviceTypeHint,
9348
+ sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9349
+ ct_ch: content.channelName,
9350
+ ct_ti: content.programTitle,
9351
+ ct_ne: content.contentNetwork
9352
+ });
9353
+ }
8481
9354
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
8482
9355
  return finalUrl;
8483
9356
  }
@@ -8529,7 +9402,6 @@ var AdConfigManager = /*#__PURE__*/ function() {
8529
9402
  }
8530
9403
  },
8531
9404
  {
8532
- // --- Tracking ---
8533
9405
  key: "initializeTracking",
8534
9406
  value: function initializeTracking() {
8535
9407
  var _this = this;
@@ -8622,7 +9494,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8622
9494
  }
8623
9495
  },
8624
9496
  {
8625
- // --- Ad stop timer ---
8626
9497
  key: "scheduleAdStopCountdown",
8627
9498
  value: function scheduleAdStopCountdown(remainingMs) {
8628
9499
  var _this = this;
@@ -8654,7 +9525,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8654
9525
  }
8655
9526
  },
8656
9527
  {
8657
- // --- Ad start timer ---
8658
9528
  key: "scheduleAdStartIn",
8659
9529
  value: function scheduleAdStartIn(delayMs) {
8660
9530
  var _this = this;
@@ -8682,7 +9552,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8682
9552
  }
8683
9553
  },
8684
9554
  {
8685
- // --- PTS drift ---
8686
9555
  key: "updatePtsDrift",
8687
9556
  value: function updatePtsDrift(ptsSecondsSample) {
8688
9557
  var sampleMs = (this.video.currentTime - ptsSecondsSample) * 1e3;
@@ -8708,7 +9577,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8708
9577
  }
8709
9578
  },
8710
9579
  {
8711
- // --- Duration boundary ---
8712
9580
  key: "beginBreakTiming",
8713
9581
  value: function beginBreakTiming(startWallClockMs) {
8714
9582
  this.currentAdBreakStartWallClockMs = startWallClockMs;
@@ -8756,7 +9624,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8756
9624
  }
8757
9625
  },
8758
9626
  {
8759
- // --- Duration budget ---
8760
9627
  key: "getWallClockRemainingAdMs",
8761
9628
  value: function getWallClockRemainingAdMs() {
8762
9629
  var endWallClockMs = this.getAdBreakEndWallClockMs();
@@ -8905,7 +9772,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8905
9772
  }
8906
9773
  },
8907
9774
  {
8908
- // --- Circuit breaker ---
8909
9775
  key: "isTemporaryAdError",
8910
9776
  value: function isTemporaryAdError(error) {
8911
9777
  var _error_message;
@@ -9039,7 +9905,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9039
9905
  }
9040
9906
  },
9041
9907
  {
9042
- // --- Watchdog ---
9043
9908
  key: "startAdRequestWatchdog",
9044
9909
  value: function startAdRequestWatchdog(token) {
9045
9910
  var _this = this;
@@ -9084,7 +9949,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9084
9949
  }
9085
9950
  },
9086
9951
  {
9087
- // --- Failsafe ---
9088
9952
  key: "startAdFailsafeTimer",
9089
9953
  value: function startAdFailsafeTimer(token) {
9090
9954
  var _this = this;
@@ -9146,7 +10010,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9146
10010
  }
9147
10011
  },
9148
10012
  {
9149
- // --- Reset for ad break end ---
9150
10013
  key: "resetForBreakEnd",
9151
10014
  value: function resetForBreakEnd() {
9152
10015
  this.clearAdStopTimer();
@@ -9347,7 +10210,7 @@ var HlsEngine = /*#__PURE__*/ function() {
9347
10210
  adBehavior: adBehavior
9348
10211
  });
9349
10212
  }
9350
- if (!this.config.autoplay) return [
10213
+ if (!(this.config.autoplay && !this.callbacks.shouldHoldContentForAds())) return [
9351
10214
  3,
9352
10215
  2
9353
10216
  ];
@@ -9538,6 +10401,12 @@ var HlsEngine = /*#__PURE__*/ function() {
9538
10401
  2
9539
10402
  ];
9540
10403
  this.hasInitialBufferCompleted = true;
10404
+ if (this.shouldAutoplayAfterBuffering && this.callbacks.shouldHoldContentForAds()) {
10405
+ this.shouldAutoplayAfterBuffering = false;
10406
+ if (this.debug) {
10407
+ console.log("[StormcloudVideoPlayer] Buffer ready during an ad break; content stays paused until the break ends");
10408
+ }
10409
+ }
9541
10410
  if (!this.shouldAutoplayAfterBuffering) return [
9542
10411
  3,
9543
10412
  2
@@ -10196,9 +11065,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10196
11065
  }
10197
11066
  },
10198
11067
  {
10199
- // ───────────────────────────────────────────────────────────────
10200
- // IMA event listeners
10201
- // ───────────────────────────────────────────────────────────────
10202
11068
  key: "nextAdRequestUrl",
10203
11069
  value: function nextAdRequestUrl(baseVastUrl) {
10204
11070
  return this.host.generatePodVastUrl(baseVastUrl);
@@ -10434,9 +11300,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10434
11300
  }
10435
11301
  },
10436
11302
  {
10437
- // ───────────────────────────────────────────────────────────────
10438
- // Ad break start
10439
- // ───────────────────────────────────────────────────────────────
10440
11303
  key: "isBreakActive",
10441
11304
  value: function isBreakActive() {
10442
11305
  return this.slotState !== "IDLE";
@@ -10464,7 +11327,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10464
11327
  key: "handleAdStart",
10465
11328
  value: function handleAdStart(marker) {
10466
11329
  return _async_to_generator(function() {
10467
- var baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
11330
+ var screenInactiveReason, baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
10468
11331
  return _ts_generator(this, function(_state) {
10469
11332
  switch(_state.label){
10470
11333
  case 0:
@@ -10477,6 +11340,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10477
11340
  2
10478
11341
  ];
10479
11342
  }
11343
+ screenInactiveReason = getScreenInactiveReason();
11344
+ if (screenInactiveReason) {
11345
+ this.logOrchestratorFunnel("break_skipped_screen_inactive", {
11346
+ reason: screenInactiveReason
11347
+ });
11348
+ this.clearPendingAdBreak();
11349
+ return [
11350
+ 2
11351
+ ];
11352
+ }
10480
11353
  baseVastUrl = this.adConfig.apiVastTagUrl;
10481
11354
  edgeConfigured = !!this.host.getEdgePodBaseUrl();
10482
11355
  if (!baseVastUrl && !edgeConfigured) {
@@ -10637,12 +11510,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10637
11510
  },
10638
11511
  {
10639
11512
  key: "startOptimizedPod",
10640
- value: // ───────────────────────────────────────────────────────────────
10641
- // Optimized pod (single multi-ad request)
10642
- // ───────────────────────────────────────────────────────────────
10643
- function startOptimizedPod(baseVastUrl) {
11513
+ value: function startOptimizedPod(baseVastUrl) {
10644
11514
  return _async_to_generator(function() {
10645
- var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, error;
11515
+ var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, _this_host_config_maxAdBreakExtensionMs, remainingMs, overrunAllowanceMs, maxAdsCap, maxAds, error;
10646
11516
  return _ts_generator(this, function(_state) {
10647
11517
  switch(_state.label){
10648
11518
  case 0:
@@ -10750,6 +11620,26 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10750
11620
  false
10751
11621
  ];
10752
11622
  }
11623
+ if (this.isBreakTimeBounded() && adPlayer.limitPodToBudget) {
11624
+ ;
11625
+ remainingMs = this.timing.getRemainingAdMs();
11626
+ overrunAllowanceMs = Math.max(0, (_this_host_config_maxAdBreakExtensionMs = this.host.config.maxAdBreakExtensionMs) !== null && _this_host_config_maxAdBreakExtensionMs !== void 0 ? _this_host_config_maxAdBreakExtensionMs : 0);
11627
+ maxAdsCap = this.adConfig.resolveAdPodConfig().maxAdsPerBreak;
11628
+ maxAds = maxAdsCap != null ? Math.max(1, maxAdsCap - this.timing.totalAdsInBreak) : Number.MAX_SAFE_INTEGER;
11629
+ if (Number.isFinite(remainingMs)) {
11630
+ podCount = adPlayer.limitPodToBudget(remainingMs + overrunAllowanceMs, maxAds);
11631
+ if (podCount < 1) {
11632
+ if (this.timing.activeAdRequestToken === requestToken) {
11633
+ this.timing.activeAdRequestToken = null;
11634
+ }
11635
+ this.recordRequestFailure(new Error("No GAM ad fits the ".concat(Math.round(remainingMs), "ms left in the break")), podUrl);
11636
+ return [
11637
+ 2,
11638
+ false
11639
+ ];
11640
+ }
11641
+ }
11642
+ }
10753
11643
  this.setSlotState("READY", "vast_ready");
10754
11644
  if (this.debug) {
10755
11645
  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"));
@@ -10819,9 +11709,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10819
11709
  }
10820
11710
  },
10821
11711
  {
10822
- // ───────────────────────────────────────────────────────────────
10823
- // Edge-first pods (live SCTE-35 only, GAM fallback)
10824
- // ───────────────────────────────────────────────────────────────
10825
11712
  key: "resetEdgeStateForBreak",
10826
11713
  value: function resetEdgeStateForBreak() {
10827
11714
  this.edgeExhaustedForBreak = false;
@@ -11039,9 +11926,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11039
11926
  }
11040
11927
  },
11041
11928
  {
11042
- // ───────────────────────────────────────────────────────────────
11043
- // Next-ad scheduling (single flight)
11044
- // ───────────────────────────────────────────────────────────────
11045
11929
  key: "setSlotState",
11046
11930
  value: function setSlotState(next, reason) {
11047
11931
  if (this.slotState === next) return;
@@ -11091,6 +11975,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11091
11975
  {
11092
11976
  key: "getStopRequestingReason",
11093
11977
  value: function getStopRequestingReason(remainingMs) {
11978
+ var screenInactiveReason = getScreenInactiveReason();
11979
+ if (screenInactiveReason) return "screen_inactive:".concat(screenInactiveReason);
11094
11980
  if (this.breakSource === "vmap") {
11095
11981
  if (this.adPodQueue.length === 0) return "vmap_queue_empty";
11096
11982
  } else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl && !this.canRequestEdge()) {
@@ -11364,9 +12250,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11364
12250
  }
11365
12251
  },
11366
12252
  {
11367
- // ───────────────────────────────────────────────────────────────
11368
- // Per-request diagnostics
11369
- // ───────────────────────────────────────────────────────────────
11370
12253
  key: "recordRequestDiagnostic",
11371
12254
  value: function recordRequestDiagnostic(payload) {
11372
12255
  var requestId = payload.requestId;
@@ -11440,9 +12323,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11440
12323
  }
11441
12324
  },
11442
12325
  {
11443
- // ───────────────────────────────────────────────────────────────
11444
- // Single ad playback
11445
- // ───────────────────────────────────────────────────────────────
11446
12326
  key: "createGamDispatchFinalizer",
11447
12327
  value: function createGamDispatchFinalizer(requestToken) {
11448
12328
  var _this = this;
@@ -11905,9 +12785,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11905
12785
  }
11906
12786
  },
11907
12787
  {
11908
- // ───────────────────────────────────────────────────────────────
11909
- // Ad break completion
11910
- // ───────────────────────────────────────────────────────────────
11911
12788
  key: "logBreakFunnel",
11912
12789
  value: function logBreakFunnel(endReason) {
11913
12790
  var funnel = this.breakFunnel;
@@ -12554,6 +13431,8 @@ var ContentHealthWatchdog = /*#__PURE__*/ function() {
12554
13431
  return ContentHealthWatchdog;
12555
13432
  }();
12556
13433
  // src/player/StormcloudVideoPlayer.ts
13434
+ var DEFAULT_PAL_NONCE_MAX_AGE_MS = 5.5 * 60 * 60 * 1e3;
13435
+ var PAL_NONCE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
12557
13436
  var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12558
13437
  "use strict";
12559
13438
  function StormcloudVideoPlayer(config) {
@@ -12565,6 +13444,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12565
13444
  var browserOverrides = getBrowserConfigOverrides();
12566
13445
  this.config = _object_spread({}, browserOverrides, config);
12567
13446
  this.video = config.videoElement;
13447
+ if (this.config.forceSingleDecoderMode != null) {
13448
+ setSingleDecoderOverride(this.config.forceSingleDecoderMode);
13449
+ }
13450
+ if (this.config.adDeviceId) {
13451
+ setHostAdIdentity({
13452
+ deviceId: this.config.adDeviceId,
13453
+ deviceIdType: this.config.adDeviceIdType,
13454
+ limitAdTracking: this.config.adLimitAdTracking
13455
+ });
13456
+ }
13457
+ if (this.config.deviceInfo) {
13458
+ setHostDeviceInfo(this.config.deviceInfo);
13459
+ }
12568
13460
  logBrowserInfo(config.debugAdTiming);
12569
13461
  this.floorLadder = new FloorLadderController();
12570
13462
  this.adPlayer = this.createAdPlayer(false);
@@ -12628,6 +13520,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12628
13520
  },
12629
13521
  hasPendingAdBreak: function hasPendingAdBreak() {
12630
13522
  return _this.adBreak.pendingAdBreak !== null;
13523
+ },
13524
+ shouldHoldContentForAds: function shouldHoldContentForAds() {
13525
+ return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
12631
13526
  }
12632
13527
  });
12633
13528
  this.adBreak = new AdBreakOrchestrator({
@@ -12823,10 +13718,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12823
13718
  },
12824
13719
  {
12825
13720
  key: "load",
12826
- value: // ───────────────────────────────────────────────────────────────
12827
- // Lifecycle
12828
- // ───────────────────────────────────────────────────────────────
12829
- function load() {
13721
+ value: function load() {
12830
13722
  return _async_to_generator(function() {
12831
13723
  var _this, error, palDescriptionUrl, continueLiveStreamDuringAds;
12832
13724
  return _ts_generator(this, function(_state) {
@@ -12836,6 +13728,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12836
13728
  if (!this.attached) {
12837
13729
  this.attach();
12838
13730
  }
13731
+ primeDeviceInfo().then(function(info) {
13732
+ if (_this.debug) {
13733
+ console.log("[DEVICE-INFO]", _object_spread_props(_object_spread({}, info), {
13734
+ internalDeviceId: info.internalDeviceId ? "...".concat(info.internalDeviceId.slice(-4)) : void 0
13735
+ }));
13736
+ }
13737
+ }).catch(function() {});
12839
13738
  _state.label = 1;
12840
13739
  case 1:
12841
13740
  _state.trys.push([
@@ -12870,21 +13769,30 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12870
13769
  fetchConsentSignals().catch(function() {
12871
13770
  return {};
12872
13771
  }).then(function(signals) {
12873
- var _this_config_lowLatencyMode;
13772
+ var _this_config_palContinuousPlayback, _this_config_lowLatencyMode, _this_config_palIconsSupported, _this_config_palSupportedApiFrameworks;
12874
13773
  _this.adConfig.consentSignals = signals;
12875
13774
  var muted = _this.video.muted;
12876
- return _this.palNonce.generateNonce(_object_spread({
13775
+ var palSessionId = _this.config.ctvAdRequest ? getOrRotateSessionId(_this.config.sessionIdMaxAgeMs) : void 0;
13776
+ var palOptions = _object_spread({
12877
13777
  videoWidth: _this.video.offsetWidth || _this.video.clientWidth || 640,
12878
13778
  videoHeight: _this.video.offsetHeight || _this.video.clientHeight || 480,
12879
13779
  adWillAutoPlay: !!_this.config.autoplay,
12880
13780
  adWillPlayMuted: muted,
12881
13781
  playerVolume: muted ? 0 : _this.video.volume,
12882
- continuousPlayback: (_this_config_lowLatencyMode = _this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
13782
+ continuousPlayback: (_this_config_palContinuousPlayback = _this.config.palContinuousPlayback) !== null && _this_config_palContinuousPlayback !== void 0 ? _this_config_palContinuousPlayback : _this.config.ctvAdRequest ? true : (_this_config_lowLatencyMode = _this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false,
13783
+ iconsSupported: (_this_config_palIconsSupported = _this.config.palIconsSupported) !== null && _this_config_palIconsSupported !== void 0 ? _this_config_palIconsSupported : false,
13784
+ supportedApiFrameworks: (_this_config_palSupportedApiFrameworks = _this.config.palSupportedApiFrameworks) !== null && _this_config_palSupportedApiFrameworks !== void 0 ? _this_config_palSupportedApiFrameworks : ""
12883
13785
  }, palDescriptionUrl ? {
12884
13786
  descriptionUrl: palDescriptionUrl
12885
13787
  } : {}, signals.storageAllowed != null ? {
12886
13788
  allowStorage: signals.storageAllowed
12887
- } : {}));
13789
+ } : {}, palSessionId ? {
13790
+ sessionId: palSessionId
13791
+ } : {});
13792
+ _this.lastPalOptions = palOptions;
13793
+ _this.palSessionId = palSessionId;
13794
+ _this.startPalNonceRefresh();
13795
+ return _this.palNonce.generateNonce(palOptions);
12888
13796
  }).catch(function() {});
12889
13797
  this.adConfig.initializeTracking();
12890
13798
  if (!this.hlsEngine.shouldUseNativeHls(function() {
@@ -12922,6 +13830,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12922
13830
  }).call(this);
12923
13831
  }
12924
13832
  },
13833
+ {
13834
+ key: "startPalNonceRefresh",
13835
+ value: function startPalNonceRefresh() {
13836
+ var _this = this;
13837
+ if (this.palRefreshTimer != null || typeof window === "undefined") return;
13838
+ this.palRefreshTimer = window.setInterval(function() {
13839
+ return _this.refreshPalNonceIfStale();
13840
+ }, PAL_NONCE_CHECK_INTERVAL_MS);
13841
+ }
13842
+ },
13843
+ {
13844
+ key: "refreshPalNonceIfStale",
13845
+ value: function refreshPalNonceIfStale() {
13846
+ var force = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
13847
+ var _this_config_palNonceMaxAgeMs;
13848
+ var options = this.lastPalOptions;
13849
+ if (!options) return;
13850
+ var maxAgeMs = (_this_config_palNonceMaxAgeMs = this.config.palNonceMaxAgeMs) !== null && _this_config_palNonceMaxAgeMs !== void 0 ? _this_config_palNonceMaxAgeMs : DEFAULT_PAL_NONCE_MAX_AGE_MS;
13851
+ var ageMs = this.palNonce.getNonceAgeMs();
13852
+ var sessionId = this.config.ctvAdRequest ? getOrRotateSessionId(this.config.sessionIdMaxAgeMs) : void 0;
13853
+ var sessionChanged = sessionId !== this.palSessionId;
13854
+ var stale = ageMs === void 0 || ageMs >= maxAgeMs;
13855
+ if (!force && !stale && !sessionChanged) return;
13856
+ var next = _object_spread({}, options);
13857
+ if (sessionId) next.sessionId = sessionId;
13858
+ else delete next.sessionId;
13859
+ this.lastPalOptions = next;
13860
+ this.palSessionId = sessionId;
13861
+ if (this.debug) {
13862
+ console.log("[PAL] Regenerating nonce", {
13863
+ force: force,
13864
+ stale: stale,
13865
+ sessionChanged: sessionChanged,
13866
+ ageMs: ageMs
13867
+ });
13868
+ }
13869
+ this.palNonce.generateNonce(next).catch(function() {});
13870
+ }
13871
+ },
13872
+ {
13873
+ key: "setAdIdentity",
13874
+ value: function setAdIdentity(identity) {
13875
+ setHostAdIdentity(identity);
13876
+ this.refreshPalNonceIfStale();
13877
+ }
13878
+ },
13879
+ {
13880
+ key: "resetAdIdentity",
13881
+ value: function resetAdIdentity1() {
13882
+ resetAdIdentity();
13883
+ this.refreshPalNonceIfStale(true);
13884
+ }
13885
+ },
13886
+ {
13887
+ key: "setContentMetadata",
13888
+ value: function setContentMetadata(meta) {
13889
+ var _this = this;
13890
+ var apply = function apply(key, value) {
13891
+ if (value === void 0) return;
13892
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
13893
+ if (clean) _this.config[key] = clean;
13894
+ else delete _this.config[key];
13895
+ };
13896
+ apply("channelName", meta.channelName);
13897
+ apply("programTitle", meta.programTitle);
13898
+ apply("contentNetwork", meta.contentNetwork);
13899
+ }
13900
+ },
13901
+ {
13902
+ key: "setScreenStandby",
13903
+ value: function setScreenStandby(standby) {
13904
+ setHostStandby(standby);
13905
+ }
13906
+ },
13907
+ {
13908
+ key: "getDeviceInfo",
13909
+ value: function getDeviceInfo1() {
13910
+ return getDeviceInfo();
13911
+ }
13912
+ },
13913
+ {
13914
+ key: "setDeviceInfo",
13915
+ value: function setDeviceInfo(info) {
13916
+ setHostDeviceInfo(info);
13917
+ }
13918
+ },
12925
13919
  {
12926
13920
  key: "onManifestParsed",
12927
13921
  value: function onManifestParsed(isLive) {
@@ -13056,9 +14050,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13056
14050
  }
13057
14051
  },
13058
14052
  {
13059
- // ───────────────────────────────────────────────────────────────
13060
- // SCTE-35 marker orchestration
13061
- // ───────────────────────────────────────────────────────────────
13062
14053
  key: "onScte35Marker",
13063
14054
  value: function onScte35Marker(marker, cueKey) {
13064
14055
  if (this.debug) {
@@ -13237,9 +14228,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13237
14228
  }
13238
14229
  },
13239
14230
  {
13240
- // ───────────────────────────────────────────────────────────────
13241
- // Ad prefetch
13242
- // ───────────────────────────────────────────────────────────────
13243
14231
  key: "startAdPrefetch",
13244
14232
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
13245
14233
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
@@ -13278,9 +14266,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13278
14266
  }
13279
14267
  },
13280
14268
  {
13281
- // ───────────────────────────────────────────────────────────────
13282
- // VMAP time-based ad breaks
13283
- // ───────────────────────────────────────────────────────────────
13284
14269
  key: "onTimeUpdate",
13285
14270
  value: function onTimeUpdate(currentTimeSec) {
13286
14271
  var _this = this;
@@ -13394,9 +14379,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13394
14379
  }
13395
14380
  },
13396
14381
  {
13397
- // ───────────────────────────────────────────────────────────────
13398
- // Public API
13399
- // ───────────────────────────────────────────────────────────────
13400
14382
  key: "getCurrentAdIndex",
13401
14383
  value: function getCurrentAdIndex() {
13402
14384
  return this.timing.currentAdIndex;
@@ -13515,12 +14497,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13515
14497
  }
13516
14498
  },
13517
14499
  {
13518
- // ───────────────────────────────────────────────────────────────
13519
- // Destroy
13520
- // ───────────────────────────────────────────────────────────────
13521
14500
  key: "destroy",
13522
14501
  value: function destroy() {
13523
14502
  var _this_adPlayer;
14503
+ if (this.palRefreshTimer != null) {
14504
+ clearInterval(this.palRefreshTimer);
14505
+ this.palRefreshTimer = void 0;
14506
+ }
13524
14507
  this.contentWatchdog.stop();
13525
14508
  this.adBreak.cancelScheduledRequest();
13526
14509
  this.timing.destroy();
@@ -13628,7 +14611,7 @@ var CRITICAL_PROPS = [
13628
14611
  var CONTROLS_HIDE_DELAY = 3e3;
13629
14612
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
13630
14613
  var StormcloudVideoPlayerComponent = React.memo(function(props) {
13631
- 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, restVideoAttrs = _object_without_properties(props, [
14614
+ 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, [
13632
14615
  "src",
13633
14616
  "autoplay",
13634
14617
  "muted",
@@ -13665,7 +14648,20 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
13665
14648
  "minRemainingMsToStartAd",
13666
14649
  "minRemainingMsToRequestAd",
13667
14650
  "maxNoFillsPerBreak",
13668
- "maxAdBreakExtensionMs"
14651
+ "maxAdBreakExtensionMs",
14652
+ "adDeviceId",
14653
+ "adDeviceIdType",
14654
+ "adLimitAdTracking",
14655
+ "fallbackDeviceIdMaxAgeMs",
14656
+ "sessionIdMaxAgeMs",
14657
+ "palIconsSupported",
14658
+ "palSupportedApiFrameworks",
14659
+ "palContinuousPlayback",
14660
+ "palNonceMaxAgeMs",
14661
+ "forceSingleDecoderMode",
14662
+ "deviceInfo",
14663
+ "sendDeviceKeyValues",
14664
+ "sendDeviceInfoToAnalytics"
13669
14665
  ]);
13670
14666
  var videoRef = useRef(null);
13671
14667
  var playerRef = useRef(null);
@@ -13861,6 +14857,19 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
13861
14857
  if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
13862
14858
  if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;
13863
14859
  if (maxAdBreakExtensionMs !== void 0) cfg.maxAdBreakExtensionMs = maxAdBreakExtensionMs;
14860
+ if (adDeviceId !== void 0) cfg.adDeviceId = adDeviceId;
14861
+ if (adDeviceIdType !== void 0) cfg.adDeviceIdType = adDeviceIdType;
14862
+ if (adLimitAdTracking !== void 0) cfg.adLimitAdTracking = adLimitAdTracking;
14863
+ if (fallbackDeviceIdMaxAgeMs !== void 0) cfg.fallbackDeviceIdMaxAgeMs = fallbackDeviceIdMaxAgeMs;
14864
+ if (sessionIdMaxAgeMs !== void 0) cfg.sessionIdMaxAgeMs = sessionIdMaxAgeMs;
14865
+ if (palIconsSupported !== void 0) cfg.palIconsSupported = palIconsSupported;
14866
+ if (palSupportedApiFrameworks !== void 0) cfg.palSupportedApiFrameworks = palSupportedApiFrameworks;
14867
+ if (palContinuousPlayback !== void 0) cfg.palContinuousPlayback = palContinuousPlayback;
14868
+ if (palNonceMaxAgeMs !== void 0) cfg.palNonceMaxAgeMs = palNonceMaxAgeMs;
14869
+ if (forceSingleDecoderMode !== void 0) cfg.forceSingleDecoderMode = forceSingleDecoderMode;
14870
+ if (deviceInfo !== void 0) cfg.deviceInfo = deviceInfo;
14871
+ if (sendDeviceKeyValues !== void 0) cfg.sendDeviceKeyValues = sendDeviceKeyValues;
14872
+ if (sendDeviceInfoToAnalytics !== void 0) cfg.sendDeviceInfoToAnalytics = sendDeviceInfoToAnalytics;
13864
14873
  var player = new StormcloudVideoPlayer(cfg);
13865
14874
  playerRef.current = player;
13866
14875
  player.load().then(function() {
@@ -13900,6 +14909,41 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
13900
14909
  autoplay,
13901
14910
  muted
13902
14911
  ]);
14912
+ useEffect(function() {
14913
+ var _playerRef_current;
14914
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
14915
+ channelName: channelName !== null && channelName !== void 0 ? channelName : null,
14916
+ programTitle: programTitle !== null && programTitle !== void 0 ? programTitle : null,
14917
+ contentNetwork: contentNetwork !== null && contentNetwork !== void 0 ? contentNetwork : null
14918
+ });
14919
+ }, [
14920
+ channelName,
14921
+ programTitle,
14922
+ contentNetwork
14923
+ ]);
14924
+ var lastAdDeviceIdRef = useRef(void 0);
14925
+ useEffect(function() {
14926
+ var player = playerRef.current;
14927
+ if (!player) return;
14928
+ if (adDeviceId === void 0 && lastAdDeviceIdRef.current === void 0) return;
14929
+ lastAdDeviceIdRef.current = adDeviceId;
14930
+ player.setAdIdentity(adDeviceId ? {
14931
+ deviceId: adDeviceId,
14932
+ deviceIdType: adDeviceIdType,
14933
+ limitAdTracking: adLimitAdTracking
14934
+ } : null);
14935
+ }, [
14936
+ adDeviceId,
14937
+ adDeviceIdType,
14938
+ adLimitAdTracking
14939
+ ]);
14940
+ var deviceInfoKey = deviceInfo ? JSON.stringify(deviceInfo) : "";
14941
+ useEffect(function() {
14942
+ if (!playerRef.current || !deviceInfoKey) return;
14943
+ playerRef.current.setDeviceInfo(JSON.parse(deviceInfoKey));
14944
+ }, [
14945
+ deviceInfoKey
14946
+ ]);
13903
14947
  useEffect(function() {
13904
14948
  if (!playerRef.current) return;
13905
14949
  var checkAdStatus = function checkAdStatus() {