plyr
Version:
A simple, accessible and customizable HTML5, YouTube and Vimeo media player
1 lines • 120 kB
JavaScript
"object"==typeof navigator&&function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Plyr",t):(e="undefined"!=typeof globalThis?globalThis:e||self).Plyr=t()}(this,function(){"use strict";function e(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t);if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function t(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function i(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var a={addCSS:!0,thumbWidth:15,watch:!0};var r=function(e){return null!=e?e.constructor:null},o=function(e,t){return!!(e&&t&&e instanceof t)},l=function(e){return null==e},c=function(e){return r(e)===Object},u=function(e){return r(e)===String},h=function(e){return Array.isArray(e)},d=function(e){return o(e,NodeList)},m=u,p=h,g=d,f=function(e){return o(e,Element)},y=function(e){return o(e,Event)},b=function(e){return l(e)||(u(e)||h(e)||d(e))&&!e.length||c(e)&&!Object.keys(e).length};function v(e,t){if(1>t){var i=function(e){var t="".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0}(t);return parseFloat(e.toFixed(i))}return Math.round(e/t)*t}var w=function(){function e(t,i){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),f(t)?this.element=t:m(t)&&(this.element=document.querySelector(t)),f(this.element)&&b(this.element.rangeTouch)&&(this.config=n({},a,{},i),this.init())}return function(e,i,s){i&&t(e.prototype,i),s&&t(e,s)}(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(e){var t=this,i=e?"addEventListener":"removeEventListener";["touchstart","touchmove","touchend"].forEach(function(e){t.element[i](e,function(e){return t.set(e)},!1)})}},{key:"get",value:function(t){if(!e.enabled||!y(t))return null;var i,s=t.target,n=t.changedTouches[0],a=parseFloat(s.getAttribute("min"))||0,r=parseFloat(s.getAttribute("max"))||100,o=parseFloat(s.getAttribute("step"))||1,l=s.getBoundingClientRect(),c=100/l.width*(this.config.thumbWidth/2)/100;return 0>(i=100/l.width*(n.clientX-l.left))?i=0:100<i&&(i=100),50>i?i-=(100-2*i)*c:50<i&&(i+=2*(i-50)*c),a+v(i/100*(r-a),o)}},{key:"set",value:function(t){e.enabled&&y(t)&&!t.target.disabled&&(t.preventDefault(),t.target.value=this.get(t),function(e,t){if(e&&t){var i=new Event(t,{bubbles:!0});e.dispatchEvent(i)}}(t.target,"touchend"===t.type?"change":"input"))}}],[{key:"setup",value:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},s=null;if(b(t)||m(t)?s=Array.from(document.querySelectorAll(m(t)?t:'input[type="range"]')):f(t)?s=[t]:g(t)?s=Array.from(t):p(t)&&(s=t.filter(f)),b(s))return null;var r=n({},a,{},i);if(m(t)&&r.watch){var o=new MutationObserver(function(i){Array.from(i).forEach(function(i){Array.from(i.addedNodes).forEach(function(i){f(i)&&function(e,t){return function(){return Array.from(document.querySelectorAll(t)).includes(this)}.call(e,t)}(i,t)&&new e(i,r)})})});o.observe(document.body,{childList:!0,subtree:!0})}return s.map(function(t){return new e(t,i)})}},{key:"enabled",get:function(){return"ontouchstart"in document.documentElement}}]),e}();const k=e=>null!=e?e.constructor:null,T=(e,t)=>Boolean(e&&t&&e instanceof t),C=e=>null==e,E=e=>k(e)===Object,S=e=>k(e)===String,A=e=>"function"==typeof e,P=e=>Array.isArray(e),M=e=>T(e,NodeList);function N(e){return C(e)||(S(e)||P(e)||M(e))&&!e.length||E(e)&&!Object.keys(e).length}var x={nullOrUndefined:C,object:E,number:e=>k(e)===Number&&!Number.isNaN(e),string:S,boolean:e=>k(e)===Boolean,function:A,array:P,weakMap:e=>T(e,WeakMap),nodeList:M,element:function(e){return null!==e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument},textNode:e=>k(e)===Text,event:e=>T(e,Event),keyboardEvent:e=>T(e,KeyboardEvent),cue:e=>T(e,window.TextTrackCue)||T(e,window.VTTCue),track:e=>T(e,TextTrack)||!C(e)&&S(e.kind),promise:e=>T(e,Promise)&&A(e.then),url:function(e){if(T(e,window.URL))return!0;if(!S(e))return!1;let t=e;e.startsWith("http://")&&e.startsWith("https://")||(t=`http://${e}`);try{return!N(new URL(t).hostname)}catch{return!1}},empty:N};const L=(()=>{const e=document.createElement("span"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},i=Object.keys(t).find(t=>void 0!==e.style[t]);return!!x.string(i)&&t[i]})();function _(e,t){setTimeout(()=>{try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch{}},t)}function I(e,t){return t.split(".").reduce((e,t)=>e&&e[t],e)}function O(e={},...t){if(!t.length)return e;const i=t.shift();return x.object(i)?(Object.keys(i).forEach(t=>{x.object(i[t])?(Object.keys(e).includes(t)||Object.assign(e,{[t]:{}}),O(e[t],i[t])):Object.assign(e,{[t]:i[t]})}),O(e,...t)):e}function $(e,t){const i=e.length?e:[e];Array.from(i).reverse().forEach((e,i)=>{const s=i>0?t.cloneNode(!0):t,n=e.parentNode,a=e.nextSibling;s.appendChild(e),a?n.insertBefore(s,a):n.appendChild(s)})}function j(e,t){x.element(e)&&!x.empty(t)&&Object.entries(t).filter(([,e])=>!x.nullOrUndefined(e)).forEach(([t,i])=>e.setAttribute(t,i))}function R(e,t,i){const s=document.createElement(e);return x.object(t)&&j(s,t),x.string(i)&&(s.textContent=i),s}function D(e,t,i,s){x.element(t)&&t.appendChild(R(e,i,s))}function q(e){x.nodeList(e)||x.array(e)?Array.from(e).forEach(q):x.element(e)&&x.element(e.parentNode)&&e.parentNode.removeChild(e)}function H(e){if(!x.element(e))return;let{length:t}=e.childNodes;for(;t>0;)e.removeChild(e.lastChild),t-=1}function F(e,t){return x.element(t)&&x.element(t.parentNode)&&x.element(e)?(t.parentNode.replaceChild(e,t),e):null}function V(e,t){if(!x.string(e)||x.empty(e))return{};const i={},s=O({},t);return e.split(",").forEach(e=>{const t=e.trim(),n=t.replace(".",""),a=t.replace(/[[\]]/g,"").split("="),[r]=a,o=a.length>1?a[1].replace(/["']/g,""):"";switch(t.charAt(0)){case".":x.string(s.class)?i.class=`${s.class} ${n}`:i.class=n;break;case"#":i.id=t.replace("#","");break;case"[":i[r]=o}}),O(s,i)}function U(e,t){if(!x.element(e))return;let i=t;x.boolean(i)||(i=!e.hidden),e.hidden=i}function B(e,t,i){if(x.nodeList(e))return Array.from(e).map(e=>B(e,t,i));if(x.element(e)){let s="toggle";return void 0!==i&&(s=i?"add":"remove"),e.classList[s](t),e.classList.contains(t)}return!1}function W(e,t){return x.element(e)&&e.classList.contains(t)}function z(e,t){const{prototype:i}=Element;return(i.matches||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||function(){return Array.from(document.querySelectorAll(t)).includes(this)}).call(e,t)}function K(e){return this.elements.container.querySelectorAll(e)}function Y(e){return this.elements.container.querySelector(e)}function X(e=null,t=!1){x.element(e)&&e.focus({preventScroll:!0,focusVisible:t})}const Q={"audio/ogg":"vorbis","audio/wav":"1","video/webm":"vp8, vorbis","video/mp4":"avc1.42E01E, mp4a.40.2","video/ogg":"theora"},J={audio:"canPlayType"in document.createElement("audio"),video:"canPlayType"in document.createElement("video"),check(e,t){const i=J[e]||"html5"!==t;return{api:i,ui:i&&J.rangeInput}},pip:document.pictureInPictureEnabled&&!R("video").disablePictureInPicture,airplay:x.function(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime(e){if(x.empty(e))return!1;const[t]=e.split("/");let i=e;if(!this.isHTML5||t!==this.type)return!1;Object.keys(Q).includes(i)&&(i+=`; codecs="${Q[e]}"`);try{return Boolean(i&&this.media.canPlayType(i).replace(/no/,""))}catch{return!1}},textTracks:"textTracks"in document.createElement("video"),rangeInput:(()=>{const e=document.createElement("input");return e.type="range","range"===e.type})(),touch:"ontouchstart"in document.documentElement,transitions:!1!==L,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},G=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,null)});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch{}return e})();function Z(e,t,i,s=!1,n=!0,a=!1){if(!e||!("addEventListener"in e)||x.empty(t)||!x.function(i))return;const r=t.split(" ");let o=a;G&&(o={passive:n,capture:a}),r.forEach(t=>{this&&this.eventListeners&&s&&this.eventListeners.push({element:e,type:t,callback:i,options:o}),e[s?"addEventListener":"removeEventListener"](t,i,o)})}function ee(e,t="",i,s=!0,n=!1){Z.call(this,e,t,i,!0,s,n)}function te(e,t="",i,s=!0,n=!1){Z.call(this,e,t,i,!1,s,n)}function ie(e,t="",i,s=!0,n=!1){const a=(...r)=>{te(e,t,a,s,n),i.apply(this,r)};Z.call(this,e,t,a,!0,s,n)}function se(e,t="",i=!1,s={}){if(!x.element(e)||x.empty(t))return;const n=new CustomEvent(t,{bubbles:i,detail:{...s,plyr:this}});e.dispatchEvent(n)}function ne(){this&&this.eventListeners&&(this.eventListeners.forEach(e=>{const{element:t,type:i,callback:s,options:n}=e;t.removeEventListener(i,s,n)}),this.eventListeners=[])}function ae(){return new Promise(e=>this.ready?setTimeout(e,0):ee.call(this,this.elements.container,"ready",e)).then(()=>{})}function re(e){x.promise(e)&&e.then(null,()=>{})}function oe(e){return x.array(e)?e.filter((t,i)=>e.indexOf(t)===i):e}function le(e,t){return x.array(e)&&e.length?e.reduce((e,i)=>Math.abs(i-t)<Math.abs(e-t)?i:e):null}function ce(e){return!(!window||!window.CSS)&&window.CSS.supports(e)}const ue=[[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,[t,i])=>({...e,[t/i]:[t,i]}),{});function he(e){if(!(x.array(e)||x.string(e)&&e.includes(":")))return!1;return(x.array(e)?e:e.split(":")).map(Number).every(x.number)}function de(e){if(!x.array(e)||!e.every(x.number))return null;const[t,i]=e,s=(e,t)=>0===t?e:s(t,e%t),n=s(t,i);return[t/n,i/n]}function me(e){const t=e=>he(e)?e.split(":").map(Number):null;let i=t(e);if(null===i&&(i=t(this.config.ratio)),null===i&&!x.empty(this.embed)&&x.array(this.embed.ratio)&&({ratio:i}=this.embed),null===i&&this.isHTML5){const{videoWidth:e,videoHeight:t}=this.media;i=[e,t]}return de(i)}function pe(e){if(!this.isVideo)return{};const{wrapper:t}=this.elements,i=me.call(this,e);if(!x.array(i))return{};const[s,n]=de(i),a=100/s*n;if(ce(`aspect-ratio: ${s}/${n}`)?t.style.aspectRatio=`${s}/${n}`:t.style.paddingBottom=`${a}%`,this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){const e=100/this.media.offsetWidth*Number.parseInt(window.getComputedStyle(this.media).paddingBottom,10),i=(e-a)/(e/50);this.fullscreen.active?t.style.paddingBottom=null:this.media.style.transform=`translateY(-${i}%)`}else this.isHTML5&&t.classList.add(this.config.classNames.videoFixedRatio);return{padding:a,ratio:i}}function ge(e,t,i=.05){const s=e/t,n=le(Object.keys(ue),s);return Math.abs(n-s)<=i?ue[n]:[e,t]}const fe={getSources(){if(!this.isHTML5)return[];return Array.from(this.media.querySelectorAll("source")).filter(e=>{const t=e.getAttribute("type");return!!x.empty(t)||J.mime.call(this,t)})},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:fe.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,x.empty(this.config.ratio)||pe.call(e),Object.defineProperty(e.media,"quality",{get(){const t=fe.getSources.call(e).find(t=>t.getAttribute("src")===e.source);return t&&Number(t.getAttribute("size"))},set(t){if(e.quality!==t){if(e.config.quality.forced&&x.function(e.config.quality.onChange))e.config.quality.onChange(t);else{const i=fe.getSources.call(e).find(e=>Number(e.getAttribute("size"))===t);if(!i)return;const{currentTime:s,paused:n,preload:a,readyState:r,playbackRate:o}=e.media;e.media.src=i.getAttribute("src"),("none"!==a||r)&&(e.once("loadedmetadata",()=>{e.speed=o,e.currentTime=s,n||re(e.play())}),e.media.load())}se.call(e,e.media,"qualitychange",!1,{quality:t})}}})},cancelRequests(){this.isHTML5&&(q(fe.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}};var ye={isIE:Boolean(window.document.documentMode),isEdge:/Edge/.test(navigator.userAgent),isWebKit:"WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent),isIPadOS:"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,isIos:/iPad|iPhone|iPod/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1};function be(e,...t){return x.empty(e)?e:e.toString().replace(/\{(\d+)\}/g,(e,i)=>t[i].toString())}function ve(e="",t="",i=""){return e.replace(new RegExp(t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),i.toString())}function we(e=""){return e.toString().replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function ke(e=""){let t=e.toString();return t=function(e=""){let t=e.toString();return t=ve(t,"-"," "),t=ve(t,"_"," "),t=we(t),ve(t," ","")}(t),t.charAt(0).toLowerCase()+t.slice(1)}function Te(e){const t=document.createElement("div");return t.appendChild(e),t.innerHTML}const Ce={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},Ee={get(e="",t={}){if(x.empty(e)||x.empty(t))return"";let i=I(t.i18n,e);if(x.empty(i))return Object.keys(Ce).includes(e)?Ce[e]:"";const s={"{seektime}":t.seekTime,"{title}":t.title};return Object.entries(s).forEach(([e,t])=>{i=ve(i,e,t)}),i}};class Se{constructor(t){e(this,"get",e=>{if(!Se.supported||!this.enabled)return null;const t=window.localStorage.getItem(this.key);if(x.empty(t))return null;const i=JSON.parse(t);return x.string(e)&&e.length?i[e]:i}),e(this,"set",e=>{if(!Se.supported||!this.enabled)return;if(!x.object(e))return;let t=this.get();x.empty(t)&&(t={}),O(t,e);try{window.localStorage.setItem(this.key,JSON.stringify(t))}catch{}}),this.enabled=t.config.storage.enabled,this.key=t.config.storage.key}static get supported(){try{if(!("localStorage"in window))return!1;const e="___test";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}}function Ae(e,t="text",i=!1){return new Promise((s,n)=>{try{const n=new XMLHttpRequest;if(!("withCredentials"in n))return;i&&(n.withCredentials=!0),n.addEventListener("load",()=>{if("text"===t)try{s(JSON.parse(n.responseText))}catch{s(n.responseText)}else s(n.response)}),n.addEventListener("error",()=>{throw new Error(n.status)}),n.open("GET",e,!0),n.responseType=t,n.send()}catch(e){n(e)}})}function Pe(e,t){if(!x.string(e))return;const i="cache",s=x.string(t);let n=!1;const a=()=>null!==document.getElementById(t),r=(e,t)=>{e.innerHTML=t,s&&a()||document.body.insertAdjacentElement("afterbegin",e)};if(!s||!a()){const a=Se.supported,o=document.createElement("div");if(o.setAttribute("hidden",""),s&&o.setAttribute("id",t),a){const e=window.localStorage.getItem(`${i}-${t}`);if(n=null!==e,n){const t=JSON.parse(e);r(o,t.content)}}Ae(e).then(e=>{if(!x.empty(e)){if(a)try{window.localStorage.setItem(`${i}-${t}`,JSON.stringify({content:e}))}catch{}r(o,e)}}).catch(()=>{})}}const Me=e=>Math.trunc(e/60/60%60,10);function Ne(e=0,t=!1,i=!1){if(!x.number(e))return Ne(void 0,t,i);const s=e=>`0${e}`.slice(-2);let n=Me(e);const a=(r=e,Math.trunc(r/60%60,10));var r;const o=(e=>Math.trunc(e%60,10))(e);return n=t||n>0?`${n}:`:"",`${i&&e>0?"-":""}${n}${s(a)}:${s(o)}`}const xe={getIconUrl(){const e=new URL(this.config.iconUrl,window.location),t=window.location.host?window.location.host:window.top.location.host,i=e.host!==t||ye.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:i}},findElements(){try{return this.elements.controls=Y.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:K.call(this,this.config.selectors.buttons.play),pause:Y.call(this,this.config.selectors.buttons.pause),restart:Y.call(this,this.config.selectors.buttons.restart),rewind:Y.call(this,this.config.selectors.buttons.rewind),fastForward:Y.call(this,this.config.selectors.buttons.fastForward),mute:Y.call(this,this.config.selectors.buttons.mute),pip:Y.call(this,this.config.selectors.buttons.pip),airplay:Y.call(this,this.config.selectors.buttons.airplay),settings:Y.call(this,this.config.selectors.buttons.settings),captions:Y.call(this,this.config.selectors.buttons.captions),fullscreen:Y.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=Y.call(this,this.config.selectors.progress),this.elements.inputs={seek:Y.call(this,this.config.selectors.inputs.seek),volume:Y.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:Y.call(this,this.config.selectors.display.buffer),currentTime:Y.call(this,this.config.selectors.display.currentTime),duration:Y.call(this,this.config.selectors.display.duration)},x.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,t){const i="http://www.w3.org/2000/svg",s=xe.getIconUrl.call(this),n=`${s.cors?"":s.url}#${this.config.iconPrefix}`,a=document.createElementNS(i,"svg");j(a,O(t,{"aria-hidden":"true",focusable:"false"}));const r=document.createElementNS(i,"use"),o=`${n}-${e}`;return"href"in r&&r.setAttributeNS("http://www.w3.org/1999/xlink","href",o),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o),a.appendChild(r),a},createLabel(e,t={}){const i=Ee.get(e,this.config);return R("span",{...t,class:[t.class,this.config.classNames.hidden].filter(Boolean).join(" ")},i)},createBadge(e){if(x.empty(e))return null;const t=R("span",{class:this.config.classNames.menu.value});return t.appendChild(R("span",{class:this.config.classNames.menu.badge},e)),t},createButton(e,t){const i=O({},t);let s=ke(e);const n={element:"button",toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch(["element","icon","label"].forEach(e=>{Object.keys(i).includes(e)&&(n[e]=i[e],delete i[e])}),"button"!==n.element||Object.keys(i).includes("type")||(i.type="button"),Object.keys(i).includes("class")?i.class.split(" ").includes(this.config.classNames.control)||O(i,{class:`${i.class} ${this.config.classNames.control}`}):i.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":i.class+=` ${this.config.classNames.control}--overlaid`,s="play",n.label="play",n.icon="play";break;default:x.empty(n.label)&&(n.label=s),x.empty(n.icon)&&(n.icon=e)}const a=R(n.element);return n.toggle?(a.appendChild(xe.createIcon.call(this,n.iconPressed,{class:"icon--pressed"})),a.appendChild(xe.createIcon.call(this,n.icon,{class:"icon--not-pressed"})),a.appendChild(xe.createLabel.call(this,n.labelPressed,{class:"label--pressed"})),a.appendChild(xe.createLabel.call(this,n.label,{class:"label--not-pressed"}))):(a.appendChild(xe.createIcon.call(this,n.icon)),a.appendChild(xe.createLabel.call(this,n.label))),O(i,V(this.config.selectors.buttons[s],i)),j(a,i),"play"===s?(x.array(this.elements.buttons[s])||(this.elements.buttons[s]=[]),this.elements.buttons[s].push(a)):this.elements.buttons[s]=a,a},createRange(e,t){const i=R("input",O(V(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":Ee.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},t));return this.elements.inputs[e]=i,xe.updateRangeFill.call(this,i),w.setup(i),i},createProgress(e,t){const i=R("progress",O(V(this.config.selectors.display[e]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},t));if("volume"!==e){i.appendChild(R("span",null,"0"));const t={played:"played",buffer:"buffered"}[e],s=t?Ee.get(t,this.config):"";i.textContent=`% ${s.toLowerCase()}`}return this.elements.display[e]=i,i},createTime(e,t){const i=V(this.config.selectors.display[e],t),s=R("div",O(i,{class:`${i.class?i.class:""} ${this.config.classNames.display.time} `.trim(),"aria-label":Ee.get(e,this.config),role:"timer"}),"00:00");return this.elements.display[e]=s,s},bindMenuItemShortcuts(e,t){ee.call(this,e,"keydown keyup",i=>{if(![" ","ArrowUp","ArrowDown","ArrowRight"].includes(i.key))return;if(i.preventDefault(),i.stopPropagation(),"keydown"===i.type)return;const s=z(e,'[role="menuitemradio"]');if(!s&&[" ","ArrowRight"].includes(i.key))xe.showMenuPanel.call(this,t,!0);else{let t;" "!==i.key&&("ArrowDown"===i.key||s&&"ArrowRight"===i.key?(t=e.nextElementSibling,x.element(t)||(t=e.parentNode.firstElementChild)):(t=e.previousElementSibling,x.element(t)||(t=e.parentNode.lastElementChild)),X.call(this,t,!0))}},!1),ee.call(this,e,"keyup",e=>{"Return"===e.key&&xe.focusFirstMenuItem.call(this,null,!0)})},createMenuItem({value:e,list:t,type:i,title:s,badge:n=null,checked:a=!1}){const r=V(this.config.selectors.inputs[i]),o=R("button",O(r,{type:"button",role:"menuitemradio",class:`${this.config.classNames.control} ${r.class?r.class:""}`.trim(),"aria-checked":a,value:e})),l=R("span");l.innerHTML=s,x.element(n)&&l.appendChild(n),o.appendChild(l),Object.defineProperty(o,"checked",{enumerable:!0,get:()=>"true"===o.getAttribute("aria-checked"),set(e){e&&Array.from(o.parentNode.children).filter(e=>z(e,'[role="menuitemradio"]')).forEach(e=>e.setAttribute("aria-checked","false")),o.setAttribute("aria-checked",e?"true":"false")}}),this.listeners.bind(o,"click keyup",t=>{if(!x.keyboardEvent(t)||" "===t.key){switch(t.preventDefault(),t.stopPropagation(),o.checked=!0,i){case"language":this.currentTrack=Number(e);break;case"quality":this.quality=e;break;case"speed":this.speed=Number.parseFloat(e)}xe.showMenuPanel.call(this,"home",x.keyboardEvent(t))}},i,!1),xe.bindMenuItemShortcuts.call(this,o,i),t.appendChild(o)},formatTime(e=0,t=!1){if(!x.number(e))return e;return Ne(e,Me(this.duration)>0,t)},updateTimeDisplay(e=null,t=0,i=!1){x.element(e)&&x.number(t)&&(e.textContent=xe.formatTime(t,i))},updateVolume(){this.supported.ui&&(x.element(this.elements.inputs.volume)&&xe.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),x.element(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||0===this.volume))},setRange(e,t=0){x.element(e)&&(e.value=t,xe.updateRangeFill.call(this,e))},updateProgress(e){if(!this.supported.ui||!x.event(e))return;let t=0;const i=(e,t)=>{const i=x.number(t)?t:0,s=x.element(e)?e:this.elements.display.buffer;if(x.element(s)){s.value=i;const e=s.getElementsByTagName("span")[0];x.element(e)&&(e.childNodes[0].nodeValue=i)}};if(e)switch(e.type){case"timeupdate":case"seeking":case"seeked":s=this.currentTime,n=this.duration,t=0===s||0===n||Number.isNaN(s)||Number.isNaN(n)?0:(s/n*100).toFixed(2),"timeupdate"===e.type&&xe.setRange.call(this,this.elements.inputs.seek,t);break;case"playing":case"progress":i(this.elements.display.buffer,100*this.buffered)}var s,n},updateRangeFill(e){const t=x.event(e)?e.target:e;if(x.element(t)&&"range"===t.getAttribute("type")){if(z(t,this.config.selectors.inputs.seek)){t.setAttribute("aria-valuenow",this.currentTime);const e=xe.formatTime(this.currentTime),i=xe.formatTime(this.duration),s=Ee.get("seekLabel",this.config);t.setAttribute("aria-valuetext",s.replace("{currentTime}",e).replace("{duration}",i))}else if(z(t,this.config.selectors.inputs.volume)){const e=100*t.value;t.setAttribute("aria-valuenow",e),t.setAttribute("aria-valuetext",`${e.toFixed(1)}%`)}else t.setAttribute("aria-valuenow",t.value);(ye.isWebKit||ye.isIPadOS)&&t.style.setProperty("--value",t.value/t.max*100+"%")}},updateSeekTooltip(e){var t,i;if(!this.config.tooltips.seek||!x.element(this.elements.inputs.seek)||!x.element(this.elements.display.seekTooltip)||0===this.duration)return;const s=this.elements.display.seekTooltip,n=`${this.config.classNames.tooltip}--visible`,a=e=>B(s,n,e);if(this.touch)return void a(!1);let r=0;const o=this.elements.progress.getBoundingClientRect();if(x.event(e)){const t=e.pageX-e.clientX;r=100/o.width*(e.pageX-o.left-t)}else{if(!W(s,n))return;r=Number.parseFloat(s.style.left,10)}r<0?r=0:r>100&&(r=100);const l=this.duration/100*r;s.textContent=xe.formatTime(l);const c=null===(t=this.config.markers)||void 0===t||null===(i=t.points)||void 0===i?void 0:i.find(({time:e})=>e===Math.round(l));c&&s.insertAdjacentHTML("afterbegin",`${c.label}<br>`),s.style.left=`${r}%`,x.event(e)&&["mouseenter","mouseleave"].includes(e.type)&&a("mouseenter"===e.type)},timeUpdate(e){const t=!x.element(this.elements.display.duration)&&this.config.invertTime;xe.updateTimeDisplay.call(this,this.elements.display.currentTime,t?this.duration-this.currentTime:this.currentTime,t),e&&"timeupdate"===e.type&&this.media.seeking||xe.updateProgress.call(this,e)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32)return U(this.elements.display.currentTime,!0),void U(this.elements.progress,!0);x.element(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);const e=x.element(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&xe.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&xe.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),this.config.markers.enabled&&xe.setMarkers.call(this),xe.updateSeekTooltip.call(this)},toggleMenuButton(e,t){U(this.elements.settings.buttons[e],!t)},updateSetting(e,t,i){const s=this.elements.settings.panels[e];let n=null,a=t;if("captions"===e)n=this.currentTrack;else{if(n=x.empty(i)?this[e]:i,x.empty(n)&&(n=this.config[e].default),!x.empty(this.options[e])&&!this.options[e].includes(n))return void this.debug.warn(`Unsupported value of '${n}' for ${e}`);if(!this.config[e].options.includes(n))return void this.debug.warn(`Disabled value of '${n}' for ${e}`)}if(x.element(a)||(a=s&&s.querySelector('[role="menu"]')),!x.element(a))return;this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`).innerHTML=xe.getLabel.call(this,e,n);const r=a&&a.querySelector(`[value="${n}"]`);x.element(r)&&(r.checked=!0)},getLabel(e,t){switch(e){case"speed":return 1===t?Ee.get("normal",this.config):`${t}×`;case"quality":if(x.number(t)){const e=Ee.get(`qualityLabel.${t}`,this.config);return e.length?e:`${t}p`}return we(t);case"captions":return Ie.getLabel.call(this);default:return null}},setQualityMenu(e){if(!x.element(this.elements.settings.panels.quality))return;const t="quality",i=this.elements.settings.panels.quality.querySelector('[role="menu"]');x.array(e)&&(this.options.quality=oe(e).filter(e=>this.config.quality.options.includes(e)));const s=!x.empty(this.options.quality)&&this.options.quality.length>1;if(xe.toggleMenuButton.call(this,t,s),H(i),xe.checkMenu.call(this),!s)return;const n=e=>{const t=Ee.get(`qualityBadge.${e}`,this.config);return t.length?xe.createBadge.call(this,t):null};this.options.quality.sort((e,t)=>{const i=this.config.quality.options;return i.indexOf(e)>i.indexOf(t)?1:-1}).forEach(e=>{xe.createMenuItem.call(this,{value:e,list:i,type:t,title:xe.getLabel.call(this,"quality",e),badge:n(e)})}),xe.updateSetting.call(this,t,i)},setCaptionsMenu(){if(!x.element(this.elements.settings.panels.captions))return;const e="captions",t=this.elements.settings.panels.captions.querySelector('[role="menu"]'),i=Ie.getTracks.call(this),s=Boolean(i.length);if(xe.toggleMenuButton.call(this,e,s),H(t),xe.checkMenu.call(this),!s)return;const n=i.map((e,i)=>({value:i,checked:this.captions.toggled&&this.currentTrack===i,title:Ie.getLabel.call(this,e),badge:e.language&&xe.createBadge.call(this,e.language.toUpperCase()),list:t,type:"language"}));n.unshift({value:-1,checked:!this.captions.toggled,title:Ee.get("disabled",this.config),list:t,type:"language"}),n.forEach(xe.createMenuItem.bind(this)),xe.updateSetting.call(this,e,t)},setSpeedMenu(){if(!x.element(this.elements.settings.panels.speed))return;const e="speed",t=this.elements.settings.panels.speed.querySelector('[role="menu"]');this.options.speed=this.options.speed.filter(e=>e>=this.minimumSpeed&&e<=this.maximumSpeed);const i=!x.empty(this.options.speed)&&this.options.speed.length>1;xe.toggleMenuButton.call(this,e,i),H(t),xe.checkMenu.call(this),i&&(this.options.speed.forEach(i=>{xe.createMenuItem.call(this,{value:i,list:t,type:e,title:xe.getLabel.call(this,"speed",i)})}),xe.updateSetting.call(this,e,t))},checkMenu(){const{buttons:e}=this.elements.settings,t=!x.empty(e)&&Object.values(e).some(e=>!e.hidden);U(this.elements.settings.menu,!t)},focusFirstMenuItem(e,t=!1){if(this.elements.settings.popup.hidden)return;let i=e;x.element(i)||(i=Object.values(this.elements.settings.panels).find(e=>!e.hidden));const s=i.querySelector('[role^="menuitem"]');X.call(this,s,t)},toggleMenu(e){const{popup:t}=this.elements.settings,i=this.elements.buttons.settings;if(!x.element(t)||!x.element(i))return;const{hidden:s}=t;let n=s;if(x.boolean(e))n=e;else if(x.keyboardEvent(e)&&"Escape"===e.key)n=!1;else if(x.event(e)){const s=x.function(e.composedPath)?e.composedPath()[0]:e.target,a=t.contains(s);if(a||!a&&e.target!==i&&n)return}i.setAttribute("aria-expanded",n),U(t,!n),B(this.elements.container,this.config.classNames.menu.open,n),n&&x.keyboardEvent(e)?xe.focusFirstMenuItem.call(this,null,!0):n||s||X.call(this,i,x.keyboardEvent(e))},getMenuSize(e){const t=e.cloneNode(!0);t.style.position="absolute",t.style.opacity=0,t.removeAttribute("hidden"),e.parentNode.appendChild(t);const i=t.scrollWidth,s=t.scrollHeight;return q(t),{width:i,height:s}},showMenuPanel(e="",t=!1){const i=this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`);if(!x.element(i))return;const s=i.parentNode,n=Array.from(s.children).find(e=>!e.hidden);if(J.transitions&&!J.reducedMotion){s.style.width=`${n.scrollWidth}px`,s.style.height=`${n.scrollHeight}px`;const e=xe.getMenuSize.call(this,i),t=e=>{e.target===s&&["width","height"].includes(e.propertyName)&&(s.style.width="",s.style.height="",te.call(this,s,L,t))};ee.call(this,s,L,t),s.style.width=`${e.width}px`,s.style.height=`${e.height}px`}U(n,!0),U(i,!1),xe.focusFirstMenuItem.call(this,i,t)},setDownloadUrl(){const e=this.elements.buttons.download;x.element(e)&&e.setAttribute("href",this.download)},create(e){const{bindMenuItemShortcuts:t,createButton:i,createProgress:s,createRange:n,createTime:a,setQualityMenu:r,setSpeedMenu:o,showMenuPanel:l}=xe;this.elements.controls=null,x.array(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(i.call(this,"play-large"));const c=R("div",V(this.config.selectors.controls.wrapper));this.elements.controls=c;const u={class:"plyr__controls__item"};return oe(x.array(this.config.controls)?this.config.controls:[]).forEach(r=>{if("restart"===r&&c.appendChild(i.call(this,"restart",u)),"rewind"===r&&c.appendChild(i.call(this,"rewind",u)),"play"===r&&c.appendChild(i.call(this,"play",u)),"fast-forward"===r&&c.appendChild(i.call(this,"fast-forward",u)),"progress"===r){const t=R("div",{class:`${u.class} plyr__progress__container`}),i=R("div",V(this.config.selectors.progress));if(i.appendChild(n.call(this,"seek",{id:`plyr-seek-${e.id}`})),i.appendChild(s.call(this,"buffer")),this.config.tooltips.seek){const e=R("span",{class:this.config.classNames.tooltip},"00:00");i.appendChild(e),this.elements.display.seekTooltip=e}this.elements.progress=i,t.appendChild(this.elements.progress),c.appendChild(t)}if("current-time"===r&&c.appendChild(a.call(this,"currentTime",u)),"duration"===r&&c.appendChild(a.call(this,"duration",u)),"mute"===r||"volume"===r){let{volume:t}=this.elements;if(x.element(t)&&c.contains(t)||(t=R("div",O({},u,{class:`${u.class} plyr__volume`.trim()})),this.elements.volume=t,c.appendChild(t)),"mute"===r&&t.appendChild(i.call(this,"mute")),"volume"===r&&!ye.isIos&&!ye.isIPadOS){const i={max:1,step:.05,value:this.config.volume};t.appendChild(n.call(this,"volume",O(i,{id:`plyr-volume-${e.id}`})))}}if("captions"===r&&c.appendChild(i.call(this,"captions",u)),"settings"===r&&!x.empty(this.config.settings)){const s=R("div",O({},u,{class:`${u.class} plyr__menu`.trim(),hidden:""}));s.appendChild(i.call(this,"settings",{"aria-haspopup":!0,"aria-controls":`plyr-settings-${e.id}`,"aria-expanded":!1}));const n=R("div",{class:"plyr__menu__container",id:`plyr-settings-${e.id}`,hidden:""}),a=R("div"),r=R("div",{id:`plyr-settings-${e.id}-home`}),o=R("div",{role:"menu"});r.appendChild(o),a.appendChild(r),this.elements.settings.panels.home=r,this.config.settings.forEach(i=>{const s=R("button",O(V(this.config.selectors.buttons.settings),{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--forward`,role:"menuitem","aria-haspopup":!0,hidden:""}));t.call(this,s,i),ee.call(this,s,"click",()=>{l.call(this,i,!1)});const n=R("span",null,Ee.get(i,this.config)),r=R("span",{class:this.config.classNames.menu.value});r.innerHTML=e[i],n.appendChild(r),s.appendChild(n),o.appendChild(s);const c=R("div",{id:`plyr-settings-${e.id}-${i}`,hidden:""}),u=R("button",{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});u.appendChild(R("span",{"aria-hidden":!0},Ee.get(i,this.config))),u.appendChild(R("span",{class:this.config.classNames.hidden},Ee.get("menuBack",this.config))),ee.call(this,c,"keydown",e=>{"ArrowLeft"===e.key&&(e.preventDefault(),e.stopPropagation(),l.call(this,"home",!0))},!1),ee.call(this,u,"click",()=>{l.call(this,"home",!1)}),c.appendChild(u),c.appendChild(R("div",{role:"menu"})),a.appendChild(c),this.elements.settings.buttons[i]=s,this.elements.settings.panels[i]=c}),n.appendChild(a),s.appendChild(n),c.appendChild(s),this.elements.settings.popup=n,this.elements.settings.menu=s}if("pip"===r&&J.pip&&c.appendChild(i.call(this,"pip",u)),"airplay"===r&&J.airplay&&c.appendChild(i.call(this,"airplay",u)),"download"===r){const e=O({},u,{element:"a",href:this.download,target:"_blank"});this.isHTML5&&(e.download="");const{download:t}=this.config.urls;!x.url(t)&&this.isEmbed&&O(e,{icon:`logo-${this.provider}`,label:this.provider}),c.appendChild(i.call(this,"download",e))}"fullscreen"===r&&c.appendChild(i.call(this,"fullscreen",u))}),this.isHTML5&&r.call(this,fe.getQualityOptions.call(this)),o.call(this),c},inject(){if(this.config.loadSprite){const e=xe.getIconUrl.call(this);e.cors&&Pe(e.url,"sprite-plyr")}this.id=Math.floor(1e4*Math.random());let e=null;this.elements.controls=null;const t={id:this.id,seektime:this.config.seekTime,title:this.config.title};let i=!0;x.function(this.config.controls)&&(this.config.controls=this.config.controls.call(this,t)),this.config.controls||(this.config.controls=[]),x.element(this.config.controls)||x.string(this.config.controls)?e=this.config.controls:(e=xe.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:Ie.getLabel.call(this)}),i=!1);let s;i&&x.string(this.config.controls)&&(e=(e=>{let i=e;return Object.entries(t).forEach(([e,t])=>{i=ve(i,`{${e}}`,t)}),i})(e)),x.string(this.config.selectors.controls.container)&&(s=document.querySelector(this.config.selectors.controls.container)),x.element(s)||(s=this.elements.container);if(s[x.element(e)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",e),x.element(this.elements.controls)||xe.findElements.call(this),!x.empty(this.elements.buttons)){const e=e=>{const t=this.config.classNames.controlPressed;e.setAttribute("aria-pressed","false"),Object.defineProperty(e,"pressed",{configurable:!0,enumerable:!0,get:()=>W(e,t),set(i=!1){B(e,t,i),e.setAttribute("aria-pressed",i?"true":"false")}})};Object.values(this.elements.buttons).filter(Boolean).forEach(t=>{x.array(t)||x.nodeList(t)?Array.from(t).filter(Boolean).forEach(e):e(t)})}if(ye.isEdge&&_(s),this.config.tooltips.controls){const{classNames:e,selectors:t}=this.config,i=`${t.controls.wrapper} ${t.labels} .${e.hidden}`,s=K.call(this,i);Array.from(s).forEach(e=>{B(e,this.config.classNames.hidden,!1),B(e,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,t;if(!this.duration||this.elements.markers)return;const i=null===(e=this.config.markers)||void 0===e||null===(t=e.points)||void 0===t?void 0:t.filter(({time:e})=>e>0&&e<this.duration);if(null==i||!i.length)return;const s=document.createDocumentFragment(),n=document.createDocumentFragment();let a=null;const r=`${this.config.classNames.tooltip}--visible`,o=e=>B(a,r,e);i.forEach(e=>{const t=R("span",{class:this.config.classNames.marker},""),i=e.time/this.duration*100+"%";a&&(t.addEventListener("mouseenter",()=>{e.label||(a.style.left=i,a.innerHTML=e.label,o(!0))}),t.addEventListener("mouseleave",()=>{o(!1)})),t.addEventListener("click",()=>{this.currentTime=e.time}),t.style.left=i,n.appendChild(t)}),s.appendChild(n),this.config.tooltips.seek||(a=R("span",{class:this.config.classNames.tooltip},""),s.appendChild(a)),this.elements.markers={points:n,tip:a},this.elements.progress.appendChild(s)}};function Le(e,t=!0){let i=e;if(t){const e=document.createElement("a");e.href=i,i=e.href}try{return new URL(i)}catch{return null}}function _e(e){const t=new URLSearchParams;return x.object(e)&&Object.entries(e).forEach(([e,i])=>{t.set(e,i)}),t}const Ie={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!J.textTracks)return void(x.array(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&xe.setCaptionsMenu.call(this));var e,t;if(x.element(this.elements.captions)||(this.elements.captions=R("div",V(this.config.selectors.captions)),this.elements.captions.setAttribute("dir","auto"),e=this.elements.captions,t=this.elements.wrapper,x.element(e)&&x.element(t)&&t.parentNode.insertBefore(e,t.nextSibling)),ye.isIE&&window.URL){const e=this.media.querySelectorAll("track");Array.from(e).forEach(e=>{const t=e.getAttribute("src"),i=Le(t);null!==i&&i.hostname!==window.location.href.hostname&&["http:","https:"].includes(i.protocol)&&Ae(t,"blob").then(t=>{e.setAttribute("src",window.URL.createObjectURL(t))}).catch(()=>{q(e)})})}const i=oe((navigator.languages||[navigator.language||navigator.userLanguage||"en"]).map(e=>e.split("-")[0]));let s=(this.storage.get("language")||this.captions.language||this.config.captions.language||"auto").toLowerCase();"auto"===s&&([s]=i);let n=this.storage.get("captions")||this.captions.active;if(x.boolean(n)||({active:n}=this.config.captions),Object.assign(this.captions,{toggled:!1,active:n,language:s,languages:i}),this.isHTML5){const e=this.config.captions.update?"addtrack removetrack":"removetrack";ee.call(this,this.media.textTracks,e,Ie.update.bind(this))}setTimeout(Ie.update.bind(this),0)},update(){const e=Ie.getTracks.call(this,!0),{active:t,language:i,meta:s,currentTrackNode:n}=this.captions,a=Boolean(e.find(e=>e.language===i));this.isHTML5&&this.isVideo&&e.filter(e=>!s.get(e)).forEach(e=>{this.debug.log("Track added",e),s.set(e,{default:"showing"===e.mode}),"showing"===e.mode&&(e.mode="hidden"),ee.call(this,e,"cuechange",()=>Ie.updateCues.call(this))}),(a&&this.language!==i||!e.includes(n))&&(Ie.setLanguage.call(this,i),Ie.toggle.call(this,t&&a)),this.elements&&B(this.elements.container,this.config.classNames.captions.enabled,!x.empty(e)),x.array(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&xe.setCaptionsMenu.call(this)},toggle(e,t=!0){if(!this.supported.ui)return;const{toggled:i}=this.captions,s=this.config.classNames.captions.active,n=x.nullOrUndefined(e)?!i:e;if(n!==i){if(t||(this.captions.active=n,this.storage.set({captions:n})),!this.language&&n&&!t){const e=Ie.getTracks.call(this),t=Ie.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);return this.captions.language=t.language,void Ie.set.call(this,e.indexOf(t))}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=n),B(this.elements.container,s,n),this.captions.toggled=n,xe.updateSetting.call(this,"captions"),se.call(this,this.media,n?"captionsenabled":"captionsdisabled")}setTimeout(()=>{n&&this.captions.toggled&&(this.captions.currentTrackNode.mode="hidden")})},set(e,t=!0){const i=Ie.getTracks.call(this);if(-1!==e)if(x.number(e))if(e in i){if(this.captions.currentTrack!==e){this.captions.currentTrack=e;const s=i[e],{language:n}=s||{};this.captions.currentTrackNode=s,xe.updateSetting.call(this,"captions"),t||(this.captions.language=n,this.storage.set({language:n})),this.isVimeo&&this.embed.enableTextTrack(n),se.call(this,this.media,"languagechange")}Ie.toggle.call(this,!0,t),this.isHTML5&&this.isVideo&&Ie.updateCues.call(this)}else this.debug.warn("Track not found",e);else this.debug.warn("Invalid caption argument",e);else Ie.toggle.call(this,!1,t)},setLanguage(e,t=!0){if(!x.string(e))return void this.debug.warn("Invalid language argument",e);const i=e.toLowerCase();this.captions.language=i;const s=Ie.getTracks.call(this),n=Ie.findTrack.call(this,[i]);Ie.set.call(this,s.indexOf(n),t)},getTracks(e=!1){return Array.from((this.media||{}).textTracks||[]).filter(t=>!this.isHTML5||e||this.captions.meta.has(t)).filter(e=>["captions","subtitles"].includes(e.kind))},findTrack(e,t=!1){const i=Ie.getTracks.call(this),s=e=>Number((this.captions.meta.get(e)||{}).default),n=Array.from(i).sort((e,t)=>s(t)-s(e));let a;return e.every(e=>(a=n.find(t=>t.language===e),!a)),a||(t?n[0]:void 0)},getCurrentTrack(){return Ie.getTracks.call(this)[this.currentTrack]},getLabel(e){let t=e;return!x.track(t)&&J.textTracks&&this.captions.toggled&&(t=Ie.getCurrentTrack.call(this)),x.track(t)?x.empty(t.label)?x.empty(t.language)?Ee.get("enabled",this.config):e.language.toUpperCase():t.label:Ee.get("disabled",this.config)},updateCues(e){if(!this.supported.ui)return;if(!x.element(this.elements.captions))return void this.debug.warn("No captions element to render to");if(!x.nullOrUndefined(e)&&!Array.isArray(e))return void this.debug.warn("updateCues: Invalid input",e);let t=e;if(!t){const e=Ie.getCurrentTrack.call(this);t=Array.from((e||{}).activeCues||[]).map(e=>e.getCueAsHTML()).map(Te)}const i=t.map(e=>e.trim()).join("\n");if(i!==this.elements.captions.innerHTML){H(this.elements.captions);const e=R("span",V(this.config.selectors.caption));e.innerHTML=i,this.elements.captions.appendChild(e),se.call(this,this.media,"cuechange")}}},Oe={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.3/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:{enabled:"plyr--captions-enabled",active:"plyr--captions-active"},fullscreen:{enabled:"plyr--fullscreen-enabled",fallback:"plyr--fullscreen-fallback"},pip:{supported:"plyr--pip-supported",active:"plyr--pip-active"},airplay:{supported:"plyr--airplay-supported",active:"plyr--airplay-active"},previewThumbnails:{thumbContainer:"plyr__preview-thumb",thumbContainerShown:"plyr__preview-thumb--is-shown",imageContainer:"plyr__preview-thumb__image-container",timeContainer:"plyr__preview-thumb__time-container",scrubbingContainer:"plyr__preview-scrubbing",scrubbingContainerShown:"plyr__preview-scrubbing--is-shown"}},attributes:{embed:{provider:"data-plyr-provider",id:"data-plyr-embed-id",hash:"data-plyr-embed-hash"}},ads:{enabled:!1,publisherId:"",tagUrl:""},previewThumbnails:{enabled:!1,src:"",withCredentials:!1},vimeo:{byline:!1,portrait:!1,title:!1,speed:!0,transparent:!1,customControls:!0,referrerPolicy:null,premium:!1},youtube:{rel:0,showinfo:0,iv_load_policy:3,modestbranding:1,cu