eb-player 2.5.3 → 2.5.4
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.
- package/dist/build/ebplayer.bundle.js +100 -100
- package/dist/build/types/src/core/browser-support.d.ts +29 -0
- package/dist/build/types/src/engines/base-engine.d.ts +13 -0
- package/dist/build/types/src/skin/base-component.d.ts +10 -0
- package/dist/build/types/src/skin/controls/volume-control.d.ts +13 -3
- package/dist/build/types/src/utils/play-quietly.d.ts +17 -0
- package/package.json +5 -3
|
@@ -1,58 +1,58 @@
|
|
|
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.5.3";const s={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 i{constructor(){this.listeners=new Map}on(e,t,s){this.listeners.has(e)||this.listeners.set(e,new Set);const i=this.listeners.get(e);i.add(t);const n=s?.signal;if(void 0!==n){const e=()=>{i.delete(t)};n.addEventListener("abort",e,{once:!0})}}notify(e,t,s){const i=this.listeners.get(e);if(void 0!==i)for(const e of i)e(t,s)}}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,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={...n,...e},r=new i;return new Proxy(t,{get:(e,t)=>"on"===t?r.on.bind(r):e[t],set(e,t,i){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}(i))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=i;if(a=n,!s[t].includes(a))return console.warn(`FSM: rejected playbackState transition "${t}" → "${n}"`),!0}var a;const o=e[n];if(o===i)return!0;return e[String(n)]=i,r.notify(n,i,o),!0}})}class a{constructor(){this.listeners=new Map}on(e,t,s){const i=s?.signal;if(!0===i?.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!==i&&i.addEventListener("abort",()=>{n.delete(r)},{once:!0})}emit(...e){const[t,s]=e,i=this.listeners.get(t);if(void 0!==i&&0!==i.size)for(const e of i)void 0!==s?e(s):e()}dispose(){this.listeners.clear()}}const o={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"]}},h={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 d(e){const t=(e.skin?h[e.skin]:void 0)??o;return e.layout??t}const u={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,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 g(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function p(e,t){if("function"==typeof t)return t;if(Array.isArray(t))return[...t];if(g(t)&&g(e)){const s={};for(const t of Object.keys(e))s[t]=e[t];for(const i of Object.keys(t))s[i]=p(e[i],t[i]);return s}if(g(t)){const e={};for(const s of Object.keys(t))e[s]=p(void 0,t[s]);return e}return void 0!==t?t:e}function m(...e){let t={};for(const s of e)null!=s&&(t=p(t,s));return t}const f=["en","fr","ar","es"],v={"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."},"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 f.includes(t)?t:"en"}class y{constructor(e){this.currentLocale=b(e),this.translations={...v}}addTranslations(e){for(const t of Object.keys(e))this.translations[t]={...this.translations[t],...e[t]}}t(e,t){const s=this.translations[e];let i;return i=void 0===s?e:void 0!==s[this.currentLocale]?s[this.currentLocale]:void 0!==s.en?s.en:e,void 0===t||0===Object.keys(t).length?i:this.interpolate(i,t)}interpolate(e,t){return e.replace(/\{(\w+)\}/g,(e,s)=>{const i=t[s];return void 0!==i?String(i):e})}setLocale(e){this.currentLocale=b(e)}getLocale(){return this.currentLocale}}class k{constructor(e,t,s,i,n,r,a,o){this.reloadCount=0,this.successTimer=0,this.toastTimer=0,this.savedQuality=-1,this.savedAudioTrack=0,this.savedSubtitleTrack=-1,this.wireVideoCommands(e,t,s,i,n,o),this.wireEngineCommands(e,i,o),this.wireReloadOrchestration(e,s,r,a,o),this.wireCastHandoff(e,t,s,n,r,o),this.wireVolumeRouting(s,n,o),this.wireGeoblock(e,s,r,o),this.wireAbortCleanup(o)}getSavedSelections(){return{quality:this.savedQuality,audioTrack:this.savedAudioTrack,subtitleTrack:this.savedSubtitleTrack}}wireVideoCommands(e,t,s,i,n,r){e.on("play",()=>{s.isCasting&&null!==n?n.getDriver()?.play():t.play()},{signal:r}),e.on("pause",()=>{s.isCasting&&null!==n?n.getDriver()?.pause():t.pause()},{signal:r}),e.on("seek",({time:e})=>{if(s.isCasting&&null!==n)return void n.getDriver()?.seek(e);const r=i();null!==r?r.seek(e):t.currentTime=e},{signal:r}),e.on("mute-toggle",()=>{t.muted=!t.muted},{signal:r}),s.on("volume",e=>{s.isCasting||(t.volume=e)},{signal:r})}wireEngineCommands(e,t,s){e.on("settings-select-quality",({index:e})=>{t()?.setQuality(e)},{signal:s}),e.on("settings-select-audio",({index:e})=>{t()?.setAudioTrack(e)},{signal:s}),e.on("settings-select-subtitle",({index:e})=>{t()?.setSubtitle(e)},{signal:s}),e.on("settings-select-speed",({rate:e})=>{t()?.setPlaybackRate(e)},{signal:s}),e.on("sync-live",()=>{t()?.seekToLive()},{signal:s})}wireReloadOrchestration(e,t,s,i,n){e.on("request-reload",()=>{if(this.reloadCount>=3)return t.reconnecting=!1,void(t.error=s.t("error.stream_unavailable"));this.savedQuality=t.currentQuality,this.savedAudioTrack=t.currentAudioTrack,this.savedSubtitleTrack=t.currentSubtitleTrack,t.reconnecting=!0,this.reloadCount++,i()},{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,s,i,n,r){e.on("cast-start",()=>{null!==i&&(t.pause(),i.toggleCast(s))},{signal:r}),e.on("cast-stop",()=>{t.play()},{signal:r}),e.on("cast-stop-with-position",({time:e})=>{t.currentTime=e,t.play()},{signal:r}),e.on("cast-failed",()=>{s.isCasting=!1,t.play(),this.showToast(s,n.t("cast.failed"))},{signal:r})}wireVolumeRouting(e,t,s){null!==t&&e.on("volume",s=>{e.isCasting&&t.getDriver()?.volume(s)},{signal:s})}wireGeoblock(e,t,s,i){e.on("geoblock-detected",()=>{t.error=s.t("error.geoblocked")},{signal:i})}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})}}
|
|
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.5.4";"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,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 h(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 u={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,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."},"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])}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=e.play();void 0!==t&&"function"==typeof t.catch&&t.catch(()=>{})}class w{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():k(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(t.error=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",()=>{k(t)},{signal:r}),e.on("cast-stop-with-position",({time:e})=>{t.currentTime=e,k(t)},{signal:r}),e.on("cast-failed",()=>{i.isCasting=!1,k(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",()=>{t.error=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 E;
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/const
|
|
6
|
+
*/const T=globalThis,C=e=>e,L=T.trustedTypes,S=L?L.createPolicy("lit-html",{createHTML:e=>e}):void 0,x="$lit$",A=`lit$${Math.random().toFixed(9).slice(2)}$`,$="?"+A,M=`<${$}>`,P=document,_=()=>P.createComment(""),R=e=>null===e||"object"!=typeof e&&"function"!=typeof e,B=Array.isArray,D="[ \t\n\f\r]",F=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,V=/>/g,N=RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),I=/'/g,H=/"/g,U=/^(?:script|style|textarea|title)$/i,j=e=>(t,...i)=>({_$litType$:e,strings:t,values:i}),z=j(1),q=j(2),W=Symbol.for("lit-noChange"),G=Symbol.for("lit-nothing"),Q=new WeakMap,Y=P.createTreeWalker(P,129);function X(e,t){if(!B(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(t):t}const K=(e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":3===t?"<math>":"",o=F;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===F?"!--"===l[1]?o=O:void 0!==l[1]?o=V:void 0!==l[2]?(U.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=N):void 0!==l[3]&&(o=N):o===N?">"===l[0]?(o=null!=n?n:F,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?N:'"'===l[3]?H:I):o===H||o===I?o=N:o===O||o===V?o=F:(o=N,n=void 0);const h=o===N&&e[t+1].startsWith("/>")?" ":"";r+=o===F?i+M:c>=0?(s.push(a),i.slice(0,c)+x+i.slice(c)+A+h):i+A+(-2===c?t:h)}return[X(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]};class J{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]=K(e,t);if(this.el=J.createElement(l,i),Y.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=Y.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(x)){const t=c[r++],i=s.getAttribute(e).split(A),o=/([.?@])?(.*)/.exec(t);a.push({type:1,index:n,name:o[2],strings:i,ctor:"."===o[1]?se:"?"===o[1]?ne:"@"===o[1]?re:ie}),s.removeAttribute(e)}else e.startsWith(A)&&(a.push({type:6,index:n}),s.removeAttribute(e));if(U.test(s.tagName)){const e=s.textContent.split(A),t=e.length-1;if(t>0){s.textContent=L?L.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],_()),Y.nextNode(),a.push({type:2,index:++n});s.append(e[t],_())}}}else if(8===s.nodeType)if(s.data===$)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(A,e+1));)a.push({type:7,index:n}),e+=A.length-1}n++}}static createElement(e,t){const i=P.createElement("template");return i.innerHTML=e,i}}function Z(e,t,i=e,s){var n,r,o;if(t===W)return t;let a=void 0!==s?null===(n=i._$Co)||void 0===n?void 0:n[s]:i._$Cl;const l=R(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=Z(e,a._$AS(e,t.values),a,s)),t}class ee{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:P).importNode(i,!0);Y.currentNode=n;let r=Y.nextNode(),o=0,a=0,l=s[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new te(r,r.nextSibling,this,e):1===l.type?t=new l.ctor(r,l.name,l.strings,this,e):6===l.type&&(t=new oe(r,this,e)),this._$AV.push(t),l=s[++a]}o!==(null==l?void 0:l.index)&&(r=Y.nextNode(),o++)}return Y.currentNode=P,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 te{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=G,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=Z(this,e,t),R(e)?e===G||null==e||""===e?(this._$AH!==G&&this._$AR(),this._$AH=G):e!==this._$AH&&e!==W&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>B(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!==G&&R(this._$AH)?this._$AA.nextSibling.data=e:this.T(P.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=J.createElement(X(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 ee(n,this),t=e.u(this.options);e.p(i),this.T(t),this._$AH=e}}_$AC(e){let t=Q.get(e.strings);return void 0===t&&Q.set(e.strings,t=new J(e)),t}k(e){B(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 te(this.O(_()),this.O(_()),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=C(e).nextSibling;C(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 ie{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=G,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=G}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=Z(this,e,t,0),r=!R(e)||e!==this._$AH&&e!==W,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=Z(this,s[i+o],t,o),a===W&&(a=this._$AH[o]),r||(r=!R(a)||a!==this._$AH[o]),a===G?e=G:e!==G&&(e+=(null!=a?a:"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===G?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class se extends ie{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===G?void 0:e}}class ne extends ie{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==G)}}class re extends ie{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=Z(this,e,t,0))&&void 0!==i?i:G)===W)return;const s=this._$AH,n=e===G&&s!==G||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==G&&(s===G||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 oe{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){Z(this,e)}}const ae=T.litHtmlPolyfillSupport;null==ae||ae(J,te),(null!==(E=T.litHtmlVersions)&&void 0!==E?E:T.litHtmlVersions=[]).push("3.3.3");class le{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 te(t.insertBefore(_(),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 ce extends le{onConnect(){this.render()}template(){var e,t;const i=this.config,s=void 0!==i.logo,n=h(i).topBar,r=e=>z`<div class="eb-slot-${e}"></div>`;return z`
|
|
7
7
|
<div class="eb-top-bar">
|
|
8
|
-
${
|
|
9
|
-
${void 0!==
|
|
10
|
-
<img class="eb-top-bar__logo" src="${
|
|
11
|
-
</a>`:
|
|
8
|
+
${s?z`
|
|
9
|
+
${void 0!==i.logoLink?z`<a class="eb-top-bar__logo-link" href="${i.logoLink}" target="_blank" rel="noopener">
|
|
10
|
+
<img class="eb-top-bar__logo" src="${i.logo}" alt="" />
|
|
11
|
+
</a>`:z`<img class="eb-top-bar__logo" src="${i.logo}" alt="" />`}
|
|
12
12
|
`:""}
|
|
13
13
|
|
|
14
14
|
<div class="eb-top-bar__actions">
|
|
15
|
-
${(
|
|
16
|
-
${(
|
|
15
|
+
${(null!==(e=n.left)&&void 0!==e?e:[]).map(r)}
|
|
16
|
+
${(null!==(t=n.right)&&void 0!==t?t:[]).map(r)}
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
|
-
`}}class
|
|
19
|
+
`}}class de extends le{onConnect(){this.render()}template(){var e,t,i;const s=h(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`
|
|
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">
|
|
23
|
-
${(e.left
|
|
24
|
-
${(
|
|
25
|
-
${(
|
|
23
|
+
${(null!==(e=s.left)&&void 0!==e?e:[]).map(n)}
|
|
24
|
+
${(null!==(t=s.center)&&void 0!==t?t:[]).map(n)}
|
|
25
|
+
${(null!==(i=s.right)&&void 0!==i?i:[]).map(n)}
|
|
26
26
|
</div>
|
|
27
27
|
</div>
|
|
28
|
-
`}}const
|
|
28
|
+
`}}const he={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 ue=!1,ve=Object.assign({},he);function ge(e){return`<svg xmlns="http://www.w3.org/2000/svg" style="display:none"><defs>${Object.values(e).join("")}</defs></svg>`}function pe(e){if(ue&&(void 0===e||0===Object.keys(e).length))return;void 0!==e&&(ve=Object.assign(Object.assign({},ve),e));const t=ge(ve),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)}ue=!0}function me(e,t){return q`<svg class="${void 0!==t?`eb-icon ${t}`:"eb-icon"}" aria-hidden="true"><use href="#eb-${e}"></use></svg>`}class fe extends le{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=h(this.config).middleBar,r=e=>z`<div class="eb-slot-${e}"></div>`;return z`
|
|
29
29
|
<div class="eb-middle-bar">
|
|
30
|
-
${(
|
|
30
|
+
${(null!==(e=n.left)&&void 0!==e?e:[]).map(r)}
|
|
31
31
|
<button
|
|
32
32
|
class="eb-button eb-middle-bar__play-btn"
|
|
33
33
|
@click="${()=>this.handleClick()}"
|
|
34
|
-
aria-label="${
|
|
34
|
+
aria-label="${s?"Pause":"Play"}"
|
|
35
35
|
>
|
|
36
|
-
${
|
|
36
|
+
${me(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
|
|
40
|
+
`}handleClick(){const e=this.state,t=this.bus;"playing"===e.playbackState||"buffering"===e.playbackState?t.emit("pause"):t.emit("play")}}class be extends le{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`
|
|
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
|
-
${
|
|
46
|
+
${me(t?"pause":"play")}
|
|
47
47
|
</button>
|
|
48
|
-
`}}class
|
|
48
|
+
`}}class ye extends le{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`
|
|
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
|
-
${
|
|
55
|
+
${me(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
|
|
65
|
+
`}}function ke(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 we(e){return new Date(e).toTimeString().split(" ")[0]}class Ee extends le{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`
|
|
66
66
|
<div
|
|
67
|
-
class="eb-epg-segment${
|
|
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:
|
|
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,h=t>0?i/t*100:0,u=this.findActiveChapter(r),v=null!==u?this.findSkippableChapter(u):null,g=r.map(e=>{const i=t>0?e.startTime/t*100:0,s=e===u,n=a?`right: ${i.toFixed(2)}%`:`left: ${i.toFixed(2)}%`;return z`
|
|
72
72
|
<div
|
|
73
|
-
class="eb-chapter-marker${
|
|
73
|
+
class="eb-chapter-marker${s?" eb-chapter-active":""}"
|
|
74
74
|
style="${n}"
|
|
75
75
|
title="${e.title}"
|
|
76
76
|
></div>
|
|
77
|
-
`}),
|
|
77
|
+
`}),p=null!==u&&null!==v?z`
|
|
78
78
|
<button
|
|
79
79
|
class="eb-chapter-skip"
|
|
80
80
|
@click="${()=>this.bus.emit("seek",{time:u.endTime})}"
|
|
81
|
-
>${
|
|
82
|
-
`:
|
|
81
|
+
>${v.message}</button>
|
|
82
|
+
`:z``,m=this.renderEpgSegments(o,a),f=this.state.isLive&&Number.isFinite(t)?we(Date.now()-1e3*(t-this.tooltipTime)):ke(this.tooltipTime),b=z`
|
|
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:
|
|
88
|
-
${
|
|
87
|
+
${null!==this.previewVideoEl?this.previewVideoEl:z``}
|
|
88
|
+
${f}
|
|
89
89
|
</div>
|
|
90
|
-
`;return
|
|
90
|
+
`;return z`
|
|
91
91
|
<div
|
|
92
92
|
class="eb-seekbar${c?" eb-seekbar-disabled":""}"
|
|
93
93
|
?hidden="${l}"
|
|
@@ -98,56 +98,56 @@
|
|
|
98
98
|
@pointermove="${e=>this.handlePointerMove(e)}"
|
|
99
99
|
@pointerup="${e=>this.handlePointerUp(e)}"
|
|
100
100
|
>
|
|
101
|
-
<div class="eb-seekbar-buffered" style="width: ${
|
|
102
|
-
<div class="eb-seekbar-progress" style="width: ${
|
|
101
|
+
<div class="eb-seekbar-buffered" style="width: ${h.toFixed(2)}%"></div>
|
|
102
|
+
<div class="eb-seekbar-progress" style="width: ${d.toFixed(2)}%">
|
|
103
103
|
<div class="eb-seekbar-thumb"></div>
|
|
104
104
|
</div>
|
|
105
|
-
${
|
|
106
|
-
${
|
|
105
|
+
${g}
|
|
106
|
+
${m}
|
|
107
107
|
${b}
|
|
108
108
|
</div>
|
|
109
|
-
${
|
|
109
|
+
${p}
|
|
110
110
|
</div>
|
|
111
|
-
`}}class
|
|
111
|
+
`}}class Te extends le{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">${we(Date.now())} <span class="eb-time-display__offset">-${ke(i)}</span></div>`}n=we(Date.now())}else n=`${ke(e)} / ${ke(t)}`;return z`<div class="eb-time-display">${n}</div>`}}class Ce extends le{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`
|
|
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">${
|
|
117
|
+
<span class="eb-live-sync__icon">${me("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
|
-
`:
|
|
121
|
+
`:z`<button class="eb-live-sync" hidden style="display:none">${me("live")}</button>`}}const Le=[.25,.5,.75,1,1.25,1.5,1.75,2];class Se extends le{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`
|
|
122
122
|
<li>
|
|
123
|
-
<button class="eb-settings-category" @click="${()=>this.navigateTo(
|
|
124
|
-
<span class="eb-settings-category__icon">${
|
|
123
|
+
<button class="eb-settings-category" @click="${()=>this.navigateTo(s)}">
|
|
124
|
+
<span class="eb-settings-category__icon">${me(e)}</span>
|
|
125
125
|
<span class="eb-settings-category__label">${t}</span>
|
|
126
|
-
<span class="eb-settings-category__value">${
|
|
127
|
-
<span class="eb-settings-category__chevron">${
|
|
126
|
+
<span class="eb-settings-category__value">${i}</span>
|
|
127
|
+
<span class="eb-settings-category__chevron">${me("chevron-right")}</span>
|
|
128
128
|
</button>
|
|
129
129
|
</li>
|
|
130
|
-
`;return
|
|
130
|
+
`;return z`
|
|
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
|
-
${
|
|
135
|
-
${
|
|
134
|
+
${s?n("speed",t.t("settings.speed"),this.currentValueLabel("speed"),"speed"):""}
|
|
135
|
+
${i?n("quality",t.t("settings.quality"),this.currentValueLabel("quality"),"quality"):""}
|
|
136
136
|
</ul>
|
|
137
|
-
`}renderSubMenu(e,t,
|
|
137
|
+
`}renderSubMenu(e,t,i){return z`
|
|
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
|
-
${
|
|
141
|
+
${me("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=>
|
|
146
|
+
${t.map(e=>z`
|
|
147
147
|
<li>
|
|
148
148
|
<button
|
|
149
149
|
class="eb-settings-item ${e.selected?"eb-settings-item--selected":""}"
|
|
150
|
-
@click="${()=>
|
|
150
|
+
@click="${()=>i(e)}"
|
|
151
151
|
>
|
|
152
152
|
${e.label}
|
|
153
153
|
</button>
|
|
@@ -155,11 +155,11 @@
|
|
|
155
155
|
`)}
|
|
156
156
|
</ul>
|
|
157
157
|
</div>
|
|
158
|
-
`}renderQualityMenu(){const e=function(e,t){const
|
|
159
|
-
<div class="${
|
|
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 Le.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`
|
|
159
|
+
<div class="${i}">
|
|
160
160
|
${t}
|
|
161
161
|
</div>
|
|
162
|
-
`}else e=
|
|
162
|
+
`}else e=z``;return z`
|
|
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
|
-
${
|
|
170
|
+
${me("settings")}
|
|
171
171
|
</button>
|
|
172
172
|
</div>
|
|
173
|
-
`}}class
|
|
173
|
+
`}}class xe extends le{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">${me("pip")}</button>`;const e=this.state.isPip?"Exit picture-in-picture":"Picture-in-picture";return z`
|
|
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
|
-
${
|
|
179
|
+
${me("pip")}
|
|
180
180
|
</button>
|
|
181
|
-
`}}class
|
|
181
|
+
`}}class Ae extends le{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`
|
|
182
182
|
<button
|
|
183
183
|
class="${t?"eb-cast eb-cast-active":"eb-cast"}"
|
|
184
184
|
aria-label="${t?"Stop casting":"Cast"}"
|
|
185
|
-
@click="${()=>this.bus.emit("cast-start",{src:
|
|
185
|
+
@click="${()=>this.bus.emit("cast-start",{src:i})}"
|
|
186
186
|
>
|
|
187
|
-
${
|
|
187
|
+
${me("cast")}
|
|
188
188
|
</button>
|
|
189
|
-
`:
|
|
189
|
+
`:z`<button class="eb-cast" hidden aria-hidden="true">${me("cast")}</button>`}}const $e=[["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"]],Me=(()=>{if("undefined"==typeof document)return!1;const e=$e[0],t={};for(const i of $e){if((null==i?void 0:i[1])in document){for(const[s,n]of i.entries())t[e[s]]=n;return t}}return!1})(),Pe={change:Me.fullscreenchange,error:Me.fullscreenerror};let _e={request:(e=document.documentElement,t)=>new Promise((i,s)=>{const n=()=>{_e.off("change",n),i()};_e.on("change",n);const r=e[Me.requestFullscreen](t);r instanceof Promise&&r.then(n).catch(s)}),exit:()=>new Promise((e,t)=>{if(!_e.isFullscreen)return void e();const i=()=>{_e.off("change",i),e()};_e.on("change",i);const s=document[Me.exitFullscreen]();s instanceof Promise&&s.then(i).catch(t)}),toggle:(e,t)=>_e.isFullscreen?_e.exit():_e.request(e,t),onchange(e){_e.on("change",e)},onerror(e){_e.on("error",e)},on(e,t){const i=Pe[e];i&&document.addEventListener(i,t,!1)},off(e,t){const i=Pe[e];i&&document.removeEventListener(i,t,!1)},raw:Me};Object.defineProperties(_e,{isFullscreen:{get:()=>Boolean(document[Me.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!==(e=document[Me.fullscreenElement])&&void 0!==e?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[Me.fullscreenEnabled])}}),Me||(_e={isEnabled:!1});var Re=_e;class Be extends le{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}),Re.isEnabled?(this.changeHandler=()=>{this.state.isFullscreen=Re.isFullscreen,this.render()},Re.on("change",this.changeHandler),this.signal.addEventListener("abort",()=>{Re.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(Re.isEnabled){const t=null!==(e=this.el.closest(".eb-player"))&&void 0!==e?e:this.el;return void Re.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(!(Re.isEnabled||this.useVideoFallback))return z`<button class="eb-fullscreen" hidden aria-hidden="true">${me("fullscreen")}</button>`;const e=this.state.isFullscreen;return z`
|
|
190
190
|
<button
|
|
191
191
|
class="eb-fullscreen"
|
|
192
192
|
aria-label="${e?"Exit fullscreen":"Fullscreen"}"
|
|
193
193
|
@click="${()=>this.handleClick()}"
|
|
194
194
|
>
|
|
195
|
-
${
|
|
195
|
+
${me(e?"fullscreen-exit":"fullscreen")}
|
|
196
196
|
</button>
|
|
197
|
-
`}}class
|
|
197
|
+
`}}class De extends le{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`
|
|
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?
|
|
203
|
+
${t?me("rewind","eb-seek-circle"):z`<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
|
|
208
|
+
`}handleClick(){const e=this.config.seekOffset||15,t=Math.max(this.state.currentTime-e,0);this.bus.emit("seek",{time:t})}}class Fe extends le{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`
|
|
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?
|
|
214
|
+
${t?me("forward","eb-seek-circle"):z`<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
|
|
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 Oe extends le{onConnect(){this.render()}template(){return!1===this.config.socials?z`<span hidden></span>`:z`
|
|
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
|
-
>${
|
|
225
|
-
`}}class
|
|
224
|
+
>${me("share")}</button>
|
|
225
|
+
`}}class Ve extends le{onConnect(){this.render()}template(){return z`
|
|
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
|
-
>${
|
|
231
|
-
`}}class
|
|
230
|
+
>${me("info")}</button>
|
|
231
|
+
`}}class Ne extends le{onConnect(){this.render()}template(){const e=this.config.channelName;return e?z`<span class="eb-channel-name">${e}</span>`:z``}}const Ie={"play-pause":()=>new be,volume:()=>new ye,seekbar:()=>new Ee,time:()=>new Te,"live-sync":()=>new Ce,settings:()=>new Se,pip:()=>new xe,cast:()=>new Ae,fullscreen:()=>new Be,rewind:()=>new De,forward:()=>new Fe,share:()=>new Oe,info:()=>new Ve,"channel-name":()=>new Ne};function He(e){return"seekbar"===e?".eb-bottom-bar__seekbar-zone":`.eb-slot-${e}`}class Ue extends le{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}">
|
|
232
232
|
<div class="eb-loading-arc"></div>
|
|
233
|
-
${
|
|
234
|
-
</div>`}}class
|
|
233
|
+
${s?z`<span class="eb-loading-text">${n}</span>`:""}
|
|
234
|
+
</div>`}}class je extends le{onConnect(){this.state.on("error",()=>this.render(),{signal:this.signal}),this.render()}template(){const e=this.state.error;return null===e?z`<div class="eb-error" hidden aria-hidden="true"></div>`:z`
|
|
235
235
|
<div class="eb-error" role="alert">
|
|
236
236
|
<p class="eb-error-message">${e}</p>
|
|
237
237
|
<button
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
Retry
|
|
242
242
|
</button>
|
|
243
243
|
</div>
|
|
244
|
-
`}}class
|
|
244
|
+
`}}class ze extends le{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`
|
|
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
|
|
253
|
+
`):[];return z`
|
|
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
|
|
266
|
+
`}}class qe extends le{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`
|
|
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
|
|
277
|
+
`}}class We extends le{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 Ge extends le{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`
|
|
278
278
|
<div
|
|
279
279
|
class="eb-preroll-overlay"
|
|
280
|
-
@click="${e=>this.handleOverlayClick(e,
|
|
280
|
+
@click="${e=>this.handleOverlayClick(e,s)}"
|
|
281
281
|
>
|
|
282
|
-
${
|
|
283
|
-
class="eb-preroll-skip${
|
|
284
|
-
aria-label="${
|
|
285
|
-
?disabled="${!
|
|
282
|
+
${n?z`<button
|
|
283
|
+
class="eb-preroll-skip${o?"":" eb-preroll-skip--locked"}"
|
|
284
|
+
aria-label="${a}"
|
|
285
|
+
?disabled="${!o}"
|
|
286
286
|
@click="${e=>this.handleSkip(e)}"
|
|
287
|
-
>${
|
|
287
|
+
>${a}${r>0?z` (${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{console.warn("PrerollOverlay: invalid prerollLink",t)}}}class
|
|
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 Qe extends le{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`
|
|
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
|
‹
|
|
298
298
|
</button>
|
|
299
299
|
<div class="eb-forja-playlist-bar__items">
|
|
300
|
-
${e.map((e,
|
|
300
|
+
${e.map((e,i)=>z`
|
|
301
301
|
<div
|
|
302
|
-
class="eb-forja-playlist-bar__item${
|
|
302
|
+
class="eb-forja-playlist-bar__item${i===t?" eb-forja-playlist-bar__item--active":""}"
|
|
303
303
|
>
|
|
304
|
-
${e.image?
|
|
304
|
+
${e.image?z`<img
|
|
305
305
|
class="eb-forja-playlist-bar__thumb"
|
|
306
306
|
src="${e.image}"
|
|
307
307
|
alt=""
|
|
@@ -320,9 +320,9 @@
|
|
|
320
320
|
›
|
|
321
321
|
</button>
|
|
322
322
|
</div>
|
|
323
|
-
`}formatDuration(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}}class
|
|
323
|
+
`}formatDuration(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}}class Ye extends le{onConnect(){this.render(),this.state.on("epgPrograms",()=>{this.render()},{signal:this.signal})}template(){const e=this.state.epgPrograms;return z`
|
|
324
324
|
<div class="eb-snrt-carousel">
|
|
325
|
-
${e.map(e=>
|
|
325
|
+
${e.map(e=>z`
|
|
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,33 +331,33 @@
|
|
|
331
331
|
</div>
|
|
332
332
|
`)}
|
|
333
333
|
</div>
|
|
334
|
-
`}formatTime(e){return new Date(1e3*e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}const
|
|
334
|
+
`}formatTime(e){return new Date(1e3*e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}const Xe={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 Ke extends le{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(){ve=Object.assign({},he);const e=ge(ve),t=document.getElementById("eb-sprite");null!==t&&(t.innerHTML=e)}(),pe(),"modern"===this.config.skin&&pe(Xe),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`
|
|
335
335
|
<div
|
|
336
|
-
class="eb-player${
|
|
337
|
-
dir="${
|
|
336
|
+
class="eb-player${s?" eb-ios-native":""}"
|
|
337
|
+
dir="${i?"rtl":"ltr"}"
|
|
338
338
|
>
|
|
339
339
|
<video
|
|
340
340
|
class="eb-video"
|
|
341
341
|
playsinline
|
|
342
342
|
.muted="${e.muted}"
|
|
343
343
|
?autoplay="${e.autoplay}"
|
|
344
|
-
?controls="${
|
|
344
|
+
?controls="${s}"
|
|
345
345
|
></video>
|
|
346
346
|
|
|
347
347
|
<div class="eb-overlay-zone">
|
|
348
|
-
${!1!==e.image?
|
|
348
|
+
${!1!==e.image?z`<img
|
|
349
349
|
class="eb-poster"
|
|
350
350
|
src="${e.image}"
|
|
351
|
-
style="${
|
|
351
|
+
style="${o?"":"display:none"}"
|
|
352
352
|
alt=""
|
|
353
353
|
/>`:""}
|
|
354
|
-
${e.posterStream?
|
|
354
|
+
${e.posterStream?z`<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
|
-
${
|
|
360
|
+
${a?z`<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?
|
|
374
|
+
${void 0!==e.logo?z`<img class="eb-logo" src="${e.logo}" alt="" />`:""}
|
|
375
375
|
</div>
|
|
376
376
|
|
|
377
|
-
${n?
|
|
377
|
+
${n?z`<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(){const
|
|
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=h(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=Ie[t];if(void 0===s)continue;const o=He(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 ce,".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 de,".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 fe,".eb-middle-bar-zone")&&void 0!==o.middleBar){const e=s.querySelector(".eb-middle-bar-zone");null!==e&&c(e,o.middleBar)}}const u=document.createElement("div");u.className="eb-loading-slot",s.appendChild(u);const v=new Ue;v.connect(u,n,r,i,a),this.childComponents.push(v);const g=[[new je,"eb-error-slot"],[new ze,"eb-socials-slot"],[new qe,"eb-info-slot"],[new We,"eb-toast-slot"],[new Ge,"eb-preroll-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 Qe,".eb-extension-bottom-extra"),"snrt"===i.skin&&l(new Ye,".eb-extension-bottom-extra")}renderNoUiTemplate(){const e=this.config;return z`
|
|
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(){const e=this.el?.firstElementChild;this.videoElement=null!==e?e.querySelector("video.eb-video"):null,this.adsContainerElement=null!==e?e.querySelector(".eb-ads-container"):null;this.config.posterStream&&null!==e&&(this.posterVideoElement=e.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(){const e=this.el?.firstElementChild;if(null==e)return;const t=e.querySelector(".eb-poster");if(null===t)return;const s=this.state.playbackState,i=this.state.currentTime>0,n=!1!==this.config.image&&("idle"===s||"loading"===s||"playing"===s&&!i);t.style.display=n?"":"none"}updateIOSState(){const e=this.el?.firstElementChild;if(null==e)return;const t=this.state.isIOS;e.classList.toggle("eb-ios-native",t);const s=e.querySelector("video.eb-video");null!==s&&(s.controls=t)}updateRadioOverlay(){const e=this.el?.firstElementChild;if(null==e)return;const t=e.querySelector(".eb-overlay-zone");if(null===t)return;const s=t.querySelector(".eb-radio-overlay"),i=this.state.isRadio;if(i&&null===s){const e=document.createElement("div");e.className="eb-radio-overlay";const s=document.createElement("div");s.className="eb-radio-bars";for(let e=0;e<5;e++){const e=document.createElement("span");e.className="eb-radio-bar",s.appendChild(e)}e.appendChild(s),t.appendChild(e)}else i||null===s||s.remove()}updateControlsVisibility(){const e=this.el?.firstElementChild;if(null==e)return;const t=this.state.controlsVisible;e.classList.toggle("eb-controls-visible",t),e.classList.toggle("eb-controls-hidden",!t)}updateAdPlayingState(){const e=this.el?.firstElementChild;null!=e&&e.classList.toggle("eb-ad-playing",this.state.adPlaying)}applyRtl(){const e=this.el?.firstElementChild;null!=e&&e.setAttribute("dir",this.state.isRtl?"rtl":"ltr")}invokeExtensions(){const e=this.config.extensions;if(void 0===e)return;const t=this.el?.firstElementChild;if(null==t)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[i,n]of Object.entries(e)){const e=s[i];if(void 0===e)continue;const r=t.querySelector(e);if(null===r)continue;const a=n(r,this.state,this.bus,this.signal);"function"==typeof a&&this.extensionCleanups.push(a)}}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 Ke{constructor(e,t,s){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),s.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 Xe{constructor(e,t,s,i,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?s.emit("pause"):s.emit("play"));if("ArrowLeft"===n.key){const e=i.seekOffset||15,n=Math.max(t.currentTime-e,0);return void s.emit("seek",{time:n})}if("ArrowRight"===n.key){const e=i.seekOffset||15,n=Math.min(t.currentTime+e,t.duration);return void s.emit("seek",{time:n})}i.supportHotKeys&&("m"!==n.key||s.emit("mute-toggle"))}};e.addEventListener("keyup",r),n.addEventListener("abort",()=>{e.removeEventListener("keyup",r)},{once:!0})}}function Je(e){const t=window;if(void 0!==t[e])return t[e];try{return(0,eval)(e)}catch{return}}function Ze(e,t,s={}){const i=Je(t);if(void 0!==i)return Promise.resolve(i);const n=s.timeout??1e4;return new Promise((s,i)=>{let r;const a=()=>{clearTimeout(r)},o=document.createElement("script");o.src=e,o.onload=()=>{a();const n=Je(t);void 0===n?i(new Error(`CDN: '${t}' not on window after loading ${e}`)):s(n)},o.onerror=()=>{a(),i(new Error(`CDN: failed to load ${e}`))},r=setTimeout(()=>{i(new Error(`CDN: timeout loading ${e}`))},n),document.head.appendChild(o)})}let et=null;class tt{constructor(e){this.localDriver=null,this.signal=e.signal}async init(e,t,s){if(!e.chromecast)return;const i=await Ze(e.chromecast,"Castjs");null===et&&(et=new i({receiver:e.chromecastApp??"00197684"})),this.localDriver=et,this.applyMetadata(e.chromecastMetadata),this.bindDriverEvents(t,s),this.registerAbortCleanup()}getDriver(){return this.localDriver}toggleCast(e){const t=this.localDriver;if(null!==t)if(t.connected)t.disconnect();else if(e.castAvailable){const s=this.buildCastOptions(e);t.cast(e.src??"",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 s=this.localDriver;s.on("available",()=>{e.castAvailable=!0}),s.on("connect",()=>{e.isCasting=!0}),s.on("disconnect",()=>{const i=s.time;e.isCasting=!1,void 0!==i&&i>0?t.emit("cast-stop-with-position",{time:i}):t.emit("cast-stop")}),s.on("error",()=>{e.isCasting=!1,t.emit("cast-failed")})}buildCastOptions(e){const t=this.localDriver;return{title:t?.title,description: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 st{constructor(){this.pollTimer=null}async start(e,t,s){if(void 0!==e.epgContentId&&(await this.fetchEpg(e,t),null!==e.epgPolling&&void 0!==e.epgPolling)){const i=1e3*e.epgPolling;this.pollTimer=setInterval(()=>{this.fetchEpg(e,t)},i),s.addEventListener("abort",()=>{clearInterval(this.pollTimer),this.pollTimer=null},{once:!0})}}async fetchEpg(e,t){const s=`https://epg.dev.easybroadcast.io/channels/${e.epgContentId}/last-24-h-programs`;try{const e=await fetch(s,{mode:"cors"});if(!e.ok)throw new Error(`EPG fetch failed with status: ${e.status}`);const i=await e.json();t.epgPrograms=i,t.epgFetchedAt=Date.now()}catch(e){console.error("EBPlayer: Error fetching EPG data:",e)}}}class it{init(e,t,s,i){const n=e.playlist;n&&0!==n.length&&(t.playlist=n,t.currentEpisode=0,s.on("playlist-next",()=>{this.advance(t,1)},{signal:i}),s.on("playlist-prev",()=>{this.advance(t,-1)},{signal:i}))}advance(e,t){const s=e.playlist.length,i=(e.currentEpisode+t+s)%s;e.currentEpisode=i,e.src=e.playlist[i].src}}class nt{constructor(){this.imaAdsManager=null,this.imaDisplayContainer=null}async init(e,t,s,i,n,r){if(!e.ad)return;let a=null,o=null,l=!1;const c=new AbortController;r.addEventListener("abort",()=>c.abort(),{once:!0});const h=()=>{null!==a&&(clearTimeout(a),a=null)},d=()=>{null!==o&&(clearTimeout(o),o=null)},u=()=>{l||(l=!0,h(),d(),null===this.imaAdsManager&&this.releaseImaResources(),t.adPlaying=!1,s.emit("ad-complete"),c.abort())};r.addEventListener("abort",()=>{h(),d(),this.releaseImaResources()},{once:!0});const g=e.autoplay?null:this.waitForUserGesture(i,c.signal);if(!(e.preroll&&(await new Promise(e=>{const t=()=>{h(),e()};s.on("intro-stream-complete",t,{signal:r}),r.addEventListener("abort",t,{once:!0}),a=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)||(o=setTimeout(()=>{console.warn("AdsManager: ad leg produced no AdsManager within the bound — falling through to main (G-07-11)"),u()},2e4),null!==g&&await g,r.aborted||l)))try{const s=await Ze("https://imasdk.googleapis.com/js/sdkloader/ima3.js","google");if(l)return;const{ima:r}=s,a=new r.AdDisplayContainer(n,i);this.imaDisplayContainer=a,a.initialize();const o=new r.AdsLoader(a);o.addEventListener(r.AdErrorEvent.Type.AD_ERROR,e=>{console.warn("AdsManager: AD_ERROR (loader) — falling through to main",e),u()}),o.addEventListener(r.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>{if(l)return;const s=e.getAdsManager(i);this.imaAdsManager=s,d();const n=i.getBoundingClientRect(),a=n.width>0?n.width:640,o=n.height>0?n.height:360;s.addEventListener(r.AdEvent.Type.CONTENT_PAUSE_REQUESTED,()=>{console.log("AdsManager: CONTENT_PAUSE_REQUESTED — content paused (D-08-08)"),t.adPlaying=!0,i.pause()}),s.addEventListener(r.AdEvent.Type.CONTENT_RESUME_REQUESTED,()=>{console.log("AdsManager: CONTENT_RESUME_REQUESTED — content resumed (D-08-08)"),t.adPlaying=!1,i.play(),u()}),s.addEventListener(r.AdEvent.Type.ALL_ADS_COMPLETED,()=>{console.log("AdsManager: ALL_ADS_COMPLETED — ad leg complete (D-08-08)"),u()}),s.addEventListener(r.AdErrorEvent.Type.AD_ERROR,e=>{console.warn("AdsManager: AD_ERROR (manager) — falling through to main",e),u()}),s.addEventListener(r.AdEvent.Type.SKIPPABLE_STATE_CHANGED,()=>{console.log("AdsManager: ad became skippable (D-08-06)")}),s.init(a,o),s.start()});const c=new r.AdsRequest;c.adTagUrl=e.ad,o.requestAds(c)}catch(e){console.warn("AdsManager: failed to load or initialize the IMA SDK — falling through to main (G-07-11)",e),u()}}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(s=>{const i=e.closest(".eb-player")??e;let n=!1;const r=()=>{n||(n=!0,i.removeEventListener("click",a,{capture:!0}),s())},a=()=>r();i.addEventListener("click",a,{capture:!0}),t.addEventListener("abort",r,{once:!0})})}}class rt{async init(e,t,s,i,n){if(!e.preroll)return;t.introStreamPlaying=!0;const r=new AbortController;n.addEventListener("abort",()=>r.abort(),{once:!0});let a=0,o=!1;const l=()=>{o||(o=!0,clearTimeout(a),t.introStreamPlaying=!1,s.emit("intro-stream-complete"),r.abort())},c=()=>l();i.addEventListener("ended",c),s.on("preroll-skip",l,{signal:r.signal}),s.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}),s.on("force-intro-complete",()=>{console.warn("IntroStreamManager: main is opening — force-completing the intro pass"),l()},{signal:r.signal}),a=setTimeout(()=>{console.warn("IntroStreamManager: intro stream exceeded INTRO_MAX_DURATION_MS — falling through to main"),l()},9e4),n.addEventListener("abort",()=>{i.removeEventListener("ended",c),clearTimeout(a)},{once:!0})}}var at,ot={exports:{}};var lt=(at||(at=1,function(e){var t,s,i,n,r=(t={fromVtt:function(e,t,i){var n=!!i;(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=[],a=0;a<e.length;a+=4){var o=e[a+3];n&&((o=o.split("\n")).shift(),o=o.join("\n")),0!==o.trim().length&&r.push({id:e[a]?+e[a].trim():r.length+1,startTime:s(e[a+1].trim(),t),endTime:s(e[a+2].trim(),t),text:o.trim()})}return r},toVtt:function(e){if(!e instanceof Array)return"";for(var t="",s=0;s<e.length;s++){var i=e[s];isNaN(i.startTime)||isNaN(i.endTime)||(i.startTime=n(parseInt(i.startTime,10)),i.endTime=n(parseInt(i.endTime,10))),t+=i.id+"\r\n",t+=i.startTime+" --\x3e "+i.endTime+"\r\n",t+=i.text.replace("\n","\r\n")+"\r\n\r\n"}return t}},s=function(e,t){return"ms"===t?i(e):"s"===t?i(e)/1e3:e},i=function(e){var t=/(\d+):(\d{2}):(\d{2})[,.](\d{3})/.exec(e);if(null===t)return 0;for(var s=1;s<5;s++)t[s]=parseInt(t[s],10),isNaN(t[s])&&(t[s]=0);return 36e5*t[1]+6e4*t[2]+1e3*t[3]+t[4]},n=function(e){var t=[36e5,6e4,1e3],s=[];for(var i in t){var n=(e/t[i]|0).toString();n.length<2&&(n="0"+n),e%=t[i],s.push(n)}var r=e.toString();if(r.length<3)for(i=0;i<=3-r.length;i++)r="0"+r;return s.join(":")+","+r},t);e.exports=r}(ot)),ot.exports);function ct(e){if(!e||!e.trim())return[];return lt.fromVtt(e,"s").map(e=>({title:e.text,startTime:e.startTime,endTime:e.endTime}))}class ht{get signal(){return this.abortController.signal}get container(){return this._container}constructor(e){this.hasExplicitPrimaryColor=void 0!==e.primaryColor,this.config=m(u,e),this.state=r(),this.bus=new a,this.i18n=new y(this.config.lang),this.abortController=new AbortController,this._container=null,this.engineSync=null,this.skinRoot=null,this.commandHandler=null,this.chromecastManager=null,this.reloadCallback=null}mount(e){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 t=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)),t?.general&&(e.style.setProperty("--eb-color-primary",t.general),e.style.setProperty("--eb-color-progress",t.general),e.style.setProperty("--eb-accent",t.general)),t?.progressBar&&e.style.setProperty("--eb-color-progress",t.progressBar),t?.volumeBar&&e.style.setProperty("--eb-color-volume",t.volumeBar),this.state.isRtl=this.config.rtl??"ar"===this.config.lang,this.state.isRadio=!0===this.config.radio;const s=new Ye;this.skinRoot=s,s.connect(e,this.state,this.bus,this.config,this.i18n);const i=s.getVideoElement();null!==i&&(this.state.muted=i.muted,this.state.volume=i.volume),this.config.noUi||(new Ke(e,this.state,this.signal),new Xe(e,this.state,this.bus,this.config,this.signal)),this.initIntegrations();const n=this.skinRoot?.getVideoElement()??null;null!==n&&(this.commandHandler=new k(this.bus,n,this.state,()=>this.engineSync,this.chromecastManager,this.i18n,()=>{this.reloadCallback?.()},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,s){/^https?:\/\//i.test(e.trim())?async function(e){try{const t=await fetch(e);return ct(await t.text())}catch{return[]}}(e).then(e=>{s.aborted||(t.chapters=e)}):t.chapters=ct(e)}initIntegrations(){const{config:e,state:t,bus:s,signal:i}=this;if(e.chromecast){const i=new tt(this.abortController);this.chromecastManager=i,i.init(e,t,s).catch(e=>{console.error("EBPlayer: ChromecastManager init failed:",e)})}if(e.epgContentId){(new st).start(e,t,i).catch(e=>{console.error("EBPlayer: EpgManager start failed:",e)})}const n=e.playlist;if(n&&n.length>0){(new it).init(e,t,s,i)}if(e.ad&&null!==this.skinRoot){const n=this.skinRoot.getVideoElement(),r=this.skinRoot.getAdsContainer();if(null!==n&&null!==r){(new nt).init(e,t,s,n,r,i).catch(e=>{console.error("EBPlayer: AdsManager init failed:",e)})}}if(e.chapters&&this.loadChapters(e.chapters,t,i),e.preroll&&null!==this.skinRoot){const n=new rt,r=this.skinRoot.getVideoElement();null!==r&&n.init(e,t,s,r,i).catch(e=>{console.error("EBPlayer: IntroStreamManager init failed:",e)})}if(e.posterStream){const s=function(){let e=null;return{attach({src:t,container:s,Hls:i}){console.log("Poster HLS: attach media",t,s),e=new i,e.loadSource(t),e.attachMedia(s)},close(){if(e){try{e.detachMedia?.(),e.destroy?.()}catch(e){console.error("Poster HLS player close error:",e)}e=null}},play(){e?.media?.play()},pause(){e?.media?.pause()}}}(),n=this.skinRoot?.getPosterVideoElement()??null;t.on("playbackState",t=>{if("playing"===t){if(null!==n){const t=window.Hls;t&&s.attach({src:e.posterStream,container:n,Hls:t})}s.play()}else"paused"!==t&&"buffering"!==t||s.pause()},{signal:i}),i.addEventListener("abort",()=>{s.close()},{once:!0})}}}class dt{}class ut{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 gt extends dt{constructor(){super(),this.video=null,this.state=null,this.signal=null,this.bus=null,this.config=null,this.loadSourceUrl="",this.watchdog=null,this.driverReady=new Promise(e=>{this.resolveDriverReady=e})}attach(e,t){this.state=e,this.signal=t,this.onAttach()}detach(){this.watchdog?.stop(),this.watchdog=null,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 ut({video:this.video,onRecoverAttempt:e=>{this.recoverFromStall(e)},onReloadRequired:()=>{e.emit("request-reload")},isCasting:()=>this.state?.isCasting??!1}),this.watchdog.start()}stopWatchdog(){this.watchdog?.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,s){const i=this.config?.syncLiveMargin??30;e.addEventListener("timeupdate",()=>{t.currentTime=Math.round(e.currentTime),t.isLive&&(t.isSyncWithLive=e.currentTime+i>e.duration)},{signal:s}),e.addEventListener("durationchange",()=>{t.duration=Math.ceil(e.duration)},{signal:s}),e.addEventListener("volumechange",()=>{t.volume=e.volume,t.muted=e.muted},{signal:s}),e.addEventListener("progress",()=>{e.buffered.length>0&&(t.bufferedEnd=e.buffered.end(e.buffered.length-1))},{signal:s}),e.addEventListener("ratechange",()=>{t.playbackRate=e.playbackRate},{signal:s});let n=!1;e.addEventListener("playing",()=>{n=!1,t.playbackState="playing"},{signal:s}),e.addEventListener("waiting",()=>{t.playbackState="buffering"},{signal:s}),e.addEventListener("pause",()=>{e.seeking||("buffering"!==t.playbackState||e.ended?t.playbackState="paused":n=!0)},{signal:s}),e.addEventListener("seeked",()=>{t.isLive&&(t.currentTime=Math.round(e.currentTime),t.isSyncWithLive=e.currentTime+i>e.duration),(n||"loading"===t.playbackState)&&e.paused&&(t.playbackState="paused",n=!1)},{signal:s}),e.addEventListener("ended",()=>{t.playbackState="ended"},{signal:s}),e.addEventListener("timeupdate",()=>{("buffering"===t.playbackState||"loading"===t.playbackState)&&!e.paused&&(t.playbackState="playing")},{signal:s})}seek(e){null!==this.video&&(this.video.currentTime=e)}}const pt=Object.freeze({EASY_B:"easy_b",BUNNY:"bunny",AKAMAI:"akamai",VENOM:"venom"}),mt=Object.freeze({UNKNOWN:"unknown",MAX_RETRY:"max_retry",FORBIDDEN:"forbidden"});class ft extends Error{constructor({status:e="unknown",errorCode:t="unknown",errorType:s=mt.UNKNOWN,message:i=null}){super(i??`TokenError: ${e} - ${t}`),this.status=e,this.errorCode=t,this.errorType=s}}class vt{constructor({src:e,responseParameters:t,error:s=null,extras:i={}}){if(this.src=e,this.responseParameters=t,this.extras=i??{},null!==s&&!(s instanceof ft))throw new Error("TokenResponse error must be an instance of TokenError");this.error=s}static fromJson({src:e,json:t}){const s=JSON.parse(t),i={token:s.token??null,tokenPath:s.token_path??null,expires:s.expires??null},n=new vt({src:e,responseParameters:i});for(const e of Object.keys(s))["token","expires","token_path"].includes(e)||(n.extras[e]=s[e]);return n}static fromAkamai({src:e,text:t}){const s=bt({src:e,text:t});return new vt({src:e,responseParameters:s})}static fromText({src:e,text:t}){if(t.trim().startsWith("{"))return vt.fromJson({src:e,json:t});const s=kt(t);if(s){const t={token:null,tokenPath:null,...s};return new vt({src:e,responseParameters:t})}const i=new URLSearchParams(t.trim().replace(/^\?/,"")),n=i.get("token")??null,r=i.get("expires"),a=r?parseInt(r,10):null,o=i.get("token_path")??null,l=new vt({src:e,responseParameters:{token:n,tokenPath:o,expires:a}});return i.forEach((e,t)=>{["token","expires","token_path"].includes(t)||(l.extras[t]=e)}),l}static fromDefault({src:e,text:t}){const s=new URLSearchParams(t.trim().replace(/^\?/,"")),i=s.get("expires"),n={verify:s.get("verify")??null,expires:i?parseInt(i,10):null},r=new vt({src:e,responseParameters:n});return s.forEach((e,t)=>{["verify","expires"].includes(t)||(r.extras[t]=e)}),r}static fromError({src:e,error:t}){const s=t instanceof ft?t:new ft(t);return new vt({src:e,error:s})}}function bt({src:e,text:t}){const s=kt(t)?.fullUrl??null,i=new URL(s??`${e}${t?`?${t}`:""}`);let n=null,r=null,a=null,o=null,l=null;const c=new URLSearchParams(i.search);if(n=c.get("hdntl"),l=c.get("hdnea"),!n&&!l){const e=i.pathname.split("/");for(const t of e){if(t.startsWith("hdntl=")){n=t.substring(6);break}if(t.startsWith("hdnea=")){l=t.substring(6);break}}}const h=n??l;if(h){const e=h.match(/exp=(\d+)/);e&&(r=e[1]);const t=h.match(/hmac=([a-f0-9]+)/);t&&(a=t[1]);const s=h.match(/acl=([^~]+)/);s&&(o=s[1])}return{expires:r,hdntl:h,hmac:a,acl:o,hdnea:l,fullUrl:s}}const yt=/^https?:\/\//i;function kt(e){const t=e.trim();if(!yt.test(t))return null;const s=new URL(t).searchParams.get("expires");return s?{fullUrl:t,expires:parseInt(s,10)}:{fullUrl:t,expires:bt({src:t,text:""}).expires}}function Et(e){const t=e?.responseParameters;return t&&"fullUrl"in t?t.fullUrl??null:null}function Tt(e){const t=e?.responseParameters,s=Et(e);if(!e||!t||!s)return null;const i=new URL(e.src),n=new URL(s);if(!n.pathname.endsWith(i.pathname))return null;const r=n.pathname.slice(0,n.pathname.length-i.pathname.length);return{fullUrl:s,originalBase:i.origin,rewrittenBase:n.origin+r,search:n.search,expires:t.expires}}function wt(e,t){if(!e.startsWith(`${t.rewrittenBase}/`))return null;const s=new URL(t.originalBase+e.slice(t.rewrittenBase.length));return s.searchParams.delete("hdnea"),s.searchParams.delete("hdntl"),s.toString()}function Lt(e,t){const s=new URL(wt(e,t)??e);if(s.origin!==t.originalBase)return null;s.searchParams.delete("hdnea"),s.searchParams.delete("hdntl");const i=s.search,n=i?`${i}&${t.search.slice(1)}`:t.search;return`${t.rewrittenBase}${s.pathname}${n}`}function Ct(e){return new Promise(t=>{setTimeout(t,e)})}class St{constructor({token:e,tokenType:t,srcInTokenRequest:s=!1,extraParamsCallback:i=null,onCDNTokenError:n,maxRetries:r=3,retryInterval:a=1e4,expirationMarginInSeconds:o=30}){const l=Object.values(pt);void 0!==t&&l.includes(t)?this.tokenType=t:this.tokenType=void 0,this.tokenGeneratorUrl=e,this.srcInTokenRequest=s,this.extraParamsCallback=i&&"function"==typeof i?i:null,this.callbackError=n&&"function"==typeof n?n:null,this.attempt=0,this.maxRetries=r,this.retryInterval=a,this.expirationMarginInSeconds=o,this.lastTokenResponse=null,this.sourceUrl=null,this.resetAttemptCounterTimeout=null,this.inFlightFetch=null}resetAttemptCounter(){this.resetAttemptCounterTimeout||(this.resetAttemptCounterTimeout=setTimeout(()=>{this.attempt=0},3e4))}async _fetchDefaultToken(e,t=null){const s=new URL(e);if(["verify","expires"].forEach(e=>s.searchParams.delete(e)),this.attempt>=this.maxRetries)return this.resetAttemptCounter(),vt.fromError({src:s.toString(),error:new ft({status:t?.status,errorCode:"Unauthorized",errorType:mt.MAX_RETRY})});try{let t;if(this.attempt+=1,t=!0===this.srcInTokenRequest?await fetch(`${this.tokenGeneratorUrl}?url=${encodeURIComponent(s.toString())}`):await fetch(this.tokenGeneratorUrl),403===t.status)return await Ct(this.retryInterval),this._fetchDefaultToken(e,t);if(t.status>=400)return vt.fromError({src:s.toString(),error:new ft({status:t.status})});this.attempt=0;const i=await t.text();return vt.fromDefault({src:s.toString(),text:i})}catch(e){return console.error("CDNToken: Error fetching default token ",e),vt.fromError({src:s.toString(),error:e})}}async _fetchEasyBToken(e,t=null){if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),vt.fromError({src:e,error:new ft({status:t?.error?.status,errorCode:t?.error?.errorCode??"Unauthorized",errorType:mt.MAX_RETRY})});try{this.attempt+=1;const s={};if(this.extraParamsCallback){const e=await this.extraParamsCallback(t?.error?.status);e?.accessToken&&(s.Authorization=`Bearer ${String(e.accessToken)}`)}else console.warn("CDNToken: no extraParamsCallback provided");let i;if(i=!0===this.srcInTokenRequest?await fetch(`${this.tokenGeneratorUrl}?url=${encodeURIComponent(e)}`,{method:"GET",headers:s}):await fetch(this.tokenGeneratorUrl,{method:"POST",headers:s,body:JSON.stringify({streamUrl:e})}),i.status>=400){const t=vt.fromError({src:e,error:new ft({status:i.status})});return 403===i.status?(await Ct(this.retryInterval),this._fetchEasyBToken(e,t)):t}this.attempt=0;const n=await i.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 ft({status:t?.status,errorCode:"Unauthorized",errorType:mt.MAX_RETRY})});try{this.attempt+=1;const t=await fetch(`${this.tokenGeneratorUrl}?url=${encodeURIComponent(e)}`);if(403===t.status)return await Ct(this.retryInterval),this._fetchAkamaiToken(e,t);if(t.status>=400)return vt.fromError({src:e,error:new ft({status:t.status})});this.attempt=0;const s=await t.text();return vt.fromAkamai({src:e,text:s})}catch(t){return console.error("CDNToken: Error fetching token ",t),vt.fromError({src:e,error:t})}}async _fetchBunnyToken(e,t=null){if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),vt.fromError({src:e,error:new ft({status:t?.error?.status,errorCode:t?.error?.errorCode??"Unauthorized",errorType:mt.MAX_RETRY})});try{this.attempt+=1;const s={"Content-Type":"application/json"};if(this.extraParamsCallback){const e=await this.extraParamsCallback(t?.error?.status);e?.accessToken&&(s.Authorization=`Bearer ${String(e.accessToken)}`)}else console.warn("CDNToken: no extraParamsCallback provided");const i=await fetch(this.tokenGeneratorUrl,{method:"POST",headers:s,body:JSON.stringify({streamUrl:e})});if(i.status>=400){const t=i.headers.get("content-type"),s=t?.includes("application/json")?await i.json():await i.text(),n="object"==typeof s&&null!==s?s.error?.errorCode??"Unauthorized":"Unauthorized",r="object"==typeof s&&null!==s?s.error?.__type??mt.UNKNOWN:mt.UNKNOWN,a=new ft({status:i.status,errorCode:n,errorType:r}),o=vt.fromError({src:e,error:a});return[403,401,498].includes(i.status)?(this.callbackError?this.callbackError({status:a.status,errorCode:a.errorCode,errorType:a.errorType}):console.warn(`CDNToken: Bunny token fetch attempt ${this.attempt} for ${e} failed with status ${i.status}, retrying in ${this.retryInterval/1e3}s`),await Ct(this.retryInterval),this._fetchBunnyToken(e,o)):(console.error(`CDNToken: error generating Bunny token on attempt ${this.attempt}`,JSON.stringify(o)),o)}const n=await i.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 pt.BUNNY:return this._fetchBunnyToken(e);case pt.AKAMAI:return this._fetchAkamaiToken(e);case pt.VENOM:case pt.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}){const t=new URL(e),s=t.searchParams.get("expires");switch(this.tokenType){case pt.AKAMAI:{const s=bt({src:e,text:""});if(!this.isTokenExpired(s.expires))return e;const i=Tt(this.lastTokenResponse),n=i&&!this.isTokenExpired(i.expires)?Lt(e,i):null;if(n)return n;const r=t.pathname.split("/");t.pathname=r.filter(e=>!e.startsWith("hdntl=")&&!e.startsWith("hdnea=")).join("/");break}case pt.EASY_B:case pt.VENOM:case pt.BUNNY:{if(!this.isTokenExpired(s))return e;["token","expires","token_path"].forEach(e=>t.searchParams.delete(e));const i=this.lastTokenResponse;if(i){const t=i.responseParameters;if(t&&!this.isTokenExpired(t.expires)){const s=Tt(i);if(s)return Lt(e,s)??e;const{token:n,expires:r,tokenPath:a}=t;return St.appendTokenParams(e,n,r,a)}}break}default:if(!this.isTokenExpired(s))return e}const i=this.tokenType===pt.EASY_B||this.tokenType===pt.VENOM||this.tokenType===pt.BUNNY,n=Tt(this.lastTokenResponse),r=(n&&wt(t.toString(),n))??t.toString(),a=i&&this.sourceUrl?this.sourceUrl:r;try{const t=await this.fetchToken({src:a});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 s=Et(t);if(s){if(t.src===r)return s;const e=Tt(t),i=e?Lt(r,e):null;if(i)return i}switch(this.tokenType){case pt.BUNNY:case pt.VENOM:case pt.EASY_B:{const s=t.responseParameters;return St.appendTokenParams(e,s.token,s.expires,s.tokenPath)}case pt.AKAMAI:{const s=t.responseParameters;return St.appendAkamaiTokenParams(e,s.hdntl??s.hdnea??"")}default:return St.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}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,s,i){const n=new URL(e);return t&&(n.searchParams.set("token",t),null!==s&&n.searchParams.set("expires",String(s)),i&&n.searchParams.set("token_path",i)),n.toString()}static appendAkamaiTokenParams(e,t){const s=new URL(e);return s.searchParams.delete("hdnea"),s.searchParams.delete("hdntl"),s.searchParams.set("hdnea",t),s.toString()}static appendDefaultTokenParams(e,t){const s=new URL(e),i=t.responseParameters;return i?.verify&&s.searchParams.set("verify",i.verify),null!=i?.expires&&s.searchParams.set("expires",String(i.expires)),s.toString()}}function xt(e){const t={};for(const s of Object.keys(e)){const i={...e[s]};!i.serverURL&&i.licenseUrl&&(i.serverURL=i.licenseUrl),t[s]=i}return t}class At{constructor(e){this.tokenManager=e}buildHlsConfig(e){if(!e.emeEnabled)return{};const t=this.tokenManager;return{emeEnabled:e.emeEnabled,...void 0!==e.drmSystems&&{drmSystems:xt(e.drmSystems)},licenseXhrSetup:async(e,s)=>{if(t?.extraParamsCallback){const s=await t.extraParamsCallback().catch(e=>(console.error("DrmConfigurator: extraParamsCallback error:",e),null));s?.accessToken&&e.setRequestHeader("Authorization",`Bearer ${s.accessToken}`)}const i=t?.lastTokenResponse?.extras?.drm_custom_data;if(i){const t=new URL(s);t.searchParams.delete("customdata"),t.searchParams.append("customdata",i),e.open("POST",t.toString(),!0)}else e.open("POST",s,!0)}}}}const $t=new Set(["keySystemError"]);function Mt(e,t){const s=new Map,i=new Set,n=new Set;let r,a=!1;e.on("hlsError",(o,l)=>{const c=l.details??l.type,h=e.media?.currentTime;if(void 0!==h&&void 0!==r&&h>r+1&&(s.clear(),i.clear()),r=h,l.fatal){if($t.has(l.type)){if(n.has(c))return;return n.add(c),console.error(`HLS Retry: Unrecoverable error "${c}" — cannot fix by retrying.`,o,l),void t?.onUnrecoverableError?.(`DRM error: ${c}`)}if(void 0!==t?.onFatalNetworkError){if(a)return;return a=!0,console.warn(`HLS Retry: Fatal error on intro pass — signalling fall-through (${c}).`,o,l),void t.onFatalNetworkError(c)}return console.warn("HLS Retry: Fatal error, trying to fix now.",o,l),void setTimeout(()=>{"mediaError"===l.type?e.recoverMediaError():e.startLoad(e.media?.currentTime??-1)},1e3)}if(i.has(c))return;const d=(s.get(c)??0)+1;if(s.set(c,d),d>3)return console.warn(`HLS Retry: Non-fatal "${c}" exceeded 3 retries, giving up.`,o,l),void i.add(c);console.warn(`HLS Retry: Non-fatal error (${d}/3), monitoring.`,o,l);const u=e.media?.currentTime;setTimeout(()=>{if(u!==e.media?.currentTime||t?.chromecast_casting)console.info("HLS Retry: Stream is playing, no action needed",o,l),s.delete(c),i.delete(c);else{if(function(e,t){if(null===e||!0===t?.isLive)return!1;const{duration:s,buffered:i,currentTime:n}=e;return!(!Number.isFinite(s)||s<=0)&&!(s-n>1)&&0!==i.length&&i.end(i.length-1)>=s-1}(e.media,t))return void console.info("HLS Retry: near VOD end, letting hls.js finish naturally",o,l);console.warn("HLS Retry: Stream is stuck, trying to fix",o,l),"mediaError"===l.type?e.recoverMediaError():e.startLoad(e.media?.currentTime??-1)}},3e3)})}function Pt(e,t){const s=e.trigger;e.trigger=function(e,i){if(e===t.AUDIO_TRACK_LOADED){const e=i;if(e?.details){const t=this.currentLevel>=0?this.currentLevel:0,s=this.levels?.[t]?.details;if(s&&e.details.endCC>s.endCC){const t=s.endCC,i=e.details.fragments;if(i)for(let e=0;e<i.length;e++)i[e].cc>t&&(i[e].cc=t);void 0!==e.details.fragmentHint?.cc&&e.details.fragmentHint.cc>t&&(e.details.fragmentHint.cc=t),e.details.endCC=t}}}return s.call(this,e,i)}}const _t=Object.freeze([pt.EASY_B,pt.VENOM,pt.BUNNY]);function Rt(e,t){try{const s=new URL(t),i=s.searchParams.get("token");if(!i)return e;const n=s.searchParams.get("expires"),r=s.searchParams.get("token_path");return St.appendTokenParams(e,i,n,r)}catch{return e}}function Bt(e,t){let s=!1;function i(e){const i=e.load.bind(e);e.load=function(e,n,r){const a=t.tokenType;if(!a||!_t.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: ${_t.join(", ")}.`}(a);return s||(s=!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 o=e.frag?.baseurl;if(!o||!e.url)return void i(e,n,r);const{hasToken:l,expires:c}=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{return{hasToken:!1,expires:null}}}(o);if(l)return t.isTokenExpired(c)?void t.updateUrlWithTokenParams({url:e.url}).then(t=>{e.url=t,i(e,n,r)}).catch(()=>{e.url=Rt(e.url,o),i(e,n,r)}):(e.url=Rt(e.url,o),void i(e,n,r));i(e,n,r)}}function n(t){if(new.target){const s=Reflect.construct(e,[t],new.target);return i(s),s}e.call(this,t),i(this)}return n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n}class Dt extends gt{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&&(this.state.error=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){this.driver&&(1===e?(console.warn("HlsEngine stall recovery: recoverMediaError"),this.driver.recoverMediaError()):(console.warn("HlsEngine stall recovery: startLoad"),this.driver.startLoad(this.video?.currentTime??-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){if(null===this.video)return;if(!this.liveSyncDisabled&&null!==this.driver&&this.state?.isLive){const e=this.driver.config;e.liveSyncDurationCount=0,e.liveMaxLatencyDurationCount=1/0,this.liveSyncDisabled=!0}const t=this.video.ended;if(this.video.currentTime=e,t&&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(){const{config:e,video:t,state:s,signal:i}=this;if(!(e&&t&&s&&i))return;const n=e.hlsjs;if(!n)throw new Error("HlsEngine: config.hlsjs URL is required");e.token&&(this.tokenManager=new St({token:e.token,tokenType:e.tokenType,srcInTokenRequest:e.srcInTokenRequest,extraParamsCallback:e.engineSettings.extraParamsCallback??e.extraParamsCallback,onCDNTokenError:e.engineSettings.onCDNTokenError}));const r=await Ze(n,"Hls");if(this.detached)return;const a=new At(this.tokenManager).buildHlsConfig(e.engineSettings),o=this.tokenManager,{emeEnabled:l,drmSystems:c,...h}=e.engineSettings,d={...h};delete d.extraParamsCallback,delete d.onCDNTokenError,delete d.signSegmentsWithCdnToken;const u={enableWorker:!0,backBufferLength:30,...d,...a,startPosition:e.startAt};if(o){const t=o;class s extends r.DefaultConfig.loader{constructor(e){super(e);const s=this.load.bind(this);this.load=function(e,i,n){if(!e.url)return void s(e,i,n);new URL(e.url).pathname.split("/").pop().endsWith(".m3u8")?t.updateUrlWithTokenParams({url:e.url}).then(t=>{e.url=t,s(e,i,n)}).catch(()=>{s(e,i,n)}):s(e,i,n)}}}if(u.pLoader=s,!0===e.engineSettings.signSegmentsWithCdnToken){const e=Bt(r.DefaultConfig.loader,t);u.fLoader=e,u.loader=e}}if(!e.disableCustomAbr)try{const{createHlsAbrController:e}=await Promise.resolve().then(function(){return Jt});if(this.detached)return;u.abrController=e(r)}catch(e){console.warn("HlsEngine: failed to load custom ABR controller, using default",e)}if(this.detached)return;const g=new r(u);this.driver=g,Pt(g,r.Events);const p=Boolean(e.preroll)&&this.loadSourceUrl===e.preroll;if(e.retry&&Mt(g,{get chromecast_casting(){return s.isCasting},get isLive(){return s.isLive},onUnrecoverableError:e=>{this.stopWatchdog(),this.state&&(this.state.error=e),this.bus?.emit("error-fatal",{code:"DRM",message:e})},...p?{onFatalNetworkError:e=>{this.stopWatchdog(),this.bus?.emit("error-fatal",{code:"NETWORK",message:`Intro stream error: ${e}`})}}:{}}),e.useGeoblockingErrorHandle){const e=this.bus;g.on(r.Events.ERROR,(t,s)=>{const i=s;i?.type!==r.ErrorTypes.NETWORK_ERROR||"manifestLoadError"!==i?.details&&"levelLoadError"!==i?.details||403!==i?.response?.code||(e?.emit("geoblock-detected"),window.dispatchEvent(new CustomEvent("geoblock",{detail:{title:"Geoblock",message:"Geoblock detected"}})),this.stopWatchdog())})}this.bindVideoEvents(t,s,i),g.attachMedia(t);let m=this.loadSourceUrl||e.src||"";if(this.tokenManager&&m&&(this.tokenManager.sourceUrl=m,m=await this.tokenManager.updateUrlWithTokenParams({url:m}),this.detached))return g.destroy(),void(this.driver=null);g.loadSource(m),this.resolveDriverReady(),this.registerDriverEvents(r,s),this.armLoadNeverStartedWatchdog(g,r,m,p);const f=g;t.addEventListener("pause",()=>{this.state?.isLive&&f.stopLoad()},{signal:i}),t.addEventListener("play",()=>{if(this.state?.isLive)setTimeout(()=>f.startLoad(-1),0);else if("ended"===this.state?.playbackState){this.state.playbackState="loading";const e=this.video?.currentTime??0;setTimeout(()=>f.startLoad(e),0)}},{signal:i}),this.startWatchdog();const v=t,b=s;let y=0;const k=setInterval(()=>{if(y++,y>=10)return void clearInterval(k);const e=b.playbackState;if("playing"!==e&&!v.paused&&v.currentTime>0)return b.playbackState="playing",void clearInterval(k);"buffering"!==e&&"loading"!==e||!v.paused||(b.playbackState="paused",clearInterval(k))},200);i.addEventListener("abort",()=>clearInterval(k),{once:!0})}registerDriverEvents(e,t){const s=this.driver;if(!s)return;this.eventState=t;const{Events:i}=e;s.on(i.MANIFEST_PARSED,this._onManifestParsed.bind(this)),s.on(i.LEVEL_LOADED,this._onLevelLoaded.bind(this)),s.on(i.LEVEL_SWITCHED,this._onLevelSwitched.bind(this)),s.on(i.AUDIO_TRACKS_UPDATED,this._onAudioTracksUpdated.bind(this)),s.on(i.AUDIO_TRACK_SWITCHED,this._onAudioTrackSwitched.bind(this)),s.on(i.SUBTITLE_TRACKS_UPDATED,this._onSubtitleTracksUpdated.bind(this)),s.on(i.SUBTITLE_TRACK_SWITCH,this._onSubtitleTrackSwitch.bind(this))}armLoadNeverStartedWatchdog(e,t,s,i){i||(e.on(t.Events.FRAG_LOADING,this._onFragLoading.bind(this)),this.loadNeverStartedTimer=setTimeout(this._onLoadNeverStartedTimeout.bind(this,s),3e4))}clearLoadNeverStartedWatchdog(){clearTimeout(this.loadNeverStartedTimer),this.loadNeverStartedTimer=0}_onFragLoading(){this.clearLoadNeverStartedWatchdog()}_onLoadNeverStartedTimeout(e){this.detached||!0!==this.state?.isLive&&!0!==this.config?.isLive&&(this.state&&(this.state.error="HlsEngine: load never started — no fragment request was issued within the bound"),this.bus?.emit("load-never-started",{src:e}))}_onManifestParsed(e,t){const s=this.eventState,i=this.driver;if(!s)return;const n=t.levels??i?.levels??[];s.qualityLevels=n.map((e,t)=>({name:e.name??`${e.height}p`,id:t,bitrate:e.bitrate,height:e.height,width:e.width}))}_onLevelLoaded(e,t){const s=this.eventState;if(!s)return;const i=t;void 0!==i?.details?.live?s.isLive=i.details.live:!0===this.config?.isLive&&(s.isLive=!0)}_onLevelSwitched(e,t){const s=this.eventState;if(s&&!this.autoQuality){const e=t;s.currentQuality=e.level}}_onAudioTracksUpdated(e,t){const s=this.eventState,i=this.driver;if(!s)return;const n=t.audioTracks??i?.audioTracks??[];s.audioTracks=n.map(e=>({id:e.id,name:e.name,lang:e.lang}))}_onAudioTrackSwitched(e,t){const s=this.eventState;if(!s)return;const i=t;s.currentAudioTrack=i.id}_onSubtitleTracksUpdated(e,t){const s=this.eventState,i=this.driver;if(!s)return;const n=t.subtitleTracks??i?.subtitleTracks??[];s.subtitleTracks=n.map(e=>({id:e.id,name:e.name,lang:e.lang}))}_onSubtitleTrackSwitch(e,t){const s=this.eventState;if(!s)return;const i=t;s.currentSubtitleTrack=i.id}}const Ft=(e,t,s,i,n,r)=>{if(r<=0)return;const[{bandwidth:a},{bandwidth:o}]=t.getMediaInfo().bitrateList;return r>2&&.8*s>=a&&s<=o?e<8?r:r-1:1===r?i.getCurrentBufferLevel("video",!0)>1.5*n&&e<8?r:r-1:void 0};function Vt(e){const t=e.FactoryMaker.getClassFactoryByName("SwitchRequest"),s=e.FactoryMaker.getSingletonFactoryByName("StreamController"),i=e.FactoryMaker.getSingletonFactoryByName("DashMetrics"),n=new Set;let r=0,a=15,o=15;const l=function(){return{getMaxIndex:e=>{const l=t(this.context).create();l.priority=t.PRIORITY.STRONG;const c=e.getMediaInfo().type,h=i(this.context).getInstance(),d=s(this.context).getInstance(),u=e.getAbrController();if(setInterval(()=>{var e;void 0!==(e=h.getCurrentBufferLevel("video",!0))&&(a<e&&(n.add(o),a=e,o=e),e<o&&(o=e,a=o))},1e3),"video"===c){let s,i;try{const[t,a]=(({requests:e,count:t,rulesContext:s,currentValue:i,dashMetrics:a})=>{if(!e)return[""];let o=null;for(let t=e.length-1;t>=0&&null===o;t--){const[{_tfinish:s,trequest:i,tresponse:n,trace:r}]=e[t];s&&i&&n&&r&&r.length&&(o=e[t])}if(null===o)return["No valid request made for this stream yet, bailing"];const l=(o[0]._tfinish.getTime()-o[0].trequest.getTime())/1e3,c=(o[0]._tfinish.getTime()-o[0].tresponse.getTime())/1e3;if("InitializationSegment"===o[0].type||"MediaSegment"===o[0].type){if(l<=0)return["Last segment not downloaded, probable network problem: Switching to lowest quality",0];if(n.size>=3){const o=Array.from(n),h=o.reduce((e,t)=>e+t,0)/n.size,d=((e,t)=>{const[{type:s,_tfinish:i,trequest:n,tresponse:r,trace:a}]=e[0];return"MediaSegment"!==s&&i&&n&&r&&a&&a.length?8*a.reduce((e,t)=>e+t.b[0],0)/t:0})(e,l),u=Math.sqrt(o.map(e=>(e-h)**2).reduce((e,t)=>e+t,0)/n.size);return n.clear(),h<=1.5?["Avg. Buffer < 10% of max buffer, switching to lowest quality",0]:h<=4.5?["Maintaining the current Bitrate",i]:h<=10.5&&s.getMediaInfo().bitrateList[i].bandwidth<d&&(r<t-1||u<=8)?["Switching to optimised quality level",r?Ft(u,s,d,a,c,t):r+1]:["Switching to optimised quality level",Ft(u,s,d,a,c,t)]}return["Maintaining the last loaded level"]}return["Last Loaded segment was not a media segment of initialization segment"]})({requests:h.getHttpRequests(c),count:e.getMediaInfo().representationCount,currentValue:u.getQualityFor(c,d.getActiveStreamInfo()),rulesContext:e,dashMetrics:h});i=t,s=a??r,r=s}catch{return n.clear(),{quality:0,reason:"Error in ABR rule",priority:t.PRIORITY.STRONG}}return l.quality=s,l.reason=i,l}return l.quality=0,l.reason="Audio Request",l}}};return l.__dashjs_factory_name="CustomAbrRule",e.FactoryMaker.getClassFactory(l)}class Nt extends gt{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&&(this.state.error=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){null!==this.video&&(1===e?(console.warn("DashEngine stall recovery: seek nudge"),this.video.currentTime+=.1):(console.warn("DashEngine stall recovery: refreshManifest"),this.driver?.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(){const{config:e,video:t,state:s,signal:i}=this;if(!(e&&t&&s&&i))return;this.isIntroPass=Boolean(e.preroll)&&this.loadSourceUrl===e.preroll;const n=e.dashjs;if(!n)throw new Error("DashEngine: config.dashjs URL is required");this.dvrErrorHandler=e=>{const t=e.reason;(t?.message?.includes("getCurrentDVRInfo")||String(e.reason).includes("getCurrentDVRInfo"))&&(e.preventDefault(),console.warn("DashEngine: suppressed DVR unhandledrejection"))},window.addEventListener("unhandledrejection",this.dvrErrorHandler,{signal:i});const r=await Ze(n,"dashjs"),a=r.MediaPlayer().create();if(!a)throw new Error("DashEngine: dash.js MediaPlayer could not be created");if(this.driver=a,this.resolveDriverReady(),a.initialize(t,this.loadSourceUrl||e.src||"",e.autoplay??!1),e.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 s=!0===t.introPass?2:1/0;e.updateSettings({streaming:{retryAttempts:{MPD:s,XLinkExpansion:s,InitializationSegment:s,IndexSegment:s,MediaSegment:s,BitstreamSwitchingSegment:s,other:s,lowLatencyMultiplyFactor:1}}})}(a,{introPass:this.isIntroPass}),!e.disableCustomAbr){const e=Vt(r);a.addABRCustomRule("qualitySwitchRules","CustomAbrRule",e)}e.lowLatency&&a.updateSettings({streaming:{lowLatencyEnabled:!0,liveDelay:30,liveCatchUpPlaybackRate:.01}}),this.registerDriverEvents(r,s,a),this.bindVideoEvents(t,s,i),this.startWatchdog(),await new Promise(e=>{const t=()=>{a.off(r.MediaPlayer.events.STREAM_INITIALIZED,t),e()};a.on(r.MediaPlayer.events.STREAM_INITIALIZED,t)});const o=t,l=s;let c=0;const h=setInterval(()=>{if(c++,c>=10)return void clearInterval(h);const e=l.playbackState;if("playing"!==e&&!o.paused&&o.currentTime>0)return l.playbackState="playing",void clearInterval(h);"buffering"!==e&&"loading"!==e||!o.paused||(l.playbackState="paused",clearInterval(h))},200);i.addEventListener("abort",()=>clearInterval(h),{once:!0})}registerDriverEvents(e,t,s){const i=e.MediaPlayer.events;s.on(i.STREAM_INITIALIZED,()=>{const e=s.getBitrateInfoListFor("video");t.qualityLevels=e.map((e,t)=>({name:`${e.height}p`,id:t,bitrate:e.bitrate}));const i=s.getTracksFor("audio");t.audioTracks=i.map(e=>({name:e.lang??"",id:e.id??e.index??0}));const n=s.getTracksFor("fragmentedText");t.subtitleTracks=n.map(e=>({name:e.lang??"",id:e.id??e.index??0}));const r=s.duration();t.duration=Number.isFinite(r)?Math.ceil(r):0;const a=s.getCurrentLiveLatency();"boolean"==typeof this.config?.isLive?t.isLive=this.config.isLive:t.isLive=!Number.isNaN(a),t.playbackState="playing"}),s.on(i.PLAYBACK_TIME_UPDATED,()=>{t.currentTime=Math.round(s.time())}),s.on(i.QUALITY_CHANGE_REQUESTED,()=>{t.currentQuality=s.getQualityFor("video")}),s.on(i.TRACK_CHANGE_RENDERED,()=>{t.currentAudioTrack=s.getQualityFor("audio")}),s.on(i.ERROR,e=>{this.handleDriverError(e)})}handleDriverError(e){const t=e;if(console.warn("DashEngine error:",t?.error?.message??t?.error??t),!this.isIntroPass||this.introFallThroughReported)return;this.introFallThroughReported=!0,this.stopWatchdog();const s=t?.error?.code??t?.error?.message??"unknown";this.bus?.emit("error-fatal",{code:"NETWORK",message:`Intro stream error: ${s}`})}}function It(e){return e.split("?")[0].replace(/(\/hdn.*\/)/g,"/")}class Ht{constructor(){this.lib=null}async integrate(e){const{video:t,driver:s,type:i,config:n,signal:r}=e;if(!n.lib||!n.manager)return;const a=await Ze(n.lib,"Easybroadcast");if(r.aborted)return;this.lib=new a.eblib.EBLibrary(n.manager);const o=It(n.src??""),l={resourceManager:{tokenRemover:It,...(n.libSettings??{}).resourceManager??{}},swarmManager:{url:o},statsOutput:{enable:!!n.stats,url:n.stats,intervalMs:3e4},playerInput:{content:String(n.content??o),contentUrl:o,proto:i,origin:n.origin}};if("dash"===i){const e=l.resourceManager;e.randomWaitForPeers=[150,400],e.timeoutV2V=500,e.storageSize=20}this.lib.integrate([s,t],i,l),this.lib.start(),r.addEventListener("abort",()=>{this.stop()},{once:!0})}stop(){null!==this.lib&&"function"==typeof this.lib.stop&&this.lib.stop(),this.lib=null}}class Ot{constructor(e,t){this.driver=null,this.offscreenVideo=null,this.throttleTimeout=null,this.pendingSeekTime=0,this.config=e,this.tokenManager=t}init(e){const t=document.createElement("video");t.preload="metadata",this.offscreenVideo=t;const s=this.tokenManager;let i,n;if(s){class t extends e.DefaultConfig.loader{constructor(e){super(e);const t=this.load.bind(this);this.load=async function(e,i,n){if(!e.url)return void t(e,i,n);new URL(e.url).pathname.split("/").pop().endsWith(".m3u8")?(e.url=await s.updateUrlWithTokenParams({url:e.url}),t(e,i,n)):t(e,i,n)}}}i=t}s&&!0===this.config.engineSettings?.signSegmentsWithCdnToken&&(n=Bt(e.DefaultConfig.loader,s));const r={...this.config.engineSettings??{}};delete r.extraParamsCallback,delete r.onCDNTokenError,delete r.signSegmentsWithCdnToken;const a={startLevel:0,enableWebVTT:!1,enableWorker:!1,maxBufferLength:1,...r,...i?{pLoader:i}:{},...n?{fLoader:n}:{}},o=new e(a);return this.driver=o,Pt(o,e.Events),o.attachMedia(t),this.config.src&&o.loadSource(this.config.src),new Promise(t=>{o.once(e.Events.MANIFEST_LOADED,()=>{o.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 Ut{constructor(e){this.player=null,this.offscreenVideo=null,this.ready=!1,this.src=e}init(e){return new Promise(t=>{const s=document.createElement("video");s.style.display="none",document.body.appendChild(s),this.offscreenVideo=s;const i={take:()=>{},destroy:()=>{},video:s};let n;try{n=e.MediaPlayer().create(),this.player=n,n.initialize(s,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 s=e instanceof Error?e.message:String(e);return console.warn("Snapshot handler initialization failed:",s),this.cleanup(),void t(i)}n.on(e.MediaPlayer.events.ERROR,e=>{const t=e;console.warn("Snapshot dash.js error:",t?.error?.message??t?.error??t)});const r=()=>{n.setMute(!0),n.off(e.MediaPlayer.events.STREAM_INITIALIZED,r),this.ready=!0;let i=null;t({take:e=>{if(this.ready&&null===i){i=setTimeout(()=>{i=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:s})};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{}this.player=null}this.cleanup()}cleanup(){null!==this.offscreenVideo&&(this.offscreenVideo.remove(),this.offscreenVideo=null)}}const zt=new Map;function qt(e){null!==e.snapshotDestroy&&(e.snapshotDestroy(),e.snapshotDestroy=null),null!==e.engine&&(e.engine.detach(),e.engine=null),e.p2p?.stop(),e.p2p=null,e.controller.dispose()}function jt(){return new Promise(e=>setTimeout(e,500))}function Wt(e){const t=function(e){if(null!=e&&"object"==typeof e&&"nodeType"in e)return e;const t="string"==typeof e?e:"#eb_player",s=document.querySelector(t);if(null===s)throw new Error(`EBPlayer: container element not found for selector "${t}". Ensure the element exists in the DOM before calling start().`);return s}(e.el),s=zt.get(t);void 0!==s&&(qt(s),zt.delete(t));const i=m(u,e),n=i.muted,r=i.manager,a=i.startAt,o=new ht(e);o.mount(t);const l=t.querySelector("video"),c={controller:o,engine:null,snapshotDestroy:null,p2p:null,container:t};zt.set(t,c);let h="";const d={open(e){h=e,null!==c.engine&&(c.engine.detach(),c.engine=null);const t=function(e,t){return e.includes(".mpd")&&!1!==t.dashjs?new Nt:new Dt}(e,i);if(null!==l&&t.setVideo(l),t.setBus(o.bus),t.setConfig(i),t.setLoadSource(e),o.setEngineSync(t),c.engine=t,i.lib&&i.manager&&null!==l){const s=e.includes(".mpd")&&!1!==i.dashjs;c.p2p?.stop();const n=new Ht;c.p2p=n,t.driverReady.then(()=>n.integrate({video:l,driver:t.getDriver(),type:s?"dash":"hls",config:i,signal:o.signal})).catch(e=>{console.error("EBPlayer: P2PManager integrate failed:",e)})}if(i.showProgressThumb&&e!==i.preroll){null!==c.snapshotDestroy&&(c.snapshotDestroy(),c.snapshotDestroy=null);const s=e.includes(".mpd")&&!1!==i.dashjs;t.driverReady.then(()=>{if(s){const t=window;if(t.dashjs){new Ut(e).init(t.dashjs).then(e=>{c.snapshotDestroy=()=>e.destroy(),o.bus.emit("snapshot-handler-ready",{take:e.take,video:e.video})}).catch(e=>{console.warn("EBPlayer: DashSnapshotHandler init failed:",e)})}}else{const s=window;if(s.Hls){const n=t.getTokenManager(),r=new At(n).buildHlsConfig(i.engineSettings),a=new Ot({src:e,engineSettings:{...i.engineSettings,...r}},n);a.init(s.Hls).then(()=>{c.snapshotDestroy=()=>a.destroy();const e=a.getVideo();null!==e&&o.bus.emit("snapshot-handler-ready",{take:e=>a.take(e),video:e}),l&&(l.addEventListener("pause",()=>{o.state?.isLive&&a.stopLoad()},{signal:o.signal}),l.addEventListener("play",()=>{o.state?.isLive&&setTimeout(()=>a.startLoad(),0)},{signal:o.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!==c.snapshotDestroy&&(c.snapshotDestroy(),c.snapshotDestroy=null),null!==c.engine&&(c.engine.detach(),c.engine=null)},destroy(){qt(c),zt.delete(t)},get state(){return o.state}};if(o.setReloadCallback(()=>{if(!h)return;const e=h,t=o.getSavedSelections();d.close(),jt().then(()=>{d.open(e),setTimeout(()=>{null!==c.engine&&(c.engine.setQuality(t.quality),c.engine.setAudioTrack(t.audioTrack),c.engine.setSubtitle(t.subtitleTrack))},2e3)})}),o.bus.on("error-fatal",()=>{c.p2p?.stop()},{signal:o.signal}),null===l){const e="EBPlayer: no <video> element found in the container after mount() — playback cannot start.";return console.error(e),o.state.error=e,d}let g=!1;const p=()=>{g||(g=!0,o.bus.emit("force-intro-complete"),l.muted=n,o.state.muted=n,i.manager=r,o.config.manager=r,i.startAt=a,o.config.startAt=a,o.state.error=null,i.src&&d.open(i.src))},f=Boolean(i.preroll),v=Boolean(i.ad);let b=null;const y=()=>{null!==b&&(clearTimeout(b),b=null)},k=e=>{b=setTimeout(()=>{o.signal.aborted||(o.state.adPlaying?k(e):(console.warn("eb-player: ad leg produced no ad-complete within the bound — falling through to main (G-07-11)"),e()))},3e4)};o.signal.addEventListener("abort",()=>{y()},{once:!0});let E=!v,T=Boolean(i.autoplay),w=!1;const L=()=>{if(w)return;w=!0;const e=c.engine;null!==e&&e.driverReady.then(()=>{const e=l.play();e&&"function"==typeof e.catch&&e.catch(e=>{console.warn("EBPlayer: deferred play() rejected",e)})})},C=()=>{E&&T&&(p(),i.autoplay||L())};if(v&&o.bus.on("ad-complete",()=>{y(),E=!0,f?p():C()},{signal:o.signal}),f)o.bus.on("intro-stream-complete",()=>{d.close(),o.state.muted=n,jt().then(()=>{g||(v?k(p):p())})},{signal:o.signal}),l.muted=!1,o.state.muted=!1,i.manager=!1,o.config.manager=!1,i.startAt=void 0,o.config.startAt=void 0,d.open(i.preroll);else if(v)i.autoplay?k(()=>{E=!0,C()}):o.bus.on("play",()=>{T||(T=!0,E?(C(),L()):k(()=>{E=!0,C()}))},{signal:o.signal});else if(i.src)if(i.autoplay)d.open(i.src);else{let e=!0;o.bus.on("play",()=>{e&&(e=!1,d.open(i.src),L())},{signal:o.signal})}return d}function Gt(){for(const e of zt.values())null!==e.engine&&(e.engine.detach(),e.engine=null)}function Qt(){for(const e of zt.values())qt(e);zt.clear()}const Yt=t;if("undefined"!=typeof window){console.info(`%cEBPlayer v${Yt}`,"color: #1FA9DD; font-weight: bold");const e=window,t=e.EBPlayer??{};Object.assign(t,{start:Wt,stop:Gt,destroy:Qt,AVAILABLE_THEMES:l,THEME_LAYOUTS:h,version:Yt}),e.EBPlayer=t}const Kt="main",Xt={bufferInfo(e,t,s){if(!e.buffered||0===e.buffered.length)return{end:0,start:0,len:0,nextStart:0};for(let i=0;i<e.buffered.length;i++){const n=e.buffered.start(i),r=e.buffered.end(i);if(t>=n-s&&t<=r+s)return{end:r,start:n,len:r-t,nextStart:0}}return{end:0,start:0,len:0,nextStart:0}}};var Jt=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:s}=e;return class extends t{constructor(e){super(e,s.FRAG_LOADING,s.FRAG_LOADED,s.FRAG_BUFFERED,s.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(s.FRAG_LOADING,this.onFragLoading,this),this.hls.on(s.FRAG_LOADED,this.onFragLoaded,this),this.hls.on(s.FRAG_BUFFERED,this.onFragBuffered,this),this.hls.on(s.LEVEL_LOADED,this.onLevelLoaded,this),this.hls.on(s.ERROR,this.onError,this)}unregisterCustomListeners(){this.hls.off(s.FRAG_LOADING,this.onFragLoading,this),this.hls.off(s.FRAG_LOADED,this.onFragLoaded,this),this.hls.off(s.FRAG_BUFFERED,this.onFragBuffered,this),this.hls.off(s.LEVEL_LOADED,this.onLevelLoaded,this),this.hls.off(s.ERROR,this.onError,this)}clearCustomTimer(){void 0!==this.timer&&(clearInterval(this.timer),this.timer=void 0)}onFragLoading(e,t){const s=t,{frag:i}=s;this.loading=!0,i.type===Kt&&(this.timer||(this.fragCurrent=i,this.partCurrent=s.part??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(Xt.bufferInfo(this.hls.media,t,this.maxBufferLength).end-t)/e}_abandonRulesCheck(){const{hls:e}=this,t=e.media,s=this.fragCurrent,i=this.partCurrent;if(!s||!t)return;if((i?i.stats:s.stats).aborted)return this.clearCustomTimer(),void(this._nextAutoLevel=-1);e.autoLevelEnabled&&!t.paused&&t.playbackRate&&t.readyState&&s.type===Kt&&"initSegment"!==s.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 i=t,{frag:n,part:r}=i,a=r?r.stats:n.stats,o=r?r.duration:n.duration;if(this.loading=!1,n.type===Kt&&"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)+a.loaded,s=(e.loaded?e.loaded.duration:0)+o;e.loaded={bytes:t,duration:s},e.realBitrate=Math.round(8*t/s),this.setBitrate.add(e.realBitrate),this.lastDuration=o,this.maxBufferLength=10*this.lastDuration}this.onFragBuffered(s.FRAG_BUFFERED,{stats:a,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){const s=t,{frag:i,part:n}=s,r=n?n.stats:s.stats??i.stats;if(r.aborted)return;if(i.type!==Kt||"initSegment"===i.sn)return;const a=r.loading?.start??0,o=(r.parsing?.end??0)-a;this.bitrateTestDelay=o/1e3,this.fraglastBuffered=Date.now()}findNextBestLevel(e){const t=this.hls.levels;for(let s=0;s<t.length;s++){if(s<t.length-2&&.8*this.avgBitrate>=t[s].bitrate&&this.avgBitrate<=t[s+1].bitrate)return this.reset(),this.lastLoadedFragLevel=e<3?s:s-1,this.lastLoadedFragLevel;if(s===t.length-1){return this.getBuffer()>this.lastDuration+this.lastDuration/2&&e<3?this.lastLoadedFragLevel=s:this.lastLoadedFragLevel=s-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(){if(!this.hls)return 0;const e=this.hls.levels.length-1,t=this.getBuffer();if(t<.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),e),this.lastLoadedFragLevel;if(!0===this.init)return this.init=!1,this.lastLoadedFragLevel=e,this.lastLoadedFragLevel;if(t>.3*this.hls.config.maxBufferLength)return this.lastLoadedFragLevel=this.findNextBestLevel(5),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),e),this.lastLoadedFragLevel;if(this.setBufferValues.size>=this.pastBufferFactor)try{const t=Array.from(this.setBufferValues).reduce((e,t)=>e+t,0)/this.setBufferValues.size,s=function(e){const t=e.reduce((e,t)=>e+t,0)/e.length,s=e.map(e=>(e-t)**2);return Math.sqrt(s.reduce((e,t)=>e+t,0)/(e.length-1))}(Array.from(this.setBufferValues));this.setBufferValues.clear();const i=this.hls.levels[this.hls.currentLevel]?.bitrate??0;return t<=.1*this.hls.config.maxBufferLength&&i>=this.hls.levels[0].bitrate?(this.reset(),this.lastLoadedFragLevel=Math.max(this.lastLoadedFragLevel-1,0),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),e),this.lastLoadedFragLevel):t<=.3*this.hls.config.maxBufferLength?(this.reset(),this.lastLoadedFragLevel):t<=.7*this.hls.config.maxBufferLength&&i<this.avgBitrate?(this.reset(),this.lastLoadedFragLevel=this.findNextBestLevel(s),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),e),this.lastLoadedFragLevel):t>.7*this.hls.config.maxBufferLength&&i<.8*this.avgBitrate?(this.lastLoadedFragLevel=this.findNextBestLevel(s),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),e),this.lastLoadedFragLevel):(this.reset(),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),e),this.lastLoadedFragLevel)}catch(t){return console.warn("HLS ABR: findBestLevel error",t),this.lastLoadedFragLevel=this.findNextBestLevel(3),this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),e),this.lastLoadedFragLevel}return this.lastLoadedFragLevel=Math.min(Math.max(this.lastLoadedFragLevel,0),e),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=h,e.destroy=Qt,e.start=Wt,e.stop=Gt,e.version=Yt});
|
|
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 Je{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 Ze{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 et(e){const t=window;if(void 0!==t[e])return t[e];try{return(0,eval)(e)}catch(e){return}}function tt(e,t,i={}){var s;const n=et(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=et(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 it=null;class st{constructor(e){this.localDriver=null,this.signal=e.signal}async init(e,t,i){var s;if(!e.chromecast)return;const n=await tt(e.chromecast,"Castjs");null===it&&(it=new n({receiver:null!==(s=e.chromecastApp)&&void 0!==s?s:"00197684"})),this.localDriver=it,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 nt{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 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 rt{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 ot{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)},h=()=>{null!==a&&(clearTimeout(a),a=null)},u=()=>{l||(l=!0,d(),h(),null===this.imaAdsManager&&this.releaseImaResources(),t.adPlaying=!1,i.emit("ad-complete"),c.abort())};r.addEventListener("abort",()=>{d(),h(),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)"),u()},2e4),null!==v&&await v,r.aborted||l)))try{const i=await tt("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),u()}),a.addEventListener(r.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>{if(l)return;const i=e.getAdsManager(s);this.imaAdsManager=i,h();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,k(s),u()}),i.addEventListener(r.AdEvent.Type.ALL_ADS_COMPLETED,()=>{console.log("AdsManager: ALL_ADS_COMPLETED — ad leg complete (D-08-08)"),u()}),i.addEventListener(r.AdErrorEvent.Type.AD_ERROR,e=>{console.warn("AdsManager: AD_ERROR (manager) — falling through to main",e),u()}),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),u()}}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 at{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 lt,ct={exports:{}};var dt=(lt||(lt=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}(ct)),ct.exports);function ht(e){if(!e||!e.trim())return[];return dt.fromVtt(e,"s").map(e=>({title:e.text,startTime:e.startTime,endTime:e.endTime}))}class ut{get signal(){return this.abortController.signal}get container(){return this._container}constructor(e){this.hasExplicitPrimaryColor=void 0!==e.primaryColor,this.config=p(u,e),this.state=r(),this.bus=new o,this.i18n=new y(this.config.lang),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 Ke;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 Je(e,this.state,this.signal),new Ze(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 w(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 fetch(e);return ht(await t.text())}catch(e){return[]}}(e).then(e=>{i.aborted||(t.chapters=e)}):t.chapters=ht(e)}initIntegrations(){var e,t;const{config:i,state:s,bus:n,signal:r}=this;if(i.chromecast){const e=new st(this.abortController);this.chromecastManager=e,e.init(i,s,n).catch(e=>{console.error("EBPlayer: ChromecastManager init failed:",e)})}if(i.epgContentId){(new nt).start(i,s,r).catch(e=>{console.error("EBPlayer: EpgManager start failed:",e)})}const o=i.playlist;if(o&&o.length>0){(new rt).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 ot).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 at,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)&&k(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 vt{}"function"==typeof SuppressedError&&SuppressedError;class gt{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 pt extends vt{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 gt({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 mt=Object.freeze({EASY_B:"easy_b",BUNNY:"bunny",AKAMAI:"akamai",VENOM:"venom"}),ft=Object.freeze({UNKNOWN:"unknown",MAX_RETRY:"max_retry",FORBIDDEN:"forbidden"});class bt 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 yt{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 bt))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 yt({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=kt({src:e,text:t});return new yt({src:e,responseParameters:i})}static fromText({src:e,text:t}){var i,s;if(t.trim().startsWith("{"))return yt.fromJson({src:e,json:t});const n=Et(t);if(n){const t=Object.assign({token:null,tokenPath:null},n);return new yt({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 yt({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 yt({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 bt?t:new bt(t);return new yt({src:e,error:i})}}function kt({src:e,text:t}){var i,s;const n=null!==(s=null===(i=Et(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 h=new URLSearchParams(r.search);if(o=h.get("hdntl"),d=h.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 u=null!=o?o:d;if(u){const e=u.match(/exp=(\d+)/);e&&(a=e[1]);const t=u.match(/hmac=([a-f0-9]+)/);t&&(l=t[1]);const i=u.match(/acl=([^~]+)/);i&&(c=i[1])}return{expires:a,hdntl:u,hmac:l,acl:c,hdnea:d,fullUrl:n}}const wt=/^https?:\/\//i;function Et(e){const t=e.trim();if(!wt.test(t))return null;const i=new URL(t).searchParams.get("expires");return i?{fullUrl:t,expires:parseInt(i,10)}:{fullUrl:t,expires:kt({src:t,text:""}).expires}}function Tt(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 Ct(e){const t=null==e?void 0:e.responseParameters,i=Tt(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 Lt(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 St(e,t){var i;const s=new URL(null!==(i=Lt(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 xt(e){return new Promise(t=>{setTimeout(t,e)})}class At{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(mt);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}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(),yt.fromError({src:i.toString(),error:new bt({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 fetch(`${this.tokenGeneratorUrl}?url=${encodeURIComponent(i.toString())}`):await fetch(this.tokenGeneratorUrl),403===t.status)return await xt(this.retryInterval),this._fetchDefaultToken(e,t);if(t.status>=400)return yt.fromError({src:i.toString(),error:new bt({status:t.status})});this.attempt=0;const s=await t.text();return yt.fromDefault({src:i.toString(),text:s})}catch(e){return console.error("CDNToken: Error fetching default token ",e),yt.fromError({src:i.toString(),error:e})}}async _fetchEasyBToken(e,t=null){var i,s,n,r;if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),yt.fromError({src:e,error:new bt({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 fetch(`${this.tokenGeneratorUrl}?url=${encodeURIComponent(e)}`,{method:"GET",headers:i}):await fetch(this.tokenGeneratorUrl,{method:"POST",headers:i,body:JSON.stringify({streamUrl:e})}),s.status>=400){const t=yt.fromError({src:e,error:new bt({status:s.status})});return 403===s.status?(await xt(this.retryInterval),this._fetchEasyBToken(e,t)):t}this.attempt=0;const n=await s.text();return yt.fromText({src:e,text:n})}catch(t){return console.error("CDNToken: Error fetching token ",t),yt.fromError({src:e,error:t})}}async _fetchAkamaiToken(e,t=null){if(this.attempt>=this.maxRetries)return this.resetAttemptCounter(),yt.fromError({src:e,error:new bt({status:null==t?void 0:t.status,errorCode:"Unauthorized",errorType:ft.MAX_RETRY})});try{this.attempt+=1;const t=await fetch(`${this.tokenGeneratorUrl}?url=${encodeURIComponent(e)}`);if(403===t.status)return await xt(this.retryInterval),this._fetchAkamaiToken(e,t);if(t.status>=400)return yt.fromError({src:e,error:new bt({status:t.status})});this.attempt=0;const i=await t.text();return yt.fromAkamai({src:e,text:i})}catch(t){return console.error("CDNToken: Error fetching token ",t),yt.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(),yt.fromError({src:e,error:new bt({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 fetch(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 bt({status:s.status,errorCode:n,errorType:r}),h=yt.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 xt(this.retryInterval),this._fetchBunnyToken(e,h)):(console.error(`CDNToken: error generating Bunny token on attempt ${this.attempt}`,JSON.stringify(h)),h)}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),yt.fromJson({src:e,json:JSON.stringify(n)})}catch(t){return console.error("CDNToken: Error fetching bunny token:",t),yt.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 mt.BUNNY:return this._fetchBunnyToken(e);case mt.AKAMAI:return this._fetchAkamaiToken(e);case mt.VENOM:case mt.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");switch(this.tokenType){case mt.AKAMAI:{const t=kt({src:e,text:""});if(!this.isTokenExpired(t.expires))return e;const i=Ct(this.lastTokenResponse),s=i&&!this.isTokenExpired(i.expires)?St(e,i):null;if(s)return s;const n=r.pathname.split("/");r.pathname=n.filter(e=>!e.startsWith("hdntl=")&&!e.startsWith("hdnea=")).join("/");break}case mt.EASY_B:case mt.VENOM:case mt.BUNNY:{if(!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=Ct(i);if(n)return null!==(t=St(e,n))&&void 0!==t?t:e;const{token:r,expires:o,tokenPath:a}=s;return At.appendTokenParams(e,r,o,a)}}break}default:if(!this.isTokenExpired(o))return e}const a=this.tokenType===mt.EASY_B||this.tokenType===mt.VENOM||this.tokenType===mt.BUNNY,l=Ct(this.lastTokenResponse),c=null!==(i=l&&Lt(r.toString(),l))&&void 0!==i?i:r.toString(),d=a&&this.sourceUrl?this.sourceUrl:c;try{const t=await this.fetchToken({src:d});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=Tt(t);if(i){if(t.src===c)return i;const e=Ct(t),s=e?St(c,e):null;if(s)return s}switch(this.tokenType){case mt.BUNNY:case mt.VENOM:case mt.EASY_B:{const i=t.responseParameters;return At.appendTokenParams(e,i.token,i.expires,i.tokenPath)}case mt.AKAMAI:{const i=t.responseParameters;return At.appendAkamaiTokenParams(e,null!==(n=null!==(s=i.hdntl)&&void 0!==s?s:i.hdnea)&&void 0!==n?n:"")}default:return At.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}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 $t(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 Mt{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:$t(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 Pt=new Set(["keySystemError"]);function _t(e,t){const i=new Map,s=new Set,n=new Set;let r,o=!1;e.on("hlsError",(a,l)=>{var c,d,h,u,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(Pt.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===(h=null==t?void 0:t.onUnrecoverableError)||void 0===h||h.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!==(u=i.get(g))&&void 0!==u?u: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 Rt(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 Bt=Object.freeze([mt.EASY_B,mt.VENOM,mt.BUNNY]);function Dt(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 At.appendTokenParams(e,s,n,r)}catch(t){return e}}function Ft(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||!Bt.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: ${Bt.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=Dt(e.url,l),s(e,n,r)}):(e.url=Dt(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 Ot extends pt{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&&(this.state.error=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 At({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 tt(r,"Hls");if(this.detached)return;const a=new Mt(this.tokenManager).buildHlsConfig(t.engineSettings),l=this.tokenManager,c=t.engineSettings,{emeEnabled:d,drmSystems:h}=c,u=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({},u);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);new URL(t.url).pathname.split("/").pop().endsWith(".m3u8")?e.updateUrlWithTokenParams({url:t.url}).then(e=>{t.url=e,i(t,s,n)}).catch(()=>{i(t,s,n)}):i(t,s,n)}}}if(g.pLoader=i,!0===t.engineSettings.signSegmentsWithCdnToken){const t=Ft(o.DefaultConfig.loader,e);g.fLoader=t,g.loader=t}}if(!t.disableCustomAbr)try{const{createHlsAbrController:e}=await Promise.resolve().then(function(){return ii});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,Rt(p,o.Events);const m=Boolean(t.preroll)&&this.loadSourceUrl===t.preroll;if(t.retry&&_t(p,Object.assign({get chromecast_casting(){return s.isCasting},get isLive(){return s.isLive},onUnrecoverableError:e=>{var t;this.stopWatchdog(),this.state&&(this.state.error=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 w=0;const E=setInterval(()=>{if(w++,w>=10)return void clearInterval(E);const e=k.playbackState;if("playing"!==e&&!y.paused&&y.currentTime>0)return k.playbackState="playing",void clearInterval(E);"buffering"!==e&&"loading"!==e||!y.paused||(k.playbackState="paused",clearInterval(E))},200);n.addEventListener("abort",()=>clearInterval(E),{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&&(this.state.error="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 Vt=(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 Nt(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(),h=i(this.context).getInstance(),u=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,h=((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),u=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<h&&(r<t-1||u<=8)?["Switching to optimised quality level",r?Vt(u,i,h,o,c,t):r+1]:["Switching to optimised quality level",Vt(u,i,h,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:u.getQualityFor(c,h.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 It extends pt{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&&(this.state.error=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 tt(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=Nt(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 h=setInterval(()=>{if(d++,d>=10)return void clearInterval(h);const e=c.playbackState;if("playing"!==e&&!l.paused&&l.currentTime>0)return c.playbackState="playing",void clearInterval(h);"buffering"!==e&&"loading"!==e||!l.paused||(c.playbackState="paused",clearInterval(h))},200);n.addEventListener("abort",()=>clearInterval(h),{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 Ht(e){return e.split("?")[0].replace(/(\/hdn.*\/)/g,"/")}class Ut{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 tt(l.lib,"Easybroadcast");if(c.aborted)return;this.lib=new d.eblib.EBLibrary(l.manager);const h=Ht(null!==(t=l.src)&&void 0!==t?t:""),u=null!==(s=(null!==(i=l.libSettings)&&void 0!==i?i:{}).resourceManager)&&void 0!==s?s:{},v={resourceManager:Object.assign({tokenRemover:Ht},u),swarmManager:{url:h},statsOutput:{enable:!!l.stats,url:l.stats,intervalMs:3e4},playerInput:{content:String(null!==(n=l.content)&&void 0!==n?n:h),contentUrl:h,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 jt{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=Ft(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,Rt(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 zt{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 qt=["Proxy","AbortController"];var Wt;const Gt=new Map;function Qt(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 Yt(){return new Promise(e=>setTimeout(e,500))}function Xt(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 qt.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=Gt.get(t);void 0!==s&&(Qt(s),Gt.delete(t));const n=p(u,e),r=n.muted,o=n.manager,a=n.startAt,l=new ut(e);l.mount(t);const c=t.querySelector("video"),d={controller:l,engine:null,snapshotDestroy:null,p2p:null,container:t};Gt.set(t,d);let h="";const v={open(e){var t;h=e,null!==d.engine&&(d.engine.detach(),d.engine=null);const i=function(e,t){return e.includes(".mpd")&&!1!==t.dashjs?new It:new Ot}(e,n);if(null!==c&&i.setVideo(c),i.setBus(l.bus),i.setConfig(n),i.setLoadSource(e),l.setEngineSync(i),d.engine=i,n.lib&&n.manager&&null!==c){const s=e.includes(".mpd")&&!1!==n.dashjs;null===(t=d.p2p)||void 0===t||t.stop();const r=new Ut;d.p2p=r,i.driverReady.then(()=>r.integrate({video:c,driver:i.getDriver(),type:s?"dash":"hls",config:n,signal:l.signal})).catch(e=>{console.error("EBPlayer: P2PManager integrate failed:",e)})}if(n.showProgressThumb&&e!==n.preroll){null!==d.snapshotDestroy&&(d.snapshotDestroy(),d.snapshotDestroy=null);const t=e.includes(".mpd")&&!1!==n.dashjs;i.driverReady.then(()=>{if(t){const t=window;if(t.dashjs){new zt(e).init(t.dashjs).then(e=>{d.snapshotDestroy=()=>e.destroy(),l.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 Mt(s).buildHlsConfig(n.engineSettings),o=new jt({src:e,engineSettings:Object.assign(Object.assign({},n.engineSettings),r)},s);o.init(t.Hls).then(()=>{d.snapshotDestroy=()=>o.destroy();const e=o.getVideo();null!==e&&l.bus.emit("snapshot-handler-ready",{take:e=>o.take(e),video:e}),c&&(c.addEventListener("pause",()=>{var e;(null===(e=l.state)||void 0===e?void 0:e.isLive)&&o.stopLoad()},{signal:l.signal}),c.addEventListener("play",()=>{var e;(null===(e=l.state)||void 0===e?void 0:e.isLive)&&setTimeout(()=>o.startLoad(),0)},{signal:l.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!==d.snapshotDestroy&&(d.snapshotDestroy(),d.snapshotDestroy=null),null!==d.engine&&(d.engine.detach(),d.engine=null)},destroy(){Qt(d),Gt.delete(t)},get state(){return l.state}};if(l.setReloadCallback(()=>{if(!h)return;const e=h,t=l.getSavedSelections();v.close(),Yt().then(()=>{v.open(e),setTimeout(()=>{null!==d.engine&&(d.engine.setQuality(t.quality),d.engine.setAudioTrack(t.audioTrack),d.engine.setSubtitle(t.subtitleTrack))},2e3)})}),l.bus.on("error-fatal",()=>{var e;null===(e=d.p2p)||void 0===e||e.stop()},{signal:l.signal}),null===c){const e="EBPlayer: no <video> element found in the container after mount() — playback cannot start.";return console.error(e),l.state.error=e,v}let g=!1;const m=()=>{g||(g=!0,l.bus.emit("force-intro-complete"),c.muted=r,l.state.muted=r,n.manager=o,l.config.manager=o,n.startAt=a,l.config.startAt=a,l.state.error=null,n.src&&v.open(n.src))},f=Boolean(n.preroll),b=Boolean(n.ad);let k=null;const w=()=>{null!==k&&(clearTimeout(k),k=null)},E=e=>{k=setTimeout(()=>{l.signal.aborted||(l.state.adPlaying?E(e):(console.warn("eb-player: ad leg produced no ad-complete within the bound — falling through to main (G-07-11)"),e()))},3e4)};l.signal.addEventListener("abort",()=>{w()},{once:!0});let T=!b,C=Boolean(n.autoplay),L=!1;const S=()=>{if(L)return;L=!0;const e=d.engine;null!==e&&e.driverReady.then(()=>{const e=c.play();e&&"function"==typeof e.catch&&e.catch(e=>{console.warn("EBPlayer: deferred play() rejected",e)})})},x=()=>{T&&C&&(m(),n.autoplay||S())};if(b&&l.bus.on("ad-complete",()=>{w(),T=!0,f?m():x()},{signal:l.signal}),f)l.bus.on("intro-stream-complete",()=>{v.close(),l.state.muted=r,Yt().then(()=>{g||(b?E(m):m())})},{signal:l.signal}),c.muted=!1,l.state.muted=!1,n.manager=!1,l.config.manager=!1,n.startAt=void 0,l.config.startAt=void 0,v.open(n.preroll);else if(b)n.autoplay?E(()=>{T=!0,x()}):l.bus.on("play",()=>{C||(C=!0,T?(x(),S()):E(()=>{T=!0,x()}))},{signal:l.signal});else if(n.src)if(n.autoplay)v.open(n.src);else{let e=!0;l.bus.on("play",()=>{e&&(e=!1,v.open(n.src),S())},{signal:l.signal})}return v}function Kt(){for(const e of Gt.values())null!==e.engine&&(e.engine.detach(),e.engine=null)}function Jt(){for(const e of Gt.values())Qt(e);Gt.clear()}const Zt=t;if("undefined"!=typeof window){console.info(`%cEBPlayer v${Zt}`,"color: #1FA9DD; font-weight: bold");const e=window,t=null!==(Wt=e.EBPlayer)&&void 0!==Wt?Wt:{};Object.assign(t,{start:Xt,stop:Kt,destroy:Jt,AVAILABLE_THEMES:l,THEME_LAYOUTS:d,version:Zt}),e.EBPlayer=t}const ei="main",ti={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 ii=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===ei&&(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(ti.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===ei&&"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===ei&&"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!==ei||"initSegment"===l.sn)return;const h=null!==(n=null===(s=d.loading)||void 0===s?void 0:s.start)&&void 0!==n?n:0,u=(null!==(o=null===(r=d.parsing)||void 0===r?void 0:r.end)&&void 0!==o?o:0)-h;this.bitrateTestDelay=u/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=Jt,e.start=Xt,e.stop=Kt,e.version=Zt});
|