stormcloud-video-player 0.8.79 → 0.8.81

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 (90) 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 +4 -1
  5. package/lib/StormcloudPlayer.cjs +1459 -167
  6. package/lib/StormcloudPlayer.cjs.map +1 -1
  7. package/lib/StormcloudPlayer.d.cts +3 -0
  8. package/lib/index.cjs +1547 -169
  9. package/lib/index.cjs.map +1 -1
  10. package/lib/index.d.cts +3 -0
  11. package/lib/index.d.ts +89 -3
  12. package/lib/index.js +1547 -169
  13. package/lib/index.js.map +1 -1
  14. package/lib/player/AdBreakOrchestrator.cjs +452 -88
  15. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  16. package/lib/player/AdBreakOrchestrator.d.cts +1 -0
  17. package/lib/player/AdConfigManager.cjs +1024 -97
  18. package/lib/player/AdConfigManager.cjs.map +1 -1
  19. package/lib/player/AdConfigManager.d.cts +2 -0
  20. package/lib/player/AdTimingService.cjs +0 -9
  21. package/lib/player/AdTimingService.cjs.map +1 -1
  22. package/lib/player/AdTimingService.d.cts +1 -0
  23. package/lib/player/EdgePodRequest.d.cts +1 -0
  24. package/lib/player/FloorLadder.cjs +3 -0
  25. package/lib/player/FloorLadder.cjs.map +1 -1
  26. package/lib/player/FloorLadder.d.cts +1 -0
  27. package/lib/player/HlsEngine.cjs +7 -1
  28. package/lib/player/HlsEngine.cjs.map +1 -1
  29. package/lib/player/HlsEngine.d.cts +2 -0
  30. package/lib/player/OptimizedPodRequest.cjs +21 -6
  31. package/lib/player/OptimizedPodRequest.cjs.map +1 -1
  32. package/lib/player/OptimizedPodRequest.d.cts +1 -1
  33. package/lib/player/PlayerControls.d.cts +1 -0
  34. package/lib/player/Scte35CueManager.d.cts +1 -0
  35. package/lib/player/Scte35Parser.d.cts +1 -0
  36. package/lib/player/StormcloudVideoPlayer.cjs +1459 -167
  37. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  38. package/lib/player/StormcloudVideoPlayer.d.cts +19 -1
  39. package/lib/player/playerTypes.d.cts +1 -0
  40. package/lib/players/HlsPlayer.cjs +1459 -167
  41. package/lib/players/HlsPlayer.cjs.map +1 -1
  42. package/lib/players/HlsPlayer.d.cts +1 -0
  43. package/lib/players/index.cjs +1459 -167
  44. package/lib/players/index.cjs.map +1 -1
  45. package/lib/props.cjs +6 -0
  46. package/lib/props.cjs.map +1 -1
  47. package/lib/props.d.cts +3 -0
  48. package/lib/sdk/hlsAdPlayer.cjs +32 -3
  49. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  50. package/lib/sdk/hlsAdPlayer.d.cts +1 -0
  51. package/lib/sdk/pal.cjs +10 -3
  52. package/lib/sdk/pal.cjs.map +1 -1
  53. package/lib/sdk/pal.d.cts +3 -0
  54. package/lib/types.d.cts +29 -1
  55. package/lib/ui/StormcloudVideoPlayer.cjs +1547 -169
  56. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  57. package/lib/ui/StormcloudVideoPlayer.d.cts +3 -0
  58. package/lib/utils/__tests__/adSignals.test.cjs +25817 -0
  59. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -0
  60. package/lib/utils/__tests__/adSignals.test.d.cts +2 -0
  61. package/lib/utils/adIdentity.cjs +421 -0
  62. package/lib/utils/adIdentity.cjs.map +1 -0
  63. package/lib/utils/adIdentity.d.cts +30 -0
  64. package/lib/utils/browserCompat.cjs +13 -0
  65. package/lib/utils/browserCompat.cjs.map +1 -1
  66. package/lib/utils/browserCompat.d.cts +2 -1
  67. package/lib/utils/contentMetadata.cjs +324 -0
  68. package/lib/utils/contentMetadata.cjs.map +1 -0
  69. package/lib/utils/contentMetadata.d.cts +51 -0
  70. package/lib/utils/ctvVastSignals.cjs +250 -181
  71. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  72. package/lib/utils/deviceInfo.cjs +698 -0
  73. package/lib/utils/deviceInfo.cjs.map +1 -0
  74. package/lib/utils/deviceInfo.d.cts +46 -0
  75. package/lib/utils/partnerSignals.cjs +294 -0
  76. package/lib/utils/partnerSignals.cjs.map +1 -0
  77. package/lib/utils/partnerSignals.d.cts +12 -0
  78. package/lib/utils/screenActivity.cjs +125 -0
  79. package/lib/utils/screenActivity.cjs.map +1 -0
  80. package/lib/utils/screenActivity.d.cts +5 -0
  81. package/lib/utils/tracking.cjs +406 -56
  82. package/lib/utils/tracking.cjs.map +1 -1
  83. package/lib/utils/tracking.d.cts +2 -1
  84. package/lib/utils/vastEnvironmentSignals.cjs +255 -85
  85. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  86. package/lib/utils/vastEnvironmentSignals.d.cts +8 -2
  87. package/lib/utils/vastMacros.cjs +58 -1
  88. package/lib/utils/vastMacros.cjs.map +1 -1
  89. package/lib/utils/vastMacros.d.cts +21 -0
  90. 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",
@@ -968,6 +1227,308 @@ function normalizeBoolean(value) {
968
1227
  }
969
1228
  return void 0;
970
1229
  }
1230
+ // src/utils/contentMetadata.ts
1231
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1232
+ var BRIDGE_KEYS = {
1233
+ channelName: [
1234
+ "channelName",
1235
+ "ct_ch"
1236
+ ],
1237
+ programTitle: [
1238
+ "programTitle",
1239
+ "ct_ti"
1240
+ ],
1241
+ contentNetwork: [
1242
+ "contentNetwork",
1243
+ "ct_ne"
1244
+ ],
1245
+ contentType: [
1246
+ "contentType",
1247
+ "ctt"
1248
+ ],
1249
+ contentCategory: [
1250
+ "contentCategory",
1251
+ "ctc"
1252
+ ],
1253
+ contentGenre: [
1254
+ "contentGenre",
1255
+ "ctgr"
1256
+ ],
1257
+ contentLanguage: [
1258
+ "contentLanguage",
1259
+ "ctlg"
1260
+ ],
1261
+ contentDuration: [
1262
+ "contentDuration",
1263
+ "ctd"
1264
+ ],
1265
+ contentSeason: [
1266
+ "contentSeason",
1267
+ "cts"
1268
+ ],
1269
+ contentEpisode: [
1270
+ "contentEpisode",
1271
+ "cte"
1272
+ ],
1273
+ contentRating: [
1274
+ "contentRating",
1275
+ "ctr"
1276
+ ],
1277
+ contentId: [
1278
+ "contentId",
1279
+ "ctid"
1280
+ ]
1281
+ };
1282
+ function sanitizeContentValue(value) {
1283
+ if (typeof value !== "string") return void 0;
1284
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1285
+ if (!cleaned) return void 0;
1286
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1287
+ if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1288
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1289
+ }
1290
+ function sanitizeContentScalar(value) {
1291
+ if (typeof value === "number") {
1292
+ return Number.isFinite(value) ? String(value) : void 0;
1293
+ }
1294
+ return sanitizeContentValue(value);
1295
+ }
1296
+ function normalizeContentLanguage(value) {
1297
+ var cleaned = sanitizeContentValue(value);
1298
+ if (!cleaned) return void 0;
1299
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1300
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1301
+ }
1302
+ function normalizeContentDuration(value) {
1303
+ var raw = sanitizeContentScalar(value);
1304
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1305
+ var seconds = Number(raw);
1306
+ if (seconds === -1) return -1;
1307
+ return seconds > 0 ? Math.round(seconds) : void 0;
1308
+ }
1309
+ function bridgeSources() {
1310
+ if (typeof window === "undefined") return [];
1311
+ var w = window;
1312
+ return [
1313
+ w.__STORMCLOUD_CTV__,
1314
+ w.__STORMCLOUD_CTV_AD_INFO__,
1315
+ w.stormcloudCtv
1316
+ ].filter(Boolean);
1317
+ }
1318
+ function readBridgeValue2(keys, sanitize) {
1319
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1320
+ try {
1321
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1322
+ var source = _step.value;
1323
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1324
+ try {
1325
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1326
+ var key = _step1.value;
1327
+ var value = void 0;
1328
+ try {
1329
+ value = source === null || source === void 0 ? void 0 : source[key];
1330
+ if (typeof value === "function") value = value.call(source);
1331
+ } catch (unused) {
1332
+ value = void 0;
1333
+ }
1334
+ var sanitized = sanitize(value);
1335
+ if (sanitized != null) return sanitized;
1336
+ }
1337
+ } catch (err) {
1338
+ _didIteratorError1 = true;
1339
+ _iteratorError1 = err;
1340
+ } finally{
1341
+ try {
1342
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1343
+ _iterator1.return();
1344
+ }
1345
+ } finally{
1346
+ if (_didIteratorError1) {
1347
+ throw _iteratorError1;
1348
+ }
1349
+ }
1350
+ }
1351
+ }
1352
+ } catch (err) {
1353
+ _didIteratorError = true;
1354
+ _iteratorError = err;
1355
+ } finally{
1356
+ try {
1357
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1358
+ _iterator.return();
1359
+ }
1360
+ } finally{
1361
+ if (_didIteratorError) {
1362
+ throw _iteratorError;
1363
+ }
1364
+ }
1365
+ }
1366
+ return void 0;
1367
+ }
1368
+ function readBridgeContentValue(keys) {
1369
+ return readBridgeValue2(keys, sanitizeContentValue);
1370
+ }
1371
+ function resolveContentMetadata(config) {
1372
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1373
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1374
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1375
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1376
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1377
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1378
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1379
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1380
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1381
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1382
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1383
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1384
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1385
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1386
+ return _object_spread({}, channelName ? {
1387
+ channelName: channelName
1388
+ } : {}, programTitle ? {
1389
+ programTitle: programTitle
1390
+ } : {}, contentNetwork ? {
1391
+ contentNetwork: contentNetwork
1392
+ } : {}, contentType ? {
1393
+ contentType: contentType
1394
+ } : {}, contentCategory ? {
1395
+ contentCategory: contentCategory
1396
+ } : {}, contentGenre ? {
1397
+ contentGenre: contentGenre
1398
+ } : {}, contentLanguage ? {
1399
+ contentLanguage: contentLanguage
1400
+ } : {}, contentDurationSeconds != null ? {
1401
+ contentDurationSeconds: contentDurationSeconds
1402
+ } : {}, contentSeason ? {
1403
+ contentSeason: contentSeason
1404
+ } : {}, contentEpisode ? {
1405
+ contentEpisode: contentEpisode
1406
+ } : {}, contentRating ? {
1407
+ contentRating: contentRating
1408
+ } : {}, contentId ? {
1409
+ contentId: contentId
1410
+ } : {});
1411
+ }
1412
+ function applyContentMetadataUpdate(target, meta) {
1413
+ var apply = function apply(key, value) {
1414
+ if (value === void 0) return;
1415
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1416
+ if (clean) target[key] = clean;
1417
+ else delete target[key];
1418
+ };
1419
+ apply("channelName", meta.channelName);
1420
+ apply("programTitle", meta.programTitle);
1421
+ apply("contentNetwork", meta.contentNetwork);
1422
+ if (meta.details === void 0) return;
1423
+ if (meta.details === null) delete target.contentDetails;
1424
+ else target.contentDetails = _object_spread({}, meta.details);
1425
+ }
1426
+ function appendMissingContentParams(url, meta) {
1427
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1428
+ try {
1429
+ var parsed = new URL(url);
1430
+ var add = function add(key, value) {
1431
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1432
+ };
1433
+ add("ct_ch", meta.channelName);
1434
+ add("ct_ti", meta.programTitle);
1435
+ add("ct_ne", meta.contentNetwork);
1436
+ return parsed.toString();
1437
+ } catch (unused) {
1438
+ return url;
1439
+ }
1440
+ }
1441
+ // src/utils/partnerSignals.ts
1442
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1443
+ "aaid",
1444
+ "adid",
1445
+ "afai",
1446
+ "idfa",
1447
+ "lgudid",
1448
+ "msai",
1449
+ "rida",
1450
+ "tifa",
1451
+ "tvos",
1452
+ "vaid",
1453
+ "vida"
1454
+ ]);
1455
+ function toIabIfaType(deviceIdType, source) {
1456
+ if (!deviceIdType) return void 0;
1457
+ var type = deviceIdType.trim().toLowerCase();
1458
+ if (source === "generated") return "sessionid";
1459
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1460
+ if (source === "platform") return "dpid";
1461
+ return "ppid";
1462
+ }
1463
+ function playbackMethodCode(autoPlay, muted) {
1464
+ if (autoPlay === false) return 3;
1465
+ if (autoPlay !== true || muted == null) return void 0;
1466
+ return muted ? 2 : 1;
1467
+ }
1468
+ function resolvePlayerSize(video) {
1469
+ var width = video ? video.clientWidth : 0;
1470
+ var height = video ? video.clientHeight : 0;
1471
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1472
+ width = window.innerWidth;
1473
+ height = window.innerHeight;
1474
+ }
1475
+ if (!(width > 0 && height > 0)) return {};
1476
+ return {
1477
+ width: Math.round(width),
1478
+ height: Math.round(height)
1479
+ };
1480
+ }
1481
+ function sanitizeUserId(value) {
1482
+ var cleaned = sanitizeContentValue(value);
1483
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1484
+ return cleaned;
1485
+ }
1486
+ function isPublicIpv4(ip) {
1487
+ var parts = ip.split(".");
1488
+ if (parts.length !== 4) return false;
1489
+ var nums = parts.map(function(p) {
1490
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1491
+ });
1492
+ if (nums.some(function(n) {
1493
+ return !(n >= 0 && n <= 255);
1494
+ })) return false;
1495
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1496
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1497
+ if (a === 100 && b >= 64 && b <= 127) return false;
1498
+ if (a === 169 && b === 254) return false;
1499
+ if (a === 172 && b >= 16 && b <= 31) return false;
1500
+ if (a === 192 && b === 168) return false;
1501
+ return true;
1502
+ }
1503
+ function isPublicIpv6(ip) {
1504
+ var lower = ip.toLowerCase();
1505
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1506
+ if (lower === "::" || lower === "::1") return false;
1507
+ if (/^fe[89ab]/.test(lower)) return false;
1508
+ if (/^f[cd]/.test(lower)) return false;
1509
+ return true;
1510
+ }
1511
+ function sanitizePublicIp(value) {
1512
+ var cleaned = sanitizeContentValue(value);
1513
+ if (!cleaned) return void 0;
1514
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1515
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1516
+ }
1517
+ function resolveUserId(configValue) {
1518
+ var _sanitizeUserId;
1519
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1520
+ "userId",
1521
+ "uid"
1522
+ ], sanitizeUserId);
1523
+ }
1524
+ function resolveClientIp(configValue) {
1525
+ var _sanitizePublicIp;
1526
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1527
+ "ipAddress",
1528
+ "clientIp",
1529
+ "ip"
1530
+ ], sanitizePublicIp);
1531
+ }
971
1532
  // src/utils/vastMacros.ts
972
1533
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
973
1534
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1285,7 +1846,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1285
1846
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1286
1847
  "PMND",
1287
1848
  "PMXD",
1288
- "PMAD"
1849
+ "PMAD",
1850
+ "MABD"
1289
1851
  ]);
1290
1852
  function hasScvpMacros(url) {
1291
1853
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1330,12 +1892,15 @@ function resolveScvpMacroValues(ctx) {
1330
1892
  set("RDID", deviceId);
1331
1893
  set("IDTYPE", deviceIdType);
1332
1894
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1895
+ set("IFA", deviceId);
1896
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1333
1897
  }
1334
1898
  set("SID", ctx.sessionId);
1335
1899
  set("DTH", ctx.deviceTypeHint);
1336
1900
  set("GIVN", ctx.palNonce);
1337
1901
  set("CT-TI", ctx.programTitle);
1338
1902
  set("CT-CH", ctx.channelName);
1903
+ set("CT-NE", ctx.contentNetwork);
1339
1904
  set("POD", ctx.pod);
1340
1905
  set("CORRELATOR", ctx.correlator);
1341
1906
  set("SCOR", ctx.streamCorrelator);
@@ -1346,6 +1911,26 @@ function resolveScvpMacroValues(ctx) {
1346
1911
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1347
1912
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1348
1913
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1914
+ set("PLAYER-WIDTH", ctx.playerWidth);
1915
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1916
+ set("TIMESTAMP", ctx.timestamp);
1917
+ set("LIVE", toFlag(ctx.isLive));
1918
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1919
+ set("DEVICE-MAKE", ctx.deviceMake);
1920
+ set("DEVICE-MODEL", ctx.deviceModel);
1921
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
1922
+ set("UA", ctx.userAgent);
1923
+ set("IP", ctx.ipAddress);
1924
+ set("UID", ctx.userId);
1925
+ set("CT-TYPE", ctx.contentType);
1926
+ set("CT-CATEGORY", ctx.contentCategory);
1927
+ set("CT-GENRE", ctx.contentGenre);
1928
+ set("CT-LANGUAGE", ctx.contentLanguage);
1929
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
1930
+ set("CT-SEASON", ctx.contentSeason);
1931
+ set("CT-EPISODE", ctx.contentEpisode);
1932
+ set("CT-RATING", ctx.contentRating);
1933
+ set("CT-ID", ctx.contentId);
1349
1934
  return values;
1350
1935
  }
1351
1936
  var keepNone = function keepNone() {
@@ -1564,6 +2149,9 @@ function applyVastMacros(baseUrl, ctx) {
1564
2149
  if (ctx.channelName) {
1565
2150
  params.set("ct_ch", ctx.channelName);
1566
2151
  }
2152
+ if (ctx.contentNetwork) {
2153
+ params.set("ct_ne", ctx.contentNetwork);
2154
+ }
1567
2155
  var staleKeys = [];
1568
2156
  params.forEach(function(value, key) {
1569
2157
  if (isMacroPlaceholder2(value)) {
@@ -2238,8 +2826,17 @@ function detectBrowser() {
2238
2826
  chromeVersion: chromeVersionNum
2239
2827
  };
2240
2828
  }
2829
+ var singleDecoderOverride;
2830
+ function setSingleDecoderOverride(value) {
2831
+ singleDecoderOverride = value;
2832
+ }
2241
2833
  function requiresMediaPipelineResetAfterAds() {
2242
2834
  var _browser_tizenVersion;
2835
+ if (singleDecoderOverride != null) return singleDecoderOverride;
2836
+ try {
2837
+ var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2838
+ if (typeof globalOverride === "boolean") return globalOverride;
2839
+ } catch (unused) {}
2243
2840
  var browser = detectBrowser();
2244
2841
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2245
2842
  }
@@ -2422,7 +3019,7 @@ function substituteVastTrackingMacros(url) {
2422
3019
  });
2423
3020
  }
2424
3021
  // src/player/OptimizedPodRequest.ts
2425
- var DEFAULT_REQUEST_SAFETY_MS = 1500;
3022
+ var DEFAULT_REQUEST_SAFETY_MS = 2500;
2426
3023
  var GAM_AD_OPPORTUNITY_DURATION_MS = 3e4;
2427
3024
  var POD_PARAM_KEYS = [
2428
3025
  "pmnd",
@@ -2582,15 +3179,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2582
3179
  values.set("PMND", String(pod.pmnd));
2583
3180
  values.set("PMXD", String(pod.pmxd));
2584
3181
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3182
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2585
3183
  }
2586
3184
  var substituted = substituteScvpMacros(rawUrl, values);
2587
3185
  var finalUrl;
2588
3186
  try {
2589
3187
  var url = new URL(normalizeVastTagUrl(substituted.url));
3188
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3189
+ var setPodParam = function setPodParam(key, value) {
3190
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3191
+ };
2590
3192
  if (pod) {
2591
- url.searchParams.set("pmnd", String(pod.pmnd));
2592
- url.searchParams.set("pmxd", String(pod.pmxd));
2593
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3193
+ setPodParam("pmnd", pod.pmnd);
3194
+ setPodParam("pmxd", pod.pmxd);
3195
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2594
3196
  else url.searchParams.delete("pmad");
2595
3197
  } else {
2596
3198
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2656,7 +3258,9 @@ function validateGamRequestUrl(url, expect) {
2656
3258
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2657
3259
  var params;
2658
3260
  try {
2659
- params = new URL(url).searchParams;
3261
+ var parsed = new URL(url);
3262
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3263
+ params = parsed.searchParams;
2660
3264
  } catch (unused) {
2661
3265
  return problems.concat("URL could not be parsed");
2662
3266
  }
@@ -2846,6 +3450,9 @@ function createHlsAdPlayer(contentVideo, options) {
2846
3450
  var mediaCandidateIndex = 0;
2847
3451
  var mediaStartTimerId;
2848
3452
  var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
3453
+ var MAX_MEDIA_START_ATTEMPTS = 2;
3454
+ var MEDIA_START_TOTAL_BUDGET_MS = Math.max(MEDIA_START_TIMEOUT_MS, 1e4);
3455
+ var mediaStartBudgetStartedAt = 0;
2849
3456
  var VAST_ERROR_MEDIA_TIMEOUT = 402;
2850
3457
  var pendingVastRequests = /* @__PURE__ */ new Set();
2851
3458
  var pendingRequestAbortReason;
@@ -4860,12 +5467,14 @@ function createHlsAdPlayer(contentVideo, options) {
4860
5467
  clearMediaStartTimer();
4861
5468
  if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
4862
5469
  var startedAt = Date.now();
5470
+ var budgetLeftMs = mediaStartBudgetStartedAt > 0 ? MEDIA_START_TOTAL_BUDGET_MS - (startedAt - mediaStartBudgetStartedAt) : MEDIA_START_TIMEOUT_MS;
5471
+ var timeoutMs = Math.max(1e3, Math.min(MEDIA_START_TIMEOUT_MS, budgetLeftMs));
4863
5472
  mediaStartTimerId = setTimeout(function() {
4864
5473
  mediaStartTimerId = void 0;
4865
5474
  if (!adPlaying || trackingFired.impression) return;
4866
- console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
5475
+ console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(timeoutMs, "ms"));
4867
5476
  logFunnel("play_resolved_but_never_started", {
4868
- timeoutMs: MEDIA_START_TIMEOUT_MS,
5477
+ timeoutMs: timeoutMs,
4869
5478
  elapsedMs: Date.now() - startedAt,
4870
5479
  readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
4871
5480
  networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
@@ -4874,7 +5483,7 @@ function createHlsAdPlayer(contentVideo, options) {
4874
5483
  vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
4875
5484
  });
4876
5485
  recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
4877
- }, MEDIA_START_TIMEOUT_MS);
5486
+ }, timeoutMs);
4878
5487
  }
4879
5488
  function resetVideoElementForNextSource() {
4880
5489
  clearStallWatchdog();
@@ -4889,6 +5498,20 @@ function createHlsAdPlayer(contentVideo, options) {
4889
5498
  function tryNextMediaCandidate() {
4890
5499
  if (!currentAd || trackingFired.impression) return false;
4891
5500
  if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
5501
+ if (mediaCandidateIndex + 1 >= MAX_MEDIA_START_ATTEMPTS) {
5502
+ logFunnel("media_fallback_capped", {
5503
+ reason: "max_attempts",
5504
+ attempts: mediaCandidateIndex + 1
5505
+ });
5506
+ return false;
5507
+ }
5508
+ if (mediaStartBudgetStartedAt > 0 && Date.now() - mediaStartBudgetStartedAt >= MEDIA_START_TOTAL_BUDGET_MS) {
5509
+ logFunnel("media_fallback_capped", {
5510
+ reason: "time_budget",
5511
+ elapsedMs: Date.now() - mediaStartBudgetStartedAt
5512
+ });
5513
+ return false;
5514
+ }
4892
5515
  var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
4893
5516
  mediaCandidateIndex++;
4894
5517
  var next = mediaCandidates[mediaCandidateIndex];
@@ -4922,6 +5545,7 @@ function createHlsAdPlayer(contentVideo, options) {
4922
5545
  }
4923
5546
  mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
4924
5547
  mediaCandidateIndex = 0;
5548
+ mediaStartBudgetStartedAt = Date.now();
4925
5549
  var mediaFile = mediaCandidates[0];
4926
5550
  if (!mediaFile) {
4927
5551
  logFunnel("media_unsupported", {
@@ -5861,6 +6485,7 @@ function getOrCreateNonceLoader(allowStorage) {
5861
6485
  }
5862
6486
  function createPalNonceManager() {
5863
6487
  var currentNonce = "";
6488
+ var currentNonceCreatedAt = 0;
5864
6489
  var currentNonceManager;
5865
6490
  var pendingNonce;
5866
6491
  return {
@@ -5877,6 +6502,9 @@ function createPalNonceManager() {
5877
6502
  getCurrentNonce: function getCurrentNonce() {
5878
6503
  return currentNonce;
5879
6504
  },
6505
+ getNonceAgeMs: function getNonceAgeMs() {
6506
+ return currentNonce ? Date.now() - currentNonceCreatedAt : void 0;
6507
+ },
5880
6508
  waitForNonce: function waitForNonce(maxWaitMs) {
5881
6509
  if (currentNonce) return Promise.resolve(currentNonce);
5882
6510
  var pending = pendingNonce;
@@ -5929,13 +6557,14 @@ function createPalNonceManager() {
5929
6557
  },
5930
6558
  reset: function reset() {
5931
6559
  currentNonce = "";
6560
+ currentNonceCreatedAt = 0;
5932
6561
  currentNonceManager = void 0;
5933
6562
  pendingNonce = void 0;
5934
6563
  }
5935
6564
  };
5936
6565
  function generate(options) {
5937
6566
  return _async_to_generator(function() {
5938
- var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, loader, goog, request, manager, error;
6567
+ var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, _options_iconsSupported, _options_supportedApiFrameworks, loader, goog, request, apiFrameworks, manager, error;
5939
6568
  return _ts_generator(this, function(_state) {
5940
6569
  switch(_state.label){
5941
6570
  case 0:
@@ -5959,10 +6588,11 @@ function createPalNonceManager() {
5959
6588
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
5960
6589
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
5961
6590
  request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5962
- request.iconsSupported = true;
6591
+ request.iconsSupported = (_options_iconsSupported = options.iconsSupported) !== null && _options_iconsSupported !== void 0 ? _options_iconsSupported : false;
5963
6592
  request.playerType = "StormcloudVideoPlayer";
5964
6593
  request.playerVersion = "1.0";
5965
- request.supportedApiFrameworks = "2,7,9";
6594
+ apiFrameworks = ((_options_supportedApiFrameworks = options.supportedApiFrameworks) !== null && _options_supportedApiFrameworks !== void 0 ? _options_supportedApiFrameworks : "").trim();
6595
+ if (apiFrameworks) request.supportedApiFrameworks = apiFrameworks;
5966
6596
  request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5967
6597
  request.videoWidth = options.videoWidth || 640;
5968
6598
  request.videoHeight = options.videoHeight || 480;
@@ -5992,6 +6622,7 @@ function createPalNonceManager() {
5992
6622
  manager = _state.sent();
5993
6623
  currentNonceManager = manager;
5994
6624
  currentNonce = manager.getNonce();
6625
+ currentNonceCreatedAt = Date.now();
5995
6626
  console.log("[PAL] Nonce generated successfully");
5996
6627
  return [
5997
6628
  2,
@@ -6015,6 +6646,458 @@ function createPalNonceManager() {
6015
6646
  })();
6016
6647
  }
6017
6648
  }
6649
+ // src/utils/deviceInfo.ts
6650
+ var CATEGORY_CODES = {
6651
+ "LG TV": "lg_tv",
6652
+ "LG Set-Top Box": "lg_stb",
6653
+ "Samsung TV": "samsung_tv",
6654
+ Other: "other"
6655
+ };
6656
+ var DEVICE_CATEGORIES = [
6657
+ "LG TV",
6658
+ "LG Set-Top Box",
6659
+ "Samsung TV",
6660
+ "Other"
6661
+ ];
6662
+ var hostDeviceInfo;
6663
+ var lgDeviceInfo;
6664
+ var platformCache;
6665
+ var primePromise;
6666
+ function cleanString(value) {
6667
+ var maxLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 128;
6668
+ if (typeof value !== "string") return void 0;
6669
+ var t = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6670
+ if (!t || /^(unknown|null|undefined|none|n\/a|-|0)$/i.test(t)) return void 0;
6671
+ return t.length > maxLength ? t.slice(0, maxLength) : t;
6672
+ }
6673
+ function safeCall2(fn, thisArg) {
6674
+ if (typeof fn !== "function") return void 0;
6675
+ try {
6676
+ return fn.call(thisArg);
6677
+ } catch (unused) {
6678
+ return void 0;
6679
+ }
6680
+ }
6681
+ function userAgent() {
6682
+ return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6683
+ }
6684
+ function bridgeSources2() {
6685
+ if (typeof window === "undefined") return [];
6686
+ var w = window;
6687
+ return [
6688
+ w.__STORMCLOUD_CTV__,
6689
+ w.__STORMCLOUD_CTV_AD_INFO__,
6690
+ w.stormcloudCtv
6691
+ ].filter(Boolean);
6692
+ }
6693
+ function readBridge(keys) {
6694
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6695
+ try {
6696
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6697
+ var source = _step.value;
6698
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6699
+ try {
6700
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6701
+ var key = _step1.value;
6702
+ var value = void 0;
6703
+ try {
6704
+ value = source === null || source === void 0 ? void 0 : source[key];
6705
+ if (typeof value === "function") value = value.call(source);
6706
+ } catch (unused) {
6707
+ value = void 0;
6708
+ }
6709
+ var clean = cleanString(value);
6710
+ if (clean) return clean;
6711
+ }
6712
+ } catch (err) {
6713
+ _didIteratorError1 = true;
6714
+ _iteratorError1 = err;
6715
+ } finally{
6716
+ try {
6717
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6718
+ _iterator1.return();
6719
+ }
6720
+ } finally{
6721
+ if (_didIteratorError1) {
6722
+ throw _iteratorError1;
6723
+ }
6724
+ }
6725
+ }
6726
+ }
6727
+ } catch (err) {
6728
+ _didIteratorError = true;
6729
+ _iteratorError = err;
6730
+ } finally{
6731
+ try {
6732
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
6733
+ _iterator.return();
6734
+ }
6735
+ } finally{
6736
+ if (_didIteratorError) {
6737
+ throw _iteratorError;
6738
+ }
6739
+ }
6740
+ }
6741
+ return void 0;
6742
+ }
6743
+ function makeForCategory(category) {
6744
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6745
+ if (category === "Samsung TV") return "Samsung";
6746
+ return void 0;
6747
+ }
6748
+ function normalizeCategory(value) {
6749
+ var v = cleanString(value);
6750
+ if (!v) return void 0;
6751
+ var exact = DEVICE_CATEGORIES.find(function(c) {
6752
+ return c.toLowerCase() === v.toLowerCase();
6753
+ });
6754
+ if (exact) return exact;
6755
+ var code = v.toLowerCase().replace(/[\s-]+/g, "_");
6756
+ var byCode = Object.keys(CATEGORY_CODES).find(function(c) {
6757
+ return CATEGORY_CODES[c] === code;
6758
+ });
6759
+ return byCode;
6760
+ }
6761
+ function parseUserAgentDeviceInfo(ua) {
6762
+ var sources = [];
6763
+ var out = {
6764
+ platform: "other",
6765
+ sources: sources
6766
+ };
6767
+ var chrome = ua.match(/(?:Chrome|PCBR)\/(\d+)\./) || ua.match(/\s(\d{2,3})\.\d+\.\d+\.\d+\/[\d.]+\s+TV\b/);
6768
+ if (chrome && chrome[1]) out.browserMajorVersion = parseInt(chrome[1], 10);
6769
+ if (/Web0S|webOS/i.test(ua)) {
6770
+ out.platform = "webos";
6771
+ var lg = ua.match(/LGE\s*;\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*;\s*(\d{2}\.\d{2}\.\d{2})/);
6772
+ if (lg && lg[1] && lg[2]) {
6773
+ out.model = lg[1];
6774
+ out.firmware = lg[2];
6775
+ sources.push("user_agent");
6776
+ }
6777
+ } else if (/Tizen/i.test(ua)) {
6778
+ out.platform = "tizen";
6779
+ var tizen = ua.match(/Tizen\s+(\d+(?:\.\d+)*)/i);
6780
+ if (tizen && tizen[1]) {
6781
+ out.osVersion = "Tizen ".concat(tizen[1]);
6782
+ sources.push("user_agent");
6783
+ }
6784
+ }
6785
+ return out;
6786
+ }
6787
+ function readSamsungProductInfo() {
6788
+ var _cleanString;
6789
+ var _window_webapis;
6790
+ if (typeof window === "undefined") return void 0;
6791
+ var productinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.productinfo;
6792
+ if (!productinfo) return void 0;
6793
+ var model = (_cleanString = cleanString(safeCall2(productinfo.getRealModel, productinfo), 40)) !== null && _cleanString !== void 0 ? _cleanString : cleanString(safeCall2(productinfo.getModel, productinfo), 40);
6794
+ var firmware = cleanString(safeCall2(productinfo.getFirmware, productinfo), 64);
6795
+ var duid = cleanString(safeCall2(productinfo.getDuid, productinfo), 128);
6796
+ if (!model && !firmware && !duid) return void 0;
6797
+ return _object_spread({}, model ? {
6798
+ model: model
6799
+ } : {}, firmware ? {
6800
+ firmware: firmware
6801
+ } : {}, duid ? {
6802
+ internalDeviceId: duid,
6803
+ internalDeviceIdSource: "samsung_duid"
6804
+ } : {});
6805
+ }
6806
+ function readLgDeviceInfo(timeoutMs) {
6807
+ var webOS = typeof window !== "undefined" ? window.webOS : void 0;
6808
+ if (lgDeviceInfo || !webOS || typeof webOS.deviceInfo !== "function") return Promise.resolve();
6809
+ return new Promise(function(resolve) {
6810
+ var settled = false;
6811
+ var finish = function finish() {
6812
+ if (settled) return;
6813
+ settled = true;
6814
+ clearTimeout(timer);
6815
+ resolve();
6816
+ };
6817
+ var timer = setTimeout(finish, Math.max(0, timeoutMs));
6818
+ try {
6819
+ webOS.deviceInfo(function(info) {
6820
+ var model = cleanString(info === null || info === void 0 ? void 0 : info.modelName, 40);
6821
+ var firmware = cleanString(info === null || info === void 0 ? void 0 : info.version, 64);
6822
+ var sdkVersion = cleanString(info === null || info === void 0 ? void 0 : info.sdkVersion, 32);
6823
+ lgDeviceInfo = _object_spread({}, model ? {
6824
+ model: model
6825
+ } : {}, firmware ? {
6826
+ firmware: firmware
6827
+ } : {}, sdkVersion ? {
6828
+ sdkVersion: sdkVersion
6829
+ } : {});
6830
+ finish();
6831
+ });
6832
+ } catch (unused) {
6833
+ finish();
6834
+ }
6835
+ });
6836
+ }
6837
+ function computePlatformInfo() {
6838
+ var info = parseUserAgentDeviceInfo(userAgent());
6839
+ var sources = _to_consumable_array(info.sources);
6840
+ var samsung = readSamsungProductInfo();
6841
+ if (samsung) {
6842
+ info.platform = "tizen";
6843
+ if (samsung.model) info.model = samsung.model;
6844
+ if (samsung.firmware) info.firmware = samsung.firmware;
6845
+ if (samsung.internalDeviceId) {
6846
+ info.internalDeviceId = samsung.internalDeviceId;
6847
+ info.internalDeviceIdSource = "samsung_duid";
6848
+ }
6849
+ sources.push("samsung_productinfo");
6850
+ }
6851
+ if (lgDeviceInfo) {
6852
+ info.platform = "webos";
6853
+ if (!info.model && lgDeviceInfo.model) info.model = lgDeviceInfo.model;
6854
+ if (!info.firmware && lgDeviceInfo.firmware) info.firmware = lgDeviceInfo.firmware;
6855
+ if (lgDeviceInfo.sdkVersion) info.osVersion = "webOS TV ".concat(lgDeviceInfo.sdkVersion);
6856
+ sources.push("lg_deviceinfo");
6857
+ }
6858
+ var lgUdid = readCachedLgUdid();
6859
+ if ((lgUdid === null || lgUdid === void 0 ? void 0 : lgUdid.deviceId) && !info.internalDeviceId) {
6860
+ info.internalDeviceId = lgUdid.deviceId;
6861
+ info.internalDeviceIdSource = "lg_udid";
6862
+ sources.push("lg_udid");
6863
+ }
6864
+ info.sources = sources;
6865
+ return info;
6866
+ }
6867
+ function categorize(platform, model) {
6868
+ if (platform === "tizen") return "Samsung TV";
6869
+ if (platform === "webos") {
6870
+ var ua = userAgent();
6871
+ if (model && /^STB-/i.test(model) || /\bSTB-\d{4}|LGSTB/i.test(ua)) return "LG Set-Top Box";
6872
+ return "LG TV";
6873
+ }
6874
+ return "Other";
6875
+ }
6876
+ function setHostDeviceInfo(info) {
6877
+ hostDeviceInfo = info ? _object_spread({}, info) : void 0;
6878
+ }
6879
+ function primeDeviceInfo() {
6880
+ var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1500;
6881
+ if (!primePromise) {
6882
+ primePromise = Promise.all([
6883
+ readLgDeviceInfo(timeoutMs),
6884
+ primeLgUdid(timeoutMs)
6885
+ ]).catch(function() {
6886
+ return void 0;
6887
+ }).then(function() {
6888
+ platformCache = computePlatformInfo();
6889
+ return getDeviceInfo();
6890
+ });
6891
+ }
6892
+ return primePromise;
6893
+ }
6894
+ function getDeviceInfo() {
6895
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6896
+ var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6897
+ if (primePromise && !platformCache) {} else {
6898
+ platformCache = platform;
6899
+ }
6900
+ var host = hostDeviceInfo !== null && hostDeviceInfo !== void 0 ? hostDeviceInfo : {};
6901
+ var bridge = {
6902
+ terminalId: readBridge([
6903
+ "terminalId",
6904
+ "terminal_id"
6905
+ ]),
6906
+ internalDeviceId: readBridge([
6907
+ "internalDeviceId",
6908
+ "internal_device_id"
6909
+ ]),
6910
+ model: readBridge([
6911
+ "deviceModel"
6912
+ ]),
6913
+ firmware: readBridge([
6914
+ "firmwareVersion"
6915
+ ]),
6916
+ category: normalizeCategory(readBridge([
6917
+ "deviceCategory"
6918
+ ])),
6919
+ make: readBridge([
6920
+ "deviceMake"
6921
+ ]),
6922
+ hardwareVersion: readBridge([
6923
+ "deviceHardwareVersion",
6924
+ "hardwareVersion"
6925
+ ])
6926
+ };
6927
+ var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6928
+ var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
6929
+ var model = (_ref = (_cleanString2 = cleanString(host.model, 40)) !== null && _cleanString2 !== void 0 ? _cleanString2 : bridge.model) !== null && _ref !== void 0 ? _ref : platform.model;
6930
+ var firmware = (_ref1 = (_cleanString3 = cleanString(host.firmware, 64)) !== null && _cleanString3 !== void 0 ? _cleanString3 : bridge.firmware) !== null && _ref1 !== void 0 ? _ref1 : platform.firmware;
6931
+ var category = (_ref2 = (_normalizeCategory = normalizeCategory(host.category)) !== null && _normalizeCategory !== void 0 ? _normalizeCategory : bridge.category) !== null && _ref2 !== void 0 ? _ref2 : categorize(platform.platform, model);
6932
+ var sources = _to_consumable_array(platform.sources);
6933
+ var bridgeValues = [
6934
+ bridge.terminalId,
6935
+ bridge.internalDeviceId,
6936
+ bridge.model,
6937
+ bridge.firmware,
6938
+ bridge.category,
6939
+ bridge.make,
6940
+ bridge.hardwareVersion
6941
+ ];
6942
+ if (bridgeValues.some(function(v) {
6943
+ return v !== void 0;
6944
+ })) sources.unshift("bridge");
6945
+ if (hostDeviceInfo) sources.unshift("host");
6946
+ var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6947
+ var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
6948
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
6949
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6950
+ var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6951
+ return _object_spread_props(_object_spread({
6952
+ category: category,
6953
+ categoryCode: CATEGORY_CODES[category]
6954
+ }, make ? {
6955
+ make: make
6956
+ } : {}, model ? {
6957
+ model: model
6958
+ } : {}, hardwareVersion ? {
6959
+ hardwareVersion: hardwareVersion
6960
+ } : {}, sonifiModel ? {
6961
+ sonifiModel: sonifiModel
6962
+ } : {}, firmware ? {
6963
+ firmware: firmware
6964
+ } : {}, platform.osVersion ? {
6965
+ osVersion: platform.osVersion
6966
+ } : {}, platform.browserMajorVersion != null ? {
6967
+ browserMajorVersion: platform.browserMajorVersion
6968
+ } : {}, internalDeviceId ? {
6969
+ internalDeviceId: internalDeviceId
6970
+ } : {}, internalDeviceId && internalDeviceIdSource ? {
6971
+ internalDeviceIdSource: internalDeviceIdSource
6972
+ } : {}, terminalId ? {
6973
+ terminalId: terminalId
6974
+ } : {}), {
6975
+ sources: sources
6976
+ });
6977
+ }
6978
+ var DEVICE_KEY_VALUE_KEYS = {
6979
+ category: "sc_dev",
6980
+ model: "sc_model",
6981
+ firmware: "sc_fw"
6982
+ };
6983
+ function sanitizeKeyValue(value) {
6984
+ if (typeof value !== "string") return void 0;
6985
+ var v = value.trim().replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "");
6986
+ return v ? v.slice(0, 40) : void 0;
6987
+ }
6988
+ function deviceKeyValuePairs(info) {
6989
+ var pairs = [
6990
+ [
6991
+ DEVICE_KEY_VALUE_KEYS.category,
6992
+ info.categoryCode
6993
+ ]
6994
+ ];
6995
+ var model = sanitizeKeyValue(info.model);
6996
+ var firmware = sanitizeKeyValue(info.firmware);
6997
+ if (model) pairs.push([
6998
+ DEVICE_KEY_VALUE_KEYS.model,
6999
+ model
7000
+ ]);
7001
+ if (firmware) pairs.push([
7002
+ DEVICE_KEY_VALUE_KEYS.firmware,
7003
+ firmware
7004
+ ]);
7005
+ return pairs;
7006
+ }
7007
+ function applyDeviceKeyValues(url, info) {
7008
+ try {
7009
+ var parsed = new URL(url);
7010
+ var pairs = deviceKeyValuePairs(info);
7011
+ var ours = new Set(pairs.map(function(param) {
7012
+ var _param = _sliced_to_array(param, 1), k = _param[0];
7013
+ return k;
7014
+ }));
7015
+ var existing = (parsed.searchParams.get("cust_params") || "").split("&").filter(function(p) {
7016
+ var _p_split_;
7017
+ return p !== "" && !ours.has((_p_split_ = p.split("=")[0]) !== null && _p_split_ !== void 0 ? _p_split_ : "");
7018
+ });
7019
+ var merged = existing.concat(pairs.map(function(param) {
7020
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
7021
+ return "".concat(k, "=").concat(v);
7022
+ })).join("&");
7023
+ parsed.searchParams.set("cust_params", merged);
7024
+ return parsed.toString();
7025
+ } catch (unused) {
7026
+ return url;
7027
+ }
7028
+ }
7029
+ function deviceInfoAnalyticsFields(info) {
7030
+ return _object_spread({
7031
+ device_category: info.category
7032
+ }, info.model ? {
7033
+ device_model: info.model
7034
+ } : {}, info.sonifiModel ? {
7035
+ sonifi_model: info.sonifiModel
7036
+ } : {}, info.firmware ? {
7037
+ firmware_version: info.firmware
7038
+ } : {}, info.osVersion ? {
7039
+ os_version: info.osVersion
7040
+ } : {}, info.browserMajorVersion != null ? {
7041
+ browser_major_version: info.browserMajorVersion
7042
+ } : {}, info.internalDeviceId ? {
7043
+ internal_device_id: info.internalDeviceId
7044
+ } : {}, info.internalDeviceIdSource ? {
7045
+ internal_device_id_source: info.internalDeviceIdSource
7046
+ } : {}, info.terminalId ? {
7047
+ terminal_id: info.terminalId
7048
+ } : {});
7049
+ }
7050
+ // src/utils/screenActivity.ts
7051
+ var hostStandby = false;
7052
+ function setHostStandby(standby) {
7053
+ hostStandby = !!standby;
7054
+ }
7055
+ function toBoolean(value) {
7056
+ if (typeof value === "boolean") return value;
7057
+ if (typeof value === "number") return value === 1;
7058
+ if (typeof value === "string") {
7059
+ var v = value.trim().toLowerCase();
7060
+ if (v === "true" || v === "1" || v === "yes") return true;
7061
+ if (v === "false" || v === "0" || v === "no") return false;
7062
+ }
7063
+ return void 0;
7064
+ }
7065
+ function bridgeSaysStandby() {
7066
+ if (typeof window === "undefined") return false;
7067
+ var w = window;
7068
+ for(var _i = 0, _iter = [
7069
+ w.__STORMCLOUD_CTV__,
7070
+ w.__STORMCLOUD_CTV_AD_INFO__,
7071
+ w.stormcloudCtv
7072
+ ]; _i < _iter.length; _i++){
7073
+ var source = _iter[_i];
7074
+ if (!source) continue;
7075
+ for(var _i1 = 0, _iter1 = [
7076
+ "standby",
7077
+ "isStandby",
7078
+ "screenOff"
7079
+ ]; _i1 < _iter1.length; _i1++){
7080
+ var key = _iter1[_i1];
7081
+ var value = void 0;
7082
+ try {
7083
+ value = source[key];
7084
+ if (typeof value === "function") value = value.call(source);
7085
+ } catch (unused) {
7086
+ value = void 0;
7087
+ }
7088
+ if (toBoolean(value) === true) return true;
7089
+ }
7090
+ }
7091
+ return false;
7092
+ }
7093
+ function getScreenInactiveReason() {
7094
+ if (hostStandby) return "host_standby";
7095
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
7096
+ return "document_hidden";
7097
+ }
7098
+ if (bridgeSaysStandby()) return "bridge_standby";
7099
+ return void 0;
7100
+ }
6018
7101
  // src/utils/trackingIngest.ts
6019
7102
  var DEFAULT_TRACKING_INGEST_CONFIG = {
6020
7103
  enabled: true,
@@ -6118,6 +7201,9 @@ function buildAnalyticsContext(config) {
6118
7201
  if (config.isLiveStream !== void 0) {
6119
7202
  context.inputStreamType = config.isLiveStream ? "live" : "vod";
6120
7203
  }
7204
+ if (config.sendDeviceInfoToAnalytics) {
7205
+ context.includeDeviceInfo = true;
7206
+ }
6121
7207
  return context;
6122
7208
  }
6123
7209
  function getClientInfo() {
@@ -6413,7 +7499,7 @@ function buildPlayerMetricEvent() {
6413
7499
  capture_at: captureAt
6414
7500
  }, context.inputStreamType ? {
6415
7501
  input_stream_type: context.inputStreamType
6416
- } : {})
7502
+ } : {}, context.includeDeviceInfo ? deviceInfoAnalyticsFields(getDeviceInfo()) : {})
6417
7503
  ];
6418
7504
  }
6419
7505
  });
@@ -7972,6 +9058,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
7972
9058
  return Scte35CueManager;
7973
9059
  }();
7974
9060
  // src/player/AdConfigManager.ts
9061
+ function isGamAdUrl(rawUrl) {
9062
+ try {
9063
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9064
+ } catch (unused) {
9065
+ return false;
9066
+ }
9067
+ }
7975
9068
  function withDeferredPodParams(rawUrl, deferNonce) {
7976
9069
  try {
7977
9070
  var url = new URL(rawUrl);
@@ -7990,11 +9083,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
7990
9083
  var AdConfigManager = /*#__PURE__*/ function() {
7991
9084
  "use strict";
7992
9085
  function AdConfigManager(config, video) {
9086
+ var _this = this;
7993
9087
  _class_call_check(this, AdConfigManager);
7994
9088
  this.vmapBreaks = [];
7995
9089
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
7996
9090
  this.streamCorrelator = generateCorrelator();
7997
9091
  this.consentSignals = {};
9092
+ this.isLiveStream = function() {
9093
+ return !!_this.config.isLiveStream;
9094
+ };
7998
9095
  this.podCounter = 0;
7999
9096
  this.podAssignedByPrefetch = false;
8000
9097
  this.lastHeartbeatTime = 0;
@@ -8445,9 +9542,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
8445
9542
  {
8446
9543
  key: "generatePodVastUrl",
8447
9544
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9545
+ var _content_contentDurationSeconds;
8448
9546
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
8449
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
8450
- var macroContext = _object_spread_props(_object_spread({
9547
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9548
+ fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9549
+ sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9550
+ });
9551
+ var content = resolveContentMetadata(this.config);
9552
+ var isLive = this.isLiveStream();
9553
+ var device = getDeviceInfo();
9554
+ var playerSize = resolvePlayerSize(this.video);
9555
+ var videoDuration = this.video.duration;
9556
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9557
+ var userId = resolveUserId(this.config.adUserId);
9558
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9559
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9560
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
8451
9561
  correlator: this.viewCorrelator,
8452
9562
  streamCorrelator: this.streamCorrelator,
8453
9563
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -8461,14 +9571,54 @@ var AdConfigManager = /*#__PURE__*/ function() {
8461
9571
  limitAdTracking: envSignals.limitAdTracking,
8462
9572
  deviceTypeHint: envSignals.deviceTypeHint,
8463
9573
  adTest: this.config.adTest
8464
- }, this.config.programTitle ? {
8465
- programTitle: this.config.programTitle
8466
- } : {}, this.config.channelName ? {
8467
- channelName: this.config.channelName
9574
+ }, content.programTitle ? {
9575
+ programTitle: content.programTitle
9576
+ } : {}, content.channelName ? {
9577
+ channelName: content.channelName
9578
+ } : {}, content.contentNetwork ? {
9579
+ contentNetwork: content.contentNetwork
8468
9580
  } : {}), {
8469
9581
  consent: this.consentSignals,
8470
- palNonce: palNonce.getCurrentNonce() || void 0
8471
- });
9582
+ palNonce: palNonce.getCurrentNonce() || void 0,
9583
+ deviceIdSource: envSignals.deviceIdSource,
9584
+ isLive: isLive
9585
+ }), playerSize.width ? {
9586
+ playerWidth: playerSize.width
9587
+ } : {}, playerSize.height ? {
9588
+ playerHeight: playerSize.height
9589
+ } : {}), {
9590
+ timestamp: String(Date.now())
9591
+ }), device.make ? {
9592
+ deviceMake: device.make
9593
+ } : {}, device.model ? {
9594
+ deviceModel: device.model
9595
+ } : {}, device.hardwareVersion ? {
9596
+ deviceHardwareVersion: device.hardwareVersion
9597
+ } : {}, userAgent2 ? {
9598
+ userAgent: userAgent2
9599
+ } : {}, ipAddress ? {
9600
+ ipAddress: ipAddress
9601
+ } : {}, userId ? {
9602
+ userId: userId
9603
+ } : {}, content.contentType ? {
9604
+ contentType: content.contentType
9605
+ } : {}, content.contentCategory ? {
9606
+ contentCategory: content.contentCategory
9607
+ } : {}, content.contentGenre ? {
9608
+ contentGenre: content.contentGenre
9609
+ } : {}, content.contentLanguage ? {
9610
+ contentLanguage: content.contentLanguage
9611
+ } : {}, contentDurationSeconds != null ? {
9612
+ contentDurationSeconds: contentDurationSeconds
9613
+ } : {}, content.contentSeason ? {
9614
+ contentSeason: content.contentSeason
9615
+ } : {}, content.contentEpisode ? {
9616
+ contentEpisode: content.contentEpisode
9617
+ } : {}, content.contentRating ? {
9618
+ contentRating: content.contentRating
9619
+ } : {}, content.contentId ? {
9620
+ contentId: content.contentId
9621
+ } : {});
8472
9622
  var nonceReady = !!macroContext.palNonce;
8473
9623
  var finalUrl;
8474
9624
  if (hasScvpMacros(baseUrl)) {
@@ -8482,6 +9632,31 @@ var AdConfigManager = /*#__PURE__*/ function() {
8482
9632
  } else {
8483
9633
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
8484
9634
  }
9635
+ if (isGamAdUrl(finalUrl)) {
9636
+ finalUrl = appendMissingContentParams(finalUrl, content);
9637
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9638
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9639
+ }
9640
+ }
9641
+ if (this.debug) {
9642
+ var id = envSignals.deviceId;
9643
+ console.log("[AD-IDENTITY]", {
9644
+ source: envSignals.deviceIdSource,
9645
+ idtype: envSignals.deviceIdType,
9646
+ rdidTail: id ? id.slice(-4) : void 0,
9647
+ isLat: envSignals.limitAdTracking,
9648
+ dth: envSignals.deviceTypeHint,
9649
+ sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9650
+ ct_ch: content.channelName,
9651
+ ct_ti: content.programTitle,
9652
+ ct_ne: content.contentNetwork,
9653
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9654
+ live: isLive,
9655
+ player: playerSize,
9656
+ make: device.make,
9657
+ model: device.model
9658
+ });
9659
+ }
8485
9660
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
8486
9661
  return finalUrl;
8487
9662
  }
@@ -8533,7 +9708,6 @@ var AdConfigManager = /*#__PURE__*/ function() {
8533
9708
  }
8534
9709
  },
8535
9710
  {
8536
- // --- Tracking ---
8537
9711
  key: "initializeTracking",
8538
9712
  value: function initializeTracking() {
8539
9713
  var _this = this;
@@ -8626,7 +9800,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8626
9800
  }
8627
9801
  },
8628
9802
  {
8629
- // --- Ad stop timer ---
8630
9803
  key: "scheduleAdStopCountdown",
8631
9804
  value: function scheduleAdStopCountdown(remainingMs) {
8632
9805
  var _this = this;
@@ -8658,7 +9831,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8658
9831
  }
8659
9832
  },
8660
9833
  {
8661
- // --- Ad start timer ---
8662
9834
  key: "scheduleAdStartIn",
8663
9835
  value: function scheduleAdStartIn(delayMs) {
8664
9836
  var _this = this;
@@ -8686,7 +9858,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8686
9858
  }
8687
9859
  },
8688
9860
  {
8689
- // --- PTS drift ---
8690
9861
  key: "updatePtsDrift",
8691
9862
  value: function updatePtsDrift(ptsSecondsSample) {
8692
9863
  var sampleMs = (this.video.currentTime - ptsSecondsSample) * 1e3;
@@ -8712,7 +9883,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8712
9883
  }
8713
9884
  },
8714
9885
  {
8715
- // --- Duration boundary ---
8716
9886
  key: "beginBreakTiming",
8717
9887
  value: function beginBreakTiming(startWallClockMs) {
8718
9888
  this.currentAdBreakStartWallClockMs = startWallClockMs;
@@ -8760,7 +9930,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8760
9930
  }
8761
9931
  },
8762
9932
  {
8763
- // --- Duration budget ---
8764
9933
  key: "getWallClockRemainingAdMs",
8765
9934
  value: function getWallClockRemainingAdMs() {
8766
9935
  var endWallClockMs = this.getAdBreakEndWallClockMs();
@@ -8909,7 +10078,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8909
10078
  }
8910
10079
  },
8911
10080
  {
8912
- // --- Circuit breaker ---
8913
10081
  key: "isTemporaryAdError",
8914
10082
  value: function isTemporaryAdError(error) {
8915
10083
  var _error_message;
@@ -9043,7 +10211,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9043
10211
  }
9044
10212
  },
9045
10213
  {
9046
- // --- Watchdog ---
9047
10214
  key: "startAdRequestWatchdog",
9048
10215
  value: function startAdRequestWatchdog(token) {
9049
10216
  var _this = this;
@@ -9088,7 +10255,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9088
10255
  }
9089
10256
  },
9090
10257
  {
9091
- // --- Failsafe ---
9092
10258
  key: "startAdFailsafeTimer",
9093
10259
  value: function startAdFailsafeTimer(token) {
9094
10260
  var _this = this;
@@ -9150,7 +10316,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9150
10316
  }
9151
10317
  },
9152
10318
  {
9153
- // --- Reset for ad break end ---
9154
10319
  key: "resetForBreakEnd",
9155
10320
  value: function resetForBreakEnd() {
9156
10321
  this.clearAdStopTimer();
@@ -9351,7 +10516,7 @@ var HlsEngine = /*#__PURE__*/ function() {
9351
10516
  adBehavior: adBehavior
9352
10517
  });
9353
10518
  }
9354
- if (!this.config.autoplay) return [
10519
+ if (!(this.config.autoplay && !this.callbacks.shouldHoldContentForAds())) return [
9355
10520
  3,
9356
10521
  2
9357
10522
  ];
@@ -9542,6 +10707,12 @@ var HlsEngine = /*#__PURE__*/ function() {
9542
10707
  2
9543
10708
  ];
9544
10709
  this.hasInitialBufferCompleted = true;
10710
+ if (this.shouldAutoplayAfterBuffering && this.callbacks.shouldHoldContentForAds()) {
10711
+ this.shouldAutoplayAfterBuffering = false;
10712
+ if (this.debug) {
10713
+ console.log("[StormcloudVideoPlayer] Buffer ready during an ad break; content stays paused until the break ends");
10714
+ }
10715
+ }
9545
10716
  if (!this.shouldAutoplayAfterBuffering) return [
9546
10717
  3,
9547
10718
  2
@@ -10200,9 +11371,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10200
11371
  }
10201
11372
  },
10202
11373
  {
10203
- // ───────────────────────────────────────────────────────────────
10204
- // IMA event listeners
10205
- // ───────────────────────────────────────────────────────────────
10206
11374
  key: "nextAdRequestUrl",
10207
11375
  value: function nextAdRequestUrl(baseVastUrl) {
10208
11376
  return this.host.generatePodVastUrl(baseVastUrl);
@@ -10438,9 +11606,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10438
11606
  }
10439
11607
  },
10440
11608
  {
10441
- // ───────────────────────────────────────────────────────────────
10442
- // Ad break start
10443
- // ───────────────────────────────────────────────────────────────
10444
11609
  key: "isBreakActive",
10445
11610
  value: function isBreakActive() {
10446
11611
  return this.slotState !== "IDLE";
@@ -10468,7 +11633,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10468
11633
  key: "handleAdStart",
10469
11634
  value: function handleAdStart(marker) {
10470
11635
  return _async_to_generator(function() {
10471
- var baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
11636
+ var screenInactiveReason, baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
10472
11637
  return _ts_generator(this, function(_state) {
10473
11638
  switch(_state.label){
10474
11639
  case 0:
@@ -10481,6 +11646,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10481
11646
  2
10482
11647
  ];
10483
11648
  }
11649
+ screenInactiveReason = getScreenInactiveReason();
11650
+ if (screenInactiveReason) {
11651
+ this.logOrchestratorFunnel("break_skipped_screen_inactive", {
11652
+ reason: screenInactiveReason
11653
+ });
11654
+ this.clearPendingAdBreak();
11655
+ return [
11656
+ 2
11657
+ ];
11658
+ }
10484
11659
  baseVastUrl = this.adConfig.apiVastTagUrl;
10485
11660
  edgeConfigured = !!this.host.getEdgePodBaseUrl();
10486
11661
  if (!baseVastUrl && !edgeConfigured) {
@@ -10641,12 +11816,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10641
11816
  },
10642
11817
  {
10643
11818
  key: "startOptimizedPod",
10644
- value: // ───────────────────────────────────────────────────────────────
10645
- // Optimized pod (single multi-ad request)
10646
- // ───────────────────────────────────────────────────────────────
10647
- function startOptimizedPod(baseVastUrl) {
11819
+ value: function startOptimizedPod(baseVastUrl) {
10648
11820
  return _async_to_generator(function() {
10649
- var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, error;
11821
+ var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, _this_host_config_maxAdBreakExtensionMs, remainingMs, overrunAllowanceMs, maxAdsCap, maxAds, error;
10650
11822
  return _ts_generator(this, function(_state) {
10651
11823
  switch(_state.label){
10652
11824
  case 0:
@@ -10754,6 +11926,26 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10754
11926
  false
10755
11927
  ];
10756
11928
  }
11929
+ if (this.isBreakTimeBounded() && adPlayer.limitPodToBudget) {
11930
+ ;
11931
+ remainingMs = this.timing.getRemainingAdMs();
11932
+ overrunAllowanceMs = Math.max(0, (_this_host_config_maxAdBreakExtensionMs = this.host.config.maxAdBreakExtensionMs) !== null && _this_host_config_maxAdBreakExtensionMs !== void 0 ? _this_host_config_maxAdBreakExtensionMs : 0);
11933
+ maxAdsCap = this.adConfig.resolveAdPodConfig().maxAdsPerBreak;
11934
+ maxAds = maxAdsCap != null ? Math.max(1, maxAdsCap - this.timing.totalAdsInBreak) : Number.MAX_SAFE_INTEGER;
11935
+ if (Number.isFinite(remainingMs)) {
11936
+ podCount = adPlayer.limitPodToBudget(remainingMs + overrunAllowanceMs, maxAds);
11937
+ if (podCount < 1) {
11938
+ if (this.timing.activeAdRequestToken === requestToken) {
11939
+ this.timing.activeAdRequestToken = null;
11940
+ }
11941
+ this.recordRequestFailure(new Error("No GAM ad fits the ".concat(Math.round(remainingMs), "ms left in the break")), podUrl);
11942
+ return [
11943
+ 2,
11944
+ false
11945
+ ];
11946
+ }
11947
+ }
11948
+ }
10757
11949
  this.setSlotState("READY", "vast_ready");
10758
11950
  if (this.debug) {
10759
11951
  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"));
@@ -10823,9 +12015,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10823
12015
  }
10824
12016
  },
10825
12017
  {
10826
- // ───────────────────────────────────────────────────────────────
10827
- // Edge-first pods (live SCTE-35 only, GAM fallback)
10828
- // ───────────────────────────────────────────────────────────────
10829
12018
  key: "resetEdgeStateForBreak",
10830
12019
  value: function resetEdgeStateForBreak() {
10831
12020
  this.edgeExhaustedForBreak = false;
@@ -11043,9 +12232,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11043
12232
  }
11044
12233
  },
11045
12234
  {
11046
- // ───────────────────────────────────────────────────────────────
11047
- // Next-ad scheduling (single flight)
11048
- // ───────────────────────────────────────────────────────────────
11049
12235
  key: "setSlotState",
11050
12236
  value: function setSlotState(next, reason) {
11051
12237
  if (this.slotState === next) return;
@@ -11095,6 +12281,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11095
12281
  {
11096
12282
  key: "getStopRequestingReason",
11097
12283
  value: function getStopRequestingReason(remainingMs) {
12284
+ var screenInactiveReason = getScreenInactiveReason();
12285
+ if (screenInactiveReason) return "screen_inactive:".concat(screenInactiveReason);
11098
12286
  if (this.breakSource === "vmap") {
11099
12287
  if (this.adPodQueue.length === 0) return "vmap_queue_empty";
11100
12288
  } else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl && !this.canRequestEdge()) {
@@ -11368,9 +12556,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11368
12556
  }
11369
12557
  },
11370
12558
  {
11371
- // ───────────────────────────────────────────────────────────────
11372
- // Per-request diagnostics
11373
- // ───────────────────────────────────────────────────────────────
11374
12559
  key: "recordRequestDiagnostic",
11375
12560
  value: function recordRequestDiagnostic(payload) {
11376
12561
  var requestId = payload.requestId;
@@ -11444,9 +12629,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11444
12629
  }
11445
12630
  },
11446
12631
  {
11447
- // ───────────────────────────────────────────────────────────────
11448
- // Single ad playback
11449
- // ───────────────────────────────────────────────────────────────
11450
12632
  key: "createGamDispatchFinalizer",
11451
12633
  value: function createGamDispatchFinalizer(requestToken) {
11452
12634
  var _this = this;
@@ -11909,9 +13091,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11909
13091
  }
11910
13092
  },
11911
13093
  {
11912
- // ───────────────────────────────────────────────────────────────
11913
- // Ad break completion
11914
- // ───────────────────────────────────────────────────────────────
11915
13094
  key: "logBreakFunnel",
11916
13095
  value: function logBreakFunnel(endReason) {
11917
13096
  var funnel = this.breakFunnel;
@@ -12558,6 +13737,8 @@ var ContentHealthWatchdog = /*#__PURE__*/ function() {
12558
13737
  return ContentHealthWatchdog;
12559
13738
  }();
12560
13739
  // src/player/StormcloudVideoPlayer.ts
13740
+ var DEFAULT_PAL_NONCE_MAX_AGE_MS = 5.5 * 60 * 60 * 1e3;
13741
+ var PAL_NONCE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
12561
13742
  var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12562
13743
  "use strict";
12563
13744
  function StormcloudVideoPlayer(config) {
@@ -12569,6 +13750,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12569
13750
  var browserOverrides = getBrowserConfigOverrides();
12570
13751
  this.config = _object_spread({}, browserOverrides, config);
12571
13752
  this.video = config.videoElement;
13753
+ if (this.config.forceSingleDecoderMode != null) {
13754
+ setSingleDecoderOverride(this.config.forceSingleDecoderMode);
13755
+ }
13756
+ if (this.config.adDeviceId) {
13757
+ setHostAdIdentity({
13758
+ deviceId: this.config.adDeviceId,
13759
+ deviceIdType: this.config.adDeviceIdType,
13760
+ limitAdTracking: this.config.adLimitAdTracking
13761
+ });
13762
+ }
13763
+ if (this.config.deviceInfo) {
13764
+ setHostDeviceInfo(this.config.deviceInfo);
13765
+ }
12572
13766
  logBrowserInfo(config.debugAdTiming);
12573
13767
  this.floorLadder = new FloorLadderController();
12574
13768
  this.adPlayer = this.createAdPlayer(false);
@@ -12632,8 +13826,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12632
13826
  },
12633
13827
  hasPendingAdBreak: function hasPendingAdBreak() {
12634
13828
  return _this.adBreak.pendingAdBreak !== null;
13829
+ },
13830
+ shouldHoldContentForAds: function shouldHoldContentForAds() {
13831
+ return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
12635
13832
  }
12636
13833
  });
13834
+ this.adConfig.isLiveStream = function() {
13835
+ return _this.hlsEngine.isLiveStream;
13836
+ };
12637
13837
  this.adBreak = new AdBreakOrchestrator({
12638
13838
  config: this.config,
12639
13839
  video: this.video,
@@ -12827,10 +14027,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12827
14027
  },
12828
14028
  {
12829
14029
  key: "load",
12830
- value: // ───────────────────────────────────────────────────────────────
12831
- // Lifecycle
12832
- // ───────────────────────────────────────────────────────────────
12833
- function load() {
14030
+ value: function load() {
12834
14031
  return _async_to_generator(function() {
12835
14032
  var _this, error, palDescriptionUrl, continueLiveStreamDuringAds;
12836
14033
  return _ts_generator(this, function(_state) {
@@ -12840,6 +14037,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12840
14037
  if (!this.attached) {
12841
14038
  this.attach();
12842
14039
  }
14040
+ primeDeviceInfo().then(function(info) {
14041
+ if (_this.debug) {
14042
+ console.log("[DEVICE-INFO]", _object_spread_props(_object_spread({}, info), {
14043
+ internalDeviceId: info.internalDeviceId ? "...".concat(info.internalDeviceId.slice(-4)) : void 0
14044
+ }));
14045
+ }
14046
+ }).catch(function() {});
12843
14047
  _state.label = 1;
12844
14048
  case 1:
12845
14049
  _state.trys.push([
@@ -12874,21 +14078,30 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12874
14078
  fetchConsentSignals().catch(function() {
12875
14079
  return {};
12876
14080
  }).then(function(signals) {
12877
- var _this_config_lowLatencyMode;
14081
+ var _this_config_palContinuousPlayback, _this_config_lowLatencyMode, _this_config_palIconsSupported, _this_config_palSupportedApiFrameworks;
12878
14082
  _this.adConfig.consentSignals = signals;
12879
14083
  var muted = _this.video.muted;
12880
- return _this.palNonce.generateNonce(_object_spread({
14084
+ var palSessionId = _this.config.ctvAdRequest ? getOrRotateSessionId(_this.config.sessionIdMaxAgeMs) : void 0;
14085
+ var palOptions = _object_spread({
12881
14086
  videoWidth: _this.video.offsetWidth || _this.video.clientWidth || 640,
12882
14087
  videoHeight: _this.video.offsetHeight || _this.video.clientHeight || 480,
12883
14088
  adWillAutoPlay: !!_this.config.autoplay,
12884
14089
  adWillPlayMuted: muted,
12885
14090
  playerVolume: muted ? 0 : _this.video.volume,
12886
- continuousPlayback: (_this_config_lowLatencyMode = _this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
14091
+ 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,
14092
+ iconsSupported: (_this_config_palIconsSupported = _this.config.palIconsSupported) !== null && _this_config_palIconsSupported !== void 0 ? _this_config_palIconsSupported : false,
14093
+ supportedApiFrameworks: (_this_config_palSupportedApiFrameworks = _this.config.palSupportedApiFrameworks) !== null && _this_config_palSupportedApiFrameworks !== void 0 ? _this_config_palSupportedApiFrameworks : ""
12887
14094
  }, palDescriptionUrl ? {
12888
14095
  descriptionUrl: palDescriptionUrl
12889
14096
  } : {}, signals.storageAllowed != null ? {
12890
14097
  allowStorage: signals.storageAllowed
12891
- } : {}));
14098
+ } : {}, palSessionId ? {
14099
+ sessionId: palSessionId
14100
+ } : {});
14101
+ _this.lastPalOptions = palOptions;
14102
+ _this.palSessionId = palSessionId;
14103
+ _this.startPalNonceRefresh();
14104
+ return _this.palNonce.generateNonce(palOptions);
12892
14105
  }).catch(function() {});
12893
14106
  this.adConfig.initializeTracking();
12894
14107
  if (!this.hlsEngine.shouldUseNativeHls(function() {
@@ -12926,6 +14139,96 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12926
14139
  }).call(this);
12927
14140
  }
12928
14141
  },
14142
+ {
14143
+ key: "startPalNonceRefresh",
14144
+ value: function startPalNonceRefresh() {
14145
+ var _this = this;
14146
+ if (this.palRefreshTimer != null || typeof window === "undefined") return;
14147
+ this.palRefreshTimer = window.setInterval(function() {
14148
+ return _this.refreshPalNonceIfStale();
14149
+ }, PAL_NONCE_CHECK_INTERVAL_MS);
14150
+ }
14151
+ },
14152
+ {
14153
+ key: "refreshPalNonceIfStale",
14154
+ value: function refreshPalNonceIfStale() {
14155
+ var force = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
14156
+ var _this_config_palNonceMaxAgeMs;
14157
+ var options = this.lastPalOptions;
14158
+ if (!options) return;
14159
+ var maxAgeMs = (_this_config_palNonceMaxAgeMs = this.config.palNonceMaxAgeMs) !== null && _this_config_palNonceMaxAgeMs !== void 0 ? _this_config_palNonceMaxAgeMs : DEFAULT_PAL_NONCE_MAX_AGE_MS;
14160
+ var ageMs = this.palNonce.getNonceAgeMs();
14161
+ var sessionId = this.config.ctvAdRequest ? getOrRotateSessionId(this.config.sessionIdMaxAgeMs) : void 0;
14162
+ var sessionChanged = sessionId !== this.palSessionId;
14163
+ var stale = ageMs === void 0 || ageMs >= maxAgeMs;
14164
+ if (!force && !stale && !sessionChanged) return;
14165
+ var next = _object_spread({}, options);
14166
+ if (sessionId) next.sessionId = sessionId;
14167
+ else delete next.sessionId;
14168
+ this.lastPalOptions = next;
14169
+ this.palSessionId = sessionId;
14170
+ if (this.debug) {
14171
+ console.log("[PAL] Regenerating nonce", {
14172
+ force: force,
14173
+ stale: stale,
14174
+ sessionChanged: sessionChanged,
14175
+ ageMs: ageMs
14176
+ });
14177
+ }
14178
+ this.palNonce.generateNonce(next).catch(function() {});
14179
+ }
14180
+ },
14181
+ {
14182
+ key: "setAdIdentity",
14183
+ value: function setAdIdentity(identity) {
14184
+ setHostAdIdentity(identity);
14185
+ this.refreshPalNonceIfStale();
14186
+ }
14187
+ },
14188
+ {
14189
+ key: "resetAdIdentity",
14190
+ value: function resetAdIdentity1() {
14191
+ resetAdIdentity();
14192
+ this.refreshPalNonceIfStale(true);
14193
+ }
14194
+ },
14195
+ {
14196
+ key: "setContentMetadata",
14197
+ value: function setContentMetadata(meta) {
14198
+ applyContentMetadataUpdate(this.config, meta);
14199
+ }
14200
+ },
14201
+ {
14202
+ key: "setRequestSignals",
14203
+ value: function setRequestSignals(signals) {
14204
+ if (signals.userId !== void 0) {
14205
+ if (signals.userId) this.config.adUserId = signals.userId;
14206
+ else delete this.config.adUserId;
14207
+ }
14208
+ if (signals.ipAddress !== void 0) {
14209
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14210
+ else delete this.config.clientIpAddress;
14211
+ }
14212
+ }
14213
+ },
14214
+ {
14215
+ key: "setScreenStandby",
14216
+ value: function setScreenStandby(standby) {
14217
+ setHostStandby(standby);
14218
+ }
14219
+ },
14220
+ {
14221
+ key: "getDeviceInfo",
14222
+ value: function getDeviceInfo1() {
14223
+ return getDeviceInfo();
14224
+ }
14225
+ },
14226
+ {
14227
+ key: "setDeviceInfo",
14228
+ value: function setDeviceInfo(info) {
14229
+ setHostDeviceInfo(info);
14230
+ }
14231
+ },
12929
14232
  {
12930
14233
  key: "onManifestParsed",
12931
14234
  value: function onManifestParsed(isLive) {
@@ -13060,9 +14363,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13060
14363
  }
13061
14364
  },
13062
14365
  {
13063
- // ───────────────────────────────────────────────────────────────
13064
- // SCTE-35 marker orchestration
13065
- // ───────────────────────────────────────────────────────────────
13066
14366
  key: "onScte35Marker",
13067
14367
  value: function onScte35Marker(marker, cueKey) {
13068
14368
  if (this.debug) {
@@ -13241,9 +14541,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13241
14541
  }
13242
14542
  },
13243
14543
  {
13244
- // ───────────────────────────────────────────────────────────────
13245
- // Ad prefetch
13246
- // ───────────────────────────────────────────────────────────────
13247
14544
  key: "startAdPrefetch",
13248
14545
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
13249
14546
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
@@ -13282,9 +14579,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13282
14579
  }
13283
14580
  },
13284
14581
  {
13285
- // ───────────────────────────────────────────────────────────────
13286
- // VMAP time-based ad breaks
13287
- // ───────────────────────────────────────────────────────────────
13288
14582
  key: "onTimeUpdate",
13289
14583
  value: function onTimeUpdate(currentTimeSec) {
13290
14584
  var _this = this;
@@ -13398,9 +14692,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13398
14692
  }
13399
14693
  },
13400
14694
  {
13401
- // ───────────────────────────────────────────────────────────────
13402
- // Public API
13403
- // ───────────────────────────────────────────────────────────────
13404
14695
  key: "getCurrentAdIndex",
13405
14696
  value: function getCurrentAdIndex() {
13406
14697
  return this.timing.currentAdIndex;
@@ -13519,12 +14810,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13519
14810
  }
13520
14811
  },
13521
14812
  {
13522
- // ───────────────────────────────────────────────────────────────
13523
- // Destroy
13524
- // ───────────────────────────────────────────────────────────────
13525
14813
  key: "destroy",
13526
14814
  value: function destroy() {
13527
14815
  var _this_adPlayer;
14816
+ if (this.palRefreshTimer != null) {
14817
+ clearInterval(this.palRefreshTimer);
14818
+ this.palRefreshTimer = void 0;
14819
+ }
13528
14820
  this.contentWatchdog.stop();
13529
14821
  this.adBreak.cancelScheduledRequest();
13530
14822
  this.timing.destroy();
@@ -13632,7 +14924,7 @@ var CRITICAL_PROPS = [
13632
14924
  var CONTROLS_HIDE_DELAY = 3e3;
13633
14925
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
13634
14926
  var StormcloudVideoPlayerComponent = React.memo(function(props) {
13635
- 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, [
14927
+ var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, isLiveStream = props.isLiveStream, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastTagUrl = props.vastTagUrl, isVmap = props.isVmap, vmapUrl = props.vmapUrl, minSegmentsBeforePlay = props.minSegmentsBeforePlay, ctvAdRequest = props.ctvAdRequest, programTitle = props.programTitle, channelName = props.channelName, contentNetwork = props.contentNetwork, contentDetails = props.contentDetails, adUserId = props.adUserId, clientIpAddress = props.clientIpAddress, minRemainingMsToStartAd = props.minRemainingMsToStartAd, minRemainingMsToRequestAd = props.minRemainingMsToRequestAd, maxNoFillsPerBreak = props.maxNoFillsPerBreak, maxAdBreakExtensionMs = props.maxAdBreakExtensionMs, adDeviceId = props.adDeviceId, adDeviceIdType = props.adDeviceIdType, adLimitAdTracking = props.adLimitAdTracking, fallbackDeviceIdMaxAgeMs = props.fallbackDeviceIdMaxAgeMs, sessionIdMaxAgeMs = props.sessionIdMaxAgeMs, palIconsSupported = props.palIconsSupported, palSupportedApiFrameworks = props.palSupportedApiFrameworks, palContinuousPlayback = props.palContinuousPlayback, palNonceMaxAgeMs = props.palNonceMaxAgeMs, forceSingleDecoderMode = props.forceSingleDecoderMode, deviceInfo = props.deviceInfo, sendDeviceKeyValues = props.sendDeviceKeyValues, sendDeviceInfoToAnalytics = props.sendDeviceInfoToAnalytics, restVideoAttrs = _object_without_properties(props, [
13636
14928
  "src",
13637
14929
  "autoplay",
13638
14930
  "muted",
@@ -13666,10 +14958,26 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
13666
14958
  "programTitle",
13667
14959
  "channelName",
13668
14960
  "contentNetwork",
14961
+ "contentDetails",
14962
+ "adUserId",
14963
+ "clientIpAddress",
13669
14964
  "minRemainingMsToStartAd",
13670
14965
  "minRemainingMsToRequestAd",
13671
14966
  "maxNoFillsPerBreak",
13672
- "maxAdBreakExtensionMs"
14967
+ "maxAdBreakExtensionMs",
14968
+ "adDeviceId",
14969
+ "adDeviceIdType",
14970
+ "adLimitAdTracking",
14971
+ "fallbackDeviceIdMaxAgeMs",
14972
+ "sessionIdMaxAgeMs",
14973
+ "palIconsSupported",
14974
+ "palSupportedApiFrameworks",
14975
+ "palContinuousPlayback",
14976
+ "palNonceMaxAgeMs",
14977
+ "forceSingleDecoderMode",
14978
+ "deviceInfo",
14979
+ "sendDeviceKeyValues",
14980
+ "sendDeviceInfoToAnalytics"
13673
14981
  ]);
13674
14982
  var videoRef = useRef(null);
13675
14983
  var playerRef = useRef(null);
@@ -13861,10 +15169,26 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
13861
15169
  if (programTitle !== void 0) cfg.programTitle = programTitle;
13862
15170
  if (channelName !== void 0) cfg.channelName = channelName;
13863
15171
  if (contentNetwork !== void 0) cfg.contentNetwork = contentNetwork;
15172
+ if (contentDetails !== void 0) cfg.contentDetails = contentDetails;
15173
+ if (adUserId !== void 0) cfg.adUserId = adUserId;
15174
+ if (clientIpAddress !== void 0) cfg.clientIpAddress = clientIpAddress;
13864
15175
  if (minRemainingMsToStartAd !== void 0) cfg.minRemainingMsToStartAd = minRemainingMsToStartAd;
13865
15176
  if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
13866
15177
  if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;
13867
15178
  if (maxAdBreakExtensionMs !== void 0) cfg.maxAdBreakExtensionMs = maxAdBreakExtensionMs;
15179
+ if (adDeviceId !== void 0) cfg.adDeviceId = adDeviceId;
15180
+ if (adDeviceIdType !== void 0) cfg.adDeviceIdType = adDeviceIdType;
15181
+ if (adLimitAdTracking !== void 0) cfg.adLimitAdTracking = adLimitAdTracking;
15182
+ if (fallbackDeviceIdMaxAgeMs !== void 0) cfg.fallbackDeviceIdMaxAgeMs = fallbackDeviceIdMaxAgeMs;
15183
+ if (sessionIdMaxAgeMs !== void 0) cfg.sessionIdMaxAgeMs = sessionIdMaxAgeMs;
15184
+ if (palIconsSupported !== void 0) cfg.palIconsSupported = palIconsSupported;
15185
+ if (palSupportedApiFrameworks !== void 0) cfg.palSupportedApiFrameworks = palSupportedApiFrameworks;
15186
+ if (palContinuousPlayback !== void 0) cfg.palContinuousPlayback = palContinuousPlayback;
15187
+ if (palNonceMaxAgeMs !== void 0) cfg.palNonceMaxAgeMs = palNonceMaxAgeMs;
15188
+ if (forceSingleDecoderMode !== void 0) cfg.forceSingleDecoderMode = forceSingleDecoderMode;
15189
+ if (deviceInfo !== void 0) cfg.deviceInfo = deviceInfo;
15190
+ if (sendDeviceKeyValues !== void 0) cfg.sendDeviceKeyValues = sendDeviceKeyValues;
15191
+ if (sendDeviceInfoToAnalytics !== void 0) cfg.sendDeviceInfoToAnalytics = sendDeviceInfoToAnalytics;
13868
15192
  var player = new StormcloudVideoPlayer(cfg);
13869
15193
  playerRef.current = player;
13870
15194
  player.load().then(function() {
@@ -13904,6 +15228,60 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
13904
15228
  autoplay,
13905
15229
  muted
13906
15230
  ]);
15231
+ useEffect(function() {
15232
+ var _playerRef_current;
15233
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15234
+ channelName: channelName !== null && channelName !== void 0 ? channelName : null,
15235
+ programTitle: programTitle !== null && programTitle !== void 0 ? programTitle : null,
15236
+ contentNetwork: contentNetwork !== null && contentNetwork !== void 0 ? contentNetwork : null
15237
+ });
15238
+ }, [
15239
+ channelName,
15240
+ programTitle,
15241
+ contentNetwork
15242
+ ]);
15243
+ var contentDetailsKey = contentDetails ? JSON.stringify(contentDetails) : "";
15244
+ useEffect(function() {
15245
+ var _playerRef_current;
15246
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15247
+ details: contentDetailsKey ? JSON.parse(contentDetailsKey) : null
15248
+ });
15249
+ }, [
15250
+ contentDetailsKey
15251
+ ]);
15252
+ useEffect(function() {
15253
+ var _playerRef_current;
15254
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setRequestSignals({
15255
+ userId: adUserId !== null && adUserId !== void 0 ? adUserId : null,
15256
+ ipAddress: clientIpAddress !== null && clientIpAddress !== void 0 ? clientIpAddress : null
15257
+ });
15258
+ }, [
15259
+ adUserId,
15260
+ clientIpAddress
15261
+ ]);
15262
+ var lastAdDeviceIdRef = useRef(void 0);
15263
+ useEffect(function() {
15264
+ var player = playerRef.current;
15265
+ if (!player) return;
15266
+ if (adDeviceId === void 0 && lastAdDeviceIdRef.current === void 0) return;
15267
+ lastAdDeviceIdRef.current = adDeviceId;
15268
+ player.setAdIdentity(adDeviceId ? {
15269
+ deviceId: adDeviceId,
15270
+ deviceIdType: adDeviceIdType,
15271
+ limitAdTracking: adLimitAdTracking
15272
+ } : null);
15273
+ }, [
15274
+ adDeviceId,
15275
+ adDeviceIdType,
15276
+ adLimitAdTracking
15277
+ ]);
15278
+ var deviceInfoKey = deviceInfo ? JSON.stringify(deviceInfo) : "";
15279
+ useEffect(function() {
15280
+ if (!playerRef.current || !deviceInfoKey) return;
15281
+ playerRef.current.setDeviceInfo(JSON.parse(deviceInfoKey));
15282
+ }, [
15283
+ deviceInfoKey
15284
+ ]);
13907
15285
  useEffect(function() {
13908
15286
  if (!playerRef.current) return;
13909
15287
  var checkAdStatus = function checkAdStatus() {