// Listen for requests from content script to dispatch HLS events in page context
(function() {
  window.addEventListener('mym-dispatch-hls-request', function(e) {
    const { videoId, m3u8Url, mediaId, userToken } = e.detail;
    
    console.log('[HLS dispatcher] Dispatching mym-hls-play with mediaId:', mediaId, 'userToken:', userToken ? 'present' : 'missing');
    
    window.dispatchEvent(new CustomEvent('mym-hls-play', {
      detail: {
        videoId: videoId,
        m3u8Url: m3u8Url,
        mediaId: mediaId,
        userToken: userToken
      }
    }));
  });
  
  console.log('[HLS dispatcher] Ready to dispatch HLS events');
})();
