eb-player 2.7.0 → 2.7.1

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.
@@ -1,14 +1,14 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EBPlayer={})}(this,function(e){"use strict";var t="2.7.0";"undefined"==typeof globalThis&&"undefined"!=typeof window&&(window.globalThis=window);const i={idle:["loading"],loading:["playing","buffering","paused","error","idle"],playing:["paused","buffering","ended","error","idle"],paused:["playing","loading","idle","buffering","ended"],buffering:["playing","paused","idle","error","ended"],error:["loading","idle"],ended:["loading","idle"]};class s{constructor(){this.listeners=new Map}on(e,t,i){this.listeners.has(e)||this.listeners.set(e,new Set);const s=this.listeners.get(e);s.add(t);const n=null==i?void 0:i.signal;if(void 0!==n){const e=()=>{s.delete(t)};n.addEventListener("abort",e,{once:!0})}}notify(e,t,i){const s=this.listeners.get(e);void 0!==s&&s.forEach(e=>{e(t,i)})}}const n={playbackState:"idle",volume:1,currentTime:0,duration:0,muted:!1,bufferedEnd:0,isLive:!1,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,subtitleTracks:[],currentSubtitleTrack:-1,playbackRate:1,error:null,errorCode:null,src:"",isFullscreen:!1,isPip:!1,isCasting:!1,controlsVisible:!0,settingsOpen:!1,socialsOpen:!1,infoOpen:!1,adPlaying:!1,introStreamPlaying:!1,castAvailable:!1,isRtl:!1,isRadio:!1,isIOS:!1,isSyncWithLive:!1,epgPrograms:[],epgFetchedAt:0,chapters:[],playlist:[],currentEpisode:-1,reconnecting:!1,toast:null};function r(e){const t=Object.assign(Object.assign({},n),e),r=new s;return new Proxy(t,{get:(e,t)=>"on"===t?r.on.bind(r):e[t],set(e,t,s){const n=t;if(!function(e){if(null==e||"object"!=typeof e)return!0;if(Array.isArray(e))return!0;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s))throw new TypeError(`PlayerState: cannot assign a non-plain object (class instance) to "${String(t)}". Only primitives, plain objects, arrays, null, and undefined are allowed. Driver instances (hls.js, dash.js) must never enter the state store.`);if("playbackState"===n){const t=e.playbackState,n=s;if(o=n,!i[t].includes(o))return console.warn(`FSM: rejected playbackState transition "${t}" → "${n}"`),!0}var o;const a=e[n];if(a===s)return!0;return e[String(n)]=s,r.notify(n,s,a),!0}})}class o{constructor(){this.listeners=new Map}on(e,t,i){const s=null==i?void 0:i.signal;if(!0===(null==s?void 0:s.aborted))return;this.listeners.has(e)||this.listeners.set(e,new Set);const n=this.listeners.get(e),r=t;n.add(r),void 0!==s&&s.addEventListener("abort",()=>{n.delete(r)},{once:!0})}emit(...e){const[t,i]=e,s=this.listeners.get(t);if(void 0!==s&&0!==s.size)for(const e of s)void 0!==i?e(i):e()}dispose(){this.listeners.clear()}}const a={topBar:{left:[],right:["share","info"]},bottomBar:{left:["play-pause","volume"],center:["seekbar"],right:["time","live-sync","settings","pip","cast","fullscreen"]},middleBar:{left:["rewind"],center:[],right:["forward"]}},l=[{value:"default",label:"Default"},{value:"forja",label:"Forja",primaryColor:"#FC013B"},{value:"radio",label:"Radio",primaryColor:"#F4A261"},{value:"snrt",label:"SNRT",primaryColor:"#006633"},{value:"modern",label:"Modern",primaryColor:"#7c3aed"},{value:"v2",label:"V2",primaryColor:"#3d4097"},{value:"lequipe",label:"L'Equipe",primaryColor:"#d61e00"}],c={topBar:{left:[],right:["pip","settings"]},bottomBar:{left:["live-sync","time","channel-name"],center:["play-pause","seekbar","volume","fullscreen"],right:[]},middleBar:{left:["rewind"],center:[],right:["forward"]}},d={v2:c,lequipe:{topBar:{left:[],right:["pip","settings"]},bottomBar:{left:["play-pause","live-sync","time"],center:["seekbar"],right:["volume","fullscreen"]},middleBar:{left:["rewind"],center:[],right:["forward"]}},modern:c,forja:{topBar:{left:[],right:[]},bottomBar:{left:["seekbar"],center:["play-pause","volume"],right:["live-sync","settings","pip","fullscreen"]},middleBar:{left:["rewind"],center:[],right:["forward"]}}};function u(e){var t;const i=e.skin?d[e.skin]:void 0,s=null!=i?i:a;return null!==(t=e.layout)&&void 0!==t?t:s}const h={template:"",el:"#eb_player",skin:"default",start:!0,forceAutoplayAudio:!1,style:void 0,css:"",dashjs:"https://reference.dashif.org/dash.js/v4.7.4/dist/dash.all.min.js",hlsjs:"https://cdn.jsdelivr.net/npm/hls.js@1.6.10/dist/hls.min.js",engineSettings:{liveSyncDurationCount:3},chromecast:"https://cdnjs.cloudflare.com/ajax/libs/castjs/5.3.0/cast.min.js",chromecastApp:void 0,chromecastMetadata:void 0,src:void 0,autoplay:!0,muted:!0,image:!1,loop:!1,startAt:void 0,loading:!0,logo:void 0,logoLink:void 0,logoPositions:["top-left"],about:"Powered by EasyBroadcast.",primaryColor:"#1FA9DD",skinColor:"",skinColors:{general:"",progressBar:"",volumeBar:""},socials:!1,customSocialsShare:!1,seekbar:!0,middlebar:!0,pip:!0,retry:!0,lowLatency:!1,ad:void 0,radio:!1,token:void 0,tokenType:void 0,srcInTokenRequest:!1,sentryDsn:void 0,onError:null,messages:null,subtitleStyle:null,defaultAudio:void 0,defaultSubtitle:void 0,forceAutoplay:!1,forceQuality:!1,liveButton:!1,syncLiveMargin:30,isLive:void 0,noUi:!1,preroll:!1,prerollSkip:1/0,prerollLink:!1,posterStream:!1,speed:!0,chapters:null,skippableChapters:[],seekOffset:15,supportHotKeys:!1,useGeoblockingErrorHandle:!1,extraParamsCallback:void 0,licenseXhrSetup:void 0,volume:1,lib:void 0,manager:"wss://manager.kube.easybroadcast.fr/easybroadcast/Xc152ogNOWvOZSH",stats:"https://stats.easybroadcast.fr",origin:"easybroadcast",content:void 0,libSettings:{resourceManager:{timeoutV2V:4500,storageSize:300,randomWaitForPeers:[1e3,3e3],partialRequest:!0,setEnableV2V:!0}},hasPlaylistPicker:!1,disableCustomAbr:!0,lang:void 0,rtl:void 0,epgContentId:void 0,epgPolling:null,epgDefaultLang:"en",showEpgTitlePreview:!1,showProgressThumb:!1,channelName:void 0,layout:void 0};function v(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function g(e,t){if("function"==typeof t)return t;if(Array.isArray(t))return[...t];if(v(t)&&v(e)){const i={};for(const t of Object.keys(e))i[t]=e[t];for(const s of Object.keys(t))i[s]=g(e[s],t[s]);return i}if(v(t)){const e={};for(const i of Object.keys(t))e[i]=g(void 0,t[i]);return e}return void 0!==t?t:e}function p(...e){let t={};for(const i of e)null!=i&&(t=g(t,i));return t}const m=["en","fr","ar","es"],f={"error.start":{en:"An error occurred while trying to start the video.",fr:"Une erreur est survenue lors de la tentative de demarrage de la video.",ar:"An error occurred while trying to start the video.",es:"Ocurrió un error al intentar iniciar el video."},"loading.reconnecting":{en:"Reconnecting...",fr:"Reconnexion...",ar:"Reconnecting...",es:"Reconectando..."},"error.stream_unavailable":{en:"The stream is unavailable. Please try again later.",fr:"Le flux est indisponible. Veuillez réessayer plus tard.",ar:"The stream is unavailable. Please try again later.",es:"La transmisión no está disponible. Por favor, inténtelo más tarde."},"error.geoblocked":{en:"This content is not available in your region.",fr:"Ce contenu n'est pas disponible dans votre région.",ar:"This content is not available in your region.",es:"Este contenido no está disponible en tu región."},"error.unsupported_browser":{en:"Your browser is too old to play this video. Please update it or use another browser.",fr:"Votre navigateur est trop ancien pour lire cette vidéo. Veuillez le mettre à jour ou utiliser un autre navigateur.",ar:"متصفحك قديم جدًا لتشغيل هذا الفيديو. يرجى تحديثه أو استخدام متصفح آخر.",es:"Su navegador es demasiado antiguo para reproducir este video. Actualícelo o utilice otro navegador."},"error.hls_init_failed":{en:"The video could not be started. Please try again later.",fr:"La vidéo n'a pas pu démarrer. Veuillez réessayer plus tard.",ar:"تعذّر بدء تشغيل الفيديو. يرجى المحاولة لاحقًا.",es:"No se pudo iniciar el video. Inténtelo de nuevo más tarde."},"error.dash_init_failed":{en:"The video could not be started. Please try again later.",fr:"La vidéo n'a pas pu démarrer. Veuillez réessayer plus tard.",ar:"تعذّر بدء تشغيل الفيديو. يرجى المحاولة لاحقًا.",es:"No se pudo iniciar el video. Inténtelo de nuevo más tarde."},"error.drm_error":{en:"This protected content could not be played on your device.",fr:"Ce contenu protégé n'a pas pu être lu sur votre appareil.",ar:"تعذّر تشغيل هذا المحتوى المحمي على جهازك.",es:"Este contenido protegido no se pudo reproducir en su dispositivo."},"error.load_never_started":{en:"The video is taking too long to load. Please check your connection and try again.",fr:"La vidéo met trop de temps à se charger. Vérifiez votre connexion et réessayez.",ar:"يستغرق تحميل الفيديو وقتًا طويلًا. تحقق من اتصالك وحاول مرة أخرى.",es:"El video tarda demasiado en cargar. Compruebe su conexión e inténtelo de nuevo."},"error.no_video_element":{en:"The player could not be initialized.",fr:"Le lecteur n'a pas pu être initialisé.",ar:"تعذّرت تهيئة المشغّل.",es:"No se pudo inicializar el reproductor."},"cast.failed":{en:"Casting failed. Resuming local playback.",fr:"La diffusion a échoué. Reprise de la lecture locale.",ar:"Casting failed. Resuming local playback.",es:"Error en la transmisión. Reanudando la reproducción local."},"settings.audio":{en:"Audio track",fr:"Piste audio",ar:"مسار صوتي",es:"Pista de audio"},"settings.subtitles":{en:"Subtitles",fr:"Sous-titres",ar:"ترجمات",es:"Subtítulos"},"settings.speed":{en:"Playback speed",fr:"Vitesse de lecture",ar:"سرعة التشغيل",es:"Velocidad"},"settings.quality":{en:"Quality",fr:"Qualité",ar:"الجودة",es:"Calidad"},"settings.default":{en:"Default",fr:"Défaut",ar:"افتراضي",es:"Predeterminado"},"settings.off":{en:"Off",fr:"Désactivés",ar:"إيقاف",es:"Desactivado"},"settings.normal":{en:"Normal",fr:"Normale",ar:"عادي",es:"Normal"},"settings.auto":{en:"Auto",fr:"Auto",ar:"تلقائي",es:"Auto"},"preroll.skip":{en:"Skip",fr:"Passer",ar:"تخطي",es:"Saltar"}};function b(e){if(void 0===e||""===e)return"en";const t=e.split(/[-_]/)[0].toLowerCase();return m.includes(t)?t:"en"}class y{constructor(e){this.currentLocale=b(e),this.translations=Object.assign({},f)}addTranslations(e){for(const t of Object.keys(e))this.translations[t]=Object.assign(Object.assign({},this.translations[t]),e[t])}addMessages(e){const t={};for(const i of Object.keys(e)){const s=i.split(/[-_]/)[0].toLowerCase();for(const n of Object.keys(e[i]))t[n]=Object.assign(Object.assign({},t[n]),{[s]:e[i][n]})}this.addTranslations(t)}has(e){return void 0!==this.translations[e]}t(e,t){const i=this.translations[e];let s;return s=void 0===i?e:void 0!==i[this.currentLocale]?i[this.currentLocale]:void 0!==i.en?i.en:e,void 0===t||0===Object.keys(t).length?s:this.interpolate(s,t)}interpolate(e,t){return e.replace(/\{(\w+)\}/g,(e,i)=>{const s=t[i];return void 0!==s?String(s):e})}setLocale(e){this.currentLocale=b(e)}getLocale(){return this.currentLocale}}const k="STREAM_UNAVAILABLE",E="GEOBLOCKED",T="HLS_INIT_FAILED",w="DASH_INIT_FAILED",C="DRM_ERROR",L="LOAD_NEVER_STARTED",S="NO_VIDEO_ELEMENT";function x(e,t,i,s){e.errorCode=i,e.error=s,null==t||t.emit("player-error",{code:i,message:s})}function A(e,t,i){if(null===e||null===i)return t;const s=function(e){return`error.${e.toLowerCase()}`}(e);return i.has(s)?i.t(s):t}function $(e){const t=e.play();void 0!==t&&"function"==typeof t.catch&&t.catch(()=>{})}class _{constructor(e,t,i,s,n,r,o,a){this.reloadCount=0,this.successTimer=0,this.toastTimer=0,this.savedQuality=-1,this.savedAudioTrack=0,this.savedSubtitleTrack=-1,this.wireVideoCommands(e,t,i,s,n,a),this.wireEngineCommands(e,s,a),this.wireReloadOrchestration(e,i,r,o,a),this.wireCastHandoff(e,t,i,n,r,a),this.wireVolumeRouting(i,n,a),this.wireGeoblock(e,i,r,a),this.wireAbortCleanup(a)}getSavedSelections(){return{quality:this.savedQuality,audioTrack:this.savedAudioTrack,subtitleTrack:this.savedSubtitleTrack}}wireVideoCommands(e,t,i,s,n,r){e.on("play",()=>{var e;i.isCasting&&null!==n?null===(e=n.getDriver())||void 0===e||e.play():$(t)},{signal:r}),e.on("pause",()=>{var e;i.isCasting&&null!==n?null===(e=n.getDriver())||void 0===e||e.pause():t.pause()},{signal:r}),e.on("seek",({time:e})=>{var r;if(i.isCasting&&null!==n)return void(null===(r=n.getDriver())||void 0===r||r.seek(e));const o=s();null!==o?o.seek(e):t.currentTime=e},{signal:r}),e.on("mute-toggle",()=>{t.muted=!t.muted},{signal:r}),i.on("volume",e=>{i.isCasting||(t.volume=e)},{signal:r})}wireEngineCommands(e,t,i){e.on("settings-select-quality",({index:e})=>{var i;null===(i=t())||void 0===i||i.setQuality(e)},{signal:i}),e.on("settings-select-audio",({index:e})=>{var i;null===(i=t())||void 0===i||i.setAudioTrack(e)},{signal:i}),e.on("settings-select-subtitle",({index:e})=>{var i;null===(i=t())||void 0===i||i.setSubtitle(e)},{signal:i}),e.on("settings-select-speed",({rate:e})=>{var i;null===(i=t())||void 0===i||i.setPlaybackRate(e)},{signal:i}),e.on("sync-live",()=>{var e;null===(e=t())||void 0===e||e.seekToLive()},{signal:i})}wireReloadOrchestration(e,t,i,s,n){e.on("request-reload",()=>{if(this.reloadCount>=3)return t.reconnecting=!1,void x(t,e,k,i.t("error.stream_unavailable"));this.savedQuality=t.currentQuality,this.savedAudioTrack=t.currentAudioTrack,this.savedSubtitleTrack=t.currentSubtitleTrack,t.reconnecting=!0,this.reloadCount++,s()},{signal:n}),t.on("playbackState",e=>{"playing"===e?(clearTimeout(this.successTimer),this.successTimer=setTimeout(()=>{this.reloadCount=0,t.reconnecting=!1},12e4)):(clearTimeout(this.successTimer),this.successTimer=0)},{signal:n})}wireCastHandoff(e,t,i,s,n,r){e.on("cast-start",()=>{null!==s&&(t.pause(),s.toggleCast(i))},{signal:r}),e.on("cast-stop",()=>{$(t)},{signal:r}),e.on("cast-stop-with-position",({time:e})=>{t.currentTime=e,$(t)},{signal:r}),e.on("cast-failed",()=>{i.isCasting=!1,$(t),this.showToast(i,n.t("cast.failed"))},{signal:r})}wireVolumeRouting(e,t,i){null!==t&&e.on("volume",i=>{var s;e.isCasting&&(null===(s=t.getDriver())||void 0===s||s.volume(i))},{signal:i})}wireGeoblock(e,t,i,s){e.on("geoblock-detected",()=>{x(t,e,E,i.t("error.geoblocked"))},{signal:s})}showToast(e,t){e.toast=t,clearTimeout(this.toastTimer),this.toastTimer=setTimeout(()=>{e.toast=null},3e3)}wireAbortCleanup(e){e.addEventListener("abort",()=>{clearTimeout(this.successTimer),clearTimeout(this.toastTimer)},{once:!0})}}var M;
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EBPlayer={})}(this,function(e){"use strict";var t="2.7.1";"undefined"==typeof globalThis&&"undefined"!=typeof window&&(window.globalThis=window);const i={idle:["loading"],loading:["playing","buffering","paused","error","idle"],playing:["paused","buffering","ended","error","idle"],paused:["playing","loading","idle","buffering","ended"],buffering:["playing","paused","idle","error","ended"],error:["loading","idle"],ended:["loading","idle"]};class s{constructor(){this.listeners=new Map}on(e,t,i){this.listeners.has(e)||this.listeners.set(e,new Set);const s=this.listeners.get(e);s.add(t);const n=null==i?void 0:i.signal;if(void 0!==n){const e=()=>{s.delete(t)};n.addEventListener("abort",e,{once:!0})}}notify(e,t,i){const s=this.listeners.get(e);void 0!==s&&s.forEach(e=>{e(t,i)})}}const n={playbackState:"idle",volume:1,currentTime:0,duration:0,muted:!1,bufferedEnd:0,isLive:!1,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,subtitleTracks:[],currentSubtitleTrack:-1,playbackRate:1,error:null,errorCode:null,src:"",isFullscreen:!1,isPip:!1,isCasting:!1,controlsVisible:!0,settingsOpen:!1,socialsOpen:!1,infoOpen:!1,adPlaying:!1,introStreamPlaying:!1,castAvailable:!1,isRtl:!1,isRadio:!1,isIOS:!1,isSyncWithLive:!1,epgPrograms:[],epgFetchedAt:0,chapters:[],playlist:[],currentEpisode:-1,reconnecting:!1,toast:null};function r(e){const t=Object.assign(Object.assign({},n),e),r=new s;return new Proxy(t,{get:(e,t)=>"on"===t?r.on.bind(r):e[t],set(e,t,s){const n=t;if(!function(e){if(null==e||"object"!=typeof e)return!0;if(Array.isArray(e))return!0;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s))throw new TypeError(`PlayerState: cannot assign a non-plain object (class instance) to "${String(t)}". Only primitives, plain objects, arrays, null, and undefined are allowed. Driver instances (hls.js, dash.js) must never enter the state store.`);if("playbackState"===n){const t=e.playbackState,n=s;if(o=n,!i[t].includes(o))return console.warn(`FSM: rejected playbackState transition "${t}" → "${n}"`),!0}var o;const a=e[n];if(a===s)return!0;return e[String(n)]=s,r.notify(n,s,a),!0}})}class o{constructor(){this.listeners=new Map}on(e,t,i){const s=null==i?void 0:i.signal;if(!0===(null==s?void 0:s.aborted))return;this.listeners.has(e)||this.listeners.set(e,new Set);const n=this.listeners.get(e),r=t;n.add(r),void 0!==s&&s.addEventListener("abort",()=>{n.delete(r)},{once:!0})}emit(...e){const[t,i]=e,s=this.listeners.get(t);if(void 0!==s&&0!==s.size)for(const e of s)void 0!==i?e(i):e()}dispose(){this.listeners.clear()}}const a={topBar:{left:[],right:["share","info"]},bottomBar:{left:["play-pause","volume"],center:["seekbar"],right:["time","live-sync","settings","pip","cast","fullscreen"]},middleBar:{left:["rewind"],center:[],right:["forward"]}},l=[{value:"default",label:"Default"},{value:"forja",label:"Forja",primaryColor:"#FC013B"},{value:"radio",label:"Radio",primaryColor:"#F4A261"},{value:"snrt",label:"SNRT",primaryColor:"#006633"},{value:"modern",label:"Modern",primaryColor:"#7c3aed"},{value:"v2",label:"V2",primaryColor:"#3d4097"},{value:"lequipe",label:"L'Equipe",primaryColor:"#d61e00"}],c={topBar:{left:[],right:["pip","settings"]},bottomBar:{left:["live-sync","time","channel-name"],center:["play-pause","seekbar","volume","fullscreen"],right:[]},middleBar:{left:["rewind"],center:[],right:["forward"]}},d={v2:c,lequipe:{topBar:{left:[],right:["pip","settings"]},bottomBar:{left:["play-pause","live-sync","time"],center:["seekbar"],right:["volume","fullscreen"]},middleBar:{left:["rewind"],center:[],right:["forward"]}},modern:c,forja:{topBar:{left:[],right:[]},bottomBar:{left:["seekbar"],center:["play-pause","volume"],right:["live-sync","settings","pip","fullscreen"]},middleBar:{left:["rewind"],center:[],right:["forward"]}}};function u(e){var t;const i=e.skin?d[e.skin]:void 0,s=null!=i?i:a;return null!==(t=e.layout)&&void 0!==t?t:s}const h={template:"",el:"#eb_player",skin:"default",start:!0,forceAutoplayAudio:!1,style:void 0,css:"",dashjs:"https://reference.dashif.org/dash.js/v4.7.4/dist/dash.all.min.js",hlsjs:"https://cdn.jsdelivr.net/npm/hls.js@1.6.10/dist/hls.min.js",engineSettings:{liveSyncDurationCount:3},chromecast:"https://cdnjs.cloudflare.com/ajax/libs/castjs/5.3.0/cast.min.js",chromecastApp:void 0,chromecastMetadata:void 0,src:void 0,autoplay:!0,muted:!0,image:!1,loop:!1,startAt:void 0,loading:!0,logo:void 0,logoLink:void 0,logoPositions:["top-left"],about:"Powered by EasyBroadcast.",primaryColor:"#1FA9DD",skinColor:"",skinColors:{general:"",progressBar:"",volumeBar:""},socials:!1,customSocialsShare:!1,seekbar:!0,middlebar:!0,pip:!0,retry:!0,lowLatency:!1,ad:void 0,radio:!1,token:void 0,tokenType:void 0,srcInTokenRequest:!1,sentryDsn:void 0,onError:null,messages:null,subtitleStyle:null,defaultAudio:void 0,defaultSubtitle:void 0,forceAutoplay:!1,forceQuality:!1,liveButton:!1,syncLiveMargin:30,isLive:void 0,noUi:!1,preroll:!1,prerollSkip:1/0,prerollLink:!1,posterStream:!1,speed:!0,chapters:null,skippableChapters:[],seekOffset:15,supportHotKeys:!1,useGeoblockingErrorHandle:!1,extraParamsCallback:void 0,licenseXhrSetup:void 0,volume:1,lib:void 0,manager:"wss://manager.kube.easybroadcast.fr/easybroadcast/Xc152ogNOWvOZSH",stats:"https://stats.easybroadcast.fr",origin:"easybroadcast",content:void 0,libSettings:{resourceManager:{timeoutV2V:4500,storageSize:300,randomWaitForPeers:[1e3,3e3],partialRequest:!0,setEnableV2V:!0}},hasPlaylistPicker:!1,disableCustomAbr:!0,lang:void 0,rtl:void 0,epgContentId:void 0,epgPolling:null,epgDefaultLang:"en",showEpgTitlePreview:!1,showProgressThumb:!1,channelName:void 0,layout:void 0};function v(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function g(e,t){if("function"==typeof t)return t;if(Array.isArray(t))return[...t];if(v(t)&&v(e)){const i={};for(const t of Object.keys(e))i[t]=e[t];for(const s of Object.keys(t))i[s]=g(e[s],t[s]);return i}if(v(t)){const e={};for(const i of Object.keys(t))e[i]=g(void 0,t[i]);return e}return void 0!==t?t:e}function p(...e){let t={};for(const i of e)null!=i&&(t=g(t,i));return t}const m=["en","fr","ar","es"],f={"error.start":{en:"An error occurred while trying to start the video.",fr:"Une erreur est survenue lors de la tentative de demarrage de la video.",ar:"An error occurred while trying to start the video.",es:"Ocurrió un error al intentar iniciar el video."},"loading.reconnecting":{en:"Reconnecting...",fr:"Reconnexion...",ar:"Reconnecting...",es:"Reconectando..."},"error.stream_unavailable":{en:"The stream is unavailable. Please try again later.",fr:"Le flux est indisponible. Veuillez réessayer plus tard.",ar:"The stream is unavailable. Please try again later.",es:"La transmisión no está disponible. Por favor, inténtelo más tarde."},"error.geoblocked":{en:"This content is not available in your region.",fr:"Ce contenu n'est pas disponible dans votre région.",ar:"This content is not available in your region.",es:"Este contenido no está disponible en tu región."},"error.unsupported_browser":{en:"Your browser is too old to play this video. Please update it or use another browser.",fr:"Votre navigateur est trop ancien pour lire cette vidéo. Veuillez le mettre à jour ou utiliser un autre navigateur.",ar:"متصفحك قديم جدًا لتشغيل هذا الفيديو. يرجى تحديثه أو استخدام متصفح آخر.",es:"Su navegador es demasiado antiguo para reproducir este video. Actualícelo o utilice otro navegador."},"error.hls_init_failed":{en:"The video could not be started. Please try again later.",fr:"La vidéo n'a pas pu démarrer. Veuillez réessayer plus tard.",ar:"تعذّر بدء تشغيل الفيديو. يرجى المحاولة لاحقًا.",es:"No se pudo iniciar el video. Inténtelo de nuevo más tarde."},"error.dash_init_failed":{en:"The video could not be started. Please try again later.",fr:"La vidéo n'a pas pu démarrer. Veuillez réessayer plus tard.",ar:"تعذّر بدء تشغيل الفيديو. يرجى المحاولة لاحقًا.",es:"No se pudo iniciar el video. Inténtelo de nuevo más tarde."},"error.drm_error":{en:"This protected content could not be played on your device.",fr:"Ce contenu protégé n'a pas pu être lu sur votre appareil.",ar:"تعذّر تشغيل هذا المحتوى المحمي على جهازك.",es:"Este contenido protegido no se pudo reproducir en su dispositivo."},"error.load_never_started":{en:"The video is taking too long to load. Please check your connection and try again.",fr:"La vidéo met trop de temps à se charger. Vérifiez votre connexion et réessayez.",ar:"يستغرق تحميل الفيديو وقتًا طويلًا. تحقق من اتصالك وحاول مرة أخرى.",es:"El video tarda demasiado en cargar. Compruebe su conexión e inténtelo de nuevo."},"error.no_video_element":{en:"The player could not be initialized.",fr:"Le lecteur n'a pas pu être initialisé.",ar:"تعذّرت تهيئة المشغّل.",es:"No se pudo inicializar el reproductor."},"cast.failed":{en:"Casting failed. Resuming local playback.",fr:"La diffusion a échoué. Reprise de la lecture locale.",ar:"Casting failed. Resuming local playback.",es:"Error en la transmisión. Reanudando la reproducción local."},"settings.audio":{en:"Audio track",fr:"Piste audio",ar:"مسار صوتي",es:"Pista de audio"},"settings.subtitles":{en:"Subtitles",fr:"Sous-titres",ar:"ترجمات",es:"Subtítulos"},"settings.speed":{en:"Playback speed",fr:"Vitesse de lecture",ar:"سرعة التشغيل",es:"Velocidad"},"settings.quality":{en:"Quality",fr:"Qualité",ar:"الجودة",es:"Calidad"},"settings.default":{en:"Default",fr:"Défaut",ar:"افتراضي",es:"Predeterminado"},"settings.off":{en:"Off",fr:"Désactivés",ar:"إيقاف",es:"Desactivado"},"settings.normal":{en:"Normal",fr:"Normale",ar:"عادي",es:"Normal"},"settings.auto":{en:"Auto",fr:"Auto",ar:"تلقائي",es:"Auto"},"preroll.skip":{en:"Skip",fr:"Passer",ar:"تخطي",es:"Saltar"}};function b(e){if(void 0===e||""===e)return"en";const t=e.split(/[-_]/)[0].toLowerCase();return m.includes(t)?t:"en"}class y{constructor(e){this.currentLocale=b(e),this.translations=Object.assign({},f)}addTranslations(e){for(const t of Object.keys(e))this.translations[t]=Object.assign(Object.assign({},this.translations[t]),e[t])}addMessages(e){const t={};for(const i of Object.keys(e)){const s=i.split(/[-_]/)[0].toLowerCase();for(const n of Object.keys(e[i]))t[n]=Object.assign(Object.assign({},t[n]),{[s]:e[i][n]})}this.addTranslations(t)}has(e){return void 0!==this.translations[e]}t(e,t){const i=this.translations[e];let s;return s=void 0===i?e:void 0!==i[this.currentLocale]?i[this.currentLocale]:void 0!==i.en?i.en:e,void 0===t||0===Object.keys(t).length?s:this.interpolate(s,t)}interpolate(e,t){return e.replace(/\{(\w+)\}/g,(e,i)=>{const s=t[i];return void 0!==s?String(s):e})}setLocale(e){this.currentLocale=b(e)}getLocale(){return this.currentLocale}}function k(e){const t=window;if(void 0!==t[e])return t[e];try{return(0,eval)(e)}catch(e){return}}function E(e,t,i={}){var s;const n=k(t);if(void 0!==n)return Promise.resolve(n);const r=null!==(s=i.timeout)&&void 0!==s?s:1e4;return new Promise((i,s)=>{let n;const o=()=>{clearTimeout(n)},a=document.createElement("script");a.src=e,a.onload=()=>{o();const n=k(t);void 0===n?s(new Error(`CDN: '${t}' not on window after loading ${e}`)):i(n)},a.onerror=()=>{o(),s(new Error(`CDN: failed to load ${e}`))},n=setTimeout(()=>{s(new Error(`CDN: timeout loading ${e}`))},r),document.head.appendChild(a)})}const T=["token","expires","token_path","hdnea","hdntl"];function w(e){try{const t=new URL(e);for(const e of T)t.searchParams.delete(e);return t.toString()}catch(t){return e}}function C(e){const t=e.data;return void 0!==t&&"string"==typeof t.url&&(t.url=w(t.url)),e}function L(e){const t=e.request;return void 0!==t&&"string"==typeof t.url&&(t.url=w(t.url)),e}let S=null,x=null;async function A(e,t,i){const s=async()=>void 0===i?fetch(t):fetch(t,i),n=S;return null===n?s():n.startSpan({name:e,op:"http.client"},async t=>{try{const i=await s();return t.setAttribute("http.response_status_code",i.status),i.status>=400&&n.captureMessage(`${e}: HTTP ${i.status}`,"warning"),i}catch(t){throw n.captureException(t,{tags:{network:e}}),t}})}const $="STREAM_UNAVAILABLE",_="GEOBLOCKED",M="HLS_INIT_FAILED",P="DASH_INIT_FAILED",R="DRM_ERROR",B="LOAD_NEVER_STARTED",D="NO_VIDEO_ELEMENT";function F(e,t,i,s){e.errorCode=i,e.error=s,null==t||t.emit("player-error",{code:i,message:s}),function(e,t){const i=S;if(null===i)return;const s=new Error(t);s.name=e,i.captureException(s,{tags:{error_code:e}})}(i,s)}function O(e,t,i){if(null===e||null===i)return t;const s=function(e){return`error.${e.toLowerCase()}`}(e);return i.has(s)?i.t(s):t}function V(e){const t=e.play();void 0!==t&&"function"==typeof t.catch&&t.catch(()=>{})}class N{constructor(e,t,i,s,n,r,o,a){this.reloadCount=0,this.successTimer=0,this.toastTimer=0,this.savedQuality=-1,this.savedAudioTrack=0,this.savedSubtitleTrack=-1,this.wireVideoCommands(e,t,i,s,n,a),this.wireEngineCommands(e,s,a),this.wireReloadOrchestration(e,i,r,o,a),this.wireCastHandoff(e,t,i,n,r,a),this.wireVolumeRouting(i,n,a),this.wireGeoblock(e,i,r,a),this.wireAbortCleanup(a)}getSavedSelections(){return{quality:this.savedQuality,audioTrack:this.savedAudioTrack,subtitleTrack:this.savedSubtitleTrack}}wireVideoCommands(e,t,i,s,n,r){e.on("play",()=>{var e;i.isCasting&&null!==n?null===(e=n.getDriver())||void 0===e||e.play():V(t)},{signal:r}),e.on("pause",()=>{var e;i.isCasting&&null!==n?null===(e=n.getDriver())||void 0===e||e.pause():t.pause()},{signal:r}),e.on("seek",({time:e})=>{var r;if(i.isCasting&&null!==n)return void(null===(r=n.getDriver())||void 0===r||r.seek(e));const o=s();null!==o?o.seek(e):t.currentTime=e},{signal:r}),e.on("mute-toggle",()=>{t.muted=!t.muted},{signal:r}),i.on("volume",e=>{i.isCasting||(t.volume=e)},{signal:r})}wireEngineCommands(e,t,i){e.on("settings-select-quality",({index:e})=>{var i;null===(i=t())||void 0===i||i.setQuality(e)},{signal:i}),e.on("settings-select-audio",({index:e})=>{var i;null===(i=t())||void 0===i||i.setAudioTrack(e)},{signal:i}),e.on("settings-select-subtitle",({index:e})=>{var i;null===(i=t())||void 0===i||i.setSubtitle(e)},{signal:i}),e.on("settings-select-speed",({rate:e})=>{var i;null===(i=t())||void 0===i||i.setPlaybackRate(e)},{signal:i}),e.on("sync-live",()=>{var e;null===(e=t())||void 0===e||e.seekToLive()},{signal:i})}wireReloadOrchestration(e,t,i,s,n){e.on("request-reload",()=>{if(this.reloadCount>=3)return t.reconnecting=!1,void F(t,e,$,i.t("error.stream_unavailable"));this.savedQuality=t.currentQuality,this.savedAudioTrack=t.currentAudioTrack,this.savedSubtitleTrack=t.currentSubtitleTrack,t.reconnecting=!0,this.reloadCount++,s()},{signal:n}),t.on("playbackState",e=>{"playing"===e?(clearTimeout(this.successTimer),this.successTimer=setTimeout(()=>{this.reloadCount=0,t.reconnecting=!1},12e4)):(clearTimeout(this.successTimer),this.successTimer=0)},{signal:n})}wireCastHandoff(e,t,i,s,n,r){e.on("cast-start",()=>{null!==s&&(t.pause(),s.toggleCast(i))},{signal:r}),e.on("cast-stop",()=>{V(t)},{signal:r}),e.on("cast-stop-with-position",({time:e})=>{t.currentTime=e,V(t)},{signal:r}),e.on("cast-failed",()=>{i.isCasting=!1,V(t),this.showToast(i,n.t("cast.failed"))},{signal:r})}wireVolumeRouting(e,t,i){null!==t&&e.on("volume",i=>{var s;e.isCasting&&(null===(s=t.getDriver())||void 0===s||s.volume(i))},{signal:i})}wireGeoblock(e,t,i,s){e.on("geoblock-detected",()=>{F(t,e,_,i.t("error.geoblocked"))},{signal:s})}showToast(e,t){e.toast=t,clearTimeout(this.toastTimer),this.toastTimer=setTimeout(()=>{e.toast=null},3e3)}wireAbortCleanup(e){e.addEventListener("abort",()=>{clearTimeout(this.successTimer),clearTimeout(this.toastTimer)},{once:!0})}}var I;
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC
5
5
  * SPDX-License-Identifier: BSD-3-Clause
6
- */const P=globalThis,R=e=>e,B=P.trustedTypes,D=B?B.createPolicy("lit-html",{createHTML:e=>e}):void 0,F="$lit$",O=`lit$${Math.random().toFixed(9).slice(2)}$`,V="?"+O,N=`<${V}>`,I=document,H=()=>I.createComment(""),j=e=>null===e||"object"!=typeof e&&"function"!=typeof e,U=Array.isArray,z="[ \t\n\f\r]",q=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,W=/-->/g,G=/>/g,Q=RegExp(`>|${z}(?:([^\\s"'>=/]+)(${z}*=${z}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Y=/'/g,K=/"/g,X=/^(?:script|style|textarea|title)$/i,J=e=>(t,...i)=>({_$litType$:e,strings:t,values:i}),Z=J(1),ee=J(2),te=Symbol.for("lit-noChange"),ie=Symbol.for("lit-nothing"),se=new WeakMap,ne=I.createTreeWalker(I,129);function re(e,t){if(!U(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==D?D.createHTML(t):t}const oe=(e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":3===t?"<math>":"",o=q;for(let t=0;t<i;t++){const i=e[t];let a,l,c=-1,d=0;for(;d<i.length&&(o.lastIndex=d,l=o.exec(i),null!==l);)d=o.lastIndex,o===q?"!--"===l[1]?o=W:void 0!==l[1]?o=G:void 0!==l[2]?(X.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=Q):void 0!==l[3]&&(o=Q):o===Q?">"===l[0]?(o=null!=n?n:q,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?Q:'"'===l[3]?K:Y):o===K||o===Y?o=Q:o===W||o===G?o=q:(o=Q,n=void 0);const u=o===Q&&e[t+1].startsWith("/>")?" ":"";r+=o===q?i+N:c>=0?(s.push(a),i.slice(0,c)+F+i.slice(c)+O+u):i+O+(-2===c?t:u)}return[re(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]};class ae{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,c]=oe(e,t);if(this.el=ae.createElement(l,i),ne.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=ne.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(F)){const t=c[r++],i=s.getAttribute(e).split(O),o=/([.?@])?(.*)/.exec(t);a.push({type:1,index:n,name:o[2],strings:i,ctor:"."===o[1]?he:"?"===o[1]?ve:"@"===o[1]?ge:ue}),s.removeAttribute(e)}else e.startsWith(O)&&(a.push({type:6,index:n}),s.removeAttribute(e));if(X.test(s.tagName)){const e=s.textContent.split(O),t=e.length-1;if(t>0){s.textContent=B?B.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],H()),ne.nextNode(),a.push({type:2,index:++n});s.append(e[t],H())}}}else if(8===s.nodeType)if(s.data===V)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(O,e+1));)a.push({type:7,index:n}),e+=O.length-1}n++}}static createElement(e,t){const i=I.createElement("template");return i.innerHTML=e,i}}function le(e,t,i=e,s){var n,r,o;if(t===te)return t;let a=void 0!==s?null===(n=i._$Co)||void 0===n?void 0:n[s]:i._$Cl;const l=j(t)?void 0:t._$litDirective$;return(null==a?void 0:a.constructor)!==l&&(null===(r=null==a?void 0:a._$AO)||void 0===r||r.call(a,!1),void 0===l?a=void 0:(a=new l(e),a._$AT(e,i,s)),void 0!==s?(null!==(o=i._$Co)&&void 0!==o?o:i._$Co=[])[s]=a:i._$Cl=a),void 0!==a&&(t=le(e,a._$AS(e,t.values),a,s)),t}class ce{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:i},parts:s}=this._$AD,n=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:I).importNode(i,!0);ne.currentNode=n;let r=ne.nextNode(),o=0,a=0,l=s[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new de(r,r.nextSibling,this,e):1===l.type?t=new l.ctor(r,l.name,l.strings,this,e):6===l.type&&(t=new pe(r,this,e)),this._$AV.push(t),l=s[++a]}o!==(null==l?void 0:l.index)&&(r=ne.nextNode(),o++)}return ne.currentNode=I,n}p(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class de{get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cv}constructor(e,t,i,s){var n;this.type=2,this._$AH=ie,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=null===(n=null==s?void 0:s.isConnected)||void 0===n||n}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===(null==e?void 0:e.nodeType)&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=le(this,e,t),j(e)?e===ie||null==e||""===e?(this._$AH!==ie&&this._$AR(),this._$AH=ie):e!==this._$AH&&e!==te&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>U(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ie&&j(this._$AH)?this._$AA.nextSibling.data=e:this.T(I.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:s}=e,n="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=ae.createElement(re(s.h,s.h[0]),this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===n)this._$AH.p(i);else{const e=new ce(n,this),t=e.u(this.options);e.p(i),this.T(t),this._$AH=e}}_$AC(e){let t=se.get(e.strings);return void 0===t&&se.set(e.strings,t=new ae(e)),t}k(e){U(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new de(this.O(H()),this.O(H()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,t);e!==this._$AB;){const t=R(e).nextSibling;R(e).remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cv=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class ue{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=ie,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ie}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=le(this,e,t,0),r=!j(e)||e!==this._$AH&&e!==te,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=le(this,s[i+o],t,o),a===te&&(a=this._$AH[o]),r||(r=!j(a)||a!==this._$AH[o]),a===ie?e=ie:e!==ie&&(e+=(null!=a?a:"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===ie?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class he extends ue{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ie?void 0:e}}class ve extends ue{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ie)}}class ge extends ue{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){var i;if((e=null!==(i=le(this,e,t,0))&&void 0!==i?i:ie)===te)return;const s=this._$AH,n=e===ie&&s!==ie||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==ie&&(s===ie||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==i?i:this.element,e):this._$AH.handleEvent(e)}}class pe{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){le(this,e)}}const me=P.litHtmlPolyfillSupport;null==me||me(ae,de),(null!==(M=P.litHtmlVersions)&&void 0!==M?M:P.litHtmlVersions=[]).push("3.3.3");class fe{constructor(){this.el=null,this.state=null,this.bus=null,this.config=null,this.i18n=null,this.abortController=null}get signal(){return this.abortController.signal}connect(e,t,i,s,n){this.el=e,this.state=t,this.bus=i,this.config=s,this.i18n=null!=n?n:null,this.abortController=new AbortController,this.onConnect()}disconnect(){var e;null===(e=this.abortController)||void 0===e||e.abort(),this.abortController=null,this.el=null,this.state=null,this.bus=null,this.config=null,this.i18n=null}render(){var e;if(null!==this.el)try{((e,t)=>{const i=t;let s=i._$litPart$;if(void 0===s){const e=null;i._$litPart$=s=new de(t.insertBefore(H(),e),e,void 0,{})}s._$AI(e)})(this.template(),this.el)}catch(t){console.error("EBPlayer: a skin component failed to render and was unsubscribed from further updates",t),null===(e=this.abortController)||void 0===e||e.abort(),this.el=null}}}class be extends fe{onConnect(){this.render()}template(){var e,t;const i=this.config,s=void 0!==i.logo,n=u(i).topBar,r=e=>Z`<div class="eb-slot-${e}"></div>`;return Z`
6
+ */const H=globalThis,j=e=>e,U=H.trustedTypes,z=U?U.createPolicy("lit-html",{createHTML:e=>e}):void 0,q="$lit$",W=`lit$${Math.random().toFixed(9).slice(2)}$`,G="?"+W,Q=`<${G}>`,Y=document,K=()=>Y.createComment(""),X=e=>null===e||"object"!=typeof e&&"function"!=typeof e,J=Array.isArray,Z="[ \t\n\f\r]",ee=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,te=/-->/g,ie=/>/g,se=RegExp(`>|${Z}(?:([^\\s"'>=/]+)(${Z}*=${Z}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),ne=/'/g,re=/"/g,oe=/^(?:script|style|textarea|title)$/i,ae=e=>(t,...i)=>({_$litType$:e,strings:t,values:i}),le=ae(1),ce=ae(2),de=Symbol.for("lit-noChange"),ue=Symbol.for("lit-nothing"),he=new WeakMap,ve=Y.createTreeWalker(Y,129);function ge(e,t){if(!J(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==z?z.createHTML(t):t}const pe=(e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":3===t?"<math>":"",o=ee;for(let t=0;t<i;t++){const i=e[t];let a,l,c=-1,d=0;for(;d<i.length&&(o.lastIndex=d,l=o.exec(i),null!==l);)d=o.lastIndex,o===ee?"!--"===l[1]?o=te:void 0!==l[1]?o=ie:void 0!==l[2]?(oe.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=se):void 0!==l[3]&&(o=se):o===se?">"===l[0]?(o=null!=n?n:ee,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?se:'"'===l[3]?re:ne):o===re||o===ne?o=se:o===te||o===ie?o=ee:(o=se,n=void 0);const u=o===se&&e[t+1].startsWith("/>")?" ":"";r+=o===ee?i+Q:c>=0?(s.push(a),i.slice(0,c)+q+i.slice(c)+W+u):i+W+(-2===c?t:u)}return[ge(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]};class me{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,c]=pe(e,t);if(this.el=me.createElement(l,i),ve.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=ve.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(q)){const t=c[r++],i=s.getAttribute(e).split(W),o=/([.?@])?(.*)/.exec(t);a.push({type:1,index:n,name:o[2],strings:i,ctor:"."===o[1]?Ee:"?"===o[1]?Te:"@"===o[1]?we:ke}),s.removeAttribute(e)}else e.startsWith(W)&&(a.push({type:6,index:n}),s.removeAttribute(e));if(oe.test(s.tagName)){const e=s.textContent.split(W),t=e.length-1;if(t>0){s.textContent=U?U.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],K()),ve.nextNode(),a.push({type:2,index:++n});s.append(e[t],K())}}}else if(8===s.nodeType)if(s.data===G)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(W,e+1));)a.push({type:7,index:n}),e+=W.length-1}n++}}static createElement(e,t){const i=Y.createElement("template");return i.innerHTML=e,i}}function fe(e,t,i=e,s){var n,r,o;if(t===de)return t;let a=void 0!==s?null===(n=i._$Co)||void 0===n?void 0:n[s]:i._$Cl;const l=X(t)?void 0:t._$litDirective$;return(null==a?void 0:a.constructor)!==l&&(null===(r=null==a?void 0:a._$AO)||void 0===r||r.call(a,!1),void 0===l?a=void 0:(a=new l(e),a._$AT(e,i,s)),void 0!==s?(null!==(o=i._$Co)&&void 0!==o?o:i._$Co=[])[s]=a:i._$Cl=a),void 0!==a&&(t=fe(e,a._$AS(e,t.values),a,s)),t}class be{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:i},parts:s}=this._$AD,n=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:Y).importNode(i,!0);ve.currentNode=n;let r=ve.nextNode(),o=0,a=0,l=s[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new ye(r,r.nextSibling,this,e):1===l.type?t=new l.ctor(r,l.name,l.strings,this,e):6===l.type&&(t=new Ce(r,this,e)),this._$AV.push(t),l=s[++a]}o!==(null==l?void 0:l.index)&&(r=ve.nextNode(),o++)}return ve.currentNode=Y,n}p(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class ye{get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cv}constructor(e,t,i,s){var n;this.type=2,this._$AH=ue,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=null===(n=null==s?void 0:s.isConnected)||void 0===n||n}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===(null==e?void 0:e.nodeType)&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=fe(this,e,t),X(e)?e===ue||null==e||""===e?(this._$AH!==ue&&this._$AR(),this._$AH=ue):e!==this._$AH&&e!==de&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>J(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ue&&X(this._$AH)?this._$AA.nextSibling.data=e:this.T(Y.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:s}=e,n="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=me.createElement(ge(s.h,s.h[0]),this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===n)this._$AH.p(i);else{const e=new be(n,this),t=e.u(this.options);e.p(i),this.T(t),this._$AH=e}}_$AC(e){let t=he.get(e.strings);return void 0===t&&he.set(e.strings,t=new me(e)),t}k(e){J(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new ye(this.O(K()),this.O(K()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,t);e!==this._$AB;){const t=j(e).nextSibling;j(e).remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cv=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class ke{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=ue,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ue}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=fe(this,e,t,0),r=!X(e)||e!==this._$AH&&e!==de,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=fe(this,s[i+o],t,o),a===de&&(a=this._$AH[o]),r||(r=!X(a)||a!==this._$AH[o]),a===ue?e=ue:e!==ue&&(e+=(null!=a?a:"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===ue?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class Ee extends ke{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ue?void 0:e}}class Te extends ke{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ue)}}class we extends ke{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){var i;if((e=null!==(i=fe(this,e,t,0))&&void 0!==i?i:ue)===de)return;const s=this._$AH,n=e===ue&&s!==ue||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==ue&&(s===ue||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==i?i:this.element,e):this._$AH.handleEvent(e)}}class Ce{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){fe(this,e)}}const Le=H.litHtmlPolyfillSupport;null==Le||Le(me,ye),(null!==(I=H.litHtmlVersions)&&void 0!==I?I:H.litHtmlVersions=[]).push("3.3.3");class Se{constructor(){this.el=null,this.state=null,this.bus=null,this.config=null,this.i18n=null,this.abortController=null}get signal(){return this.abortController.signal}connect(e,t,i,s,n){this.el=e,this.state=t,this.bus=i,this.config=s,this.i18n=null!=n?n:null,this.abortController=new AbortController,this.onConnect()}disconnect(){var e;null===(e=this.abortController)||void 0===e||e.abort(),this.abortController=null,this.el=null,this.state=null,this.bus=null,this.config=null,this.i18n=null}render(){var e;if(null!==this.el)try{((e,t)=>{const i=t;let s=i._$litPart$;if(void 0===s){const e=null;i._$litPart$=s=new ye(t.insertBefore(K(),e),e,void 0,{})}s._$AI(e)})(this.template(),this.el)}catch(t){console.error("EBPlayer: a skin component failed to render and was unsubscribed from further updates",t),null===(e=this.abortController)||void 0===e||e.abort(),this.el=null}}}class xe extends Se{onConnect(){this.render()}template(){var e,t;const i=this.config,s=void 0!==i.logo,n=u(i).topBar,r=e=>le`<div class="eb-slot-${e}"></div>`;return le`
7
7
  <div class="eb-top-bar">
8
- ${s?Z`
9
- ${void 0!==i.logoLink?Z`<a class="eb-top-bar__logo-link" href="${i.logoLink}" target="_blank" rel="noopener">
8
+ ${s?le`
9
+ ${void 0!==i.logoLink?le`<a class="eb-top-bar__logo-link" href="${i.logoLink}" target="_blank" rel="noopener">
10
10
  <img class="eb-top-bar__logo" src="${i.logo}" alt="" />
11
- </a>`:Z`<img class="eb-top-bar__logo" src="${i.logo}" alt="" />`}
11
+ </a>`:le`<img class="eb-top-bar__logo" src="${i.logo}" alt="" />`}
12
12
  `:""}
13
13
 
14
14
  <div class="eb-top-bar__actions">
@@ -16,7 +16,7 @@
16
16
  ${(null!==(t=n.right)&&void 0!==t?t:[]).map(r)}
17
17
  </div>
18
18
  </div>
19
- `}}class ye extends fe{onConnect(){this.render()}template(){var e,t,i;const s=u(this.config).bottomBar,n=e=>"seekbar"===e?Z`<div class="eb-bottom-bar__seekbar-zone"></div>`:Z`<div class="eb-slot-${e}"></div>`;return Z`
19
+ `}}class Ae extends Se{onConnect(){this.render()}template(){var e,t,i;const s=u(this.config).bottomBar,n=e=>"seekbar"===e?le`<div class="eb-bottom-bar__seekbar-zone"></div>`:le`<div class="eb-slot-${e}"></div>`;return le`
20
20
  <div class="eb-bottom-bar">
21
21
  <div class="eb-bottom-bar__gradient"></div>
22
22
  <div class="eb-bottom-bar__controls-row">
@@ -25,7 +25,7 @@
25
25
  ${(null!==(i=s.right)&&void 0!==i?i:[]).map(n)}
26
26
  </div>
27
27
  </div>
28
- `}}const ke={play:'<symbol id="eb-play" viewBox="0 0 24 24"><path d="M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"/></symbol>',pause:'<symbol id="eb-pause" viewBox="0 0 24 24"><rect x="14" y="3" width="5" height="18" rx="1"/><rect x="5" y="3" width="5" height="18" rx="1"/></symbol>',"volume-high":'<symbol id="eb-volume-high" viewBox="0 0 24 24"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/></symbol>',"volume-low":'<symbol id="eb-volume-low" viewBox="0 0 24 24"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/></symbol>',"volume-mute":'<symbol id="eb-volume-mute" viewBox="0 0 24 24"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><line x1="22" x2="16" y1="9" y2="15"/><line x1="16" x2="22" y1="9" y2="15"/></symbol>',fullscreen:'<symbol id="eb-fullscreen" viewBox="0 0 24 24"><path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/></symbol>',"fullscreen-exit":'<symbol id="eb-fullscreen-exit" viewBox="0 0 24 24"><path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/></symbol>',settings:'<symbol id="eb-settings" viewBox="0 0 24 24"><path fill="currentColor" stroke="none" d="M19.14 12.94c.04-.3.06-.61.06-.94s-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/></symbol>',pip:'<symbol id="eb-pip" viewBox="0 0 24 24"><path d="M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"/><rect width="10" height="7" x="12" y="13" rx="2"/></symbol>',cast:'<symbol id="eb-cast" viewBox="0 0 24 24"><path d="M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6"/><path d="M2 12a9 9 0 0 1 8 8"/><path d="M2 16a5 5 0 0 1 4 4"/><line x1="2" x2="2.01" y1="20" y2="20"/></symbol>',close:'<symbol id="eb-close" viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></symbol>',share:'<symbol id="eb-share" viewBox="0 0 24 24"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" x2="15.42" y1="13.51" y2="17.49"/><line x1="15.41" x2="8.59" y1="6.51" y2="10.49"/></symbol>',info:'<symbol id="eb-info" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></symbol>',speed:'<symbol id="eb-speed" viewBox="0 0 24 24"><path d="m12 14 4-4"/><path d="M3.34 19a10 10 0 1 1 17.32 0"/></symbol>',check:'<symbol id="eb-check" viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></symbol>',"chevron-left":'<symbol id="eb-chevron-left" viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></symbol>',"chevron-right":'<symbol id="eb-chevron-right" viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></symbol>',spinner:'<symbol id="eb-spinner" viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></symbol>',live:'<symbol id="eb-live" viewBox="0 0 24 24"><path d="M16.247 7.761a6 6 0 0 1 0 8.478"/><path d="M19.075 4.933a10 10 0 0 1 0 14.134"/><path d="M4.925 19.067a10 10 0 0 1 0-14.134"/><path d="M7.753 16.239a6 6 0 0 1 0-8.478"/><circle cx="12" cy="12" r="2"/></symbol>',"skip-forward":'<symbol id="eb-skip-forward" viewBox="0 0 24 24"><path d="M21 4v16"/><path d="M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z"/></symbol>',"skip-back":'<symbol id="eb-skip-back" viewBox="0 0 24 24"><path d="M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z"/><path d="M3 20V4"/></symbol>',"radio-bars":'<symbol id="eb-radio-bars" viewBox="0 0 24 24"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"/><path d="M7.8 16.2a6 6 0 0 1 0-8.4"/><path d="M16.2 7.8a6 6 0 0 1 0 8.4"/><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"/><circle cx="12" cy="12" r="2"/></symbol>',subtitle:'<symbol id="eb-subtitle" viewBox="0 0 24 24"><rect width="18" height="14" x="3" y="5" rx="2" ry="2"/><path d="M7 15h4M15 15h2M7 11h2M13 11h4"/></symbol>',audio:'<symbol id="eb-audio" viewBox="0 0 24 24"><path d="M2 10v3"/><path d="M6 6v11"/><path d="M10 3v18"/><path d="M14 8v7"/><path d="M18 5v13"/><path d="M22 10v3"/></symbol>',quality:'<symbol id="eb-quality" viewBox="0 0 24 24"><path d="M2 20h.01"/><path d="M7 20v-4"/><path d="M12 20v-8"/><path d="M17 20V8"/><path d="M22 4v16"/></symbol>'};let Ee=!1,Te=Object.assign({},ke);function we(e){return`<svg xmlns="http://www.w3.org/2000/svg" style="display:none"><defs>${Object.values(e).join("")}</defs></svg>`}function Ce(e){if(Ee&&(void 0===e||0===Object.keys(e).length))return;void 0!==e&&(Te=Object.assign(Object.assign({},Te),e));const t=we(Te),i=document.getElementById("eb-sprite");if(null!==i)i.innerHTML=t;else{const e=document.createElement("div");e.id="eb-sprite",e.style.display="none",e.innerHTML=t,document.body.prepend(e)}Ee=!0}function Le(e,t){return ee`<svg class="${void 0!==t?`eb-icon ${t}`:"eb-icon"}" aria-hidden="true"><use href="#eb-${e}"></use></svg>`}class Se extends fe{onConnect(){this.render();const{signal:e}=this;this.state.on("playbackState",()=>this.render(),{signal:e})}template(){var e,t;const i=this.state,s="playing"===i.playbackState||"buffering"===i.playbackState,n=u(this.config).middleBar,r=e=>Z`<div class="eb-slot-${e}"></div>`;return Z`
28
+ `}}const $e={play:'<symbol id="eb-play" viewBox="0 0 24 24"><path d="M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"/></symbol>',pause:'<symbol id="eb-pause" viewBox="0 0 24 24"><rect x="14" y="3" width="5" height="18" rx="1"/><rect x="5" y="3" width="5" height="18" rx="1"/></symbol>',"volume-high":'<symbol id="eb-volume-high" viewBox="0 0 24 24"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/></symbol>',"volume-low":'<symbol id="eb-volume-low" viewBox="0 0 24 24"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/></symbol>',"volume-mute":'<symbol id="eb-volume-mute" viewBox="0 0 24 24"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><line x1="22" x2="16" y1="9" y2="15"/><line x1="16" x2="22" y1="9" y2="15"/></symbol>',fullscreen:'<symbol id="eb-fullscreen" viewBox="0 0 24 24"><path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/></symbol>',"fullscreen-exit":'<symbol id="eb-fullscreen-exit" viewBox="0 0 24 24"><path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/></symbol>',settings:'<symbol id="eb-settings" viewBox="0 0 24 24"><path fill="currentColor" stroke="none" d="M19.14 12.94c.04-.3.06-.61.06-.94s-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/></symbol>',pip:'<symbol id="eb-pip" viewBox="0 0 24 24"><path d="M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"/><rect width="10" height="7" x="12" y="13" rx="2"/></symbol>',cast:'<symbol id="eb-cast" viewBox="0 0 24 24"><path d="M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6"/><path d="M2 12a9 9 0 0 1 8 8"/><path d="M2 16a5 5 0 0 1 4 4"/><line x1="2" x2="2.01" y1="20" y2="20"/></symbol>',close:'<symbol id="eb-close" viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></symbol>',share:'<symbol id="eb-share" viewBox="0 0 24 24"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" x2="15.42" y1="13.51" y2="17.49"/><line x1="15.41" x2="8.59" y1="6.51" y2="10.49"/></symbol>',info:'<symbol id="eb-info" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></symbol>',speed:'<symbol id="eb-speed" viewBox="0 0 24 24"><path d="m12 14 4-4"/><path d="M3.34 19a10 10 0 1 1 17.32 0"/></symbol>',check:'<symbol id="eb-check" viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></symbol>',"chevron-left":'<symbol id="eb-chevron-left" viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></symbol>',"chevron-right":'<symbol id="eb-chevron-right" viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></symbol>',spinner:'<symbol id="eb-spinner" viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></symbol>',live:'<symbol id="eb-live" viewBox="0 0 24 24"><path d="M16.247 7.761a6 6 0 0 1 0 8.478"/><path d="M19.075 4.933a10 10 0 0 1 0 14.134"/><path d="M4.925 19.067a10 10 0 0 1 0-14.134"/><path d="M7.753 16.239a6 6 0 0 1 0-8.478"/><circle cx="12" cy="12" r="2"/></symbol>',"skip-forward":'<symbol id="eb-skip-forward" viewBox="0 0 24 24"><path d="M21 4v16"/><path d="M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z"/></symbol>',"skip-back":'<symbol id="eb-skip-back" viewBox="0 0 24 24"><path d="M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z"/><path d="M3 20V4"/></symbol>',"radio-bars":'<symbol id="eb-radio-bars" viewBox="0 0 24 24"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"/><path d="M7.8 16.2a6 6 0 0 1 0-8.4"/><path d="M16.2 7.8a6 6 0 0 1 0 8.4"/><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"/><circle cx="12" cy="12" r="2"/></symbol>',subtitle:'<symbol id="eb-subtitle" viewBox="0 0 24 24"><rect width="18" height="14" x="3" y="5" rx="2" ry="2"/><path d="M7 15h4M15 15h2M7 11h2M13 11h4"/></symbol>',audio:'<symbol id="eb-audio" viewBox="0 0 24 24"><path d="M2 10v3"/><path d="M6 6v11"/><path d="M10 3v18"/><path d="M14 8v7"/><path d="M18 5v13"/><path d="M22 10v3"/></symbol>',quality:'<symbol id="eb-quality" viewBox="0 0 24 24"><path d="M2 20h.01"/><path d="M7 20v-4"/><path d="M12 20v-8"/><path d="M17 20V8"/><path d="M22 4v16"/></symbol>'};let _e=!1,Me=Object.assign({},$e);function Pe(e){return`<svg xmlns="http://www.w3.org/2000/svg" style="display:none"><defs>${Object.values(e).join("")}</defs></svg>`}function Re(e){if(_e&&(void 0===e||0===Object.keys(e).length))return;void 0!==e&&(Me=Object.assign(Object.assign({},Me),e));const t=Pe(Me),i=document.getElementById("eb-sprite");if(null!==i)i.innerHTML=t;else{const e=document.createElement("div");e.id="eb-sprite",e.style.display="none",e.innerHTML=t,document.body.prepend(e)}_e=!0}function Be(e,t){return ce`<svg class="${void 0!==t?`eb-icon ${t}`:"eb-icon"}" aria-hidden="true"><use href="#eb-${e}"></use></svg>`}class De extends Se{onConnect(){this.render();const{signal:e}=this;this.state.on("playbackState",()=>this.render(),{signal:e})}template(){var e,t;const i=this.state,s="playing"===i.playbackState||"buffering"===i.playbackState,n=u(this.config).middleBar,r=e=>le`<div class="eb-slot-${e}"></div>`;return le`
29
29
  <div class="eb-middle-bar">
30
30
  ${(null!==(e=n.left)&&void 0!==e?e:[]).map(r)}
31
31
  <button
@@ -33,26 +33,26 @@
33
33
  @click="${()=>this.handleClick()}"
34
34
  aria-label="${s?"Pause":"Play"}"
35
35
  >
36
- ${Le(s?"pause":"play")}
36
+ ${Be(s?"pause":"play")}
37
37
  </button>
38
38
  ${(null!==(t=n.right)&&void 0!==t?t:[]).map(r)}
39
39
  </div>
40
- `}handleClick(){const e=this.state,t=this.bus;"playing"===e.playbackState||"buffering"===e.playbackState?t.emit("pause"):t.emit("play")}}class xe extends fe{onConnect(){this.state.on("playbackState",()=>this.render(),{signal:this.signal}),this.render()}template(){const e=this.state.playbackState,t="playing"===e||"buffering"===e;return Z`
40
+ `}handleClick(){const e=this.state,t=this.bus;"playing"===e.playbackState||"buffering"===e.playbackState?t.emit("pause"):t.emit("play")}}class Fe extends Se{onConnect(){this.state.on("playbackState",()=>this.render(),{signal:this.signal}),this.render()}template(){const e=this.state.playbackState,t="playing"===e||"buffering"===e;return le`
41
41
  <button
42
42
  class="eb-play-pause"
43
43
  aria-label="${t?"Pause":"Play"}"
44
44
  @click="${()=>this.bus.emit(t?"pause":"play")}"
45
45
  >
46
- ${Le(t?"pause":"play")}
46
+ ${Be(t?"pause":"play")}
47
47
  </button>
48
- `}}class Ae extends fe{constructor(){super(...arguments),this.trackRect=null,this.onDocumentPointerMove=e=>{const t=this.eventToVolume(e.clientX);null!==t&&(this.state.volume=t)},this.onDocumentPointerUp=e=>{const t=this.eventToVolume(e.clientX);null!==t&&(this.state.volume=t),this.endDrag()},this.onDocumentPointerCancel=()=>{this.endDrag()}}onConnect(){this.state.on("volume",()=>this.render(),{signal:this.signal}),this.state.on("muted",()=>this.render(),{signal:this.signal}),this.signal.addEventListener("abort",()=>this.endDrag()),this.render()}eventToVolume(e){if(null===this.trackRect)return null;const t=(e-this.trackRect.left)/this.trackRect.width,i=this.state.isRtl?1-t:t;return Math.min(1,Math.max(0,i))}handlePointerDown(e){const t=e.currentTarget;this.trackRect=t.getBoundingClientRect(),document.addEventListener("pointermove",this.onDocumentPointerMove),document.addEventListener("pointerup",this.onDocumentPointerUp),document.addEventListener("pointercancel",this.onDocumentPointerCancel)}endDrag(){document.removeEventListener("pointermove",this.onDocumentPointerMove),document.removeEventListener("pointerup",this.onDocumentPointerUp),document.removeEventListener("pointercancel",this.onDocumentPointerCancel),this.trackRect=null}getVolumeIcon(){return this.state.muted||0===this.state.volume?"volume-mute":this.state.volume<.5?"volume-low":"volume-high"}template(){const e=this.state.muted?0:this.state.volume,t=`${Math.round(100*e)}%`,i=this.getVolumeIcon();return Z`
48
+ `}}class Oe extends Se{constructor(){super(...arguments),this.trackRect=null,this.onDocumentPointerMove=e=>{const t=this.eventToVolume(e.clientX);null!==t&&(this.state.volume=t)},this.onDocumentPointerUp=e=>{const t=this.eventToVolume(e.clientX);null!==t&&(this.state.volume=t),this.endDrag()},this.onDocumentPointerCancel=()=>{this.endDrag()}}onConnect(){this.state.on("volume",()=>this.render(),{signal:this.signal}),this.state.on("muted",()=>this.render(),{signal:this.signal}),this.signal.addEventListener("abort",()=>this.endDrag()),this.render()}eventToVolume(e){if(null===this.trackRect)return null;const t=(e-this.trackRect.left)/this.trackRect.width,i=this.state.isRtl?1-t:t;return Math.min(1,Math.max(0,i))}handlePointerDown(e){const t=e.currentTarget;this.trackRect=t.getBoundingClientRect(),document.addEventListener("pointermove",this.onDocumentPointerMove),document.addEventListener("pointerup",this.onDocumentPointerUp),document.addEventListener("pointercancel",this.onDocumentPointerCancel)}endDrag(){document.removeEventListener("pointermove",this.onDocumentPointerMove),document.removeEventListener("pointerup",this.onDocumentPointerUp),document.removeEventListener("pointercancel",this.onDocumentPointerCancel),this.trackRect=null}getVolumeIcon(){return this.state.muted||0===this.state.volume?"volume-mute":this.state.volume<.5?"volume-low":"volume-high"}template(){const e=this.state.muted?0:this.state.volume,t=`${Math.round(100*e)}%`,i=this.getVolumeIcon();return le`
49
49
  <div class="eb-volume-control">
50
50
  <button
51
51
  class="eb-volume-mute"
52
52
  aria-label="${this.state.muted?"Unmute":"Mute"}"
53
53
  @click="${()=>this.bus.emit("mute-toggle")}"
54
54
  >
55
- ${Le(i)}
55
+ ${Be(i)}
56
56
  </button>
57
57
  <div
58
58
  class="eb-volume-track"
@@ -62,32 +62,32 @@
62
62
  <div class="eb-volume-thumb" style="inset-inline-start: ${t}"></div>
63
63
  </div>
64
64
  </div>
65
- `}}function $e(e){if(!Number.isFinite(e)||e<0)return"0:00";const t=Math.floor(e),i=Math.floor(t/3600),s=Math.floor(t%3600/60),n=String(t%60).padStart(2,"0");if(i>0){return`${i}:${String(s).padStart(2,"0")}:${n}`}return`${s}:${n}`}function _e(e){return new Date(e).toTimeString().split(" ")[0]}class Me extends fe{constructor(){super(...arguments),this.isDragging=!1,this.dragValue=0,this.rafPending=!1,this.tooltipVisible=!1,this.tooltipTime=0,this.tooltipX=0,this.previewVideoEl=null,this.snapshotTake=null,this.trackEl=null,this.boundDocPointerMove=null}onConnect(){this.bus.on("snapshot-handler-ready",e=>{this.snapshotTake=e.take,this.previewVideoEl=e.video,this.previewVideoEl.className="eb-seekbar-preview",this.previewVideoEl.muted=!0},{signal:this.signal}),this.state.on("currentTime",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("duration",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("bufferedEnd",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("isRtl",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("adPlaying",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("introStreamPlaying",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("chapters",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("epgPrograms",()=>this.scheduleRender(),{signal:this.signal}),this.render()}disconnect(){this.stopDocumentTracking(),super.disconnect()}scheduleRender(){this.rafPending||(this.rafPending=!0,requestAnimationFrame(()=>{this.rafPending=!1,this.render()}))}eventToTime(e,t){const i=t.getBoundingClientRect(),s=(e.clientX-i.left)/i.width,n=this.state.isRtl?1-s:s;return Math.min(1,Math.max(0,n))*this.state.duration}startDocumentTracking(){this.boundDocPointerMove||(this.boundDocPointerMove=e=>this.onDocPointerMove(e),document.addEventListener("pointermove",this.boundDocPointerMove),document.addEventListener("mouseleave",this.boundDocPointerMove))}stopDocumentTracking(){this.boundDocPointerMove&&(document.removeEventListener("pointermove",this.boundDocPointerMove),document.removeEventListener("mouseleave",this.boundDocPointerMove),this.boundDocPointerMove=null)}onDocPointerMove(e){if(this.isDragging)return;if(!this.trackEl)return;const t=this.trackEl.getBoundingClientRect();e.clientX>=t.left&&e.clientX<=t.right&&e.clientY>=t.top&&e.clientY<=t.bottom||(this.tooltipVisible=!1,this.stopDocumentTracking(),this.render())}handlePointerDown(e){if(this.state.adPlaying||this.state.introStreamPlaying)return;const t=e.currentTarget;this.trackEl=t,"function"==typeof t.setPointerCapture&&t.setPointerCapture(e.pointerId),this.isDragging=!0,this.dragValue=this.eventToTime(e,t),this.render()}handlePointerMove(e){if(this.isDragging){const t=e.currentTarget;this.dragValue=this.eventToTime(e,t),this.scheduleRender();const i=t.getBoundingClientRect();return void(e.clientX>=i.left&&e.clientX<=i.right&&this.updateTooltip(e))}this.updateTooltip(e)}handlePointerUp(e){if(!this.isDragging)return;const t=e.currentTarget,i=this.eventToTime(e,t);this.isDragging=!1,this.bus.emit("seek",{time:i}),this.tooltipVisible=!1,this.stopDocumentTracking(),this.render()}updateTooltip(e){const t=e.currentTarget;this.trackEl=t;const i=t.getBoundingClientRect(),s=(e.clientX-i.left)/i.width,n=Math.min(1,Math.max(0,s));this.tooltipTime=this.state.isRtl?(1-n)*this.state.duration:n*this.state.duration,this.tooltipX=Math.min(i.width,Math.max(0,e.clientX-i.left)),this.tooltipVisible=!0,this.startDocumentTracking(),null!==this.snapshotTake&&this.snapshotTake(this.tooltipTime),this.render()}findActiveChapter(e){const t=this.state.currentTime;for(const i of e)if(t>=i.startTime&&t<=i.endTime)return i;return null}findSkippableChapter(e){const t=this.config.skippableChapters;for(const i of t)if(i.chapter===e.title)return i;return null}renderEpgSegments(e,t){if(0===e.length)return[];const i=e[0].start,s=e[e.length-1].end-i;if(s<=0)return[];const n=Date.now();return e.map(e=>{const r=(e.start-i)/s*100,o=(e.end-e.start)/s*100,a=n>=e.start&&n<e.end,l=t?`right: ${r.toFixed(2)}%; width: ${o.toFixed(2)}%`:`left: ${r.toFixed(2)}%; width: ${o.toFixed(2)}%`;return Z`
65
+ `}}function Ve(e){if(!Number.isFinite(e)||e<0)return"0:00";const t=Math.floor(e),i=Math.floor(t/3600),s=Math.floor(t%3600/60),n=String(t%60).padStart(2,"0");if(i>0){return`${i}:${String(s).padStart(2,"0")}:${n}`}return`${s}:${n}`}function Ne(e){return new Date(e).toTimeString().split(" ")[0]}class Ie extends Se{constructor(){super(...arguments),this.isDragging=!1,this.dragValue=0,this.rafPending=!1,this.tooltipVisible=!1,this.tooltipTime=0,this.tooltipX=0,this.previewVideoEl=null,this.snapshotTake=null,this.trackEl=null,this.boundDocPointerMove=null}onConnect(){this.bus.on("snapshot-handler-ready",e=>{this.snapshotTake=e.take,this.previewVideoEl=e.video,this.previewVideoEl.className="eb-seekbar-preview",this.previewVideoEl.muted=!0},{signal:this.signal}),this.state.on("currentTime",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("duration",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("bufferedEnd",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("isRtl",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("adPlaying",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("introStreamPlaying",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("chapters",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("epgPrograms",()=>this.scheduleRender(),{signal:this.signal}),this.render()}disconnect(){this.stopDocumentTracking(),super.disconnect()}scheduleRender(){this.rafPending||(this.rafPending=!0,requestAnimationFrame(()=>{this.rafPending=!1,this.render()}))}eventToTime(e,t){const i=t.getBoundingClientRect(),s=(e.clientX-i.left)/i.width,n=this.state.isRtl?1-s:s;return Math.min(1,Math.max(0,n))*this.state.duration}startDocumentTracking(){this.boundDocPointerMove||(this.boundDocPointerMove=e=>this.onDocPointerMove(e),document.addEventListener("pointermove",this.boundDocPointerMove),document.addEventListener("mouseleave",this.boundDocPointerMove))}stopDocumentTracking(){this.boundDocPointerMove&&(document.removeEventListener("pointermove",this.boundDocPointerMove),document.removeEventListener("mouseleave",this.boundDocPointerMove),this.boundDocPointerMove=null)}onDocPointerMove(e){if(this.isDragging)return;if(!this.trackEl)return;const t=this.trackEl.getBoundingClientRect();e.clientX>=t.left&&e.clientX<=t.right&&e.clientY>=t.top&&e.clientY<=t.bottom||(this.tooltipVisible=!1,this.stopDocumentTracking(),this.render())}handlePointerDown(e){if(this.state.adPlaying||this.state.introStreamPlaying)return;const t=e.currentTarget;this.trackEl=t,"function"==typeof t.setPointerCapture&&t.setPointerCapture(e.pointerId),this.isDragging=!0,this.dragValue=this.eventToTime(e,t),this.render()}handlePointerMove(e){if(this.isDragging){const t=e.currentTarget;this.dragValue=this.eventToTime(e,t),this.scheduleRender();const i=t.getBoundingClientRect();return void(e.clientX>=i.left&&e.clientX<=i.right&&this.updateTooltip(e))}this.updateTooltip(e)}handlePointerUp(e){if(!this.isDragging)return;const t=e.currentTarget,i=this.eventToTime(e,t);this.isDragging=!1,this.bus.emit("seek",{time:i}),this.tooltipVisible=!1,this.stopDocumentTracking(),this.render()}updateTooltip(e){const t=e.currentTarget;this.trackEl=t;const i=t.getBoundingClientRect(),s=(e.clientX-i.left)/i.width,n=Math.min(1,Math.max(0,s));this.tooltipTime=this.state.isRtl?(1-n)*this.state.duration:n*this.state.duration,this.tooltipX=Math.min(i.width,Math.max(0,e.clientX-i.left)),this.tooltipVisible=!0,this.startDocumentTracking(),null!==this.snapshotTake&&this.snapshotTake(this.tooltipTime),this.render()}findActiveChapter(e){const t=this.state.currentTime;for(const i of e)if(t>=i.startTime&&t<=i.endTime)return i;return null}findSkippableChapter(e){const t=this.config.skippableChapters;for(const i of t)if(i.chapter===e.title)return i;return null}renderEpgSegments(e,t){if(0===e.length)return[];const i=e[0].start,s=e[e.length-1].end-i;if(s<=0)return[];const n=Date.now();return e.map(e=>{const r=(e.start-i)/s*100,o=(e.end-e.start)/s*100,a=n>=e.start&&n<e.end,l=t?`right: ${r.toFixed(2)}%; width: ${o.toFixed(2)}%`:`left: ${r.toFixed(2)}%; width: ${o.toFixed(2)}%`;return le`
66
66
  <div
67
67
  class="eb-epg-segment${a?" eb-epg-current":""}"
68
68
  style="${l}"
69
69
  title="${e.title}"
70
70
  ></div>
71
- `})}template(){const{currentTime:e,duration:t,bufferedEnd:i,adPlaying:s,introStreamPlaying:n,chapters:r,epgPrograms:o,isRtl:a}=this.state,l=!this.config.seekbar,c=s||n,d=t>0?(this.isDragging?this.dragValue:e)/t*100:0,u=t>0?i/t*100:0,h=this.findActiveChapter(r),v=null!==h?this.findSkippableChapter(h):null,g=r.map(e=>{const i=t>0?e.startTime/t*100:0,s=e===h,n=a?`right: ${i.toFixed(2)}%`:`left: ${i.toFixed(2)}%`;return Z`
71
+ `})}template(){const{currentTime:e,duration:t,bufferedEnd:i,adPlaying:s,introStreamPlaying:n,chapters:r,epgPrograms:o,isRtl:a}=this.state,l=!this.config.seekbar,c=s||n,d=t>0?(this.isDragging?this.dragValue:e)/t*100:0,u=t>0?i/t*100:0,h=this.findActiveChapter(r),v=null!==h?this.findSkippableChapter(h):null,g=r.map(e=>{const i=t>0?e.startTime/t*100:0,s=e===h,n=a?`right: ${i.toFixed(2)}%`:`left: ${i.toFixed(2)}%`;return le`
72
72
  <div
73
73
  class="eb-chapter-marker${s?" eb-chapter-active":""}"
74
74
  style="${n}"
75
75
  title="${e.title}"
76
76
  ></div>
77
- `}),p=null!==h&&null!==v?Z`
77
+ `}),p=null!==h&&null!==v?le`
78
78
  <button
79
79
  class="eb-chapter-skip"
80
80
  @click="${()=>this.bus.emit("seek",{time:h.endTime})}"
81
81
  >${v.message}</button>
82
- `:Z``,m=this.renderEpgSegments(o,a),f=this.state.isLive&&Number.isFinite(t)?_e(Date.now()-1e3*(t-this.tooltipTime)):$e(this.tooltipTime),b=Z`
82
+ `:le``,m=this.renderEpgSegments(o,a),f=this.state.isLive&&Number.isFinite(t)?Ne(Date.now()-1e3*(t-this.tooltipTime)):Ve(this.tooltipTime),b=le`
83
83
  <div
84
84
  class="eb-seekbar-tooltip"
85
85
  style="left: ${this.tooltipX}px; visibility: ${this.tooltipVisible?"visible":"hidden"}"
86
86
  >
87
- ${null!==this.previewVideoEl?this.previewVideoEl:Z``}
87
+ ${null!==this.previewVideoEl?this.previewVideoEl:le``}
88
88
  ${f}
89
89
  </div>
90
- `;return Z`
90
+ `;return le`
91
91
  <div
92
92
  class="eb-seekbar${c?" eb-seekbar-disabled":""}"
93
93
  ?hidden="${l}"
@@ -108,42 +108,42 @@
108
108
  </div>
109
109
  ${p}
110
110
  </div>
111
- `}}class Pe extends fe{constructor(){super(...arguments),this.rafPending=!1}onConnect(){this.state.on("currentTime",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("duration",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("isLive",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("isSyncWithLive",()=>this.scheduleRender(),{signal:this.signal}),this.render()}scheduleRender(){this.rafPending||(this.rafPending=!0,requestAnimationFrame(()=>{this.rafPending=!1,this.render()}))}template(){const{currentTime:e,duration:t,isLive:i,isSyncWithLive:s}=this.state;if(!this.config.seekbar)return Z`<div class="eb-time-display" hidden></div>`;let n;if(i){if(!s&&Number.isFinite(t)){const i=t-e;return Z`<div class="eb-time-display">${_e(Date.now())} <span class="eb-time-display__offset">-${$e(i)}</span></div>`}n=_e(Date.now())}else n=`${$e(e)} / ${$e(t)}`;return Z`<div class="eb-time-display">${n}</div>`}}class Re extends fe{onConnect(){this.state.on("isLive",()=>this.render(),{signal:this.signal}),this.state.on("isSyncWithLive",()=>this.render(),{signal:this.signal}),this.render()}template(){const{isLive:e,isSyncWithLive:t}=this.state,i=!0===this.config.liveButton||!0===this.config.isLive;return this.config.seekbar&&(e||i)?Z`
111
+ `}}class He extends Se{constructor(){super(...arguments),this.rafPending=!1}onConnect(){this.state.on("currentTime",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("duration",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("isLive",()=>this.scheduleRender(),{signal:this.signal}),this.state.on("isSyncWithLive",()=>this.scheduleRender(),{signal:this.signal}),this.render()}scheduleRender(){this.rafPending||(this.rafPending=!0,requestAnimationFrame(()=>{this.rafPending=!1,this.render()}))}template(){const{currentTime:e,duration:t,isLive:i,isSyncWithLive:s}=this.state;if(!this.config.seekbar)return le`<div class="eb-time-display" hidden></div>`;let n;if(i){if(!s&&Number.isFinite(t)){const i=t-e;return le`<div class="eb-time-display">${Ne(Date.now())} <span class="eb-time-display__offset">-${Ve(i)}</span></div>`}n=Ne(Date.now())}else n=`${Ve(e)} / ${Ve(t)}`;return le`<div class="eb-time-display">${n}</div>`}}class je extends Se{onConnect(){this.state.on("isLive",()=>this.render(),{signal:this.signal}),this.state.on("isSyncWithLive",()=>this.render(),{signal:this.signal}),this.render()}template(){const{isLive:e,isSyncWithLive:t}=this.state,i=!0===this.config.liveButton||!0===this.config.isLive;return this.config.seekbar&&(e||i)?le`
112
112
  <button
113
113
  class="${t?"eb-live-sync eb-live-synced":"eb-live-sync"}"
114
114
  aria-label="Go to live"
115
115
  @click="${()=>this.bus.emit("sync-live")}"
116
116
  >
117
- <span class="eb-live-sync__icon">${Le("live")}</span>
117
+ <span class="eb-live-sync__icon">${Be("live")}</span>
118
118
  <span class="eb-live-sync__dot"></span>
119
119
  <span class="eb-live-sync__label">LIVE</span>
120
120
  </button>
121
- `:Z`<button class="eb-live-sync" hidden style="display:none">${Le("live")}</button>`}}const Be=[.25,.5,.75,1,1.25,1.5,1.75,2];class De extends fe{constructor(){super(...arguments),this.mode="root",this.verticalDir="up",this.horizontalDir="right",this.outsideClickHandler=null,this.outsideClickTimer=null}onConnect(){this.state.on("settingsOpen",()=>{this.state.settingsOpen?(this.computePlacement(),this.addOutsideClickListener()):(this.mode="root",this.removeOutsideClickListener()),this.render()},{signal:this.signal}),this.state.on("qualityLevels",()=>this.render(),{signal:this.signal}),this.state.on("currentQuality",()=>this.render(),{signal:this.signal}),this.state.on("audioTracks",()=>this.render(),{signal:this.signal}),this.state.on("currentAudioTrack",()=>this.render(),{signal:this.signal}),this.state.on("subtitleTracks",()=>this.render(),{signal:this.signal}),this.state.on("currentSubtitleTrack",()=>this.render(),{signal:this.signal}),this.state.on("playbackRate",()=>this.render(),{signal:this.signal}),this.signal.addEventListener("abort",()=>this.removeOutsideClickListener()),this.render()}computePlacement(){var e,t;const i=null===(e=this.el)||void 0===e?void 0:e.closest(".eb-player"),s=null===(t=this.el)||void 0===t?void 0:t.querySelector(".eb-settings-toggle");if(!i||!s)return;const n=i.getBoundingClientRect(),r=s.getBoundingClientRect(),o=r.top+r.height/2-n.top,a=r.left+r.width/2-n.left;this.verticalDir=o<n.height/2?"down":"up",this.horizontalDir=a<n.width/2?"left":"right"}navigateTo(e){this.mode=e,this.render()}navigateBack(){this.mode="root",this.render()}currentValueLabel(e){const t=this.i18n;if("quality"===e){const e=this.state.qualityLevels,i=this.state.currentQuality;if(-1===i)return t.t("settings.auto");const s=e[i];return(null==s?void 0:s.height)?`${s.height}p`:t.t("settings.auto")}if("speed"===e){const e=this.state.playbackRate;return 1===e?t.t("settings.normal"):`${e}x`}if("audio"===e){const e=this.state.audioTracks;if(e.length<=1)return t.t("settings.default");const i=e[this.state.currentAudioTrack];return(null==i?void 0:i.name)||(null==i?void 0:i.lang)||t.t("settings.default")}if("subtitles"===e){const e=this.state.subtitleTracks;if(0===e.length)return t.t("settings.off");const i=this.state.currentSubtitleTrack;if(-1===i)return t.t("settings.off");const s=e[i];return(null==s?void 0:s.name)||(null==s?void 0:s.lang)||`Track ${i}`}return""}renderRootMenu(){const e=this.state.qualityLevels,t=this.i18n,i=e.length>0,s=!0===this.config.speed,n=(e,t,i,s)=>Z`
121
+ `:le`<button class="eb-live-sync" hidden style="display:none">${Be("live")}</button>`}}const Ue=[.25,.5,.75,1,1.25,1.5,1.75,2];class ze extends Se{constructor(){super(...arguments),this.mode="root",this.verticalDir="up",this.horizontalDir="right",this.outsideClickHandler=null,this.outsideClickTimer=null}onConnect(){this.state.on("settingsOpen",()=>{this.state.settingsOpen?(this.computePlacement(),this.addOutsideClickListener()):(this.mode="root",this.removeOutsideClickListener()),this.render()},{signal:this.signal}),this.state.on("qualityLevels",()=>this.render(),{signal:this.signal}),this.state.on("currentQuality",()=>this.render(),{signal:this.signal}),this.state.on("audioTracks",()=>this.render(),{signal:this.signal}),this.state.on("currentAudioTrack",()=>this.render(),{signal:this.signal}),this.state.on("subtitleTracks",()=>this.render(),{signal:this.signal}),this.state.on("currentSubtitleTrack",()=>this.render(),{signal:this.signal}),this.state.on("playbackRate",()=>this.render(),{signal:this.signal}),this.signal.addEventListener("abort",()=>this.removeOutsideClickListener()),this.render()}computePlacement(){var e,t;const i=null===(e=this.el)||void 0===e?void 0:e.closest(".eb-player"),s=null===(t=this.el)||void 0===t?void 0:t.querySelector(".eb-settings-toggle");if(!i||!s)return;const n=i.getBoundingClientRect(),r=s.getBoundingClientRect(),o=r.top+r.height/2-n.top,a=r.left+r.width/2-n.left;this.verticalDir=o<n.height/2?"down":"up",this.horizontalDir=a<n.width/2?"left":"right"}navigateTo(e){this.mode=e,this.render()}navigateBack(){this.mode="root",this.render()}currentValueLabel(e){const t=this.i18n;if("quality"===e){const e=this.state.qualityLevels,i=this.state.currentQuality;if(-1===i)return t.t("settings.auto");const s=e[i];return(null==s?void 0:s.height)?`${s.height}p`:t.t("settings.auto")}if("speed"===e){const e=this.state.playbackRate;return 1===e?t.t("settings.normal"):`${e}x`}if("audio"===e){const e=this.state.audioTracks;if(e.length<=1)return t.t("settings.default");const i=e[this.state.currentAudioTrack];return(null==i?void 0:i.name)||(null==i?void 0:i.lang)||t.t("settings.default")}if("subtitles"===e){const e=this.state.subtitleTracks;if(0===e.length)return t.t("settings.off");const i=this.state.currentSubtitleTrack;if(-1===i)return t.t("settings.off");const s=e[i];return(null==s?void 0:s.name)||(null==s?void 0:s.lang)||`Track ${i}`}return""}renderRootMenu(){const e=this.state.qualityLevels,t=this.i18n,i=e.length>0,s=!0===this.config.speed,n=(e,t,i,s)=>le`
122
122
  <li>
123
123
  <button class="eb-settings-category" @click="${()=>this.navigateTo(s)}">
124
- <span class="eb-settings-category__icon">${Le(e)}</span>
124
+ <span class="eb-settings-category__icon">${Be(e)}</span>
125
125
  <span class="eb-settings-category__label">${t}</span>
126
126
  <span class="eb-settings-category__value">${i}</span>
127
- <span class="eb-settings-category__chevron">${Le("chevron-right")}</span>
127
+ <span class="eb-settings-category__chevron">${Be("chevron-right")}</span>
128
128
  </button>
129
129
  </li>
130
- `;return Z`
130
+ `;return le`
131
131
  <ul class="eb-settings-menu eb-settings-root">
132
132
  ${n("audio",t.t("settings.audio"),this.currentValueLabel("audio"),"audio")}
133
133
  ${n("subtitle",t.t("settings.subtitles"),this.currentValueLabel("subtitles"),"subtitles")}
134
134
  ${s?n("speed",t.t("settings.speed"),this.currentValueLabel("speed"),"speed"):""}
135
135
  ${i?n("quality",t.t("settings.quality"),this.currentValueLabel("quality"),"quality"):""}
136
136
  </ul>
137
- `}renderSubMenu(e,t,i){return Z`
137
+ `}renderSubMenu(e,t,i){return le`
138
138
  <div class="eb-settings-submenu">
139
139
  <div class="eb-settings-header">
140
140
  <button class="eb-settings-back" @click="${()=>this.navigateBack()}">
141
- ${Le("chevron-left")}
141
+ ${Be("chevron-left")}
142
142
  </button>
143
143
  <span class="eb-settings-header__title">${e}</span>
144
144
  </div>
145
145
  <ul class="eb-settings-menu">
146
- ${t.map(e=>Z`
146
+ ${t.map(e=>le`
147
147
  <li>
148
148
  <button
149
149
  class="eb-settings-item ${e.selected?"eb-settings-item--selected":""}"
@@ -155,11 +155,11 @@
155
155
  `)}
156
156
  </ul>
157
157
  </div>
158
- `}renderQualityMenu(){const e=function(e,t){const i=e.map((e,i)=>{var s;return{label:e.height?`${e.height}p`:`${Math.round((null!==(s=e.bitrate)&&void 0!==s?s:0)/1e3)} kbps`,value:i,selected:i===t}});return i.push({label:"Auto",value:-1,selected:-1===t}),i}(this.state.qualityLevels,this.state.currentQuality);return this.renderSubMenu(this.i18n.t("settings.quality"),e,e=>{this.bus.emit("settings-select-quality",{index:e.value})})}renderSpeedMenu(){const e=function(e){return Be.map(t=>({label:1===t?"Normal":`${t}x`,value:t,selected:t===e}))}(this.state.playbackRate);return this.renderSubMenu(this.i18n.t("settings.speed"),e,e=>{this.bus.emit("settings-select-speed",{rate:e.value})})}renderAudioMenu(){const e=this.state.audioTracks,t=this.state.currentAudioTrack,i=e.length>1?function(e,t){return e.map((e,i)=>({label:e.name||e.lang||`Track ${i}`,value:i,selected:i===t}))}(e,t):[{label:this.i18n.t("settings.default"),value:0,selected:!0}];return this.renderSubMenu(this.i18n.t("settings.audio"),i,t=>{e.length>0&&this.bus.emit("settings-select-audio",{index:t.value})})}renderSubtitlesMenu(){const e=this.state.subtitleTracks,t=this.state.currentSubtitleTrack,i=e.length>0?function(e,t){const i=e.map((e,i)=>({label:e.name||e.lang||`Track ${i}`,value:i,selected:i===t}));return i.push({label:"Off",value:-1,selected:-1===t}),i}(e,t):[{label:this.i18n.t("settings.off"),value:-1,selected:!0}];return this.renderSubMenu(this.i18n.t("settings.subtitles"),i,t=>{e.length>0&&this.bus.emit("settings-select-subtitle",{index:t.value})})}addOutsideClickListener(){this.removeOutsideClickListener(),this.outsideClickTimer=setTimeout(()=>{var e;this.outsideClickTimer=null,(null===(e=this.state)||void 0===e?void 0:e.settingsOpen)&&(this.outsideClickHandler=e=>{var t;const i=null===(t=this.el)||void 0===t?void 0:t.querySelector(".eb-settings-wrapper");i&&!i.contains(e.target)&&(this.state.settingsOpen=!1)},document.addEventListener("click",this.outsideClickHandler,{capture:!0}))},0)}removeOutsideClickListener(){null!==this.outsideClickTimer&&(clearTimeout(this.outsideClickTimer),this.outsideClickTimer=null),null!==this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler,{capture:!0}),this.outsideClickHandler=null)}toggleSettings(){this.state.settingsOpen=!this.state.settingsOpen}template(){let e;if(this.state.settingsOpen){let t;t="quality"===this.mode?this.renderQualityMenu():"speed"===this.mode?this.renderSpeedMenu():"audio"===this.mode?this.renderAudioMenu():"subtitles"===this.mode?this.renderSubtitlesMenu():this.renderRootMenu();const i=`eb-settings-panel eb-settings-panel--${this.verticalDir} eb-settings-panel--${this.horizontalDir}`;e=Z`
158
+ `}renderQualityMenu(){const e=function(e,t){const i=e.map((e,i)=>{var s;return{label:e.height?`${e.height}p`:`${Math.round((null!==(s=e.bitrate)&&void 0!==s?s:0)/1e3)} kbps`,value:i,selected:i===t}});return i.push({label:"Auto",value:-1,selected:-1===t}),i}(this.state.qualityLevels,this.state.currentQuality);return this.renderSubMenu(this.i18n.t("settings.quality"),e,e=>{this.bus.emit("settings-select-quality",{index:e.value})})}renderSpeedMenu(){const e=function(e){return Ue.map(t=>({label:1===t?"Normal":`${t}x`,value:t,selected:t===e}))}(this.state.playbackRate);return this.renderSubMenu(this.i18n.t("settings.speed"),e,e=>{this.bus.emit("settings-select-speed",{rate:e.value})})}renderAudioMenu(){const e=this.state.audioTracks,t=this.state.currentAudioTrack,i=e.length>1?function(e,t){return e.map((e,i)=>({label:e.name||e.lang||`Track ${i}`,value:i,selected:i===t}))}(e,t):[{label:this.i18n.t("settings.default"),value:0,selected:!0}];return this.renderSubMenu(this.i18n.t("settings.audio"),i,t=>{e.length>0&&this.bus.emit("settings-select-audio",{index:t.value})})}renderSubtitlesMenu(){const e=this.state.subtitleTracks,t=this.state.currentSubtitleTrack,i=e.length>0?function(e,t){const i=e.map((e,i)=>({label:e.name||e.lang||`Track ${i}`,value:i,selected:i===t}));return i.push({label:"Off",value:-1,selected:-1===t}),i}(e,t):[{label:this.i18n.t("settings.off"),value:-1,selected:!0}];return this.renderSubMenu(this.i18n.t("settings.subtitles"),i,t=>{e.length>0&&this.bus.emit("settings-select-subtitle",{index:t.value})})}addOutsideClickListener(){this.removeOutsideClickListener(),this.outsideClickTimer=setTimeout(()=>{var e;this.outsideClickTimer=null,(null===(e=this.state)||void 0===e?void 0:e.settingsOpen)&&(this.outsideClickHandler=e=>{var t;const i=null===(t=this.el)||void 0===t?void 0:t.querySelector(".eb-settings-wrapper");i&&!i.contains(e.target)&&(this.state.settingsOpen=!1)},document.addEventListener("click",this.outsideClickHandler,{capture:!0}))},0)}removeOutsideClickListener(){null!==this.outsideClickTimer&&(clearTimeout(this.outsideClickTimer),this.outsideClickTimer=null),null!==this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler,{capture:!0}),this.outsideClickHandler=null)}toggleSettings(){this.state.settingsOpen=!this.state.settingsOpen}template(){let e;if(this.state.settingsOpen){let t;t="quality"===this.mode?this.renderQualityMenu():"speed"===this.mode?this.renderSpeedMenu():"audio"===this.mode?this.renderAudioMenu():"subtitles"===this.mode?this.renderSubtitlesMenu():this.renderRootMenu();const i=`eb-settings-panel eb-settings-panel--${this.verticalDir} eb-settings-panel--${this.horizontalDir}`;e=le`
159
159
  <div class="${i}">
160
160
  ${t}
161
161
  </div>
162
- `}else e=Z``;return Z`
162
+ `}else e=le``;return le`
163
163
  <div class="eb-settings-wrapper">
164
164
  ${e}
165
165
  <button
@@ -167,71 +167,71 @@
167
167
  aria-label="Settings"
168
168
  @click="${()=>this.toggleSettings()}"
169
169
  >
170
- ${Le("settings")}
170
+ ${Be("settings")}
171
171
  </button>
172
172
  </div>
173
- `}}class Fe extends fe{constructor(){super(...arguments),this.pipEnabled=!1,this.videoEl=null,this.enterHandler=null,this.leaveHandler=null}onConnect(){if(this.pipEnabled=!0===this.config.pip&&!0===document.pictureInPictureEnabled,this.pipEnabled){const e=this.el.closest(".eb-player");this.videoEl=null!==e?e.querySelector("video.eb-video"):this.el.querySelector("video"),null!==this.videoEl&&(this.enterHandler=()=>{this.state.isPip=!0},this.leaveHandler=()=>{this.state.isPip=!1},this.videoEl.addEventListener("enterpictureinpicture",this.enterHandler),this.videoEl.addEventListener("leavepictureinpicture",this.leaveHandler),this.signal.addEventListener("abort",()=>{this.videoEl.removeEventListener("enterpictureinpicture",this.enterHandler),this.videoEl.removeEventListener("leavepictureinpicture",this.leaveHandler),this.enterHandler=null,this.leaveHandler=null,this.videoEl=null}))}this.state.on("isPip",()=>this.render(),{signal:this.signal}),this.render()}handleClick(){this.state.isPip?document.exitPictureInPicture():null!==this.videoEl&&this.videoEl.requestPictureInPicture()}template(){if(!this.pipEnabled)return Z`<button class="eb-pip" hidden aria-hidden="true">${Le("pip")}</button>`;const e=this.state.isPip?"Exit picture-in-picture":"Picture-in-picture";return Z`
173
+ `}}class qe extends Se{constructor(){super(...arguments),this.pipEnabled=!1,this.videoEl=null,this.enterHandler=null,this.leaveHandler=null}onConnect(){if(this.pipEnabled=!0===this.config.pip&&!0===document.pictureInPictureEnabled,this.pipEnabled){const e=this.el.closest(".eb-player");this.videoEl=null!==e?e.querySelector("video.eb-video"):this.el.querySelector("video"),null!==this.videoEl&&(this.enterHandler=()=>{this.state.isPip=!0},this.leaveHandler=()=>{this.state.isPip=!1},this.videoEl.addEventListener("enterpictureinpicture",this.enterHandler),this.videoEl.addEventListener("leavepictureinpicture",this.leaveHandler),this.signal.addEventListener("abort",()=>{this.videoEl.removeEventListener("enterpictureinpicture",this.enterHandler),this.videoEl.removeEventListener("leavepictureinpicture",this.leaveHandler),this.enterHandler=null,this.leaveHandler=null,this.videoEl=null}))}this.state.on("isPip",()=>this.render(),{signal:this.signal}),this.render()}handleClick(){this.state.isPip?document.exitPictureInPicture():null!==this.videoEl&&this.videoEl.requestPictureInPicture()}template(){if(!this.pipEnabled)return le`<button class="eb-pip" hidden aria-hidden="true">${Be("pip")}</button>`;const e=this.state.isPip?"Exit picture-in-picture":"Picture-in-picture";return le`
174
174
  <button
175
175
  class="${this.state.isPip?"eb-pip eb-pip-active":"eb-pip"}"
176
176
  aria-label="${e}"
177
177
  @click="${()=>this.handleClick()}"
178
178
  >
179
- ${Le("pip")}
179
+ ${Be("pip")}
180
180
  </button>
181
- `}}class Oe extends fe{onConnect(){this.state.on("castAvailable",()=>this.render(),{signal:this.signal}),this.state.on("isCasting",()=>this.render(),{signal:this.signal}),this.render()}template(){const{castAvailable:e,isCasting:t,src:i}=this.state;return e?Z`
181
+ `}}class We extends Se{onConnect(){this.state.on("castAvailable",()=>this.render(),{signal:this.signal}),this.state.on("isCasting",()=>this.render(),{signal:this.signal}),this.render()}template(){const{castAvailable:e,isCasting:t,src:i}=this.state;return e?le`
182
182
  <button
183
183
  class="${t?"eb-cast eb-cast-active":"eb-cast"}"
184
184
  aria-label="${t?"Stop casting":"Cast"}"
185
185
  @click="${()=>this.bus.emit("cast-start",{src:i})}"
186
186
  >
187
- ${Le("cast")}
187
+ ${Be("cast")}
188
188
  </button>
189
- `:Z`<button class="eb-cast" hidden aria-hidden="true">${Le("cast")}</button>`}}const Ve=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],Ne=(()=>{if("undefined"==typeof document)return!1;const e=Ve[0],t={};for(const i of Ve){if((null==i?void 0:i[1])in document){for(const[s,n]of i.entries())t[e[s]]=n;return t}}return!1})(),Ie={change:Ne.fullscreenchange,error:Ne.fullscreenerror};let He={request:(e=document.documentElement,t)=>new Promise((i,s)=>{const n=()=>{He.off("change",n),i()};He.on("change",n);const r=e[Ne.requestFullscreen](t);r instanceof Promise&&r.then(n).catch(s)}),exit:()=>new Promise((e,t)=>{if(!He.isFullscreen)return void e();const i=()=>{He.off("change",i),e()};He.on("change",i);const s=document[Ne.exitFullscreen]();s instanceof Promise&&s.then(i).catch(t)}),toggle:(e,t)=>He.isFullscreen?He.exit():He.request(e,t),onchange(e){He.on("change",e)},onerror(e){He.on("error",e)},on(e,t){const i=Ie[e];i&&document.addEventListener(i,t,!1)},off(e,t){const i=Ie[e];i&&document.removeEventListener(i,t,!1)},raw:Ne};Object.defineProperties(He,{isFullscreen:{get:()=>Boolean(document[Ne.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!==(e=document[Ne.fullscreenElement])&&void 0!==e?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[Ne.fullscreenEnabled])}}),Ne||(He={isEnabled:!1});var je=He;class Ue extends fe{constructor(){super(...arguments),this.changeHandler=null,this.videoEl=null,this.videoFullscreenBeginHandler=null,this.videoFullscreenEndHandler=null,this.useVideoFallback=!1,this.handleDocFullscreenChange=()=>{const e=document.fullscreenElement===this.videoEl;this.state.isFullscreen=e,this.render()}}onConnect(){this.state.on("isFullscreen",()=>this.render(),{signal:this.signal}),je.isEnabled?(this.changeHandler=()=>{this.state.isFullscreen=je.isFullscreen,this.render()},je.on("change",this.changeHandler),this.signal.addEventListener("abort",()=>{je.off("change",this.changeHandler),this.changeHandler=null})):this.initVideoFallback(),this.render()}initVideoFallback(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.closest(".eb-player");if(!t)return;const i=t.querySelector("video.eb-video");if(!i)return;const s="function"==typeof i.webkitEnterFullscreen,n="function"==typeof i.requestFullscreen;(s||n)&&(this.videoEl=i,this.useVideoFallback=!0,this.videoFullscreenBeginHandler=()=>{this.state.isFullscreen=!0,this.render()},this.videoFullscreenEndHandler=()=>{this.state.isFullscreen=!1,this.render()},i.addEventListener("webkitbeginfullscreen",this.videoFullscreenBeginHandler),i.addEventListener("webkitendfullscreen",this.videoFullscreenEndHandler),document.addEventListener("fullscreenchange",this.handleDocFullscreenChange),this.signal.addEventListener("abort",()=>{i.removeEventListener("webkitbeginfullscreen",this.videoFullscreenBeginHandler),i.removeEventListener("webkitendfullscreen",this.videoFullscreenEndHandler),document.removeEventListener("fullscreenchange",this.handleDocFullscreenChange),this.videoFullscreenBeginHandler=null,this.videoFullscreenEndHandler=null,this.videoEl=null}))}handleClick(){var e;if(je.isEnabled){const t=null!==(e=this.el.closest(".eb-player"))&&void 0!==e?e:this.el;return void je.toggle(t)}this.useVideoFallback&&this.videoEl&&(this.state.isFullscreen?"function"==typeof this.videoEl.webkitExitFullscreen?this.videoEl.webkitExitFullscreen():document.exitFullscreen&&document.exitFullscreen():"function"==typeof this.videoEl.webkitEnterFullscreen?this.videoEl.webkitEnterFullscreen():"function"==typeof this.videoEl.requestFullscreen&&this.videoEl.requestFullscreen())}template(){if(!(je.isEnabled||this.useVideoFallback))return Z`<button class="eb-fullscreen" hidden aria-hidden="true">${Le("fullscreen")}</button>`;const e=this.state.isFullscreen;return Z`
189
+ `:le`<button class="eb-cast" hidden aria-hidden="true">${Be("cast")}</button>`}}const Ge=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],Qe=(()=>{if("undefined"==typeof document)return!1;const e=Ge[0],t={};for(const i of Ge){if((null==i?void 0:i[1])in document){for(const[s,n]of i.entries())t[e[s]]=n;return t}}return!1})(),Ye={change:Qe.fullscreenchange,error:Qe.fullscreenerror};let Ke={request:(e=document.documentElement,t)=>new Promise((i,s)=>{const n=()=>{Ke.off("change",n),i()};Ke.on("change",n);const r=e[Qe.requestFullscreen](t);r instanceof Promise&&r.then(n).catch(s)}),exit:()=>new Promise((e,t)=>{if(!Ke.isFullscreen)return void e();const i=()=>{Ke.off("change",i),e()};Ke.on("change",i);const s=document[Qe.exitFullscreen]();s instanceof Promise&&s.then(i).catch(t)}),toggle:(e,t)=>Ke.isFullscreen?Ke.exit():Ke.request(e,t),onchange(e){Ke.on("change",e)},onerror(e){Ke.on("error",e)},on(e,t){const i=Ye[e];i&&document.addEventListener(i,t,!1)},off(e,t){const i=Ye[e];i&&document.removeEventListener(i,t,!1)},raw:Qe};Object.defineProperties(Ke,{isFullscreen:{get:()=>Boolean(document[Qe.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!==(e=document[Qe.fullscreenElement])&&void 0!==e?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[Qe.fullscreenEnabled])}}),Qe||(Ke={isEnabled:!1});var Xe=Ke;class Je extends Se{constructor(){super(...arguments),this.changeHandler=null,this.videoEl=null,this.videoFullscreenBeginHandler=null,this.videoFullscreenEndHandler=null,this.useVideoFallback=!1,this.handleDocFullscreenChange=()=>{const e=document.fullscreenElement===this.videoEl;this.state.isFullscreen=e,this.render()}}onConnect(){this.state.on("isFullscreen",()=>this.render(),{signal:this.signal}),Xe.isEnabled?(this.changeHandler=()=>{this.state.isFullscreen=Xe.isFullscreen,this.render()},Xe.on("change",this.changeHandler),this.signal.addEventListener("abort",()=>{Xe.off("change",this.changeHandler),this.changeHandler=null})):this.initVideoFallback(),this.render()}initVideoFallback(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.closest(".eb-player");if(!t)return;const i=t.querySelector("video.eb-video");if(!i)return;const s="function"==typeof i.webkitEnterFullscreen,n="function"==typeof i.requestFullscreen;(s||n)&&(this.videoEl=i,this.useVideoFallback=!0,this.videoFullscreenBeginHandler=()=>{this.state.isFullscreen=!0,this.render()},this.videoFullscreenEndHandler=()=>{this.state.isFullscreen=!1,this.render()},i.addEventListener("webkitbeginfullscreen",this.videoFullscreenBeginHandler),i.addEventListener("webkitendfullscreen",this.videoFullscreenEndHandler),document.addEventListener("fullscreenchange",this.handleDocFullscreenChange),this.signal.addEventListener("abort",()=>{i.removeEventListener("webkitbeginfullscreen",this.videoFullscreenBeginHandler),i.removeEventListener("webkitendfullscreen",this.videoFullscreenEndHandler),document.removeEventListener("fullscreenchange",this.handleDocFullscreenChange),this.videoFullscreenBeginHandler=null,this.videoFullscreenEndHandler=null,this.videoEl=null}))}handleClick(){var e;if(Xe.isEnabled){const t=null!==(e=this.el.closest(".eb-player"))&&void 0!==e?e:this.el;return void Xe.toggle(t)}this.useVideoFallback&&this.videoEl&&(this.state.isFullscreen?"function"==typeof this.videoEl.webkitExitFullscreen?this.videoEl.webkitExitFullscreen():document.exitFullscreen&&document.exitFullscreen():"function"==typeof this.videoEl.webkitEnterFullscreen?this.videoEl.webkitEnterFullscreen():"function"==typeof this.videoEl.requestFullscreen&&this.videoEl.requestFullscreen())}template(){if(!(Xe.isEnabled||this.useVideoFallback))return le`<button class="eb-fullscreen" hidden aria-hidden="true">${Be("fullscreen")}</button>`;const e=this.state.isFullscreen;return le`
190
190
  <button
191
191
  class="eb-fullscreen"
192
192
  aria-label="${e?"Exit fullscreen":"Fullscreen"}"
193
193
  @click="${()=>this.handleClick()}"
194
194
  >
195
- ${Le(e?"fullscreen-exit":"fullscreen")}
195
+ ${Be(e?"fullscreen-exit":"fullscreen")}
196
196
  </button>
197
- `}}class ze extends fe{onConnect(){this.state.on("adPlaying",()=>this.render(),{signal:this.signal}),this.state.on("introStreamPlaying",()=>this.render(),{signal:this.signal}),this.render()}template(){if(this.state.adPlaying||this.state.introStreamPlaying)return Z``;const e=this.config.seekOffset||15,t="modern"===this.config.skin;return Z`
197
+ `}}class Ze extends Se{onConnect(){this.state.on("adPlaying",()=>this.render(),{signal:this.signal}),this.state.on("introStreamPlaying",()=>this.render(),{signal:this.signal}),this.render()}template(){if(this.state.adPlaying||this.state.introStreamPlaying)return le``;const e=this.config.seekOffset||15,t="modern"===this.config.skin;return le`
198
198
  <button
199
199
  class="eb-button eb-middle-bar__seek-btn"
200
200
  aria-label="Rewind ${e} seconds"
201
201
  @click="${()=>this.handleClick()}"
202
202
  >
203
- ${t?Le("rewind","eb-seek-circle"):Z`<svg class="eb-seek-circle" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
203
+ ${t?Be("rewind","eb-seek-circle"):le`<svg class="eb-seek-circle" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
204
204
  <path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z" fill="currentColor"/>
205
205
  </svg>`}
206
206
  <span class="eb-seek-label">${e}</span>
207
207
  </button>
208
- `}handleClick(){const e=this.config.seekOffset||15,t=Math.max(this.state.currentTime-e,0);this.bus.emit("seek",{time:t})}}class qe extends fe{onConnect(){this.state.on("adPlaying",()=>this.render(),{signal:this.signal}),this.state.on("introStreamPlaying",()=>this.render(),{signal:this.signal}),this.render()}template(){if(this.state.adPlaying||this.state.introStreamPlaying)return Z``;const e=this.config.seekOffset||15,t="modern"===this.config.skin;return Z`
208
+ `}handleClick(){const e=this.config.seekOffset||15,t=Math.max(this.state.currentTime-e,0);this.bus.emit("seek",{time:t})}}class et extends Se{onConnect(){this.state.on("adPlaying",()=>this.render(),{signal:this.signal}),this.state.on("introStreamPlaying",()=>this.render(),{signal:this.signal}),this.render()}template(){if(this.state.adPlaying||this.state.introStreamPlaying)return le``;const e=this.config.seekOffset||15,t="modern"===this.config.skin;return le`
209
209
  <button
210
210
  class="eb-button eb-middle-bar__seek-btn"
211
211
  aria-label="Forward ${e} seconds"
212
212
  @click="${()=>this.handleClick()}"
213
213
  >
214
- ${t?Le("forward","eb-seek-circle"):Z`<svg class="eb-seek-circle" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
214
+ ${t?Be("forward","eb-seek-circle"):le`<svg class="eb-seek-circle" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
215
215
  <path d="M12 5V1l5 5-5 5V7c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6h2c0 4.42-3.58 8-8 8s-8-3.58-8-8 3.58-8 8-8z" fill="currentColor"/>
216
216
  </svg>`}
217
217
  <span class="eb-seek-label">${e}</span>
218
218
  </button>
219
- `}handleClick(){const e=this.config.seekOffset||15,t=Math.min(this.state.currentTime+e,this.state.duration);this.bus.emit("seek",{time:t})}}class We extends fe{onConnect(){this.render()}template(){return!1===this.config.socials?Z`<span hidden></span>`:Z`
219
+ `}handleClick(){const e=this.config.seekOffset||15,t=Math.min(this.state.currentTime+e,this.state.duration);this.bus.emit("seek",{time:t})}}class tt extends Se{onConnect(){this.render()}template(){return!1===this.config.socials?le`<span hidden></span>`:le`
220
220
  <button
221
221
  class="eb-button eb-top-bar__btn-share"
222
222
  @click="${()=>{this.state.socialsOpen=!this.state.socialsOpen}}"
223
223
  aria-label="Share"
224
- >${Le("share")}</button>
225
- `}}class Ge extends fe{onConnect(){this.render()}template(){return Z`
224
+ >${Be("share")}</button>
225
+ `}}class it extends Se{onConnect(){this.render()}template(){return le`
226
226
  <button
227
227
  class="eb-button eb-top-bar__btn-info"
228
228
  @click="${()=>{this.state.infoOpen=!this.state.infoOpen}}"
229
229
  aria-label="Info"
230
- >${Le("info")}</button>
231
- `}}class Qe extends fe{onConnect(){this.render()}template(){const e=this.config.channelName;return e?Z`<span class="eb-channel-name">${e}</span>`:Z``}}const Ye={"play-pause":()=>new xe,volume:()=>new Ae,seekbar:()=>new Me,time:()=>new Pe,"live-sync":()=>new Re,settings:()=>new De,pip:()=>new Fe,cast:()=>new Oe,fullscreen:()=>new Ue,rewind:()=>new ze,forward:()=>new qe,share:()=>new We,info:()=>new Ge,"channel-name":()=>new Qe};function Ke(e){return"seekbar"===e?".eb-bottom-bar__seekbar-zone":`.eb-slot-${e}`}class Xe extends fe{onConnect(){this.state.on("playbackState",()=>this.render(),{signal:this.signal}),this.state.on("reconnecting",()=>this.render(),{signal:this.signal}),this.render()}template(){var e,t;const i="buffering"===this.state.playbackState,s=this.state.reconnecting;if(!i&&!s)return Z`<div class="eb-loading" hidden aria-hidden="true"></div>`;const n=s?null!==(t=null===(e=this.i18n)||void 0===e?void 0:e.t("loading.reconnecting"))&&void 0!==t?t:"Reconnecting...":"Loading";return Z`<div class="eb-loading" role="status" aria-label="${n}">
230
+ >${Be("info")}</button>
231
+ `}}class st extends Se{onConnect(){this.render()}template(){const e=this.config.channelName;return e?le`<span class="eb-channel-name">${e}</span>`:le``}}const nt={"play-pause":()=>new Fe,volume:()=>new Oe,seekbar:()=>new Ie,time:()=>new He,"live-sync":()=>new je,settings:()=>new ze,pip:()=>new qe,cast:()=>new We,fullscreen:()=>new Je,rewind:()=>new Ze,forward:()=>new et,share:()=>new tt,info:()=>new it,"channel-name":()=>new st};function rt(e){return"seekbar"===e?".eb-bottom-bar__seekbar-zone":`.eb-slot-${e}`}class ot extends Se{onConnect(){this.state.on("playbackState",()=>this.render(),{signal:this.signal}),this.state.on("reconnecting",()=>this.render(),{signal:this.signal}),this.render()}template(){var e,t;const i="buffering"===this.state.playbackState,s=this.state.reconnecting;if(!i&&!s)return le`<div class="eb-loading" hidden aria-hidden="true"></div>`;const n=s?null!==(t=null===(e=this.i18n)||void 0===e?void 0:e.t("loading.reconnecting"))&&void 0!==t?t:"Reconnecting...":"Loading";return le`<div class="eb-loading" role="status" aria-label="${n}">
232
232
  <div class="eb-loading-arc"></div>
233
- ${s?Z`<span class="eb-loading-text">${n}</span>`:""}
234
- </div>`}}class Je extends fe{onConnect(){this.state.on("error",()=>this.render(),{signal:this.signal}),this.render()}template(){const e=this.state.error;if(null===e)return Z`<div class="eb-error" hidden aria-hidden="true"></div>`;const t=A(this.state.errorCode,e,this.i18n);return Z`
233
+ ${s?le`<span class="eb-loading-text">${n}</span>`:""}
234
+ </div>`}}class at extends Se{onConnect(){this.state.on("error",()=>this.render(),{signal:this.signal}),this.render()}template(){const e=this.state.error;if(null===e)return le`<div class="eb-error" hidden aria-hidden="true"></div>`;const t=O(this.state.errorCode,e,this.i18n);return le`
235
235
  <div class="eb-error" role="alert">
236
236
  <p class="eb-error-message">${t}</p>
237
237
  <button
@@ -241,7 +241,7 @@
241
241
  Retry
242
242
  </button>
243
243
  </div>
244
- `}}const Ze=["subtitles","captions"];function et(e){return"number"==typeof e?`${e}px`:e}class tt extends fe{constructor(){super(...arguments),this.video=null,this.taken=[],this.listRoot=null,this.onTracksChange=()=>this.syncTracks(),this.onCueChange=()=>this.paint()}onConnect(){var e,t,i;this.applyStyle(null!==(e=this.config.subtitleStyle)&&void 0!==e?e:{}),this.render(),this.listRoot=this.el.querySelector(".eb-subtitle");const s=this.state.isIOS?null:null===(t=this.el.closest(".eb-player"))||void 0===t?void 0:t.querySelector("video.eb-video");null!=s&&"function"==typeof(null===(i=s.textTracks)||void 0===i?void 0:i.addEventListener)&&(this.video=s,this.video.textTracks.addEventListener("change",this.onTracksChange),this.video.textTracks.addEventListener("addtrack",this.onTracksChange),this.syncTracks())}disconnect(){null!==this.video&&(this.video.textTracks.removeEventListener("change",this.onTracksChange),this.video.textTracks.removeEventListener("addtrack",this.onTracksChange));for(const e of this.taken)e.removeEventListener("cuechange",this.onCueChange);this.taken.length=0,this.video=null,this.listRoot=null,super.disconnect()}template(){return Z`<div class="eb-subtitle" aria-hidden="true"></div>`}applyStyle(e){const t=this.el,i=[["--eb-subtitle-font-family",e.fontFamily],["--eb-subtitle-font-size",e.fontSize],["--eb-subtitle-color",e.color],["--eb-subtitle-background",e.backgroundColor],["--eb-subtitle-bottom",e.bottom],["--eb-subtitle-bottom-controls",e.bottomWithControls]];for(const[e,s]of i)void 0!==s&&t.style.setProperty(e,et(s))}syncTracks(){const e=this.video.textTracks;for(let t=0;t<e.length;t++){const i=e[t];if(-1===Ze.indexOf(i.kind))continue;const s=this.taken.indexOf(i);"showing"===i.mode?(i.mode="hidden",-1===s&&(this.taken.push(i),i.addEventListener("cuechange",this.onCueChange))):"disabled"===i.mode&&-1!==s&&(this.taken.splice(s,1),i.removeEventListener("cuechange",this.onCueChange))}this.paint()}paint(){const e=this.listRoot;if(null!==e){e.textContent="";for(const t of this.taken)if("hidden"===t.mode&&null!==t.activeCues)for(let i=0;i<t.activeCues.length;i++)e.appendChild(this.renderCue(t.activeCues[i]))}}renderCue(e){const t=document.createElement("div");t.className="eb-subtitle__cue";const i=e;return"function"==typeof i.getCueAsHTML?t.appendChild(i.getCueAsHTML()):t.textContent=i.text,t}}class it extends fe{onConnect(){this.state.on("socialsOpen",()=>this.render(),{signal:this.signal}),this.render()}template(){if(!this.state.socialsOpen)return Z`<div class="eb-socials-overlay" hidden aria-hidden="true"></div>`;const e=this.config.socials,t=!1!==e?Object.entries(e).map(([e,t])=>Z`
244
+ `}}const lt=["subtitles","captions"];function ct(e){return"number"==typeof e?`${e}px`:e}class dt extends Se{constructor(){super(...arguments),this.video=null,this.taken=[],this.listRoot=null,this.onTracksChange=()=>this.syncTracks(),this.onCueChange=()=>this.paint()}onConnect(){var e,t,i;this.applyStyle(null!==(e=this.config.subtitleStyle)&&void 0!==e?e:{}),this.render(),this.listRoot=this.el.querySelector(".eb-subtitle");const s=this.state.isIOS?null:null===(t=this.el.closest(".eb-player"))||void 0===t?void 0:t.querySelector("video.eb-video");null!=s&&"function"==typeof(null===(i=s.textTracks)||void 0===i?void 0:i.addEventListener)&&(this.video=s,this.video.textTracks.addEventListener("change",this.onTracksChange),this.video.textTracks.addEventListener("addtrack",this.onTracksChange),this.syncTracks())}disconnect(){null!==this.video&&(this.video.textTracks.removeEventListener("change",this.onTracksChange),this.video.textTracks.removeEventListener("addtrack",this.onTracksChange));for(const e of this.taken)e.removeEventListener("cuechange",this.onCueChange);this.taken.length=0,this.video=null,this.listRoot=null,super.disconnect()}template(){return le`<div class="eb-subtitle" aria-hidden="true"></div>`}applyStyle(e){const t=this.el,i=[["--eb-subtitle-font-family",e.fontFamily],["--eb-subtitle-font-size",e.fontSize],["--eb-subtitle-color",e.color],["--eb-subtitle-background",e.backgroundColor],["--eb-subtitle-bottom",e.bottom],["--eb-subtitle-bottom-controls",e.bottomWithControls]];for(const[e,s]of i)void 0!==s&&t.style.setProperty(e,ct(s))}syncTracks(){const e=this.video.textTracks;for(let t=0;t<e.length;t++){const i=e[t];if(-1===lt.indexOf(i.kind))continue;const s=this.taken.indexOf(i);"showing"===i.mode?(i.mode="hidden",-1===s&&(this.taken.push(i),i.addEventListener("cuechange",this.onCueChange))):"disabled"===i.mode&&-1!==s&&(this.taken.splice(s,1),i.removeEventListener("cuechange",this.onCueChange))}this.paint()}paint(){const e=this.listRoot;if(null!==e){e.textContent="";for(const t of this.taken)if("hidden"===t.mode&&null!==t.activeCues)for(let i=0;i<t.activeCues.length;i++)e.appendChild(this.renderCue(t.activeCues[i]))}}renderCue(e){const t=document.createElement("div");t.className="eb-subtitle__cue";const i=e;return"function"==typeof i.getCueAsHTML?t.appendChild(i.getCueAsHTML()):t.textContent=i.text,t}}class ut extends Se{onConnect(){this.state.on("socialsOpen",()=>this.render(),{signal:this.signal}),this.render()}template(){if(!this.state.socialsOpen)return le`<div class="eb-socials-overlay" hidden aria-hidden="true"></div>`;const e=this.config.socials,t=!1!==e?Object.entries(e).map(([e,t])=>le`
245
245
  <a
246
246
  class="eb-socials-link eb-socials-link--${e}"
247
247
  href="${t}"
@@ -250,7 +250,7 @@
250
250
  >
251
251
  ${e}
252
252
  </a>
253
- `):[];return Z`
253
+ `):[];return le`
254
254
  <div class="eb-socials-overlay" role="dialog" aria-label="Share">
255
255
  <div class="eb-socials-links">
256
256
  ${t}
@@ -263,7 +263,7 @@
263
263
  Close
264
264
  </button>
265
265
  </div>
266
- `}}class st extends fe{onConnect(){this.state.on("infoOpen",()=>this.render(),{signal:this.signal}),this.render()}template(){if(!this.state.infoOpen)return Z`<div class="eb-info-overlay" hidden aria-hidden="true"></div>`;const e=this.config.about;return Z`
266
+ `}}class ht extends Se{onConnect(){this.state.on("infoOpen",()=>this.render(),{signal:this.signal}),this.render()}template(){if(!this.state.infoOpen)return le`<div class="eb-info-overlay" hidden aria-hidden="true"></div>`;const e=this.config.about;return le`
267
267
  <div class="eb-info-overlay" role="dialog" aria-label="About">
268
268
  <div class="eb-info-content">${e}</div>
269
269
  <button
@@ -274,19 +274,19 @@
274
274
  Close
275
275
  </button>
276
276
  </div>
277
- `}}class nt extends fe{onConnect(){this.state.on("toast",()=>this.render(),{signal:this.signal}),this.render()}template(){const e=this.state.toast;return null===e?Z`<div class="eb-toast" hidden aria-hidden="true"></div>`:Z`<div class="eb-toast" role="status">${e}</div>`}}class rt extends fe{onConnect(){this.state.on("introStreamPlaying",()=>this.render(),{signal:this.signal}),this.state.on("currentTime",()=>this.render(),{signal:this.signal}),this.render()}remainingSkip(){const e=this.config.prerollSkip;return Number.isFinite(e)?Math.max(0,Math.ceil(e-this.state.currentTime)):1/0}template(){var e,t;if(!this.state.introStreamPlaying)return Z`<div class="eb-preroll-overlay" hidden aria-hidden="true"></div>`;const i=this.config.prerollSkip,s=this.config.prerollLink,n=Number.isFinite(i),r=this.remainingSkip(),o=r<=0,a=null!==(t=null===(e=this.i18n)||void 0===e?void 0:e.t("preroll.skip"))&&void 0!==t?t:"Skip";return Z`
277
+ `}}class vt extends Se{onConnect(){this.state.on("toast",()=>this.render(),{signal:this.signal}),this.render()}template(){const e=this.state.toast;return null===e?le`<div class="eb-toast" hidden aria-hidden="true"></div>`:le`<div class="eb-toast" role="status">${e}</div>`}}class gt extends Se{onConnect(){this.state.on("introStreamPlaying",()=>this.render(),{signal:this.signal}),this.state.on("currentTime",()=>this.render(),{signal:this.signal}),this.render()}remainingSkip(){const e=this.config.prerollSkip;return Number.isFinite(e)?Math.max(0,Math.ceil(e-this.state.currentTime)):1/0}template(){var e,t;if(!this.state.introStreamPlaying)return le`<div class="eb-preroll-overlay" hidden aria-hidden="true"></div>`;const i=this.config.prerollSkip,s=this.config.prerollLink,n=Number.isFinite(i),r=this.remainingSkip(),o=r<=0,a=null!==(t=null===(e=this.i18n)||void 0===e?void 0:e.t("preroll.skip"))&&void 0!==t?t:"Skip";return le`
278
278
  <div
279
279
  class="eb-preroll-overlay"
280
280
  @click="${e=>this.handleOverlayClick(e,s)}"
281
281
  >
282
- ${n?Z`<button
282
+ ${n?le`<button
283
283
  class="eb-preroll-skip${o?"":" eb-preroll-skip--locked"}"
284
284
  aria-label="${a}"
285
285
  ?disabled="${!o}"
286
286
  @click="${e=>this.handleSkip(e)}"
287
- >${a}${r>0?Z` (${r})`:""}</button>`:""}
287
+ >${a}${r>0?le` (${r})`:""}</button>`:""}
288
288
  </div>
289
- `}handleSkip(e){e.stopPropagation(),this.remainingSkip()>0||this.bus.emit("preroll-skip")}handleOverlayClick(e,t){if(t)try{const e=new URL(t,window.location.href);if("http:"!==e.protocol&&"https:"!==e.protocol)return void console.warn("PrerollOverlay: refusing to open non-http(s) prerollLink",t);window.open(e.href,"_blank","noopener,noreferrer")}catch(e){console.warn("PrerollOverlay: invalid prerollLink",t)}}}class ot extends fe{onConnect(){this.render(),this.state.on("playlist",()=>{this.render()},{signal:this.signal}),this.state.on("currentEpisode",()=>{this.render()},{signal:this.signal})}template(){const e=this.state.playlist,t=this.state.currentEpisode;return 0===e.length?Z``:Z`
289
+ `}handleSkip(e){e.stopPropagation(),this.remainingSkip()>0||this.bus.emit("preroll-skip")}handleOverlayClick(e,t){if(t)try{const e=new URL(t,window.location.href);if("http:"!==e.protocol&&"https:"!==e.protocol)return void console.warn("PrerollOverlay: refusing to open non-http(s) prerollLink",t);window.open(e.href,"_blank","noopener,noreferrer")}catch(e){console.warn("PrerollOverlay: invalid prerollLink",t)}}}class pt extends Se{onConnect(){this.render(),this.state.on("playlist",()=>{this.render()},{signal:this.signal}),this.state.on("currentEpisode",()=>{this.render()},{signal:this.signal})}template(){const e=this.state.playlist,t=this.state.currentEpisode;return 0===e.length?le``:le`
290
290
  <div class="eb-forja-playlist-bar">
291
291
  <button
292
292
  class="eb-forja-playlist-bar__nav"
@@ -297,11 +297,11 @@
297
297
  &#8249;
298
298
  </button>
299
299
  <div class="eb-forja-playlist-bar__items">
300
- ${e.map((e,i)=>Z`
300
+ ${e.map((e,i)=>le`
301
301
  <div
302
302
  class="eb-forja-playlist-bar__item${i===t?" eb-forja-playlist-bar__item--active":""}"
303
303
  >
304
- ${e.image?Z`<img
304
+ ${e.image?le`<img
305
305
  class="eb-forja-playlist-bar__thumb"
306
306
  src="${e.image}"
307
307
  alt=""
@@ -320,9 +320,9 @@
320
320
  &#8250;
321
321
  </button>
322
322
  </div>
323
- `}formatDuration(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}}class at extends fe{onConnect(){this.render(),this.state.on("epgPrograms",()=>{this.render()},{signal:this.signal})}template(){const e=this.state.epgPrograms;return Z`
323
+ `}formatDuration(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}}class mt extends Se{onConnect(){this.render(),this.state.on("epgPrograms",()=>{this.render()},{signal:this.signal})}template(){const e=this.state.epgPrograms;return le`
324
324
  <div class="eb-snrt-carousel">
325
- ${e.map(e=>Z`
325
+ ${e.map(e=>le`
326
326
  <div class="eb-snrt-carousel__item">
327
327
  <span class="eb-snrt-carousel__title">${e.title}</span>
328
328
  <span class="eb-snrt-carousel__time">
@@ -331,7 +331,7 @@
331
331
  </div>
332
332
  `)}
333
333
  </div>
334
- `}formatTime(e){return new Date(1e3*e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}const lt={play:'<symbol id="eb-play" viewBox="0 0 24 24"><path fill="currentColor" d="M8 5v14l11-7z"/></symbol>',pause:'<symbol id="eb-pause" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/></symbol>',"volume-high":'<symbol id="eb-volume-high" viewBox="0 0 24 24"><path fill="currentColor" d="M3 9v6h4l5 4V5L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></symbol>',"volume-low":'<symbol id="eb-volume-low" viewBox="0 0 24 24"><path fill="currentColor" d="M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 4V5L9 9H5z"/></symbol>',"volume-mute":'<symbol id="eb-volume-mute" viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 4v-7.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/></symbol>',fullscreen:'<symbol id="eb-fullscreen" viewBox="0 0 24 24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></symbol>',"fullscreen-exit":'<symbol id="eb-fullscreen-exit" viewBox="0 0 24 24"><path fill="currentColor" d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/></symbol>',settings:'<symbol id="eb-settings" viewBox="0 0 24 24"><path fill="currentColor" d="M19.14 12.94c.04-.3.06-.61.06-.94s-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/></symbol>',pip:'<symbol id="eb-pip" viewBox="0 0 24 24"><path fill="currentColor" d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z"/></symbol>',cast:'<symbol id="eb-cast" viewBox="0 0 24 24"><path fill="currentColor" d="M21 3H3c-1.1 0-2 .9-2 2v3h2V5h18v14h-7v2h7c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM1 18v3h3c0-1.66-1.34-3-3-3zm0-4v2c2.76 0 5 2.24 5 5h2c0-3.87-3.13-7-7-7zm0-4v2c4.97 0 9 4.03 9 9h2c0-6.08-4.93-11-11-11z"/></symbol>',close:'<symbol id="eb-close" viewBox="0 0 24 24"><path fill="currentColor" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></symbol>',share:'<symbol id="eb-share" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-width="2" d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><polyline fill="none" stroke="currentColor" stroke-width="2" points="16 6 12 2 8 6"/><line fill="none" stroke="currentColor" stroke-width="2" x1="12" y1="2" x2="12" y2="15"/></symbol>',info:'<symbol id="eb-info" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></symbol>',speed:'<symbol id="eb-speed" viewBox="0 0 24 24"><path fill="currentColor" d="M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"/></symbol>',"chevron-left":'<symbol id="eb-chevron-left" viewBox="0 0 24 24"><polyline fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" points="15 18 9 12 15 6"/></symbol>',"chevron-right":'<symbol id="eb-chevron-right" viewBox="0 0 24 24"><polyline fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" points="9 18 15 12 9 6"/></symbol>',spinner:'<symbol id="eb-spinner" viewBox="0 0 24 24"><path fill="currentColor" d="M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8z"/></symbol>',live:'<symbol id="eb-live" viewBox="0 0 24 24"><path fill="currentColor" d="M16.247 7.761a6 6 0 0 1 0 8.478"/><path fill="currentColor" d="M19.075 4.933a10 10 0 0 1 0 14.134"/><path fill="currentColor" d="M4.925 19.067a10 10 0 0 1 0-14.134"/><path fill="currentColor" d="M7.753 16.239a6 6 0 0 1 0-8.478"/><circle fill="currentColor" cx="12" cy="12" r="2"/></symbol>',subtitle:'<symbol id="eb-subtitle" viewBox="0 0 24 24"><path fill="currentColor" d="M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 7H8v-1.5H6V14h2v-1.5h4V15H6c-1.1 0-2-.9-2-2v-2c0-1.1.9-2 2-2h6v3zm8 0h-4v-1.5h-2V14h2v-1.5h4V15h-6c-1.1 0-2-.9-2-2v-2c0-1.1.9-2 2-2h6v3z"/></symbol>',audio:'<symbol id="eb-audio" viewBox="0 0 24 24"><path fill="currentColor" d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></symbol>',quality:'<symbol id="eb-quality" viewBox="0 0 24 24"><rect fill="currentColor" x="2" y="16" width="4" height="5" rx="1" opacity=".4"/><rect fill="currentColor" x="7" y="12" width="4" height="9" rx="1" opacity=".65"/><rect fill="currentColor" x="12" y="7" width="4" height="14" rx="1" opacity=".85"/><rect fill="currentColor" x="17" y="3" width="4" height="18" rx="1"/></symbol>',rewind:'<symbol id="eb-rewind" viewBox="0 0 24 24"><path fill="currentColor" d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/></symbol>',forward:'<symbol id="eb-forward" viewBox="0 0 24 24"><path fill="currentColor" d="M12 5V1l5 5-5 5V7c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6h2c0 4.42-3.58 8-8 8s-8-3.58-8-8 3.58-8 8-8z"/></symbol>'};class ct extends fe{constructor(){super(...arguments),this.videoElement=null,this.adsContainerElement=null,this.posterVideoElement=null,this.extensionCleanups=[],this.childComponents=[]}getVideoElement(){return this.videoElement}getAdsContainer(){return this.adsContainerElement}getPosterVideoElement(){return this.posterVideoElement}onConnect(){!function(){Te=Object.assign({},ke);const e=we(Te),t=document.getElementById("eb-sprite");null!==t&&(t.innerHTML=e)}(),Ce(),"modern"===this.config.skin&&Ce(lt),this.render(),this.bindElementRefs(),this.connectChildComponents(),this.subscribeToState(),this.updateControlsVisibility(),this.invokeExtensions()}template(){const e=this.config,t=this.state;if(e.noUi)return this.renderNoUiTemplate();const i=t.isRtl,s=t.isIOS,n=e.middlebar,r=t.currentTime>0,o=!1!==e.image&&("idle"===t.playbackState||"loading"===t.playbackState||"playing"===t.playbackState&&!r),a=t.isRadio;return Z`
334
+ `}formatTime(e){return new Date(1e3*e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}const ft={play:'<symbol id="eb-play" viewBox="0 0 24 24"><path fill="currentColor" d="M8 5v14l11-7z"/></symbol>',pause:'<symbol id="eb-pause" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/></symbol>',"volume-high":'<symbol id="eb-volume-high" viewBox="0 0 24 24"><path fill="currentColor" d="M3 9v6h4l5 4V5L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></symbol>',"volume-low":'<symbol id="eb-volume-low" viewBox="0 0 24 24"><path fill="currentColor" d="M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 4V5L9 9H5z"/></symbol>',"volume-mute":'<symbol id="eb-volume-mute" viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 4v-7.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/></symbol>',fullscreen:'<symbol id="eb-fullscreen" viewBox="0 0 24 24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></symbol>',"fullscreen-exit":'<symbol id="eb-fullscreen-exit" viewBox="0 0 24 24"><path fill="currentColor" d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/></symbol>',settings:'<symbol id="eb-settings" viewBox="0 0 24 24"><path fill="currentColor" d="M19.14 12.94c.04-.3.06-.61.06-.94s-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/></symbol>',pip:'<symbol id="eb-pip" viewBox="0 0 24 24"><path fill="currentColor" d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z"/></symbol>',cast:'<symbol id="eb-cast" viewBox="0 0 24 24"><path fill="currentColor" d="M21 3H3c-1.1 0-2 .9-2 2v3h2V5h18v14h-7v2h7c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM1 18v3h3c0-1.66-1.34-3-3-3zm0-4v2c2.76 0 5 2.24 5 5h2c0-3.87-3.13-7-7-7zm0-4v2c4.97 0 9 4.03 9 9h2c0-6.08-4.93-11-11-11z"/></symbol>',close:'<symbol id="eb-close" viewBox="0 0 24 24"><path fill="currentColor" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></symbol>',share:'<symbol id="eb-share" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-width="2" d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><polyline fill="none" stroke="currentColor" stroke-width="2" points="16 6 12 2 8 6"/><line fill="none" stroke="currentColor" stroke-width="2" x1="12" y1="2" x2="12" y2="15"/></symbol>',info:'<symbol id="eb-info" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></symbol>',speed:'<symbol id="eb-speed" viewBox="0 0 24 24"><path fill="currentColor" d="M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"/></symbol>',"chevron-left":'<symbol id="eb-chevron-left" viewBox="0 0 24 24"><polyline fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" points="15 18 9 12 15 6"/></symbol>',"chevron-right":'<symbol id="eb-chevron-right" viewBox="0 0 24 24"><polyline fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" points="9 18 15 12 9 6"/></symbol>',spinner:'<symbol id="eb-spinner" viewBox="0 0 24 24"><path fill="currentColor" d="M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8z"/></symbol>',live:'<symbol id="eb-live" viewBox="0 0 24 24"><path fill="currentColor" d="M16.247 7.761a6 6 0 0 1 0 8.478"/><path fill="currentColor" d="M19.075 4.933a10 10 0 0 1 0 14.134"/><path fill="currentColor" d="M4.925 19.067a10 10 0 0 1 0-14.134"/><path fill="currentColor" d="M7.753 16.239a6 6 0 0 1 0-8.478"/><circle fill="currentColor" cx="12" cy="12" r="2"/></symbol>',subtitle:'<symbol id="eb-subtitle" viewBox="0 0 24 24"><path fill="currentColor" d="M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 7H8v-1.5H6V14h2v-1.5h4V15H6c-1.1 0-2-.9-2-2v-2c0-1.1.9-2 2-2h6v3zm8 0h-4v-1.5h-2V14h2v-1.5h4V15h-6c-1.1 0-2-.9-2-2v-2c0-1.1.9-2 2-2h6v3z"/></symbol>',audio:'<symbol id="eb-audio" viewBox="0 0 24 24"><path fill="currentColor" d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></symbol>',quality:'<symbol id="eb-quality" viewBox="0 0 24 24"><rect fill="currentColor" x="2" y="16" width="4" height="5" rx="1" opacity=".4"/><rect fill="currentColor" x="7" y="12" width="4" height="9" rx="1" opacity=".65"/><rect fill="currentColor" x="12" y="7" width="4" height="14" rx="1" opacity=".85"/><rect fill="currentColor" x="17" y="3" width="4" height="18" rx="1"/></symbol>',rewind:'<symbol id="eb-rewind" viewBox="0 0 24 24"><path fill="currentColor" d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/></symbol>',forward:'<symbol id="eb-forward" viewBox="0 0 24 24"><path fill="currentColor" d="M12 5V1l5 5-5 5V7c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6h2c0 4.42-3.58 8-8 8s-8-3.58-8-8 3.58-8 8-8z"/></symbol>'};class bt extends Se{constructor(){super(...arguments),this.videoElement=null,this.adsContainerElement=null,this.posterVideoElement=null,this.extensionCleanups=[],this.childComponents=[]}getVideoElement(){return this.videoElement}getAdsContainer(){return this.adsContainerElement}getPosterVideoElement(){return this.posterVideoElement}onConnect(){!function(){Me=Object.assign({},$e);const e=Pe(Me),t=document.getElementById("eb-sprite");null!==t&&(t.innerHTML=e)}(),Re(),"modern"===this.config.skin&&Re(ft),this.render(),this.bindElementRefs(),this.connectChildComponents(),this.subscribeToState(),this.updateControlsVisibility(),this.invokeExtensions()}template(){const e=this.config,t=this.state;if(e.noUi)return this.renderNoUiTemplate();const i=t.isRtl,s=t.isIOS,n=e.middlebar,r=t.currentTime>0,o=!1!==e.image&&("idle"===t.playbackState||"loading"===t.playbackState||"playing"===t.playbackState&&!r),a=t.isRadio;return le`
335
335
  <div
336
336
  class="eb-player${s?" eb-ios-native":""}"
337
337
  dir="${i?"rtl":"ltr"}"
@@ -345,19 +345,19 @@
345
345
  ></video>
346
346
 
347
347
  <div class="eb-overlay-zone">
348
- ${!1!==e.image?Z`<img
348
+ ${!1!==e.image?le`<img
349
349
  class="eb-poster"
350
350
  src="${e.image}"
351
351
  style="${o?"":"display:none"}"
352
352
  alt=""
353
353
  />`:""}
354
- ${e.posterStream?Z`<video
354
+ ${e.posterStream?le`<video
355
355
  class="eb-poster-video"
356
356
  muted
357
357
  playsinline
358
358
  style="position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover;display:none"
359
359
  ></video>`:""}
360
- ${a?Z`<div class="eb-radio-overlay">
360
+ ${a?le`<div class="eb-radio-overlay">
361
361
  <div class="eb-radio-bars">
362
362
  <span class="eb-radio-bar"></span>
363
363
  <span class="eb-radio-bar"></span>
@@ -371,10 +371,10 @@
371
371
  <div class="eb-ads-container"></div>
372
372
 
373
373
  <div class="eb-top-bar-zone">
374
- ${void 0!==e.logo?Z`<img class="eb-logo" src="${e.logo}" alt="" />`:""}
374
+ ${void 0!==e.logo?le`<img class="eb-logo" src="${e.logo}" alt="" />`:""}
375
375
  </div>
376
376
 
377
- ${n?Z`<div class="eb-middle-bar-zone"></div>`:""}
377
+ ${n?le`<div class="eb-middle-bar-zone"></div>`:""}
378
378
 
379
379
  <div class="eb-bottom-bar-zone"></div>
380
380
 
@@ -383,7 +383,7 @@
383
383
  <div class="eb-extension-overlay"></div>
384
384
  <div class="eb-extension-controls-extra"></div>
385
385
  </div>
386
- `}connectChildComponents(){var e,t;const i=this.config;if(i.noUi)return;const s=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==s)return;const n=this.state,r=this.bus,o=u(i),a=null!==(t=this.i18n)&&void 0!==t?t:void 0,l=(e,t)=>{const o=s.querySelector(t);return null!==o&&(e.connect(o,n,r,i,a),this.childComponents.push(e),!0)},c=(e,t)=>{var s,o,l;const c=[...null!==(s=t.left)&&void 0!==s?s:[],...null!==(o=t.center)&&void 0!==o?o:[],...null!==(l=t.right)&&void 0!==l?l:[]];for(const t of c){const s=Ye[t];if(void 0===s)continue;const o=Ke(t),l=e.querySelector(o);if(null===l)continue;const c=s();c.connect(l,n,r,i,a),this.childComponents.push(c)}};l(new be,".eb-top-bar-zone");const d=s.querySelector(".eb-top-bar-zone");null!==d&&void 0!==o.topBar&&c(d,o.topBar);if(l(new ye,".eb-bottom-bar-zone")&&void 0!==o.bottomBar){const e=s.querySelector(".eb-bottom-bar-zone");null!==e&&c(e,o.bottomBar)}if(i.middlebar){if(l(new Se,".eb-middle-bar-zone")&&void 0!==o.middleBar){const e=s.querySelector(".eb-middle-bar-zone");null!==e&&c(e,o.middleBar)}}const h=document.createElement("div");h.className="eb-loading-slot",s.appendChild(h);const v=new Xe;v.connect(h,n,r,i,a),this.childComponents.push(v);const g=[[new Je,"eb-error-slot"],[new it,"eb-socials-slot"],[new st,"eb-info-slot"],[new nt,"eb-toast-slot"],[new rt,"eb-preroll-slot"]];null!=i.subtitleStyle&&g.push([new tt,"eb-subtitle-slot"]);for(const[e,t]of g){const o=document.createElement("div");o.className=t,s.appendChild(o),e.connect(o,n,r,i,a),this.childComponents.push(e)}"forja"===i.skin&&l(new ot,".eb-extension-bottom-extra"),"snrt"===i.skin&&l(new at,".eb-extension-bottom-extra")}renderNoUiTemplate(){const e=this.config;return Z`
386
+ `}connectChildComponents(){var e,t;const i=this.config;if(i.noUi)return;const s=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==s)return;const n=this.state,r=this.bus,o=u(i),a=null!==(t=this.i18n)&&void 0!==t?t:void 0,l=(e,t)=>{const o=s.querySelector(t);return null!==o&&(e.connect(o,n,r,i,a),this.childComponents.push(e),!0)},c=(e,t)=>{var s,o,l;const c=[...null!==(s=t.left)&&void 0!==s?s:[],...null!==(o=t.center)&&void 0!==o?o:[],...null!==(l=t.right)&&void 0!==l?l:[]];for(const t of c){const s=nt[t];if(void 0===s)continue;const o=rt(t),l=e.querySelector(o);if(null===l)continue;const c=s();c.connect(l,n,r,i,a),this.childComponents.push(c)}};l(new xe,".eb-top-bar-zone");const d=s.querySelector(".eb-top-bar-zone");null!==d&&void 0!==o.topBar&&c(d,o.topBar);if(l(new Ae,".eb-bottom-bar-zone")&&void 0!==o.bottomBar){const e=s.querySelector(".eb-bottom-bar-zone");null!==e&&c(e,o.bottomBar)}if(i.middlebar){if(l(new De,".eb-middle-bar-zone")&&void 0!==o.middleBar){const e=s.querySelector(".eb-middle-bar-zone");null!==e&&c(e,o.middleBar)}}const h=document.createElement("div");h.className="eb-loading-slot",s.appendChild(h);const v=new ot;v.connect(h,n,r,i,a),this.childComponents.push(v);const g=[[new at,"eb-error-slot"],[new ut,"eb-socials-slot"],[new ht,"eb-info-slot"],[new vt,"eb-toast-slot"],[new gt,"eb-preroll-slot"]];null!=i.subtitleStyle&&g.push([new dt,"eb-subtitle-slot"]);for(const[e,t]of g){const o=document.createElement("div");o.className=t,s.appendChild(o),e.connect(o,n,r,i,a),this.childComponents.push(e)}"forja"===i.skin&&l(new pt,".eb-extension-bottom-extra"),"snrt"===i.skin&&l(new mt,".eb-extension-bottom-extra")}renderNoUiTemplate(){const e=this.config;return le`
387
387
  <div class="eb-player">
388
388
  <video
389
389
  class="eb-video"
@@ -392,4 +392,4 @@
392
392
  ?autoplay="${e.autoplay}"
393
393
  ></video>
394
394
  </div>
395
- `}bindElementRefs(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;this.videoElement=null!==t?t.querySelector("video.eb-video"):null,this.adsContainerElement=null!==t?t.querySelector(".eb-ads-container"):null;this.config.posterStream&&null!==t&&(this.posterVideoElement=t.querySelector(".eb-poster-video"))}subscribeToState(){const e=this.state,{signal:t}=this;e.on("isRtl",()=>{this.applyRtl()},{signal:t}),e.on("isIOS",()=>{this.updateIOSState()},{signal:t}),e.on("playbackState",()=>{this.updatePosterVisibility()},{signal:t}),e.on("currentTime",()=>{this.state.currentTime>0&&this.updatePosterVisibility()},{signal:t}),e.on("isRadio",()=>{this.updateRadioOverlay()},{signal:t}),e.on("controlsVisible",()=>{this.updateControlsVisibility()},{signal:t}),e.on("adPlaying",()=>{this.updateAdPlayingState()},{signal:t})}updatePosterVisibility(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==t)return;const i=t.querySelector(".eb-poster");if(null===i)return;const s=this.state.playbackState,n=this.state.currentTime>0,r=!1!==this.config.image&&("idle"===s||"loading"===s||"playing"===s&&!n);i.style.display=r?"":"none"}updateIOSState(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==t)return;const i=this.state.isIOS;t.classList.toggle("eb-ios-native",i);const s=t.querySelector("video.eb-video");null!==s&&(s.controls=i)}updateRadioOverlay(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==t)return;const i=t.querySelector(".eb-overlay-zone");if(null===i)return;const s=i.querySelector(".eb-radio-overlay"),n=this.state.isRadio;if(n&&null===s){const e=document.createElement("div");e.className="eb-radio-overlay";const t=document.createElement("div");t.className="eb-radio-bars";for(let e=0;e<5;e++){const e=document.createElement("span");e.className="eb-radio-bar",t.appendChild(e)}e.appendChild(t),i.appendChild(e)}else n||null===s||s.remove()}updateControlsVisibility(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==t)return;const i=this.state.controlsVisible;t.classList.toggle("eb-controls-visible",i),t.classList.toggle("eb-controls-hidden",!i)}updateAdPlayingState(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;null!=t&&t.classList.toggle("eb-ad-playing",this.state.adPlaying)}applyRtl(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;null!=t&&t.setAttribute("dir",this.state.isRtl?"rtl":"ltr")}invokeExtensions(){var e;const t=this.config.extensions;if(void 0===t)return;const i=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==i)return;const s={"top-extra":".eb-extension-top-extra","bottom-extra":".eb-extension-bottom-extra",overlay:".eb-extension-overlay","controls-extra":".eb-extension-controls-extra"};for(const[e,n]of Object.entries(t)){const t=s[e];if(void 0===t)continue;const r=i.querySelector(t);if(null===r)continue;const o=n(r,this.state,this.bus,this.signal);"function"==typeof o&&this.extensionCleanups.push(o)}}disconnect(){for(const e of this.childComponents)e.disconnect();this.childComponents=[];for(const e of this.extensionCleanups)e();this.extensionCleanups=[],this.videoElement=null,this.adsContainerElement=null,this.posterVideoElement=null,super.disconnect()}}class dt{constructor(e,t,i){this.timer=0,this.state=t,this.container=e,this.onActivity=()=>this.show(),e.addEventListener("pointermove",this.onActivity),e.addEventListener("touchstart",this.onActivity),e.addEventListener("keyup",this.onActivity),i.addEventListener("abort",()=>{this.container.removeEventListener("pointermove",this.onActivity),this.container.removeEventListener("touchstart",this.onActivity),this.container.removeEventListener("keyup",this.onActivity),clearTimeout(this.timer),this.timer=0},{once:!0}),this.show()}show(){this.state.controlsVisible=!0,clearTimeout(this.timer),this.timer=setTimeout(()=>{this.hide()},3e3)}hide(){this.state.settingsOpen||this.state.socialsOpen||this.state.infoOpen||this.state.adPlaying||this.state.introStreamPlaying||(this.state.controlsVisible=!1)}}class ut{constructor(e,t,i,s,n){e.tabIndex<0&&(e.tabIndex=0);const r=e=>{const n=e;if(!t.adPlaying&&!t.introStreamPlaying){if(" "===n.key)return n.preventDefault(),void("playing"===t.playbackState?i.emit("pause"):i.emit("play"));if("ArrowLeft"===n.key){const e=s.seekOffset||15,n=Math.max(t.currentTime-e,0);return void i.emit("seek",{time:n})}if("ArrowRight"===n.key){const e=s.seekOffset||15,n=Math.min(t.currentTime+e,t.duration);return void i.emit("seek",{time:n})}s.supportHotKeys&&("m"!==n.key||i.emit("mute-toggle"))}};e.addEventListener("keyup",r),n.addEventListener("abort",()=>{e.removeEventListener("keyup",r)},{once:!0})}}function ht(e){const t=window;if(void 0!==t[e])return t[e];try{return(0,eval)(e)}catch(e){return}}function vt(e,t,i={}){var s;const n=ht(t);if(void 0!==n)return Promise.resolve(n);const r=null!==(s=i.timeout)&&void 0!==s?s:1e4;return new Promise((i,s)=>{let n;const o=()=>{clearTimeout(n)},a=document.createElement("script");a.src=e,a.onload=()=>{o();const n=ht(t);void 0===n?s(new Error(`CDN: '${t}' not on window after loading ${e}`)):i(n)},a.onerror=()=>{o(),s(new Error(`CDN: failed to load ${e}`))},n=setTimeout(()=>{s(new Error(`CDN: timeout loading ${e}`))},r),document.head.appendChild(a)})}let gt=null;class pt{constructor(e){this.localDriver=null,this.signal=e.signal}async init(e,t,i){var s;if(!e.chromecast)return;const n=await vt(e.chromecast,"Castjs");null===gt&&(gt=new n({receiver:null!==(s=e.chromecastApp)&&void 0!==s?s:"00197684"})),this.localDriver=gt,this.applyMetadata(e.chromecastMetadata),this.bindDriverEvents(t,i),this.registerAbortCleanup()}getDriver(){return this.localDriver}toggleCast(e){var t;const i=this.localDriver;if(null!==i)if(i.connected)i.disconnect();else if(e.castAvailable){const s=this.buildCastOptions(e);i.cast(null!==(t=e.src)&&void 0!==t?t:"",s)}}applyMetadata(e){if(void 0===e||null===this.localDriver)return;const t=this.localDriver;void 0!==e.title&&(t.title=e.title),void 0!==e.description&&(t.description=e.description),void 0!==e.poster&&(t.poster=e.poster)}bindDriverEvents(e,t){const i=this.localDriver;i.on("available",()=>{e.castAvailable=!0}),i.on("connect",()=>{e.isCasting=!0}),i.on("disconnect",()=>{const s=i.time;e.isCasting=!1,void 0!==s&&s>0?t.emit("cast-stop-with-position",{time:s}):t.emit("cast-stop")}),i.on("error",()=>{e.isCasting=!1,t.emit("cast-failed")})}buildCastOptions(e){const t=this.localDriver;return{title:null==t?void 0:t.title,description:null==t?void 0:t.description,poster:e.image}}registerAbortCleanup(){this.signal.addEventListener("abort",()=>{const e=this.localDriver;null!==e&&e.connected&&e.disconnect(),this.localDriver=null},{once:!0})}}const mt=["token","expires","token_path","hdnea","hdntl"];function ft(e){try{const t=new URL(e);for(const e of mt)t.searchParams.delete(e);return t.toString()}catch(t){return e}}function bt(e){const t=e.data;return void 0!==t&&"string"==typeof t.url&&(t.url=ft(t.url)),e}function yt(e){const t=e.request;return void 0!==t&&"string"==typeof t.url&&(t.url=ft(t.url)),e}let kt=null,Et=null;async function Tt(e,t,i){const s=async()=>void 0===i?fetch(t):fetch(t,i),n=kt;return null===n?s():n.startSpan({name:e,op:"http.client"},async t=>{try{const i=await s();return t.setAttribute("http.response_status_code",i.status),i.status>=400&&n.captureMessage(`${e}: HTTP ${i.status}`,"warning"),i}catch(t){throw n.captureException(t,{tags:{network:e}}),t}})}class wt{constructor(){this.pollTimer=null}async start(e,t,i){if(void 0!==e.epgContentId&&(await this.fetchEpg(e,t),null!==e.epgPolling&&void 0!==e.epgPolling)){const s=1e3*e.epgPolling;this.pollTimer=setInterval(()=>{this.fetchEpg(e,t)},s),i.addEventListener("abort",()=>{clearInterval(this.pollTimer),this.pollTimer=null},{once:!0})}}async fetchEpg(e,t){const i=`https://epg.dev.easybroadcast.io/channels/${e.epgContentId}/last-24-h-programs`;try{const e=await Tt("epg:fetch",i,{mode:"cors"});if(!e.ok)throw new Error(`EPG fetch failed with status: ${e.status}`);const s=await e.json();t.epgPrograms=s,t.epgFetchedAt=Date.now()}catch(e){console.error("EBPlayer: Error fetching EPG data:",e)}}}class Ct{init(e,t,i,s){const n=e.playlist;n&&0!==n.length&&(t.playlist=n,t.currentEpisode=0,i.on("playlist-next",()=>{this.advance(t,1)},{signal:s}),i.on("playlist-prev",()=>{this.advance(t,-1)},{signal:s}))}advance(e,t){const i=e.playlist.length,s=(e.currentEpisode+t+i)%i;e.currentEpisode=s,e.src=e.playlist[s].src}}class Lt{constructor(){this.imaAdsManager=null,this.imaDisplayContainer=null}async init(e,t,i,s,n,r){if(!e.ad)return;let o=null,a=null,l=!1;const c=new AbortController;r.addEventListener("abort",()=>c.abort(),{once:!0});const d=()=>{null!==o&&(clearTimeout(o),o=null)},u=()=>{null!==a&&(clearTimeout(a),a=null)},h=()=>{l||(l=!0,d(),u(),null===this.imaAdsManager&&this.releaseImaResources(),t.adPlaying=!1,i.emit("ad-complete"),c.abort())};r.addEventListener("abort",()=>{d(),u(),this.releaseImaResources()},{once:!0});const v=e.autoplay?null:this.waitForUserGesture(s,c.signal);if(!(e.preroll&&(await new Promise(e=>{const t=()=>{d(),e()};i.on("intro-stream-complete",t,{signal:r}),r.addEventListener("abort",t,{once:!0}),o=setTimeout(()=>{console.warn("AdsManager: intro-stream-complete never arrived within the bound — falling through to the ad leg (G-07-9)"),t()},12e4)}),r.aborted)||(a=setTimeout(()=>{console.warn("AdsManager: ad leg produced no AdsManager within the bound — falling through to main (G-07-11)"),h()},2e4),null!==v&&await v,r.aborted||l)))try{const i=await vt("https://imasdk.googleapis.com/js/sdkloader/ima3.js","google");if(l)return;const{ima:r}=i,o=new r.AdDisplayContainer(n,s);this.imaDisplayContainer=o,o.initialize();const a=new r.AdsLoader(o);a.addEventListener(r.AdErrorEvent.Type.AD_ERROR,e=>{console.warn("AdsManager: AD_ERROR (loader) — falling through to main",e),h()}),a.addEventListener(r.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>{if(l)return;const i=e.getAdsManager(s);this.imaAdsManager=i,u();const n=s.getBoundingClientRect(),o=n.width>0?n.width:640,a=n.height>0?n.height:360;i.addEventListener(r.AdEvent.Type.CONTENT_PAUSE_REQUESTED,()=>{console.log("AdsManager: CONTENT_PAUSE_REQUESTED — content paused (D-08-08)"),t.adPlaying=!0,s.pause()}),i.addEventListener(r.AdEvent.Type.CONTENT_RESUME_REQUESTED,()=>{console.log("AdsManager: CONTENT_RESUME_REQUESTED — content resumed (D-08-08)"),t.adPlaying=!1,$(s),h()}),i.addEventListener(r.AdEvent.Type.ALL_ADS_COMPLETED,()=>{console.log("AdsManager: ALL_ADS_COMPLETED — ad leg complete (D-08-08)"),h()}),i.addEventListener(r.AdErrorEvent.Type.AD_ERROR,e=>{console.warn("AdsManager: AD_ERROR (manager) — falling through to main",e),h()}),i.addEventListener(r.AdEvent.Type.SKIPPABLE_STATE_CHANGED,()=>{console.log("AdsManager: ad became skippable (D-08-06)")}),i.init(o,a),i.start()});const c=new r.AdsRequest;c.adTagUrl=e.ad,a.requestAds(c)}catch(e){console.warn("AdsManager: failed to load or initialize the IMA SDK — falling through to main (G-07-11)",e),h()}}releaseImaResources(){null!==this.imaAdsManager&&(this.imaAdsManager.destroy(),this.imaAdsManager=null),null!==this.imaDisplayContainer&&(this.imaDisplayContainer.destroy(),this.imaDisplayContainer=null)}waitForUserGesture(e,t){return new Promise(i=>{var s;const n=null!==(s=e.closest(".eb-player"))&&void 0!==s?s:e;let r=!1;const o=()=>{r||(r=!0,n.removeEventListener("click",a,{capture:!0}),i())},a=()=>o();n.addEventListener("click",a,{capture:!0}),t.addEventListener("abort",o,{once:!0})})}}class St{async init(e,t,i,s,n){if(!e.preroll)return;t.introStreamPlaying=!0;const r=new AbortController;n.addEventListener("abort",()=>r.abort(),{once:!0});let o=0,a=!1;const l=()=>{a||(a=!0,clearTimeout(o),t.introStreamPlaying=!1,i.emit("intro-stream-complete"),r.abort())},c=()=>l();s.addEventListener("ended",c),i.on("preroll-skip",l,{signal:r.signal}),i.on("error-fatal",()=>{console.warn("IntroStreamManager: intro stream errored — falling through to main"),l()},{signal:r.signal}),t.on("error",e=>{null!==e&&(console.warn("IntroStreamManager: intro stream errored via state.error — falling through to main"),l())},{signal:r.signal}),i.on("force-intro-complete",()=>{console.warn("IntroStreamManager: main is opening — force-completing the intro pass"),l()},{signal:r.signal}),o=setTimeout(()=>{console.warn("IntroStreamManager: intro stream exceeded INTRO_MAX_DURATION_MS — falling through to main"),l()},9e4),n.addEventListener("abort",()=>{s.removeEventListener("ended",c),clearTimeout(o)},{once:!0})}}var xt,At={exports:{}};var $t=(xt||(xt=1,function(e){var t,i,s,n,r=(t={fromVtt:function(e,t,s){var n=!!s;(e=(e=e.replace(/\r/g,"")).split(/(\d+)?\n?(\d{2}:\d{2}:\d{2}[,.]\d{3}) --> (\d{2}:\d{2}:\d{2}[,.]\d{3}).*\n/g)).shift();for(var r=[],o=0;o<e.length;o+=4){var a=e[o+3];n&&((a=a.split("\n")).shift(),a=a.join("\n")),0!==a.trim().length&&r.push({id:e[o]?+e[o].trim():r.length+1,startTime:i(e[o+1].trim(),t),endTime:i(e[o+2].trim(),t),text:a.trim()})}return r},toVtt:function(e){if(!e instanceof Array)return"";for(var t="",i=0;i<e.length;i++){var s=e[i];isNaN(s.startTime)||isNaN(s.endTime)||(s.startTime=n(parseInt(s.startTime,10)),s.endTime=n(parseInt(s.endTime,10))),t+=s.id+"\r\n",t+=s.startTime+" --\x3e "+s.endTime+"\r\n",t+=s.text.replace("\n","\r\n")+"\r\n\r\n"}return t}},i=function(e,t){return"ms"===t?s(e):"s"===t?s(e)/1e3:e},s=function(e){var t=/(\d+):(\d{2}):(\d{2})[,.](\d{3})/.exec(e);if(null===t)return 0;for(var i=1;i<5;i++)t[i]=parseInt(t[i],10),isNaN(t[i])&&(t[i]=0);return 36e5*t[1]+6e4*t[2]+1e3*t[3]+t[4]},n=function(e){var t=[36e5,6e4,1e3],i=[];for(var s in t){var n=(e/t[s]|0).toString();n.length<2&&(n="0"+n),e%=t[s],i.push(n)}var r=e.toString();if(r.length<3)for(s=0;s<=3-r.length;s++)r="0"+r;return i.join(":")+","+r},t);e.exports=r}(At)),At.exports);function _t(e){if(!e||!e.trim())return[];return $t.fromVtt(e,"s").map(e=>({title:e.text,startTime:e.startTime,endTime:e.endTime}))}class Mt{get signal(){return this.abortController.signal}get container(){return this._container}constructor(e){this.hasExplicitPrimaryColor=void 0!==e.primaryColor,this.config=p(h,e),this.state=r(),this.bus=new o,this.i18n=new y(this.config.lang),this.config.messages&&this.i18n.addMessages(this.config.messages),this.abortController=new AbortController,this._container=null,this.engineSync=null,this.skinRoot=null,this.commandHandler=null,this.chromecastManager=null,this.reloadCallback=null}mount(e){var t,i,s;this._container=e,e.textContent="",delete e._$litPart$,e.removeAttribute("data-theme"),e.removeAttribute("style"),this.config.skin&&"default"!==this.config.skin&&e.setAttribute("data-theme",this.config.skin);const n=this.config.skinColors;this.hasExplicitPrimaryColor&&this.config.primaryColor&&(e.style.setProperty("--eb-color-primary",this.config.primaryColor),e.style.setProperty("--eb-color-progress",this.config.primaryColor),e.style.setProperty("--eb-accent",this.config.primaryColor)),(null==n?void 0:n.general)&&(e.style.setProperty("--eb-color-primary",n.general),e.style.setProperty("--eb-color-progress",n.general),e.style.setProperty("--eb-accent",n.general)),(null==n?void 0:n.progressBar)&&e.style.setProperty("--eb-color-progress",n.progressBar),(null==n?void 0:n.volumeBar)&&e.style.setProperty("--eb-color-volume",n.volumeBar),this.state.isRtl=null!==(t=this.config.rtl)&&void 0!==t?t:"ar"===this.config.lang,this.state.isRadio=!0===this.config.radio;const r=new ct;this.skinRoot=r,r.connect(e,this.state,this.bus,this.config,this.i18n);const o=r.getVideoElement();null!==o&&(this.state.muted=o.muted,this.state.volume=o.volume),this.config.noUi||(new dt(e,this.state,this.signal),new ut(e,this.state,this.bus,this.config,this.signal)),this.initIntegrations();const a=null!==(s=null===(i=this.skinRoot)||void 0===i?void 0:i.getVideoElement())&&void 0!==s?s:null;null!==a&&(this.commandHandler=new _(this.bus,a,this.state,()=>this.engineSync,this.chromecastManager,this.i18n,()=>{var e;null===(e=this.reloadCallback)||void 0===e||e.call(this)},this.signal))}setReloadCallback(e){this.reloadCallback=e}getSavedSelections(){return null!==this.commandHandler?this.commandHandler.getSavedSelections():{quality:-1,audioTrack:0,subtitleTrack:-1}}setEngineSync(e){null!==this.engineSync&&this.engineSync.detach(),this.engineSync=e,e.attach(this.state,this.signal)}dispose(){null!==this.engineSync&&(this.engineSync.detach(),this.engineSync=null),this.bus.dispose(),this.abortController.abort(),null!==this.skinRoot&&(this.skinRoot.disconnect(),this.skinRoot=null),this._container=null,this.commandHandler=null,this.chromecastManager=null,this.reloadCallback=null,this.abortController=new AbortController}loadChapters(e,t,i){/^https?:\/\//i.test(e.trim())?async function(e){try{const t=await Tt("chapters:fetch",e);return _t(await t.text())}catch(e){return[]}}(e).then(e=>{i.aborted||(t.chapters=e)}):t.chapters=_t(e)}initIntegrations(){var e,t;const{config:i,state:s,bus:n,signal:r}=this;if(i.chromecast){const e=new pt(this.abortController);this.chromecastManager=e,e.init(i,s,n).catch(e=>{console.error("EBPlayer: ChromecastManager init failed:",e)})}if(i.epgContentId){(new wt).start(i,s,r).catch(e=>{console.error("EBPlayer: EpgManager start failed:",e)})}const o=i.playlist;if(o&&o.length>0){(new Ct).init(i,s,n,r)}if(i.ad&&null!==this.skinRoot){const e=this.skinRoot.getVideoElement(),t=this.skinRoot.getAdsContainer();if(null!==e&&null!==t){(new Lt).init(i,s,n,e,t,r).catch(e=>{console.error("EBPlayer: AdsManager init failed:",e)})}}if(i.chapters&&this.loadChapters(i.chapters,s,r),i.preroll&&null!==this.skinRoot){const e=new St,t=this.skinRoot.getVideoElement();null!==t&&e.init(i,s,n,t,r).catch(e=>{console.error("EBPlayer: IntroStreamManager init failed:",e)})}if(i.posterStream){const n=function(){let e=null;return{attach({src:t,container:i,Hls:s}){console.log("Poster HLS: attach media",t,i),e=new s,e.loadSource(t),e.attachMedia(i)},close(){var t,i;if(e){try{null===(t=e.detachMedia)||void 0===t||t.call(e),null===(i=e.destroy)||void 0===i||i.call(e)}catch(e){console.error("Poster HLS player close error:",e)}e=null}},play(){(null==e?void 0:e.media)&&$(e.media)},pause(){var t;null===(t=null==e?void 0:e.media)||void 0===t||t.pause()}}}(),o=null!==(t=null===(e=this.skinRoot)||void 0===e?void 0:e.getPosterVideoElement())&&void 0!==t?t:null;s.on("playbackState",e=>{if("playing"===e){if(null!==o){const e=window.Hls;e&&n.attach({src:i.posterStream,container:o,Hls:e})}n.play()}else"paused"!==e&&"buffering"!==e||n.pause()},{signal:r}),r.addEventListener("abort",()=>{n.close()},{once:!0})}}}class Pt{}"function"==typeof SuppressedError&&SuppressedError;class Rt{constructor(e){this.intervalId=null,this.lastTime=null,this.stallAttempts=0,this.video=e.video,this.onRecoverAttempt=e.onRecoverAttempt,this.onReloadRequired=e.onReloadRequired,this.isCasting=e.isCasting}start(){this.stop(),this.intervalId=setInterval(()=>{this.tick()},1e4)}stop(){null!==this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.lastTime=null,this.stallAttempts=0}tick(){if(this.video.paused||this.video.seeking||this.video.readyState<3||this.isCasting())return this.lastTime=null,void(this.stallAttempts=0);const e=this.video.currentTime;null!==this.lastTime&&e===this.lastTime?(this.stallAttempts+=1,this.stallAttempts<=2?this.onRecoverAttempt(this.stallAttempts):(this.onReloadRequired(),this.stop())):(this.stallAttempts=0,this.lastTime=e)}}class Bt extends Pt{constructor(){super(),this.video=null,this.state=null,this.signal=null,this.bus=null,this.config=null,this.loadSourceUrl="",this.watchdog=null,this.videoListeners=[],this.driverReady=new Promise(e=>{this.resolveDriverReady=e})}attach(e,t){this.state=e,this.signal=t,this.onAttach()}detach(){var e;null===(e=this.watchdog)||void 0===e||e.stop(),this.watchdog=null,this.unbindVideoEvents(),this.onDetach(),this.video=null,this.state=null,this.signal=null,this.bus=null,this.config=null,this.loadSourceUrl=""}startWatchdog(){if(!this.video||!this.bus)return;const e=this.bus;this.watchdog=new Rt({video:this.video,onRecoverAttempt:e=>{this.recoverFromStall(e)},onReloadRequired:()=>{e.emit("request-reload")},isCasting:()=>{var e,t;return null!==(t=null===(e=this.state)||void 0===e?void 0:e.isCasting)&&void 0!==t&&t}}),this.watchdog.start()}stopWatchdog(){var e;null===(e=this.watchdog)||void 0===e||e.stop(),this.watchdog=null}setConfig(e){this.config=e}setBus(e){this.bus=e}setVideo(e){this.video=e}setLoadSource(e){this.loadSourceUrl=e}bindVideoEvents(e,t,i){var s,n;const r=(t,i,s)=>{e.addEventListener(t,i,s),this.videoListeners.push({video:e,type:t,listener:i})},o=null!==(n=null===(s=this.config)||void 0===s?void 0:s.syncLiveMargin)&&void 0!==n?n:30;r("timeupdate",()=>{t.currentTime=Math.round(e.currentTime),t.isLive&&(t.isSyncWithLive=e.currentTime+o>e.duration)},{signal:i}),r("durationchange",()=>{t.duration=Math.ceil(e.duration)},{signal:i}),r("volumechange",()=>{t.volume=e.volume,t.muted=e.muted},{signal:i}),r("progress",()=>{e.buffered.length>0&&(t.bufferedEnd=e.buffered.end(e.buffered.length-1))},{signal:i}),r("ratechange",()=>{t.playbackRate=e.playbackRate},{signal:i});let a=!1;r("playing",()=>{a=!1,t.playbackState="playing"},{signal:i}),r("waiting",()=>{t.playbackState="buffering"},{signal:i}),r("pause",()=>{e.seeking||("buffering"!==t.playbackState||e.ended?t.playbackState="paused":a=!0)},{signal:i}),r("seeked",()=>{t.isLive&&(t.currentTime=Math.round(e.currentTime),t.isSyncWithLive=e.currentTime+o>e.duration),(a||"loading"===t.playbackState)&&e.paused&&(t.playbackState="paused",a=!1)},{signal:i}),r("ended",()=>{t.playbackState="ended"},{signal:i}),r("timeupdate",()=>{("buffering"===t.playbackState||"loading"===t.playbackState)&&!e.paused&&(t.playbackState="playing")},{signal:i})}unbindVideoEvents(){for(const{video:e,type:t,listener:i}of this.videoListeners)e.removeEventListener(t,i);this.videoListeners=[]}seek(e){null!==this.video&&(this.video.currentTime=e)}}const Dt=Object.freeze({EASY_B:"easy_b",BUNNY:"bunny",AKAMAI:"akamai",VENOM:"venom"}),Ft=Object.freeze({UNKNOWN:"unknown",MAX_RETRY:"max_retry",FORBIDDEN:"forbidden"});class Ot extends Error{constructor({status:e="unknown",errorCode:t="unknown",errorType:i=Ft.UNKNOWN,message:s=null}){super(null!=s?s:`TokenError: ${e} - ${t}`),this.status=e,this.errorCode=t,this.errorType=i}}class Vt{constructor({src:e,responseParameters:t,error:i=null,extras:s={}}){if(this.src=e,this.responseParameters=t,this.extras=null!=s?s:{},null!==i&&!(i instanceof Ot))throw new Error("TokenResponse error must be an instance of TokenError");this.error=i}static fromJson({src:e,json:t}){var i,s,n;const r=JSON.parse(t),o={token:null!==(i=r.token)&&void 0!==i?i:null,tokenPath:null!==(s=r.token_path)&&void 0!==s?s:null,expires:null!==(n=r.expires)&&void 0!==n?n:null},a=new Vt({src:e,responseParameters:o});for(const e of Object.keys(r))["token","expires","token_path"].includes(e)||(a.extras[e]=r[e]);return a}static fromAkamai({src:e,text:t}){const i=Nt({src:e,text:t});return new Vt({src:e,responseParameters:i})}static fromText({src:e,text:t}){var i,s;if(t.trim().startsWith("{"))return Vt.fromJson({src:e,json:t});const n=Ht(t);if(n){const t=Object.assign({token:null,tokenPath:null},n);return new Vt({src:e,responseParameters:t})}const r=new URLSearchParams(t.trim().replace(/^\?/,"")),o=null!==(i=r.get("token"))&&void 0!==i?i:null,a=r.get("expires"),l=a?parseInt(a,10):null,c=null!==(s=r.get("token_path"))&&void 0!==s?s:null,d=new Vt({src:e,responseParameters:{token:o,tokenPath:c,expires:l}});return r.forEach((e,t)=>{["token","expires","token_path"].includes(t)||(d.extras[t]=e)}),d}static fromDefault({src:e,text:t}){var i;const s=new URLSearchParams(t.trim().replace(/^\?/,"")),n=s.get("expires"),r={verify:null!==(i=s.get("verify"))&&void 0!==i?i:null,expires:n?parseInt(n,10):null},o=new Vt({src:e,responseParameters:r});return s.forEach((e,t)=>{["verify","expires"].includes(t)||(o.extras[t]=e)}),o}static fromError({src:e,error:t}){const i=t instanceof Ot?t:new Ot(t);return new Vt({src:e,error:i})}}function Nt({src:e,text:t}){var i,s;const n=null!==(s=null===(i=Ht(t))||void 0===i?void 0:i.fullUrl)&&void 0!==s?s:null,r=new URL(null!=n?n:`${e}${t?`?${t}`:""}`);let o=null,a=null,l=null,c=null,d=null;const u=new URLSearchParams(r.search);if(o=u.get("hdntl"),d=u.get("hdnea"),!o&&!d){const e=r.pathname.split("/");for(const t of e){if(t.startsWith("hdntl=")){o=t.substring(6);break}if(t.startsWith("hdnea=")){d=t.substring(6);break}}}const h=null!=o?o:d;if(h){const e=h.match(/exp=(\d+)/);e&&(a=e[1]);const t=h.match(/hmac=([a-f0-9]+)/);t&&(l=t[1]);const i=h.match(/acl=([^~]+)/);i&&(c=i[1])}return{expires:a,hdntl:h,hmac:l,acl:c,hdnea:d,fullUrl:n}}const It=/^https?:\/\//i;function Ht(e){const t=e.trim();if(!It.test(t))return null;const i=new URL(t).searchParams.get("expires");return i?{fullUrl:t,expires:parseInt(i,10)}:{fullUrl:t,expires:Nt({src:t,text:""}).expires}}function jt(e){var t;const i=null==e?void 0:e.responseParameters;return i&&"fullUrl"in i&&null!==(t=i.fullUrl)&&void 0!==t?t:null}function Ut(e){const t=null==e?void 0:e.responseParameters,i=jt(e);if(!e||!t||!i)return null;const s=new URL(e.src),n=new URL(i);if(!n.pathname.endsWith(s.pathname))return null;const r=n.pathname.slice(0,n.pathname.length-s.pathname.length);return{fullUrl:i,originalBase:s.origin,rewrittenBase:n.origin+r,search:n.search,expires:t.expires}}function zt(e,t){if(!e.startsWith(`${t.rewrittenBase}/`))return null;const i=new URL(t.originalBase+e.slice(t.rewrittenBase.length));return i.searchParams.delete("hdnea"),i.searchParams.delete("hdntl"),i.toString()}function qt(e,t){var i;const s=new URL(null!==(i=zt(e,t))&&void 0!==i?i:e);if(s.origin!==t.originalBase)return null;s.searchParams.delete("hdnea"),s.searchParams.delete("hdntl");const n=s.search,r=n?`${n}&${t.search.slice(1)}`:t.search;return`${t.rewrittenBase}${s.pathname}${r}`}function Wt(e){return new Promise(t=>{setTimeout(t,e)})}class Gt{constructor({token:e,tokenType:t,srcInTokenRequest:i=!1,extraParamsCallback:s=null,onCDNTokenError:n,maxRetries:r=3,retryInterval:o=1e4,expirationMarginInSeconds:a=30}){const l=Object.values(Dt);void 0!==t&&l.includes(t)?this.tokenType=t:this.tokenType=void 0,this.tokenGeneratorUrl=e,this.srcInTokenRequest=i,this.extraParamsCallback=s&&"function"==typeof s?s:null,this.callbackError=n&&"function"==typeof n?n:null,this.attempt=0,this.maxRetries=r,this.retryInterval=o,this.expirationMarginInSeconds=a,this.lastTokenResponse=null,this.sourceUrl=null,this.resetAttemptCounterTimeout=null,this.inFlightFetch=null,this.cdnRejectionCount=0,this.forceRefreshOnce=!1}resetAttemptCounter(){this.resetAttemptCounterTimeout||(this.resetAttemptCounterTimeout=setTimeout(()=>{this.attempt=0},3e4))}async _fetchDefaultToken(e,t=null){const i=new URL(e);if(["verify","expires"].forEach(e=>i.searchParams.delete(e)),this.attempt>=this.maxRetries)return this.resetAttemptCounter(),Vt.fromError({src:i.toString(),error:new Ot({status:null==t?void 0:t.status,errorCode:"Unauthorized",errorType:Ft.MAX_RETRY})});try{let t;if(this.attempt+=1,t=!0===this.srcInTokenRequest?await Tt("cdn-token:default",`${this.tokenGeneratorUrl}?url=${encodeURIComponent(i.toString())}`):await Tt("cdn-token:default",this.tokenGeneratorUrl),403===t.status)return await Wt(this.retryInterval),this._fetchDefaultToken(e,t);if(t.status>=400)return Vt.fromError({src:i.toString(),error:new Ot({status:t.status})});this.attempt=0;const s=await t.text();return Vt.fromDefault({src:i.toString(),text:s})}catch(e){return console.error("CDNToken: Error fetching default token ",e),Vt.fromError({src:i.toString(),error:e})}}async _fetchEasyBToken(e,t=null){var i,s,n,r;if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),Vt.fromError({src:e,error:new Ot({status:null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.status,errorCode:null!==(n=null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorCode)&&void 0!==n?n:"Unauthorized",errorType:Ft.MAX_RETRY})});try{this.attempt+=1;const i={};if(this.extraParamsCallback){const e=await this.extraParamsCallback(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.status);(null==e?void 0:e.accessToken)&&(i.Authorization=`Bearer ${String(e.accessToken)}`)}else console.warn("CDNToken: no extraParamsCallback provided");let s;if(s=!0===this.srcInTokenRequest?await Tt("cdn-token:easy_b",`${this.tokenGeneratorUrl}?url=${encodeURIComponent(e)}`,{method:"GET",headers:i}):await Tt("cdn-token:easy_b",this.tokenGeneratorUrl,{method:"POST",headers:i,body:JSON.stringify({streamUrl:e})}),s.status>=400){const t=Vt.fromError({src:e,error:new Ot({status:s.status})});return 403===s.status?(await Wt(this.retryInterval),this._fetchEasyBToken(e,t)):t}this.attempt=0;const n=await s.text();return Vt.fromText({src:e,text:n})}catch(t){return console.error("CDNToken: Error fetching token ",t),Vt.fromError({src:e,error:t})}}async _fetchAkamaiToken(e,t=null){if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),Vt.fromError({src:e,error:new Ot({status:null==t?void 0:t.status,errorCode:"Unauthorized",errorType:Ft.MAX_RETRY})});try{this.attempt+=1;const t=await Tt("cdn-token:akamai",`${this.tokenGeneratorUrl}?url=${encodeURIComponent(e)}`);if(403===t.status)return await Wt(this.retryInterval),this._fetchAkamaiToken(e,t);if(t.status>=400)return Vt.fromError({src:e,error:new Ot({status:t.status})});this.attempt=0;const i=await t.text();return Vt.fromAkamai({src:e,text:i})}catch(t){return console.error("CDNToken: Error fetching token ",t),Vt.fromError({src:e,error:t})}}async _fetchBunnyToken(e,t=null){var i,s,n,r,o,a,l,c;if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),Vt.fromError({src:e,error:new Ot({status:null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.status,errorCode:null!==(n=null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorCode)&&void 0!==n?n:"Unauthorized",errorType:Ft.MAX_RETRY})});try{this.attempt+=1;const i={"Content-Type":"application/json"};if(this.extraParamsCallback){const e=await this.extraParamsCallback(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.status);(null==e?void 0:e.accessToken)&&(i.Authorization=`Bearer ${String(e.accessToken)}`)}else console.warn("CDNToken: no extraParamsCallback provided");const s=await Tt("cdn-token:bunny",this.tokenGeneratorUrl,{method:"POST",headers:i,body:JSON.stringify({streamUrl:e})});if(s.status>=400){const t=s.headers.get("content-type"),i=(null==t?void 0:t.includes("application/json"))?await s.json():await s.text(),n="object"==typeof i&&null!==i&&null!==(a=null===(o=i.error)||void 0===o?void 0:o.errorCode)&&void 0!==a?a:"Unauthorized",r="object"==typeof i&&null!==i&&null!==(c=null===(l=i.error)||void 0===l?void 0:l.__type)&&void 0!==c?c:Ft.UNKNOWN,d=new Ot({status:s.status,errorCode:n,errorType:r}),u=Vt.fromError({src:e,error:d});return[403,401,498].includes(s.status)?(this.callbackError?this.callbackError({status:d.status,errorCode:d.errorCode,errorType:d.errorType}):console.warn(`CDNToken: Bunny token fetch attempt ${this.attempt} for ${e} failed with status ${s.status}, retrying in ${this.retryInterval/1e3}s`),await Wt(this.retryInterval),this._fetchBunnyToken(e,u)):(console.error(`CDNToken: error generating Bunny token on attempt ${this.attempt}`,JSON.stringify(u)),u)}const n=await s.json();return this.attempt=0,Number.isInteger(n.max_retries)&&n.max_retries>0&&(this.maxRetries=n.max_retries),Number.isInteger(n.retry_interval)&&n.retry_interval>0&&(this.retryInterval=1e3*n.retry_interval),Vt.fromJson({src:e,json:JSON.stringify(n)})}catch(t){return console.error("CDNToken: Error fetching bunny token:",t),Vt.fromError({src:e,error:t})}}async fetchToken({src:e}){if(!e)return console.warn("CDNToken: Missing src to tokenize"),null;if(this.inFlightFetch)return this.inFlightFetch;return this.inFlightFetch=(async()=>{switch(this.tokenType){case Dt.BUNNY:return this._fetchBunnyToken(e);case Dt.AKAMAI:return this._fetchAkamaiToken(e);case Dt.VENOM:case Dt.EASY_B:return this._fetchEasyBToken(e);default:return this._fetchDefaultToken(e)}})().then(e=>(this.lastTokenResponse=e,this.inFlightFetch=null,e)).catch(e=>{throw this.inFlightFetch=null,e}),this.inFlightFetch}async updateUrlWithTokenParams({url:e}){var t,i,s,n;const r=new URL(e),o=r.searchParams.get("expires"),a=this.forceRefreshOnce;switch(a&&(this.forceRefreshOnce=!1),this.tokenType){case Dt.AKAMAI:{const t=Nt({src:e,text:""});if(!a&&!this.isTokenExpired(t.expires))return e;const i=Ut(this.lastTokenResponse),s=i&&!this.isTokenExpired(i.expires)?qt(e,i):null;if(s)return s;const n=r.pathname.split("/");r.pathname=n.filter(e=>!e.startsWith("hdntl=")&&!e.startsWith("hdnea=")).join("/"),r.searchParams.delete("hdnea"),r.searchParams.delete("hdntl");break}case Dt.EASY_B:case Dt.VENOM:case Dt.BUNNY:{if(!a&&!this.isTokenExpired(o))return e;["token","expires","token_path"].forEach(e=>r.searchParams.delete(e));const i=this.lastTokenResponse;if(i){const s=i.responseParameters;if(s&&!this.isTokenExpired(s.expires)){const n=Ut(i);if(n)return null!==(t=qt(e,n))&&void 0!==t?t:e;const{token:r,expires:o,tokenPath:a}=s;return Gt.appendTokenParams(e,r,o,a)}}break}default:if(!a&&!this.isTokenExpired(o))return e}const l=this.tokenType===Dt.EASY_B||this.tokenType===Dt.VENOM||this.tokenType===Dt.BUNNY,c=Ut(this.lastTokenResponse),d=null!==(i=c&&zt(r.toString(),c))&&void 0!==i?i:r.toString(),u=l&&this.sourceUrl?this.sourceUrl:d;try{const t=await this.fetchToken({src:u});if(null===t)return e;if(t.error)return this.callbackError&&this.callbackError({status:t.error.status,errorCode:t.error.errorCode,errorType:t.error.errorType}),e;const i=jt(t);if(i){if(t.src===d)return i;const e=Ut(t),s=e?qt(d,e):null;if(s)return s}switch(this.tokenType){case Dt.BUNNY:case Dt.VENOM:case Dt.EASY_B:{const i=t.responseParameters;return Gt.appendTokenParams(e,i.token,i.expires,i.tokenPath)}case Dt.AKAMAI:{const i=t.responseParameters;return Gt.appendAkamaiTokenParams(e,null!==(n=null!==(s=i.hdntl)&&void 0!==s?s:i.hdnea)&&void 0!==n?n:"")}default:return Gt.appendDefaultTokenParams(e,t)}}catch(t){return console.error("CDNToken: Error while fetching new token:",t),e}}isTokenExpired(e){if(null==e)return!0;const t=Math.floor(Date.now()/1e3)+this.expirationMarginInSeconds;return Number(e)<t}notifyCdnRejection(){return!(this.cdnRejectionCount>=this.maxRetries)&&(this.cdnRejectionCount+=1,this.forceRefreshOnce=!0,this.lastTokenResponse=null,!0)}resetCdnRejectionCount(){this.cdnRejectionCount=0}destroy(){this.resetAttemptCounterTimeout&&(clearTimeout(this.resetAttemptCounterTimeout),this.resetAttemptCounterTimeout=null),this.attempt=0,this.lastTokenResponse=null,this.inFlightFetch=null,console.log("CDNTokenManager: destroyed")}static appendTokenParams(e,t,i,s){const n=new URL(e);return t&&(n.searchParams.set("token",t),null!==i&&n.searchParams.set("expires",String(i)),s&&n.searchParams.set("token_path",s)),n.toString()}static appendAkamaiTokenParams(e,t){const i=new URL(e);return i.searchParams.delete("hdnea"),i.searchParams.delete("hdntl"),i.searchParams.set("hdnea",t),i.toString()}static appendDefaultTokenParams(e,t){const i=new URL(e),s=t.responseParameters;return(null==s?void 0:s.verify)&&i.searchParams.set("verify",s.verify),null!==(null==s?void 0:s.expires)&&void 0!==(null==s?void 0:s.expires)&&i.searchParams.set("expires",String(s.expires)),i.toString()}}function Qt(e){const t={};for(const i of Object.keys(e)){const s=Object.assign({},e[i]);!s.serverURL&&s.licenseUrl&&(s.serverURL=s.licenseUrl),t[i]=s}return t}class Yt{constructor(e){this.tokenManager=e}buildHlsConfig(e){if(!e.emeEnabled)return{};const t=this.tokenManager;return Object.assign(Object.assign({emeEnabled:e.emeEnabled},void 0!==e.drmSystems&&{drmSystems:Qt(e.drmSystems)}),{licenseXhrSetup:async(e,i)=>{var s,n;if(null==t?void 0:t.extraParamsCallback){const i=await t.extraParamsCallback().catch(e=>(console.error("DrmConfigurator: extraParamsCallback error:",e),null));(null==i?void 0:i.accessToken)&&e.setRequestHeader("Authorization",`Bearer ${i.accessToken}`)}const r=null===(n=null===(s=null==t?void 0:t.lastTokenResponse)||void 0===s?void 0:s.extras)||void 0===n?void 0:n.drm_custom_data;if(r){const t=new URL(i);t.searchParams.delete("customdata"),t.searchParams.append("customdata",r),e.open("POST",t.toString(),!0)}else e.open("POST",i,!0)}})}}const Kt=new Set(["keySystemError"]);function Xt(e,t){const i=new Map,s=new Set,n=new Set;let r,o=!1;e.on("hlsError",(a,l)=>{var c,d,u,h,v;const g=null!==(c=l.details)&&void 0!==c?c:l.type,p=null===(d=e.media)||void 0===d?void 0:d.currentTime;if(void 0!==p&&void 0!==r&&p>r+1&&(i.clear(),s.clear()),r=p,l.fatal){if(Kt.has(l.type)){if(n.has(g))return;return n.add(g),console.error(`HLS Retry: Unrecoverable error "${g}" — cannot fix by retrying.`,a,l),void(null===(u=null==t?void 0:t.onUnrecoverableError)||void 0===u||u.call(t,`DRM error: ${g}`))}if(void 0!==(null==t?void 0:t.onFatalNetworkError)){if(o)return;return o=!0,console.warn(`HLS Retry: Fatal error on intro pass — signalling fall-through (${g}).`,a,l),void t.onFatalNetworkError(g)}return console.warn("HLS Retry: Fatal error, trying to fix now.",a,l),void setTimeout(()=>{var t,i;"mediaError"===l.type?e.recoverMediaError():e.startLoad(null!==(i=null===(t=e.media)||void 0===t?void 0:t.currentTime)&&void 0!==i?i:-1)},1e3)}if(s.has(g))return;const m=(null!==(h=i.get(g))&&void 0!==h?h:0)+1;if(i.set(g,m),m>3)return console.warn(`HLS Retry: Non-fatal "${g}" exceeded 3 retries, giving up.`,a,l),void s.add(g);console.warn(`HLS Retry: Non-fatal error (${m}/3), monitoring.`,a,l);const f=null===(v=e.media)||void 0===v?void 0:v.currentTime;setTimeout(()=>{var n,r,o;if(f!==(null===(n=e.media)||void 0===n?void 0:n.currentTime)||(null==t?void 0:t.chromecast_casting))console.info("HLS Retry: Stream is playing, no action needed",a,l),i.delete(g),s.delete(g);else{if(function(e,t){if(null===e||!0===(null==t?void 0:t.isLive))return!1;const{duration:i,buffered:s,currentTime:n}=e;return!(!Number.isFinite(i)||i<=0)&&!(i-n>1)&&0!==s.length&&s.end(s.length-1)>=i-1}(e.media,t))return void console.info("HLS Retry: near VOD end, letting hls.js finish naturally",a,l);console.warn("HLS Retry: Stream is stuck, trying to fix",a,l),"mediaError"===l.type?e.recoverMediaError():e.startLoad(null!==(o=null===(r=e.media)||void 0===r?void 0:r.currentTime)&&void 0!==o?o:-1)}},3e3)})}function Jt(e,t){const i=e.trigger;e.trigger=function(e,s){var n,r,o;if(e===t.AUDIO_TRACK_LOADED){const e=s;if(null==e?void 0:e.details){const t=this.currentLevel>=0?this.currentLevel:0,i=null===(r=null===(n=this.levels)||void 0===n?void 0:n[t])||void 0===r?void 0:r.details;if(i&&e.details.endCC>i.endCC){const t=i.endCC,s=e.details.fragments;if(s)for(let e=0;e<s.length;e++)s[e].cc>t&&(s[e].cc=t);void 0!==(null===(o=e.details.fragmentHint)||void 0===o?void 0:o.cc)&&e.details.fragmentHint.cc>t&&(e.details.fragmentHint.cc=t),e.details.endCC=t}}}return i.call(this,e,s)}}const Zt=Object.freeze([Dt.EASY_B,Dt.VENOM,Dt.BUNNY]);function ei(e,t){try{const i=new URL(t),s=i.searchParams.get("token");if(!s)return e;const n=i.searchParams.get("expires"),r=i.searchParams.get("token_path");return Gt.appendTokenParams(e,s,n,r)}catch(t){return e}}function ti(e,t){let i=!1;function s(e){const s=e.load.bind(e);e.load=function(e,n,r){var o;const a=t.tokenType;if(!a||!Zt.includes(a)){const t=function(e){return`signSegmentsWithCdnToken: segment signing is not supported for ${void 0===e?"no token type configured":`token type "${e}"`}. Supported token types: ${Zt.join(", ")}.`}(a);return i||(i=!0,console.error(t)),void r.onError({code:0,text:t},e,null,{aborted:!1,loaded:0,total:0,retry:0,chunkCount:0,bwEstimate:0,loading:{start:0,first:0,end:0},parsing:{start:0,end:0},buffering:{start:0,first:0,end:0}})}const l=null===(o=e.frag)||void 0===o?void 0:o.baseurl;if(!l||!e.url)return void s(e,n,r);const{hasToken:c,expires:d}=function(e){try{const t=new URL(e);return t.searchParams.get("token")?{hasToken:!0,expires:t.searchParams.get("expires")}:{hasToken:!1,expires:null}}catch(e){return{hasToken:!1,expires:null}}}(l);if(c)return t.isTokenExpired(d)?void t.updateUrlWithTokenParams({url:e.url}).then(t=>{e.url=t,s(e,n,r)}).catch(()=>{e.url=ei(e.url,l),s(e,n,r)}):(e.url=ei(e.url,l),void s(e,n,r));s(e,n,r)}}function n(t){if(new.target){const i=Reflect.construct(e,[t],new.target);return s(i),i}e.call(this,t),s(this)}return n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n}class ii extends Bt{constructor(){super(...arguments),this.driver=null,this.tokenManager=null,this.autoQuality=!0,this.eventState=null,this.loadNeverStartedTimer=0,this.liveSyncDisabled=!1}getDriver(){return this.driver}getTokenManager(){return this.tokenManager}async onAttach(){if(this.state){this.state.playbackState="loading";try{await this.init()}catch(e){console.error("HlsEngine: init failed",e),this.state&&x(this.state,this.bus,T,e instanceof Error?e.message:String(e))}}}onDetach(){if(this.stopWatchdog(),this.clearLoadNeverStartedWatchdog(),null!==this.driver){try{this.driver.detachMedia(),this.driver.destroy()}catch(e){console.error("HlsEngine: error during driver teardown",e)}this.driver=null}this.tokenManager=null,this.eventState=null}recoverFromStall(e){var t,i;this.driver&&(1===e?(console.warn("HlsEngine stall recovery: recoverMediaError"),this.driver.recoverMediaError()):(console.warn("HlsEngine stall recovery: startLoad"),this.driver.startLoad(null!==(i=null===(t=this.video)||void 0===t?void 0:t.currentTime)&&void 0!==i?i:-1)))}setQuality(e){null!==this.driver&&(this.driver.currentLevel=e,this.autoQuality=-1===e,null!==this.state&&(this.state.currentQuality=e))}setAudioTrack(e){null!==this.driver&&(this.driver.audioTrack=e)}setSubtitle(e){null!==this.driver&&(this.driver.subtitleTrack=e)}setPlaybackRate(e){null!==this.video&&(this.video.playbackRate=e)}seek(e){var t;if(null===this.video)return;if(!this.liveSyncDisabled&&null!==this.driver&&(null===(t=this.state)||void 0===t?void 0:t.isLive)){const e=this.driver.config;e.liveSyncDurationCount=0,e.liveMaxLatencyDurationCount=1/0,this.liveSyncDisabled=!0}const i=this.video.ended;if(this.video.currentTime=e,i&&null!==this.driver){this.state&&(this.state.playbackState="loading");const t=this.driver;setTimeout(()=>t.startLoad(e),0)}}seekToLive(){if(null===this.video)return;const e=this.video.duration;Number.isFinite(e)&&(this.video.currentTime=e-30)}get detached(){return null===this.state}async init(){var e;const{config:t,video:i,state:s,signal:n}=this;if(!(t&&i&&s&&n))return;const r=t.hlsjs;if(!r)throw new Error("HlsEngine: config.hlsjs URL is required");t.token&&(this.tokenManager=new Gt({token:t.token,tokenType:t.tokenType,srcInTokenRequest:t.srcInTokenRequest,extraParamsCallback:null!==(e=t.engineSettings.extraParamsCallback)&&void 0!==e?e:t.extraParamsCallback,onCDNTokenError:t.engineSettings.onCDNTokenError}));const o=await vt(r,"Hls");if(this.detached)return;const a=new Yt(this.tokenManager).buildHlsConfig(t.engineSettings),l=this.tokenManager,c=t.engineSettings,{emeEnabled:d,drmSystems:u}=c,h=function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(i[s[n]]=e[s[n]])}return i}(c,["emeEnabled","drmSystems"]),v=Object.assign({},h);delete v.extraParamsCallback,delete v.onCDNTokenError,delete v.signSegmentsWithCdnToken;const g=Object.assign(Object.assign(Object.assign({enableWorker:!0,backBufferLength:30},v),a),{startPosition:t.startAt});if(l){const e=l;class i extends o.DefaultConfig.loader{constructor(t){super(t);const i=this.load.bind(this);this.load=function(t,s,n){if(!t.url)return void i(t,s,n);if(!new URL(t.url).pathname.split("/").pop().endsWith(".m3u8"))return void i(t,s,n);const r=Object.assign(Object.assign({},n),{onSuccess:(t,i,s)=>{e.resetCdnRejectionCount(),n.onSuccess(t,i,s)},onError:(t,i,s)=>{403===(null==t?void 0:t.code)&&e.notifyCdnRejection(),n.onError(t,i,s)}});e.updateUrlWithTokenParams({url:t.url}).then(e=>{t.url=e,i(t,s,r)}).catch(()=>{i(t,s,r)})}}}if(g.pLoader=i,!0===t.engineSettings.signSegmentsWithCdnToken){const t=ti(o.DefaultConfig.loader,e);g.fLoader=t,g.loader=t}}if(!t.disableCustomAbr)try{const{createHlsAbrController:e}=await Promise.resolve().then(function(){return Ei});if(this.detached)return;g.abrController=e(o)}catch(e){console.warn("HlsEngine: failed to load custom ABR controller, using default",e)}if(this.detached)return;const p=new o(g);this.driver=p,Jt(p,o.Events);const m=Boolean(t.preroll)&&this.loadSourceUrl===t.preroll;if(t.retry&&Xt(p,Object.assign({get chromecast_casting(){return s.isCasting},get isLive(){return s.isLive},onUnrecoverableError:e=>{var t;this.stopWatchdog(),this.state&&x(this.state,this.bus,C,e),null===(t=this.bus)||void 0===t||t.emit("error-fatal",{code:"DRM",message:e})}},m?{onFatalNetworkError:e=>{var t;this.stopWatchdog(),null===(t=this.bus)||void 0===t||t.emit("error-fatal",{code:"NETWORK",message:`Intro stream error: ${e}`})}}:{})),t.useGeoblockingErrorHandle){const e=this.bus;p.on(o.Events.ERROR,(t,i)=>{var s;const n=i;(null==n?void 0:n.type)!==o.ErrorTypes.NETWORK_ERROR||"manifestLoadError"!==(null==n?void 0:n.details)&&"levelLoadError"!==(null==n?void 0:n.details)||403!==(null===(s=null==n?void 0:n.response)||void 0===s?void 0:s.code)||(null==e||e.emit("geoblock-detected"),window.dispatchEvent(new CustomEvent("geoblock",{detail:{title:"Geoblock",message:"Geoblock detected"}})),this.stopWatchdog())})}this.bindVideoEvents(i,s,n),p.attachMedia(i);let f=this.loadSourceUrl||t.src||"";if(this.tokenManager&&f&&(this.tokenManager.sourceUrl=f,f=await this.tokenManager.updateUrlWithTokenParams({url:f}),this.detached))return p.destroy(),void(this.driver=null);p.loadSource(f),this.resolveDriverReady(),this.registerDriverEvents(o,s),this.armLoadNeverStartedWatchdog(p,o,f,m);const b=p;i.addEventListener("pause",()=>{var e;(null===(e=this.state)||void 0===e?void 0:e.isLive)&&b.stopLoad()},{signal:n}),i.addEventListener("play",()=>{var e,t,i,s;if(null===(e=this.state)||void 0===e?void 0:e.isLive)setTimeout(()=>b.startLoad(-1),0);else if("ended"===(null===(t=this.state)||void 0===t?void 0:t.playbackState)){this.state.playbackState="loading";const e=null!==(s=null===(i=this.video)||void 0===i?void 0:i.currentTime)&&void 0!==s?s:0;setTimeout(()=>b.startLoad(e),0)}},{signal:n}),this.startWatchdog();const y=i,k=s;let E=0;const T=setInterval(()=>{if(E++,E>=10)return void clearInterval(T);const e=k.playbackState;if("playing"!==e&&!y.paused&&y.currentTime>0)return k.playbackState="playing",void clearInterval(T);"buffering"!==e&&"loading"!==e||!y.paused||(k.playbackState="paused",clearInterval(T))},200);n.addEventListener("abort",()=>clearInterval(T),{once:!0})}registerDriverEvents(e,t){const i=this.driver;if(!i)return;this.eventState=t;const{Events:s}=e;i.on(s.MANIFEST_PARSED,this._onManifestParsed.bind(this)),i.on(s.LEVEL_LOADED,this._onLevelLoaded.bind(this)),i.on(s.LEVEL_SWITCHED,this._onLevelSwitched.bind(this)),i.on(s.AUDIO_TRACKS_UPDATED,this._onAudioTracksUpdated.bind(this)),i.on(s.AUDIO_TRACK_SWITCHED,this._onAudioTrackSwitched.bind(this)),i.on(s.SUBTITLE_TRACKS_UPDATED,this._onSubtitleTracksUpdated.bind(this)),i.on(s.SUBTITLE_TRACK_SWITCH,this._onSubtitleTrackSwitch.bind(this))}armLoadNeverStartedWatchdog(e,t,i,s){s||(e.on(t.Events.FRAG_LOADING,this._onFragLoading.bind(this)),this.loadNeverStartedTimer=setTimeout(this._onLoadNeverStartedTimeout.bind(this,i),3e4))}clearLoadNeverStartedWatchdog(){clearTimeout(this.loadNeverStartedTimer),this.loadNeverStartedTimer=0}_onFragLoading(){this.clearLoadNeverStartedWatchdog()}_onLoadNeverStartedTimeout(e){var t,i,s;this.detached||!0!==(null===(t=this.state)||void 0===t?void 0:t.isLive)&&!0!==(null===(i=this.config)||void 0===i?void 0:i.isLive)&&(this.state&&x(this.state,this.bus,L,"HlsEngine: load never started — no fragment request was issued within the bound"),null===(s=this.bus)||void 0===s||s.emit("load-never-started",{src:e}))}_onManifestParsed(e,t){var i,s;const n=this.eventState,r=this.driver;if(!n)return;const o=null!==(s=null!==(i=t.levels)&&void 0!==i?i:null==r?void 0:r.levels)&&void 0!==s?s:[];n.qualityLevels=o.map((e,t)=>{var i;return{name:null!==(i=e.name)&&void 0!==i?i:`${e.height}p`,id:t,bitrate:e.bitrate,height:e.height,width:e.width}})}_onLevelLoaded(e,t){var i,s;const n=this.eventState;if(!n)return;const r=t;void 0!==(null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.live)?n.isLive=r.details.live:!0===(null===(s=this.config)||void 0===s?void 0:s.isLive)&&(n.isLive=!0)}_onLevelSwitched(e,t){const i=this.eventState;if(i&&!this.autoQuality){const e=t;i.currentQuality=e.level}}_onAudioTracksUpdated(e,t){var i,s;const n=this.eventState,r=this.driver;if(!n)return;const o=null!==(s=null!==(i=t.audioTracks)&&void 0!==i?i:null==r?void 0:r.audioTracks)&&void 0!==s?s:[];n.audioTracks=o.map(e=>({id:e.id,name:e.name,lang:e.lang}))}_onAudioTrackSwitched(e,t){const i=this.eventState;if(!i)return;const s=t;i.currentAudioTrack=s.id}_onSubtitleTracksUpdated(e,t){var i,s;const n=this.eventState,r=this.driver;if(!n)return;const o=null!==(s=null!==(i=t.subtitleTracks)&&void 0!==i?i:null==r?void 0:r.subtitleTracks)&&void 0!==s?s:[];n.subtitleTracks=o.map(e=>({id:e.id,name:e.name,lang:e.lang}))}_onSubtitleTrackSwitch(e,t){const i=this.eventState;if(!i)return;const s=t;i.currentSubtitleTrack=s.id}}const si=(e,t,i,s,n,r)=>{if(r<=0)return;const[{bandwidth:o},{bandwidth:a}]=t.getMediaInfo().bitrateList;return r>2&&.8*i>=o&&i<=a?e<8?r:r-1:1===r?s.getCurrentBufferLevel("video",!0)>1.5*n&&e<8?r:r-1:void 0};function ni(e){const t=e.FactoryMaker.getClassFactoryByName("SwitchRequest"),i=e.FactoryMaker.getSingletonFactoryByName("StreamController"),s=e.FactoryMaker.getSingletonFactoryByName("DashMetrics"),n=new Set;let r=0,o=15,a=15;const l=function(){return{getMaxIndex:e=>{const l=t(this.context).create();l.priority=t.PRIORITY.STRONG;const c=e.getMediaInfo().type,d=s(this.context).getInstance(),u=i(this.context).getInstance(),h=e.getAbrController();if(setInterval(()=>{var e;void 0!==(e=d.getCurrentBufferLevel("video",!0))&&(o<e&&(n.add(a),o=e,a=e),e<a&&(a=e,o=a))},1e3),"video"===c){let i,s;try{const[t,o]=(({requests:e,count:t,rulesContext:i,currentValue:s,dashMetrics:o})=>{if(!e)return[""];let a=null;for(let t=e.length-1;t>=0&&null===a;t--){const[{_tfinish:i,trequest:s,tresponse:n,trace:r}]=e[t];i&&s&&n&&r&&r.length&&(a=e[t])}if(null===a)return["No valid request made for this stream yet, bailing"];const l=(a[0]._tfinish.getTime()-a[0].trequest.getTime())/1e3,c=(a[0]._tfinish.getTime()-a[0].tresponse.getTime())/1e3;if("InitializationSegment"===a[0].type||"MediaSegment"===a[0].type){if(l<=0)return["Last segment not downloaded, probable network problem: Switching to lowest quality",0];if(n.size>=3){const a=Array.from(n),d=a.reduce((e,t)=>e+t,0)/n.size,u=((e,t)=>{const[{type:i,_tfinish:s,trequest:n,tresponse:r,trace:o}]=e[0];return"MediaSegment"!==i&&s&&n&&r&&o&&o.length?8*o.reduce((e,t)=>e+t.b[0],0)/t:0})(e,l),h=Math.sqrt(a.map(e=>(e-d)**2).reduce((e,t)=>e+t,0)/n.size);return n.clear(),d<=1.5?["Avg. Buffer < 10% of max buffer, switching to lowest quality",0]:d<=4.5?["Maintaining the current Bitrate",s]:d<=10.5&&i.getMediaInfo().bitrateList[s].bandwidth<u&&(r<t-1||h<=8)?["Switching to optimised quality level",r?si(h,i,u,o,c,t):r+1]:["Switching to optimised quality level",si(h,i,u,o,c,t)]}return["Maintaining the last loaded level"]}return["Last Loaded segment was not a media segment of initialization segment"]})({requests:d.getHttpRequests(c),count:e.getMediaInfo().representationCount,currentValue:h.getQualityFor(c,u.getActiveStreamInfo()),rulesContext:e,dashMetrics:d});s=t,i=null!=o?o:r,r=i}catch(e){return n.clear(),{quality:0,reason:"Error in ABR rule",priority:t.PRIORITY.STRONG}}return l.quality=i,l.reason=s,l}return l.quality=0,l.reason="Audio Request",l}}};return l.__dashjs_factory_name="CustomAbrRule",e.FactoryMaker.getClassFactory(l)}class ri extends Bt{constructor(){super(...arguments),this.driver=null,this.dvrErrorHandler=null,this.isIntroPass=!1,this.introFallThroughReported=!1}getDriver(){return this.driver}setConfig(e){this.config=e}setBus(e){this.bus=e}setVideo(e){this.video=e}async onAttach(){if(this.state){this.state.playbackState="loading";try{await this.init()}catch(e){console.error("DashEngine: init failed",e),this.state&&x(this.state,this.bus,w,e instanceof Error?e.message:String(e))}}}onDetach(){if(this.stopWatchdog(),null!==this.driver){try{this.driver.reset(),this.driver.destroy()}catch(e){console.error("DashEngine: error during driver teardown",e)}this.driver=null}null!==this.dvrErrorHandler&&(window.removeEventListener("unhandledrejection",this.dvrErrorHandler),this.dvrErrorHandler=null)}recoverFromStall(e){var t;null!==this.video&&(1===e?(console.warn("DashEngine stall recovery: seek nudge"),this.video.currentTime+=.1):(console.warn("DashEngine stall recovery: refreshManifest"),null===(t=this.driver)||void 0===t||t.refreshManifest()))}setQuality(e){null!==this.driver&&this.driver.setQualityFor("video",e)}setAudioTrack(e){if(null===this.driver)return;const t=this.driver.getTracksFor("audio");void 0!==t[e]&&this.driver.setCurrentTrack(t[e])}setSubtitle(e){if(null===this.driver)return;const t=this.driver.getTracksFor("fragmentedText");void 0!==t[e]&&this.driver.setCurrentTrack(t[e])}setPlaybackRate(e){null!==this.video&&(this.video.playbackRate=e)}seekToLive(){if(null===this.driver||null===this.video)return;const e=this.driver.duration();Number.isFinite(e)&&(this.video.currentTime=e)}async init(){var e;const{config:t,video:i,state:s,signal:n}=this;if(!(t&&i&&s&&n))return;this.isIntroPass=Boolean(t.preroll)&&this.loadSourceUrl===t.preroll;const r=t.dashjs;if(!r)throw new Error("DashEngine: config.dashjs URL is required");this.dvrErrorHandler=e=>{var t;const i=e.reason;((null===(t=null==i?void 0:i.message)||void 0===t?void 0:t.includes("getCurrentDVRInfo"))||String(e.reason).includes("getCurrentDVRInfo"))&&(e.preventDefault(),console.warn("DashEngine: suppressed DVR unhandledrejection"))},window.addEventListener("unhandledrejection",this.dvrErrorHandler,{signal:n});const o=await vt(r,"dashjs"),a=o.MediaPlayer().create();if(!a)throw new Error("DashEngine: dash.js MediaPlayer could not be created");if(this.driver=a,this.resolveDriverReady(),a.initialize(i,this.loadSourceUrl||t.src||"",null!==(e=t.autoplay)&&void 0!==e&&e),t.retry&&function(e,t={}){e.updateSettings({streaming:{retryIntervals:{MPD:1e3,XLinkExpansion:1e3,InitializationSegment:1e3,IndexSegment:1e3,MediaSegment:1e3,BitstreamSwitchingSegment:1e3,other:1e3,lowLatencyReductionFactor:1}}});const i=!0===t.introPass?2:1/0;e.updateSettings({streaming:{retryAttempts:{MPD:i,XLinkExpansion:i,InitializationSegment:i,IndexSegment:i,MediaSegment:i,BitstreamSwitchingSegment:i,other:i,lowLatencyMultiplyFactor:1}}})}(a,{introPass:this.isIntroPass}),!t.disableCustomAbr){const e=ni(o);a.addABRCustomRule("qualitySwitchRules","CustomAbrRule",e)}t.lowLatency&&a.updateSettings({streaming:{lowLatencyEnabled:!0,liveDelay:30,liveCatchUpPlaybackRate:.01}}),this.registerDriverEvents(o,s,a),this.bindVideoEvents(i,s,n),this.startWatchdog(),await new Promise(e=>{const t=()=>{a.off(o.MediaPlayer.events.STREAM_INITIALIZED,t),e()};a.on(o.MediaPlayer.events.STREAM_INITIALIZED,t)});const l=i,c=s;let d=0;const u=setInterval(()=>{if(d++,d>=10)return void clearInterval(u);const e=c.playbackState;if("playing"!==e&&!l.paused&&l.currentTime>0)return c.playbackState="playing",void clearInterval(u);"buffering"!==e&&"loading"!==e||!l.paused||(c.playbackState="paused",clearInterval(u))},200);n.addEventListener("abort",()=>clearInterval(u),{once:!0})}registerDriverEvents(e,t,i){const s=e.MediaPlayer.events;i.on(s.STREAM_INITIALIZED,()=>{var e;const s=i.getBitrateInfoListFor("video");t.qualityLevels=s.map((e,t)=>({name:`${e.height}p`,id:t,bitrate:e.bitrate}));const n=i.getTracksFor("audio");t.audioTracks=n.map(e=>{var t,i,s;return{name:null!==(t=e.lang)&&void 0!==t?t:"",id:null!==(s=null!==(i=e.id)&&void 0!==i?i:e.index)&&void 0!==s?s:0}});const r=i.getTracksFor("fragmentedText");t.subtitleTracks=r.map(e=>{var t,i,s;return{name:null!==(t=e.lang)&&void 0!==t?t:"",id:null!==(s=null!==(i=e.id)&&void 0!==i?i:e.index)&&void 0!==s?s:0}});const o=i.duration();t.duration=Number.isFinite(o)?Math.ceil(o):0;const a=i.getCurrentLiveLatency();"boolean"==typeof(null===(e=this.config)||void 0===e?void 0:e.isLive)?t.isLive=this.config.isLive:t.isLive=!Number.isNaN(a),t.playbackState="playing"}),i.on(s.PLAYBACK_TIME_UPDATED,()=>{t.currentTime=Math.round(i.time())}),i.on(s.QUALITY_CHANGE_REQUESTED,()=>{t.currentQuality=i.getQualityFor("video")}),i.on(s.TRACK_CHANGE_RENDERED,()=>{t.currentAudioTrack=i.getQualityFor("audio")}),i.on(s.ERROR,e=>{this.handleDriverError(e)})}handleDriverError(e){var t,i,s,n,r,o,a,l;const c=e;if(console.warn("DashEngine error:",null!==(s=null!==(i=null===(t=null==c?void 0:c.error)||void 0===t?void 0:t.message)&&void 0!==i?i:null==c?void 0:c.error)&&void 0!==s?s:c),!this.isIntroPass||this.introFallThroughReported)return;this.introFallThroughReported=!0,this.stopWatchdog();const d=null!==(a=null!==(r=null===(n=null==c?void 0:c.error)||void 0===n?void 0:n.code)&&void 0!==r?r:null===(o=null==c?void 0:c.error)||void 0===o?void 0:o.message)&&void 0!==a?a:"unknown";null===(l=this.bus)||void 0===l||l.emit("error-fatal",{code:"NETWORK",message:`Intro stream error: ${d}`})}}function oi(e){return e.split("?")[0].replace(/(\/hdn.*\/)/g,"/")}class ai{constructor(){this.lib=null}async integrate(e){var t,i,s,n;const{video:r,driver:o,type:a,config:l,signal:c}=e;if(!l.lib||!l.manager)return;const d=await vt(l.lib,"Easybroadcast");if(c.aborted)return;this.lib=new d.eblib.EBLibrary(l.manager);const u=oi(null!==(t=l.src)&&void 0!==t?t:""),h=null!==(s=(null!==(i=l.libSettings)&&void 0!==i?i:{}).resourceManager)&&void 0!==s?s:{},v={resourceManager:Object.assign({tokenRemover:oi},h),swarmManager:{url:u},statsOutput:{enable:!!l.stats,url:l.stats,intervalMs:3e4},playerInput:{content:String(null!==(n=l.content)&&void 0!==n?n:u),contentUrl:u,proto:a,origin:l.origin}};if("dash"===a){const e=v.resourceManager;e.randomWaitForPeers=[150,400],e.timeoutV2V=500,e.storageSize=20}this.lib.integrate([o,r],a,v),this.lib.start(),c.addEventListener("abort",()=>{this.stop()},{once:!0})}stop(){null!==this.lib&&"function"==typeof this.lib.stop&&this.lib.stop(),this.lib=null}}class li{constructor(e,t){this.driver=null,this.offscreenVideo=null,this.throttleTimeout=null,this.pendingSeekTime=0,this.config=e,this.tokenManager=t}init(e){var t,i;const s=document.createElement("video");s.preload="metadata",this.offscreenVideo=s;const n=this.tokenManager;let r,o;if(n){class t extends e.DefaultConfig.loader{constructor(e){super(e);const t=this.load.bind(this);this.load=async function(e,i,s){if(!e.url)return void t(e,i,s);new URL(e.url).pathname.split("/").pop().endsWith(".m3u8")?(e.url=await n.updateUrlWithTokenParams({url:e.url}),t(e,i,s)):t(e,i,s)}}}r=t}n&&!0===(null===(t=this.config.engineSettings)||void 0===t?void 0:t.signSegmentsWithCdnToken)&&(o=ti(e.DefaultConfig.loader,n));const a=Object.assign({},null!==(i=this.config.engineSettings)&&void 0!==i?i:{});delete a.extraParamsCallback,delete a.onCDNTokenError,delete a.signSegmentsWithCdnToken;const l=Object.assign(Object.assign(Object.assign({startLevel:0,enableWebVTT:!1,enableWorker:!1,maxBufferLength:1},a),r?{pLoader:r}:{}),o?{fLoader:o}:{}),c=new e(l);return this.driver=c,Jt(c,e.Events),c.attachMedia(s),this.config.src&&c.loadSource(this.config.src),new Promise(t=>{c.once(e.Events.MANIFEST_LOADED,()=>{c.loadLevel=0,t()})})}take(e){this.offscreenVideo&&(null!==this.throttleTimeout&&clearTimeout(this.throttleTimeout),this.pendingSeekTime=e,this.throttleTimeout=setTimeout(this.applyPendingSeek.bind(this),250))}applyPendingSeek(){this.offscreenVideo&&(this.offscreenVideo.currentTime=this.pendingSeekTime),this.throttleTimeout=null}getVideo(){return this.offscreenVideo}stopLoad(){this.driver&&"function"==typeof this.driver.stopLoad&&this.driver.stopLoad()}startLoad(){this.driver&&"function"==typeof this.driver.startLoad&&this.driver.startLoad(-1)}destroy(){if(null!==this.throttleTimeout&&(clearTimeout(this.throttleTimeout),this.throttleTimeout=null),null!==this.driver){try{this.driver.detachMedia(),this.driver.destroy()}catch(e){console.warn("HlsSnapshotHandler: error during destroy",e)}this.driver=null}this.offscreenVideo=null}}class ci{constructor(e){this.player=null,this.offscreenVideo=null,this.ready=!1,this.src=e}init(e){return new Promise(t=>{const i=document.createElement("video");i.style.display="none",document.body.appendChild(i),this.offscreenVideo=i;const s={take:()=>{},destroy:()=>{},video:i};let n;try{n=e.MediaPlayer().create(),this.player=n,n.initialize(i,this.src,!1),n.updateSettings({streaming:{text:{defaultEnabled:!1},buffer:{fastSwitchEnabled:!1},abr:{autoSwitchBitrate:{video:!1,audio:!1},initialBitrate:{video:0,audio:0}}}})}catch(e){const i=e instanceof Error?e.message:String(e);return console.warn("Snapshot handler initialization failed:",i),this.cleanup(),void t(s)}n.on(e.MediaPlayer.events.ERROR,e=>{var t,i,s;const n=e;console.warn("Snapshot dash.js error:",null!==(s=null!==(i=null===(t=null==n?void 0:n.error)||void 0===t?void 0:t.message)&&void 0!==i?i:null==n?void 0:n.error)&&void 0!==s?s:n)});const r=()=>{n.setMute(!0),n.off(e.MediaPlayer.events.STREAM_INITIALIZED,r),this.ready=!0;let s=null;t({take:e=>{if(this.ready&&null===s){s=setTimeout(()=>{s=null},250);try{n.seek(e),n.isPaused()&&n.play()}catch(e){const t=e instanceof Error?e.message:String(e);console.warn("Snapshot seek error:",t)}}},destroy:()=>{this.ready=!1,this.destroy()},video:i})};n.on(e.MediaPlayer.events.STREAM_INITIALIZED,r),n.on(e.MediaPlayer.events.PLAYBACK_PLAYING,()=>{n.isPaused()||n.pause()})})}destroy(){if(this.ready=!1,null!==this.player){try{this.player.reset()}catch(e){}this.player=null}this.cleanup()}cleanup(){null!==this.offscreenVideo&&(this.offscreenVideo.remove(),this.offscreenVideo=null)}}const di=["Proxy","AbortController"];var ui;const hi=new Map;function vi(e){var t;null!==e.snapshotDestroy&&(e.snapshotDestroy(),e.snapshotDestroy=null),null!==e.engine&&(e.engine.detach(),e.engine=null),null===(t=e.p2p)||void 0===t||t.stop(),e.p2p=null,e.controller.dispose()}function gi(){return new Promise(e=>setTimeout(e,500))}function pi(e){const t=function(e){if(null!=e&&"object"==typeof e&&"nodeType"in e)return e;const t="string"==typeof e?e:"#eb_player",i=document.querySelector(t);if(null===i)throw new Error(`EBPlayer: container element not found for selector "${t}". Ensure the element exists in the DOM before calling start().`);return i}(e.el),i=function(e=window){return di.filter(t=>"function"!=typeof e[t])}();if(i.length>0)throw function(e,t){const i=new y(t),s=document.createElement("div");s.className="eb-player";const n=document.createElement("div");n.className="eb-error-slot";const r=document.createElement("div");r.className="eb-error",r.setAttribute("role","alert");const o=document.createElement("p");o.className="eb-error-message",o.textContent=i.t("error.unsupported_browser"),r.appendChild(o),n.appendChild(r),s.appendChild(n),e.textContent="",e.appendChild(s)}(t,e.lang),new Error(`EBPlayer: unsupported browser — missing ${i.join(", ")}`);const s=hi.get(t);void 0!==s&&(vi(s),hi.delete(t));const n=p(h,e);var r;void 0!==(r=n.sentryDsn)&&(null===Et?(Et=r,vt("https://browser.sentry-cdn.com/11.0.0/bundle.tracing.min.js","Sentry").then(e=>{e.init({dsn:r,tracesSampleRate:1,integrations:[],beforeBreadcrumb:bt,beforeSend:yt}),kt=e}).catch(e=>{console.warn("Telemetry: failed to load Sentry SDK",e)})):Et!==r&&console.warn("Telemetry: Sentry already initialized with a different DSN — ignoring"));const o=n.muted,a=n.manager,l=n.startAt,c=new Mt(e);c.mount(t);const d=t.querySelector("video"),u={controller:c,engine:null,snapshotDestroy:null,p2p:null,container:t};hi.set(t,u);let v="";const g={on(e,t){const i=new AbortController;return"error"===e&&c.bus.on("player-error",e=>{t(m(e))},{signal:i.signal}),()=>i.abort()},open(e){var t;v=e,null!==u.engine&&(u.engine.detach(),u.engine=null);const i=function(e,t){return e.includes(".mpd")&&!1!==t.dashjs?new ri:new ii}(e,n);if(null!==d&&i.setVideo(d),i.setBus(c.bus),i.setConfig(n),i.setLoadSource(e),c.setEngineSync(i),u.engine=i,n.lib&&n.manager&&null!==d){const s=e.includes(".mpd")&&!1!==n.dashjs;null===(t=u.p2p)||void 0===t||t.stop();const r=new ai;u.p2p=r,i.driverReady.then(()=>r.integrate({video:d,driver:i.getDriver(),type:s?"dash":"hls",config:n,signal:c.signal})).catch(e=>{console.error("EBPlayer: P2PManager integrate failed:",e)})}if(n.showProgressThumb&&e!==n.preroll){null!==u.snapshotDestroy&&(u.snapshotDestroy(),u.snapshotDestroy=null);const t=e.includes(".mpd")&&!1!==n.dashjs;i.driverReady.then(()=>{if(t){const t=window;if(t.dashjs){new ci(e).init(t.dashjs).then(e=>{u.snapshotDestroy=()=>e.destroy(),c.bus.emit("snapshot-handler-ready",{take:e.take,video:e.video})}).catch(e=>{console.warn("EBPlayer: DashSnapshotHandler init failed:",e)})}}else{const t=window;if(t.Hls){const s=i.getTokenManager(),r=new Yt(s).buildHlsConfig(n.engineSettings),o=new li({src:e,engineSettings:Object.assign(Object.assign({},n.engineSettings),r)},s);o.init(t.Hls).then(()=>{u.snapshotDestroy=()=>o.destroy();const e=o.getVideo();null!==e&&c.bus.emit("snapshot-handler-ready",{take:e=>o.take(e),video:e}),d&&(d.addEventListener("pause",()=>{var e;(null===(e=c.state)||void 0===e?void 0:e.isLive)&&o.stopLoad()},{signal:c.signal}),d.addEventListener("play",()=>{var e;(null===(e=c.state)||void 0===e?void 0:e.isLive)&&setTimeout(()=>o.startLoad(),0)},{signal:c.signal}))}).catch(e=>{console.warn("EBPlayer: HlsSnapshotHandler init failed:",e)})}else console.warn("EBPlayer: window.Hls not available after driverReady — snapshot preview disabled")}}).catch(e=>{console.warn("EBPlayer: Snapshot handler init failed:",e)})}},close(){null!==u.snapshotDestroy&&(u.snapshotDestroy(),u.snapshotDestroy=null),null!==u.engine&&(u.engine.detach(),u.engine=null)},destroy(){vi(u),hi.delete(t)},get state(){return c.state}};c.setReloadCallback(()=>{if(!v)return;const e=v,t=c.getSavedSelections();g.close(),gi().then(()=>{g.open(e),setTimeout(()=>{null!==u.engine&&(u.engine.setQuality(t.quality),u.engine.setAudioTrack(t.audioTrack),u.engine.setSubtitle(t.subtitleTrack))},2e3)})});const m=e=>Object.assign(Object.assign({},e),{localizedMessage:A(e.code,e.message,c.i18n)}),f=n.onError;if("function"==typeof f&&c.bus.on("player-error",e=>{try{f(m(e))}catch(e){console.error("EBPlayer: config.onError threw",e)}},{signal:c.signal}),c.bus.on("error-fatal",()=>{var e;null===(e=u.p2p)||void 0===e||e.stop()},{signal:c.signal}),null===d){const e="EBPlayer: no <video> element found in the container after mount() — playback cannot start.";return console.error(e),x(c.state,c.bus,S,e),g}let b=!1;const k=()=>{b||(b=!0,c.bus.emit("force-intro-complete"),d.muted=o,c.state.muted=o,n.manager=a,c.config.manager=a,n.startAt=l,c.config.startAt=l,c.state.error=null,c.state.errorCode=null,n.src&&g.open(n.src))},E=Boolean(n.preroll),T=Boolean(n.ad);let w=null;const C=()=>{null!==w&&(clearTimeout(w),w=null)},L=e=>{w=setTimeout(()=>{c.signal.aborted||(c.state.adPlaying?L(e):(console.warn("eb-player: ad leg produced no ad-complete within the bound — falling through to main (G-07-11)"),e()))},3e4)};c.signal.addEventListener("abort",()=>{C()},{once:!0});let $=!T,_=Boolean(n.autoplay),M=!1;const P=()=>{if(M)return;M=!0;const e=u.engine;null!==e&&e.driverReady.then(()=>{const e=d.play();e&&"function"==typeof e.catch&&e.catch(e=>{console.warn("EBPlayer: deferred play() rejected",e)})})},R=()=>{$&&_&&(k(),n.autoplay||P())};if(T&&c.bus.on("ad-complete",()=>{C(),$=!0,E?k():R()},{signal:c.signal}),E)c.bus.on("intro-stream-complete",()=>{g.close(),c.state.muted=o,gi().then(()=>{b||(T?L(k):k())})},{signal:c.signal}),d.muted=!1,c.state.muted=!1,n.manager=!1,c.config.manager=!1,n.startAt=void 0,c.config.startAt=void 0,g.open(n.preroll);else if(T)n.autoplay?L(()=>{$=!0,R()}):c.bus.on("play",()=>{_||(_=!0,$?(R(),P()):L(()=>{$=!0,R()}))},{signal:c.signal});else if(n.src)if(n.autoplay)g.open(n.src);else{let e=!0;c.bus.on("play",()=>{e&&(e=!1,g.open(n.src),P())},{signal:c.signal})}return g}function mi(){for(const e of hi.values())null!==e.engine&&(e.engine.detach(),e.engine=null)}function fi(){for(const e of hi.values())vi(e);hi.clear()}const bi=t;if("undefined"!=typeof window){console.info(`%cEBPlayer v${bi}`,"color: #1FA9DD; font-weight: bold");const e=window,t=null!==(ui=e.EBPlayer)&&void 0!==ui?ui:{};Object.assign(t,{start:pi,stop:mi,destroy:fi,AVAILABLE_THEMES:l,THEME_LAYOUTS:d,version:bi}),e.EBPlayer=t}const yi="main",ki={bufferInfo(e,t,i){if(!e.buffered||0===e.buffered.length)return{end:0,start:0,len:0,nextStart:0};for(let s=0;s<e.buffered.length;s++){const n=e.buffered.start(s),r=e.buffered.end(s);if(t>=n-i&&t<=r+i)return{end:r,start:n,len:r-t,nextStart:0}}return{end:0,start:0,len:0,nextStart:0}}};var Ei=Object.freeze({__proto__:null,createHlsAbrController:function(e){const t=e.DefaultConfig.abrController;if(!t)return class{constructor(e){}get nextAutoLevel(){return-1}set nextAutoLevel(e){}destroy(){}};const{Events:i}=e;return class extends t{constructor(e){super(e,i.FRAG_LOADING,i.FRAG_LOADED,i.FRAG_BUFFERED,i.ERROR),this.hls=e,this.lastLoadedLevel=1,this._nextAutoLevel=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.onBufferCheckTick=this._onBufferCheckTick.bind(this),this.bufferCheckLastPlayPos=0,this.bufferCheckCurrentPlayPos=0,this.bufferCheckBufferingDetected=!1,this.lastDuration=6,this.setBufferValues=new Set,this.setBitrate=new Set,this.loading=!1,this.playingTime=0,this.minBufferValue=30,this.maxBufferValue=0,this.lastBufferValue=30,this.maxBufferLength=30,this.rebuffering=0,this.rebufferingRatio=.15,this.pastBufferFactor=5,this.bitrateTestDelay=0,this.timer=void 0,this.bufferCheckTimer=void 0,this.init=!0,this.fraglastBuffered=0,this.lastLoadedFragLevel=1,this.fragCurrent=null,this.partCurrent=null,this.bufferCheckVideo=null,this.registerCustomListeners()}destroy(){this.unregisterCustomListeners(),this.clearCustomTimer(),void 0!==this.bufferCheckTimer&&(clearInterval(this.bufferCheckTimer),this.bufferCheckTimer=void 0),"function"==typeof super.destroy&&super.destroy()}registerCustomListeners(){this.hls.on(i.FRAG_LOADING,this.onFragLoading,this),this.hls.on(i.FRAG_LOADED,this.onFragLoaded,this),this.hls.on(i.FRAG_BUFFERED,this.onFragBuffered,this),this.hls.on(i.LEVEL_LOADED,this.onLevelLoaded,this),this.hls.on(i.ERROR,this.onError,this)}unregisterCustomListeners(){this.hls.off(i.FRAG_LOADING,this.onFragLoading,this),this.hls.off(i.FRAG_LOADED,this.onFragLoaded,this),this.hls.off(i.FRAG_BUFFERED,this.onFragBuffered,this),this.hls.off(i.LEVEL_LOADED,this.onLevelLoaded,this),this.hls.off(i.ERROR,this.onError,this)}clearCustomTimer(){void 0!==this.timer&&(clearInterval(this.timer),this.timer=void 0)}onFragLoading(e,t){var i;const s=t,{frag:n}=s;this.loading=!0,n.type===yi&&(this.timer||(this.fragCurrent=n,this.partCurrent=null!==(i=s.part)&&void 0!==i?i:null,this.timer=setInterval(this.onCheck,100)))}getBuffer(){if(!this.hls.media)return 0;const e=this.hls.media.playbackRate||1,t=this.hls.media.currentTime;return(ki.bufferInfo(this.hls.media,t,this.maxBufferLength).end-t)/e}_abandonRulesCheck(){const{hls:e}=this,t=e.media,i=this.fragCurrent,s=this.partCurrent;if(!i||!t)return;if((s?s.stats:i.stats).aborted)return this.clearCustomTimer(),void(this._nextAutoLevel=-1);e.autoLevelEnabled&&!t.paused&&t.playbackRate&&t.readyState&&i.type===yi&&"initSegment"!==i.sn&&(this.bufferCheckLastPlayPos=0,this.bufferCheckCurrentPlayPos=0,this.bufferCheckBufferingDetected=!1,this.bufferCheckVideo=t,this.bufferCheckTimer=setInterval(this.onBufferCheckTick,1e3))}_onBufferCheckTick(){if(!this.hls)return;if(!1===this.loading){const e=this.getBuffer();this.getBufferMinMaxValue(e)}const e=this.bufferCheckVideo;e&&(this.playingTime+=1,this.bufferCheckCurrentPlayPos=e.currentTime,this.bufferCheckLastPlayPos>0&&e.paused&&!this.bufferCheckBufferingDetected&&this.bufferCheckCurrentPlayPos<=this.bufferCheckLastPlayPos&&(this.rebuffering+=1,this.bufferCheckBufferingDetected=!0,this.hls.currentLevel>0&&(this.reset(),0!==this.lastLoadedFragLevel&&this.clearCustomTimer())),this.bufferCheckLastPlayPos>0&&this.bufferCheckBufferingDetected&&!e.paused&&this.bufferCheckCurrentPlayPos>this.bufferCheckLastPlayPos&&(this.bufferCheckBufferingDetected=!1),this.bufferCheckLastPlayPos=this.bufferCheckCurrentPlayPos)}onFragLoaded(e,t){const s=t,{frag:n,part:r}=s,o=r?r.stats:n.stats,a=r?r.duration:n.duration;if(this.loading=!1,n.type===yi&&"number"==typeof n.sn){this.clearCustomTimer(),this.lastLoadedFragLevel=n.level,this._nextAutoLevel=-1;const e=this.hls.levels[n.level];if(e){const t=(e.loaded?e.loaded.bytes:0)+o.loaded,i=(e.loaded?e.loaded.duration:0)+a;e.loaded={bytes:t,duration:i},e.realBitrate=Math.round(8*t/i),this.setBitrate.add(e.realBitrate),this.lastDuration=a,this.maxBufferLength=10*this.lastDuration}this.onFragBuffered(i.FRAG_BUFFERED,{stats:o,frag:n,part:r,id:n.type})}}getBufferMinMaxValue(e){this.lastBufferValue<e&&(this.setBufferValues.add(this.minBufferValue),this.maxBufferValue=e,this.lastBufferValue=e,this.minBufferValue=e),e>this.maxBufferValue&&(this.maxBufferValue=e),e<this.minBufferValue&&(this.minBufferValue=e,this.lastBufferValue=this.minBufferValue)}reset(){this.setBufferValues.clear(),this.setBitrate.clear()}onError(e,t){if("fragLoadTimeOut"===t.details)this.clearCustomTimer()}onLevelLoaded(e,t){}onFragBuffered(e,t){var i,s,n,r,o;const a=t,{frag:l,part:c}=a,d=c?c.stats:null!==(i=a.stats)&&void 0!==i?i:l.stats;if(d.aborted)return;if(l.type!==yi||"initSegment"===l.sn)return;const u=null!==(n=null===(s=d.loading)||void 0===s?void 0:s.start)&&void 0!==n?n:0,h=(null!==(o=null===(r=d.parsing)||void 0===r?void 0:r.end)&&void 0!==o?o:0)-u;this.bitrateTestDelay=h/1e3,this.fraglastBuffered=Date.now()}findNextBestLevel(e){const t=this.hls.levels;for(let i=0;i<t.length;i++){if(i<t.length-2&&.8*this.avgBitrate>=t[i].bitrate&&this.avgBitrate<=t[i+1].bitrate)return this.reset(),this.lastLoadedFragLevel=e<3?i:i-1,this.lastLoadedFragLevel;if(i===t.length-1){return this.getBuffer()>this.lastDuration+this.lastDuration/2&&e<3?this.lastLoadedFragLevel=i:this.lastLoadedFragLevel=i-1,this.reset(),this.lastLoadedFragLevel}}return this.lastLoadedFragLevel}get avgBitrate(){return 0===this.setBitrate.size?0:Array.from(this.setBitrate).reduce((e,t)=>e+t,0)/this.setBitrate.size}set avgBitrate(e){}findBestLevel(){var e,t;if(!this.hls)return 0;const i=this.hls.levels.length-1,s=this.getBuffer();if(s<.1*this.hls.config.maxBufferLength)return this.reset(),this.lastLoadedFragLevel=Math.max(this.lastLoadedFragLevel-1,0),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel;if(!0===this.init)return this.init=!1,this.lastLoadedFragLevel=i,this.lastLoadedFragLevel;if(s>.3*this.hls.config.maxBufferLength)return this.lastLoadedFragLevel=this.findNextBestLevel(5),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel;if(this.setBufferValues.size>=this.pastBufferFactor)try{const s=Array.from(this.setBufferValues).reduce((e,t)=>e+t,0)/this.setBufferValues.size,n=function(e){const t=e.reduce((e,t)=>e+t,0)/e.length,i=e.map(e=>(e-t)**2);return Math.sqrt(i.reduce((e,t)=>e+t,0)/(e.length-1))}(Array.from(this.setBufferValues));this.setBufferValues.clear();const r=null!==(t=null===(e=this.hls.levels[this.hls.currentLevel])||void 0===e?void 0:e.bitrate)&&void 0!==t?t:0;return s<=.1*this.hls.config.maxBufferLength&&r>=this.hls.levels[0].bitrate?(this.reset(),this.lastLoadedFragLevel=Math.max(this.lastLoadedFragLevel-1,0),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel):s<=.3*this.hls.config.maxBufferLength?(this.reset(),this.lastLoadedFragLevel):s<=.7*this.hls.config.maxBufferLength&&r<this.avgBitrate?(this.reset(),this.lastLoadedFragLevel=this.findNextBestLevel(n),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel):s>.7*this.hls.config.maxBufferLength&&r<.8*this.avgBitrate?(this.lastLoadedFragLevel=this.findNextBestLevel(n),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel):(this.reset(),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel)}catch(e){return console.warn("HLS ABR: findBestLevel error",e),this.lastLoadedFragLevel=this.findNextBestLevel(3),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel}return this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel}get _nextABRAutoLevel(){try{return this.playingTime>0&&this.rebuffering/this.playingTime>this.rebufferingRatio?(this.lastLoadedFragLevel=0,0):(this.setBitrate.size>0&&(this.lastLoadedFragLevel=this.findBestLevel()),this.lastLoadedFragLevel)}catch(e){return console.warn("HLS ABR: Could not define level, using last loaded level",e),this.lastLoadedFragLevel}}get nextAutoLevel(){return this._nextABRAutoLevel}set nextAutoLevel(e){this._nextAutoLevel=e}}}});e.AVAILABLE_THEMES=l,e.THEME_LAYOUTS=d,e.destroy=fi,e.start=pi,e.stop=mi,e.version=bi});
395
+ `}bindElementRefs(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;this.videoElement=null!==t?t.querySelector("video.eb-video"):null,this.adsContainerElement=null!==t?t.querySelector(".eb-ads-container"):null;this.config.posterStream&&null!==t&&(this.posterVideoElement=t.querySelector(".eb-poster-video"))}subscribeToState(){const e=this.state,{signal:t}=this;e.on("isRtl",()=>{this.applyRtl()},{signal:t}),e.on("isIOS",()=>{this.updateIOSState()},{signal:t}),e.on("playbackState",()=>{this.updatePosterVisibility()},{signal:t}),e.on("currentTime",()=>{this.state.currentTime>0&&this.updatePosterVisibility()},{signal:t}),e.on("isRadio",()=>{this.updateRadioOverlay()},{signal:t}),e.on("controlsVisible",()=>{this.updateControlsVisibility()},{signal:t}),e.on("adPlaying",()=>{this.updateAdPlayingState()},{signal:t})}updatePosterVisibility(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==t)return;const i=t.querySelector(".eb-poster");if(null===i)return;const s=this.state.playbackState,n=this.state.currentTime>0,r=!1!==this.config.image&&("idle"===s||"loading"===s||"playing"===s&&!n);i.style.display=r?"":"none"}updateIOSState(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==t)return;const i=this.state.isIOS;t.classList.toggle("eb-ios-native",i);const s=t.querySelector("video.eb-video");null!==s&&(s.controls=i)}updateRadioOverlay(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==t)return;const i=t.querySelector(".eb-overlay-zone");if(null===i)return;const s=i.querySelector(".eb-radio-overlay"),n=this.state.isRadio;if(n&&null===s){const e=document.createElement("div");e.className="eb-radio-overlay";const t=document.createElement("div");t.className="eb-radio-bars";for(let e=0;e<5;e++){const e=document.createElement("span");e.className="eb-radio-bar",t.appendChild(e)}e.appendChild(t),i.appendChild(e)}else n||null===s||s.remove()}updateControlsVisibility(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==t)return;const i=this.state.controlsVisible;t.classList.toggle("eb-controls-visible",i),t.classList.toggle("eb-controls-hidden",!i)}updateAdPlayingState(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;null!=t&&t.classList.toggle("eb-ad-playing",this.state.adPlaying)}applyRtl(){var e;const t=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;null!=t&&t.setAttribute("dir",this.state.isRtl?"rtl":"ltr")}invokeExtensions(){var e;const t=this.config.extensions;if(void 0===t)return;const i=null===(e=this.el)||void 0===e?void 0:e.firstElementChild;if(null==i)return;const s={"top-extra":".eb-extension-top-extra","bottom-extra":".eb-extension-bottom-extra",overlay:".eb-extension-overlay","controls-extra":".eb-extension-controls-extra"};for(const[e,n]of Object.entries(t)){const t=s[e];if(void 0===t)continue;const r=i.querySelector(t);if(null===r)continue;const o=n(r,this.state,this.bus,this.signal);"function"==typeof o&&this.extensionCleanups.push(o)}}disconnect(){for(const e of this.childComponents)e.disconnect();this.childComponents=[];for(const e of this.extensionCleanups)e();this.extensionCleanups=[],this.videoElement=null,this.adsContainerElement=null,this.posterVideoElement=null,super.disconnect()}}class yt{constructor(e,t,i){this.timer=0,this.state=t,this.container=e,this.onActivity=()=>this.show(),e.addEventListener("pointermove",this.onActivity),e.addEventListener("touchstart",this.onActivity),e.addEventListener("keyup",this.onActivity),i.addEventListener("abort",()=>{this.container.removeEventListener("pointermove",this.onActivity),this.container.removeEventListener("touchstart",this.onActivity),this.container.removeEventListener("keyup",this.onActivity),clearTimeout(this.timer),this.timer=0},{once:!0}),this.show()}show(){this.state.controlsVisible=!0,clearTimeout(this.timer),this.timer=setTimeout(()=>{this.hide()},3e3)}hide(){this.state.settingsOpen||this.state.socialsOpen||this.state.infoOpen||this.state.adPlaying||this.state.introStreamPlaying||(this.state.controlsVisible=!1)}}class kt{constructor(e,t,i,s,n){e.tabIndex<0&&(e.tabIndex=0);const r=e=>{const n=e;if(!t.adPlaying&&!t.introStreamPlaying){if(" "===n.key)return n.preventDefault(),void("playing"===t.playbackState?i.emit("pause"):i.emit("play"));if("ArrowLeft"===n.key){const e=s.seekOffset||15,n=Math.max(t.currentTime-e,0);return void i.emit("seek",{time:n})}if("ArrowRight"===n.key){const e=s.seekOffset||15,n=Math.min(t.currentTime+e,t.duration);return void i.emit("seek",{time:n})}s.supportHotKeys&&("m"!==n.key||i.emit("mute-toggle"))}};e.addEventListener("keyup",r),n.addEventListener("abort",()=>{e.removeEventListener("keyup",r)},{once:!0})}}let Et=null;class Tt{constructor(e){this.localDriver=null,this.signal=e.signal}async init(e,t,i){var s;if(!e.chromecast)return;const n=await E(e.chromecast,"Castjs");null===Et&&(Et=new n({receiver:null!==(s=e.chromecastApp)&&void 0!==s?s:"00197684"})),this.localDriver=Et,this.applyMetadata(e.chromecastMetadata),this.bindDriverEvents(t,i),this.registerAbortCleanup()}getDriver(){return this.localDriver}toggleCast(e){var t;const i=this.localDriver;if(null!==i)if(i.connected)i.disconnect();else if(e.castAvailable){const s=this.buildCastOptions(e);i.cast(null!==(t=e.src)&&void 0!==t?t:"",s)}}applyMetadata(e){if(void 0===e||null===this.localDriver)return;const t=this.localDriver;void 0!==e.title&&(t.title=e.title),void 0!==e.description&&(t.description=e.description),void 0!==e.poster&&(t.poster=e.poster)}bindDriverEvents(e,t){const i=this.localDriver;i.on("available",()=>{e.castAvailable=!0}),i.on("connect",()=>{e.isCasting=!0}),i.on("disconnect",()=>{const s=i.time;e.isCasting=!1,void 0!==s&&s>0?t.emit("cast-stop-with-position",{time:s}):t.emit("cast-stop")}),i.on("error",()=>{e.isCasting=!1,t.emit("cast-failed")})}buildCastOptions(e){const t=this.localDriver;return{title:null==t?void 0:t.title,description:null==t?void 0:t.description,poster:e.image}}registerAbortCleanup(){this.signal.addEventListener("abort",()=>{const e=this.localDriver;null!==e&&e.connected&&e.disconnect(),this.localDriver=null},{once:!0})}}class wt{constructor(){this.pollTimer=null}async start(e,t,i){if(void 0!==e.epgContentId&&(await this.fetchEpg(e,t),null!==e.epgPolling&&void 0!==e.epgPolling)){const s=1e3*e.epgPolling;this.pollTimer=setInterval(()=>{this.fetchEpg(e,t)},s),i.addEventListener("abort",()=>{clearInterval(this.pollTimer),this.pollTimer=null},{once:!0})}}async fetchEpg(e,t){const i=`https://epg.dev.easybroadcast.io/channels/${e.epgContentId}/last-24-h-programs`;try{const e=await A("epg:fetch",i,{mode:"cors"});if(!e.ok)throw new Error(`EPG fetch failed with status: ${e.status}`);const s=await e.json();t.epgPrograms=s,t.epgFetchedAt=Date.now()}catch(e){console.error("EBPlayer: Error fetching EPG data:",e)}}}class Ct{init(e,t,i,s){const n=e.playlist;n&&0!==n.length&&(t.playlist=n,t.currentEpisode=0,i.on("playlist-next",()=>{this.advance(t,1)},{signal:s}),i.on("playlist-prev",()=>{this.advance(t,-1)},{signal:s}))}advance(e,t){const i=e.playlist.length,s=(e.currentEpisode+t+i)%i;e.currentEpisode=s,e.src=e.playlist[s].src}}class Lt{constructor(){this.imaAdsManager=null,this.imaDisplayContainer=null}async init(e,t,i,s,n,r){if(!e.ad)return;let o=null,a=null,l=!1;const c=new AbortController;r.addEventListener("abort",()=>c.abort(),{once:!0});const d=()=>{null!==o&&(clearTimeout(o),o=null)},u=()=>{null!==a&&(clearTimeout(a),a=null)},h=()=>{l||(l=!0,d(),u(),null===this.imaAdsManager&&this.releaseImaResources(),t.adPlaying=!1,i.emit("ad-complete"),c.abort())};r.addEventListener("abort",()=>{d(),u(),this.releaseImaResources()},{once:!0});const v=e.autoplay?null:this.waitForUserGesture(s,c.signal);if(!(e.preroll&&(await new Promise(e=>{const t=()=>{d(),e()};i.on("intro-stream-complete",t,{signal:r}),r.addEventListener("abort",t,{once:!0}),o=setTimeout(()=>{console.warn("AdsManager: intro-stream-complete never arrived within the bound — falling through to the ad leg (G-07-9)"),t()},12e4)}),r.aborted)||(a=setTimeout(()=>{console.warn("AdsManager: ad leg produced no AdsManager within the bound — falling through to main (G-07-11)"),h()},2e4),null!==v&&await v,r.aborted||l)))try{const i=await E("https://imasdk.googleapis.com/js/sdkloader/ima3.js","google");if(l)return;const{ima:r}=i,o=new r.AdDisplayContainer(n,s);this.imaDisplayContainer=o,o.initialize();const a=new r.AdsLoader(o);a.addEventListener(r.AdErrorEvent.Type.AD_ERROR,e=>{console.warn("AdsManager: AD_ERROR (loader) — falling through to main",e),h()}),a.addEventListener(r.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>{if(l)return;const i=e.getAdsManager(s);this.imaAdsManager=i,u();const n=s.getBoundingClientRect(),o=n.width>0?n.width:640,a=n.height>0?n.height:360;i.addEventListener(r.AdEvent.Type.CONTENT_PAUSE_REQUESTED,()=>{console.log("AdsManager: CONTENT_PAUSE_REQUESTED — content paused (D-08-08)"),t.adPlaying=!0,s.pause()}),i.addEventListener(r.AdEvent.Type.CONTENT_RESUME_REQUESTED,()=>{console.log("AdsManager: CONTENT_RESUME_REQUESTED — content resumed (D-08-08)"),t.adPlaying=!1,V(s),h()}),i.addEventListener(r.AdEvent.Type.ALL_ADS_COMPLETED,()=>{console.log("AdsManager: ALL_ADS_COMPLETED — ad leg complete (D-08-08)"),h()}),i.addEventListener(r.AdErrorEvent.Type.AD_ERROR,e=>{console.warn("AdsManager: AD_ERROR (manager) — falling through to main",e),h()}),i.addEventListener(r.AdEvent.Type.SKIPPABLE_STATE_CHANGED,()=>{console.log("AdsManager: ad became skippable (D-08-06)")}),i.init(o,a),i.start()});const c=new r.AdsRequest;c.adTagUrl=e.ad,a.requestAds(c)}catch(e){console.warn("AdsManager: failed to load or initialize the IMA SDK — falling through to main (G-07-11)",e),h()}}releaseImaResources(){null!==this.imaAdsManager&&(this.imaAdsManager.destroy(),this.imaAdsManager=null),null!==this.imaDisplayContainer&&(this.imaDisplayContainer.destroy(),this.imaDisplayContainer=null)}waitForUserGesture(e,t){return new Promise(i=>{var s;const n=null!==(s=e.closest(".eb-player"))&&void 0!==s?s:e;let r=!1;const o=()=>{r||(r=!0,n.removeEventListener("click",a,{capture:!0}),i())},a=()=>o();n.addEventListener("click",a,{capture:!0}),t.addEventListener("abort",o,{once:!0})})}}class St{async init(e,t,i,s,n){if(!e.preroll)return;t.introStreamPlaying=!0;const r=new AbortController;n.addEventListener("abort",()=>r.abort(),{once:!0});let o=0,a=!1;const l=()=>{a||(a=!0,clearTimeout(o),t.introStreamPlaying=!1,i.emit("intro-stream-complete"),r.abort())},c=()=>l();s.addEventListener("ended",c),i.on("preroll-skip",l,{signal:r.signal}),i.on("error-fatal",()=>{console.warn("IntroStreamManager: intro stream errored — falling through to main"),l()},{signal:r.signal}),t.on("error",e=>{null!==e&&(console.warn("IntroStreamManager: intro stream errored via state.error — falling through to main"),l())},{signal:r.signal}),i.on("force-intro-complete",()=>{console.warn("IntroStreamManager: main is opening — force-completing the intro pass"),l()},{signal:r.signal}),o=setTimeout(()=>{console.warn("IntroStreamManager: intro stream exceeded INTRO_MAX_DURATION_MS — falling through to main"),l()},9e4),n.addEventListener("abort",()=>{s.removeEventListener("ended",c),clearTimeout(o)},{once:!0})}}var xt,At={exports:{}};var $t=(xt||(xt=1,function(e){var t,i,s,n,r=(t={fromVtt:function(e,t,s){var n=!!s;(e=(e=e.replace(/\r/g,"")).split(/(\d+)?\n?(\d{2}:\d{2}:\d{2}[,.]\d{3}) --> (\d{2}:\d{2}:\d{2}[,.]\d{3}).*\n/g)).shift();for(var r=[],o=0;o<e.length;o+=4){var a=e[o+3];n&&((a=a.split("\n")).shift(),a=a.join("\n")),0!==a.trim().length&&r.push({id:e[o]?+e[o].trim():r.length+1,startTime:i(e[o+1].trim(),t),endTime:i(e[o+2].trim(),t),text:a.trim()})}return r},toVtt:function(e){if(!e instanceof Array)return"";for(var t="",i=0;i<e.length;i++){var s=e[i];isNaN(s.startTime)||isNaN(s.endTime)||(s.startTime=n(parseInt(s.startTime,10)),s.endTime=n(parseInt(s.endTime,10))),t+=s.id+"\r\n",t+=s.startTime+" --\x3e "+s.endTime+"\r\n",t+=s.text.replace("\n","\r\n")+"\r\n\r\n"}return t}},i=function(e,t){return"ms"===t?s(e):"s"===t?s(e)/1e3:e},s=function(e){var t=/(\d+):(\d{2}):(\d{2})[,.](\d{3})/.exec(e);if(null===t)return 0;for(var i=1;i<5;i++)t[i]=parseInt(t[i],10),isNaN(t[i])&&(t[i]=0);return 36e5*t[1]+6e4*t[2]+1e3*t[3]+t[4]},n=function(e){var t=[36e5,6e4,1e3],i=[];for(var s in t){var n=(e/t[s]|0).toString();n.length<2&&(n="0"+n),e%=t[s],i.push(n)}var r=e.toString();if(r.length<3)for(s=0;s<=3-r.length;s++)r="0"+r;return i.join(":")+","+r},t);e.exports=r}(At)),At.exports);function _t(e){if(!e||!e.trim())return[];return $t.fromVtt(e,"s").map(e=>({title:e.text,startTime:e.startTime,endTime:e.endTime}))}class Mt{get signal(){return this.abortController.signal}get container(){return this._container}constructor(e){this.hasExplicitPrimaryColor=void 0!==e.primaryColor,this.config=p(h,e),this.state=r(),this.bus=new o,this.i18n=new y(this.config.lang),this.config.messages&&this.i18n.addMessages(this.config.messages),this.abortController=new AbortController,this._container=null,this.engineSync=null,this.skinRoot=null,this.commandHandler=null,this.chromecastManager=null,this.reloadCallback=null}mount(e){var t,i,s;this._container=e,e.textContent="",delete e._$litPart$,e.removeAttribute("data-theme"),e.removeAttribute("style"),this.config.skin&&"default"!==this.config.skin&&e.setAttribute("data-theme",this.config.skin);const n=this.config.skinColors;this.hasExplicitPrimaryColor&&this.config.primaryColor&&(e.style.setProperty("--eb-color-primary",this.config.primaryColor),e.style.setProperty("--eb-color-progress",this.config.primaryColor),e.style.setProperty("--eb-accent",this.config.primaryColor)),(null==n?void 0:n.general)&&(e.style.setProperty("--eb-color-primary",n.general),e.style.setProperty("--eb-color-progress",n.general),e.style.setProperty("--eb-accent",n.general)),(null==n?void 0:n.progressBar)&&e.style.setProperty("--eb-color-progress",n.progressBar),(null==n?void 0:n.volumeBar)&&e.style.setProperty("--eb-color-volume",n.volumeBar),this.state.isRtl=null!==(t=this.config.rtl)&&void 0!==t?t:"ar"===this.config.lang,this.state.isRadio=!0===this.config.radio;const r=new bt;this.skinRoot=r,r.connect(e,this.state,this.bus,this.config,this.i18n);const o=r.getVideoElement();null!==o&&(this.state.muted=o.muted,this.state.volume=o.volume),this.config.noUi||(new yt(e,this.state,this.signal),new kt(e,this.state,this.bus,this.config,this.signal)),this.initIntegrations();const a=null!==(s=null===(i=this.skinRoot)||void 0===i?void 0:i.getVideoElement())&&void 0!==s?s:null;null!==a&&(this.commandHandler=new N(this.bus,a,this.state,()=>this.engineSync,this.chromecastManager,this.i18n,()=>{var e;null===(e=this.reloadCallback)||void 0===e||e.call(this)},this.signal))}setReloadCallback(e){this.reloadCallback=e}getSavedSelections(){return null!==this.commandHandler?this.commandHandler.getSavedSelections():{quality:-1,audioTrack:0,subtitleTrack:-1}}setEngineSync(e){null!==this.engineSync&&this.engineSync.detach(),this.engineSync=e,e.attach(this.state,this.signal)}dispose(){null!==this.engineSync&&(this.engineSync.detach(),this.engineSync=null),this.bus.dispose(),this.abortController.abort(),null!==this.skinRoot&&(this.skinRoot.disconnect(),this.skinRoot=null),this._container=null,this.commandHandler=null,this.chromecastManager=null,this.reloadCallback=null,this.abortController=new AbortController}loadChapters(e,t,i){/^https?:\/\//i.test(e.trim())?async function(e){try{const t=await A("chapters:fetch",e);return _t(await t.text())}catch(e){return[]}}(e).then(e=>{i.aborted||(t.chapters=e)}):t.chapters=_t(e)}initIntegrations(){var e,t;const{config:i,state:s,bus:n,signal:r}=this;if(i.chromecast){const e=new Tt(this.abortController);this.chromecastManager=e,e.init(i,s,n).catch(e=>{console.error("EBPlayer: ChromecastManager init failed:",e)})}if(i.epgContentId){(new wt).start(i,s,r).catch(e=>{console.error("EBPlayer: EpgManager start failed:",e)})}const o=i.playlist;if(o&&o.length>0){(new Ct).init(i,s,n,r)}if(i.ad&&null!==this.skinRoot){const e=this.skinRoot.getVideoElement(),t=this.skinRoot.getAdsContainer();if(null!==e&&null!==t){(new Lt).init(i,s,n,e,t,r).catch(e=>{console.error("EBPlayer: AdsManager init failed:",e)})}}if(i.chapters&&this.loadChapters(i.chapters,s,r),i.preroll&&null!==this.skinRoot){const e=new St,t=this.skinRoot.getVideoElement();null!==t&&e.init(i,s,n,t,r).catch(e=>{console.error("EBPlayer: IntroStreamManager init failed:",e)})}if(i.posterStream){const n=function(){let e=null;return{attach({src:t,container:i,Hls:s}){console.log("Poster HLS: attach media",t,i),e=new s,e.loadSource(t),e.attachMedia(i)},close(){var t,i;if(e){try{null===(t=e.detachMedia)||void 0===t||t.call(e),null===(i=e.destroy)||void 0===i||i.call(e)}catch(e){console.error("Poster HLS player close error:",e)}e=null}},play(){(null==e?void 0:e.media)&&V(e.media)},pause(){var t;null===(t=null==e?void 0:e.media)||void 0===t||t.pause()}}}(),o=null!==(t=null===(e=this.skinRoot)||void 0===e?void 0:e.getPosterVideoElement())&&void 0!==t?t:null;s.on("playbackState",e=>{if("playing"===e){if(null!==o){const e=window.Hls;e&&n.attach({src:i.posterStream,container:o,Hls:e})}n.play()}else"paused"!==e&&"buffering"!==e||n.pause()},{signal:r}),r.addEventListener("abort",()=>{n.close()},{once:!0})}}}class Pt{}"function"==typeof SuppressedError&&SuppressedError;class Rt{constructor(e){this.intervalId=null,this.lastTime=null,this.stallAttempts=0,this.video=e.video,this.onRecoverAttempt=e.onRecoverAttempt,this.onReloadRequired=e.onReloadRequired,this.isCasting=e.isCasting}start(){this.stop(),this.intervalId=setInterval(()=>{this.tick()},1e4)}stop(){null!==this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.lastTime=null,this.stallAttempts=0}tick(){if(this.video.paused||this.video.seeking||this.video.readyState<3||this.isCasting())return this.lastTime=null,void(this.stallAttempts=0);const e=this.video.currentTime;null!==this.lastTime&&e===this.lastTime?(this.stallAttempts+=1,this.stallAttempts<=2?this.onRecoverAttempt(this.stallAttempts):(this.onReloadRequired(),this.stop())):(this.stallAttempts=0,this.lastTime=e)}}class Bt extends Pt{constructor(){super(),this.video=null,this.state=null,this.signal=null,this.bus=null,this.config=null,this.loadSourceUrl="",this.watchdog=null,this.videoListeners=[],this.driverReady=new Promise(e=>{this.resolveDriverReady=e})}attach(e,t){this.state=e,this.signal=t,this.onAttach()}detach(){var e;null===(e=this.watchdog)||void 0===e||e.stop(),this.watchdog=null,this.unbindVideoEvents(),this.onDetach(),this.video=null,this.state=null,this.signal=null,this.bus=null,this.config=null,this.loadSourceUrl=""}startWatchdog(){if(!this.video||!this.bus)return;const e=this.bus;this.watchdog=new Rt({video:this.video,onRecoverAttempt:e=>{this.recoverFromStall(e)},onReloadRequired:()=>{e.emit("request-reload")},isCasting:()=>{var e,t;return null!==(t=null===(e=this.state)||void 0===e?void 0:e.isCasting)&&void 0!==t&&t}}),this.watchdog.start()}stopWatchdog(){var e;null===(e=this.watchdog)||void 0===e||e.stop(),this.watchdog=null}setConfig(e){this.config=e}setBus(e){this.bus=e}setVideo(e){this.video=e}setLoadSource(e){this.loadSourceUrl=e}bindVideoEvents(e,t,i){var s,n;const r=(t,i,s)=>{e.addEventListener(t,i,s),this.videoListeners.push({video:e,type:t,listener:i})},o=null!==(n=null===(s=this.config)||void 0===s?void 0:s.syncLiveMargin)&&void 0!==n?n:30;r("timeupdate",()=>{t.currentTime=Math.round(e.currentTime),t.isLive&&(t.isSyncWithLive=e.currentTime+o>e.duration)},{signal:i}),r("durationchange",()=>{t.duration=Math.ceil(e.duration)},{signal:i}),r("volumechange",()=>{t.volume=e.volume,t.muted=e.muted},{signal:i}),r("progress",()=>{e.buffered.length>0&&(t.bufferedEnd=e.buffered.end(e.buffered.length-1))},{signal:i}),r("ratechange",()=>{t.playbackRate=e.playbackRate},{signal:i});let a=!1;r("playing",()=>{a=!1,t.playbackState="playing"},{signal:i}),r("waiting",()=>{t.playbackState="buffering"},{signal:i}),r("pause",()=>{e.seeking||("buffering"!==t.playbackState||e.ended?t.playbackState="paused":a=!0)},{signal:i}),r("seeked",()=>{t.isLive&&(t.currentTime=Math.round(e.currentTime),t.isSyncWithLive=e.currentTime+o>e.duration),(a||"loading"===t.playbackState)&&e.paused&&(t.playbackState="paused",a=!1)},{signal:i}),r("ended",()=>{t.playbackState="ended"},{signal:i}),r("timeupdate",()=>{("buffering"===t.playbackState||"loading"===t.playbackState)&&!e.paused&&(t.playbackState="playing")},{signal:i})}unbindVideoEvents(){for(const{video:e,type:t,listener:i}of this.videoListeners)e.removeEventListener(t,i);this.videoListeners=[]}seek(e){null!==this.video&&(this.video.currentTime=e)}}const Dt=Object.freeze({EASY_B:"easy_b",BUNNY:"bunny",AKAMAI:"akamai",VENOM:"venom"}),Ft=Object.freeze({UNKNOWN:"unknown",MAX_RETRY:"max_retry",FORBIDDEN:"forbidden"});class Ot extends Error{constructor({status:e="unknown",errorCode:t="unknown",errorType:i=Ft.UNKNOWN,message:s=null}){super(null!=s?s:`TokenError: ${e} - ${t}`),this.status=e,this.errorCode=t,this.errorType=i}}class Vt{constructor({src:e,responseParameters:t,error:i=null,extras:s={}}){if(this.src=e,this.responseParameters=t,this.extras=null!=s?s:{},null!==i&&!(i instanceof Ot))throw new Error("TokenResponse error must be an instance of TokenError");this.error=i}static fromJson({src:e,json:t}){var i,s,n;const r=JSON.parse(t),o={token:null!==(i=r.token)&&void 0!==i?i:null,tokenPath:null!==(s=r.token_path)&&void 0!==s?s:null,expires:null!==(n=r.expires)&&void 0!==n?n:null},a=new Vt({src:e,responseParameters:o});for(const e of Object.keys(r))["token","expires","token_path"].includes(e)||(a.extras[e]=r[e]);return a}static fromAkamai({src:e,text:t}){const i=Nt({src:e,text:t});return new Vt({src:e,responseParameters:i})}static fromText({src:e,text:t}){var i,s;if(t.trim().startsWith("{"))return Vt.fromJson({src:e,json:t});const n=Ht(t);if(n){const t=Object.assign({token:null,tokenPath:null},n);return new Vt({src:e,responseParameters:t})}const r=new URLSearchParams(t.trim().replace(/^\?/,"")),o=null!==(i=r.get("token"))&&void 0!==i?i:null,a=r.get("expires"),l=a?parseInt(a,10):null,c=null!==(s=r.get("token_path"))&&void 0!==s?s:null,d=new Vt({src:e,responseParameters:{token:o,tokenPath:c,expires:l}});return r.forEach((e,t)=>{["token","expires","token_path"].includes(t)||(d.extras[t]=e)}),d}static fromDefault({src:e,text:t}){var i;const s=new URLSearchParams(t.trim().replace(/^\?/,"")),n=s.get("expires"),r={verify:null!==(i=s.get("verify"))&&void 0!==i?i:null,expires:n?parseInt(n,10):null},o=new Vt({src:e,responseParameters:r});return s.forEach((e,t)=>{["verify","expires"].includes(t)||(o.extras[t]=e)}),o}static fromError({src:e,error:t}){const i=t instanceof Ot?t:new Ot(t);return new Vt({src:e,error:i})}}function Nt({src:e,text:t}){var i,s;const n=null!==(s=null===(i=Ht(t))||void 0===i?void 0:i.fullUrl)&&void 0!==s?s:null,r=new URL(null!=n?n:`${e}${t?`?${t}`:""}`);let o=null,a=null,l=null,c=null,d=null;const u=new URLSearchParams(r.search);if(o=u.get("hdntl"),d=u.get("hdnea"),!o&&!d){const e=r.pathname.split("/");for(const t of e){if(t.startsWith("hdntl=")){o=t.substring(6);break}if(t.startsWith("hdnea=")){d=t.substring(6);break}}}const h=null!=o?o:d;if(h){const e=h.match(/exp=(\d+)/);e&&(a=e[1]);const t=h.match(/hmac=([a-f0-9]+)/);t&&(l=t[1]);const i=h.match(/acl=([^~]+)/);i&&(c=i[1])}return{expires:a,hdntl:h,hmac:l,acl:c,hdnea:d,fullUrl:n}}const It=/^https?:\/\//i;function Ht(e){const t=e.trim();if(!It.test(t))return null;const i=new URL(t).searchParams.get("expires");return i?{fullUrl:t,expires:parseInt(i,10)}:{fullUrl:t,expires:Nt({src:t,text:""}).expires}}function jt(e){var t;const i=null==e?void 0:e.responseParameters;return i&&"fullUrl"in i&&null!==(t=i.fullUrl)&&void 0!==t?t:null}function Ut(e){const t=null==e?void 0:e.responseParameters,i=jt(e);if(!e||!t||!i)return null;const s=new URL(e.src),n=new URL(i);if(!n.pathname.endsWith(s.pathname))return null;const r=n.pathname.slice(0,n.pathname.length-s.pathname.length);return{fullUrl:i,originalBase:s.origin,rewrittenBase:n.origin+r,search:n.search,expires:t.expires}}function zt(e,t){if(!e.startsWith(`${t.rewrittenBase}/`))return null;const i=new URL(t.originalBase+e.slice(t.rewrittenBase.length));return i.searchParams.delete("hdnea"),i.searchParams.delete("hdntl"),i.toString()}function qt(e,t){var i;const s=new URL(null!==(i=zt(e,t))&&void 0!==i?i:e);if(s.origin!==t.originalBase)return null;s.searchParams.delete("hdnea"),s.searchParams.delete("hdntl");const n=s.search,r=n?`${n}&${t.search.slice(1)}`:t.search;return`${t.rewrittenBase}${s.pathname}${r}`}function Wt(e){return new Promise(t=>{setTimeout(t,e)})}class Gt{constructor({token:e,tokenType:t,srcInTokenRequest:i=!1,extraParamsCallback:s=null,onCDNTokenError:n,maxRetries:r=3,retryInterval:o=1e4,expirationMarginInSeconds:a=30}){const l=Object.values(Dt);void 0!==t&&l.includes(t)?this.tokenType=t:this.tokenType=void 0,this.tokenGeneratorUrl=e,this.srcInTokenRequest=i,this.extraParamsCallback=s&&"function"==typeof s?s:null,this.callbackError=n&&"function"==typeof n?n:null,this.attempt=0,this.maxRetries=r,this.retryInterval=o,this.expirationMarginInSeconds=a,this.lastTokenResponse=null,this.sourceUrl=null,this.resetAttemptCounterTimeout=null,this.inFlightFetch=null,this.cdnRejectionCount=0,this.forceRefreshOnce=!1}resetAttemptCounter(){this.resetAttemptCounterTimeout||(this.resetAttemptCounterTimeout=setTimeout(()=>{this.attempt=0},3e4))}async _fetchDefaultToken(e,t=null){const i=new URL(e);if(["verify","expires"].forEach(e=>i.searchParams.delete(e)),this.attempt>=this.maxRetries)return this.resetAttemptCounter(),Vt.fromError({src:i.toString(),error:new Ot({status:null==t?void 0:t.status,errorCode:"Unauthorized",errorType:Ft.MAX_RETRY})});try{let t;if(this.attempt+=1,t=!0===this.srcInTokenRequest?await A("cdn-token:default",`${this.tokenGeneratorUrl}?url=${encodeURIComponent(i.toString())}`):await A("cdn-token:default",this.tokenGeneratorUrl),403===t.status)return await Wt(this.retryInterval),this._fetchDefaultToken(e,t);if(t.status>=400)return Vt.fromError({src:i.toString(),error:new Ot({status:t.status})});this.attempt=0;const s=await t.text();return Vt.fromDefault({src:i.toString(),text:s})}catch(e){return console.error("CDNToken: Error fetching default token ",e),Vt.fromError({src:i.toString(),error:e})}}async _fetchEasyBToken(e,t=null){var i,s,n,r;if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),Vt.fromError({src:e,error:new Ot({status:null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.status,errorCode:null!==(n=null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorCode)&&void 0!==n?n:"Unauthorized",errorType:Ft.MAX_RETRY})});try{this.attempt+=1;const i={};if(this.extraParamsCallback){const e=await this.extraParamsCallback(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.status);(null==e?void 0:e.accessToken)&&(i.Authorization=`Bearer ${String(e.accessToken)}`)}else console.warn("CDNToken: no extraParamsCallback provided");let s;if(s=!0===this.srcInTokenRequest?await A("cdn-token:easy_b",`${this.tokenGeneratorUrl}?url=${encodeURIComponent(e)}`,{method:"GET",headers:i}):await A("cdn-token:easy_b",this.tokenGeneratorUrl,{method:"POST",headers:i,body:JSON.stringify({streamUrl:e})}),s.status>=400){const t=Vt.fromError({src:e,error:new Ot({status:s.status})});return 403===s.status?(await Wt(this.retryInterval),this._fetchEasyBToken(e,t)):t}this.attempt=0;const n=await s.text();return Vt.fromText({src:e,text:n})}catch(t){return console.error("CDNToken: Error fetching token ",t),Vt.fromError({src:e,error:t})}}async _fetchAkamaiToken(e,t=null){if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),Vt.fromError({src:e,error:new Ot({status:null==t?void 0:t.status,errorCode:"Unauthorized",errorType:Ft.MAX_RETRY})});try{this.attempt+=1;const t=await A("cdn-token:akamai",`${this.tokenGeneratorUrl}?url=${encodeURIComponent(e)}`);if(403===t.status)return await Wt(this.retryInterval),this._fetchAkamaiToken(e,t);if(t.status>=400)return Vt.fromError({src:e,error:new Ot({status:t.status})});this.attempt=0;const i=await t.text();return Vt.fromAkamai({src:e,text:i})}catch(t){return console.error("CDNToken: Error fetching token ",t),Vt.fromError({src:e,error:t})}}async _fetchBunnyToken(e,t=null){var i,s,n,r,o,a,l,c;if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),Vt.fromError({src:e,error:new Ot({status:null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.status,errorCode:null!==(n=null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorCode)&&void 0!==n?n:"Unauthorized",errorType:Ft.MAX_RETRY})});try{this.attempt+=1;const i={"Content-Type":"application/json"};if(this.extraParamsCallback){const e=await this.extraParamsCallback(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.status);(null==e?void 0:e.accessToken)&&(i.Authorization=`Bearer ${String(e.accessToken)}`)}else console.warn("CDNToken: no extraParamsCallback provided");const s=await A("cdn-token:bunny",this.tokenGeneratorUrl,{method:"POST",headers:i,body:JSON.stringify({streamUrl:e})});if(s.status>=400){const t=s.headers.get("content-type"),i=(null==t?void 0:t.includes("application/json"))?await s.json():await s.text(),n="object"==typeof i&&null!==i&&null!==(a=null===(o=i.error)||void 0===o?void 0:o.errorCode)&&void 0!==a?a:"Unauthorized",r="object"==typeof i&&null!==i&&null!==(c=null===(l=i.error)||void 0===l?void 0:l.__type)&&void 0!==c?c:Ft.UNKNOWN,d=new Ot({status:s.status,errorCode:n,errorType:r}),u=Vt.fromError({src:e,error:d});return[403,401,498].includes(s.status)?(this.callbackError?this.callbackError({status:d.status,errorCode:d.errorCode,errorType:d.errorType}):console.warn(`CDNToken: Bunny token fetch attempt ${this.attempt} for ${e} failed with status ${s.status}, retrying in ${this.retryInterval/1e3}s`),await Wt(this.retryInterval),this._fetchBunnyToken(e,u)):(console.error(`CDNToken: error generating Bunny token on attempt ${this.attempt}`,JSON.stringify(u)),u)}const n=await s.json();return this.attempt=0,Number.isInteger(n.max_retries)&&n.max_retries>0&&(this.maxRetries=n.max_retries),Number.isInteger(n.retry_interval)&&n.retry_interval>0&&(this.retryInterval=1e3*n.retry_interval),Vt.fromJson({src:e,json:JSON.stringify(n)})}catch(t){return console.error("CDNToken: Error fetching bunny token:",t),Vt.fromError({src:e,error:t})}}async fetchToken({src:e}){if(!e)return console.warn("CDNToken: Missing src to tokenize"),null;if(this.inFlightFetch)return this.inFlightFetch;return this.inFlightFetch=(async()=>{switch(this.tokenType){case Dt.BUNNY:return this._fetchBunnyToken(e);case Dt.AKAMAI:return this._fetchAkamaiToken(e);case Dt.VENOM:case Dt.EASY_B:return this._fetchEasyBToken(e);default:return this._fetchDefaultToken(e)}})().then(e=>(this.lastTokenResponse=e,this.inFlightFetch=null,e)).catch(e=>{throw this.inFlightFetch=null,e}),this.inFlightFetch}async updateUrlWithTokenParams({url:e}){var t,i,s,n;const r=new URL(e),o=r.searchParams.get("expires"),a=this.forceRefreshOnce;switch(a&&(this.forceRefreshOnce=!1),this.tokenType){case Dt.AKAMAI:{const t=Nt({src:e,text:""});if(!a&&!this.isTokenExpired(t.expires))return e;const i=Ut(this.lastTokenResponse),s=i&&!this.isTokenExpired(i.expires)?qt(e,i):null;if(s)return s;const n=r.pathname.split("/");r.pathname=n.filter(e=>!e.startsWith("hdntl=")&&!e.startsWith("hdnea=")).join("/"),r.searchParams.delete("hdnea"),r.searchParams.delete("hdntl");break}case Dt.EASY_B:case Dt.VENOM:case Dt.BUNNY:{if(!a&&!this.isTokenExpired(o))return e;["token","expires","token_path"].forEach(e=>r.searchParams.delete(e));const i=this.lastTokenResponse;if(i){const s=i.responseParameters;if(s&&!this.isTokenExpired(s.expires)){const n=Ut(i);if(n)return null!==(t=qt(e,n))&&void 0!==t?t:e;const{token:r,expires:o,tokenPath:a}=s;return Gt.appendTokenParams(e,r,o,a)}}break}default:if(!a&&!this.isTokenExpired(o))return e}const l=this.tokenType===Dt.EASY_B||this.tokenType===Dt.VENOM||this.tokenType===Dt.BUNNY,c=Ut(this.lastTokenResponse),d=null!==(i=c&&zt(r.toString(),c))&&void 0!==i?i:r.toString(),u=l&&this.sourceUrl?this.sourceUrl:d;try{const t=await this.fetchToken({src:u});if(null===t)return e;if(t.error)return this.callbackError&&this.callbackError({status:t.error.status,errorCode:t.error.errorCode,errorType:t.error.errorType}),e;const i=jt(t);if(i){if(t.src===d)return i;const e=Ut(t),s=e?qt(d,e):null;if(s)return s}switch(this.tokenType){case Dt.BUNNY:case Dt.VENOM:case Dt.EASY_B:{const i=t.responseParameters;return Gt.appendTokenParams(e,i.token,i.expires,i.tokenPath)}case Dt.AKAMAI:{const i=t.responseParameters;return Gt.appendAkamaiTokenParams(e,null!==(n=null!==(s=i.hdntl)&&void 0!==s?s:i.hdnea)&&void 0!==n?n:"")}default:return Gt.appendDefaultTokenParams(e,t)}}catch(t){return console.error("CDNToken: Error while fetching new token:",t),e}}isTokenExpired(e){if(null==e)return!0;const t=Math.floor(Date.now()/1e3)+this.expirationMarginInSeconds;return Number(e)<t}notifyCdnRejection(){return!(this.cdnRejectionCount>=this.maxRetries)&&(this.cdnRejectionCount+=1,this.forceRefreshOnce=!0,this.lastTokenResponse=null,!0)}resetCdnRejectionCount(){this.cdnRejectionCount=0}destroy(){this.resetAttemptCounterTimeout&&(clearTimeout(this.resetAttemptCounterTimeout),this.resetAttemptCounterTimeout=null),this.attempt=0,this.lastTokenResponse=null,this.inFlightFetch=null,console.log("CDNTokenManager: destroyed")}static appendTokenParams(e,t,i,s){const n=new URL(e);return t&&(n.searchParams.set("token",t),null!==i&&n.searchParams.set("expires",String(i)),s&&n.searchParams.set("token_path",s)),n.toString()}static appendAkamaiTokenParams(e,t){const i=new URL(e);return i.searchParams.delete("hdnea"),i.searchParams.delete("hdntl"),i.searchParams.set("hdnea",t),i.toString()}static appendDefaultTokenParams(e,t){const i=new URL(e),s=t.responseParameters;return(null==s?void 0:s.verify)&&i.searchParams.set("verify",s.verify),null!==(null==s?void 0:s.expires)&&void 0!==(null==s?void 0:s.expires)&&i.searchParams.set("expires",String(s.expires)),i.toString()}}function Qt(e){const t={};for(const i of Object.keys(e)){const s=Object.assign({},e[i]);!s.serverURL&&s.licenseUrl&&(s.serverURL=s.licenseUrl),t[i]=s}return t}class Yt{constructor(e){this.tokenManager=e}buildHlsConfig(e){if(!e.emeEnabled)return{};const t=this.tokenManager;return Object.assign(Object.assign({emeEnabled:e.emeEnabled},void 0!==e.drmSystems&&{drmSystems:Qt(e.drmSystems)}),{licenseXhrSetup:async(e,i)=>{var s,n;if(null==t?void 0:t.extraParamsCallback){const i=await t.extraParamsCallback().catch(e=>(console.error("DrmConfigurator: extraParamsCallback error:",e),null));(null==i?void 0:i.accessToken)&&e.setRequestHeader("Authorization",`Bearer ${i.accessToken}`)}const r=null===(n=null===(s=null==t?void 0:t.lastTokenResponse)||void 0===s?void 0:s.extras)||void 0===n?void 0:n.drm_custom_data;if(r){const t=new URL(i);t.searchParams.delete("customdata"),t.searchParams.append("customdata",r),e.open("POST",t.toString(),!0)}else e.open("POST",i,!0)}})}}const Kt=new Set(["keySystemError"]);function Xt(e,t){const i=new Map,s=new Set,n=new Set;let r,o=!1;e.on("hlsError",(a,l)=>{var c,d,u,h,v;const g=null!==(c=l.details)&&void 0!==c?c:l.type,p=null===(d=e.media)||void 0===d?void 0:d.currentTime;if(void 0!==p&&void 0!==r&&p>r+1&&(i.clear(),s.clear()),r=p,l.fatal){if(Kt.has(l.type)){if(n.has(g))return;return n.add(g),console.error(`HLS Retry: Unrecoverable error "${g}" — cannot fix by retrying.`,a,l),void(null===(u=null==t?void 0:t.onUnrecoverableError)||void 0===u||u.call(t,`DRM error: ${g}`))}if(void 0!==(null==t?void 0:t.onFatalNetworkError)){if(o)return;return o=!0,console.warn(`HLS Retry: Fatal error on intro pass — signalling fall-through (${g}).`,a,l),void t.onFatalNetworkError(g)}return console.warn("HLS Retry: Fatal error, trying to fix now.",a,l),void setTimeout(()=>{var t,i;"mediaError"===l.type?e.recoverMediaError():e.startLoad(null!==(i=null===(t=e.media)||void 0===t?void 0:t.currentTime)&&void 0!==i?i:-1)},1e3)}if(s.has(g))return;const m=(null!==(h=i.get(g))&&void 0!==h?h:0)+1;if(i.set(g,m),m>3)return console.warn(`HLS Retry: Non-fatal "${g}" exceeded 3 retries, giving up.`,a,l),void s.add(g);console.warn(`HLS Retry: Non-fatal error (${m}/3), monitoring.`,a,l);const f=null===(v=e.media)||void 0===v?void 0:v.currentTime;setTimeout(()=>{var n,r,o;if(f!==(null===(n=e.media)||void 0===n?void 0:n.currentTime)||(null==t?void 0:t.chromecast_casting))console.info("HLS Retry: Stream is playing, no action needed",a,l),i.delete(g),s.delete(g);else{if(function(e,t){if(null===e||!0===(null==t?void 0:t.isLive))return!1;const{duration:i,buffered:s,currentTime:n}=e;return!(!Number.isFinite(i)||i<=0)&&!(i-n>1)&&0!==s.length&&s.end(s.length-1)>=i-1}(e.media,t))return void console.info("HLS Retry: near VOD end, letting hls.js finish naturally",a,l);console.warn("HLS Retry: Stream is stuck, trying to fix",a,l),"mediaError"===l.type?e.recoverMediaError():e.startLoad(null!==(o=null===(r=e.media)||void 0===r?void 0:r.currentTime)&&void 0!==o?o:-1)}},3e3)})}function Jt(e,t){const i=e.trigger;e.trigger=function(e,s){var n,r,o;if(e===t.AUDIO_TRACK_LOADED){const e=s;if(null==e?void 0:e.details){const t=this.currentLevel>=0?this.currentLevel:0,i=null===(r=null===(n=this.levels)||void 0===n?void 0:n[t])||void 0===r?void 0:r.details;if(i&&e.details.endCC>i.endCC){const t=i.endCC,s=e.details.fragments;if(s)for(let e=0;e<s.length;e++)s[e].cc>t&&(s[e].cc=t);void 0!==(null===(o=e.details.fragmentHint)||void 0===o?void 0:o.cc)&&e.details.fragmentHint.cc>t&&(e.details.fragmentHint.cc=t),e.details.endCC=t}}}return i.call(this,e,s)}}const Zt=Object.freeze([Dt.EASY_B,Dt.VENOM,Dt.BUNNY]);function ei(e,t){try{const i=new URL(t),s=i.searchParams.get("token");if(!s)return e;const n=i.searchParams.get("expires"),r=i.searchParams.get("token_path");return Gt.appendTokenParams(e,s,n,r)}catch(t){return e}}function ti(e,t){let i=!1;function s(e){const s=e.load.bind(e);e.load=function(e,n,r){var o;const a=t.tokenType;if(!a||!Zt.includes(a)){const t=function(e){return`signSegmentsWithCdnToken: segment signing is not supported for ${void 0===e?"no token type configured":`token type "${e}"`}. Supported token types: ${Zt.join(", ")}.`}(a);return i||(i=!0,console.error(t)),void r.onError({code:0,text:t},e,null,{aborted:!1,loaded:0,total:0,retry:0,chunkCount:0,bwEstimate:0,loading:{start:0,first:0,end:0},parsing:{start:0,end:0},buffering:{start:0,first:0,end:0}})}const l=null===(o=e.frag)||void 0===o?void 0:o.baseurl;if(!l||!e.url)return void s(e,n,r);const{hasToken:c,expires:d}=function(e){try{const t=new URL(e);return t.searchParams.get("token")?{hasToken:!0,expires:t.searchParams.get("expires")}:{hasToken:!1,expires:null}}catch(e){return{hasToken:!1,expires:null}}}(l);if(c)return t.isTokenExpired(d)?void t.updateUrlWithTokenParams({url:e.url}).then(t=>{e.url=t,s(e,n,r)}).catch(()=>{e.url=ei(e.url,l),s(e,n,r)}):(e.url=ei(e.url,l),void s(e,n,r));s(e,n,r)}}function n(t){if(new.target){const i=Reflect.construct(e,[t],new.target);return s(i),i}e.call(this,t),s(this)}return n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n}class ii extends Bt{constructor(){super(...arguments),this.driver=null,this.tokenManager=null,this.autoQuality=!0,this.eventState=null,this.loadNeverStartedTimer=0,this.liveSyncDisabled=!1}getDriver(){return this.driver}getTokenManager(){return this.tokenManager}async onAttach(){if(this.state){this.state.playbackState="loading";try{await this.init()}catch(e){console.error("HlsEngine: init failed",e),this.state&&F(this.state,this.bus,M,e instanceof Error?e.message:String(e))}}}onDetach(){if(this.stopWatchdog(),this.clearLoadNeverStartedWatchdog(),null!==this.driver){try{this.driver.detachMedia(),this.driver.destroy()}catch(e){console.error("HlsEngine: error during driver teardown",e)}this.driver=null}this.tokenManager=null,this.eventState=null}recoverFromStall(e){var t,i;this.driver&&(1===e?(console.warn("HlsEngine stall recovery: recoverMediaError"),this.driver.recoverMediaError()):(console.warn("HlsEngine stall recovery: startLoad"),this.driver.startLoad(null!==(i=null===(t=this.video)||void 0===t?void 0:t.currentTime)&&void 0!==i?i:-1)))}setQuality(e){null!==this.driver&&(this.driver.currentLevel=e,this.autoQuality=-1===e,null!==this.state&&(this.state.currentQuality=e))}setAudioTrack(e){null!==this.driver&&(this.driver.audioTrack=e)}setSubtitle(e){null!==this.driver&&(this.driver.subtitleTrack=e)}setPlaybackRate(e){null!==this.video&&(this.video.playbackRate=e)}seek(e){var t;if(null===this.video)return;if(!this.liveSyncDisabled&&null!==this.driver&&(null===(t=this.state)||void 0===t?void 0:t.isLive)){const e=this.driver.config;e.liveSyncDurationCount=0,e.liveMaxLatencyDurationCount=1/0,this.liveSyncDisabled=!0}const i=this.video.ended;if(this.video.currentTime=e,i&&null!==this.driver){this.state&&(this.state.playbackState="loading");const t=this.driver;setTimeout(()=>t.startLoad(e),0)}}seekToLive(){if(null===this.video)return;const e=this.video.duration;Number.isFinite(e)&&(this.video.currentTime=e-30)}get detached(){return null===this.state}async init(){var e;const{config:t,video:i,state:s,signal:n}=this;if(!(t&&i&&s&&n))return;const r=t.hlsjs;if(!r)throw new Error("HlsEngine: config.hlsjs URL is required");t.token&&(this.tokenManager=new Gt({token:t.token,tokenType:t.tokenType,srcInTokenRequest:t.srcInTokenRequest,extraParamsCallback:null!==(e=t.engineSettings.extraParamsCallback)&&void 0!==e?e:t.extraParamsCallback,onCDNTokenError:t.engineSettings.onCDNTokenError}));const o=await E(r,"Hls");if(this.detached)return;const a=new Yt(this.tokenManager).buildHlsConfig(t.engineSettings),l=this.tokenManager,c=t.engineSettings,{emeEnabled:d,drmSystems:u}=c,h=function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(i[s[n]]=e[s[n]])}return i}(c,["emeEnabled","drmSystems"]),v=Object.assign({},h);delete v.extraParamsCallback,delete v.onCDNTokenError,delete v.signSegmentsWithCdnToken;const g=Object.assign(Object.assign(Object.assign({enableWorker:!0,backBufferLength:30},v),a),{startPosition:t.startAt});if(l){const e=l;class i extends o.DefaultConfig.loader{constructor(t){super(t);const i=this.load.bind(this);this.load=function(t,s,n){if(!t.url)return void i(t,s,n);if(!new URL(t.url).pathname.split("/").pop().endsWith(".m3u8"))return void i(t,s,n);const r=Object.assign(Object.assign({},n),{onSuccess:(t,i,s)=>{e.resetCdnRejectionCount(),n.onSuccess(t,i,s)},onError:(t,i,s)=>{403===(null==t?void 0:t.code)&&e.notifyCdnRejection(),n.onError(t,i,s)}});e.updateUrlWithTokenParams({url:t.url}).then(e=>{t.url=e,i(t,s,r)}).catch(()=>{i(t,s,r)})}}}if(g.pLoader=i,!0===t.engineSettings.signSegmentsWithCdnToken){const t=ti(o.DefaultConfig.loader,e);g.fLoader=t,g.loader=t}}if(!t.disableCustomAbr)try{const{createHlsAbrController:e}=await Promise.resolve().then(function(){return Ei});if(this.detached)return;g.abrController=e(o)}catch(e){console.warn("HlsEngine: failed to load custom ABR controller, using default",e)}if(this.detached)return;const p=new o(g);this.driver=p,Jt(p,o.Events);const m=Boolean(t.preroll)&&this.loadSourceUrl===t.preroll;if(t.retry&&Xt(p,Object.assign({get chromecast_casting(){return s.isCasting},get isLive(){return s.isLive},onUnrecoverableError:e=>{var t;this.stopWatchdog(),this.state&&F(this.state,this.bus,R,e),null===(t=this.bus)||void 0===t||t.emit("error-fatal",{code:"DRM",message:e})}},m?{onFatalNetworkError:e=>{var t;this.stopWatchdog(),null===(t=this.bus)||void 0===t||t.emit("error-fatal",{code:"NETWORK",message:`Intro stream error: ${e}`})}}:{})),t.useGeoblockingErrorHandle){const e=this.bus;p.on(o.Events.ERROR,(t,i)=>{var s;const n=i;(null==n?void 0:n.type)!==o.ErrorTypes.NETWORK_ERROR||"manifestLoadError"!==(null==n?void 0:n.details)&&"levelLoadError"!==(null==n?void 0:n.details)||403!==(null===(s=null==n?void 0:n.response)||void 0===s?void 0:s.code)||(null==e||e.emit("geoblock-detected"),window.dispatchEvent(new CustomEvent("geoblock",{detail:{title:"Geoblock",message:"Geoblock detected"}})),this.stopWatchdog())})}this.bindVideoEvents(i,s,n),p.attachMedia(i);let f=this.loadSourceUrl||t.src||"";if(this.tokenManager&&f&&(this.tokenManager.sourceUrl=f,f=await this.tokenManager.updateUrlWithTokenParams({url:f}),this.detached))return p.destroy(),void(this.driver=null);p.loadSource(f),this.resolveDriverReady(),this.registerDriverEvents(o,s),this.armLoadNeverStartedWatchdog(p,o,f,m);const b=p;i.addEventListener("pause",()=>{var e;(null===(e=this.state)||void 0===e?void 0:e.isLive)&&b.stopLoad()},{signal:n}),i.addEventListener("play",()=>{var e,t,i,s;if(null===(e=this.state)||void 0===e?void 0:e.isLive)setTimeout(()=>b.startLoad(-1),0);else if("ended"===(null===(t=this.state)||void 0===t?void 0:t.playbackState)){this.state.playbackState="loading";const e=null!==(s=null===(i=this.video)||void 0===i?void 0:i.currentTime)&&void 0!==s?s:0;setTimeout(()=>b.startLoad(e),0)}},{signal:n}),this.startWatchdog();const y=i,k=s;let T=0;const w=setInterval(()=>{if(T++,T>=10)return void clearInterval(w);const e=k.playbackState;if("playing"!==e&&!y.paused&&y.currentTime>0)return k.playbackState="playing",void clearInterval(w);"buffering"!==e&&"loading"!==e||!y.paused||(k.playbackState="paused",clearInterval(w))},200);n.addEventListener("abort",()=>clearInterval(w),{once:!0})}registerDriverEvents(e,t){const i=this.driver;if(!i)return;this.eventState=t;const{Events:s}=e;i.on(s.MANIFEST_PARSED,this._onManifestParsed.bind(this)),i.on(s.LEVEL_LOADED,this._onLevelLoaded.bind(this)),i.on(s.LEVEL_SWITCHED,this._onLevelSwitched.bind(this)),i.on(s.AUDIO_TRACKS_UPDATED,this._onAudioTracksUpdated.bind(this)),i.on(s.AUDIO_TRACK_SWITCHED,this._onAudioTrackSwitched.bind(this)),i.on(s.SUBTITLE_TRACKS_UPDATED,this._onSubtitleTracksUpdated.bind(this)),i.on(s.SUBTITLE_TRACK_SWITCH,this._onSubtitleTrackSwitch.bind(this))}armLoadNeverStartedWatchdog(e,t,i,s){s||(e.on(t.Events.FRAG_LOADING,this._onFragLoading.bind(this)),this.loadNeverStartedTimer=setTimeout(this._onLoadNeverStartedTimeout.bind(this,i),3e4))}clearLoadNeverStartedWatchdog(){clearTimeout(this.loadNeverStartedTimer),this.loadNeverStartedTimer=0}_onFragLoading(){this.clearLoadNeverStartedWatchdog()}_onLoadNeverStartedTimeout(e){var t,i,s;this.detached||!0!==(null===(t=this.state)||void 0===t?void 0:t.isLive)&&!0!==(null===(i=this.config)||void 0===i?void 0:i.isLive)&&(this.state&&F(this.state,this.bus,B,"HlsEngine: load never started — no fragment request was issued within the bound"),null===(s=this.bus)||void 0===s||s.emit("load-never-started",{src:e}))}_onManifestParsed(e,t){var i,s;const n=this.eventState,r=this.driver;if(!n)return;const o=null!==(s=null!==(i=t.levels)&&void 0!==i?i:null==r?void 0:r.levels)&&void 0!==s?s:[];n.qualityLevels=o.map((e,t)=>{var i;return{name:null!==(i=e.name)&&void 0!==i?i:`${e.height}p`,id:t,bitrate:e.bitrate,height:e.height,width:e.width}})}_onLevelLoaded(e,t){var i,s;const n=this.eventState;if(!n)return;const r=t;void 0!==(null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.live)?n.isLive=r.details.live:!0===(null===(s=this.config)||void 0===s?void 0:s.isLive)&&(n.isLive=!0)}_onLevelSwitched(e,t){const i=this.eventState;if(i&&!this.autoQuality){const e=t;i.currentQuality=e.level}}_onAudioTracksUpdated(e,t){var i,s;const n=this.eventState,r=this.driver;if(!n)return;const o=null!==(s=null!==(i=t.audioTracks)&&void 0!==i?i:null==r?void 0:r.audioTracks)&&void 0!==s?s:[];n.audioTracks=o.map(e=>({id:e.id,name:e.name,lang:e.lang}))}_onAudioTrackSwitched(e,t){const i=this.eventState;if(!i)return;const s=t;i.currentAudioTrack=s.id}_onSubtitleTracksUpdated(e,t){var i,s;const n=this.eventState,r=this.driver;if(!n)return;const o=null!==(s=null!==(i=t.subtitleTracks)&&void 0!==i?i:null==r?void 0:r.subtitleTracks)&&void 0!==s?s:[];n.subtitleTracks=o.map(e=>({id:e.id,name:e.name,lang:e.lang}))}_onSubtitleTrackSwitch(e,t){const i=this.eventState;if(!i)return;const s=t;i.currentSubtitleTrack=s.id}}const si=(e,t,i,s,n,r)=>{if(r<=0)return;const[{bandwidth:o},{bandwidth:a}]=t.getMediaInfo().bitrateList;return r>2&&.8*i>=o&&i<=a?e<8?r:r-1:1===r?s.getCurrentBufferLevel("video",!0)>1.5*n&&e<8?r:r-1:void 0};function ni(e){const t=e.FactoryMaker.getClassFactoryByName("SwitchRequest"),i=e.FactoryMaker.getSingletonFactoryByName("StreamController"),s=e.FactoryMaker.getSingletonFactoryByName("DashMetrics"),n=new Set;let r=0,o=15,a=15;const l=function(){return{getMaxIndex:e=>{const l=t(this.context).create();l.priority=t.PRIORITY.STRONG;const c=e.getMediaInfo().type,d=s(this.context).getInstance(),u=i(this.context).getInstance(),h=e.getAbrController();if(setInterval(()=>{var e;void 0!==(e=d.getCurrentBufferLevel("video",!0))&&(o<e&&(n.add(a),o=e,a=e),e<a&&(a=e,o=a))},1e3),"video"===c){let i,s;try{const[t,o]=(({requests:e,count:t,rulesContext:i,currentValue:s,dashMetrics:o})=>{if(!e)return[""];let a=null;for(let t=e.length-1;t>=0&&null===a;t--){const[{_tfinish:i,trequest:s,tresponse:n,trace:r}]=e[t];i&&s&&n&&r&&r.length&&(a=e[t])}if(null===a)return["No valid request made for this stream yet, bailing"];const l=(a[0]._tfinish.getTime()-a[0].trequest.getTime())/1e3,c=(a[0]._tfinish.getTime()-a[0].tresponse.getTime())/1e3;if("InitializationSegment"===a[0].type||"MediaSegment"===a[0].type){if(l<=0)return["Last segment not downloaded, probable network problem: Switching to lowest quality",0];if(n.size>=3){const a=Array.from(n),d=a.reduce((e,t)=>e+t,0)/n.size,u=((e,t)=>{const[{type:i,_tfinish:s,trequest:n,tresponse:r,trace:o}]=e[0];return"MediaSegment"!==i&&s&&n&&r&&o&&o.length?8*o.reduce((e,t)=>e+t.b[0],0)/t:0})(e,l),h=Math.sqrt(a.map(e=>(e-d)**2).reduce((e,t)=>e+t,0)/n.size);return n.clear(),d<=1.5?["Avg. Buffer < 10% of max buffer, switching to lowest quality",0]:d<=4.5?["Maintaining the current Bitrate",s]:d<=10.5&&i.getMediaInfo().bitrateList[s].bandwidth<u&&(r<t-1||h<=8)?["Switching to optimised quality level",r?si(h,i,u,o,c,t):r+1]:["Switching to optimised quality level",si(h,i,u,o,c,t)]}return["Maintaining the last loaded level"]}return["Last Loaded segment was not a media segment of initialization segment"]})({requests:d.getHttpRequests(c),count:e.getMediaInfo().representationCount,currentValue:h.getQualityFor(c,u.getActiveStreamInfo()),rulesContext:e,dashMetrics:d});s=t,i=null!=o?o:r,r=i}catch(e){return n.clear(),{quality:0,reason:"Error in ABR rule",priority:t.PRIORITY.STRONG}}return l.quality=i,l.reason=s,l}return l.quality=0,l.reason="Audio Request",l}}};return l.__dashjs_factory_name="CustomAbrRule",e.FactoryMaker.getClassFactory(l)}class ri extends Bt{constructor(){super(...arguments),this.driver=null,this.dvrErrorHandler=null,this.isIntroPass=!1,this.introFallThroughReported=!1}getDriver(){return this.driver}setConfig(e){this.config=e}setBus(e){this.bus=e}setVideo(e){this.video=e}async onAttach(){if(this.state){this.state.playbackState="loading";try{await this.init()}catch(e){console.error("DashEngine: init failed",e),this.state&&F(this.state,this.bus,P,e instanceof Error?e.message:String(e))}}}onDetach(){if(this.stopWatchdog(),null!==this.driver){try{this.driver.reset(),this.driver.destroy()}catch(e){console.error("DashEngine: error during driver teardown",e)}this.driver=null}null!==this.dvrErrorHandler&&(window.removeEventListener("unhandledrejection",this.dvrErrorHandler),this.dvrErrorHandler=null)}recoverFromStall(e){var t;null!==this.video&&(1===e?(console.warn("DashEngine stall recovery: seek nudge"),this.video.currentTime+=.1):(console.warn("DashEngine stall recovery: refreshManifest"),null===(t=this.driver)||void 0===t||t.refreshManifest()))}setQuality(e){null!==this.driver&&this.driver.setQualityFor("video",e)}setAudioTrack(e){if(null===this.driver)return;const t=this.driver.getTracksFor("audio");void 0!==t[e]&&this.driver.setCurrentTrack(t[e])}setSubtitle(e){if(null===this.driver)return;const t=this.driver.getTracksFor("fragmentedText");void 0!==t[e]&&this.driver.setCurrentTrack(t[e])}setPlaybackRate(e){null!==this.video&&(this.video.playbackRate=e)}seekToLive(){if(null===this.driver||null===this.video)return;const e=this.driver.duration();Number.isFinite(e)&&(this.video.currentTime=e)}async init(){var e;const{config:t,video:i,state:s,signal:n}=this;if(!(t&&i&&s&&n))return;this.isIntroPass=Boolean(t.preroll)&&this.loadSourceUrl===t.preroll;const r=t.dashjs;if(!r)throw new Error("DashEngine: config.dashjs URL is required");this.dvrErrorHandler=e=>{var t;const i=e.reason;((null===(t=null==i?void 0:i.message)||void 0===t?void 0:t.includes("getCurrentDVRInfo"))||String(e.reason).includes("getCurrentDVRInfo"))&&(e.preventDefault(),console.warn("DashEngine: suppressed DVR unhandledrejection"))},window.addEventListener("unhandledrejection",this.dvrErrorHandler,{signal:n});const o=await E(r,"dashjs"),a=o.MediaPlayer().create();if(!a)throw new Error("DashEngine: dash.js MediaPlayer could not be created");if(this.driver=a,this.resolveDriverReady(),a.initialize(i,this.loadSourceUrl||t.src||"",null!==(e=t.autoplay)&&void 0!==e&&e),t.retry&&function(e,t={}){e.updateSettings({streaming:{retryIntervals:{MPD:1e3,XLinkExpansion:1e3,InitializationSegment:1e3,IndexSegment:1e3,MediaSegment:1e3,BitstreamSwitchingSegment:1e3,other:1e3,lowLatencyReductionFactor:1}}});const i=!0===t.introPass?2:1/0;e.updateSettings({streaming:{retryAttempts:{MPD:i,XLinkExpansion:i,InitializationSegment:i,IndexSegment:i,MediaSegment:i,BitstreamSwitchingSegment:i,other:i,lowLatencyMultiplyFactor:1}}})}(a,{introPass:this.isIntroPass}),!t.disableCustomAbr){const e=ni(o);a.addABRCustomRule("qualitySwitchRules","CustomAbrRule",e)}t.lowLatency&&a.updateSettings({streaming:{lowLatencyEnabled:!0,liveDelay:30,liveCatchUpPlaybackRate:.01}}),this.registerDriverEvents(o,s,a),this.bindVideoEvents(i,s,n),this.startWatchdog(),await new Promise(e=>{const t=()=>{a.off(o.MediaPlayer.events.STREAM_INITIALIZED,t),e()};a.on(o.MediaPlayer.events.STREAM_INITIALIZED,t)});const l=i,c=s;let d=0;const u=setInterval(()=>{if(d++,d>=10)return void clearInterval(u);const e=c.playbackState;if("playing"!==e&&!l.paused&&l.currentTime>0)return c.playbackState="playing",void clearInterval(u);"buffering"!==e&&"loading"!==e||!l.paused||(c.playbackState="paused",clearInterval(u))},200);n.addEventListener("abort",()=>clearInterval(u),{once:!0})}registerDriverEvents(e,t,i){const s=e.MediaPlayer.events;i.on(s.STREAM_INITIALIZED,()=>{var e;const s=i.getBitrateInfoListFor("video");t.qualityLevels=s.map((e,t)=>({name:`${e.height}p`,id:t,bitrate:e.bitrate}));const n=i.getTracksFor("audio");t.audioTracks=n.map(e=>{var t,i,s;return{name:null!==(t=e.lang)&&void 0!==t?t:"",id:null!==(s=null!==(i=e.id)&&void 0!==i?i:e.index)&&void 0!==s?s:0}});const r=i.getTracksFor("fragmentedText");t.subtitleTracks=r.map(e=>{var t,i,s;return{name:null!==(t=e.lang)&&void 0!==t?t:"",id:null!==(s=null!==(i=e.id)&&void 0!==i?i:e.index)&&void 0!==s?s:0}});const o=i.duration();t.duration=Number.isFinite(o)?Math.ceil(o):0;const a=i.getCurrentLiveLatency();"boolean"==typeof(null===(e=this.config)||void 0===e?void 0:e.isLive)?t.isLive=this.config.isLive:t.isLive=!Number.isNaN(a),t.playbackState="playing"}),i.on(s.PLAYBACK_TIME_UPDATED,()=>{t.currentTime=Math.round(i.time())}),i.on(s.QUALITY_CHANGE_REQUESTED,()=>{t.currentQuality=i.getQualityFor("video")}),i.on(s.TRACK_CHANGE_RENDERED,()=>{t.currentAudioTrack=i.getQualityFor("audio")}),i.on(s.ERROR,e=>{this.handleDriverError(e)})}handleDriverError(e){var t,i,s,n,r,o,a,l;const c=e;if(console.warn("DashEngine error:",null!==(s=null!==(i=null===(t=null==c?void 0:c.error)||void 0===t?void 0:t.message)&&void 0!==i?i:null==c?void 0:c.error)&&void 0!==s?s:c),!this.isIntroPass||this.introFallThroughReported)return;this.introFallThroughReported=!0,this.stopWatchdog();const d=null!==(a=null!==(r=null===(n=null==c?void 0:c.error)||void 0===n?void 0:n.code)&&void 0!==r?r:null===(o=null==c?void 0:c.error)||void 0===o?void 0:o.message)&&void 0!==a?a:"unknown";null===(l=this.bus)||void 0===l||l.emit("error-fatal",{code:"NETWORK",message:`Intro stream error: ${d}`})}}function oi(e){return e.split("?")[0].replace(/(\/hdn.*\/)/g,"/")}class ai{constructor(){this.lib=null}async integrate(e){var t,i,s,n;const{video:r,driver:o,type:a,config:l,signal:c}=e;if(!l.lib||!l.manager)return;const d=await E(l.lib,"Easybroadcast");if(c.aborted)return;this.lib=new d.eblib.EBLibrary(l.manager);const u=oi(null!==(t=l.src)&&void 0!==t?t:""),h=null!==(s=(null!==(i=l.libSettings)&&void 0!==i?i:{}).resourceManager)&&void 0!==s?s:{},v={resourceManager:Object.assign({tokenRemover:oi},h),swarmManager:{url:u},statsOutput:{enable:!!l.stats,url:l.stats,intervalMs:3e4},playerInput:{content:String(null!==(n=l.content)&&void 0!==n?n:u),contentUrl:u,proto:a,origin:l.origin}};if("dash"===a){const e=v.resourceManager;e.randomWaitForPeers=[150,400],e.timeoutV2V=500,e.storageSize=20}this.lib.integrate([o,r],a,v),this.lib.start(),c.addEventListener("abort",()=>{this.stop()},{once:!0})}stop(){null!==this.lib&&"function"==typeof this.lib.stop&&this.lib.stop(),this.lib=null}}class li{constructor(e,t){this.driver=null,this.offscreenVideo=null,this.throttleTimeout=null,this.pendingSeekTime=0,this.config=e,this.tokenManager=t}init(e){var t,i;const s=document.createElement("video");s.preload="metadata",this.offscreenVideo=s;const n=this.tokenManager;let r,o;if(n){class t extends e.DefaultConfig.loader{constructor(e){super(e);const t=this.load.bind(this);this.load=async function(e,i,s){if(!e.url)return void t(e,i,s);new URL(e.url).pathname.split("/").pop().endsWith(".m3u8")?(e.url=await n.updateUrlWithTokenParams({url:e.url}),t(e,i,s)):t(e,i,s)}}}r=t}n&&!0===(null===(t=this.config.engineSettings)||void 0===t?void 0:t.signSegmentsWithCdnToken)&&(o=ti(e.DefaultConfig.loader,n));const a=Object.assign({},null!==(i=this.config.engineSettings)&&void 0!==i?i:{});delete a.extraParamsCallback,delete a.onCDNTokenError,delete a.signSegmentsWithCdnToken;const l=Object.assign(Object.assign(Object.assign({startLevel:0,enableWebVTT:!1,enableWorker:!1,maxBufferLength:1},a),r?{pLoader:r}:{}),o?{fLoader:o}:{}),c=new e(l);return this.driver=c,Jt(c,e.Events),c.attachMedia(s),this.config.src&&c.loadSource(this.config.src),new Promise(t=>{c.once(e.Events.MANIFEST_LOADED,()=>{c.loadLevel=0,t()})})}take(e){this.offscreenVideo&&(null!==this.throttleTimeout&&clearTimeout(this.throttleTimeout),this.pendingSeekTime=e,this.throttleTimeout=setTimeout(this.applyPendingSeek.bind(this),250))}applyPendingSeek(){this.offscreenVideo&&(this.offscreenVideo.currentTime=this.pendingSeekTime),this.throttleTimeout=null}getVideo(){return this.offscreenVideo}stopLoad(){this.driver&&"function"==typeof this.driver.stopLoad&&this.driver.stopLoad()}startLoad(){this.driver&&"function"==typeof this.driver.startLoad&&this.driver.startLoad(-1)}destroy(){if(null!==this.throttleTimeout&&(clearTimeout(this.throttleTimeout),this.throttleTimeout=null),null!==this.driver){try{this.driver.detachMedia(),this.driver.destroy()}catch(e){console.warn("HlsSnapshotHandler: error during destroy",e)}this.driver=null}this.offscreenVideo=null}}class ci{constructor(e){this.player=null,this.offscreenVideo=null,this.ready=!1,this.src=e}init(e){return new Promise(t=>{const i=document.createElement("video");i.style.display="none",document.body.appendChild(i),this.offscreenVideo=i;const s={take:()=>{},destroy:()=>{},video:i};let n;try{n=e.MediaPlayer().create(),this.player=n,n.initialize(i,this.src,!1),n.updateSettings({streaming:{text:{defaultEnabled:!1},buffer:{fastSwitchEnabled:!1},abr:{autoSwitchBitrate:{video:!1,audio:!1},initialBitrate:{video:0,audio:0}}}})}catch(e){const i=e instanceof Error?e.message:String(e);return console.warn("Snapshot handler initialization failed:",i),this.cleanup(),void t(s)}n.on(e.MediaPlayer.events.ERROR,e=>{var t,i,s;const n=e;console.warn("Snapshot dash.js error:",null!==(s=null!==(i=null===(t=null==n?void 0:n.error)||void 0===t?void 0:t.message)&&void 0!==i?i:null==n?void 0:n.error)&&void 0!==s?s:n)});const r=()=>{n.setMute(!0),n.off(e.MediaPlayer.events.STREAM_INITIALIZED,r),this.ready=!0;let s=null;t({take:e=>{if(this.ready&&null===s){s=setTimeout(()=>{s=null},250);try{n.seek(e),n.isPaused()&&n.play()}catch(e){const t=e instanceof Error?e.message:String(e);console.warn("Snapshot seek error:",t)}}},destroy:()=>{this.ready=!1,this.destroy()},video:i})};n.on(e.MediaPlayer.events.STREAM_INITIALIZED,r),n.on(e.MediaPlayer.events.PLAYBACK_PLAYING,()=>{n.isPaused()||n.pause()})})}destroy(){if(this.ready=!1,null!==this.player){try{this.player.reset()}catch(e){}this.player=null}this.cleanup()}cleanup(){null!==this.offscreenVideo&&(this.offscreenVideo.remove(),this.offscreenVideo=null)}}const di=["Proxy","AbortController"];var ui;const hi=new Map;function vi(e){var t;null!==e.snapshotDestroy&&(e.snapshotDestroy(),e.snapshotDestroy=null),null!==e.engine&&(e.engine.detach(),e.engine=null),null===(t=e.p2p)||void 0===t||t.stop(),e.p2p=null,e.controller.dispose()}function gi(){return new Promise(e=>setTimeout(e,500))}function pi(e){const t=function(e){if(null!=e&&"object"==typeof e&&"nodeType"in e)return e;const t="string"==typeof e?e:"#eb_player",i=document.querySelector(t);if(null===i)throw new Error(`EBPlayer: container element not found for selector "${t}". Ensure the element exists in the DOM before calling start().`);return i}(e.el),i=function(e=window){return di.filter(t=>"function"!=typeof e[t])}();if(i.length>0)throw function(e,t){const i=new y(t),s=document.createElement("div");s.className="eb-player";const n=document.createElement("div");n.className="eb-error-slot";const r=document.createElement("div");r.className="eb-error",r.setAttribute("role","alert");const o=document.createElement("p");o.className="eb-error-message",o.textContent=i.t("error.unsupported_browser"),r.appendChild(o),n.appendChild(r),s.appendChild(n),e.textContent="",e.appendChild(s)}(t,e.lang),new Error(`EBPlayer: unsupported browser — missing ${i.join(", ")}`);const s=hi.get(t);void 0!==s&&(vi(s),hi.delete(t));const n=p(h,e);var r;void 0!==(r=n.sentryDsn)&&(null===x?(x=r,E("https://browser.sentry-cdn.com/11.0.0/bundle.tracing.min.js","Sentry").then(e=>{e.init({dsn:r,tracesSampleRate:1,integrations:[],beforeBreadcrumb:C,beforeSend:L}),S=e}).catch(e=>{console.warn("Telemetry: failed to load Sentry SDK",e)})):x!==r&&console.warn("Telemetry: Sentry already initialized with a different DSN — ignoring"));const o=n.muted,a=n.manager,l=n.startAt,c=new Mt(e);c.mount(t);const d=t.querySelector("video"),u={controller:c,engine:null,snapshotDestroy:null,p2p:null,container:t};hi.set(t,u);let v="";const g={on(e,t){const i=new AbortController;return"error"===e&&c.bus.on("player-error",e=>{t(m(e))},{signal:i.signal}),()=>i.abort()},open(e){var t;v=e,null!==u.engine&&(u.engine.detach(),u.engine=null);const i=function(e,t){return e.includes(".mpd")&&!1!==t.dashjs?new ri:new ii}(e,n);if(null!==d&&i.setVideo(d),i.setBus(c.bus),i.setConfig(n),i.setLoadSource(e),c.setEngineSync(i),u.engine=i,n.lib&&n.manager&&null!==d){const s=e.includes(".mpd")&&!1!==n.dashjs;null===(t=u.p2p)||void 0===t||t.stop();const r=new ai;u.p2p=r,i.driverReady.then(()=>r.integrate({video:d,driver:i.getDriver(),type:s?"dash":"hls",config:n,signal:c.signal})).catch(e=>{console.error("EBPlayer: P2PManager integrate failed:",e)})}if(n.showProgressThumb&&e!==n.preroll){null!==u.snapshotDestroy&&(u.snapshotDestroy(),u.snapshotDestroy=null);const t=e.includes(".mpd")&&!1!==n.dashjs;i.driverReady.then(()=>{if(t){const t=window;if(t.dashjs){new ci(e).init(t.dashjs).then(e=>{u.snapshotDestroy=()=>e.destroy(),c.bus.emit("snapshot-handler-ready",{take:e.take,video:e.video})}).catch(e=>{console.warn("EBPlayer: DashSnapshotHandler init failed:",e)})}}else{const t=window;if(t.Hls){const s=i.getTokenManager(),r=new Yt(s).buildHlsConfig(n.engineSettings),o=new li({src:e,engineSettings:Object.assign(Object.assign({},n.engineSettings),r)},s);o.init(t.Hls).then(()=>{u.snapshotDestroy=()=>o.destroy();const e=o.getVideo();null!==e&&c.bus.emit("snapshot-handler-ready",{take:e=>o.take(e),video:e}),d&&(d.addEventListener("pause",()=>{var e;(null===(e=c.state)||void 0===e?void 0:e.isLive)&&o.stopLoad()},{signal:c.signal}),d.addEventListener("play",()=>{var e;(null===(e=c.state)||void 0===e?void 0:e.isLive)&&setTimeout(()=>o.startLoad(),0)},{signal:c.signal}))}).catch(e=>{console.warn("EBPlayer: HlsSnapshotHandler init failed:",e)})}else console.warn("EBPlayer: window.Hls not available after driverReady — snapshot preview disabled")}}).catch(e=>{console.warn("EBPlayer: Snapshot handler init failed:",e)})}},close(){null!==u.snapshotDestroy&&(u.snapshotDestroy(),u.snapshotDestroy=null),null!==u.engine&&(u.engine.detach(),u.engine=null)},destroy(){vi(u),hi.delete(t)},get state(){return c.state}};c.setReloadCallback(()=>{if(!v)return;const e=v,t=c.getSavedSelections();g.close(),gi().then(()=>{g.open(e),setTimeout(()=>{null!==u.engine&&(u.engine.setQuality(t.quality),u.engine.setAudioTrack(t.audioTrack),u.engine.setSubtitle(t.subtitleTrack))},2e3)})});const m=e=>Object.assign(Object.assign({},e),{localizedMessage:O(e.code,e.message,c.i18n)}),f=n.onError;if("function"==typeof f&&c.bus.on("player-error",e=>{try{f(m(e))}catch(e){console.error("EBPlayer: config.onError threw",e)}},{signal:c.signal}),c.bus.on("error-fatal",()=>{var e;null===(e=u.p2p)||void 0===e||e.stop()},{signal:c.signal}),null===d){const e="EBPlayer: no <video> element found in the container after mount() — playback cannot start.";return console.error(e),F(c.state,c.bus,D,e),g}let b=!1;const k=()=>{b||(b=!0,c.bus.emit("force-intro-complete"),d.muted=o,c.state.muted=o,n.manager=a,c.config.manager=a,n.startAt=l,c.config.startAt=l,c.state.error=null,c.state.errorCode=null,n.src&&g.open(n.src))},T=Boolean(n.preroll),w=Boolean(n.ad);let A=null;const $=()=>{null!==A&&(clearTimeout(A),A=null)},_=e=>{A=setTimeout(()=>{c.signal.aborted||(c.state.adPlaying?_(e):(console.warn("eb-player: ad leg produced no ad-complete within the bound — falling through to main (G-07-11)"),e()))},3e4)};c.signal.addEventListener("abort",()=>{$()},{once:!0});let M=!w,P=Boolean(n.autoplay),R=!1;const B=()=>{if(R)return;R=!0;const e=u.engine;null!==e&&e.driverReady.then(()=>{const e=d.play();e&&"function"==typeof e.catch&&e.catch(e=>{console.warn("EBPlayer: deferred play() rejected",e)})})},V=()=>{M&&P&&(k(),n.autoplay||B())};if(w&&c.bus.on("ad-complete",()=>{$(),M=!0,T?k():V()},{signal:c.signal}),T)c.bus.on("intro-stream-complete",()=>{g.close(),c.state.muted=o,gi().then(()=>{b||(w?_(k):k())})},{signal:c.signal}),d.muted=!1,c.state.muted=!1,n.manager=!1,c.config.manager=!1,n.startAt=void 0,c.config.startAt=void 0,g.open(n.preroll);else if(w)n.autoplay?_(()=>{M=!0,V()}):c.bus.on("play",()=>{P||(P=!0,M?(V(),B()):_(()=>{M=!0,V()}))},{signal:c.signal});else if(n.src)if(n.autoplay)g.open(n.src);else{let e=!0;c.bus.on("play",()=>{e&&(e=!1,g.open(n.src),B())},{signal:c.signal})}return g}function mi(){for(const e of hi.values())null!==e.engine&&(e.engine.detach(),e.engine=null)}function fi(){for(const e of hi.values())vi(e);hi.clear()}const bi=t;if("undefined"!=typeof window){console.info(`%cEBPlayer v${bi}`,"color: #1FA9DD; font-weight: bold");const e=window,t=null!==(ui=e.EBPlayer)&&void 0!==ui?ui:{};Object.assign(t,{start:pi,stop:mi,destroy:fi,AVAILABLE_THEMES:l,THEME_LAYOUTS:d,version:bi}),e.EBPlayer=t}const yi="main",ki={bufferInfo(e,t,i){if(!e.buffered||0===e.buffered.length)return{end:0,start:0,len:0,nextStart:0};for(let s=0;s<e.buffered.length;s++){const n=e.buffered.start(s),r=e.buffered.end(s);if(t>=n-i&&t<=r+i)return{end:r,start:n,len:r-t,nextStart:0}}return{end:0,start:0,len:0,nextStart:0}}};var Ei=Object.freeze({__proto__:null,createHlsAbrController:function(e){const t=e.DefaultConfig.abrController;if(!t)return class{constructor(e){}get nextAutoLevel(){return-1}set nextAutoLevel(e){}destroy(){}};const{Events:i}=e;return class extends t{constructor(e){super(e,i.FRAG_LOADING,i.FRAG_LOADED,i.FRAG_BUFFERED,i.ERROR),this.hls=e,this.lastLoadedLevel=1,this._nextAutoLevel=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.onBufferCheckTick=this._onBufferCheckTick.bind(this),this.bufferCheckLastPlayPos=0,this.bufferCheckCurrentPlayPos=0,this.bufferCheckBufferingDetected=!1,this.lastDuration=6,this.setBufferValues=new Set,this.setBitrate=new Set,this.loading=!1,this.playingTime=0,this.minBufferValue=30,this.maxBufferValue=0,this.lastBufferValue=30,this.maxBufferLength=30,this.rebuffering=0,this.rebufferingRatio=.15,this.pastBufferFactor=5,this.bitrateTestDelay=0,this.timer=void 0,this.bufferCheckTimer=void 0,this.init=!0,this.fraglastBuffered=0,this.lastLoadedFragLevel=1,this.fragCurrent=null,this.partCurrent=null,this.bufferCheckVideo=null,this.registerCustomListeners()}destroy(){this.unregisterCustomListeners(),this.clearCustomTimer(),void 0!==this.bufferCheckTimer&&(clearInterval(this.bufferCheckTimer),this.bufferCheckTimer=void 0),"function"==typeof super.destroy&&super.destroy()}registerCustomListeners(){this.hls.on(i.FRAG_LOADING,this.onFragLoading,this),this.hls.on(i.FRAG_LOADED,this.onFragLoaded,this),this.hls.on(i.FRAG_BUFFERED,this.onFragBuffered,this),this.hls.on(i.LEVEL_LOADED,this.onLevelLoaded,this),this.hls.on(i.ERROR,this.onError,this)}unregisterCustomListeners(){this.hls.off(i.FRAG_LOADING,this.onFragLoading,this),this.hls.off(i.FRAG_LOADED,this.onFragLoaded,this),this.hls.off(i.FRAG_BUFFERED,this.onFragBuffered,this),this.hls.off(i.LEVEL_LOADED,this.onLevelLoaded,this),this.hls.off(i.ERROR,this.onError,this)}clearCustomTimer(){void 0!==this.timer&&(clearInterval(this.timer),this.timer=void 0)}onFragLoading(e,t){var i;const s=t,{frag:n}=s;this.loading=!0,n.type===yi&&(this.timer||(this.fragCurrent=n,this.partCurrent=null!==(i=s.part)&&void 0!==i?i:null,this.timer=setInterval(this.onCheck,100)))}getBuffer(){if(!this.hls.media)return 0;const e=this.hls.media.playbackRate||1,t=this.hls.media.currentTime;return(ki.bufferInfo(this.hls.media,t,this.maxBufferLength).end-t)/e}_abandonRulesCheck(){const{hls:e}=this,t=e.media,i=this.fragCurrent,s=this.partCurrent;if(!i||!t)return;if((s?s.stats:i.stats).aborted)return this.clearCustomTimer(),void(this._nextAutoLevel=-1);e.autoLevelEnabled&&!t.paused&&t.playbackRate&&t.readyState&&i.type===yi&&"initSegment"!==i.sn&&(this.bufferCheckLastPlayPos=0,this.bufferCheckCurrentPlayPos=0,this.bufferCheckBufferingDetected=!1,this.bufferCheckVideo=t,this.bufferCheckTimer=setInterval(this.onBufferCheckTick,1e3))}_onBufferCheckTick(){if(!this.hls)return;if(!1===this.loading){const e=this.getBuffer();this.getBufferMinMaxValue(e)}const e=this.bufferCheckVideo;e&&(this.playingTime+=1,this.bufferCheckCurrentPlayPos=e.currentTime,this.bufferCheckLastPlayPos>0&&e.paused&&!this.bufferCheckBufferingDetected&&this.bufferCheckCurrentPlayPos<=this.bufferCheckLastPlayPos&&(this.rebuffering+=1,this.bufferCheckBufferingDetected=!0,this.hls.currentLevel>0&&(this.reset(),0!==this.lastLoadedFragLevel&&this.clearCustomTimer())),this.bufferCheckLastPlayPos>0&&this.bufferCheckBufferingDetected&&!e.paused&&this.bufferCheckCurrentPlayPos>this.bufferCheckLastPlayPos&&(this.bufferCheckBufferingDetected=!1),this.bufferCheckLastPlayPos=this.bufferCheckCurrentPlayPos)}onFragLoaded(e,t){const s=t,{frag:n,part:r}=s,o=r?r.stats:n.stats,a=r?r.duration:n.duration;if(this.loading=!1,n.type===yi&&"number"==typeof n.sn){this.clearCustomTimer(),this.lastLoadedFragLevel=n.level,this._nextAutoLevel=-1;const e=this.hls.levels[n.level];if(e){const t=(e.loaded?e.loaded.bytes:0)+o.loaded,i=(e.loaded?e.loaded.duration:0)+a;e.loaded={bytes:t,duration:i},e.realBitrate=Math.round(8*t/i),this.setBitrate.add(e.realBitrate),this.lastDuration=a,this.maxBufferLength=10*this.lastDuration}this.onFragBuffered(i.FRAG_BUFFERED,{stats:o,frag:n,part:r,id:n.type})}}getBufferMinMaxValue(e){this.lastBufferValue<e&&(this.setBufferValues.add(this.minBufferValue),this.maxBufferValue=e,this.lastBufferValue=e,this.minBufferValue=e),e>this.maxBufferValue&&(this.maxBufferValue=e),e<this.minBufferValue&&(this.minBufferValue=e,this.lastBufferValue=this.minBufferValue)}reset(){this.setBufferValues.clear(),this.setBitrate.clear()}onError(e,t){if("fragLoadTimeOut"===t.details)this.clearCustomTimer()}onLevelLoaded(e,t){}onFragBuffered(e,t){var i,s,n,r,o;const a=t,{frag:l,part:c}=a,d=c?c.stats:null!==(i=a.stats)&&void 0!==i?i:l.stats;if(d.aborted)return;if(l.type!==yi||"initSegment"===l.sn)return;const u=null!==(n=null===(s=d.loading)||void 0===s?void 0:s.start)&&void 0!==n?n:0,h=(null!==(o=null===(r=d.parsing)||void 0===r?void 0:r.end)&&void 0!==o?o:0)-u;this.bitrateTestDelay=h/1e3,this.fraglastBuffered=Date.now()}findNextBestLevel(e){const t=this.hls.levels;for(let i=0;i<t.length;i++){if(i<t.length-2&&.8*this.avgBitrate>=t[i].bitrate&&this.avgBitrate<=t[i+1].bitrate)return this.reset(),this.lastLoadedFragLevel=e<3?i:i-1,this.lastLoadedFragLevel;if(i===t.length-1){return this.getBuffer()>this.lastDuration+this.lastDuration/2&&e<3?this.lastLoadedFragLevel=i:this.lastLoadedFragLevel=i-1,this.reset(),this.lastLoadedFragLevel}}return this.lastLoadedFragLevel}get avgBitrate(){return 0===this.setBitrate.size?0:Array.from(this.setBitrate).reduce((e,t)=>e+t,0)/this.setBitrate.size}set avgBitrate(e){}findBestLevel(){var e,t;if(!this.hls)return 0;const i=this.hls.levels.length-1,s=this.getBuffer();if(s<.1*this.hls.config.maxBufferLength)return this.reset(),this.lastLoadedFragLevel=Math.max(this.lastLoadedFragLevel-1,0),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel;if(!0===this.init)return this.init=!1,this.lastLoadedFragLevel=i,this.lastLoadedFragLevel;if(s>.3*this.hls.config.maxBufferLength)return this.lastLoadedFragLevel=this.findNextBestLevel(5),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel;if(this.setBufferValues.size>=this.pastBufferFactor)try{const s=Array.from(this.setBufferValues).reduce((e,t)=>e+t,0)/this.setBufferValues.size,n=function(e){const t=e.reduce((e,t)=>e+t,0)/e.length,i=e.map(e=>(e-t)**2);return Math.sqrt(i.reduce((e,t)=>e+t,0)/(e.length-1))}(Array.from(this.setBufferValues));this.setBufferValues.clear();const r=null!==(t=null===(e=this.hls.levels[this.hls.currentLevel])||void 0===e?void 0:e.bitrate)&&void 0!==t?t:0;return s<=.1*this.hls.config.maxBufferLength&&r>=this.hls.levels[0].bitrate?(this.reset(),this.lastLoadedFragLevel=Math.max(this.lastLoadedFragLevel-1,0),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel):s<=.3*this.hls.config.maxBufferLength?(this.reset(),this.lastLoadedFragLevel):s<=.7*this.hls.config.maxBufferLength&&r<this.avgBitrate?(this.reset(),this.lastLoadedFragLevel=this.findNextBestLevel(n),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel):s>.7*this.hls.config.maxBufferLength&&r<.8*this.avgBitrate?(this.lastLoadedFragLevel=this.findNextBestLevel(n),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel):(this.reset(),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel)}catch(e){return console.warn("HLS ABR: findBestLevel error",e),this.lastLoadedFragLevel=this.findNextBestLevel(3),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel}return this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),i),this.lastLoadedFragLevel}get _nextABRAutoLevel(){try{return this.playingTime>0&&this.rebuffering/this.playingTime>this.rebufferingRatio?(this.lastLoadedFragLevel=0,0):(this.setBitrate.size>0&&(this.lastLoadedFragLevel=this.findBestLevel()),this.lastLoadedFragLevel)}catch(e){return console.warn("HLS ABR: Could not define level, using last loaded level",e),this.lastLoadedFragLevel}}get nextAutoLevel(){return this._nextABRAutoLevel}set nextAutoLevel(e){this._nextAutoLevel=e}}}});e.AVAILABLE_THEMES=l,e.THEME_LAYOUTS=d,e.destroy=fi,e.start=pi,e.stop=mi,e.version=bi});
@@ -30,7 +30,8 @@ export interface PlayerErrorInfo {
30
30
  export declare function errorMessageKey(code: string): string;
31
31
  /**
32
32
  * The one place a fatal, user-visible error is surfaced: sets the code before
33
- * the message (the overlay re-renders on `error`), and announces it on the bus.
33
+ * the message (the overlay re-renders on `error`), announces it on the bus,
34
+ * and reports it to Sentry when telemetry is enabled (`config.sentryDsn`).
34
35
  * Distinct from `error-fatal`, which has side effects (P2P teardown, intro
35
36
  * fall-through) and is only emitted for a subset of failures.
36
37
  */
@@ -12,6 +12,14 @@
12
12
  * on one page is a host-app concern, not something this player can resolve.
13
13
  */
14
14
  export declare function initTelemetry(dsn: string | undefined): void;
15
+ /**
16
+ * Reports a fatal, user-visible player error (the ones surfaced through
17
+ * src/core/errors.ts reportError()) to Sentry. Sent as an exception whose
18
+ * name is the stable error code so issues group per code, not per diagnostic
19
+ * message. `message` is engine diagnostic prose, never a URL (see the
20
+ * reportError() call sites). No-op until the SDK has loaded.
21
+ */
22
+ export declare function captureError(code: string, message: string): void;
15
23
  /**
16
24
  * Drop-in replacement for `fetch(url, init)` that additionally records a
17
25
  * response-time span and captures errors to Sentry, when telemetry is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eb-player",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "scripts": {
6
6
  "generate-demo": "pnpm generate --brand default --variant demo && cp dist/players/default/default.js test_player/src/demo.js",