suada-components 1.9.0 → 1.10.0

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 (96) hide show
  1. package/dist/{components/DailyMotion-B7yDPBbg.js → DailyMotion-DacNkqsi.js} +1 -1
  2. package/dist/{components/DailyMotion-BmnymjR1.esm.js → DailyMotion-gaY-1HqX.esm.js} +1 -1
  3. package/dist/{components/Facebook-D9Ak6ZJU.esm.js → Facebook-C_tH1Bi_.esm.js} +1 -1
  4. package/dist/{components/Facebook-42iqQU2G.js → Facebook-D4wLMJkY.js} +1 -1
  5. package/dist/{components/FilePlayer-CAnHK0Cd.js → FilePlayer-B4s5OcYq.js} +1 -1
  6. package/dist/{components/FilePlayer-wg9lyafD.esm.js → FilePlayer-DqR2mvGK.esm.js} +1 -1
  7. package/dist/{components/Kaltura-DPaEN-dq.esm.js → Kaltura-C9QbmEfO.esm.js} +1 -1
  8. package/dist/{components/Kaltura-Ct6kwbgP.js → Kaltura-kCqUZWuf.js} +1 -1
  9. package/dist/{components/Mixcloud-sBbcL5rG.js → Mixcloud-2c71b3Nf.js} +1 -1
  10. package/dist/{components/Mixcloud-BobSN3YI.esm.js → Mixcloud-ib_DIXF1.esm.js} +1 -1
  11. package/dist/{components/Mux-Cosy8sFO.js → Mux-BsXgGo6C.js} +1 -1
  12. package/dist/{components/Mux-B9YP-rFr.esm.js → Mux-CJ6kEh1R.esm.js} +1 -1
  13. package/dist/{components/Preview-DiVfo6aa.js → Preview-gEkhA4mX.js} +1 -1
  14. package/dist/{components/Preview-XcTlhHT1.esm.js → Preview-kqr7fWet.esm.js} +1 -1
  15. package/dist/{components/SoundCloud-CIWqB-QW.js → SoundCloud-BWup2g--.js} +1 -1
  16. package/dist/{components/SoundCloud-BTHoyFWT.esm.js → SoundCloud-DJM0bsQG.esm.js} +1 -1
  17. package/dist/{components/Streamable-DsfQCy3p.esm.js → Streamable-CJltauTy.esm.js} +1 -1
  18. package/dist/{components/Streamable-9anYiQtU.js → Streamable-UeTHV2nZ.js} +1 -1
  19. package/dist/{components/Twitch-D1BOr8hj.esm.js → Twitch-C9qq_89Q.esm.js} +1 -1
  20. package/dist/{components/Twitch-Dud6e1Rv.js → Twitch-_N8mEsiS.js} +1 -1
  21. package/dist/{components/Vidyard-BuOu85uS.js → Vidyard-CQuxB99Z.js} +1 -1
  22. package/dist/{components/Vidyard-C1csjpQH.esm.js → Vidyard-gtcLQdYd.esm.js} +1 -1
  23. package/dist/{components/Vimeo-CHlHIswX.esm.js → Vimeo-Dzp5eoLi.esm.js} +1 -1
  24. package/dist/{components/Vimeo-DrDJ5O9H.js → Vimeo-nhXVoFTb.js} +1 -1
  25. package/dist/{components/Wistia-fh9U2CA2.js → Wistia-C1DqA9IW.js} +1 -1
  26. package/dist/{components/Wistia-D-eYyONb.esm.js → Wistia-DV3BO3z9.esm.js} +1 -1
  27. package/dist/{components/YouTube-CmnnzZvk.esm.js → YouTube-BKwvJCnt.esm.js} +1 -1
  28. package/dist/{components/YouTube-DC2uZ14c.js → YouTube-DDou5phH.js} +1 -1
  29. package/dist/components/CourseCard/CourseCard.styles.d.ts +1 -1
  30. package/dist/components/DailyMotion-B8IJNjSc.js +180 -0
  31. package/dist/components/DailyMotion-COg3zgIZ.esm.js +178 -0
  32. package/dist/components/Facebook-DJ7a3Bj8.js +181 -0
  33. package/dist/components/Facebook-NS80Vk6j.esm.js +179 -0
  34. package/dist/components/FilePlayer-D-fc3B0E.esm.js +408 -0
  35. package/dist/components/FilePlayer-SyLt5qGX.js +410 -0
  36. package/dist/components/Kaltura-BTFxSMxP.js +178 -0
  37. package/dist/components/Kaltura-CmFIWSef.esm.js +176 -0
  38. package/dist/components/Mixcloud-CO5MsWUJ.esm.js +164 -0
  39. package/dist/components/Mixcloud-DHAfVpcc.js +166 -0
  40. package/dist/components/Mux-C8-HithD.esm.js +264 -0
  41. package/dist/components/Mux-bycDxP8G.js +266 -0
  42. package/dist/components/Preview-Clg3y6sj.esm.js +173 -0
  43. package/dist/components/Preview-CzpcknZI.js +175 -0
  44. package/dist/components/SoundCloud-Dz9DeIIM.js +183 -0
  45. package/dist/components/SoundCloud-LfWEBVy1.esm.js +181 -0
  46. package/dist/components/Streamable-BpcVhi4M.esm.js +174 -0
  47. package/dist/components/Streamable-Cs_c-7jS.js +176 -0
  48. package/dist/components/Twitch-BJ9aSIM2.esm.js +168 -0
  49. package/dist/components/Twitch-C9bksXF6.js +170 -0
  50. package/dist/components/VideoPlayer/PiPContext.d.ts +8 -0
  51. package/dist/components/VideoPlayer/PiPContext.js +149 -0
  52. package/dist/components/VideoPlayer/PiPContext.js.map +1 -0
  53. package/dist/components/VideoPlayer/PiPContext.types.d.ts +16 -0
  54. package/dist/components/VideoPlayer/PiPContext.types.js +2 -0
  55. package/dist/components/VideoPlayer/PiPContext.types.js.map +1 -0
  56. package/dist/components/VideoPlayer/usePiP.d.ts +2 -0
  57. package/dist/components/VideoPlayer/usePiP.js +10 -0
  58. package/dist/components/VideoPlayer/usePiP.js.map +1 -0
  59. package/dist/components/VideoPlayer/usePlayerControls.js +46 -64
  60. package/dist/components/VideoPlayer/usePlayerControls.js.map +1 -1
  61. package/dist/components/Vidyard-CsUFSBXh.js +174 -0
  62. package/dist/components/Vidyard-Dc8NHJ7p.esm.js +172 -0
  63. package/dist/components/Vimeo-CwlScNtK.esm.js +213 -0
  64. package/dist/components/Vimeo-D6C93592.js +215 -0
  65. package/dist/components/Wistia-Bxvdn3oO.js +190 -0
  66. package/dist/components/Wistia-Cwl4fNWW.esm.js +188 -0
  67. package/dist/components/YouTube-BF85SRPF.js +260 -0
  68. package/dist/components/YouTube-DKkYzN7-.esm.js +258 -0
  69. package/dist/components/components/CourseCard/CourseCard.styles.d.ts +1 -1
  70. package/dist/components/components/VideoPlayer/PiPContext.d.ts +8 -0
  71. package/dist/components/components/VideoPlayer/PiPContext.types.d.ts +16 -0
  72. package/dist/components/components/VideoPlayer/usePiP.d.ts +2 -0
  73. package/dist/components/components/index.d.ts +2 -0
  74. package/dist/components/{index-DetZ05pw.js → index-C08W0lXg.js} +157 -295
  75. package/dist/components/{index-DKAGRUEW.esm.js → index-F6zEoSWf.esm.js} +156 -296
  76. package/dist/components/index.d.ts +2 -0
  77. package/dist/components/index.esm.js +1 -1
  78. package/dist/components/index.js +2 -0
  79. package/dist/components/index.js.map +1 -1
  80. package/dist/icons/components/CourseCard/CourseCard.styles.d.ts +1 -1
  81. package/dist/icons/components/VideoPlayer/PiPContext.d.ts +8 -0
  82. package/dist/icons/components/VideoPlayer/PiPContext.types.d.ts +16 -0
  83. package/dist/icons/components/VideoPlayer/usePiP.d.ts +2 -0
  84. package/dist/icons/components/index.d.ts +2 -0
  85. package/dist/index-CcTTuhg8.esm.js +94920 -0
  86. package/dist/index-Dq4qpx9F.js +95142 -0
  87. package/dist/index.d.ts +2 -0
  88. package/dist/index.esm.js +3 -3
  89. package/dist/index.js +3 -0
  90. package/dist/index.js.map +1 -1
  91. package/package.json +1 -1
  92. package/dist/components/VideoPlayer/pipManager.d.ts +0 -60
  93. package/dist/components/VideoPlayer/pipManager.js +0 -272
  94. package/dist/components/VideoPlayer/pipManager.js.map +0 -1
  95. package/dist/components/components/VideoPlayer/pipManager.d.ts +0 -60
  96. package/dist/icons/components/VideoPlayer/pipManager.d.ts +0 -60
@@ -81375,7 +81375,7 @@ function requirePlayers () {
81375
81375
  canPlay: import_patterns.canPlay.youtube,
81376
81376
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81377
81377
  /* webpackChunkName: 'reactPlayerYouTube' */
81378
- './YouTube-DC2uZ14c.js'
81378
+ './YouTube-BF85SRPF.js'
81379
81379
  ); }).then(function (n) { return n.YouTube; }))
81380
81380
  },
81381
81381
  {
@@ -81384,7 +81384,7 @@ function requirePlayers () {
81384
81384
  canPlay: import_patterns.canPlay.soundcloud,
81385
81385
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81386
81386
  /* webpackChunkName: 'reactPlayerSoundCloud' */
81387
- './SoundCloud-CIWqB-QW.js'
81387
+ './SoundCloud-Dz9DeIIM.js'
81388
81388
  ); }).then(function (n) { return n.SoundCloud; }))
81389
81389
  },
81390
81390
  {
@@ -81393,7 +81393,7 @@ function requirePlayers () {
81393
81393
  canPlay: import_patterns.canPlay.vimeo,
81394
81394
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81395
81395
  /* webpackChunkName: 'reactPlayerVimeo' */
81396
- './Vimeo-DrDJ5O9H.js'
81396
+ './Vimeo-D6C93592.js'
81397
81397
  ); }).then(function (n) { return n.Vimeo; }))
81398
81398
  },
81399
81399
  {
@@ -81402,7 +81402,7 @@ function requirePlayers () {
81402
81402
  canPlay: import_patterns.canPlay.mux,
81403
81403
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81404
81404
  /* webpackChunkName: 'reactPlayerMux' */
81405
- './Mux-Cosy8sFO.js'
81405
+ './Mux-bycDxP8G.js'
81406
81406
  ); }).then(function (n) { return n.Mux; }))
81407
81407
  },
81408
81408
  {
@@ -81411,7 +81411,7 @@ function requirePlayers () {
81411
81411
  canPlay: import_patterns.canPlay.facebook,
81412
81412
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81413
81413
  /* webpackChunkName: 'reactPlayerFacebook' */
81414
- './Facebook-42iqQU2G.js'
81414
+ './Facebook-DJ7a3Bj8.js'
81415
81415
  ); }).then(function (n) { return n.Facebook; }))
81416
81416
  },
81417
81417
  {
@@ -81420,7 +81420,7 @@ function requirePlayers () {
81420
81420
  canPlay: import_patterns.canPlay.streamable,
81421
81421
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81422
81422
  /* webpackChunkName: 'reactPlayerStreamable' */
81423
- './Streamable-9anYiQtU.js'
81423
+ './Streamable-Cs_c-7jS.js'
81424
81424
  ); }).then(function (n) { return n.Streamable; }))
81425
81425
  },
81426
81426
  {
@@ -81429,7 +81429,7 @@ function requirePlayers () {
81429
81429
  canPlay: import_patterns.canPlay.wistia,
81430
81430
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81431
81431
  /* webpackChunkName: 'reactPlayerWistia' */
81432
- './Wistia-fh9U2CA2.js'
81432
+ './Wistia-Bxvdn3oO.js'
81433
81433
  ); }).then(function (n) { return n.Wistia; }))
81434
81434
  },
81435
81435
  {
@@ -81438,7 +81438,7 @@ function requirePlayers () {
81438
81438
  canPlay: import_patterns.canPlay.twitch,
81439
81439
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81440
81440
  /* webpackChunkName: 'reactPlayerTwitch' */
81441
- './Twitch-Dud6e1Rv.js'
81441
+ './Twitch-C9bksXF6.js'
81442
81442
  ); }).then(function (n) { return n.Twitch; }))
81443
81443
  },
81444
81444
  {
@@ -81447,7 +81447,7 @@ function requirePlayers () {
81447
81447
  canPlay: import_patterns.canPlay.dailymotion,
81448
81448
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81449
81449
  /* webpackChunkName: 'reactPlayerDailyMotion' */
81450
- './DailyMotion-B7yDPBbg.js'
81450
+ './DailyMotion-B8IJNjSc.js'
81451
81451
  ); }).then(function (n) { return n.DailyMotion; }))
81452
81452
  },
81453
81453
  {
@@ -81456,7 +81456,7 @@ function requirePlayers () {
81456
81456
  canPlay: import_patterns.canPlay.mixcloud,
81457
81457
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81458
81458
  /* webpackChunkName: 'reactPlayerMixcloud' */
81459
- './Mixcloud-sBbcL5rG.js'
81459
+ './Mixcloud-DHAfVpcc.js'
81460
81460
  ); }).then(function (n) { return n.Mixcloud; }))
81461
81461
  },
81462
81462
  {
@@ -81465,7 +81465,7 @@ function requirePlayers () {
81465
81465
  canPlay: import_patterns.canPlay.vidyard,
81466
81466
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81467
81467
  /* webpackChunkName: 'reactPlayerVidyard' */
81468
- './Vidyard-BuOu85uS.js'
81468
+ './Vidyard-CsUFSBXh.js'
81469
81469
  ); }).then(function (n) { return n.Vidyard; }))
81470
81470
  },
81471
81471
  {
@@ -81474,7 +81474,7 @@ function requirePlayers () {
81474
81474
  canPlay: import_patterns.canPlay.kaltura,
81475
81475
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81476
81476
  /* webpackChunkName: 'reactPlayerKaltura' */
81477
- './Kaltura-Ct6kwbgP.js'
81477
+ './Kaltura-BTFxSMxP.js'
81478
81478
  ); }).then(function (n) { return n.Kaltura; }))
81479
81479
  },
81480
81480
  {
@@ -81486,7 +81486,7 @@ function requirePlayers () {
81486
81486
  },
81487
81487
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81488
81488
  /* webpackChunkName: 'reactPlayerFilePlayer' */
81489
- './FilePlayer-CAnHK0Cd.js'
81489
+ './FilePlayer-SyLt5qGX.js'
81490
81490
  ); }).then(function (n) { return n.FilePlayer; }))
81491
81491
  }
81492
81492
  ];
@@ -82307,7 +82307,7 @@ function requireReactPlayer () {
82307
82307
  var import_Player = __toESM(/*@__PURE__*/ requirePlayer());
82308
82308
  const Preview = (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
82309
82309
  /* webpackChunkName: 'reactPlayerPreview' */
82310
- './Preview-DiVfo6aa.js'
82310
+ './Preview-CzpcknZI.js'
82311
82311
  ); }).then(function (n) { return n.Preview; }));
82312
82312
  const IS_BROWSER = typeof window !== "undefined" && window.document && typeof document !== "undefined";
82313
82313
  const IS_GLOBAL = typeof commonjsGlobal !== "undefined" && commonjsGlobal.window && commonjsGlobal.window.document;
@@ -88758,153 +88758,69 @@ var useEventListener = function useEventListener(eventName, handler, element, sh
88758
88758
  }, [eventName, element, shouldRun]);
88759
88759
  };
88760
88760
 
88761
- /**
88762
- * Global Picture-in-Picture Manager
88763
- * This module manages PiP state across component unmounts and route changes
88764
- */
88765
- var PictureInPictureManager = /** @class */function () {
88766
- function PictureInPictureManager() {
88767
- this.videoElement = null;
88768
- this.pipContainer = null;
88769
- this.currentVideoState = null;
88770
- this.onStateChange = null;
88771
- // Listen for PiP events globally
88772
- document.addEventListener('leavepictureinpicture', this.handlePiPExit.bind(this));
88773
- document.addEventListener('enterpictureinpicture', this.handlePiPEnter.bind(this));
88774
- }
88775
- /**
88776
- * Register a video element for PiP management
88777
- */
88778
- PictureInPictureManager.prototype.registerVideo = function (videoElement, url, onStateChange) {
88779
- this.videoElement = videoElement;
88780
- this.onStateChange = onStateChange || null;
88781
- // Store current video state
88782
- this.currentVideoState = {
88783
- url: url,
88784
- currentTime: videoElement.currentTime,
88785
- isPlaying: !videoElement.paused,
88786
- volume: videoElement.volume,
88787
- playbackRate: videoElement.playbackRate
88788
- };
88789
- // Add listeners to track state changes
88790
- videoElement.addEventListener('timeupdate', this.handleTimeUpdate.bind(this));
88791
- videoElement.addEventListener('play', this.handlePlayStateChange.bind(this));
88792
- videoElement.addEventListener('pause', this.handlePlayStateChange.bind(this));
88793
- videoElement.addEventListener('volumechange', this.handleVolumeChange.bind(this));
88794
- videoElement.addEventListener('ratechange', this.handleRateChange.bind(this));
88795
- };
88796
- /**
88797
- * Unregister the current video element
88798
- */
88799
- PictureInPictureManager.prototype.unregisterVideo = function () {
88800
- if (this.videoElement) {
88801
- this.videoElement.removeEventListener('timeupdate', this.handleTimeUpdate.bind(this));
88802
- this.videoElement.removeEventListener('play', this.handlePlayStateChange.bind(this));
88803
- this.videoElement.removeEventListener('pause', this.handlePlayStateChange.bind(this));
88804
- this.videoElement.removeEventListener('volumechange', this.handleVolumeChange.bind(this));
88805
- this.videoElement.removeEventListener('ratechange', this.handleRateChange.bind(this));
88806
- }
88807
- this.videoElement = null;
88808
- this.onStateChange = null;
88809
- };
88810
- /**
88811
- * Create a persistent video element for PiP
88812
- */
88813
- PictureInPictureManager.prototype.createPersistentVideo = function (originalVideo) {
88814
- var persistentVideo = originalVideo.cloneNode(true);
88815
- // Copy all relevant properties
88816
- persistentVideo.src = originalVideo.src;
88817
- persistentVideo.currentTime = originalVideo.currentTime;
88818
- persistentVideo.volume = originalVideo.volume;
88819
- persistentVideo.playbackRate = originalVideo.playbackRate;
88820
- persistentVideo.muted = originalVideo.muted;
88821
- // Set properties for PiP
88822
- persistentVideo.style.position = 'fixed';
88823
- persistentVideo.style.top = '-9999px';
88824
- persistentVideo.style.left = '-9999px';
88825
- persistentVideo.style.width = '1px';
88826
- persistentVideo.style.height = '1px';
88827
- persistentVideo.style.opacity = '0';
88828
- persistentVideo.style.pointerEvents = 'none';
88829
- return persistentVideo;
88830
- };
88831
- /**
88832
- * Enter picture-in-picture mode with persistence
88833
- */
88834
- PictureInPictureManager.prototype.enterPiP = function () {
88835
- return __awaiter(this, void 0, void 0, function () {
88836
- var persistentVideo_1, error_1;
88761
+ var PiPContext = /*#__PURE__*/React.createContext(undefined);
88762
+ var PiPProvider = function PiPProvider(_a) {
88763
+ var children = _a.children;
88764
+ var _b = React.useState(false),
88765
+ isPiPActive = _b[0],
88766
+ setIsPiPActive = _b[1];
88767
+ var _c = React.useState(null),
88768
+ pipVideoState = _c[0],
88769
+ setPipVideoState = _c[1];
88770
+ var videoElementRef = React.useRef(null);
88771
+ var updateVideoState = React.useCallback(function (state) {
88772
+ setPipVideoState(function (prev) {
88773
+ return prev ? __assign(__assign({}, prev), state) : null;
88774
+ });
88775
+ }, []);
88776
+ var registerVideoElement = React.useCallback(function (element) {
88777
+ videoElementRef.current = element;
88778
+ }, []);
88779
+ var unregisterVideoElement = React.useCallback(function () {
88780
+ videoElementRef.current = null;
88781
+ }, []);
88782
+ var enterPiP = React.useCallback(function (videoElement, videoState) {
88783
+ return __awaiter(void 0, void 0, void 0, function () {
88784
+ var error_1;
88837
88785
  return __generator(this, function (_a) {
88838
88786
  switch (_a.label) {
88839
88787
  case 0:
88840
- if (!this.videoElement || !document.pictureInPictureEnabled) {
88841
- return [2 /*return*/];
88788
+ if (!document.pictureInPictureEnabled) {
88789
+ console.warn('Picture-in-Picture is not supported in this browser');
88790
+ return [2 /*return*/, false];
88791
+ }
88792
+ if (document.pictureInPictureElement) {
88793
+ console.warn('Another video is already in Picture-in-Picture mode');
88794
+ return [2 /*return*/, false];
88842
88795
  }
88843
88796
  _a.label = 1;
88844
88797
  case 1:
88845
- _a.trys.push([1, 6,, 7]);
88846
- if (!document.pictureInPictureElement) return [3 /*break*/, 3];
88847
- return [4 /*yield*/, document.exitPictureInPicture()];
88798
+ _a.trys.push([1, 5,, 6]);
88799
+ // Store video state
88800
+ setPipVideoState(videoState);
88801
+ videoElementRef.current = videoElement;
88802
+ if (!(videoElement.paused && videoState.isPlaying)) return [3 /*break*/, 3];
88803
+ return [4 /*yield*/, videoElement.play()];
88848
88804
  case 2:
88849
88805
  _a.sent();
88850
88806
  _a.label = 3;
88851
88807
  case 3:
88852
- // Create a container if it doesn't exist
88853
- if (!this.pipContainer) {
88854
- this.pipContainer = document.createElement('div');
88855
- this.pipContainer.id = 'suada-pip-container';
88856
- this.pipContainer.style.position = 'fixed';
88857
- this.pipContainer.style.top = '-9999px';
88858
- this.pipContainer.style.left = '-9999px';
88859
- this.pipContainer.style.width = '1px';
88860
- this.pipContainer.style.height = '1px';
88861
- this.pipContainer.style.zIndex = '-1';
88862
- document.body.appendChild(this.pipContainer);
88863
- }
88864
- persistentVideo_1 = this.createPersistentVideo(this.videoElement);
88865
- this.pipContainer.appendChild(persistentVideo_1);
88866
- // Wait for video to load
88867
- return [4 /*yield*/, new Promise(function (resolve) {
88868
- if (persistentVideo_1.readyState >= 2) {
88869
- resolve();
88870
- } else {
88871
- persistentVideo_1.addEventListener('loadedmetadata', function () {
88872
- return resolve();
88873
- }, {
88874
- once: true
88875
- });
88876
- }
88877
- })
88878
- // Enter PiP mode
88879
- ];
88808
+ return [4 /*yield*/, videoElement.requestPictureInPicture()];
88880
88809
  case 4:
88881
- // Wait for video to load
88882
88810
  _a.sent();
88883
- // Enter PiP mode
88884
- return [4 /*yield*/, persistentVideo_1.requestPictureInPicture()
88885
- // Update the reference to the persistent video
88886
- ];
88811
+ return [2 /*return*/, true];
88887
88812
  case 5:
88888
- // Enter PiP mode
88889
- _a.sent();
88890
- // Update the reference to the persistent video
88891
- this.videoElement = persistentVideo_1;
88892
- return [3 /*break*/, 7];
88893
- case 6:
88894
88813
  error_1 = _a.sent();
88895
88814
  console.error('Failed to enter picture-in-picture:', error_1);
88896
- return [3 /*break*/, 7];
88897
- case 7:
88815
+ return [2 /*return*/, false];
88816
+ case 6:
88898
88817
  return [2 /*return*/];
88899
88818
  }
88900
88819
  });
88901
88820
  });
88902
- };
88903
- /**
88904
- * Exit picture-in-picture mode
88905
- */
88906
- PictureInPictureManager.prototype.exitPiP = function () {
88907
- return __awaiter(this, void 0, void 0, function () {
88821
+ }, []);
88822
+ var exitPiP = React.useCallback(function () {
88823
+ return __awaiter(void 0, void 0, void 0, function () {
88908
88824
  var error_2;
88909
88825
  return __generator(this, function (_a) {
88910
88826
  switch (_a.label) {
@@ -88916,88 +88832,56 @@ var PictureInPictureManager = /** @class */function () {
88916
88832
  _a.sent();
88917
88833
  _a.label = 2;
88918
88834
  case 2:
88919
- return [3 /*break*/, 4];
88835
+ return [2 /*return*/, true];
88920
88836
  case 3:
88921
88837
  error_2 = _a.sent();
88922
88838
  console.error('Failed to exit picture-in-picture:', error_2);
88923
- return [3 /*break*/, 4];
88839
+ return [2 /*return*/, false];
88924
88840
  case 4:
88925
88841
  return [2 /*return*/];
88926
88842
  }
88927
88843
  });
88928
88844
  });
88845
+ }, []);
88846
+ // Listen for PiP events
88847
+ React.useEffect(function () {
88848
+ var handlePiPEnter = function handlePiPEnter() {
88849
+ setIsPiPActive(true);
88850
+ };
88851
+ var handlePiPLeave = function handlePiPLeave() {
88852
+ setIsPiPActive(false);
88853
+ // Keep the video state for potential restoration
88854
+ // but don't clear it immediately
88855
+ };
88856
+ document.addEventListener('enterpictureinpicture', handlePiPEnter);
88857
+ document.addEventListener('leavepictureinpicture', handlePiPLeave);
88858
+ return function () {
88859
+ document.removeEventListener('enterpictureinpicture', handlePiPEnter);
88860
+ document.removeEventListener('leavepictureinpicture', handlePiPLeave);
88861
+ };
88862
+ }, []);
88863
+ var value = {
88864
+ isPiPActive: isPiPActive,
88865
+ pipVideoState: pipVideoState,
88866
+ enterPiP: enterPiP,
88867
+ exitPiP: exitPiP,
88868
+ updateVideoState: updateVideoState,
88869
+ registerVideoElement: registerVideoElement,
88870
+ unregisterVideoElement: unregisterVideoElement
88929
88871
  };
88930
- /**
88931
- * Check if currently in PiP mode
88932
- */
88933
- PictureInPictureManager.prototype.isPiPActive = function () {
88934
- return !!document.pictureInPictureElement;
88935
- };
88936
- /**
88937
- * Get current video state
88938
- */
88939
- PictureInPictureManager.prototype.getCurrentState = function () {
88940
- return this.currentVideoState;
88941
- };
88942
- /**
88943
- * Restore video state to a new video element
88944
- */
88945
- PictureInPictureManager.prototype.restoreStateToVideo = function (videoElement) {
88946
- if (!this.currentVideoState) return;
88947
- videoElement.currentTime = this.currentVideoState.currentTime;
88948
- videoElement.volume = this.currentVideoState.volume;
88949
- videoElement.playbackRate = this.currentVideoState.playbackRate;
88950
- if (this.currentVideoState.isPlaying) {
88951
- videoElement.play()["catch"](console.error);
88952
- }
88953
- };
88954
- PictureInPictureManager.prototype.handleTimeUpdate = function () {
88955
- if (this.videoElement && this.currentVideoState) {
88956
- this.currentVideoState.currentTime = this.videoElement.currentTime;
88957
- this.notifyStateChange();
88958
- }
88959
- };
88960
- PictureInPictureManager.prototype.handlePlayStateChange = function () {
88961
- if (this.videoElement && this.currentVideoState) {
88962
- this.currentVideoState.isPlaying = !this.videoElement.paused;
88963
- this.notifyStateChange();
88964
- }
88965
- };
88966
- PictureInPictureManager.prototype.handleVolumeChange = function () {
88967
- if (this.videoElement && this.currentVideoState) {
88968
- this.currentVideoState.volume = this.videoElement.volume;
88969
- this.notifyStateChange();
88970
- }
88971
- };
88972
- PictureInPictureManager.prototype.handleRateChange = function () {
88973
- if (this.videoElement && this.currentVideoState) {
88974
- this.currentVideoState.playbackRate = this.videoElement.playbackRate;
88975
- this.notifyStateChange();
88976
- }
88977
- };
88978
- PictureInPictureManager.prototype.handlePiPEnter = function () {
88979
- console.log('Entered picture-in-picture mode');
88980
- };
88981
- PictureInPictureManager.prototype.handlePiPExit = function () {
88982
- console.log('Exited picture-in-picture mode');
88983
- this.cleanup();
88984
- };
88985
- PictureInPictureManager.prototype.notifyStateChange = function () {
88986
- if (this.onStateChange && this.currentVideoState) {
88987
- this.onStateChange(this.currentVideoState);
88988
- }
88989
- };
88990
- PictureInPictureManager.prototype.cleanup = function () {
88991
- // Clean up the persistent container
88992
- if (this.pipContainer && this.pipContainer.parentNode) {
88993
- this.pipContainer.parentNode.removeChild(this.pipContainer);
88994
- this.pipContainer = null;
88995
- }
88996
- };
88997
- return PictureInPictureManager;
88998
- }();
88999
- // Create a singleton instance
89000
- var pipManager = new PictureInPictureManager();
88872
+ return jsxRuntimeExports.jsx(PiPContext.Provider, {
88873
+ value: value,
88874
+ children: children
88875
+ });
88876
+ };
88877
+
88878
+ var usePiP = function usePiP() {
88879
+ var context = React.useContext(PiPContext);
88880
+ if (context === undefined) {
88881
+ throw new Error('usePiP must be used within a PiPProvider');
88882
+ }
88883
+ return context;
88884
+ };
89001
88885
 
89002
88886
  var count = 0;
89003
88887
  var defaultVideoState = {
@@ -89030,26 +88914,30 @@ function usePlayerControls(_a) {
89030
88914
  isSubtitlesChecked = _e[0],
89031
88915
  setIsSubtitlesChecked = _e[1];
89032
88916
  var _f = React.useState(false),
89033
- isPiPActive = _f[0],
89034
- setIsPiPActive = _f[1];
88917
+ isFullscreen = _f[0],
88918
+ setIsFullscreen = _f[1];
89035
88919
  var _g = React.useState(false),
89036
- isFullscreen = _g[0],
89037
- setIsFullscreen = _g[1];
89038
- var _h = React.useState(false),
89039
- isControlsActive = _h[0],
89040
- setIsControlsActive = _h[1];
88920
+ isControlsActive = _g[0],
88921
+ setIsControlsActive = _g[1];
89041
88922
  var videoPlayerRef = React.useRef(null);
89042
88923
  var controlRef = React.useRef(null);
89043
88924
  var playerContainerRef = React.useRef(null);
89044
- var _j = React.useState([]),
89045
- subtitles = _j[0],
89046
- setSubtitles = _j[1];
89047
- var _k = React.useState(''),
89048
- currentSubtitle = _k[0],
89049
- setCurrentSubtitle = _k[1];
88925
+ var _h = React.useState([]),
88926
+ subtitles = _h[0],
88927
+ setSubtitles = _h[1];
88928
+ var _j = React.useState(''),
88929
+ currentSubtitle = _j[0],
88930
+ setCurrentSubtitle = _j[1];
89050
88931
  var lastSubtitleIndexRef = React.useRef(null);
89051
88932
  var lastPlaybackTimeRef = React.useRef(0);
89052
88933
  var lastCallTimeRef = React.useRef(Date.now());
88934
+ // Use PiP context instead of local state
88935
+ var _k = usePiP(),
88936
+ isPiPActive = _k.isPiPActive,
88937
+ enterPiP = _k.enterPiP,
88938
+ exitPiP = _k.exitPiP,
88939
+ registerVideoElement = _k.registerVideoElement,
88940
+ unregisterVideoElement = _k.unregisterVideoElement;
89053
88941
  var muted = videoState.muted,
89054
88942
  volume = videoState.volume,
89055
88943
  prevVolume = videoState.prevVolume,
@@ -89079,12 +88967,21 @@ function usePlayerControls(_a) {
89079
88967
  setIsFullscreen(!!document.fullscreenElement);
89080
88968
  };
89081
88969
  var handlePiPEnter = function handlePiPEnter() {
89082
- setIsPiPActive(true);
88970
+ var _a;
88971
+ // Use context method to update global PiP state
88972
+ var videoElement = (_a = videoPlayerRef.current) === null || _a === void 0 ? void 0 : _a.getInternalPlayer();
88973
+ if (videoElement && videoElement instanceof HTMLVideoElement) {
88974
+ enterPiP(videoElement, {
88975
+ url: url,
88976
+ currentTime: videoElement.currentTime,
88977
+ isPlaying: isPlaying,
88978
+ volume: videoState.volume,
88979
+ muted: videoState.muted
88980
+ });
88981
+ }
89083
88982
  };
89084
88983
  var handlePiPLeave = function handlePiPLeave() {
89085
- setIsPiPActive(false);
89086
- // Also cleanup the PiP manager when PiP exits
89087
- pipManager.unregisterVideo();
88984
+ exitPiP();
89088
88985
  };
89089
88986
  document.addEventListener('fullscreenchange', handleFullscreenChange);
89090
88987
  document.addEventListener('enterpictureinpicture', handlePiPEnter);
@@ -89094,6 +88991,8 @@ function usePlayerControls(_a) {
89094
88991
  if (videoElement && videoElement instanceof HTMLVideoElement) {
89095
88992
  videoElement.addEventListener('enterpictureinpicture', handlePiPEnter);
89096
88993
  videoElement.addEventListener('leavepictureinpicture', handlePiPLeave);
88994
+ // Register video element with PiP context
88995
+ registerVideoElement(videoElement);
89097
88996
  }
89098
88997
  return function () {
89099
88998
  document.removeEventListener('fullscreenchange', handleFullscreenChange);
@@ -89104,37 +89003,25 @@ function usePlayerControls(_a) {
89104
89003
  videoElement.removeEventListener('enterpictureinpicture', handlePiPEnter);
89105
89004
  videoElement.removeEventListener('leavepictureinpicture', handlePiPLeave);
89106
89005
  }
89006
+ // Unregister video element from PiP context
89007
+ unregisterVideoElement();
89107
89008
  };
89108
- }, [url]); // Re-run when URL changes to ensure proper cleanup and setup
89009
+ }, [url, enterPiP, exitPiP, registerVideoElement, unregisterVideoElement, isPlaying, videoState.volume, videoState.muted]); // Re-run when URL changes to ensure proper cleanup and setup
89109
89010
  React.useEffect(function () {
89110
89011
  setStartPlayed(false);
89111
- // Check if there's an active PiP session and restore state
89112
- if (pipManager.isPiPActive()) {
89113
- var savedState_1 = pipManager.getCurrentState();
89114
- if (savedState_1 && savedState_1.url === url) {
89115
- setIsPiPActive(true);
89116
- // Restore video state from PiP manager
89117
- setVideoState(function (prev) {
89118
- var _a;
89119
- return __assign(__assign({}, prev), {
89120
- volume: savedState_1.volume,
89121
- playbackRate: savedState_1.playbackRate,
89122
- played: savedState_1.currentTime / (((_a = videoPlayerRef.current) === null || _a === void 0 ? void 0 : _a.getDuration()) || 1)
89123
- });
89124
- });
89125
- setIsPlaying(savedState_1.isPlaying);
89126
- }
89127
- }
89128
- }, [url, setIsPlaying]);
89012
+ }, [url]);
89129
89013
  // Cleanup effect to handle component unmounting while in PiP mode
89130
89014
  React.useEffect(function () {
89015
+ var currentVideoPlayerRef = videoPlayerRef.current;
89131
89016
  return function () {
89132
- // Unregister from PiP manager when component unmounts
89133
- pipManager.unregisterVideo();
89134
89017
  // Check if we're in PiP mode when component unmounts
89135
89018
  if (document.pictureInPictureElement) {
89136
- // The PiP manager will handle keeping the video alive
89137
- console.log('Component unmounting while in Picture-in-Picture mode - PiP will persist');
89019
+ // Try to keep the video element alive by cloning it
89020
+ var videoElement = currentVideoPlayerRef === null || currentVideoPlayerRef === void 0 ? void 0 : currentVideoPlayerRef.getInternalPlayer();
89021
+ if (videoElement && videoElement instanceof HTMLVideoElement) {
89022
+ // Create a warning for the user that PiP will exit
89023
+ console.log('Component unmounting while in Picture-in-Picture mode');
89024
+ }
89138
89025
  }
89139
89026
  };
89140
89027
  }, []);
@@ -89308,18 +89195,9 @@ function usePlayerControls(_a) {
89308
89195
  if (videoPlayerRef.current && !startPlayed) {
89309
89196
  videoPlayerRef.current.seekTo(startTime);
89310
89197
  setStartPlayed(true);
89311
- // Register video with PiP manager when it's ready
89312
- var videoElement = videoPlayerRef.current.getInternalPlayer();
89313
- if (videoElement && videoElement instanceof HTMLVideoElement) {
89314
- // Restore state if there was a previous PiP session
89315
- var savedState = pipManager.getCurrentState();
89316
- if (savedState && savedState.url === url && pipManager.isPiPActive()) {
89317
- pipManager.restoreStateToVideo(videoElement);
89318
- }
89319
- }
89320
89198
  }
89321
89199
  setLoading(false);
89322
- }, [startTime, startPlayed, setLoading, url]);
89200
+ }, [startTime, startPlayed, setLoading]);
89323
89201
  var handleFullScreen = function handleFullScreen() {
89324
89202
  var playerContainer = playerContainerRef.current;
89325
89203
  if (!playerContainer) {
@@ -89341,37 +89219,19 @@ function usePlayerControls(_a) {
89341
89219
  console.warn('Picture-in-Picture is not supported in this browser');
89342
89220
  return;
89343
89221
  }
89344
- if (document.pictureInPictureElement) {
89345
- pipManager.exitPiP()["catch"](function (error) {
89346
- console.error('Failed to exit picture-in-picture:', error);
89347
- });
89222
+ if (isPiPActive) {
89223
+ // Exit PiP using context method
89224
+ exitPiP();
89348
89225
  } else {
89349
- // Register the video with the PiP manager
89350
- pipManager.registerVideo(videoElement, url, function (state) {
89351
- // Update local state when PiP video state changes
89352
- setVideoState(function (prev) {
89353
- return __assign(__assign({}, prev), {
89354
- played: state.currentTime / duration,
89355
- volume: state.volume,
89356
- playbackRate: state.playbackRate
89357
- });
89358
- });
89359
- setIsPlaying(state.isPlaying);
89360
- });
89361
- // Ensure the video is playing before entering PiP mode
89362
- if (videoElement.paused && isPlaying) {
89363
- videoElement.play().then(function () {
89364
- pipManager.enterPiP()["catch"](function (error) {
89365
- console.error('Failed to enter picture-in-picture:', error);
89366
- });
89367
- })["catch"](function (error) {
89368
- console.error('Failed to play video before PiP:', error);
89369
- });
89370
- } else {
89371
- pipManager.enterPiP()["catch"](function (error) {
89372
- console.error('Failed to enter picture-in-picture:', error);
89373
- });
89374
- }
89226
+ // Enter PiP using context method
89227
+ var pipVideoState = {
89228
+ url: url,
89229
+ currentTime: videoElement.currentTime,
89230
+ isPlaying: isPlaying,
89231
+ volume: videoState.volume,
89232
+ muted: videoState.muted
89233
+ };
89234
+ enterPiP(videoElement, pipVideoState);
89375
89235
  }
89376
89236
  };
89377
89237
  var handleKeyDown = React.useCallback(function (event) {
@@ -95093,6 +94953,7 @@ exports.Loader = Loader;
95093
94953
  exports.NavigationBar = NavigationBar;
95094
94954
  exports.Pagination = Pagination;
95095
94955
  exports.PhoneCountryCode = PhoneCountryCode;
94956
+ exports.PiPProvider = PiPProvider;
95096
94957
  exports.RadioButton = RadioButton;
95097
94958
  exports.RangeSlider = RangeSlider;
95098
94959
  exports.SearchInput = SearchInput;
@@ -95110,3 +94971,4 @@ exports.activeTabClassName = activeTabClassName;
95110
94971
  exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
95111
94972
  exports.requirePatterns = requirePatterns;
95112
94973
  exports.requireUtils = requireUtils;
94974
+ exports.usePiP = usePiP;