@asicupv/paella-video-plugins
Version:
More video formats for Paella Player
9 lines • 444 kB
JavaScript
(function(me,Qe){typeof exports=="object"&&typeof module<"u"?Qe(exports):typeof define=="function"&&define.amd?define(["exports"],Qe):(me=typeof globalThis<"u"?globalThis:me||self,Qe(me["paella-video-plugins"]={}))})(this,function(me){"use strict";var Qe=n=>{throw TypeError(n)},as=(n,e,t)=>e.has(n)||Qe("Cannot "+t),re=(n,e,t)=>(as(n,e,"read from private field"),t?t.call(n):e.get(n)),Je=(n,e,t)=>e.has(n)?Qe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Tt=(n,e,t,s)=>(as(n,e,"write to private field"),e.set(n,t),t),Si=(n,e,t)=>(as(n,e,"access private method"),t);const lt=Object.freeze({PLAY:"paella:play",PAUSE:"paella:pause",STOP:"paella:stop",ENDED:"paella:ended",SEEK:"paella:seek",FULLSCREEN_CHANGED:"paella:fullscreenchanged",ENTER_FULLSCREEN:"paella:enterfullscreen",EXIT_FULLSCREEN:"paella:exitfullscreen",VOLUME_CHANGED:"paella:volumeChanged",TIMEUPDATE:"paella:timeupdate",TRIMMING_CHANGED:"paella:trimmingChanged",CAPTIONS_CHANGED:"paella:captionsChanged",CAPTIONS_ENABLED:"paella:captionsEnabled",CAPTIONS_DISABLED:"paella:captionsDisabled",BUTTON_PRESS:"paella:buttonPress",SHOW_POPUP:"paella:showPopUp",HIDE_POPUP:"paella:hidePopUp",MANIFEST_LOADED:"paella:manifestLoaded",STREAM_LOADED:"paella:streamLoaded",PLAYER_LOADED:"paella:playerLoaded",PLAYER_UNLOADED:"paella:playerUnloaded",RESIZE:"paella:resize",RESIZE_END:"paella:resizeEnd",LAYOUT_CHANGED:"paella:layoutChanged",PLAYBACK_RATE_CHANGED:"paella:playbackRateChanged",VIDEO_QUALITY_CHANGED:"paella:videoQualityChanged",HIDE_UI:"paella:hideUI",SHOW_UI:"paella:showUI",COOKIE_CONSENT_CHANGED:"paella:cookieConsentChanged",LOG:"paella:log"});function os(n,e,t,s=!0){return n.__eventListeners__=n.__eventListeners__||{},Array.isArray(e)||(e=[e]),e.forEach(i=>{n.__eventListeners__[i]=n.__eventListeners__[i]||[],n.__eventListeners__[i].push({callback:t,unregisterOnUnload:s})}),t}function Li(n,e,t={}){n.__eventListeners__&&n.__eventListeners__[e]&&n.__eventListeners__[e].forEach(s=>s.callback(t))}function na(n){return new Promise((e,t)=>{fetch(n).then(s=>s.text()).then(s=>{e(s)}).catch(s=>t(s))})}function aa(n){const e=new URLSearchParams(window.location.search);return e.has(n)?e.get(n):null}function oa(n){const e=window.location.hash.replace("#","?"),t=new URLSearchParams(e);return t.has(n)?t.get(n):null}function Ai(n,e){const t=e||"/";return n=n.map((s,i)=>(i&&(s=s.replace(new RegExp("^"+t),"")),i!==n.length-1&&(s=s.replace(new RegExp(t+"$"),"")),s)),n.join(t)}function bi(n){return new RegExp("^([a-z]+://|//)","i").test(n)||/^\//.test(n)}function Ri(n){try{return new URL(n).pathname.split("/").pop()}catch{return n.split("/").pop()}}function la(n){return n.split(".").reduce((e,t,s,i)=>s<i.length-1?e!==""?`${e}.${t}`:t:e,"")}function ca(n){const e=t=>{const s=t.split("/").reduce((i,r,a,o)=>a<o.length-1?i!==""?`${i}/${r}`:r:i,"");return(t[0]==="/"?`/${s}`:s)+"/"};try{const t=new URL(n);return t.origin+e(t.pathname)}catch{return e(n)}}function ha(n){return Ri(n).split(".").pop()}function ls(n,e){return bi(e)?e:Ai([n.manifestUrl,e])}function ua(n){n.__hideTimerPaused__=!0}function Ii(n){n.__hideTimerPaused__=!1}function da(n,e="hideUiTime"){var t;n.__hideTimer__=null;const s=async()=>n.__hideTimerPaused__?(n.log.debug("UI not hidden because the auto hide timer is paused"),!1):i()?(n.log.debug("UI not hidden because there is a focused element"),!1):(await n.hideUserInterface(),!0);(t=n.config.ui)!=null&&t.hideOnMouseLeave&&n.containerElement.addEventListener("mouseleave",()=>{s()});const i=()=>{const a=document.activeElement,o=document.querySelector(":focus-visible");return(n.playbackBar.element.contains(a)||n.videoContainer.element.contains(a))&&["input","textarea","button"].find(l=>a.tagName.toLowerCase(l))!==-1&&o},r=async()=>{n.__hideTimer__&&clearTimeout(n.__hideTimer__),await n.showUserInterface(),n.__hideTimer__=setTimeout(async()=>{n.__hideTimer__=null,s()||r()},n[e])};n.containerElement.addEventListener("mousemove",async a=>{r()}),os(n,lt.PLAY,async()=>{r()}),os(n,lt.PAUSE,async()=>{await n.showUserInterface()}),os(n,lt.ENDED,async()=>{await n.showUserInterface()}),document.addEventListener("keydown",async()=>{r()})}function fa(n){n.__hideTimer__&&(clearTimeout(n.__hideTimer__),delete n.__hideTimer__)}function ga(n){const e=Math.floor(n/60/60),t=Math.floor(n/60)-e*60,s=Math.floor(n%60);return(e>0?e.toString().padStart(2,"0")+":":"")+t.toString().padStart(2,"0")+":"+s.toString().padStart(2,"0")}function ma(n){const e=/^(?:(\d+):){0,1}(\d+):(\d+)(\.\d+)?$/.exec(n);if(e){const t=e[1]!==void 0?Number(e[1]):0,s=Number(e[2]),i=Number(e[3]);return t*3600+s*60+i}return null}function pa(n){const e=/^(?:(\d+):){0,1}(\d+):(\d+)\.(\d+)?$/.exec(n);if(e){const t=e[1]!==void 0?Number(e[1]):0,s=Number(e[2]),i=Number(e[3]),r=e[4]&&Number(e[4])||0;return t*36e5+s*6e4+i*1e3+r}return null}function Ci(n,e,t=365){let s=new Date;s.setTime(s.getTime()+t*24*60*60*1e3);let i=`expires=${s.toUTCString()}`;document.cookie=`${n}=${e};${i};path=/;SameSite=None;`+(/Apple/.test(navigator.vendor)?"":"Secure;")}function ya(n,e,t,s,i=365){n.cookieConsent.getConsentForType(e)&&Ci(t,s,i)}function cs(n){let e=n+"=",t=decodeURIComponent(document.cookie).split(";");for(let s=0;s<t.length;++s){let i=t[s];for(;i.charAt(0)==" ";)i=i.substring(1);if(i.indexOf(e)==0)return i.substring(e.length,i.length)}return""}function Ta(n){const e=cs(n),t=Number(e);return e!==""&&!isNaN(t)?t:null}function Ea(n){try{return JSON.parse(cs(n))}catch{return null}}function xa(n,e=!0){return new Promise(t=>{const s=document.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href",n),s.onload=()=>t(s);const i=document.getElementsByTagName("head")[0];e&&i.appendChild(s),t()})}function va(n){document.getElementsByTagName("head")[0].removeChild(n)}function hs(n,e,t=!0){for(const s in e){const i=n[s];let r=e[s];t&&Array.isArray(i)&&Array.isArray(r)?(i.forEach(a=>{r=r.filter(o=>typeof a=="object"&&typeof o=="object"&&a.id===o.id?(hs(a,o,t),!1):!0)}),r.forEach(a=>{i.push(a)})):typeof i=="object"&&r?hs(i,r,t):n[s]=e[s]}}function us(n,{excludedTags:e=null}={}){const t=document.createElement("div");t.innerHTML=n;const s=["script"];return e&&s.push(...e),s.flatMap(i=>Array.from(t.getElementsByTagName(i))).forEach(i=>{i.parentElement.removeChild(i)}),t.innerHTML}let Et=null;function Sa(n){if(!n)return!1;Et||(Et=document.createElement("video"));let e=Et.canPlayType(n);if(e==="maybe"||e==="probably")return!0;if(/video\/mp4/i.test(n))return e=Et.canPlayType("video/mp4"),e==="maybe"||e==="probably"}const La=Object.freeze(Object.defineProperty({__proto__:null,clearAutoHideTimer:fa,getCookie:cs,getFileExtension:ha,getHashParameter:oa,getJSONCookie:Ea,getNumericCookie:Ta,getUrlFileName:Ri,getUrlParameter:aa,isAbsoluteUrl:bi,joinPath:Ai,loadStyle:xa,loadSvgIcon:na,mergeObjects:hs,pauseAutoHideUiTimer:ua,removeExtension:la,removeFileName:ca,resolveResourcePath:ls,resumeAutoHideUiTimer:Ii,sanitizeHTML:us,secondsToTime:ga,setCookie:Ci,setCookieIfAllowed:ya,setupAutoHideUiTimer:da,supportsVideoType:Sa,timeToMilliseconds:pa,timeToSeconds:ma,unloadStyle:va},Symbol.toStringTag,{value:"Module"}));var xt;class ds{constructor(e){Je(this,xt,null),Tt(this,xt,e)}get player(){return re(this,xt)}}xt=new WeakMap;function Aa({tag:n="div",attributes:e={},children:t="",innerText:s="",parent:i=null}){const r=document.createElement(n);r.innerText=s;for(let a in e)r.setAttribute(a,e[a]);return r.innerHTML=t,i&&i.appendChild(r),r}function ct(n,e=null){const t=document.createElement("div");t.innerHTML=n;const s=t.children[0];return e&&e.appendChild(s),s}var Ae;class ba extends ds{constructor(e,{tag:t="div",attributes:s=[],children:i="",parent:r=null}){super(e),Je(this,Ae,null),Tt(this,Ae,Aa({tag:t,attributes:s,children:i,parent:r})),Object.defineProperty(this,t,{get:()=>re(this,Ae)})}get element(){return re(this,Ae)}get parent(){return re(this,Ae).parentElement}hide(){this.element.style.display="none"}show(e="block"){this.element.style.display=null}get isVisible(){const e=window.getComputedStyle(this.element);return e.display!=="none"&&e.display!==""}setAttribute(e,t){re(this,Ae).setAttribute(e,t)}removeFromParent(){var e;(e=re(this,Ae).parentElement)==null||e.removeChild(re(this,Ae))}setParent(e){this.removeFromParent(),e.appendChild(re(this,Ae))}}Ae=new WeakMap;class Di extends ds{constructor(e,t){super(e),this._name=t}getPluginModuleInstance(){return null}get config(){return this._config}get type(){return"none"}get order(){var e;return((e=this._config)==null?void 0:e.order)||0}get description(){var e;return((e=this._config)==null?void 0:e.description)||""}get name(){return this._name}async isEnabled(){var e;return(e=this.config)==null?void 0:e.enabled}async load(){}async unload(){}}class fs extends Di{get type(){return"video"}get streamType(){return"mp4"}async isCompatible(){return!1}async getVideoInstance(){return null}getCompatibleFileExtensions(){return[]}getManifestData(e){}}async function Ra(){return await new Promise(n=>{const e=document.createElement("audio"),t=setTimeout(()=>n(!1),100);e.addEventListener("volumechange",s=>{clearTimeout(t),n(!0)}),e.volume=.5})}class Ia extends ba{constructor(e,t,s){const i={class:"video-player"};super(t,{tag:e,attributes:i,parent:s}),this._streamProvider=null,this._streamData=null,this._ready=!1}async isVolumeApiAvailable(){return await Ra()}get streamData(){return this._streamData}get ready(){return this._ready}async load(e,t){return this._streamProvider=t,this._streamData=e,await this.loadStreamData(e)}get isMainAudioPlayer(){return this._streamProvider.mainAudioPlayer===this}onVideoEnded(e){this._videoEndedCallback=e}async play(){return!1}async pause(){return!1}async duration(){return-1}get currentTimeSync(){return-1}async currentTime(){return-1}async setCurrentTime(){return!1}async volume(){return-1}async setVolume(){return!1}initVolume(e){this._initialVolume=e}async paused(){return!0}async playbackRate(){return-1}async setPlaybackRate(){return!1}async getQualities(){return null}async setQuality(){return!1}get currentQuality(){return null}async getDimensions(){return null}async supportsMultiaudio(){return!1}async getAudioTracks(){return null}async setCurrentAudioTrack(){}get currentAudioTrack(){return null}async loadStreamData(e){return!1}get isEnabled(){return this._enabled}async enable(){this._enabled=!0}async disable(){this._enabled=!1}}class Ca extends ds{get moduleName(){return this.player.log.warn(`Incomplete player module definition: '${__filename}.moduleName'`),"-"}get moduleVersion(){return this.player.log.warn(`Incomplete player module definition: '${__filename}.moduleVersion'`),"0.0.0"}async getDictionaries(){return null}}class _i extends Ia{constructor(e,t,s,i){super("video",e,t),this._config=i||{};const r=this._config.crossOrigin??"";this.element.setAttribute("playsinline",""),r!==!1&&this.element.setAttribute("crossorigin",r),this.isMainAudio=s,this.element.setAttribute("autoplay",""),this.element.autoplay=!0,s||(this.element.muted=!0),this._videoEnabled=!0}async play(){if(this._videoEnabled)try{return await this.waitForLoaded(),this.video.play()}catch{}else this._disabledProperties.paused=!1}async pause(){if(this._videoEnabled)return await this.waitForLoaded(),this.video.pause();this._disabledProperties.paused=!0}async duration(){return this._videoEnabled?(await this.waitForLoaded(),this.video.duration):this._disabledProperties.duration}get currentTimeSync(){return this._videoEnabled?this.ready?this.video.currentTime:-1:this._disabledProperties.currentTime}async currentTime(){return this._videoEnabled?(await this.waitForLoaded(),this.currentTimeSync):this._disabledProperties.currentTime}async setCurrentTime(e){return this._videoEnabled?(await this.waitForLoaded(),this.video.currentTime=e):(this._disabledProperties.currentTime=e,e)}async volume(){return this._videoEnabled?(await this.waitForLoaded(),this.video.volume):this._disabledProperties.volume}async setVolume(e){return this._videoEnabled?(await this.waitForLoaded(),e===0?this.video.setAttribute("muted",""):this.video.removeAttribute("muted"),this.video.volume=e):(this._disabledProperties.volume=e,e)}async paused(){return this._videoEnabled?(await this.waitForLoaded(),this.video.paused):this._disabledProperties.paused}async playbackRate(){return this._videoEnabled?(await this.waitForLoaded(),await this.video.playbackRate):this._disabledProperties.playbackRate}async setPlaybackRate(e){return this._videoEnabled?(await this.waitForLoaded(),this.video.playbackRate=e):(this._disabledProperties.playbackRate=e,e)}async getQualities(){}async setQuality(){}get currentQuality(){return 0}async getDimensions(){return this._videoEnabled?(await this.waitForLoaded(),{w:this.video.videoWidth,h:this.video.videoHeight}):{w:this._disabledProperties.videoWidth,h:this._disabledProperties.videoHeight}}saveDisabledProperties(e){this._disabledProperties={duration:e.duration,volume:e.volume,videoWidth:e.videoWidth,videoHeight:e.videoHeight,playbackRate:e.playbackRate,paused:e.paused,currentTime:e.currentTime}}async loadStreamData(e=null){this._streamData=this._streamData||e,this.player.log.debug("es.upv.paella.htmlVideoFormat: loadStreamData"),this._sources=e.sources.html,this._currentQuality=0,this.isMainAudioPlayer||(this.video.muted=!0),this._sources.forEach(({src:t,mimetype:s})=>{t=ls(this.player,t);const i=document.createElement("source");i.src=t,i.type=s,this.video.appendChild(i)}),this._endedCallback=this._endedCallback||(()=>{typeof this._videoEndedCallback=="function"&&this._videoEndedCallback()}),this.video.addEventListener("ended",this._endedCallback);try{await this.video.play()}catch{}await this.waitForLoaded(),this.player.log.debug(`es.upv.paella.htmlVideoFormat (${this.streamData.content}): video loaded and ready.`),this.saveDisabledProperties(this.video)}async clearStreamData(){this.video.src="",this.video.removeEventListener("ended",this._endedCallback),this.video.removeEventListener("loadeddata",this._handleLoadedCallback),this._ready=!1}get isEnabled(){return this._videoEnabled}async enable(){this._videoEnabled=!0}async disable(){return this.isMainAudio?this.player.log.debug("video.disable() - the video is not disabled because it is the main audio source."):this._videoEnabled=!1,this._videoEnabled}waitForLoaded(){return new Promise((e,t)=>{this.video.readyState>=2&&(this._ready=!0),this.ready?e():(this._handleLoadedCallback=s=>{this.video.readyState>=2&&(this.video.pause(),this._ready=!0,e())},this.video.addEventListener("loadeddata",this._handleLoadedCallback))})}}class $e{constructor({label:e,shortLabel:t,isAuto:s=!1,index:i=0,src:r="",width:a=-1,height:o=-1,bitrate:l=-1}){this._label=e,this._shortLabel=t,this._index=i,this._src=r,this._res={w:a,h:o},this._bitrate=l,this._isAuto=s}get label(){return this._label}get shortLabel(){return this._shortLabel}get index(){return this._index}get src(){return this._src}get res(){return this._res}get bitrate(){return this._bitrate}get isAuto(){return this._isAuto}get quality(){return this._res.w!==-1&&this._res.h!==-1?this._res.w*this._res.h:this._bitrate}compare(e){return e.quality-this.quality}}class Da extends _i{constructor(e,t,s,i){super(e,t,s,i)}async loadStreamData(e=null){this._streamData=this._streamData||e,this.player.log.debug("es.upv.paella.mp4VideoFormat: loadStreamData"),this._currentSource||(this._sources=null,this._currentQuality=0,this._sources=e.sources.mp4,this._sources.sort((t,s)=>Number(t.res.w)-Number(s.res.w)),this._currentQuality=this._sources.length-1,this._currentSource=this._sources[this._currentQuality]),this.isMainAudioPlayer||(this.video.muted=!0),this._initialVolume&&(this.video.volume=this._initialVolume,this._initialVolume===0&&(this.video.muted=!0)),this.video.src=ls(this.player,this._currentSource.src),this._endedCallback=this._endedCallback||(()=>{typeof this._videoEndedCallback=="function"&&this._videoEndedCallback()}),this.video.addEventListener("ended",this._endedCallback);try{await this.video.play()}catch{}await this.waitForLoaded(),this.player.log.debug(`es.upv.paella.mp4VideoFormat (${this.streamData.content}): video loaded and ready.`),this.saveDisabledProperties(this.video)}}class _a extends Di{constructor(e,t,s){super(e,t,s),this.__uiPlugin=!0}async getDictionaries(){return null}}const wi=()=>{const n=document.createElement("span");return n.classList.add("side-container"),n.classList.add("hidden"),n};class wa{onIconChanged(e,t,s){}onTitleChanged(e,t,s){}onStateChanged(e,t,s,i,r){}}var vt,gs,Ge,He,St;class ka extends _a{constructor(){super(...arguments),Je(this,vt),Je(this,Ge,null),Je(this,He,null),Je(this,St,[])}get type(){return"button"}get container(){return this._container}get button(){return this._button}get interactive(){return!0}get dynamicWidth(){return!1}getId(){return null}get id(){return this.config.id||this.getId()}getButtonName(){return null}get buttonName(){return this.config.name||this.getButtonName()||this.name}get ariaLabel(){return this.config.ariaLabel||this.getAriaLabel()}getAriaLabel(){return""}get tabIndex(){return this.config.tabIndex||this.getTabIndex()}getTabIndex(){return null}getDescription(){return""}get description(){return this.config.description||this.getDescription()}get minContainerSize(){return this.config.minContainerSize||this.getMinContainerSize()}getMinContainerSize(){return 0}setObserver(e){if(e instanceof wa)this._observer=e;else if(typeof e.onIconChanged=="function"||typeof e.onTitleChanged=="function"||typeof e.onStateChanged=="function")this._observer=e;else throw new Error("Invalid observer for ButtonPlugin")}get icon(){return this._icon||(this._icon=""),this._icon}set icon(e){typeof e=="string"&&(e=us(e)),this._icon=e,Si(this,vt,gs).call(this)}get haveIcon(){return this.icon!==""}get menuIcon(){return this._menuIcon||(this._menuIcon=""),this._menuIcon}set menuIcon(e){typeof e=="string"&&(e=us(e)),this._menuIcon=e,Si(this,vt,gs).call(this)}get haveMenuIcon(){return this.menuIcon!==""}get isMenuButton(){var e,t,s;const i=((e=this.config)==null?void 0:e.parentContainer)==="playbackBar"||!((t=this.config)!=null&&t.parentContainer),r=((s=this.config)==null?void 0:s.parentContainer)==="videoContainer";return!i&&!r}get title(){return this._title||""}set title(e){var t;if(this._title=e,e&&this._button instanceof HTMLElement){const s=this._button.querySelector("span")||ct(`<span class="button-title-${this.titleSize}"></span>`,this._button);s.innerHTML=e}else if(this._button instanceof HTMLElement){const s=this._button.querySelector("span");s&&this._button.removeChild(s)}(t=this._observer)!=null&&t.onTitleChanged&&this._observer.onTitleChanged(this,this._title,e)}get titleSize(){return"medium"}get side(){var e;return((e=this.config)==null?void 0:e.side)||"left"}get closePopUps(){return this.config.closePopUps||this.getClosePopUps()}getClosePopUps(){return!0}get parentContainer(){var e;return((e=this.config)==null?void 0:e.parentContainer)||"playbackBar"}get className(){return""}enable(){this._enabled=!0,this.show()}disable(){this._enabled=!1,this.hide()}hide(){this._button&&(this._button.style.display="none")}show(){if(this._enabled===!1)return;const{width:e}=this.player.playbackBar.containerSize;this._button&&(e>this.minContainerSize||this.parentContainer!=="playbackBar")&&(this._button.style.display=null)}get leftSideContainer(){return re(this,Ge)||(Tt(this,Ge,wi()),this.container.appendChild(re(this,Ge))),re(this,Ge)}get leftSideContainerPresent(){return re(this,Ge)!==null}get rightSideContainer(){return re(this,He)||(Tt(this,He,wi()),this.container.appendChild(re(this,He))),re(this,He)}get rightSideContainerPresent(){return re(this,He)!==null}get stateText(){return null}get stateIcon(){return null}setState({text:e=null,icon:t=null}={}){var s,i;const r=this._statusText,a=this._statusIcon;this._statusText=e,this._statusIcon=t,re(this,St).forEach(o=>o(this)),this._statusIcon&&(this.icon=this._statusIcon,this.menuIcon=this._statusIcon),this._statusText&&(this.title=this._statusText),(i=(s=this._observer)==null?void 0:s.onStateChanged)==null||i.call(s,this,r,e,a,t)}onStateChange(e){typeof e=="function"?re(this,St).push(e):this.player.log.warn("Invalid callback for ButtonPlugin.onStateChange")}async action(e,t=null){}onResize({width:e,height:t}){e<this.minContainerSize?this.hide():this.show()}focus(){var e;(e=this.button)==null||e.focus()}blur(){var e;(e=this.button)==null||e.blur()}isFocus(){return this.button===document.activeElement}}vt=new WeakSet,gs=function(){var n;const e=this.isMenuButton?this._menuIcon:this._icon,t=this.isMenuButton&&this.haveMenuIcon?this.menuIcon:this.icon;if(t&&this._button instanceof HTMLElement){const s=this._button.querySelector("i")||ct("<i></i>",this._button);s.innerHTML=t}else if(this._button instanceof HTMLElement){const s=this._button.querySelector("i");s&&this._button.removeChild(s)}(n=this._observer)!=null&&n.onIconChanged&&this._observer.onIconChanged(this,e,t)},Ge=new WeakMap,He=new WeakMap,St=new WeakMap;class Pa extends ka{constructor(){super(...arguments),this._refreshContent=!0}set refreshContent(e){this._refreshContent=e}get refreshContent(){return this._refreshContent}get closeParentPopUp(){return this.config.closeParentPopUp||this.getCloseParentPopUp()}getCloseParentPopUp(){return!1}async action(e,t){super.action(e,t),this.parentPopUp=t,await this.showPopUp()}get parentPopUp(){return this._parentPopUp}set parentPopUp(e){this._parentPopUp=e}get popUp(){return this._popUp}get menuTitle(){return this.config.menuTitle||null}get moveable(){return this.config.moveable??!1}get resizeable(){return this.config.resizeable??!1}get customPopUpClass(){return this.config.customPopUpClass??""}get closeActions(){var e,t;const s=((e=this.config.closeActions)==null?void 0:e.clickOutside)??!0,i=((t=this.config.closeActions)==null?void 0:t.closeButton)??!1;return{clickOutside:s,closeButton:i}}get currentContent(){return this._currentContent}async getContent(){return ct("<p>Pop Up Button Plugin Content</p>")}async checkRefreshContent(){if(this.refreshContent){const e=await this.getContent();this._currentContent.innerHTML="",Array.from(e.children).forEach(t=>this._currentContent.appendChild(t))}}get popUpType(){return this.config.popUpType||"modal"}hidePopUp(){this.player.playbackBar.popUp.isHidden||this.player.playbackBar.popUp.hide()}async showPopUp(){this._keyEventHandler||(this._keyEventHandler=t=>{t.key==="Escape"&&this.hidePopUp()},this.button.addEventListener("keydown",this._keyEventHandler));const e=this.player.playbackBar.popUp;if(e.isHidden||this._contentId!==e.currentContentId){const t=await this.getContent();this._currentContent=t,this._contentId=e.show({title:this.menuTitle||this.description,content:t,attachRight:this.popUpType==="timeline"||this.side==="right",attachLeft:this.popUpType==="timeline"||this.side==="left",parent:this.parentPopUp})}else e.hide()}}const Fa=n=>n?`<span class="menu-title">${n}</span>`:"",Oa=n=>n?`<i class="menu-icon">${n}</i>`:"",Ma=n=>n?`aria-label="${n}"`:"",Na=n=>n?`<span class="state-text">${n}</span>`:"",Ua=n=>n?`<i class="state-icon">${n}</i>`:"",Ba=(n,e)=>n||e?`<span class="button-state">${Na(n)}${Ua(e)}</span>`:"";function $a({itemData:n,buttonType:e,container:t,allItems:s,menuName:i,selectedItems:r,itemPlugin:a}){const{id:o=0,title:l=null,icon:c=null,iconText:h=null,showTitle:u=!0,stateText:d=null,stateIcon:g=null}=n,f=this,m=document.createElement("li"),y=r[o]??!1,T=ct(`
<button class="menu-button-item${y?" selected":""}" ${Ma(l)} data-id="${o}"" id="${f.name}_menuItem_${o}">
${Oa(c)}
${u?Fa(l):""}
${d||g?Ba(d,g):""}
</button>
`);return a&&(a._button=T),T.addEventListener("keydown",E=>{var x;const b=()=>{E.stopPropagation(),E.preventDefault()};if(E.key==="ArrowUp"){const v=T.dataPrev;v==null||v.focus(),b()}else if(E.key==="ArrowDown"){const v=T.dataNext;v==null||v.focus(),b()}else if(E.key==="Tab"){const v=E.shiftKey?E.target.dataPrev:E.target.dataNext;v==null||v.focus(),b()}else E.key==="Escape"&&(this.player.playbackBar.popUp.pop()?(x=f.button)==null||x.focus():this.focus(),b())}),T.addEventListener("click",async E=>{if(e==="check"){const x=s.find(b=>b.id===o);r[o]=!r[o],f.itemSelected(x,s)}else if(e==="radio"){r[o]=!0;let x=null;s.forEach(b=>{b.id===o?x=b:r[b.id]=!1}),f.itemSelected(x,s)}else{const x=s.find(b=>b.id===o);f.itemSelected(x,s)}await f.checkRefreshContent(),E.stopPropagation(),f.closeOnSelect&&(f.closeMenu(),Ii(f.player))}),m.appendChild(T),t.appendChild(m),m}class Ga extends Pa{get closeOnSelect(){return this.config.closeOnSelect===void 0&&(this.buttonType!=="check"?this.config.closeOnSelect=!0:this.config.closeOnSelect=!1),this.config.closeOnSelect}setSelected(e,t){this._selectedItems&&(this._selectedItems[e]=t)}async getContent(){var e,t;const s=(e=document.activeElement)==null?void 0:e.id,i=ct("<menu></menu>");this._content=i;const r=await this.getMenu();this._menuItems=r,this._selectedItems||(this._selectedItems={},this._menuItems.forEach(l=>{l.selected!==void 0&&l.selected!==null&&(this._selectedItems[l.id]=l.selected)}));const a=self.crypto.randomUUID(),o=r.map(l=>$a.apply(this,[{itemData:l,buttonType:typeof this.buttonType=="function"?this.buttonType():this.buttonType,container:i,allItems:r,menuName:a,selectedItems:this._selectedItems,itemPlugin:l.plugin}]));return o.forEach((l,c,h)=>{const u=l.querySelector("button");let d=h[c+1],g=h[c-1];c===h.length-1&&(d=h[0]),c===0&&(g=h[h.length-1]),u.dataNext=d==null?void 0:d.querySelector("button"),u.dataPrev=g==null?void 0:g.querySelector("button")}),this._firstItem=(t=o[0])==null?void 0:t.querySelector("button"),s&&setTimeout(()=>{var l;(l=document.getElementById(s))==null||l.focus()},10),i}get menuTitle(){return this.config.menuTitle||null}async getMenu(){return[{id:0,title:"Option 1"},{id:1,title:"Option 2"},{id:2,title:"Option 3"},{id:3,title:"Option 4"},{id:4,title:"Option 5"}]}get menuItems(){return this._menuItems}get showTitles(){return!0}get buttonType(){return"radio"}itemSelected(e,t){this.player.log.warn(`MenuButtonPlugin (${this.name}): itemSelected() function not implemented.`)}closeMenu(){this.player.playbackBar.popUp.hide()}async showPopUp(){this.refreshContent=!0,await super.showPopUp(),this.player.containsFocus&&this._firstItem&&this._firstItem.focus()}}Object.freeze({DISABLED:0,ERROR:1,WARN:2,INFO:3,DEBUG:4,VERBOSE:5}).INFO;class ki{constructor({id:e,name:t,groupId:s="",language:i="",selected:r=!1}){this._id=e,this._name=t,this._groupId=s,this._lang=i,this._selected=r}get id(){return this._id}get name(){return this._name}get groupId(){return this._groupId}get language(){return this._lang}get selected(){return this._selected}set selected(e){this._selected=e}}const Ha={version:"2.2.1"};let ms=null;class Ze extends Ca{static Get(){return ms||(ms=new Ze),ms}get moduleName(){return"paella-video-plugins"}get moduleVersion(){return Ha.version}}const ps={autoStartLoad:!0,startPosition:-1,capLevelToPlayerSize:!0,debug:!1,defaultAudioCodec:void 0,initialLiveManifestSize:1,maxBufferLength:6,maxMaxBufferLength:6,maxBufferSize:600*1e3*1e3,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.2,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:500,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:500,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:500,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,appendErrorMaxRetry:3,enableWebVTT:!0,enableCEA708Captions:!0,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:5,abrEwmaSlowLive:9,abrEwmaFastVoD:4,abrEwmaSlowVoD:15,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,minAutoBitrate:0},Pi={withCredentials:!0,requestHeaders:{"Access-Control-Allow-Headers":"Content-Type, Accept, X-Requested-With","Access-Control-Allow-Origin":"http://localhost:8000","Access-Control-Allow-Credentials":"true"}},ue={UNSUPPORTED:0,MEDIA_SOURCE_EXTENSIONS:1,NATIVE:2};let ys=null;async function Ts(){return ys||(console.debug("Loading HLS.js"),ys=(await Promise.resolve().then(()=>cu)).default),ys}async function Se(n=!1){const e=await Ts(),t=document.createElement("video");return t.canPlayType("application/vnd.apple.mpegurl")&&n?ue.NATIVE:e.isSupported()?ue.MEDIA_SOURCE_EXTENSIONS:t.canPlayType("application/vnd.apple.mpegurl")?ue.NATIVE:ue.UNSUPPORTED}const Va=async(n,e,t,s,i)=>{var l,c;const r=await Ts();i.withCredentials&&(s.xhrSetup=function(h,u){h.withCredentials=i.withCredentials;for(const d in i.requestHeaders){const g=i.requestHeaders[d];h.setRequestHeader(d,g)}}),s.autoStartLoad=!0;const a=new r(s),o=((c=(l=e==null?void 0:e.sources)==null?void 0:l.hls)==null?void 0:c.length)>0&&e.sources.hls[0];return[a,new Promise((h,u)=>{let d=!1;a.on(r.Events.LEVEL_SWITCHED,(y,T)=>{n.log.debug(`HLS: quality level switched to ${T.level}`),d||(a.currentLevel=-1,d=!0),Li(n,lt.VIDEO_QUALITY_CHANGED,{})}),a.on(r.Events.ERROR,(y,T)=>{if(T.fatal)switch(T.type){case r.ErrorTypes.NETWORK_ERROR:T.details===r.ErrorDetails.MANIFEST_LOAD_ERROR?u(Error("hlsVideoFormatPlugin: unrecoverable error in HLS player. The video is not available")):(n.log.warn("hlsVideoFormatPlugin: Fatal network error. Try to recover"),a.startLoad());break;case r.ErrorTypes.MEDIA_ERROR:n.log.warn("hlsVideoFormatPlugin: Fatal media error encountered. Try to recover"),a.recoverMediaError();break;default:a.destroy(),u(Error("hlsVideoFormat: Fatal error. Can not recover"))}else n.log.warn("HLS: error"),n.log.warn(T.details)}),a.on(r.Events.LEVEL_SWITCHING,()=>{n.log.debug("HLS media attached")}),a.on(r.Events.MEDIA_ATTACHED,()=>{n.log.debug("HLS media attached")}),a.on(r.Events.MEDIA_DETACHING,()=>{n.log.debug("HLS media detaching")}),a.on(r.Events.MEDIA_DETACHED,()=>{n.log.debug("HLS media detached")}),a.on(r.Events.MANIFEST_PARSED,()=>{n.log.debug("HLS manifest parsed"),a.startLoad(-1)});const g=Math.floor(Math.random()*1e11),f=o.src+(s.enableCache?/\?/.test(o.src)?`&cache=${g}`:`?cache=${g}`:"");a.loadSource(f),a.attachMedia(t);let m=!1;a._videoEventListener=()=>{m=!0,h()},t.addEventListener("canplay",a._videoEventListener),setTimeout(()=>{m||t.play()},1e3)})]};class Es extends _i{constructor(e,t,s,i){super(e,t,i,s),this._config=this._config||{audioTrackLabel:s.audioTrackLabel||"name",enableCache:s.enableCache||!1};for(const r in ps)this._config[r]=ps[r];for(const r in s.hlsConfig)this._config[r]=s.hlsConfig[r];this._cors={};for(const r in Pi)this._cors[r]=Pi[r];for(const r in s.corsConfig)this._cors[r]=s.corsConfig[r];this._ready=!1,this._autoQuality=!0,this._forceNative=s.forceNative||!1}get autoQuality(){return this._autoQuality}get forceNative(){return this._forceNative}async loadStreamData(e){var s,i;if(await Se(this.forceNative)===ue.NATIVE){e.sources.mp4=e.sources.hls;const r=await super.loadStreamData(e),a=await this.getAudioTracks();return this._currentAudioTrack=a.find(o=>o.selected),this._autoQuality=new $e({label:"auto",shortLabel:"auto",index:-1,width:1,height:1,isAuto:!0}),this._currentQuality=this._autoQuality,this.saveDisabledProperties(this.video),this._endedCallback=this._endedCallback||(()=>{typeof this._videoEndedCallback=="function"&&this._videoEndedCallback()}),this.video.addEventListener("ended",this._endedCallback),r}else{this.player.log.debug("Loading HLS stream");const r=((i=(s=e==null?void 0:e.sources)==null?void 0:s.hls)==null?void 0:i.length)&&e.sources.hls[0];this._config.audioTrackLabel=(r==null?void 0:r.audioLabel)||this._config.audioTrackLabel;const[a,o]=await Va(this.player,e,this.video,this._config,this._cors);this._hls=a,await o,this.video.pause(),this._autoQuality=new $e({label:"auto",shortLabel:"auto",index:-1,width:1,height:1,isAuto:!0}),this._currentQuality=this._autoQuality;const l=await this.getAudioTracks();this._currentAudioTrack=l.find(c=>c.selected),this.saveDisabledProperties(this.video),this._endedCallback=this._endedCallback||(()=>{typeof this._videoEndedCallback=="function"&&this._videoEndedCallback()}),this.video.addEventListener("ended",this._endedCallback)}}async duration(){var e;if(this._videoEnabled){await this.waitForLoaded();let t=this.video.duration;return t===1/0&&(t=((e=this._hls)==null?void 0:e.liveSyncPosition)||0),t}else return this._disabledProperties.duration}async waitForLoaded(){if(await Se(this.forceNative)===ue.NATIVE)return super.waitForLoaded();await new Promise((t,s)=>{const i=()=>{this._ready&&t(),this.video.readyState>=2?(this._ready=!0,t()):setTimeout(()=>i(),200)};i()})}async getQualities(){const e=[];return e.push(this._autoQuality),await Se(this.forceNative)===ue.MEDIA_SOURCE_EXTENSIONS&&(this._hls.levels.forEach((s,i)=>{e.push(new $e({index:i,label:`${s.width}x${s.height}`,shortLabel:`${s.height}p`,width:s.width,height:s.height}))}),e.sort((s,i)=>s.res.h-i.res.h)),e}async setQuality(e){const t=await Se(this.forceNative);if(this._videoEnabled){if(!(e instanceof $e))throw Error("Invalid parameter setting video quality. VideoQualityItem object expected.");t===ue.MEDIA_SOURCE_EXTENSIONS?(this._currentQuality=e,this._hls.currentLevel=e.index):this.player.log.warn("Could not set video quality of HLS stream, because the HLS support of this browser is native.")}}get currentQuality(){return this._currentQuality}async supportsMultiaudio(){var t;await this.waitForLoaded();const e=await Se(this.forceNative);return e===ue.MEDIA_SOURCE_EXTENSIONS?this._hls.audioTracks.length>1:e===ue.NATIVE?((t=this.video.audioTracks)==null?void 0:t.length)>1:!1}async getAudioTracks(){await this.waitForLoaded();const e=this._config.audioTrackLabel||"name",t=await Se(this.forceNative);return t===ue.MEDIA_SOURCE_EXTENSIONS?this._hls.audioTracks.map(i=>new ki({id:i.id,name:i[e],language:i.lang,selected:this._hls.audioTrack===i.id})):t===ue.NATIVE?Array.from(this.video.audioTracks).map(i=>new ki({id:i.id,name:i.label,language:i.language,selected:i.enabled})):null}async setCurrentAudioTrack(e){await this.waitForLoaded();const s=(await this.getAudioTracks()).find(r=>r.id===e.id),i=await Se(this.forceNative);return i===ue.MEDIA_SOURCE_EXTENSIONS&&s?this._hls.audioTrack=s.id:i===ue.NATIVE&&s&&Array.from(this.video.audioTracks).forEach(r=>{r.id===s.id?r.enabled=!0:r.enabled=!1}),this._currentAudioTrack=s,s}get currentAudioTrack(){return this._currentAudioTrack}async clearStreamData(){this.video.removeEventListener("canplay",this._hls._videoEventListener),this.video.src="",this._hls.destroy(),this._ready=!1}}class Fi extends fs{getPluginModuleInstance(){return Ze.Get()}get name(){return super.name||"es.upv.paella.hlsVideoFormat"}get streamType(){return"hls"}async isCompatible(e){const{hls:t}=e.sources;return t&&await Se()}async getVideoInstance(e,t){return new Es(this.player,e,this.config,t)}getCompatibleFileExtensions(){return["m3u8"]}getManifestData(e){return{hls:e.map(t=>({src:t,mimetype:"video/mp4"}))}}}const Ka=async(n,e,t,s,i)=>{var l,c;const r=await Ts();i.withCredentials&&(s.xhrSetup=function(h,u){h.withCredentials=i.withCredentials;for(const d in i.requestHeaders){const g=i.requestHeaders[d];h.setRequestHeader(d,g)}});const a=new r(s),o=((c=(l=e==null?void 0:e.sources)==null?void 0:l.hlsLive)==null?void 0:c.length)>0&&e.sources.hlsLive[0];return s.initialQualityLevel!==void 0&&s.initialQualityLevel,[a,new Promise((h,u)=>{let d=!1;a.on(r.Events.LEVEL_SWITCHED,(m,y)=>{(void 0).player.log.debug(`HLS: quality level switched to ${y.level}`),d||(a.currentLevel=-1,d=!0),Li(n,lt.VIDEO_QUALITY_CHANGED,{})}),a.on(r.Events.ERROR,(m,y)=>{if(y.fatal)switch(y.type){case r.ErrorTypes.NETWORK_ERROR:y.details===r.ErrorDetails.MANIFEST_LOAD_ERROR?u(Error("hlsVideoFormatPlugin: unrecoverable error in HLS player. The video is not available")):(n.log.warn("hlsVideoFormatPlugin: Fatal network error. Try to recover"),a.startLoad());break;case r.ErrorTypes.MEDIA_ERROR:n.log.warn("hlsVideoFormatPlugin: Fatal media error encountered. Try to recover"),a.recoverMediaError();break;default:a.destroy(),u(Error("hlsVideoFormat: Fatal error. Can not recover"))}}),a.on(r.Events.MANIFEST_PARSED,()=>{s.autoStartLoad||a.autoStartLoad()});const g=Math.floor(Math.random()*1e11),f=o.src+(s.enableCache?/\?/.test(o.src)?`&cache=${g}`:`?cache=${g}`:"");a.loadSource(f),a.attachMedia(t),a._videoEventListener=()=>{h()},t.addEventListener("canplay",a._videoEventListener)})]};class Wa extends Es{async loadStreamData(e){if(await Se()===ue.NATIVE)return e.sources.hls=e.sources.hlsLive,super.loadStreamData(e);{this.player.log.debug("Loading HLS stream");const[s,i]=await Ka(this.player,e,this.video,this._config,this._cors);this._hls=s,await i,this._autoQuality=new $e({label:"auto",shortLabel:"auto",index:-1,width:1,height:1,isAuto:!0}),this._currentQuality=this._autoQuality;const r=await this.getAudioTracks();this._currentAudioTrack=r.find(a=>a.selected),this.saveDisabledProperties(this.video)}}}class Oi extends fs{getPluginModuleInstance(){return Ze.Get()}get name(){return super.name||"es.upv.paella.hlsLiveVideoFormat"}get streamType(){return"hlsLive"}async isCompatible(e){const t=await Se(),{hlsLive:s}=e.sources;return s&&t}async getVideoInstance(e,t){return new Wa(this.player,e,this.config,t)}}const Ya=`<svg width="100%" height="100%" viewBox="0 0 39 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="M37,9.5C37,5.913 34.087,3 30.5,3L8.5,3C4.913,3 2,5.913 2,9.5L2,22.5C2,26.087 4.913,29 8.5,29L30.5,29C34.087,29 37,26.087 37,22.5L37,9.5ZM18.97,21.884C18.97,21.983 18.891,22.125 18.733,22.308C17.111,24.188 15.102,25.128 12.706,25.128C10.21,25.128 8.214,24.217 6.716,22.395C5.319,20.698 4.62,18.577 4.62,16.031C4.62,13.486 5.331,11.356 6.754,9.642C8.268,7.795 10.269,6.872 12.756,6.872C15.277,6.872 17.227,7.725 18.608,9.43C18.741,9.605 18.808,9.75 18.808,9.867C18.808,10.008 18.587,10.426 18.147,11.121C17.706,11.816 17.439,12.163 17.348,12.163C17.24,12.163 16.986,11.959 16.587,11.551C16.096,11.052 15.634,10.678 15.202,10.428C14.486,10.021 13.696,9.817 12.831,9.817C11.184,9.817 9.902,10.445 8.987,11.701C8.172,12.824 7.765,14.238 7.765,15.944C7.765,17.649 8.168,19.076 8.975,20.224C9.89,21.513 11.167,22.158 12.806,22.158C13.621,22.158 14.407,21.954 15.164,21.547C15.663,21.28 16.171,20.902 16.687,20.411C17.119,20.003 17.356,19.8 17.398,19.8C17.448,19.8 17.722,20.13 18.221,20.792C18.721,21.453 18.97,21.817 18.97,21.884ZM34.38,21.884C34.38,21.983 34.301,22.125 34.143,22.308C32.521,24.188 30.512,25.128 28.116,25.128C25.62,25.128 23.624,24.217 22.126,22.395C20.729,20.698 20.03,18.577 20.03,16.031C20.03,13.486 20.741,11.356 22.164,9.642C23.678,7.795 25.678,6.872 28.166,6.872C30.686,6.872 32.637,7.725 34.018,9.43C34.151,9.605 34.218,9.75 34.218,9.867C34.218,10.008 33.997,10.426 33.556,11.121C33.116,11.816 32.849,12.163 32.758,12.163C32.65,12.163 32.396,11.959 31.997,11.551C31.506,11.052 31.044,10.678 30.612,10.428C29.896,10.021 29.106,9.817 28.241,9.817C26.594,9.817 25.312,10.445 24.397,11.701C23.582,12.824 23.174,14.238 23.174,15.944C23.174,17.649 23.578,19.076 24.385,20.224C25.3,21.513 26.577,22.158 28.216,22.158C29.031,22.158 29.817,21.954 30.574,21.547C31.073,21.28 31.581,20.902 32.096,20.411C32.529,20.003 32.766,19.8 32.808,19.8C32.858,19.8 33.132,20.13 33.631,20.792C34.13,21.453 34.38,21.817 34.38,21.884Z" />
</svg>`;class Mi extends Ga{getPluginModuleInstance(){return Ze.Get()}get name(){return super.name||"es.upv.paella.hlsCaptionsSelectorPlugin"}getAriaLabel(){return"Select captions"}getDescription(){return this.getAriaLabel()}async isEnabled(){const e=await super.isEnabled();return this._hls=this.player.videoContainer.streamProvider.mainAudioPlayer._hls,this._video=this.player.videoContainer.streamProvider.mainAudioPlayer.video,this._hls&&e}async load(){this.icon=this.player.getCustomPluginIcon(this.name,"captionsIcon")||Ya;const e=this._hls.subtitleTracks||[],t=this._video.textTracks||[];if(e.length>0)this._tracks=e,this._trackType="hls";else{this._videoTracks=t;const s=()=>(console.log("getTextTracks"),Array.from(t).map((i,r)=>({attrs:{LANGUAGE:i.language,NAME:i.label},language:i.language})));this._tracks=s(),this._videoTracks.length>0&&(this._trackType="native",this._tracks=s(),this._tracks.length>0&&this.enable()),t.onaddtrack=()=>{this._trackType="native",this._tracks=s(),this._tracks.length>0&&this.enable()}}this._hls.subtitleTrack,this._disabledTrack={id:-1,title:"Disabled",index:-1,selected:!0},this._selected=null,this._tracks.length==0&&this.disable()}async getMenu(){const e=[{id:-1,title:"Disabled",index:-1,selected:this._selected===null}];return this._tracks.forEach((t,s)=>{e.push({id:t.attrs.LANGUAGE||t.attrs.NAME,title:t.attrs.NAME||t.attrs.LANGUAGE,index:s,selected:t.language===this._selected})}),e}get buttonType(){return"radio"}itemSelected(e){var t;console.log(e),e.index===-1?(this._selected=null,this._trackType==="hls"?this._hls.subtitleTrack=-1:this._trackType==="native"&&Array.from(this._videoTracks).forEach(s=>s.mode="disabled")):(this._trackType==="hls"?this._hls.subtitleTrack=e.index:this._trackType==="native"&&(this._videoTracks[e.index].mode="showing"),this._selected=(t=this._tracks.find(s=>s.index===e.index))==null?void 0:t.language)}}class qa extends Da{async getQualities(){return this._qualities||(this._qualities=this._sources.map((e,t)=>new $e({index:t,label:`${e.res.w}x${e.res.h}`,shortLabel:`${e.res.h}p`,width:e.res.w,height:e.res.h,src:e.src}))),this._qualities}async setQuality(e){if(!(e instanceof $e))throw new Error("Invalid parameter setting video quality");this.player.log.debug(`org.opencast.paella.mp4MultiQualityVideoFormat: Change video quality to ${e.shortLabel}`),this._currentQuality=e;const t=this.video.currentTime,s=this.video.playbackRate;this.clearStreamData(),this.video.src=e.src,this.video.currentTime=t,this.video.playbackRate=s,this.video.addEventListener("ended",this._endedCallback),await new Promise(i=>{const r=()=>{this._ready=!0,this.video.pause(),this.video.removeEventListener("canplay",r),i(null)};this.video.addEventListener("canplay",r)})}get currentQuality(){return this._currentQuality}async loadStreamData(e=null){if(this._sources=null,this._sources=e.sources.mp4,this._sources.sort((t,s)=>Number(t.res.w)-Number(s.res.w)),!this._qualities){const t=await this.getQualities(),s=[window.screen.width,window.screen.height].map(l=>l*window.devicePixelRatio);let i=Math.min(s[0],s[1]),r=Math.max(s[0],s[1]);/Mobi/i.test(window.navigator.userAgent)&&(i=Math.max(i,900),r=Math.max(i,1600));let o=0;for(let l=1;l<this._sources.length;l+=1){const c=this._sources[l],h=Math.min(c.res.w,c.res.h),u=Math.max(c.res.w,c.res.h);h<=i&&u<=r&&(o=l)}this._currentQuality=t[o]}this._currentSource=this._sources[this._currentQuality.index],await super.loadStreamData(e)}}let Ni=class extends fs{getPluginModuleInstance(){return Ze.Get()}get streamType(){return"mp4"}get name(){return"es.upv.paella.mp4MultiQualityVideoFormat"}isCompatible(e){var s;const{mp4:t}=e.sources;return t&&La.supportsVideoType((s=t[0])==null?void 0:s.mimetype)}async getVideoInstance(e,t){return new qa(this.player,e,t,this.config)}};function ja(){return require.context("./plugins",!0,/\.js/)}const Ui=[{plugin:Fi,config:{enabled:!1}},{plugin:Oi,config:{enabled:!1}},{plugin:Mi,config:{enabled:!1}},{plugin:Ni,config:{enabled:!1}}],za=Ui,Xa=Fi,Qa=Oi,Ja=Mi,Za=Ni,eo={HlsVideo:Es,getHlsSupport:Se,defaultHlsConfig:ps,HlsSupport:ue};function to(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Bi={exports:{}};(function(n,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,c,h){if(h=h||{},l=l.trim(),c=c.trim(),!c){if(!h.alwaysNormalize)return l;var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var d=o.parseURL(c);if(!d)throw new Error("Error trying to parse relative URL.");if(d.scheme)return h.alwaysNormalize?(d.path=o.normalizePath(d.path),o.buildURLFromParts(d)):c;var g=o.parseURL(l);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var f=i.exec(g.path);g.netLoc=f[1],g.path=f[2]}g.netLoc&&!g.path&&(g.path="/");var m={scheme:g.scheme,netLoc:d.netLoc,path:null,params:d.params,query:d.query,fragment:d.fragment};if(!d.netLoc&&(m.netLoc=g.netLoc,d.path[0]!=="/"))if(!d.path)m.path=g.path,d.params||(m.params=g.params,d.query||(m.query=g.query));else{var y=g.path,T=y.substring(0,y.lastIndexOf("/")+1)+d.path;m.path=o.normalizePath(T)}return m.path===null&&(m.path=h.alwaysNormalize?o.normalizePath(d.path):d.path),o.buildURLFromParts(m)},parseURL:function(l){var c=s.exec(l);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};n.exports=o})()})(Bi);var xs=Bi.exports;function $i(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);e&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,s)}return t}function ne(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?$i(Object(t),!0).forEach(function(s){ro(n,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):$i(Object(t)).forEach(function(s){Object.defineProperty(n,s,Object.getOwnPropertyDescriptor(t,s))})}return n}function so(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var s=t.call(n,e);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function io(n){var e=so(n,"string");return typeof e=="symbol"?e:String(e)}function ro(n,e,t){return e=io(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function te(){return te=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=t[s])}return n},te.apply(this,arguments)}const O=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)},no=Number.isSafeInteger||function(n){return typeof n=="number"&&Math.abs(n)<=ao},ao=Number.MAX_SAFE_INTEGER||9007199254740991;let p=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",n}({}),B=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),A=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRe