UNPKG

mira-app-server

Version:

Mira Server - standalone server application using mira-app-core

2 lines 113 kB
function m(e,i,t){return(i=bt(i))in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}function gt(e,i){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var s=t.call(e,i);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(e)}function bt(e){var i=gt(e,"string");return typeof i=="symbol"?i:i+""}function yt(e,i){if(!(e instanceof i))throw new TypeError("Cannot call a class as a function")}function Oe(e,i){for(var t=0;t<i.length;t++){var s=i[t];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function vt(e,i,t){return i&&Oe(e.prototype,i),t&&Oe(e,t),e}function wt(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}function _e(e,i){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);i&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,s)}return t}function je(e){for(var i=1;i<arguments.length;i++){var t=arguments[i]!=null?arguments[i]:{};i%2?_e(Object(t),!0).forEach(function(s){wt(e,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):_e(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))})}return e}var De={addCSS:!0,thumbWidth:15,watch:!0};function kt(e,i){return function(){return Array.from(document.querySelectorAll(i)).includes(this)}.call(e,i)}function Tt(e,i){if(e&&i){var t=new Event(i,{bubbles:!0});e.dispatchEvent(t)}}var ie=function(e){return e!=null?e.constructor:null},Me=function(e,i){return!!(e&&i&&e instanceof i)},Be=function(e){return e==null},We=function(e){return ie(e)===Object},Ct=function(e){return ie(e)===Number&&!Number.isNaN(e)},ze=function(e){return ie(e)===String},At=function(e){return ie(e)===Boolean},Et=function(e){return ie(e)===Function},Ke=function(e){return Array.isArray(e)},Ye=function(e){return Me(e,NodeList)},St=function(e){return Me(e,Element)},Pt=function(e){return Me(e,Event)},Mt=function(e){return Be(e)||(ze(e)||Ke(e)||Ye(e))&&!e.length||We(e)&&!Object.keys(e).length},D={nullOrUndefined:Be,object:We,number:Ct,string:ze,boolean:At,function:Et,array:Ke,nodeList:Ye,element:St,event:Pt,empty:Mt};function Nt(e){var i="".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return i?Math.max(0,(i[1]?i[1].length:0)-(i[2]?+i[2]:0)):0}function xt(e,i){if(1>i){var t=Nt(i);return parseFloat(e.toFixed(t))}return Math.round(e/i)*i}var Lt=(function(){function e(i,t){yt(this,e),D.element(i)?this.element=i:D.string(i)&&(this.element=document.querySelector(i)),D.element(this.element)&&D.empty(this.element.rangeTouch)&&(this.config=je({},De,{},t),this.init())}return vt(e,[{key:"init",value:function(){e.enabled&&(this.config.addCSS&&(this.element.style.userSelect="none",this.element.style.webKitUserSelect="none",this.element.style.touchAction="manipulation"),this.listeners(!0),this.element.rangeTouch=this)}},{key:"destroy",value:function(){e.enabled&&(this.config.addCSS&&(this.element.style.userSelect="",this.element.style.webKitUserSelect="",this.element.style.touchAction=""),this.listeners(!1),this.element.rangeTouch=null)}},{key:"listeners",value:function(i){var t=this,s=i?"addEventListener":"removeEventListener";["touchstart","touchmove","touchend"].forEach(function(n){t.element[s](n,function(r){return t.set(r)},!1)})}},{key:"get",value:function(i){if(!e.enabled||!D.event(i))return null;var t,s=i.target,n=i.changedTouches[0],r=parseFloat(s.getAttribute("min"))||0,l=parseFloat(s.getAttribute("max"))||100,o=parseFloat(s.getAttribute("step"))||1,c=s.getBoundingClientRect(),u=100/c.width*(this.config.thumbWidth/2)/100;return 0>(t=100/c.width*(n.clientX-c.left))?t=0:100<t&&(t=100),50>t?t-=(100-2*t)*u:50<t&&(t+=2*(t-50)*u),r+xt(t/100*(l-r),o)}},{key:"set",value:function(i){e.enabled&&D.event(i)&&!i.target.disabled&&(i.preventDefault(),i.target.value=this.get(i),Tt(i.target,i.type==="touchend"?"change":"input"))}}],[{key:"setup",value:function(i){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},s=null;if(D.empty(i)||D.string(i)?s=Array.from(document.querySelectorAll(D.string(i)?i:'input[type="range"]')):D.element(i)?s=[i]:D.nodeList(i)?s=Array.from(i):D.array(i)&&(s=i.filter(D.element)),D.empty(s))return null;var n=je({},De,{},t);if(D.string(i)&&n.watch){var r=new MutationObserver(function(l){Array.from(l).forEach(function(o){Array.from(o.addedNodes).forEach(function(c){D.element(c)&&kt(c,i)&&new e(c,n)})})});r.observe(document.body,{childList:!0,subtree:!0})}return s.map(function(l){return new e(l,t)})}},{key:"enabled",get:function(){return"ontouchstart"in document.documentElement}}]),e})();const se=e=>e!==null&&typeof e<"u"?e.constructor:null,B=(e,i)=>!!(e&&i&&e instanceof i),Ne=e=>e===null||typeof e>"u",Xe=e=>se(e)===Object,$t=e=>se(e)===Number&&!Number.isNaN(e),pe=e=>se(e)===String,It=e=>se(e)===Boolean,Qe=e=>typeof e=="function",Je=e=>Array.isArray(e),Ot=e=>B(e,WeakMap),Ge=e=>B(e,NodeList),_t=e=>se(e)===Text,jt=e=>B(e,Event),Dt=e=>B(e,KeyboardEvent),Rt=e=>B(e,window.TextTrackCue)||B(e,window.VTTCue),Ht=e=>B(e,TextTrack)||!Ne(e)&&pe(e.kind),qt=e=>B(e,Promise)&&Qe(e.then);function Vt(e){return e!==null&&typeof e=="object"&&e.nodeType===1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"}function Ze(e){return Ne(e)||(pe(e)||Je(e)||Ge(e))&&!e.length||Xe(e)&&!Object.keys(e).length}function Ft(e){if(B(e,window.URL))return!0;if(!pe(e))return!1;let i=e;(!e.startsWith("http://")||!e.startsWith("https://"))&&(i=`http://${e}`);try{return!Ze(new URL(i).hostname)}catch{return!1}}var a={nullOrUndefined:Ne,object:Xe,number:$t,string:pe,boolean:It,function:Qe,array:Je,weakMap:Ot,nodeList:Ge,element:Vt,textNode:_t,event:jt,keyboardEvent:Dt,cue:Rt,track:Ht,promise:qt,url:Ft,empty:Ze};const ke=(()=>{const e=document.createElement("span"),i={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},t=Object.keys(i).find(s=>e.style[s]!==void 0);return a.string(t)?i[t]:!1})();function et(e,i){setTimeout(()=>{try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch{}},i)}function Ut(e){return JSON.parse(JSON.stringify(e))}function tt(e,i){return i.split(".").reduce((t,s)=>t&&t[s],e)}function L(e={},...i){if(!i.length)return e;const t=i.shift();return a.object(t)?(Object.keys(t).forEach(s=>{a.object(t[s])?(Object.keys(e).includes(s)||Object.assign(e,{[s]:{}}),L(e[s],t[s])):Object.assign(e,{[s]:t[s]})}),L(e,...i)):e}function it(e,i){const t=e.length?e:[e];Array.from(t).reverse().forEach((s,n)=>{const r=n>0?i.cloneNode(!0):i,l=s.parentNode,o=s.nextSibling;r.appendChild(s),o?l.insertBefore(r,o):l.appendChild(r)})}function Te(e,i){!a.element(e)||a.empty(i)||Object.entries(i).filter(([,t])=>!a.nullOrUndefined(t)).forEach(([t,s])=>e.setAttribute(t,s))}function y(e,i,t){const s=document.createElement(e);return a.object(i)&&Te(s,i),a.string(t)&&(s.textContent=t),s}function Bt(e,i){!a.element(e)||!a.element(i)||i.parentNode.insertBefore(e,i.nextSibling)}function Re(e,i,t,s){a.element(i)&&i.appendChild(y(e,t,s))}function U(e){if(a.nodeList(e)||a.array(e)){Array.from(e).forEach(U);return}!a.element(e)||!a.element(e.parentNode)||e.parentNode.removeChild(e)}function ae(e){if(!a.element(e))return;let{length:i}=e.childNodes;for(;i>0;)e.removeChild(e.lastChild),i-=1}function ue(e,i){return!a.element(i)||!a.element(i.parentNode)||!a.element(e)?null:(i.parentNode.replaceChild(e,i),e)}function V(e,i){if(!a.string(e)||a.empty(e))return{};const t={},s=L({},i);return e.split(",").forEach(n=>{const r=n.trim(),l=r.replace(".",""),c=r.replace(/[[\]]/g,"").split("="),[u]=c,p=c.length>1?c[1].replace(/["']/g,""):"";switch(r.charAt(0)){case".":a.string(s.class)?t.class=`${s.class} ${l}`:t.class=l;break;case"#":t.id=r.replace("#","");break;case"[":t[u]=p;break}}),L(s,t)}function K(e,i){if(!a.element(e))return;let t=i;a.boolean(t)||(t=!e.hidden),e.hidden=t}function E(e,i,t){if(a.nodeList(e))return Array.from(e).map(s=>E(s,i,t));if(a.element(e)){let s="toggle";return typeof t<"u"&&(s=t?"add":"remove"),e.classList[s](i),e.classList.contains(i)}return!1}function he(e,i){return a.element(e)&&e.classList.contains(i)}function Y(e,i){const{prototype:t}=Element;function s(){return Array.from(document.querySelectorAll(i)).includes(this)}return(t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||s).call(e,i)}function Wt(e,i){const{prototype:t}=Element;function s(){let r=this;do{if(Y.matches(r,i))return r;r=r.parentElement||r.parentNode}while(r!==null&&r.nodeType===1);return null}return(t.closest||s).call(e,i)}function Z(e){return this.elements.container.querySelectorAll(e)}function I(e){return this.elements.container.querySelector(e)}function be(e=null,i=!1){a.element(e)&&e.focus({preventScroll:!0,focusVisible:i})}const He={"audio/ogg":"vorbis","audio/wav":"1","video/webm":"vp8, vorbis","video/mp4":"avc1.42E01E, mp4a.40.2","video/ogg":"theora"},$={audio:"canPlayType"in document.createElement("audio"),video:"canPlayType"in document.createElement("video"),check(e,i){const t=$[e]||i!=="html5",s=t&&$.rangeInput;return{api:t,ui:s}},pip:document.pictureInPictureEnabled&&!y("video").disablePictureInPicture,airplay:a.function(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime(e){if(a.empty(e))return!1;const[i]=e.split("/");let t=e;if(!this.isHTML5||i!==this.type)return!1;Object.keys(He).includes(t)&&(t+=`; codecs="${He[e]}"`);try{return!!(t&&this.media.canPlayType(t).replace(/no/,""))}catch{return!1}},textTracks:"textTracks"in document.createElement("video"),rangeInput:(()=>{const e=document.createElement("input");return e.type="range",e.type==="range"})(),touch:"ontouchstart"in document.documentElement,transitions:ke!==!1,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},zt=(()=>{let e=!1;try{const i=Object.defineProperty({},"passive",{get(){return e=!0,null}});window.addEventListener("test",null,i),window.removeEventListener("test",null,i)}catch{}return e})();function ee(e,i,t,s=!1,n=!0,r=!1){if(!e||!("addEventListener"in e)||a.empty(i)||!a.function(t))return;const l=i.split(" ");let o=r;zt&&(o={passive:n,capture:r}),l.forEach(c=>{this&&this.eventListeners&&s&&this.eventListeners.push({element:e,type:c,callback:t,options:o}),e[s?"addEventListener":"removeEventListener"](c,t,o)})}function T(e,i="",t,s=!0,n=!1){ee.call(this,e,i,t,!0,s,n)}function fe(e,i="",t,s=!0,n=!1){ee.call(this,e,i,t,!1,s,n)}function xe(e,i="",t,s=!0,n=!1){const r=(...l)=>{fe(e,i,r,s,n),t.apply(this,l)};ee.call(this,e,i,r,!0,s,n)}function v(e,i="",t=!1,s={}){if(!a.element(e)||a.empty(i))return;const n=new CustomEvent(i,{bubbles:t,detail:{...s,plyr:this}});e.dispatchEvent(n)}function Kt(){this&&this.eventListeners&&(this.eventListeners.forEach(e=>{const{element:i,type:t,callback:s,options:n}=e;i.removeEventListener(t,s,n)}),this.eventListeners=[])}function Yt(){return new Promise(e=>this.ready?setTimeout(e,0):T.call(this,this.elements.container,"ready",e)).then(()=>{})}function F(e){a.promise(e)&&e.then(null,()=>{})}function Ce(e){return a.array(e)?e.filter((i,t)=>e.indexOf(i)===t):e}function st(e,i){return!a.array(e)||!e.length?null:e.reduce((t,s)=>Math.abs(s-i)<Math.abs(t-i)?s:t)}function nt(e){return!window||!window.CSS?!1:window.CSS.supports(e)}const qe=[[1,1],[4,3],[3,4],[5,4],[4,5],[3,2],[2,3],[16,10],[10,16],[16,9],[9,16],[21,9],[9,21],[32,9],[9,32]].reduce((e,[i,t])=>({...e,[i/t]:[i,t]}),{});function rt(e){return!a.array(e)&&(!a.string(e)||!e.includes(":"))?!1:(a.array(e)?e:e.split(":")).map(Number).every(a.number)}function de(e){if(!a.array(e)||!e.every(a.number))return null;const[i,t]=e,s=(r,l)=>l===0?r:s(l,r%l),n=s(i,t);return[i/n,t/n]}function Le(e){const i=s=>rt(s)?s.split(":").map(Number):null;let t=i(e);if(t===null&&(t=i(this.config.ratio)),t===null&&!a.empty(this.embed)&&a.array(this.embed.ratio)&&({ratio:t}=this.embed),t===null&&this.isHTML5){const{videoWidth:s,videoHeight:n}=this.media;t=[s,n]}return de(t)}function X(e){if(!this.isVideo)return{};const{wrapper:i}=this.elements,t=Le.call(this,e);if(!a.array(t))return{};const[s,n]=de(t),r=nt(`aspect-ratio: ${s}/${n}`),l=100/s*n;if(r?i.style.aspectRatio=`${s}/${n}`:i.style.paddingBottom=`${l}%`,this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){const o=100/this.media.offsetWidth*Number.parseInt(window.getComputedStyle(this.media).paddingBottom,10),c=(o-l)/(o/50);this.fullscreen.active?i.style.paddingBottom=null:this.media.style.transform=`translateY(-${c}%)`}else this.isHTML5&&i.classList.add(this.config.classNames.videoFixedRatio);return{padding:l,ratio:t}}function at(e,i,t=.05){const s=e/i,n=st(Object.keys(qe),s);return Math.abs(n-s)<=t?qe[n]:[e,i]}function Xt(){const e=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0);return[e,i]}const z={getSources(){return this.isHTML5?Array.from(this.media.querySelectorAll("source")).filter(i=>{const t=i.getAttribute("type");return a.empty(t)?!0:$.mime.call(this,t)}):[]},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:z.getSources.call(this).map(e=>Number(e.getAttribute("size"))).filter(Boolean)},setup(){if(!this.isHTML5)return;const e=this;e.options.speed=e.config.speed.options,a.empty(this.config.ratio)||X.call(e),Object.defineProperty(e.media,"quality",{get(){const t=z.getSources.call(e).find(s=>s.getAttribute("src")===e.source);return t&&Number(t.getAttribute("size"))},set(i){if(e.quality!==i){if(e.config.quality.forced&&a.function(e.config.quality.onChange))e.config.quality.onChange(i);else{const s=z.getSources.call(e).find(u=>Number(u.getAttribute("size"))===i);if(!s)return;const{currentTime:n,paused:r,preload:l,readyState:o,playbackRate:c}=e.media;e.media.src=s.getAttribute("src"),(l!=="none"||o)&&(e.once("loadedmetadata",()=>{e.speed=c,e.currentTime=n,r||F(e.play())}),e.media.load())}v.call(e,e.media,"qualitychange",!1,{quality:i})}}})},cancelRequests(){this.isHTML5&&(U(z.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}},Qt=!!window.document.documentMode,Jt=/Edge/.test(navigator.userAgent),Gt="WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent),Zt=navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,ei=/iPad|iPhone|iPod/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1;var _={isIE:Qt,isEdge:Jt,isWebKit:Gt,isIPadOS:Zt,isIos:ei};function ti(e){return`${e}-${Math.floor(Math.random()*1e4)}`}function Ae(e,...i){return a.empty(e)?e:e.toString().replace(/\{(\d+)\}/g,(t,s)=>i[s].toString())}function ii(e,i){return e===0||i===0||Number.isNaN(e)||Number.isNaN(i)?0:(e/i*100).toFixed(2)}function G(e="",i="",t=""){return e.replace(new RegExp(i.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),t.toString())}function lt(e=""){return e.toString().replace(/\w\S*/g,i=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase())}function si(e=""){let i=e.toString();return i=G(i,"-"," "),i=G(i,"_"," "),i=lt(i),G(i," ","")}function ni(e=""){let i=e.toString();return i=si(i),i.charAt(0).toLowerCase()+i.slice(1)}function ri(e){const i=document.createDocumentFragment(),t=document.createElement("div");return i.appendChild(t),t.innerHTML=e,i.firstChild.textContent}function ai(e){const i=document.createElement("div");return i.appendChild(e),i.innerHTML}const Ve={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},O={get(e="",i={}){if(a.empty(e)||a.empty(i))return"";let t=tt(i.i18n,e);if(a.empty(t))return Object.keys(Ve).includes(e)?Ve[e]:"";const s={"{seektime}":i.seekTime,"{title}":i.title};return Object.entries(s).forEach(([n,r])=>{t=G(t,n,r)}),t}};class te{constructor(i){m(this,"get",t=>{if(!te.supported||!this.enabled)return null;const s=window.localStorage.getItem(this.key);if(a.empty(s))return null;const n=JSON.parse(s);return a.string(t)&&t.length?n[t]:n}),m(this,"set",t=>{if(!te.supported||!this.enabled||!a.object(t))return;let s=this.get();a.empty(s)&&(s={}),L(s,t);try{window.localStorage.setItem(this.key,JSON.stringify(s))}catch{}}),this.enabled=i.config.storage.enabled,this.key=i.config.storage.key}static get supported(){try{if(!("localStorage"in window))return!1;const i="___test";return window.localStorage.setItem(i,i),window.localStorage.removeItem(i),!0}catch{return!1}}}function ne(e,i="text",t=!1){return new Promise((s,n)=>{try{const r=new XMLHttpRequest;if(!("withCredentials"in r))return;t&&(r.withCredentials=!0),r.addEventListener("load",()=>{if(i==="text")try{s(JSON.parse(r.responseText))}catch{s(r.responseText)}else s(r.response)}),r.addEventListener("error",()=>{throw new Error(r.status)}),r.open("GET",e,!0),r.responseType=i,r.send()}catch(r){n(r)}})}function ot(e,i){if(!a.string(e))return;const t="cache",s=a.string(i);let n=!1;const r=()=>document.getElementById(i)!==null,l=(o,c)=>{o.innerHTML=c,!(s&&r())&&document.body.insertAdjacentElement("afterbegin",o)};if(!s||!r()){const o=te.supported,c=document.createElement("div");if(c.setAttribute("hidden",""),s&&c.setAttribute("id",i),o){const u=window.localStorage.getItem(`${t}-${i}`);if(n=u!==null,n){const p=JSON.parse(u);l(c,p.content)}}ne(e).then(u=>{if(!a.empty(u)){if(o)try{window.localStorage.setItem(`${t}-${i}`,JSON.stringify({content:u}))}catch{}l(c,u)}}).catch(()=>{})}}const ct=e=>Math.trunc(e/60/60%60,10),li=e=>Math.trunc(e/60%60,10),oi=e=>Math.trunc(e%60,10);function ge(e=0,i=!1,t=!1){if(!a.number(e))return ge(void 0,i,t);const s=o=>`0${o}`.slice(-2);let n=ct(e);const r=li(e),l=oi(e);return i||n>0?n=`${n}:`:n="",`${t&&e>0?"-":""}${n}${s(r)}:${s(l)}`}const d={getIconUrl(){const e=new URL(this.config.iconUrl,window.location),i=window.location.host?window.location.host:window.top.location.host,t=e.host!==i||_.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:t}},findElements(){try{return this.elements.controls=I.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:Z.call(this,this.config.selectors.buttons.play),pause:I.call(this,this.config.selectors.buttons.pause),restart:I.call(this,this.config.selectors.buttons.restart),rewind:I.call(this,this.config.selectors.buttons.rewind),fastForward:I.call(this,this.config.selectors.buttons.fastForward),mute:I.call(this,this.config.selectors.buttons.mute),pip:I.call(this,this.config.selectors.buttons.pip),airplay:I.call(this,this.config.selectors.buttons.airplay),settings:I.call(this,this.config.selectors.buttons.settings),captions:I.call(this,this.config.selectors.buttons.captions),fullscreen:I.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=I.call(this,this.config.selectors.progress),this.elements.inputs={seek:I.call(this,this.config.selectors.inputs.seek),volume:I.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:I.call(this,this.config.selectors.display.buffer),currentTime:I.call(this,this.config.selectors.display.currentTime),duration:I.call(this,this.config.selectors.display.duration)},a.element(this.elements.progress)&&(this.elements.display.seekTooltip=this.elements.progress.querySelector(`.${this.config.classNames.tooltip}`)),!0}catch(e){return this.debug.warn("It looks like there is a problem with your custom controls HTML",e),this.toggleNativeControls(!0),!1}},createIcon(e,i){const t="http://www.w3.org/2000/svg",s=d.getIconUrl.call(this),n=`${s.cors?"":s.url}#${this.config.iconPrefix}`,r=document.createElementNS(t,"svg");Te(r,L(i,{"aria-hidden":"true",focusable:"false"}));const l=document.createElementNS(t,"use"),o=`${n}-${e}`;return"href"in l&&l.setAttributeNS("http://www.w3.org/1999/xlink","href",o),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o),r.appendChild(l),r},createLabel(e,i={}){const t=O.get(e,this.config),s={...i,class:[i.class,this.config.classNames.hidden].filter(Boolean).join(" ")};return y("span",s,t)},createBadge(e){if(a.empty(e))return null;const i=y("span",{class:this.config.classNames.menu.value});return i.appendChild(y("span",{class:this.config.classNames.menu.badge},e)),i},createButton(e,i){const t=L({},i);let s=ni(e);const n={element:"button",toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch(["element","icon","label"].forEach(l=>{Object.keys(t).includes(l)&&(n[l]=t[l],delete t[l])}),n.element==="button"&&!Object.keys(t).includes("type")&&(t.type="button"),Object.keys(t).includes("class")?t.class.split(" ").includes(this.config.classNames.control)||L(t,{class:`${t.class} ${this.config.classNames.control}`}):t.class=this.config.classNames.control,e){case"play":n.toggle=!0,n.label="play",n.labelPressed="pause",n.icon="play",n.iconPressed="pause";break;case"mute":n.toggle=!0,n.label="mute",n.labelPressed="unmute",n.icon="volume",n.iconPressed="muted";break;case"captions":n.toggle=!0,n.label="enableCaptions",n.labelPressed="disableCaptions",n.icon="captions-off",n.iconPressed="captions-on";break;case"fullscreen":n.toggle=!0,n.label="enterFullscreen",n.labelPressed="exitFullscreen",n.icon="enter-fullscreen",n.iconPressed="exit-fullscreen";break;case"play-large":t.class+=` ${this.config.classNames.control}--overlaid`,s="play",n.label="play",n.icon="play";break;default:a.empty(n.label)&&(n.label=s),a.empty(n.icon)&&(n.icon=e)}const r=y(n.element);return n.toggle?(r.appendChild(d.createIcon.call(this,n.iconPressed,{class:"icon--pressed"})),r.appendChild(d.createIcon.call(this,n.icon,{class:"icon--not-pressed"})),r.appendChild(d.createLabel.call(this,n.labelPressed,{class:"label--pressed"})),r.appendChild(d.createLabel.call(this,n.label,{class:"label--not-pressed"}))):(r.appendChild(d.createIcon.call(this,n.icon)),r.appendChild(d.createLabel.call(this,n.label))),L(t,V(this.config.selectors.buttons[s],t)),Te(r,t),s==="play"?(a.array(this.elements.buttons[s])||(this.elements.buttons[s]=[]),this.elements.buttons[s].push(r)):this.elements.buttons[s]=r,r},createRange(e,i){const t=y("input",L(V(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":O.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},i));return this.elements.inputs[e]=t,d.updateRangeFill.call(this,t),Lt.setup(t),t},createProgress(e,i){const t=y("progress",L(V(this.config.selectors.display[e]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},i));if(e!=="volume"){t.appendChild(y("span",null,"0"));const s={played:"played",buffer:"buffered"}[e],n=s?O.get(s,this.config):"";t.textContent=`% ${n.toLowerCase()}`}return this.elements.display[e]=t,t},createTime(e,i){const t=V(this.config.selectors.display[e],i),s=y("div",L(t,{class:`${t.class?t.class:""} ${this.config.classNames.display.time} `.trim(),"aria-label":O.get(e,this.config),role:"timer"}),"00:00");return this.elements.display[e]=s,s},bindMenuItemShortcuts(e,i){T.call(this,e,"keydown keyup",t=>{if(![" ","ArrowUp","ArrowDown","ArrowRight"].includes(t.key)||(t.preventDefault(),t.stopPropagation(),t.type==="keydown"))return;const s=Y(e,'[role="menuitemradio"]');if(!s&&[" ","ArrowRight"].includes(t.key))d.showMenuPanel.call(this,i,!0);else{let n;t.key!==" "&&(t.key==="ArrowDown"||s&&t.key==="ArrowRight"?(n=e.nextElementSibling,a.element(n)||(n=e.parentNode.firstElementChild)):(n=e.previousElementSibling,a.element(n)||(n=e.parentNode.lastElementChild)),be.call(this,n,!0))}},!1),T.call(this,e,"keyup",t=>{t.key==="Return"&&d.focusFirstMenuItem.call(this,null,!0)})},createMenuItem({value:e,list:i,type:t,title:s,badge:n=null,checked:r=!1}){const l=V(this.config.selectors.inputs[t]),o=y("button",L(l,{type:"button",role:"menuitemradio",class:`${this.config.classNames.control} ${l.class?l.class:""}`.trim(),"aria-checked":r,value:e})),c=y("span");c.innerHTML=s,a.element(n)&&c.appendChild(n),o.appendChild(c),Object.defineProperty(o,"checked",{enumerable:!0,get(){return o.getAttribute("aria-checked")==="true"},set(u){u&&Array.from(o.parentNode.children).filter(p=>Y(p,'[role="menuitemradio"]')).forEach(p=>p.setAttribute("aria-checked","false")),o.setAttribute("aria-checked",u?"true":"false")}}),this.listeners.bind(o,"click keyup",u=>{if(!(a.keyboardEvent(u)&&u.key!==" ")){switch(u.preventDefault(),u.stopPropagation(),o.checked=!0,t){case"language":this.currentTrack=Number(e);break;case"quality":this.quality=e;break;case"speed":this.speed=Number.parseFloat(e);break}d.showMenuPanel.call(this,"home",a.keyboardEvent(u))}},t,!1),d.bindMenuItemShortcuts.call(this,o,t),i.appendChild(o)},formatTime(e=0,i=!1){if(!a.number(e))return e;const t=ct(this.duration)>0;return ge(e,t,i)},updateTimeDisplay(e=null,i=0,t=!1){!a.element(e)||!a.number(i)||(e.textContent=d.formatTime(i,t))},updateVolume(){this.supported.ui&&(a.element(this.elements.inputs.volume)&&d.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),a.element(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||this.volume===0))},setRange(e,i=0){a.element(e)&&(e.value=i,d.updateRangeFill.call(this,e))},updateProgress(e){if(!this.supported.ui||!a.event(e))return;let i=0;const t=(s,n)=>{const r=a.number(n)?n:0,l=a.element(s)?s:this.elements.display.buffer;if(a.element(l)){l.value=r;const o=l.getElementsByTagName("span")[0];a.element(o)&&(o.childNodes[0].nodeValue=r)}};if(e)switch(e.type){case"timeupdate":case"seeking":case"seeked":i=ii(this.currentTime,this.duration),e.type==="timeupdate"&&d.setRange.call(this,this.elements.inputs.seek,i);break;case"playing":case"progress":t(this.elements.display.buffer,this.buffered*100);break}},updateRangeFill(e){const i=a.event(e)?e.target:e;if(!(!a.element(i)||i.getAttribute("type")!=="range")){if(Y(i,this.config.selectors.inputs.seek)){i.setAttribute("aria-valuenow",this.currentTime);const t=d.formatTime(this.currentTime),s=d.formatTime(this.duration),n=O.get("seekLabel",this.config);i.setAttribute("aria-valuetext",n.replace("{currentTime}",t).replace("{duration}",s))}else if(Y(i,this.config.selectors.inputs.volume)){const t=i.value*100;i.setAttribute("aria-valuenow",t),i.setAttribute("aria-valuetext",`${t.toFixed(1)}%`)}else i.setAttribute("aria-valuenow",i.value);!_.isWebKit&&!_.isIPadOS||i.style.setProperty("--value",`${i.value/i.max*100}%`)}},updateSeekTooltip(e){var i,t;if(!this.config.tooltips.seek||!a.element(this.elements.inputs.seek)||!a.element(this.elements.display.seekTooltip)||this.duration===0)return;const s=this.elements.display.seekTooltip,n=`${this.config.classNames.tooltip}--visible`,r=p=>E(s,n,p);if(this.touch){r(!1);return}let l=0;const o=this.elements.progress.getBoundingClientRect();if(a.event(e)){const p=e.pageX-e.clientX;l=100/o.width*(e.pageX-o.left-p)}else if(he(s,n))l=Number.parseFloat(s.style.left,10);else return;l<0?l=0:l>100&&(l=100);const c=this.duration/100*l;s.textContent=d.formatTime(c);const u=(i=this.config.markers)===null||i===void 0||(t=i.points)===null||t===void 0?void 0:t.find(({time:p})=>p===Math.round(c));u&&s.insertAdjacentHTML("afterbegin",`${u.label}<br>`),s.style.left=`${l}%`,a.event(e)&&["mouseenter","mouseleave"].includes(e.type)&&r(e.type==="mouseenter")},timeUpdate(e){const i=!a.element(this.elements.display.duration)&&this.config.invertTime;d.updateTimeDisplay.call(this,this.elements.display.currentTime,i?this.duration-this.currentTime:this.currentTime,i),!(e&&e.type==="timeupdate"&&this.media.seeking)&&d.updateProgress.call(this,e)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32){K(this.elements.display.currentTime,!0),K(this.elements.progress,!0);return}a.element(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);const e=a.element(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&d.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&d.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),this.config.markers.enabled&&d.setMarkers.call(this),d.updateSeekTooltip.call(this)},toggleMenuButton(e,i){K(this.elements.settings.buttons[e],!i)},updateSetting(e,i,t){const s=this.elements.settings.panels[e];let n=null,r=i;if(e==="captions")n=this.currentTrack;else{if(n=a.empty(t)?this[e]:t,a.empty(n)&&(n=this.config[e].default),!a.empty(this.options[e])&&!this.options[e].includes(n)){this.debug.warn(`Unsupported value of '${n}' for ${e}`);return}if(!this.config[e].options.includes(n)){this.debug.warn(`Disabled value of '${n}' for ${e}`);return}}if(a.element(r)||(r=s&&s.querySelector('[role="menu"]')),!a.element(r))return;const l=this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`);l.innerHTML=d.getLabel.call(this,e,n);const o=r&&r.querySelector(`[value="${n}"]`);a.element(o)&&(o.checked=!0)},getLabel(e,i){switch(e){case"speed":return i===1?O.get("normal",this.config):`${i}&times;`;case"quality":if(a.number(i)){const t=O.get(`qualityLabel.${i}`,this.config);return t.length?t:`${i}p`}return lt(i);case"captions":return A.getLabel.call(this);default:return null}},setQualityMenu(e){if(!a.element(this.elements.settings.panels.quality))return;const i="quality",t=this.elements.settings.panels.quality.querySelector('[role="menu"]');a.array(e)&&(this.options.quality=Ce(e).filter(r=>this.config.quality.options.includes(r)));const s=!a.empty(this.options.quality)&&this.options.quality.length>1;if(d.toggleMenuButton.call(this,i,s),ae(t),d.checkMenu.call(this),!s)return;const n=r=>{const l=O.get(`qualityBadge.${r}`,this.config);return l.length?d.createBadge.call(this,l):null};this.options.quality.sort((r,l)=>{const o=this.config.quality.options;return o.indexOf(r)>o.indexOf(l)?1:-1}).forEach(r=>{d.createMenuItem.call(this,{value:r,list:t,type:i,title:d.getLabel.call(this,"quality",r),badge:n(r)})}),d.updateSetting.call(this,i,t)},setCaptionsMenu(){if(!a.element(this.elements.settings.panels.captions))return;const e="captions",i=this.elements.settings.panels.captions.querySelector('[role="menu"]'),t=A.getTracks.call(this),s=!!t.length;if(d.toggleMenuButton.call(this,e,s),ae(i),d.checkMenu.call(this),!s)return;const n=t.map((r,l)=>({value:l,checked:this.captions.toggled&&this.currentTrack===l,title:A.getLabel.call(this,r),badge:r.language&&d.createBadge.call(this,r.language.toUpperCase()),list:i,type:"language"}));n.unshift({value:-1,checked:!this.captions.toggled,title:O.get("disabled",this.config),list:i,type:"language"}),n.forEach(d.createMenuItem.bind(this)),d.updateSetting.call(this,e,i)},setSpeedMenu(){if(!a.element(this.elements.settings.panels.speed))return;const e="speed",i=this.elements.settings.panels.speed.querySelector('[role="menu"]');this.options.speed=this.options.speed.filter(s=>s>=this.minimumSpeed&&s<=this.maximumSpeed);const t=!a.empty(this.options.speed)&&this.options.speed.length>1;d.toggleMenuButton.call(this,e,t),ae(i),d.checkMenu.call(this),t&&(this.options.speed.forEach(s=>{d.createMenuItem.call(this,{value:s,list:i,type:e,title:d.getLabel.call(this,"speed",s)})}),d.updateSetting.call(this,e,i))},checkMenu(){const{buttons:e}=this.elements.settings,i=!a.empty(e)&&Object.values(e).some(t=>!t.hidden);K(this.elements.settings.menu,!i)},focusFirstMenuItem(e,i=!1){if(this.elements.settings.popup.hidden)return;let t=e;a.element(t)||(t=Object.values(this.elements.settings.panels).find(n=>!n.hidden));const s=t.querySelector('[role^="menuitem"]');be.call(this,s,i)},toggleMenu(e){const{popup:i}=this.elements.settings,t=this.elements.buttons.settings;if(!a.element(i)||!a.element(t))return;const{hidden:s}=i;let n=s;if(a.boolean(e))n=e;else if(a.keyboardEvent(e)&&e.key==="Escape")n=!1;else if(a.event(e)){const r=a.function(e.composedPath)?e.composedPath()[0]:e.target,l=i.contains(r);if(l||!l&&e.target!==t&&n)return}t.setAttribute("aria-expanded",n),K(i,!n),E(this.elements.container,this.config.classNames.menu.open,n),n&&a.keyboardEvent(e)?d.focusFirstMenuItem.call(this,null,!0):!n&&!s&&be.call(this,t,a.keyboardEvent(e))},getMenuSize(e){const i=e.cloneNode(!0);i.style.position="absolute",i.style.opacity=0,i.removeAttribute("hidden"),e.parentNode.appendChild(i);const t=i.scrollWidth,s=i.scrollHeight;return U(i),{width:t,height:s}},showMenuPanel(e="",i=!1){const t=this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`);if(!a.element(t))return;const s=t.parentNode,n=Array.from(s.children).find(r=>!r.hidden);if($.transitions&&!$.reducedMotion){s.style.width=`${n.scrollWidth}px`,s.style.height=`${n.scrollHeight}px`;const r=d.getMenuSize.call(this,t),l=o=>{o.target!==s||!["width","height"].includes(o.propertyName)||(s.style.width="",s.style.height="",fe.call(this,s,ke,l))};T.call(this,s,ke,l),s.style.width=`${r.width}px`,s.style.height=`${r.height}px`}K(n,!0),K(t,!1),d.focusFirstMenuItem.call(this,t,i)},setDownloadUrl(){const e=this.elements.buttons.download;a.element(e)&&e.setAttribute("href",this.download)},create(e){const{bindMenuItemShortcuts:i,createButton:t,createProgress:s,createRange:n,createTime:r,setQualityMenu:l,setSpeedMenu:o,showMenuPanel:c}=d;this.elements.controls=null,a.array(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(t.call(this,"play-large"));const u=y("div",V(this.config.selectors.controls.wrapper));this.elements.controls=u;const p={class:"plyr__controls__item"};return Ce(a.array(this.config.controls)?this.config.controls:[]).forEach(b=>{if(b==="restart"&&u.appendChild(t.call(this,"restart",p)),b==="rewind"&&u.appendChild(t.call(this,"rewind",p)),b==="play"&&u.appendChild(t.call(this,"play",p)),b==="fast-forward"&&u.appendChild(t.call(this,"fast-forward",p)),b==="progress"){const h=y("div",{class:`${p.class} plyr__progress__container`}),g=y("div",V(this.config.selectors.progress));if(g.appendChild(n.call(this,"seek",{id:`plyr-seek-${e.id}`})),g.appendChild(s.call(this,"buffer")),this.config.tooltips.seek){const C=y("span",{class:this.config.classNames.tooltip},"00:00");g.appendChild(C),this.elements.display.seekTooltip=C}this.elements.progress=g,h.appendChild(this.elements.progress),u.appendChild(h)}if(b==="current-time"&&u.appendChild(r.call(this,"currentTime",p)),b==="duration"&&u.appendChild(r.call(this,"duration",p)),b==="mute"||b==="volume"){let{volume:h}=this.elements;if((!a.element(h)||!u.contains(h))&&(h=y("div",L({},p,{class:`${p.class} plyr__volume`.trim()})),this.elements.volume=h,u.appendChild(h)),b==="mute"&&h.appendChild(t.call(this,"mute")),b==="volume"&&!_.isIos&&!_.isIPadOS){const g={max:1,step:.05,value:this.config.volume};h.appendChild(n.call(this,"volume",L(g,{id:`plyr-volume-${e.id}`})))}}if(b==="captions"&&u.appendChild(t.call(this,"captions",p)),b==="settings"&&!a.empty(this.config.settings)){const h=y("div",L({},p,{class:`${p.class} plyr__menu`.trim(),hidden:""}));h.appendChild(t.call(this,"settings",{"aria-haspopup":!0,"aria-controls":`plyr-settings-${e.id}`,"aria-expanded":!1}));const g=y("div",{class:"plyr__menu__container",id:`plyr-settings-${e.id}`,hidden:""}),C=y("div"),w=y("div",{id:`plyr-settings-${e.id}-home`}),x=y("div",{role:"menu"});w.appendChild(x),C.appendChild(w),this.elements.settings.panels.home=w,this.config.settings.forEach(P=>{const f=y("button",L(V(this.config.selectors.buttons.settings),{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--forward`,role:"menuitem","aria-haspopup":!0,hidden:""}));i.call(this,f,P),T.call(this,f,"click",()=>{c.call(this,P,!1)});const k=y("span",null,O.get(P,this.config)),M=y("span",{class:this.config.classNames.menu.value});M.innerHTML=e[P],k.appendChild(M),f.appendChild(k),x.appendChild(f);const j=y("div",{id:`plyr-settings-${e.id}-${P}`,hidden:""}),R=y("button",{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});R.appendChild(y("span",{"aria-hidden":!0},O.get(P,this.config))),R.appendChild(y("span",{class:this.config.classNames.hidden},O.get("menuBack",this.config))),T.call(this,j,"keydown",H=>{H.key==="ArrowLeft"&&(H.preventDefault(),H.stopPropagation(),c.call(this,"home",!0))},!1),T.call(this,R,"click",()=>{c.call(this,"home",!1)}),j.appendChild(R),j.appendChild(y("div",{role:"menu"})),C.appendChild(j),this.elements.settings.buttons[P]=f,this.elements.settings.panels[P]=j}),g.appendChild(C),h.appendChild(g),u.appendChild(h),this.elements.settings.popup=g,this.elements.settings.menu=h}if(b==="pip"&&$.pip&&u.appendChild(t.call(this,"pip",p)),b==="airplay"&&$.airplay&&u.appendChild(t.call(this,"airplay",p)),b==="download"){const h=L({},p,{element:"a",href:this.download,target:"_blank"});this.isHTML5&&(h.download="");const{download:g}=this.config.urls;!a.url(g)&&this.isEmbed&&L(h,{icon:`logo-${this.provider}`,label:this.provider}),u.appendChild(t.call(this,"download",h))}b==="fullscreen"&&u.appendChild(t.call(this,"fullscreen",p))}),this.isHTML5&&l.call(this,z.getQualityOptions.call(this)),o.call(this),u},inject(){if(this.config.loadSprite){const l=d.getIconUrl.call(this);l.cors&&ot(l.url,"sprite-plyr")}this.id=Math.floor(Math.random()*1e4);let e=null;this.elements.controls=null;const i={id:this.id,seektime:this.config.seekTime,title:this.config.title};let t=!0;a.function(this.config.controls)&&(this.config.controls=this.config.controls.call(this,i)),this.config.controls||(this.config.controls=[]),a.element(this.config.controls)||a.string(this.config.controls)?e=this.config.controls:(e=d.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:A.getLabel.call(this)}),t=!1);const s=l=>{let o=l;return Object.entries(i).forEach(([c,u])=>{o=G(o,`{${c}}`,u)}),o};t&&a.string(this.config.controls)&&(e=s(e));let n;a.string(this.config.selectors.controls.container)&&(n=document.querySelector(this.config.selectors.controls.container)),a.element(n)||(n=this.elements.container);const r=a.element(e)?"insertAdjacentElement":"insertAdjacentHTML";if(n[r]("afterbegin",e),a.element(this.elements.controls)||d.findElements.call(this),!a.empty(this.elements.buttons)){const l=o=>{const c=this.config.classNames.controlPressed;o.setAttribute("aria-pressed","false"),Object.defineProperty(o,"pressed",{configurable:!0,enumerable:!0,get(){return he(o,c)},set(u=!1){E(o,c,u),o.setAttribute("aria-pressed",u?"true":"false")}})};Object.values(this.elements.buttons).filter(Boolean).forEach(o=>{a.array(o)||a.nodeList(o)?Array.from(o).filter(Boolean).forEach(l):l(o)})}if(_.isEdge&&et(n),this.config.tooltips.controls){const{classNames:l,selectors:o}=this.config,c=`${o.controls.wrapper} ${o.labels} .${l.hidden}`,u=Z.call(this,c);Array.from(u).forEach(p=>{E(p,this.config.classNames.hidden,!1),E(p,this.config.classNames.tooltip,!0)})}},setMediaMetadata(){try{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new window.MediaMetadata({title:this.config.mediaMetadata.title,artist:this.config.mediaMetadata.artist,album:this.config.mediaMetadata.album,artwork:this.config.mediaMetadata.artwork}))}catch{}},setMarkers(){var e,i;if(!this.duration||this.elements.markers)return;const t=(e=this.config.markers)===null||e===void 0||(i=e.points)===null||i===void 0?void 0:i.filter(({time:c})=>c>0&&c<this.duration);if(!(t!=null&&t.length))return;const s=document.createDocumentFragment(),n=document.createDocumentFragment();let r=null;const l=`${this.config.classNames.tooltip}--visible`,o=c=>E(r,l,c);t.forEach(c=>{const u=y("span",{class:this.config.classNames.marker},""),p=`${c.time/this.duration*100}%`;r&&(u.addEventListener("mouseenter",()=>{c.label||(r.style.left=p,r.innerHTML=c.label,o(!0))}),u.addEventListener("mouseleave",()=>{o(!1)})),u.addEventListener("click",()=>{this.currentTime=c.time}),u.style.left=p,n.appendChild(u)}),s.appendChild(n),this.config.tooltips.seek||(r=y("span",{class:this.config.classNames.tooltip},""),s.appendChild(r)),this.elements.markers={points:n,tip:r},this.elements.progress.appendChild(s)}};function ut(e,i=!0){let t=e;if(i){const s=document.createElement("a");s.href=t,t=s.href}try{return new URL(t)}catch{return null}}function ht(e){const i=new URLSearchParams;return a.object(e)&&Object.entries(e).forEach(([t,s])=>{i.set(t,s)}),i}const A={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!$.textTracks){a.array(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&d.setCaptionsMenu.call(this);return}if(a.element(this.elements.captions)||(this.elements.captions=y("div",V(this.config.selectors.captions)),this.elements.captions.setAttribute("dir","auto"),Bt(this.elements.captions,this.elements.wrapper)),_.isIE&&window.URL){const n=this.media.querySelectorAll("track");Array.from(n).forEach(r=>{const l=r.getAttribute("src"),o=ut(l);o!==null&&o.hostname!==window.location.href.hostname&&["http:","https:"].includes(o.protocol)&&ne(l,"blob").then(c=>{r.setAttribute("src",window.URL.createObjectURL(c))}).catch(()=>{U(r)})})}const e=navigator.languages||[navigator.language||navigator.userLanguage||"en"],i=Ce(e.map(n=>n.split("-")[0]));let t=(this.storage.get("language")||this.captions.language||this.config.captions.language||"auto").toLowerCase();t==="auto"&&([t]=i);let s=this.storage.get("captions")||this.captions.active;if(a.boolean(s)||({active:s}=this.config.captions),Object.assign(this.captions,{toggled:!1,active:s,language:t,languages:i}),this.isHTML5){const n=this.config.captions.update?"addtrack removetrack":"removetrack";T.call(this,this.media.textTracks,n,A.update.bind(this))}setTimeout(A.update.bind(this),0)},update(){const e=A.getTracks.call(this,!0),{active:i,language:t,meta:s,currentTrackNode:n}=this.captions,r=!!e.find(l=>l.language===t);this.isHTML5&&this.isVideo&&e.filter(l=>!s.get(l)).forEach(l=>{this.debug.log("Track added",l),s.set(l,{default:l.mode==="showing"}),l.mode==="showing"&&(l.mode="hidden"),T.call(this,l,"cuechange",()=>A.updateCues.call(this))}),(r&&this.language!==t||!e.includes(n))&&(A.setLanguage.call(this,t),A.toggle.call(this,i&&r)),this.elements&&E(this.elements.container,this.config.classNames.captions.enabled,!a.empty(e)),a.array(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&d.setCaptionsMenu.call(this)},toggle(e,i=!0){if(!this.supported.ui)return;const{toggled:t}=this.captions,s=this.config.classNames.captions.active,n=a.nullOrUndefined(e)?!t:e;if(n!==t){if(i||(this.captions.active=n,this.storage.set({captions:n})),!this.language&&n&&!i){const r=A.getTracks.call(this),l=A.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);this.captions.language=l.language,A.set.call(this,r.indexOf(l));return}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=n),E(this.elements.container,s,n),this.captions.toggled=n,d.updateSetting.call(this,"captions"),v.call(this,this.media,n?"captionsenabled":"captionsdisabled")}setTimeout(()=>{n&&this.captions.toggled&&(this.captions.currentTrackNode.mode="hidden")})},set(e,i=!0){const t=A.getTracks.call(this);if(e===-1){A.toggle.call(this,!1,i);return}if(!a.number(e)){this.debug.warn("Invalid caption argument",e);return}if(!(e in t)){this.debug.warn("Track not found",e);return}if(this.captions.currentTrack!==e){this.captions.currentTrack=e;const s=t[e],{language:n}=s||{};this.captions.currentTrackNode=s,d.updateSetting.call(this,"captions"),i||(this.captions.language=n,this.storage.set({language:n})),this.isVimeo&&this.embed.enableTextTrack(n,null,!1),v.call(this,this.media,"languagechange")}A.toggle.call(this,!0,i),this.isHTML5&&this.isVideo&&A.updateCues.call(this)},setLanguage(e,i=!0){if(!a.string(e)){this.debug.warn("Invalid language argument",e);return}const t=e.toLowerCase();this.captions.language=t;const s=A.getTracks.call(this),n=A.findTrack.call(this,[t]);A.set.call(this,s.indexOf(n),i)},getTracks(e=!1){return Array.from((this.media||{}).textTracks||[]).filter(t=>!this.isHTML5||e||this.captions.meta.has(t)).filter(t=>["captions","subtitles"].includes(t.kind))},findTrack(e,i=!1){const t=A.getTracks.call(this),s=l=>Number((this.captions.meta.get(l)||{}).default),n=Array.from(t).sort((l,o)=>s(o)-s(l));let r;return e.every(l=>(r=n.find(o=>o.language===l),!r)),r||(i?n[0]:void 0)},getCurrentTrack(){return A.getTracks.call(this)[this.currentTrack]},getLabel(e){let i=e;return!a.track(i)&&$.textTracks&&this.captions.toggled&&(i=A.getCurrentTrack.call(this)),a.track(i)?a.empty(i.label)?a.empty(i.language)?O.get("enabled",this.config):e.language.toUpperCase():i.label:O.get("disabled",this.config)},updateCues(e){if(!this.supported.ui)return;if(!a.element(this.elements.captions)){this.debug.warn("No captions element to render to");return}if(!a.nullOrUndefined(e)&&!Array.isArray(e)){this.debug.warn("updateCues: Invalid input",e);return}let i=e;if(!i){const n=A.getCurrentTrack.call(this);i=Array.from((n||{}).activeCues||[]).map(r=>r.getCueAsHTML()).map(ai)}const t=i.map(n=>n.trim()).join(` `);if(t!==this.elements.captions.innerHTML){ae(this.elements.captions);const n=y("span",V(this.config.selectors.caption));n.innerHTML=t,this.elements.captions.appendChild(n),v.call(this,this.media,"cuechange")}}},dt={enabled:!0,title:"",debug:!1,autoplay:!1,autopause:!0,playsinline:!0,seekTime:10,volume:1,muted:!1,duration:null,displayDuration:!0,invertTime:!0,toggleInvert:!0,ratio:null,clickToPlay:!0,hideControls:!0,resetOnEnd:!1,disableContextMenu:!0,loadSprite:!0,iconPrefix:"plyr",iconUrl:"https://cdn.plyr.io/3.8.4/plyr.svg",blankVideo:"https://cdn.plyr.io/static/blank.mp4",quality:{default:576,options:[4320,2880,2160,1440,1080,720,576,480,360,240],forced:!1,onChange:null},loop:{active:!1},speed:{selected:1,options:[.5,.75,1,1.25,1.5,1.75,2,4]},keyboard:{focused:!0,global:!1},tooltips:{controls:!1,seek:!0},captions:{active:!1,language:"auto",update:!1},fullscreen:{enabled:!0,fallback:!0,iosNative:!1},storage:{enabled:!0,key:"plyr"},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","pip","airplay","fullscreen"],settings:["captions","quality","speed"],i18n:{restart:"Restart",rewind:"Rewind {seektime}s",play:"Play",pause:"Pause",fastForward:"Forward {seektime}s",seek:"Seek",seekLabel:"{currentTime} of {duration}",played:"Played",buffered:"Buffered",currentTime:"Current time",duration:"Duration",volume:"Volume",mute:"Mute",unmute:"Unmute",enableCaptions:"Enable captions",disableCaptions:"Disable captions",download:"Download",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",frameTitle:"Player for {title}",captions:"Captions",settings:"Settings",pip:"PIP",menuBack:"Go back to previous menu",speed:"Speed",normal:"Normal",quality:"Quality",loop:"Loop",start:"Start",end:"End",all:"All",reset:"Reset",disabled:"Disabled",enabled:"Enabled",advertisement:"Ad",qualityBadge:{2160:"4K",1440:"HD",1080:"HD",720:"HD",576:"SD",480:"SD"}},urls:{download:null,vimeo:{sdk:"https://player.vimeo.com/api/player.js",iframe:"https://player.vimeo.com/video/{0}?{1}",api:"https://vimeo.com/api/oembed.json?url={0}"},youtube:{sdk:"https://www.youtube.com/iframe_api",api:"https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}"},googleIMA:{sdk:"https://imasdk.googleapis.com/js/sdkloader/ima3.js"}},listeners:{seek:null,play:null,pause:null,restart:null,rewind:null,fastForward:null,mute:null,volume:null,captions:null,download:null,fullscreen:null,pip:null,airplay:null,speed:null,quality:null,loop:null,language:null},events:["ended","progress","stalled","playing","waiting","canplay","canplaythrough","loadstart","loadeddata","loadedmetadata","timeupdate","volumechange","play","pause","error","seeking","seeked","emptied","ratechange","cuechange","download","enterfullscreen","exitfullscreen","captionsenabled","captionsdisabled","languagechange","controlshidden","controlsshown","ready","statechange","qualitychange","adsloaded","adscontentpause","adscontentresume","adstarted","adsmidpoint","adscomplete","adsallcomplete","adsimpression","adsclick"],selectors:{editable:"input, textarea, select, [contenteditable]",container:".plyr",controls:{container:null,wrapper:".plyr__controls"},labels:"[data-plyr]",buttons:{play:'[data-plyr="play"]',pause:'[data-plyr="pause"]',restart:'[data-plyr="restart"]',rewind:'[data-plyr="rewind"]',fastForward:'[data-plyr="fast-forward"]',mute:'[data-plyr="mute"]',captions:'[data-plyr="captions"]',download:'[data-plyr="download"]',fullscreen:'[data-plyr="fullscreen"]',pip:'[data-plyr="pip"]',airplay:'[data-plyr="airplay"]',settings:'[data-plyr="settings"]',loop:'[data-plyr="loop"]'},inputs:{seek:'[data-plyr="seek"]',volume:'[data-plyr="volume"]',speed:'[data-plyr="speed"]',language:'[data-plyr="language"]',quality:'[data-plyr="quality"]'},display:{currentTime:".plyr__time--current",duration:".plyr__time--duration",buffer:".plyr__progress__buffer",loop:".plyr__progress__loop",volume:".plyr__volume--display"},progress:".plyr__progress",captions:".plyr__captions",caption:".plyr__caption"},classNames:{type:"plyr--{0}",provider:"plyr--{0}",video:"plyr__video-wrapper",embed:"plyr__video-embed",videoFixedRatio:"plyr__video-wrapper--fixed-ratio",embedContainer:"plyr__video-embed__container",poster:"plyr__poster",posterEnabled:"plyr__poster-enabled",ads:"plyr__ads",control:"plyr__control",controlPressed:"plyr__control--pressed",playing:"plyr--playing",paused:"plyr--paused",stopped:"plyr--stopped",loading:"plyr--loading",hover:"plyr--hover",tooltip:"plyr__tooltip",cues:"plyr__cues",marker:"plyr__progress__marker",hidden:"plyr__sr-only",hideControls:"plyr--hide-controls",isTouch:"plyr--is-touch",uiSupported:"plyr--full-ui",noTransition:"plyr--no-transition",display:{time:"plyr__time"},menu:{value:"plyr__menu__value",badge:"plyr__badge",open:"plyr--menu-open"},captions:{ena