import{P as e}from"./p-BDVGDaui.js";import"./p-BxRAfMA5.js";import"./p-EuTDjLsB.js";import"./p-D8o-F2Bu.js";const n=({config:t,selector:n,src:o,preload:r})=>new Promise(async(a,s)=>{if(!window.Hls)for(;!window.hasOwnProperty("Hls");)await new Promise(e=>setTimeout(e,50));if(window.Hls.isSupported()){let s=!["metadata","none"].includes(r);wp?.blocks&&(s=!0);var l=new window.Hls(window?.wp?.hooks?.applyFilters?.("presto.hlsSettings",{autoStartLoad:s,capLevelToPlayerSize:!0}));return l.loadSource(o),l.on(window.Hls.Events.LEVEL_SWITCHED,(e,t)=>{var o=n.closest(".presto-player__wrapper").querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span");l.autoLevelEnabled?o.innerHTML=`AUTO (${l.levels[t.level].height}p)`:o.innerHTML="AUTO"}),void l.on(window.Hls.Events.MANIFEST_PARSED,function(o,r){var s=l.levels.map(function(e){return e.height});s.unshift(0);const i=(s||[]).findIndex(e=>e===parseInt(window?.prestoPlayer?.hls_start_level));l.startLevel=i?i-1:2,t.quality={default:0,options:s,forced:!0,onChange:function(e){0===e?prestoHLS.currentLevel=-1:prestoHLS.levels.forEach(function(t,n){t.height===e&&(console.log("Found quality match with "+e),prestoHLS.currentLevel=n)})}},l.attachMedia(n),window.prestoHLS=l;const p=new e(n,{...t});p.hls=l;const u=()=>{l.startLoad(-1),p.off("waiting",u)};return p.on("waiting",u),p.on("languagechange",()=>{setTimeout(()=>l.subtitleTrack=p.currentTrack,50)}),a(p)})}return n.canPlayType("application/vnd.apple.mpegurl"),a(new e(n,{...t}))});export{n as default};