2 lines
110 KiB
JavaScript
2 lines
110 KiB
JavaScript
import{A as e,B as t,D as n,_ as r,g as i,x as a}from"./index-DqPZBT3C.js";function o(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return typeof t==`symbol`?t:t+``}function l(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function d(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?p(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var h={addCSS:!0,thumbWidth:15,watch:!0};function ee(e,t){return function(){return Array.from(document.querySelectorAll(t)).includes(this)}.call(e,t)}function te(e,t){if(e&&t){var n=new Event(t,{bubbles:!0});e.dispatchEvent(n)}}var g=function(e){return e==null?null:e.constructor},ne=function(e,t){return!!(e&&t&&e instanceof t)},re=function(e){return e==null},ie=function(e){return g(e)===Object},ae=function(e){return g(e)===Number&&!Number.isNaN(e)},oe=function(e){return g(e)===String},se=function(e){return g(e)===Boolean},ce=function(e){return g(e)===Function},le=function(e){return Array.isArray(e)},ue=function(e){return ne(e,NodeList)},_={nullOrUndefined:re,object:ie,number:ae,string:oe,boolean:se,function:ce,array:le,nodeList:ue,element:function(e){return ne(e,Element)},event:function(e){return ne(e,Event)},empty:function(e){return re(e)||(oe(e)||le(e)||ue(e))&&!e.length||ie(e)&&!Object.keys(e).length}};function de(e){var t=`${e}`.match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0}function fe(e,t){if(1>t){var n=de(t);return parseFloat(e.toFixed(n))}return Math.round(e/t)*t}var pe=function(){function e(t,n){l(this,e),_.element(t)?this.element=t:_.string(t)&&(this.element=document.querySelector(t)),_.element(this.element)&&_.empty(this.element.rangeTouch)&&(this.config=m({},h,{},n),this.init())}return d(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,n=e?`addEventListener`:`removeEventListener`;[`touchstart`,`touchmove`,`touchend`].forEach(function(e){t.element[n](e,function(e){return t.set(e)},!1)})}},{key:`get`,value:function(t){if(!e.enabled||!_.event(t))return null;var n,r=t.target,i=t.changedTouches[0],a=parseFloat(r.getAttribute(`min`))||0,o=parseFloat(r.getAttribute(`max`))||100,s=parseFloat(r.getAttribute(`step`))||1,c=r.getBoundingClientRect(),l=100/c.width*(this.config.thumbWidth/2)/100;return 0>(n=100/c.width*(i.clientX-c.left))?n=0:100<n&&(n=100),50>n?n-=(100-2*n)*l:50<n&&(n+=2*(n-50)*l),a+fe(n/100*(o-a),s)}},{key:`set`,value:function(t){e.enabled&&_.event(t)&&!t.target.disabled&&(t.preventDefault(),t.target.value=this.get(t),te(t.target,t.type===`touchend`?`change`:`input`))}}],[{key:`setup`,value:function(t){var n=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},r=null;if(_.empty(t)||_.string(t)?r=Array.from(document.querySelectorAll(_.string(t)?t:`input[type="range"]`)):_.element(t)?r=[t]:_.nodeList(t)?r=Array.from(t):_.array(t)&&(r=t.filter(_.element)),_.empty(r))return null;var i=m({},h,{},n);return _.string(t)&&i.watch&&new MutationObserver(function(n){Array.from(n).forEach(function(n){Array.from(n.addedNodes).forEach(function(n){_.element(n)&&ee(n,t)&&new e(n,i)})})}).observe(document.body,{childList:!0,subtree:!0}),r.map(function(t){return new e(t,n)})}},{key:`enabled`,get:function(){return`ontouchstart`in document.documentElement}}]),e}(),v=e=>e==null?null:e.constructor,y=(e,t)=>!!(e&&t&&e instanceof t),me=e=>e==null,he=e=>v(e)===Object,ge=e=>v(e)===Number&&!Number.isNaN(e),b=e=>v(e)===String,_e=e=>v(e)===Boolean,ve=e=>typeof e==`function`,ye=e=>Array.isArray(e),be=e=>y(e,WeakMap),xe=e=>y(e,NodeList),Se=e=>v(e)===Text,Ce=e=>y(e,Event),we=e=>y(e,KeyboardEvent),Te=e=>y(e,window.TextTrackCue)||y(e,window.VTTCue),Ee=e=>y(e,TextTrack)||!me(e)&&b(e.kind),De=e=>y(e,Promise)&&ve(e.then);function Oe(e){return typeof e==`object`&&!!e&&e.nodeType===1&&typeof e.style==`object`&&typeof e.ownerDocument==`object`}function ke(e){return me(e)||(b(e)||ye(e)||xe(e))&&!e.length||he(e)&&!Object.keys(e).length}function Ae(e){if(y(e,window.URL))return!0;if(!b(e))return!1;let t=e;(!e.startsWith(`http://`)||!e.startsWith(`https://`))&&(t=`http://${e}`);try{return!ke(new URL(t).hostname)}catch{return!1}}var x={nullOrUndefined:me,object:he,number:ge,string:b,boolean:_e,function:ve,array:ye,weakMap:be,nodeList:xe,element:Oe,textNode:Se,event:Ce,keyboardEvent:we,cue:Te,track:Ee,promise:De,url:Ae,empty:ke},je=(()=>{let e=document.createElement(`span`),t={WebkitTransition:`webkitTransitionEnd`,MozTransition:`transitionend`,OTransition:`oTransitionEnd otransitionend`,transition:`transitionend`},n=Object.keys(t).find(t=>e.style[t]!==void 0);return x.string(n)?t[n]:!1})();function Me(e,t){setTimeout(()=>{try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch{}},t)}function Ne(e){return JSON.parse(JSON.stringify(e))}function Pe(e,t){return t.split(`.`).reduce((e,t)=>e&&e[t],e)}function S(e={},...t){if(!t.length)return e;let n=t.shift();return x.object(n)?(Object.keys(n).forEach(t=>{x.object(n[t])?(Object.keys(e).includes(t)||Object.assign(e,{[t]:{}}),S(e[t],n[t])):Object.assign(e,{[t]:n[t]})}),S(e,...t)):e}function Fe(e,t){let n=e.length?e:[e];Array.from(n).reverse().forEach((e,n)=>{let r=n>0?t.cloneNode(!0):t,i=e.parentNode,a=e.nextSibling;r.appendChild(e),a?i.insertBefore(r,a):i.appendChild(r)})}function Ie(e,t){!x.element(e)||x.empty(t)||Object.entries(t).filter(([,e])=>!x.nullOrUndefined(e)).forEach(([t,n])=>e.setAttribute(t,n))}function C(e,t,n){let r=document.createElement(e);return x.object(t)&&Ie(r,t),x.string(n)&&(r.textContent=n),r}function Le(e,t){!x.element(e)||!x.element(t)||t.parentNode.insertBefore(e,t.nextSibling)}function Re(e,t,n,r){x.element(t)&&t.appendChild(C(e,n,r))}function w(e){if(x.nodeList(e)||x.array(e)){Array.from(e).forEach(w);return}!x.element(e)||!x.element(e.parentNode)||e.parentNode.removeChild(e)}function T(e){if(!x.element(e))return;let{length:t}=e.childNodes;for(;t>0;)e.removeChild(e.lastChild),--t}function E(e,t){return!x.element(t)||!x.element(t.parentNode)||!x.element(e)?null:(t.parentNode.replaceChild(e,t),e)}function D(e,t){if(!x.string(e)||x.empty(e))return{};let n={},r=S({},t);return e.split(`,`).forEach(e=>{let t=e.trim(),i=t.replace(`.`,``),a=t.replace(/[[\]]/g,``).split(`=`),[o]=a,s=a.length>1?a[1].replace(/["']/g,``):``;switch(t.charAt(0)){case`.`:x.string(r.class)?n.class=`${r.class} ${i}`:n.class=i;break;case`#`:n.id=t.replace(`#`,``);break;case`[`:n[o]=s;break}}),S(r,n)}function O(e,t){if(!x.element(e))return;let n=t;x.boolean(n)||(n=!e.hidden),e.hidden=n}function k(e,t,n){if(x.nodeList(e))return Array.from(e).map(e=>k(e,t,n));if(x.element(e)){let r=`toggle`;return n!==void 0&&(r=n?`add`:`remove`),e.classList[r](t),e.classList.contains(t)}return!1}function ze(e,t){return x.element(e)&&e.classList.contains(t)}function A(e,t){let{prototype:n}=Element;function r(){return Array.from(document.querySelectorAll(t)).includes(this)}return(n.matches||n.webkitMatchesSelector||n.mozMatchesSelector||n.msMatchesSelector||r).call(e,t)}function Be(e,t){let{prototype:n}=Element;function r(){let e=this;do{if(A.matches(e,t))return e;e=e.parentElement||e.parentNode}while(e!==null&&e.nodeType===1);return null}return(n.closest||r).call(e,t)}function j(e){return this.elements.container.querySelectorAll(e)}function M(e){return this.elements.container.querySelector(e)}function Ve(e=null,t=!1){x.element(e)&&e.focus({preventScroll:!0,focusVisible:t})}var He={"audio/ogg":`vorbis`,"audio/wav":`1`,"video/webm":`vp8, vorbis`,"video/mp4":`avc1.42E01E, mp4a.40.2`,"video/ogg":`theora`},N={audio:`canPlayType`in document.createElement(`audio`),video:`canPlayType`in document.createElement(`video`),check(e,t){let n=N[e]||t!==`html5`;return{api:n,ui:n&&N.rangeInput}},pip:document.pictureInPictureEnabled&&!C(`video`).disablePictureInPicture,airplay:x.function(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:`playsInline`in document.createElement(`video`),mime(e){if(x.empty(e))return!1;let[t]=e.split(`/`),n=e;if(!this.isHTML5||t!==this.type)return!1;Object.keys(He).includes(n)&&(n+=`; codecs="${He[e]}"`);try{return!!(n&&this.media.canPlayType(n).replace(/no/,``))}catch{return!1}},textTracks:`textTracks`in document.createElement(`video`),rangeInput:(()=>{let e=document.createElement(`input`);return e.type=`range`,e.type===`range`})(),touch:`ontouchstart`in document.documentElement,transitions:je!==!1,reducedMotion:`matchMedia`in window&&window.matchMedia(`(prefers-reduced-motion)`).matches},Ue=(()=>{let e=!1;try{let t=Object.defineProperty({},`passive`,{get(){return e=!0,null}});window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t)}catch{}return e})();function P(e,t,n,r=!1,i=!0,a=!1){if(!e||!(`addEventListener`in e)||x.empty(t)||!x.function(n))return;let o=t.split(` `),s=a;Ue&&(s={passive:i,capture:a}),o.forEach(t=>{this&&this.eventListeners&&r&&this.eventListeners.push({element:e,type:t,callback:n,options:s}),e[r?`addEventListener`:`removeEventListener`](t,n,s)})}function F(e,t=``,n,r=!0,i=!1){P.call(this,e,t,n,!0,r,i)}function I(e,t=``,n,r=!0,i=!1){P.call(this,e,t,n,!1,r,i)}function We(e,t=``,n,r=!0,i=!1){let a=(...o)=>{I(e,t,a,r,i),n.apply(this,o)};P.call(this,e,t,a,!0,r,i)}function L(e,t=``,n=!1,r={}){if(!x.element(e)||x.empty(t))return;let i=new CustomEvent(t,{bubbles:n,detail:{...r,plyr:this}});e.dispatchEvent(i)}function Ge(){this&&this.eventListeners&&(this.eventListeners.forEach(e=>{let{element:t,type:n,callback:r,options:i}=e;t.removeEventListener(n,r,i)}),this.eventListeners=[])}function Ke(){return new Promise(e=>this.ready?setTimeout(e,0):F.call(this,this.elements.container,`ready`,e)).then(()=>{})}function R(e){x.promise(e)&&e.then(null,()=>{})}function qe(e){return x.array(e)?e.filter((t,n)=>e.indexOf(t)===n):e}function Je(e,t){return!x.array(e)||!e.length?null:e.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)}function Ye(e){return!window||!window.CSS?!1:window.CSS.supports(e)}var Xe=[[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,n])=>({...e,[t/n]:[t,n]}),{});function Ze(e){return!x.array(e)&&(!x.string(e)||!e.includes(`:`))?!1:(x.array(e)?e:e.split(`:`)).map(Number).every(x.number)}function z(e){if(!x.array(e)||!e.every(x.number))return null;let[t,n]=e,r=(e,t)=>t===0?e:r(t,e%t),i=r(t,n);return[t/i,n/i]}function Qe(e){let t=e=>Ze(e)?e.split(`:`).map(Number):null,n=t(e);if(n===null&&(n=t(this.config.ratio)),n===null&&!x.empty(this.embed)&&x.array(this.embed.ratio)&&({ratio:n}=this.embed),n===null&&this.isHTML5){let{videoWidth:e,videoHeight:t}=this.media;n=[e,t]}return z(n)}function B(e){if(!this.isVideo)return{};let{wrapper:t}=this.elements,n=Qe.call(this,e);if(!x.array(n))return{};let[r,i]=z(n),a=Ye(`aspect-ratio: ${r}/${i}`),o=100/r*i;if(a?t.style.aspectRatio=`${r}/${i}`:t.style.paddingBottom=`${o}%`,this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){let e=100/this.media.offsetWidth*Number.parseInt(window.getComputedStyle(this.media).paddingBottom,10),n=(e-o)/(e/50);this.fullscreen.active?t.style.paddingBottom=null:this.media.style.transform=`translateY(-${n}%)`}else this.isHTML5&&t.classList.add(this.config.classNames.videoFixedRatio);return{padding:o,ratio:n}}function $e(e,t,n=.05){let r=e/t,i=Je(Object.keys(Xe),r);return Math.abs(i-r)<=n?Xe[i]:[e,t]}function et(){return[Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)]}var V={getSources(){return this.isHTML5?Array.from(this.media.querySelectorAll(`source`)).filter(e=>{let t=e.getAttribute(`type`);return x.empty(t)?!0:N.mime.call(this,t)}):[]},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:V.getSources.call(this).map(e=>Number(e.getAttribute(`size`))).filter(Boolean)},setup(){if(!this.isHTML5)return;let e=this;e.options.speed=e.config.speed.options,x.empty(this.config.ratio)||B.call(e),Object.defineProperty(e.media,`quality`,{get(){let t=V.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{let n=V.getSources.call(e).find(e=>Number(e.getAttribute(`size`))===t);if(!n)return;let{currentTime:r,paused:i,preload:a,readyState:o,playbackRate:s}=e.media;e.media.src=n.getAttribute(`src`),(a!==`none`||o)&&(e.once(`loadedmetadata`,()=>{e.speed=s,e.currentTime=r,i||R(e.play())}),e.media.load())}L.call(e,e.media,`qualitychange`,!1,{quality:t})}}})},cancelRequests(){this.isHTML5&&(w(V.getSources.call(this)),this.media.setAttribute(`src`,this.config.blankVideo),this.media.load(),this.debug.log(`Cancelled network requests`))}},H={isIE:!!window.document.documentMode,isEdge:/Edge/.test(navigator.userAgent),isWebKit:`WebkitAppearance`in document.documentElement.style&&!/Edge/.test(navigator.userAgent),isIPadOS:navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,isIos:/iPad|iPhone|iPod/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1};function tt(e){return`${e}-${Math.floor(Math.random()*1e4)}`}function nt(e,...t){return x.empty(e)?e:e.toString().replace(/\{(\d+)\}/g,(e,n)=>t[n].toString())}function rt(e,t){return e===0||t===0||Number.isNaN(e)||Number.isNaN(t)?0:(e/t*100).toFixed(2)}function U(e=``,t=``,n=``){return e.replace(new RegExp(t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,`\\$1`),`g`),n.toString())}function it(e=``){return e.toString().replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function at(e=``){let t=e.toString();return t=U(t,`-`,` `),t=U(t,`_`,` `),t=it(t),U(t,` `,``)}function ot(e=``){let t=e.toString();return t=at(t),t.charAt(0).toLowerCase()+t.slice(1)}function st(e){let t=document.createDocumentFragment(),n=document.createElement(`div`);return t.appendChild(n),n.innerHTML=e,t.firstChild.textContent}function ct(e){let t=document.createElement(`div`);return t.appendChild(e),t.innerHTML}var lt={pip:`PIP`,airplay:`AirPlay`,html5:`HTML5`,vimeo:`Vimeo`,youtube:`YouTube`},W={get(e=``,t={}){if(x.empty(e)||x.empty(t))return``;let n=Pe(t.i18n,e);if(x.empty(n))return Object.keys(lt).includes(e)?lt[e]:``;let r={"{seektime}":t.seekTime,"{title}":t.title};return Object.entries(r).forEach(([e,t])=>{n=U(n,e,t)}),n}},ut=class e{constructor(t){o(this,`get`,t=>{if(!e.supported||!this.enabled)return null;let n=window.localStorage.getItem(this.key);if(x.empty(n))return null;let r=JSON.parse(n);return x.string(t)&&t.length?r[t]:r}),o(this,`set`,t=>{if(!e.supported||!this.enabled||!x.object(t))return;let n=this.get();x.empty(n)&&(n={}),S(n,t);try{window.localStorage.setItem(this.key,JSON.stringify(n))}catch{}}),this.enabled=t.config.storage.enabled,this.key=t.config.storage.key}static get supported(){try{if(!(`localStorage`in window))return!1;let e=`___test`;return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}};function G(e,t=`text`,n=!1){return new Promise((r,i)=>{try{let i=new XMLHttpRequest;if(!(`withCredentials`in i))return;n&&(i.withCredentials=!0),i.addEventListener(`load`,()=>{if(t===`text`)try{r(JSON.parse(i.responseText))}catch{r(i.responseText)}else r(i.response)}),i.addEventListener(`error`,()=>{throw Error(i.status)}),i.open(`GET`,e,!0),i.responseType=t,i.send()}catch(e){i(e)}})}function dt(e,t){if(!x.string(e))return;let n=`cache`,r=x.string(t),i=!1,a=()=>document.getElementById(t)!==null,o=(e,t)=>{e.innerHTML=t,!(r&&a())&&document.body.insertAdjacentElement(`afterbegin`,e)};if(!r||!a()){let a=ut.supported,s=document.createElement(`div`);if(s.setAttribute(`hidden`,``),r&&s.setAttribute(`id`,t),a){let e=window.localStorage.getItem(`${n}-${t}`);i=e!==null,i&&o(s,JSON.parse(e).content)}G(e).then(e=>{if(!x.empty(e)){if(a)try{window.localStorage.setItem(`${n}-${t}`,JSON.stringify({content:e}))}catch{}o(s,e)}}).catch(()=>{})}}var ft=e=>Math.trunc(e/60/60%60,10),pt=e=>Math.trunc(e/60%60,10),mt=e=>Math.trunc(e%60,10);function K(e=0,t=!1,n=!1){if(!x.number(e))return K(void 0,t,n);let r=e=>`0${e}`.slice(-2),i=ft(e),a=pt(e),o=mt(e);return i=t||i>0?`${i}:`:``,`${n&&e>0?`-`:``}${i}${r(a)}:${r(o)}`}var q={getIconUrl(){let e=new URL(this.config.iconUrl,window.location),t=window.location.host?window.location.host:window.top.location.host,n=e.host!==t||H.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:n}},findElements(){try{return this.elements.controls=M.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:j.call(this,this.config.selectors.buttons.play),pause:M.call(this,this.config.selectors.buttons.pause),restart:M.call(this,this.config.selectors.buttons.restart),rewind:M.call(this,this.config.selectors.buttons.rewind),fastForward:M.call(this,this.config.selectors.buttons.fastForward),mute:M.call(this,this.config.selectors.buttons.mute),pip:M.call(this,this.config.selectors.buttons.pip),airplay:M.call(this,this.config.selectors.buttons.airplay),settings:M.call(this,this.config.selectors.buttons.settings),captions:M.call(this,this.config.selectors.buttons.captions),fullscreen:M.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=M.call(this,this.config.selectors.progress),this.elements.inputs={seek:M.call(this,this.config.selectors.inputs.seek),volume:M.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:M.call(this,this.config.selectors.display.buffer),currentTime:M.call(this,this.config.selectors.display.currentTime),duration:M.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){let n=`http://www.w3.org/2000/svg`,r=q.getIconUrl.call(this),i=`${r.cors?``:r.url}#${this.config.iconPrefix}`,a=document.createElementNS(n,`svg`);Ie(a,S(t,{"aria-hidden":`true`,focusable:`false`}));let o=document.createElementNS(n,`use`),s=`${i}-${e}`;return`href`in o&&o.setAttributeNS(`http://www.w3.org/1999/xlink`,`href`,s),o.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,s),a.appendChild(o),a},createLabel(e,t={}){let n=W.get(e,this.config);return C(`span`,{...t,class:[t.class,this.config.classNames.hidden].filter(Boolean).join(` `)},n)},createBadge(e){if(x.empty(e))return null;let t=C(`span`,{class:this.config.classNames.menu.value});return t.appendChild(C(`span`,{class:this.config.classNames.menu.badge},e)),t},createButton(e,t){let n=S({},t),r=ot(e),i={element:`button`,toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch([`element`,`icon`,`label`].forEach(e=>{Object.keys(n).includes(e)&&(i[e]=n[e],delete n[e])}),i.element===`button`&&!Object.keys(n).includes(`type`)&&(n.type=`button`),Object.keys(n).includes(`class`)?n.class.split(` `).includes(this.config.classNames.control)||S(n,{class:`${n.class} ${this.config.classNames.control}`}):n.class=this.config.classNames.control,e){case`play`:i.toggle=!0,i.label=`play`,i.labelPressed=`pause`,i.icon=`play`,i.iconPressed=`pause`;break;case`mute`:i.toggle=!0,i.label=`mute`,i.labelPressed=`unmute`,i.icon=`volume`,i.iconPressed=`muted`;break;case`captions`:i.toggle=!0,i.label=`enableCaptions`,i.labelPressed=`disableCaptions`,i.icon=`captions-off`,i.iconPressed=`captions-on`;break;case`fullscreen`:i.toggle=!0,i.label=`enterFullscreen`,i.labelPressed=`exitFullscreen`,i.icon=`enter-fullscreen`,i.iconPressed=`exit-fullscreen`;break;case`play-large`:n.class+=` ${this.config.classNames.control}--overlaid`,r=`play`,i.label=`play`,i.icon=`play`;break;default:x.empty(i.label)&&(i.label=r),x.empty(i.icon)&&(i.icon=e)}let a=C(i.element);return i.toggle?(a.appendChild(q.createIcon.call(this,i.iconPressed,{class:`icon--pressed`})),a.appendChild(q.createIcon.call(this,i.icon,{class:`icon--not-pressed`})),a.appendChild(q.createLabel.call(this,i.labelPressed,{class:`label--pressed`})),a.appendChild(q.createLabel.call(this,i.label,{class:`label--not-pressed`}))):(a.appendChild(q.createIcon.call(this,i.icon)),a.appendChild(q.createLabel.call(this,i.label))),S(n,D(this.config.selectors.buttons[r],n)),Ie(a,n),r===`play`?(x.array(this.elements.buttons[r])||(this.elements.buttons[r]=[]),this.elements.buttons[r].push(a)):this.elements.buttons[r]=a,a},createRange(e,t){let n=C(`input`,S(D(this.config.selectors.inputs[e]),{type:`range`,min:0,max:100,step:.01,value:0,autocomplete:`off`,role:`slider`,"aria-label":W.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},t));return this.elements.inputs[e]=n,q.updateRangeFill.call(this,n),pe.setup(n),n},createProgress(e,t){let n=C(`progress`,S(D(this.config.selectors.display[e]),{min:0,max:100,value:0,role:`progressbar`,"aria-hidden":!0},t));if(e!==`volume`){n.appendChild(C(`span`,null,`0`));let t={played:`played`,buffer:`buffered`}[e];n.textContent=`% ${(t?W.get(t,this.config):``).toLowerCase()}`}return this.elements.display[e]=n,n},createTime(e,t){let n=D(this.config.selectors.display[e],t),r=C(`div`,S(n,{class:`${n.class?n.class:``} ${this.config.classNames.display.time} `.trim(),"aria-label":W.get(e,this.config),role:`timer`}),`00:00`);return this.elements.display[e]=r,r},bindMenuItemShortcuts(e,t){F.call(this,e,`keydown keyup`,n=>{if(![` `,`ArrowUp`,`ArrowDown`,`ArrowRight`].includes(n.key)||(n.preventDefault(),n.stopPropagation(),n.type===`keydown`))return;let r=A(e,`[role="menuitemradio"]`);if(!r&&[` `,`ArrowRight`].includes(n.key))q.showMenuPanel.call(this,t,!0);else{let t;n.key!==` `&&(n.key===`ArrowDown`||r&&n.key===`ArrowRight`?(t=e.nextElementSibling,x.element(t)||(t=e.parentNode.firstElementChild)):(t=e.previousElementSibling,x.element(t)||(t=e.parentNode.lastElementChild)),Ve.call(this,t,!0))}},!1),F.call(this,e,`keyup`,e=>{e.key===`Return`&&q.focusFirstMenuItem.call(this,null,!0)})},createMenuItem({value:e,list:t,type:n,title:r,badge:i=null,checked:a=!1}){let o=D(this.config.selectors.inputs[n]),s=C(`button`,S(o,{type:`button`,role:`menuitemradio`,class:`${this.config.classNames.control} ${o.class?o.class:``}`.trim(),"aria-checked":a,value:e})),c=C(`span`);c.innerHTML=r,x.element(i)&&c.appendChild(i),s.appendChild(c),Object.defineProperty(s,`checked`,{enumerable:!0,get(){return s.getAttribute(`aria-checked`)===`true`},set(e){e&&Array.from(s.parentNode.children).filter(e=>A(e,`[role="menuitemradio"]`)).forEach(e=>e.setAttribute(`aria-checked`,`false`)),s.setAttribute(`aria-checked`,e?`true`:`false`)}}),this.listeners.bind(s,`click keyup`,t=>{if(!(x.keyboardEvent(t)&&t.key!==` `)){switch(t.preventDefault(),t.stopPropagation(),s.checked=!0,n){case`language`:this.currentTrack=Number(e);break;case`quality`:this.quality=e;break;case`speed`:this.speed=Number.parseFloat(e);break}q.showMenuPanel.call(this,`home`,x.keyboardEvent(t))}},n,!1),q.bindMenuItemShortcuts.call(this,s,n),t.appendChild(s)},formatTime(e=0,t=!1){return x.number(e)?K(e,ft(this.duration)>0,t):e},updateTimeDisplay(e=null,t=0,n=!1){!x.element(e)||!x.number(t)||(e.textContent=q.formatTime(t,n))},updateVolume(){this.supported.ui&&(x.element(this.elements.inputs.volume)&&q.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||this.volume===0))},setRange(e,t=0){x.element(e)&&(e.value=t,q.updateRangeFill.call(this,e))},updateProgress(e){if(!this.supported.ui||!x.event(e))return;let t=0,n=(e,t)=>{let n=x.number(t)?t:0,r=x.element(e)?e:this.elements.display.buffer;if(x.element(r)){r.value=n;let e=r.getElementsByTagName(`span`)[0];x.element(e)&&(e.childNodes[0].nodeValue=n)}};if(e)switch(e.type){case`timeupdate`:case`seeking`:case`seeked`:t=rt(this.currentTime,this.duration),e.type===`timeupdate`&&q.setRange.call(this,this.elements.inputs.seek,t);break;case`playing`:case`progress`:n(this.elements.display.buffer,this.buffered*100);break}},updateRangeFill(e){let t=x.event(e)?e.target:e;if(!(!x.element(t)||t.getAttribute(`type`)!==`range`)){if(A(t,this.config.selectors.inputs.seek)){t.setAttribute(`aria-valuenow`,this.currentTime);let e=q.formatTime(this.currentTime),n=q.formatTime(this.duration),r=W.get(`seekLabel`,this.config);t.setAttribute(`aria-valuetext`,r.replace(`{currentTime}`,e).replace(`{duration}`,n))}else if(A(t,this.config.selectors.inputs.volume)){let e=t.value*100;t.setAttribute(`aria-valuenow`,e),t.setAttribute(`aria-valuetext`,`${e.toFixed(1)}%`)}else t.setAttribute(`aria-valuenow`,t.value);!H.isWebKit&&!H.isIPadOS||t.style.setProperty(`--value`,`${t.value/t.max*100}%`)}},updateSeekTooltip(e){if(!this.config.tooltips.seek||!x.element(this.elements.inputs.seek)||!x.element(this.elements.display.seekTooltip)||this.duration===0)return;let t=this.elements.display.seekTooltip,n=`${this.config.classNames.tooltip}--visible`,r=e=>k(t,n,e);if(this.touch){r(!1);return}let i=0,a=this.elements.progress.getBoundingClientRect();if(x.event(e)){let t=e.pageX-e.clientX;i=100/a.width*(e.pageX-a.left-t)}else if(ze(t,n))i=Number.parseFloat(t.style.left,10);else return;i<0?i=0:i>100&&(i=100);let o=this.duration/100*i;t.textContent=q.formatTime(o);let s=this.config.markers?.points?.find(({time:e})=>e===Math.round(o));s&&t.insertAdjacentHTML(`afterbegin`,`${s.label}<br>`),t.style.left=`${i}%`,x.event(e)&&[`mouseenter`,`mouseleave`].includes(e.type)&&r(e.type===`mouseenter`)},timeUpdate(e){let t=!x.element(this.elements.display.duration)&&this.config.invertTime;q.updateTimeDisplay.call(this,this.elements.display.currentTime,t?this.duration-this.currentTime:this.currentTime,t),!(e&&e.type===`timeupdate`&&this.media.seeking)&&q.updateProgress.call(this,e)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32){O(this.elements.display.currentTime,!0),O(this.elements.progress,!0);return}x.element(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute(`aria-valuemax`,this.duration);let e=x.element(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&q.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&q.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),this.config.markers.enabled&&q.setMarkers.call(this),q.updateSeekTooltip.call(this)},toggleMenuButton(e,t){O(this.elements.settings.buttons[e],!t)},updateSetting(e,t,n){let r=this.elements.settings.panels[e],i=null,a=t;if(e===`captions`)i=this.currentTrack;else{if(i=x.empty(n)?this[e]:n,x.empty(i)&&(i=this.config[e].default),!x.empty(this.options[e])&&!this.options[e].includes(i)){this.debug.warn(`Unsupported value of '${i}' for ${e}`);return}if(!this.config[e].options.includes(i)){this.debug.warn(`Disabled value of '${i}' for ${e}`);return}}if(x.element(a)||(a=r&&r.querySelector(`[role="menu"]`)),!x.element(a))return;let o=this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`);o.innerHTML=q.getLabel.call(this,e,i);let s=a&&a.querySelector(`[value="${i}"]`);x.element(s)&&(s.checked=!0)},getLabel(e,t){switch(e){case`speed`:return t===1?W.get(`normal`,this.config):`${t}×`;case`quality`:if(x.number(t)){let e=W.get(`qualityLabel.${t}`,this.config);return e.length?e:`${t}p`}return it(t);case`captions`:return J.getLabel.call(this);default:return null}},setQualityMenu(e){if(!x.element(this.elements.settings.panels.quality))return;let t=`quality`,n=this.elements.settings.panels.quality.querySelector(`[role="menu"]`);x.array(e)&&(this.options.quality=qe(e).filter(e=>this.config.quality.options.includes(e)));let r=!x.empty(this.options.quality)&&this.options.quality.length>1;if(q.toggleMenuButton.call(this,t,r),T(n),q.checkMenu.call(this),!r)return;let i=e=>{let t=W.get(`qualityBadge.${e}`,this.config);return t.length?q.createBadge.call(this,t):null};this.options.quality.sort((e,t)=>{let n=this.config.quality.options;return n.indexOf(e)>n.indexOf(t)?1:-1}).forEach(e=>{q.createMenuItem.call(this,{value:e,list:n,type:t,title:q.getLabel.call(this,`quality`,e),badge:i(e)})}),q.updateSetting.call(this,t,n)},setCaptionsMenu(){if(!x.element(this.elements.settings.panels.captions))return;let e=`captions`,t=this.elements.settings.panels.captions.querySelector(`[role="menu"]`),n=J.getTracks.call(this),r=!!n.length;if(q.toggleMenuButton.call(this,e,r),T(t),q.checkMenu.call(this),!r)return;let i=n.map((e,n)=>({value:n,checked:this.captions.toggled&&this.currentTrack===n,title:J.getLabel.call(this,e),badge:e.language&&q.createBadge.call(this,e.language.toUpperCase()),list:t,type:`language`}));i.unshift({value:-1,checked:!this.captions.toggled,title:W.get(`disabled`,this.config),list:t,type:`language`}),i.forEach(q.createMenuItem.bind(this)),q.updateSetting.call(this,e,t)},setSpeedMenu(){if(!x.element(this.elements.settings.panels.speed))return;let 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);let n=!x.empty(this.options.speed)&&this.options.speed.length>1;q.toggleMenuButton.call(this,e,n),T(t),q.checkMenu.call(this),n&&(this.options.speed.forEach(n=>{q.createMenuItem.call(this,{value:n,list:t,type:e,title:q.getLabel.call(this,`speed`,n)})}),q.updateSetting.call(this,e,t))},checkMenu(){let{buttons:e}=this.elements.settings,t=!x.empty(e)&&Object.values(e).some(e=>!e.hidden);O(this.elements.settings.menu,!t)},focusFirstMenuItem(e,t=!1){if(this.elements.settings.popup.hidden)return;let n=e;x.element(n)||(n=Object.values(this.elements.settings.panels).find(e=>!e.hidden));let r=n.querySelector(`[role^="menuitem"]`);Ve.call(this,r,t)},toggleMenu(e){let{popup:t}=this.elements.settings,n=this.elements.buttons.settings;if(!x.element(t)||!x.element(n))return;let{hidden:r}=t,i=r;if(x.boolean(e))i=e;else if(x.keyboardEvent(e)&&e.key===`Escape`)i=!1;else if(x.event(e)){let r=x.function(e.composedPath)?e.composedPath()[0]:e.target,a=t.contains(r);if(a||!a&&e.target!==n&&i)return}n.setAttribute(`aria-expanded`,i),O(t,!i),k(this.elements.container,this.config.classNames.menu.open,i),i&&x.keyboardEvent(e)?q.focusFirstMenuItem.call(this,null,!0):!i&&!r&&Ve.call(this,n,x.keyboardEvent(e))},getMenuSize(e){let t=e.cloneNode(!0);t.style.position=`absolute`,t.style.opacity=0,t.removeAttribute(`hidden`),e.parentNode.appendChild(t);let n=t.scrollWidth,r=t.scrollHeight;return w(t),{width:n,height:r}},showMenuPanel(e=``,t=!1){let n=this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`);if(!x.element(n))return;let r=n.parentNode,i=Array.from(r.children).find(e=>!e.hidden);if(N.transitions&&!N.reducedMotion){r.style.width=`${i.scrollWidth}px`,r.style.height=`${i.scrollHeight}px`;let e=q.getMenuSize.call(this,n),t=e=>{e.target!==r||![`width`,`height`].includes(e.propertyName)||(r.style.width=``,r.style.height=``,I.call(this,r,je,t))};F.call(this,r,je,t),r.style.width=`${e.width}px`,r.style.height=`${e.height}px`}O(i,!0),O(n,!1),q.focusFirstMenuItem.call(this,n,t)},setDownloadUrl(){let e=this.elements.buttons.download;x.element(e)&&e.setAttribute(`href`,this.download)},create(e){let{bindMenuItemShortcuts:t,createButton:n,createProgress:r,createRange:i,createTime:a,setQualityMenu:o,setSpeedMenu:s,showMenuPanel:c}=q;this.elements.controls=null,x.array(this.config.controls)&&this.config.controls.includes(`play-large`)&&this.elements.container.appendChild(n.call(this,`play-large`));let l=C(`div`,D(this.config.selectors.controls.wrapper));this.elements.controls=l;let u={class:`plyr__controls__item`};return qe(x.array(this.config.controls)?this.config.controls:[]).forEach(o=>{if(o===`restart`&&l.appendChild(n.call(this,`restart`,u)),o===`rewind`&&l.appendChild(n.call(this,`rewind`,u)),o===`play`&&l.appendChild(n.call(this,`play`,u)),o===`fast-forward`&&l.appendChild(n.call(this,`fast-forward`,u)),o===`progress`){let t=C(`div`,{class:`${u.class} plyr__progress__container`}),n=C(`div`,D(this.config.selectors.progress));if(n.appendChild(i.call(this,`seek`,{id:`plyr-seek-${e.id}`})),n.appendChild(r.call(this,`buffer`)),this.config.tooltips.seek){let e=C(`span`,{class:this.config.classNames.tooltip},`00:00`);n.appendChild(e),this.elements.display.seekTooltip=e}this.elements.progress=n,t.appendChild(this.elements.progress),l.appendChild(t)}if(o===`current-time`&&l.appendChild(a.call(this,`currentTime`,u)),o===`duration`&&l.appendChild(a.call(this,`duration`,u)),o===`mute`||o===`volume`){let{volume:t}=this.elements;if((!x.element(t)||!l.contains(t))&&(t=C(`div`,S({},u,{class:`${u.class} plyr__volume`.trim()})),this.elements.volume=t,l.appendChild(t)),o===`mute`&&t.appendChild(n.call(this,`mute`)),o===`volume`&&!H.isIos&&!H.isIPadOS){let n={max:1,step:.05,value:this.config.volume};t.appendChild(i.call(this,`volume`,S(n,{id:`plyr-volume-${e.id}`})))}}if(o===`captions`&&l.appendChild(n.call(this,`captions`,u)),o===`settings`&&!x.empty(this.config.settings)){let r=C(`div`,S({},u,{class:`${u.class} plyr__menu`.trim(),hidden:``}));r.appendChild(n.call(this,`settings`,{"aria-haspopup":!0,"aria-controls":`plyr-settings-${e.id}`,"aria-expanded":!1}));let i=C(`div`,{class:`plyr__menu__container`,id:`plyr-settings-${e.id}`,hidden:``}),a=C(`div`),o=C(`div`,{id:`plyr-settings-${e.id}-home`}),s=C(`div`,{role:`menu`});o.appendChild(s),a.appendChild(o),this.elements.settings.panels.home=o,this.config.settings.forEach(n=>{let r=C(`button`,S(D(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,r,n),F.call(this,r,`click`,()=>{c.call(this,n,!1)});let i=C(`span`,null,W.get(n,this.config)),o=C(`span`,{class:this.config.classNames.menu.value});o.innerHTML=e[n],i.appendChild(o),r.appendChild(i),s.appendChild(r);let l=C(`div`,{id:`plyr-settings-${e.id}-${n}`,hidden:``}),u=C(`button`,{type:`button`,class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});u.appendChild(C(`span`,{"aria-hidden":!0},W.get(n,this.config))),u.appendChild(C(`span`,{class:this.config.classNames.hidden},W.get(`menuBack`,this.config))),F.call(this,l,`keydown`,e=>{e.key===`ArrowLeft`&&(e.preventDefault(),e.stopPropagation(),c.call(this,`home`,!0))},!1),F.call(this,u,`click`,()=>{c.call(this,`home`,!1)}),l.appendChild(u),l.appendChild(C(`div`,{role:`menu`})),a.appendChild(l),this.elements.settings.buttons[n]=r,this.elements.settings.panels[n]=l}),i.appendChild(a),r.appendChild(i),l.appendChild(r),this.elements.settings.popup=i,this.elements.settings.menu=r}if(o===`pip`&&N.pip&&l.appendChild(n.call(this,`pip`,u)),o===`airplay`&&N.airplay&&l.appendChild(n.call(this,`airplay`,u)),o===`download`){let e=S({},u,{element:`a`,href:this.download,target:`_blank`});this.isHTML5&&(e.download=``);let{download:t}=this.config.urls;!x.url(t)&&this.isEmbed&&S(e,{icon:`logo-${this.provider}`,label:this.provider}),l.appendChild(n.call(this,`download`,e))}o===`fullscreen`&&l.appendChild(n.call(this,`fullscreen`,u))}),this.isHTML5&&o.call(this,V.getQualityOptions.call(this)),s.call(this),l},inject(){if(this.config.loadSprite){let e=q.getIconUrl.call(this);e.cors&&dt(e.url,`sprite-plyr`)}this.id=Math.floor(Math.random()*1e4);let e=null;this.elements.controls=null;let t={id:this.id,seektime:this.config.seekTime,title:this.config.title},n=!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=q.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:J.getLabel.call(this)}),n=!1),n&&x.string(this.config.controls)&&(e=(e=>{let n=e;return Object.entries(t).forEach(([e,t])=>{n=U(n,`{${e}}`,t)}),n})(e));let r;x.string(this.config.selectors.controls.container)&&(r=document.querySelector(this.config.selectors.controls.container)),x.element(r)||(r=this.elements.container);let i=x.element(e)?`insertAdjacentElement`:`insertAdjacentHTML`;if(r[i](`afterbegin`,e),x.element(this.elements.controls)||q.findElements.call(this),!x.empty(this.elements.buttons)){let e=e=>{let t=this.config.classNames.controlPressed;e.setAttribute(`aria-pressed`,`false`),Object.defineProperty(e,`pressed`,{configurable:!0,enumerable:!0,get(){return ze(e,t)},set(n=!1){k(e,t,n),e.setAttribute(`aria-pressed`,n?`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(H.isEdge&&Me(r),this.config.tooltips.controls){let{classNames:e,selectors:t}=this.config,n=`${t.controls.wrapper} ${t.labels} .${e.hidden}`,r=j.call(this,n);Array.from(r).forEach(e=>{k(e,this.config.classNames.hidden,!1),k(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(){if(!this.duration||this.elements.markers)return;let e=this.config.markers?.points?.filter(({time:e})=>e>0&&e<this.duration);if(!(e!=null&&e.length))return;let t=document.createDocumentFragment(),n=document.createDocumentFragment(),r=null,i=`${this.config.classNames.tooltip}--visible`,a=e=>k(r,i,e);e.forEach(e=>{let t=C(`span`,{class:this.config.classNames.marker},``),i=`${e.time/this.duration*100}%`;r&&(t.addEventListener(`mouseenter`,()=>{e.label||(r.style.left=i,r.innerHTML=e.label,a(!0))}),t.addEventListener(`mouseleave`,()=>{a(!1)})),t.addEventListener(`click`,()=>{this.currentTime=e.time}),t.style.left=i,n.appendChild(t)}),t.appendChild(n),this.config.tooltips.seek||(r=C(`span`,{class:this.config.classNames.tooltip},``),t.appendChild(r)),this.elements.markers={points:n,tip:r},this.elements.progress.appendChild(t)}};function ht(e,t=!0){let n=e;if(t){let e=document.createElement(`a`);e.href=n,n=e.href}try{return new URL(n)}catch{return null}}function gt(e){let t=new URLSearchParams;return x.object(e)&&Object.entries(e).forEach(([e,n])=>{t.set(e,n)}),t}var J={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!N.textTracks){x.array(this.config.controls)&&this.config.controls.includes(`settings`)&&this.config.settings.includes(`captions`)&&q.setCaptionsMenu.call(this);return}if(x.element(this.elements.captions)||(this.elements.captions=C(`div`,D(this.config.selectors.captions)),this.elements.captions.setAttribute(`dir`,`auto`),Le(this.elements.captions,this.elements.wrapper)),H.isIE&&window.URL){let e=this.media.querySelectorAll(`track`);Array.from(e).forEach(e=>{let t=e.getAttribute(`src`),n=ht(t);n!==null&&n.hostname!==window.location.href.hostname&&[`http:`,`https:`].includes(n.protocol)&&G(t,`blob`).then(t=>{e.setAttribute(`src`,window.URL.createObjectURL(t))}).catch(()=>{w(e)})})}let e=qe((navigator.languages||[navigator.language||navigator.userLanguage||`en`]).map(e=>e.split(`-`)[0])),t=(this.storage.get(`language`)||this.captions.language||this.config.captions.language||`auto`).toLowerCase();t===`auto`&&([t]=e);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:t,languages:e}),this.isHTML5){let e=this.config.captions.update?`addtrack removetrack`:`removetrack`;F.call(this,this.media.textTracks,e,J.update.bind(this))}setTimeout(J.update.bind(this),0)},update(){let e=J.getTracks.call(this,!0),{active:t,language:n,meta:r,currentTrackNode:i}=this.captions,a=!!e.find(e=>e.language===n);this.isHTML5&&this.isVideo&&e.filter(e=>!r.get(e)).forEach(e=>{this.debug.log(`Track added`,e),r.set(e,{default:e.mode===`showing`}),e.mode===`showing`&&(e.mode=`hidden`),F.call(this,e,`cuechange`,()=>J.updateCues.call(this))}),(a&&this.language!==n||!e.includes(i))&&(J.setLanguage.call(this,n),J.toggle.call(this,t&&a)),this.elements&&k(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`)&&q.setCaptionsMenu.call(this)},toggle(e,t=!0){if(!this.supported.ui)return;let{toggled:n}=this.captions,r=this.config.classNames.captions.active,i=x.nullOrUndefined(e)?!n:e;if(i!==n){if(t||(this.captions.active=i,this.storage.set({captions:i})),!this.language&&i&&!t){let e=J.getTracks.call(this),t=J.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);this.captions.language=t.language,J.set.call(this,e.indexOf(t));return}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=i),k(this.elements.container,r,i),this.captions.toggled=i,q.updateSetting.call(this,`captions`),L.call(this,this.media,i?`captionsenabled`:`captionsdisabled`)}setTimeout(()=>{i&&this.captions.toggled&&(this.captions.currentTrackNode.mode=`hidden`)})},set(e,t=!0){let n=J.getTracks.call(this);if(e===-1){J.toggle.call(this,!1,t);return}if(!x.number(e)){this.debug.warn(`Invalid caption argument`,e);return}if(!(e in n)){this.debug.warn(`Track not found`,e);return}if(this.captions.currentTrack!==e){this.captions.currentTrack=e;let r=n[e],{language:i}=r||{};this.captions.currentTrackNode=r,q.updateSetting.call(this,`captions`),t||(this.captions.language=i,this.storage.set({language:i})),this.isVimeo&&this.embed.enableTextTrack(i,null,!1),L.call(this,this.media,`languagechange`)}J.toggle.call(this,!0,t),this.isHTML5&&this.isVideo&&J.updateCues.call(this)},setLanguage(e,t=!0){if(!x.string(e)){this.debug.warn(`Invalid language argument`,e);return}let n=e.toLowerCase();this.captions.language=n;let r=J.getTracks.call(this),i=J.findTrack.call(this,[n]);J.set.call(this,r.indexOf(i),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){let n=J.getTracks.call(this),r=e=>Number((this.captions.meta.get(e)||{}).default),i=Array.from(n).sort((e,t)=>r(t)-r(e)),a;return e.every(e=>(a=i.find(t=>t.language===e),!a)),a||(t?i[0]:void 0)},getCurrentTrack(){return J.getTracks.call(this)[this.currentTrack]},getLabel(e){let t=e;return!x.track(t)&&N.textTracks&&this.captions.toggled&&(t=J.getCurrentTrack.call(this)),x.track(t)?x.empty(t.label)?x.empty(t.language)?W.get(`enabled`,this.config):e.language.toUpperCase():t.label:W.get(`disabled`,this.config)},updateCues(e){if(!this.supported.ui)return;if(!x.element(this.elements.captions)){this.debug.warn(`No captions element to render to`);return}if(!x.nullOrUndefined(e)&&!Array.isArray(e)){this.debug.warn(`updateCues: Invalid input`,e);return}let t=e;if(!t){let e=J.getCurrentTrack.call(this);t=Array.from((e||{}).activeCues||[]).map(e=>e.getCueAsHTML()).map(ct)}let n=t.map(e=>e.trim()).join(`
|
|
`);if(n!==this.elements.captions.innerHTML){T(this.elements.captions);let e=C(`span`,D(this.config.selectors.caption));e.innerHTML=n,this.elements.captions.appendChild(e),L.call(this,this.media,`cuechange`)}}},_t={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`.split(`.`),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,customControls:!0,noCookie:!1},mediaMetadata:{title:``,artist:``,album:``,artwork:[]},markers:{enabled:!1,points:[]}},vt={active:`picture-in-picture`,inactive:`inline`},Y={html5:`html5`,youtube:`youtube`,vimeo:`vimeo`},yt={audio:`audio`,video:`video`};function bt(e){return/^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(e)?Y.youtube:/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(e)?Y.vimeo:null}function xt(){}var St=class{constructor(e=!1){this.enabled=window.console&&e,this.enabled&&this.log(`Debugging enabled`)}get log(){return this.enabled?Function.prototype.bind.call(console.log,console):xt}get warn(){return this.enabled?Function.prototype.bind.call(console.warn,console):xt}get error(){return this.enabled?Function.prototype.bind.call(console.error,console):xt}},Ct=class e{constructor(t){o(this,`onChange`,()=>{if(!this.supported)return;let e=this.player.elements.buttons.fullscreen;x.element(e)&&(e.pressed=this.active);let t=this.target===this.player.media?this.target:this.player.elements.container;L.call(this.player,t,this.active?`enterfullscreen`:`exitfullscreen`,!0)}),o(this,`toggleFallback`,(e=!1)=>{if(e?this.scrollPosition={x:window.scrollX??0,y:window.scrollY??0}:window.scrollTo(this.scrollPosition.x,this.scrollPosition.y),document.body.style.overflow=e?`hidden`:``,k(this.target,this.player.config.classNames.fullscreen.fallback,e),H.isIos){let t=document.head.querySelector(`meta[name="viewport"]`),n=`viewport-fit=cover`;t||(t=document.createElement(`meta`),t.setAttribute(`name`,`viewport`));let r=x.string(t.content)&&t.content.includes(n);e?(this.cleanupViewport=!r,r||(t.content+=`,${n}`)):this.cleanupViewport&&(t.content=t.content.split(`,`).filter(e=>e.trim()!==n).join(`,`))}this.onChange()}),o(this,`trapFocus`,e=>{if(H.isIos||H.isIPadOS||!this.active||e.key!==`Tab`)return;let t=document.activeElement,n=j.call(this.player,`a[href], button:not(:disabled), input:not(:disabled), [tabindex]`),[r]=n,i=n[n.length-1];t===i&&!e.shiftKey?(r.focus(),e.preventDefault()):t===r&&e.shiftKey&&(i.focus(),e.preventDefault())}),o(this,`update`,()=>{if(this.supported){let t;t=this.forceFallback?`Fallback (forced)`:e.nativeSupported?`Native`:`Fallback`,this.player.debug.log(`${t} fullscreen enabled`)}else this.player.debug.log(`Fullscreen not supported and fallback disabled`);k(this.player.elements.container,this.player.config.classNames.fullscreen.enabled,this.supported)}),o(this,`enter`,()=>{this.supported&&(H.isIos&&this.player.config.fullscreen.iosNative?this.player.isVimeo?this.player.embed.requestFullscreen():this.target.webkitEnterFullscreen():!e.nativeSupported||this.forceFallback?this.toggleFallback(!0):this.prefix?x.empty(this.prefix)||this.target[`${this.prefix}Request${this.property}`]():this.target.requestFullscreen({navigationUI:`hide`}))}),o(this,`exit`,()=>{if(this.supported){if(H.isIos&&this.player.config.fullscreen.iosNative)this.player.isVimeo?this.player.embed.exitFullscreen():this.target.webkitEnterFullscreen(),R(this.player.play());else if(!e.nativeSupported||this.forceFallback)this.toggleFallback(!1);else if(!this.prefix)(document.cancelFullScreen||document.exitFullscreen).call(document);else if(!x.empty(this.prefix)){let e=this.prefix===`moz`?`Cancel`:`Exit`;document[`${this.prefix}${e}${this.property}`]()}}}),o(this,`toggle`,()=>{this.active?this.exit():this.enter()}),this.player=t,this.prefix=e.prefix,this.property=e.property,this.scrollPosition={x:0,y:0},this.forceFallback=t.config.fullscreen.fallback===`force`,this.player.elements.fullscreen=t.config.fullscreen.container&&Be(this.player.elements.container,t.config.fullscreen.container),F.call(this.player,document,this.prefix===`ms`?`MSFullscreenChange`:`${this.prefix}fullscreenchange`,()=>{this.onChange()}),F.call(this.player,this.player.elements.container,`dblclick`,e=>{x.element(this.player.elements.controls)&&this.player.elements.controls.contains(e.target)||this.player.listeners.proxy(e,this.toggle,`fullscreen`)}),F.call(this,this.player.elements.container,`keydown`,e=>this.trapFocus(e)),this.update()}static get nativeSupported(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}get useNative(){return e.nativeSupported&&!this.forceFallback}static get prefix(){if(x.function(document.exitFullscreen))return``;let e=``;return[`webkit`,`moz`,`ms`].some(t=>x.function(document[`${t}ExitFullscreen`])||x.function(document[`${t}CancelFullScreen`])?(e=t,!0):!1),e}static get property(){return this.prefix===`moz`?`FullScreen`:`Fullscreen`}get supported(){return[this.player.config.fullscreen.enabled,this.player.isVideo,e.nativeSupported||this.player.config.fullscreen.fallback,!this.player.isYouTube||e.nativeSupported||!H.isIos||this.player.config.playsinline&&!this.player.config.fullscreen.iosNative].every(Boolean)}get active(){if(!this.supported)return!1;if(!e.nativeSupported||this.forceFallback)return ze(this.target,this.player.config.classNames.fullscreen.fallback);let t=this.prefix?this.target.getRootNode()[`${this.prefix}${this.property}Element`]:this.target.getRootNode().fullscreenElement;return t&&t.shadowRoot?t===this.target.getRootNode().host:t===this.target}get target(){return H.isIos&&this.player.config.fullscreen.iosNative?this.player.media:this.player.elements.fullscreen??this.player.elements.container}};function wt(e,t=1){return new Promise((n,r)=>{let i=new Image,a=()=>{delete i.onload,delete i.onerror,(i.naturalWidth>=t?n:r)(i)};Object.assign(i,{onload:a,onerror:a,src:e})})}var X={addStyleHook(){k(this.elements.container,this.config.selectors.container.replace(`.`,``),!0),k(this.elements.container,this.config.classNames.uiSupported,this.supported.ui)},toggleNativeControls(e=!1){e&&this.isHTML5?this.media.setAttribute(`controls`,``):this.media.removeAttribute(`controls`)},build(){if(this.listeners.media(),!this.supported.ui){this.debug.warn(`Basic support only for ${this.provider} ${this.type}`),X.toggleNativeControls.call(this,!0);return}x.element(this.elements.controls)||(q.inject.call(this),this.listeners.controls()),X.toggleNativeControls.call(this),this.isHTML5&&J.setup.call(this),this.volume=null,this.muted=null,this.loop=null,this.quality=null,this.speed=null,q.updateVolume.call(this),q.timeUpdate.call(this),q.durationUpdate.call(this),X.checkPlaying.call(this),k(this.elements.container,this.config.classNames.pip.supported,N.pip&&this.isHTML5&&this.isVideo),k(this.elements.container,this.config.classNames.airplay.supported,N.airplay&&this.isHTML5),k(this.elements.container,this.config.classNames.isTouch,this.touch),this.ready=!0,setTimeout(()=>{L.call(this,this.media,`ready`)},0),X.setTitle.call(this),this.poster&&X.setPoster.call(this,this.poster,!1).catch(()=>{}),this.config.duration&&q.durationUpdate.call(this),this.config.mediaMetadata&&q.setMediaMetadata.call(this)},setTitle(){let e=W.get(`play`,this.config);if(x.string(this.config.title)&&!x.empty(this.config.title)&&(e+=`, ${this.config.title}`),Array.from(this.elements.buttons.play||[]).forEach(t=>{t.setAttribute(`aria-label`,e)}),this.isEmbed){let e=M.call(this,`iframe`);if(!x.element(e))return;let t=x.empty(this.config.title)?`video`:this.config.title,n=W.get(`frameTitle`,this.config);e.setAttribute(`title`,n.replace(`{title}`,t))}},togglePoster(e){k(this.elements.container,this.config.classNames.posterEnabled,e)},setPoster(e,t=!0){return t&&this.poster?Promise.reject(Error(`Poster already set`)):(this.media.setAttribute(`data-poster`,e),this.elements.poster.removeAttribute(`hidden`),Ke.call(this).then(()=>wt(e)).catch(t=>{throw e===this.poster&&X.togglePoster.call(this,!1),t}).then(()=>{if(e!==this.poster)throw Error(`setPoster cancelled by later call to setPoster`)}).then(()=>(Object.assign(this.elements.poster.style,{backgroundImage:`url('${e}')`,backgroundSize:``}),X.togglePoster.call(this,!0),e)))},checkPlaying(e){k(this.elements.container,this.config.classNames.playing,this.playing),k(this.elements.container,this.config.classNames.paused,this.paused),k(this.elements.container,this.config.classNames.stopped,this.stopped),Array.from(this.elements.buttons.play||[]).forEach(e=>{Object.assign(e,{pressed:this.playing}),e.setAttribute(`aria-label`,W.get(this.playing?`pause`:`play`,this.config))}),!(x.event(e)&&e.type===`timeupdate`)&&X.toggleControls.call(this)},checkLoading(e){this.loading=[`stalled`,`waiting`].includes(e.type),clearTimeout(this.timers.loading),this.timers.loading=setTimeout(()=>{k(this.elements.container,this.config.classNames.loading,this.loading),X.toggleControls.call(this)},this.loading?250:0)},toggleControls(e){let{controls:t}=this.elements;if(t&&this.config.hideControls){let n=this.touch&&this.lastSeekTime+2e3>Date.now();this.toggleControls(!!(e||this.loading||this.paused||t.pressed||t.hover||n))}},migrateStyles(){Object.values({...this.media.style}).filter(e=>!x.empty(e)&&x.string(e)&&e.startsWith(`--plyr`)).forEach(e=>{this.elements.container.style.setProperty(e,this.media.style.getPropertyValue(e)),this.media.style.removeProperty(e)}),x.empty(this.media.style)&&this.media.removeAttribute(`style`)}},Tt=class{constructor(e){o(this,`firstTouch`,()=>{let{player:e}=this,{elements:t}=e;e.touch=!0,k(t.container,e.config.classNames.isTouch,!0)}),o(this,`global`,(e=!0)=>{let{player:t}=this;t.config.keyboard.global&&P.call(t,window,`keydown keyup`,this.handleKey,e,!1),P.call(t,document.body,`click`,this.toggleMenu,e),We.call(t,document.body,`touchstart`,this.firstTouch)}),o(this,`container`,()=>{let{player:e}=this,{config:t,elements:n,timers:r}=e;!t.keyboard.global&&t.keyboard.focused&&F.call(e,n.container,`keydown keyup`,this.handleKey,!1),F.call(e,n.container,`mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen`,t=>{let{controls:i}=n;i&&t.type===`enterfullscreen`&&(i.pressed=!1,i.hover=!1);let a=[`touchstart`,`touchmove`,`mousemove`].includes(t.type),o=0;a&&(X.toggleControls.call(e,!0),o=e.touch?3e3:2e3),clearTimeout(r.controls),r.controls=setTimeout(()=>X.toggleControls.call(e,!1),o)});let i=()=>{if(!e.isVimeo||e.config.vimeo.premium)return;let t=n.wrapper,{active:r}=e.fullscreen,[i,a]=Qe.call(e),o=Ye(`aspect-ratio: ${i} / ${a}`);if(!r){o?(t.style.width=null,t.style.height=null):(t.style.maxWidth=null,t.style.margin=null);return}let[s,c]=et(),l=s/c>i/a;o?(t.style.width=l?`auto`:`100%`,t.style.height=l?`100%`:`auto`):(t.style.maxWidth=l?`${c/a*i}px`:null,t.style.margin=l?`0 auto`:null)},a=()=>{clearTimeout(r.resized),r.resized=setTimeout(i,50)};F.call(e,n.container,`enterfullscreen exitfullscreen`,t=>{let{target:r}=e.fullscreen;r===n.container&&(!e.isEmbed&&x.empty(e.config.ratio)||(i(),(t.type===`enterfullscreen`?F:I).call(e,window,`resize`,a)))})}),o(this,`media`,()=>{let{player:e}=this,{elements:t}=e;if(F.call(e,e.media,`timeupdate seeking seeked`,t=>q.timeUpdate.call(e,t)),F.call(e,e.media,`durationchange loadeddata loadedmetadata`,t=>q.durationUpdate.call(e,t)),F.call(e,e.media,`ended`,()=>{e.isHTML5&&e.isVideo&&e.config.resetOnEnd&&(e.restart(),e.pause())}),F.call(e,e.media,`progress playing seeking seeked`,t=>q.updateProgress.call(e,t)),F.call(e,e.media,`volumechange`,t=>q.updateVolume.call(e,t)),F.call(e,e.media,`playing play pause ended emptied timeupdate`,t=>X.checkPlaying.call(e,t)),F.call(e,e.media,`waiting canplay seeked playing`,t=>X.checkLoading.call(e,t)),e.supported.ui&&e.config.clickToPlay&&!e.isAudio){let n=M.call(e,`.${e.config.classNames.video}`);if(!x.element(n))return;F.call(e,t.container,`click`,r=>{![t.container,n].includes(r.target)&&!n.contains(r.target)||e.touch&&e.config.hideControls||(e.ended?(this.proxy(r,e.restart,`restart`),this.proxy(r,()=>{R(e.play())},`play`)):this.proxy(r,()=>{R(e.togglePlay())},`play`))})}e.supported.ui&&e.config.disableContextMenu&&F.call(e,t.wrapper,`contextmenu`,e=>{e.preventDefault()},!1),F.call(e,e.media,`volumechange`,()=>{e.storage.set({volume:e.volume,muted:e.muted})}),F.call(e,e.media,`ratechange`,()=>{q.updateSetting.call(e,`speed`),e.storage.set({speed:e.speed})}),F.call(e,e.media,`qualitychange`,t=>{q.updateSetting.call(e,`quality`,null,t.detail.quality)}),F.call(e,e.media,`ready qualitychange`,()=>{q.setDownloadUrl.call(e)});let n=e.config.events.concat([`keyup`,`keydown`]).join(` `);F.call(e,e.media,n,n=>{let{detail:r={}}=n;n.type===`error`&&(r=e.media.error),L.call(e,t.container,n.type,!0,r)})}),o(this,`proxy`,(e,t,n)=>{let{player:r}=this,i=r.config.listeners[n],a=x.function(i),o=!0;a&&(o=i.call(r,e)),o!==!1&&x.function(t)&&t.call(r,e)}),o(this,`bind`,(e,t,n,r,i=!0)=>{let{player:a}=this,o=a.config.listeners[r],s=x.function(o);F.call(a,e,t,e=>this.proxy(e,n,r),i&&!s)}),o(this,`controls`,()=>{let{player:e}=this,{elements:t}=e,n=H.isIE?`change`:`input`;if(t.buttons.play&&Array.from(t.buttons.play).forEach(t=>{this.bind(t,`click`,()=>{R(e.togglePlay())},`play`)}),this.bind(t.buttons.restart,`click`,e.restart,`restart`),this.bind(t.buttons.rewind,`click`,()=>{e.lastSeekTime=Date.now(),e.rewind()},`rewind`),this.bind(t.buttons.fastForward,`click`,()=>{e.lastSeekTime=Date.now(),e.forward()},`fastForward`),this.bind(t.buttons.mute,`click`,()=>{e.muted=!e.muted},`mute`),this.bind(t.buttons.captions,`click`,()=>e.toggleCaptions()),this.bind(t.buttons.download,`click`,()=>{L.call(e,e.media,`download`)},`download`),this.bind(t.buttons.fullscreen,`click`,()=>{e.fullscreen.toggle()},`fullscreen`),this.bind(t.buttons.pip,`click`,()=>{e.pip=`toggle`},`pip`),this.bind(t.buttons.airplay,`click`,e.airplay,`airplay`),this.bind(t.buttons.settings,`click`,t=>{t.stopPropagation(),t.preventDefault(),q.toggleMenu.call(e,t)},null,!1),this.bind(t.buttons.settings,`keyup`,t=>{if([` `,`Enter`].includes(t.key)){if(t.key===`Enter`){q.focusFirstMenuItem.call(e,null,!0);return}t.preventDefault(),t.stopPropagation(),q.toggleMenu.call(e,t)}},null,!1),this.bind(t.settings.menu,`keydown`,t=>{t.key===`Escape`&&q.toggleMenu.call(e,t)}),this.bind(t.inputs.seek,`mousedown mousemove`,e=>{let n=t.progress.getBoundingClientRect(),r=e.pageX-e.clientX,i=100/n.width*(e.pageX-n.left-r);e.currentTarget.setAttribute(`seek-value`,i)}),this.bind(t.inputs.seek,`mousedown mouseup keydown keyup touchstart touchend`,t=>{let n=t.currentTarget,r=`play-on-seeked`;if(x.keyboardEvent(t)&&![`ArrowLeft`,`ArrowRight`].includes(t.key))return;e.lastSeekTime=Date.now();let i=n.hasAttribute(r),a=[`mouseup`,`touchend`,`keyup`].includes(t.type);i&&a?(n.removeAttribute(r),R(e.play())):!a&&e.playing&&(n.setAttribute(r,``),e.pause())}),H.isIos){let t=j.call(e,`input[type="range"]`);Array.from(t).forEach(e=>this.bind(e,n,e=>Me(e.target)))}this.bind(t.inputs.seek,n,t=>{let n=t.currentTarget,r=n.getAttribute(`seek-value`);x.empty(r)&&(r=n.value),n.removeAttribute(`seek-value`),e.currentTime=r/n.max*e.duration},`seek`),this.bind(t.progress,`mouseenter mouseleave mousemove`,t=>q.updateSeekTooltip.call(e,t)),this.bind(t.progress,`mousemove touchmove`,t=>{let{previewThumbnails:n}=e;n&&n.loaded&&n.startMove(t)}),this.bind(t.progress,`mouseleave touchend click`,()=>{let{previewThumbnails:t}=e;t&&t.loaded&&t.endMove(!1,!0)}),this.bind(t.progress,`mousedown touchstart`,t=>{let{previewThumbnails:n}=e;n&&n.loaded&&n.startScrubbing(t)}),this.bind(t.progress,`mouseup touchend`,t=>{let{previewThumbnails:n}=e;n&&n.loaded&&n.endScrubbing(t)}),H.isWebKit&&Array.from(j.call(e,`input[type="range"]`)).forEach(t=>{this.bind(t,`input`,t=>q.updateRangeFill.call(e,t.target))}),e.config.toggleInvert&&!x.element(t.display.duration)&&this.bind(t.display.currentTime,`click`,()=>{e.currentTime!==0&&(e.config.invertTime=!e.config.invertTime,q.timeUpdate.call(e))}),this.bind(t.inputs.volume,n,t=>{e.volume=t.target.value},`volume`),this.bind(t.controls,`mouseenter mouseleave`,n=>{t.controls.hover=!e.touch&&n.type===`mouseenter`}),t.fullscreen&&Array.from(t.fullscreen.children).filter(e=>!e.contains(t.container)).forEach(n=>{this.bind(n,`mouseenter mouseleave`,n=>{t.controls&&(t.controls.hover=!e.touch&&n.type===`mouseenter`)})}),this.bind(t.controls,`mousedown mouseup touchstart touchend touchcancel`,e=>{t.controls.pressed=[`mousedown`,`touchstart`].includes(e.type)}),this.bind(t.controls,`focusin`,()=>{let{config:n,timers:r}=e;k(t.controls,n.classNames.noTransition,!0),X.toggleControls.call(e,!0),setTimeout(()=>{k(t.controls,n.classNames.noTransition,!1)},0);let i=this.touch?3e3:4e3;clearTimeout(r.controls),r.controls=setTimeout(()=>X.toggleControls.call(e,!1),i)}),this.bind(t.inputs.volume,`wheel`,t=>{let n=t.webkitDirectionInvertedFromDevice,[r,i]=[t.deltaX,-t.deltaY].map(e=>n?-e:e),a=Math.sign(Math.abs(r)>Math.abs(i)?r:i);e.increaseVolume(a/50);let{volume:o}=e.media;(a===1&&o<1||a===-1&&o>0)&&t.preventDefault()},`volume`,!1)}),this.player=e,this.lastKey=null,this.focusTimer=null,this.lastKeyDown=null,this.handleKey=this.handleKey.bind(this),this.toggleMenu=this.toggleMenu.bind(this),this.firstTouch=this.firstTouch.bind(this)}handleKey(e){let{player:t}=this,{elements:n}=t,{key:r,type:i,altKey:a,ctrlKey:o,metaKey:s,shiftKey:c}=e,l=i===`keydown`,u=l&&r===this.lastKey;if(a||o||s||c||!r)return;let d=e=>{t.currentTime=t.duration/10*e};if(l){let i=document.activeElement;if(x.element(i)){let{editable:r}=t.config.selectors,{seek:a}=n.inputs;if(i!==a&&A(i,r)||e.key===` `&&A(i,`button, [role^="menuitem"]`))return}switch([` `,`ArrowLeft`,`ArrowUp`,`ArrowRight`,`ArrowDown`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`c`,`f`,`k`,`l`,`m`].includes(r)&&(e.preventDefault(),e.stopPropagation()),r){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:u||d(Number.parseInt(r,10));break;case` `:case`k`:u||R(t.togglePlay());break;case`ArrowUp`:t.increaseVolume(.1);break;case`ArrowDown`:t.decreaseVolume(.1);break;case`m`:u||(t.muted=!t.muted);break;case`ArrowRight`:t.forward();break;case`ArrowLeft`:t.rewind();break;case`f`:t.fullscreen.toggle();break;case`c`:u||t.toggleCaptions();break;case`l`:t.loop=!t.loop;break}r===`Escape`&&!t.fullscreen.usingNative&&t.fullscreen.active&&t.fullscreen.toggle(),this.lastKey=r}else this.lastKey=null}toggleMenu(e){q.toggleMenu.call(this.player,e)}};function Et(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Z={exports:{}},Dt=Z.exports,Ot;function kt(){return Ot?Z.exports:(Ot=1,(function(e,t){(function(t,n){e.exports=n()})(Dt,function(){var e=function(){},t={},n={},r={};function i(e,t){e=e.push?e:[e];for(var i=[],a=e.length,o=a,s=function(e,n){n.length&&i.push(e),o--,o||t(i)},c,l,u;a--;){if(c=e[a],l=n[c],l){s(c,l);continue}u=r[c]=r[c]||[],u.push(s)}}function a(e,t){if(e){var i=r[e];if(n[e]=t,i)for(;i.length;)i[0](e,t),i.splice(0,1)}}function o(t,n){t.call&&(t={success:t}),n.length?(t.error||e)(n):(t.success||e)(t)}function s(t,n,r,i){var a=document,o=r.async,c=(r.numRetries||0)+1,l=r.before||e,u=t.replace(/[\?|#].*$/,``),d=t.replace(/^(css|img|module|nomodule)!/,``),f,p,m;if(i||=0,/(^css!|\.css$)/.test(u))m=a.createElement(`link`),m.rel=`stylesheet`,m.href=d,f=`hideFocus`in m,f&&m.relList&&(f=0,m.rel=`preload`,m.as=`style`);else if(/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(u))m=a.createElement(`img`),m.src=d;else if(m=a.createElement(`script`),m.src=d,m.async=o===void 0?!0:o,p=`noModule`in m,/^module!/.test(u)){if(!p)return n(t,`l`);m.type=`module`}else if(/^nomodule!/.test(u)&&p)return n(t,`l`);m.onload=m.onerror=m.onbeforeload=function(e){var a=e.type[0];if(f)try{m.sheet.cssText.length||(a=`e`)}catch(e){e.code!=18&&(a=`e`)}if(a==`e`){if(i+=1,i<c)return s(t,n,r,i)}else if(m.rel==`preload`&&m.as==`style`)return m.rel=`stylesheet`;n(t,a,e.defaultPrevented)},l(t,m)!==!1&&a.head.appendChild(m)}function c(e,t,n){e=e.push?e:[e];var r=e.length,i=r,a=[],o=function(e,n,i){if(n==`e`&&a.push(e),n==`b`)if(i)a.push(e);else return;r--,r||t(a)},c;for(c=0;c<i;c++)s(e[c],o,n)}function l(e,n,r){var i,s;if(n&&n.trim&&(i=n),s=(i?r:n)||{},i){if(i in t)throw`LoadJS`;t[i]=!0}function l(t,n){c(e,function(e){o(s,e),t&&o({success:t,error:n},e),a(i,e)},s)}if(s.returnPromise)return new Promise(l);l()}return l.ready=function(e,t){return i(e,function(e){o(t,e)}),l},l.done=function(e){a(e,[])},l.reset=function(){t={},n={},r={}},l.isDefined=function(e){return e in t},l})})(Z),Z.exports)}var At=Et(kt());function jt(e){return new Promise((t,n)=>{At(e,{success:t,error:n})})}function Mt(e){if(x.empty(e))return null;if(x.number(Number(e)))return e;let t=e.match(/^.*(vimeo.com\/|video\/)(\d+).*/);return t?t[2]:e}function Nt(e){let t=e.match(/^.*(vimeo.com\/|video\/)(\d+)(\?.*h=|\/)+([\d,a-f]+)/);return t&&t.length===5?t[4]:null}function Q(e){e&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===e&&(this.media.paused=!e,L.call(this,this.media,e?`play`:`pause`))}var Pt={setup(){let e=this;k(e.elements.wrapper,e.config.classNames.embed,!0),e.options.speed=e.config.speed.options,B.call(e),x.object(window.Vimeo)?Pt.ready.call(e):jt(e.config.urls.vimeo.sdk).then(()=>{Pt.ready.call(e)}).catch(t=>{e.debug.warn(`Vimeo SDK (player.js) failed to load`,t)})},ready(){let e=this,t=e.config.vimeo,{premium:n,referrerPolicy:r,...i}=t,a=e.media.getAttribute(`src`),o=``;x.empty(a)?(a=e.media.getAttribute(e.config.attributes.embed.id),o=e.media.getAttribute(e.config.attributes.embed.hash)):o=Nt(a);let s=o?{h:o}:{};n&&Object.assign(i,{controls:!1,sidedock:!1});let c=gt({loop:e.config.loop.active,autoplay:e.autoplay,muted:e.muted,gesture:`media`,playsinline:e.config.playsinline,...s,...i}),l=Mt(a),u=C(`iframe`),d=nt(e.config.urls.vimeo.iframe,l,c);if(u.setAttribute(`src`,d),u.setAttribute(`allowfullscreen`,``),u.setAttribute(`allow`,[`autoplay`,`fullscreen`,`picture-in-picture`,`encrypted-media`,`accelerometer`,`gyroscope`].join(`; `)),x.empty(r)||u.setAttribute(`referrerPolicy`,r),n||!t.customControls)u.setAttribute(`data-poster`,e.poster),e.media=E(u,e.media);else{let t=C(`div`,{class:e.config.classNames.embedContainer,"data-poster":e.poster});t.appendChild(u),e.media=E(t,e.media)}t.customControls||G(nt(e.config.urls.vimeo.api,d)).then(t=>{x.empty(t)||!t.thumbnail_url||X.setPoster.call(e,t.thumbnail_url).catch(()=>{})}),e.embed=new window.Vimeo.Player(u,{autopause:e.config.autopause,muted:e.muted}),e.media.paused=!0,e.media.currentTime=0,e.supported.ui&&e.embed.disableTextTrack(),e.media.play=()=>(Q.call(e,!0),e.embed.play()),e.media.pause=()=>(Q.call(e,!1),e.embed.pause()),e.media.stop=()=>{e.pause(),e.currentTime=0};let{currentTime:f}=e.media;Object.defineProperty(e.media,`currentTime`,{get(){return f},set(t){let{embed:n,media:r,paused:i,volume:a}=e,o=i&&!n.hasPlayed;r.seeking=!0,L.call(e,r,`seeking`),Promise.resolve(o&&n.setVolume(0)).then(()=>n.setCurrentTime(t)).then(()=>o&&n.pause()).then(()=>o&&n.setVolume(a)).catch(()=>{})}});let p=e.config.speed.selected;Object.defineProperty(e.media,`playbackRate`,{get(){return p},set(t){e.embed.setPlaybackRate(t).then(()=>{p=t,L.call(e,e.media,`ratechange`)}).catch(()=>{e.options.speed=[1]})}});let{volume:m}=e.config;Object.defineProperty(e.media,`volume`,{get(){return m},set(t){e.embed.setVolume(t).then(()=>{m=t,L.call(e,e.media,`volumechange`)})}});let{muted:h}=e.config;Object.defineProperty(e.media,`muted`,{get(){return h},set(t){let n=x.boolean(t)?t:!1;e.embed.setMuted(n?!0:e.config.muted).then(()=>{h=n,L.call(e,e.media,`volumechange`)})}});let{loop:ee}=e.config;Object.defineProperty(e.media,`loop`,{get(){return ee},set(t){let n=x.boolean(t)?t:e.config.loop.active;e.embed.setLoop(n).then(()=>{ee=n})}});let te;e.embed.getVideoUrl().then(t=>{te=t,q.setDownloadUrl.call(e)}).catch(e=>{this.debug.warn(e)}),Object.defineProperty(e.media,`currentSrc`,{get(){return te}}),Object.defineProperty(e.media,`ended`,{get(){return e.currentTime===e.duration}}),Promise.all([e.embed.getVideoWidth(),e.embed.getVideoHeight()]).then(t=>{let[n,r]=t;e.embed.ratio=$e(n,r),B.call(this)}),e.embed.setAutopause(e.config.autopause).then(t=>{e.config.autopause=t}),e.embed.getVideoTitle().then(t=>{e.config.title=t,X.setTitle.call(this)}),e.embed.getCurrentTime().then(t=>{f=t,L.call(e,e.media,`timeupdate`)}),e.embed.getDuration().then(t=>{e.media.duration=t,L.call(e,e.media,`durationchange`)}),e.embed.getTextTracks().then(t=>{e.media.textTracks=t,J.setup.call(e)}),e.embed.on(`cuechange`,({cues:t=[]})=>{let n=t.map(e=>st(e.text));J.updateCues.call(e,n)}),e.embed.on(`loaded`,()=>{e.embed.getPaused().then(t=>{Q.call(e,!t),t||L.call(e,e.media,`playing`)}),x.element(e.embed.element)&&e.supported.ui&&e.embed.element.setAttribute(`tabindex`,-1)}),e.embed.on(`bufferstart`,()=>{L.call(e,e.media,`waiting`)}),e.embed.on(`bufferend`,()=>{L.call(e,e.media,`playing`)}),e.embed.on(`play`,()=>{Q.call(e,!0),L.call(e,e.media,`playing`)}),e.embed.on(`pause`,()=>{Q.call(e,!1)}),e.embed.on(`timeupdate`,t=>{e.media.seeking=!1,f=t.seconds,L.call(e,e.media,`timeupdate`)}),e.embed.on(`progress`,t=>{e.media.buffered=t.percent,L.call(e,e.media,`progress`),Number.parseInt(t.percent,10)===1&&L.call(e,e.media,`canplaythrough`),e.embed.getDuration().then(t=>{t!==e.media.duration&&(e.media.duration=t,L.call(e,e.media,`durationchange`))})}),e.embed.on(`seeked`,()=>{e.media.seeking=!1,L.call(e,e.media,`seeked`)}),e.embed.on(`ended`,()=>{e.media.paused=!0,L.call(e,e.media,`ended`)}),e.embed.on(`error`,t=>{e.media.error=t,L.call(e,e.media,`error`)}),t.customControls&&setTimeout(()=>X.build.call(e),0)}};function Ft(e){if(x.empty(e))return null;let t=e.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return t&&t[2]?t[2]:e}function $(e){e&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===e&&(this.media.paused=!e,L.call(this,this.media,e?`play`:`pause`))}function It(e){if(e.noCookie)return`https://www.youtube-nocookie.com`;if(window.location.protocol===`http:`)return`http://www.youtube.com`}var Lt={setup(){if(k(this.elements.wrapper,this.config.classNames.embed,!0),x.object(window.YT)&&x.function(window.YT.Player))Lt.ready.call(this);else{let e=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{x.function(e)&&e(),Lt.ready.call(this)},jt(this.config.urls.youtube.sdk).catch(e=>{this.debug.warn(`YouTube API failed to load`,e)})}},getTitle(e){G(nt(this.config.urls.youtube.api,e)).then(e=>{if(x.object(e)){let{title:t,height:n,width:r}=e;this.config.title=t,X.setTitle.call(this),this.embed.ratio=$e(r,n)}B.call(this)}).catch(()=>{B.call(this)})},ready(){let e=this,t=e.config.youtube,n=e.media&&e.media.getAttribute(`id`);if(!x.empty(n)&&n.startsWith(`youtube-`))return;let r=e.media.getAttribute(`src`);x.empty(r)&&(r=e.media.getAttribute(this.config.attributes.embed.id));let i=Ft(r);if(e.media=E(C(`div`,{id:tt(e.provider),"data-poster":t.customControls?e.poster:void 0}),e.media),t.customControls){let t=e=>`https://i.ytimg.com/vi/${i}/${e}default.jpg`;wt(t(`maxres`),121).catch(()=>wt(t(`sd`),121)).catch(()=>wt(t(`hq`))).then(t=>X.setPoster.call(e,t.src)).then(t=>{t.includes(`maxres`)||(e.elements.poster.style.backgroundSize=`cover`)}).catch(()=>{})}e.embed=new window.YT.Player(e.media,{videoId:i,host:It(t),playerVars:S({},{autoplay:+!!e.config.autoplay,hl:e.config.hl,controls:e.supported.ui&&t.customControls?0:1,disablekb:1,playsinline:e.config.playsinline&&!e.config.fullscreen.iosNative?1:0,cc_load_policy:+!!e.captions.active,cc_lang_pref:e.config.captions.language,widget_referrer:window?window.location.href:null},t),events:{onError(t){if(!e.media.error){let n=t.data,r={2:`The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.`,5:`The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.`,100:`The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.`,101:`The owner of the requested video does not allow it to be played in embedded players.`,150:`The owner of the requested video does not allow it to be played in embedded players.`}[n]||`An unknown error occurred`;e.media.error={code:n,message:r},L.call(e,e.media,`error`)}},onPlaybackRateChange(t){let n=t.target;e.media.playbackRate=n.getPlaybackRate(),L.call(e,e.media,`ratechange`)},onReady(n){if(x.function(e.media.play))return;let r=n.target;Lt.getTitle.call(e,i),e.media.play=()=>{$.call(e,!0),r.playVideo()},e.media.pause=()=>{$.call(e,!1),r.pauseVideo()},e.media.stop=()=>{r.stopVideo()},e.media.duration=r.getDuration(),e.media.paused=!0,e.media.currentTime=0,Object.defineProperty(e.media,`currentTime`,{get(){return Number(r.getCurrentTime())},set(t){e.paused&&!e.embed.hasPlayed&&e.embed.mute(),e.media.seeking=!0,L.call(e,e.media,`seeking`),r.seekTo(t)}}),Object.defineProperty(e.media,`playbackRate`,{get(){return r.getPlaybackRate()},set(e){r.setPlaybackRate(e)}});let{volume:a}=e.config;Object.defineProperty(e.media,`volume`,{get(){return a},set(t){a=t,r.setVolume(a*100),L.call(e,e.media,`volumechange`)}});let{muted:o}=e.config;Object.defineProperty(e.media,`muted`,{get(){return o},set(t){let n=x.boolean(t)?t:o;o=n,r[n?`mute`:`unMute`](),r.setVolume(a*100),L.call(e,e.media,`volumechange`)}}),Object.defineProperty(e.media,`currentSrc`,{get(){return r.getVideoUrl()}}),Object.defineProperty(e.media,`ended`,{get(){return e.currentTime===e.duration}});let s=r.getAvailablePlaybackRates();e.options.speed=s.filter(t=>e.config.speed.options.includes(t)),e.supported.ui&&t.customControls&&e.media.setAttribute(`tabindex`,-1),L.call(e,e.media,`timeupdate`),L.call(e,e.media,`durationchange`),clearInterval(e.timers.buffering),e.timers.buffering=setInterval(()=>{e.media.buffered=r.getVideoLoadedFraction(),(e.media.lastBuffered===null||e.media.lastBuffered<e.media.buffered)&&L.call(e,e.media,`progress`),e.media.lastBuffered=e.media.buffered,e.media.buffered===1&&(clearInterval(e.timers.buffering),L.call(e,e.media,`canplaythrough`))},200),t.customControls&&setTimeout(()=>X.build.call(e),50)},onStateChange(n){let r=n.target;switch(clearInterval(e.timers.playing),e.media.seeking&&[1,2].includes(n.data)&&(e.media.seeking=!1,L.call(e,e.media,`seeked`)),n.data){case-1:L.call(e,e.media,`timeupdate`),e.media.buffered=r.getVideoLoadedFraction(),L.call(e,e.media,`progress`);break;case 0:$.call(e,!1),e.media.loop?(r.stopVideo(),r.playVideo()):L.call(e,e.media,`ended`);break;case 1:t.customControls&&!e.config.autoplay&&e.media.paused&&!e.embed.hasPlayed?e.media.pause():($.call(e,!0),L.call(e,e.media,`playing`),e.timers.playing=setInterval(()=>{L.call(e,e.media,`timeupdate`)},50),e.media.duration!==r.getDuration()&&(e.media.duration=r.getDuration(),L.call(e,e.media,`durationchange`)));break;case 2:e.muted||e.embed.unMute(),$.call(e,!1);break;case 3:L.call(e,e.media,`waiting`);break}L.call(e,e.elements.container,`statechange`,!1,{code:n.data})}}})}},Rt={setup(){if(!this.media){this.debug.warn(`No media element found!`);return}k(this.elements.container,this.config.classNames.type.replace(`{0}`,this.type),!0),k(this.elements.container,this.config.classNames.provider.replace(`{0}`,this.provider),!0),this.isEmbed&&k(this.elements.container,this.config.classNames.type.replace(`{0}`,`video`),!0),this.isVideo&&(this.elements.wrapper=C(`div`,{class:this.config.classNames.video}),Fe(this.media,this.elements.wrapper),this.elements.poster=C(`div`,{class:this.config.classNames.poster}),this.elements.wrapper.appendChild(this.elements.poster)),this.isHTML5?V.setup.call(this):this.isYouTube?Lt.setup.call(this):this.isVimeo&&Pt.setup.call(this)}};function zt(e){e.manager&&e.manager.destroy(),e.elements.displayContainer&&e.elements.displayContainer.destroy(),e.elements.container.remove()}var Bt=class{constructor(e){o(this,`load`,()=>{this.enabled&&(!x.object(window.google)||!x.object(window.google.ima)?jt(this.player.config.urls.googleIMA.sdk).then(()=>{this.ready()}).catch(()=>{this.trigger(`error`,Error(`Google IMA SDK failed to load`))}):this.ready())}),o(this,`ready`,()=>{this.enabled||zt(this),this.startSafetyTimer(12e3,`ready()`),this.managerPromise.then(()=>{this.clearSafetyTimer(`onAdsManagerLoaded()`)}),this.listeners(),this.setupIMA()}),o(this,`setupIMA`,()=>{this.elements.container=C(`div`,{class:this.player.config.classNames.ads}),this.player.elements.container.appendChild(this.elements.container),google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),google.ima.settings.setLocale(this.player.config.ads.language),google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.player.config.playsinline),this.elements.displayContainer=new google.ima.AdDisplayContainer(this.elements.container,this.player.media),this.loader=new google.ima.AdsLoader(this.elements.displayContainer),this.loader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>this.onAdsManagerLoaded(e),!1),this.loader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,e=>this.onAdError(e),!1),this.requestAds()}),o(this,`requestAds`,()=>{let{container:e}=this.player.elements;try{let t=new google.ima.AdsRequest;t.adTagUrl=this.tagUrl,t.linearAdSlotWidth=e.offsetWidth,t.linearAdSlotHeight=e.offsetHeight,t.nonLinearAdSlotWidth=e.offsetWidth,t.nonLinearAdSlotHeight=e.offsetHeight,t.forceNonLinearFullSlot=!1,t.setAdWillPlayMuted(!this.player.muted),this.loader.requestAds(t)}catch(e){this.onAdError(e)}}),o(this,`pollCountdown`,(e=!1)=>{if(!e){clearInterval(this.countdownTimer),this.elements.container.removeAttribute(`data-badge-text`);return}let t=()=>{let e=K(Math.max(this.manager.getRemainingTime(),0)),t=`${W.get(`advertisement`,this.player.config)} - ${e}`;this.elements.container.setAttribute(`data-badge-text`,t)};this.countdownTimer=setInterval(t,100)}),o(this,`onAdsManagerLoaded`,e=>{if(!this.enabled)return;let t=new google.ima.AdsRenderingSettings;t.restoreCustomPlaybackStateOnAdBreakComplete=!0,t.enablePreloading=!0,this.manager=e.getAdsManager(this.player,t),this.cuePoints=this.manager.getCuePoints(),this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,e=>this.onAdError(e)),Object.keys(google.ima.AdEvent.Type).forEach(e=>{this.manager.addEventListener(google.ima.AdEvent.Type[e],e=>this.onAdEvent(e))}),this.trigger(`loaded`)}),o(this,`addCuePoints`,()=>{x.empty(this.cuePoints)||this.cuePoints.forEach(e=>{if(e!==0&&e!==-1&&e<this.player.duration){let t=this.player.elements.progress;if(x.element(t)){let n=100/this.player.duration*e,r=C(`span`,{class:this.player.config.classNames.cues});r.style.left=`${n.toString()}%`,t.appendChild(r)}}})}),o(this,`onAdEvent`,e=>{let{container:t}=this.player.elements,n=e.getAd(),r=e.getAdData();switch((e=>{L.call(this.player,this.player.media,`ads${e.replace(/_/g,``).toLowerCase()}`)})(e.type),e.type){case google.ima.AdEvent.Type.LOADED:this.trigger(`loaded`),this.pollCountdown(!0),n.isLinear()||(n.width=t.offsetWidth,n.height=t.offsetHeight);break;case google.ima.AdEvent.Type.STARTED:this.manager.setVolume(this.player.volume);break;case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:this.player.ended?this.loadAds():this.loader.contentComplete();break;case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:this.pauseContent();break;case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:this.pollCountdown(),this.resumeContent();break;case google.ima.AdEvent.Type.LOG:r.adError&&this.player.debug.warn(`Non-fatal ad error: ${r.adError.getMessage()}`);break}}),o(this,`onAdError`,e=>{this.cancel(),this.player.debug.warn(`Ads error`,e)}),o(this,`listeners`,()=>{let{container:e}=this.player.elements,t;this.player.on(`canplay`,()=>{this.addCuePoints()}),this.player.on(`ended`,()=>{this.loader.contentComplete()}),this.player.on(`timeupdate`,()=>{t=this.player.currentTime}),this.player.on(`seeked`,()=>{let e=this.player.currentTime;x.empty(this.cuePoints)||this.cuePoints.forEach((n,r)=>{t<n&&n<e&&(this.manager.discardAdBreak(),this.cuePoints.splice(r,1))})}),window.addEventListener(`resize`,()=>{this.manager&&this.manager.resize(e.offsetWidth,e.offsetHeight,google.ima.ViewMode.NORMAL)})}),o(this,`play`,()=>{let{container:e}=this.player.elements;this.managerPromise||this.resumeContent(),this.managerPromise.then(()=>{this.manager.setVolume(this.player.volume),this.elements.displayContainer.initialize();try{this.initialized||(this.manager.init(e.offsetWidth,e.offsetHeight,google.ima.ViewMode.NORMAL),this.manager.start()),this.initialized=!0}catch(e){this.onAdError(e)}}).catch(()=>{})}),o(this,`resumeContent`,()=>{this.elements.container.style.zIndex=``,this.playing=!1,R(this.player.media.play())}),o(this,`pauseContent`,()=>{this.elements.container.style.zIndex=3,this.playing=!0,this.player.media.pause()}),o(this,`cancel`,()=>{this.initialized&&this.resumeContent(),this.trigger(`error`),this.loadAds()}),o(this,`loadAds`,()=>{this.managerPromise.then(()=>{this.manager&&this.manager.destroy(),this.managerPromise=new Promise(e=>{this.on(`loaded`,e),this.player.debug.log(this.manager)}),this.initialized=!1,this.requestAds()}).catch(()=>{})}),o(this,`trigger`,(e,...t)=>{let n=this.events[e];x.array(n)&&n.forEach(e=>{x.function(e)&&e.apply(this,t)})}),o(this,`on`,(e,t)=>(x.array(this.events[e])||(this.events[e]=[]),this.events[e].push(t),this)),o(this,`startSafetyTimer`,(e,t)=>{this.player.debug.log(`Safety timer invoked from: ${t}`),this.safetyTimer=setTimeout(()=>{this.cancel(),this.clearSafetyTimer(`startSafetyTimer()`)},e)}),o(this,`clearSafetyTimer`,e=>{x.nullOrUndefined(this.safetyTimer)||(this.player.debug.log(`Safety timer cleared from: ${e}`),clearTimeout(this.safetyTimer),this.safetyTimer=null)}),this.player=e,this.config=e.config.ads,this.playing=!1,this.initialized=!1,this.elements={container:null,displayContainer:null},this.manager=null,this.loader=null,this.cuePoints=null,this.events={},this.safetyTimer=null,this.countdownTimer=null,this.managerPromise=new Promise((e,t)=>{this.on(`loaded`,e),this.on(`error`,t)}),this.load()}get enabled(){let{config:e}=this;return this.player.isHTML5&&this.player.isVideo&&e.enabled&&(!x.empty(e.publisherId)||x.url(e.tagUrl))}get tagUrl(){let{config:e}=this;return x.url(e.tagUrl)?e.tagUrl:`https://go.aniview.com/api/adserver6/vast/?${gt({AV_PUBLISHERID:`58c25bb0073ef448b1087ad6`,AV_CHANNELID:`5a0458dc28a06145e4519d21`,AV_URL:window.location.hostname,cb:Date.now(),AV_WIDTH:640,AV_HEIGHT:480,AV_CDIM2:e.publisherId})}`}};function Vt(e=0,t=0,n=255){return Math.min(Math.max(e,t),n)}function Ht(e){let t=[];return e.split(/\r\n\r\n|\n\n|\r\r/).forEach(e=>{let n={};e.split(/\r\n|\n|\r/).forEach(e=>{if(!x.number(n.startTime)){let t=e.match(/(\d{2})?:?(\d{2}):(\d{2}).(\d{2,3})( ?--> ?)(\d{2})?:?(\d{2}):(\d{2}).(\d{2,3})/);t&&(n.startTime=Number(t[1]||0)*60*60+Number(t[2])*60+Number(t[3])+Number(`0.${t[4]}`),n.endTime=Number(t[6]||0)*60*60+Number(t[7])*60+Number(t[8])+Number(`0.${t[9]}`))}else if(!x.empty(e.trim())&&x.empty(n.text)){let t=e.trim().split(`#xywh=`);[n.text]=t,t[1]&&([n.x,n.y,n.w,n.h]=t[1].split(`,`))}}),n.text&&t.push(n)}),t}function Ut(e,t){let n=t.width/t.height,r={};return e>n?(r.width=t.width,r.height=1/e*t.width):(r.height=t.height,r.width=e*t.height),r}var Wt=class{constructor(e){o(this,`load`,()=>{this.player.elements.display.seekTooltip&&(this.player.elements.display.seekTooltip.hidden=this.enabled),this.enabled&&this.getThumbnails().then(()=>{this.enabled&&(this.render(),this.determineContainerAutoSizing(),this.listeners(),this.loaded=!0)})}),o(this,`getThumbnails`,()=>new Promise(e=>{let{src:t}=this.player.config.previewThumbnails;if(x.empty(t))throw Error(`Missing previewThumbnails.src config attribute`);let n=()=>{this.thumbnails.sort((e,t)=>e.height-t.height),this.player.debug.log(`Preview thumbnails`,this.thumbnails),e()};if(x.function(t))t(e=>{this.thumbnails=e,n()});else{let e=(x.string(t)?[t]:t).map(e=>this.getThumbnail(e));Promise.all(e).then(n)}})),o(this,`getThumbnail`,e=>new Promise(t=>{G(e,void 0,this.player.config.previewThumbnails.withCredentials).then(n=>{let r={frames:Ht(n),height:null,urlPrefix:``};!r.frames[0].text.startsWith(`/`)&&!r.frames[0].text.startsWith(`http://`)&&!r.frames[0].text.startsWith(`https://`)&&(r.urlPrefix=e.substring(0,e.lastIndexOf(`/`)+1));let i=new Image;i.onload=()=>{r.height=i.naturalHeight,r.width=i.naturalWidth,this.thumbnails.push(r),t()},i.src=r.urlPrefix+r.frames[0].text})})),o(this,`startMove`,e=>{if(this.loaded&&!(!x.event(e)||![`touchmove`,`mousemove`].includes(e.type))&&this.player.media.duration){if(e.type===`touchmove`)this.seekTime=this.player.media.duration*(this.player.elements.inputs.seek.value/100);else{let t=this.player.elements.progress.getBoundingClientRect(),n=100/t.width*(e.pageX-t.left);this.seekTime=this.player.media.duration*(n/100),this.seekTime<0&&(this.seekTime=0),this.seekTime>this.player.media.duration-1&&(this.seekTime=this.player.media.duration-1),this.mousePosX=e.pageX,this.elements.thumb.time.textContent=K(this.seekTime);let r=this.player.config.markers?.points?.find(({time:e})=>e===Math.round(this.seekTime));r&&this.elements.thumb.time.insertAdjacentHTML(`afterbegin`,`${r.label}<br>`)}this.showImageAtCurrentTime()}}),o(this,`endMove`,()=>{this.toggleThumbContainer(!1,!0)}),o(this,`startScrubbing`,e=>{(x.nullOrUndefined(e.button)||e.button===!1||e.button===0)&&(this.mouseDown=!0,this.player.media.duration&&(this.toggleScrubbingContainer(!0),this.toggleThumbContainer(!1,!0),this.showImageAtCurrentTime()))}),o(this,`endScrubbing`,()=>{this.mouseDown=!1,Math.ceil(this.lastTime)===Math.ceil(this.player.media.currentTime)?this.toggleScrubbingContainer(!1):We.call(this.player,this.player.media,`timeupdate`,()=>{this.mouseDown||this.toggleScrubbingContainer(!1)})}),o(this,`listeners`,()=>{this.player.on(`play`,()=>{this.toggleThumbContainer(!1,!0)}),this.player.on(`seeked`,()=>{this.toggleThumbContainer(!1)}),this.player.on(`timeupdate`,()=>{this.lastTime=this.player.media.currentTime})}),o(this,`render`,()=>{this.elements.thumb.container=C(`div`,{class:this.player.config.classNames.previewThumbnails.thumbContainer}),this.elements.thumb.imageContainer=C(`div`,{class:this.player.config.classNames.previewThumbnails.imageContainer}),this.elements.thumb.container.appendChild(this.elements.thumb.imageContainer);let e=C(`div`,{class:this.player.config.classNames.previewThumbnails.timeContainer});this.elements.thumb.time=C(`span`,{},`00:00`),e.appendChild(this.elements.thumb.time),this.elements.thumb.imageContainer.appendChild(e),x.element(this.player.elements.progress)&&this.player.elements.progress.appendChild(this.elements.thumb.container),this.elements.scrubbing.container=C(`div`,{class:this.player.config.classNames.previewThumbnails.scrubbingContainer}),this.player.elements.wrapper.appendChild(this.elements.scrubbing.container)}),o(this,`destroy`,()=>{this.elements.thumb.container&&this.elements.thumb.container.remove(),this.elements.scrubbing.container&&this.elements.scrubbing.container.remove()}),o(this,`showImageAtCurrentTime`,()=>{this.mouseDown?this.setScrubbingContainerSize():this.setThumbContainerSizeAndPos();let e=this.thumbnails[0].frames.findIndex(e=>this.seekTime>=e.startTime&&this.seekTime<=e.endTime),t=e>=0,n=0;this.mouseDown||this.toggleThumbContainer(t),t&&(this.thumbnails.forEach((t,r)=>{this.loadedImages.includes(t.frames[e].text)&&(n=r)}),e!==this.showingThumb&&(this.showingThumb=e,this.loadImage(n)))}),o(this,`loadImage`,(e=0)=>{let t=this.showingThumb,n=this.thumbnails[e],{urlPrefix:r}=n,i=n.frames[t],a=n.frames[t].text,o=r+a;if(!this.currentImageElement||this.currentImageElement.dataset.filename!==a){this.loadingImage&&this.usingSprites&&(this.loadingImage.onload=null);let n=new Image;n.src=o,n.dataset.index=t,n.dataset.filename=a,this.showingThumbFilename=a,this.player.debug.log(`Loading image: ${o}`),n.onload=()=>this.showImage(n,i,e,t,a,!0),this.loadingImage=n,this.removeOldImages(n)}else this.showImage(this.currentImageElement,i,e,t,a,!1),this.currentImageElement.dataset.index=t,this.removeOldImages(this.currentImageElement)}),o(this,`showImage`,(e,t,n,r,i,a=!0)=>{this.player.debug.log(`Showing thumb: ${i}. num: ${r}. qual: ${n}. newimg: ${a}`),this.setImageSizeAndOffset(e,t),a&&(this.currentImageContainer.appendChild(e),this.currentImageElement=e,this.loadedImages.includes(i)||this.loadedImages.push(i)),this.preloadNearby(r,!0).then(this.preloadNearby(r,!1)).then(this.getHigherQuality(n,e,t,i))}),o(this,`removeOldImages`,e=>{Array.from(this.currentImageContainer.children).forEach(t=>{if(t.tagName.toLowerCase()!==`img`)return;let n=this.usingSprites?500:1e3;if(t.dataset.index!==e.dataset.index&&!t.dataset.deleting){t.dataset.deleting=!0;let{currentImageContainer:e}=this;setTimeout(()=>{e.removeChild(t),this.player.debug.log(`Removing thumb: ${t.dataset.filename}`)},n)}})}),o(this,`preloadNearby`,(e,t=!0)=>new Promise(n=>{setTimeout(()=>{let r=this.thumbnails[0].frames[e].text;if(this.showingThumbFilename===r){let i;i=t?this.thumbnails[0].frames.slice(e):this.thumbnails[0].frames.slice(0,e).reverse();let a=!1;i.forEach(e=>{let t=e.text;if(t!==r&&!this.loadedImages.includes(t)){a=!0,this.player.debug.log(`Preloading thumb filename: ${t}`);let{urlPrefix:e}=this.thumbnails[0],r=e+t,i=new Image;i.src=r,i.onload=()=>{this.player.debug.log(`Preloaded thumb filename: ${t}`),this.loadedImages.includes(t)||this.loadedImages.push(t),n()}}}),a||n()}},300)})),o(this,`getHigherQuality`,(e,t,n,r)=>{if(e<this.thumbnails.length-1){let i=t.naturalHeight;this.usingSprites&&(i=n.h),i<this.thumbContainerHeight&&setTimeout(()=>{this.showingThumbFilename===r&&(this.player.debug.log(`Showing higher quality thumb for: ${r}`),this.loadImage(e+1))},300)}}),o(this,`toggleThumbContainer`,(e=!1,t=!1)=>{let n=this.player.config.classNames.previewThumbnails.thumbContainerShown;this.elements.thumb.container.classList.toggle(n,e),!e&&t&&(this.showingThumb=null,this.showingThumbFilename=null)}),o(this,`toggleScrubbingContainer`,(e=!1)=>{let t=this.player.config.classNames.previewThumbnails.scrubbingContainerShown;this.elements.scrubbing.container.classList.toggle(t,e),e||(this.showingThumb=null,this.showingThumbFilename=null)}),o(this,`determineContainerAutoSizing`,()=>{(this.elements.thumb.imageContainer.clientHeight>20||this.elements.thumb.imageContainer.clientWidth>20)&&(this.sizeSpecifiedInCSS=!0)}),o(this,`setThumbContainerSizeAndPos`,()=>{let{imageContainer:e}=this.elements.thumb;if(!this.sizeSpecifiedInCSS){let t=Math.floor(this.thumbContainerHeight*this.thumbAspectRatio);e.style.height=`${this.thumbContainerHeight}px`,e.style.width=`${t}px`}else if(e.clientHeight>20&&e.clientWidth<20){let t=Math.floor(e.clientHeight*this.thumbAspectRatio);e.style.width=`${t}px`}else if(e.clientHeight<20&&e.clientWidth>20){let t=Math.floor(e.clientWidth/this.thumbAspectRatio);e.style.height=`${t}px`}this.setThumbContainerPos()}),o(this,`setThumbContainerPos`,()=>{let e=this.player.elements.progress.getBoundingClientRect(),t=this.player.elements.container.getBoundingClientRect(),{container:n}=this.elements.thumb,r=t.left-e.left+10,i=t.right-e.left-n.clientWidth-10,a=this.mousePosX-e.left-n.clientWidth/2,o=Vt(a,r,i);n.style.left=`${o}px`,n.style.setProperty(`--preview-arrow-offset`,`${a-o}px`)}),o(this,`setScrubbingContainerSize`,()=>{let{width:e,height:t}=Ut(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});this.elements.scrubbing.container.style.width=`${e}px`,this.elements.scrubbing.container.style.height=`${t}px`}),o(this,`setImageSizeAndOffset`,(e,t)=>{if(!this.usingSprites)return;let n=this.thumbContainerHeight/t.h;e.style.height=`${e.naturalHeight*n}px`,e.style.width=`${e.naturalWidth*n}px`,e.style.left=`-${t.x*n}px`,e.style.top=`-${t.y*n}px`}),this.player=e,this.thumbnails=[],this.loaded=!1,this.lastMouseMoveTime=Date.now(),this.mouseDown=!1,this.loadedImages=[],this.elements={thumb:{},scrubbing:{}},this.load()}get enabled(){return this.player.isHTML5&&this.player.isVideo&&this.player.config.previewThumbnails.enabled}get currentImageContainer(){return this.mouseDown?this.elements.scrubbing.container:this.elements.thumb.imageContainer}get usingSprites(){return Object.keys(this.thumbnails[0].frames[0]).includes(`w`)}get thumbAspectRatio(){return this.usingSprites?this.thumbnails[0].frames[0].w/this.thumbnails[0].frames[0].h:this.thumbnails[0].width/this.thumbnails[0].height}get thumbContainerHeight(){if(this.mouseDown){let{height:e}=Ut(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});return e}return this.sizeSpecifiedInCSS?this.elements.thumb.imageContainer.clientHeight:Math.floor(this.player.media.clientWidth/this.thumbAspectRatio/4)}get currentImageElement(){return this.mouseDown?this.currentScrubbingImageElement:this.currentThumbnailImageElement}set currentImageElement(e){this.mouseDown?this.currentScrubbingImageElement=e:this.currentThumbnailImageElement=e}},Gt={insertElements(e,t){x.string(t)?Re(e,this.media,{src:t}):x.array(t)&&t.forEach(t=>{Re(e,this.media,t)})},change(e){if(!Pe(e,`sources.length`)){this.debug.warn(`Invalid source format`);return}V.cancelRequests.call(this),this.destroy(()=>{this.options.quality=[],w(this.media),this.media=null,x.element(this.elements.container)&&this.elements.container.removeAttribute(`class`);let{sources:t,type:n}=e,[{provider:r=Y.html5,src:i}]=t,a=r===`html5`?n:`div`,o=r===`html5`?{}:{src:i};Object.assign(this,{provider:r,type:n,supported:N.check(n,r,this.config.playsinline),media:C(a,o)}),this.elements.container.appendChild(this.media),x.boolean(e.autoplay)&&(this.config.autoplay=e.autoplay),this.isHTML5&&(this.config.crossorigin&&this.media.setAttribute(`crossorigin`,``),this.config.autoplay&&this.media.setAttribute(`autoplay`,``),x.empty(e.poster)||(this.poster=e.poster),this.config.loop.active&&this.media.setAttribute(`loop`,``),this.config.muted&&this.media.setAttribute(`muted`,``),this.config.playsinline&&this.media.setAttribute(`playsinline`,``)),X.addStyleHook.call(this),this.isHTML5&&Gt.insertElements.call(this,`source`,t),this.config.title=e.title,Rt.setup.call(this),this.isHTML5&&Object.keys(e).includes(`tracks`)&&Gt.insertElements.call(this,`track`,e.tracks),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&X.build.call(this),this.isHTML5&&this.media.load(),x.empty(e.previewThumbnails)||(Object.assign(this.config.previewThumbnails,e.previewThumbnails),this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new Wt(this))),this.fullscreen.update()},!0)}},Kt=class e{constructor(t,n){if(o(this,`play`,()=>x.function(this.media.play)?(this.ads&&this.ads.enabled&&this.ads.managerPromise.then(()=>this.ads.play()).catch(()=>R(this.media.play())),this.media.play()):null),o(this,`pause`,()=>!this.playing||!x.function(this.media.pause)?null:this.media.pause()),o(this,`togglePlay`,e=>(x.boolean(e)?e:!this.playing)?this.play():this.pause()),o(this,`stop`,()=>{this.isHTML5?(this.pause(),this.restart()):x.function(this.media.stop)&&this.media.stop()}),o(this,`restart`,()=>{this.currentTime=0}),o(this,`rewind`,e=>{this.currentTime-=x.number(e)?e:this.config.seekTime}),o(this,`forward`,e=>{this.currentTime+=x.number(e)?e:this.config.seekTime}),o(this,`increaseVolume`,e=>{let t=this.media.muted?0:this.volume;this.volume=t+(x.number(e)?e:0)}),o(this,`decreaseVolume`,e=>{this.increaseVolume(-e)}),o(this,`airplay`,()=>{N.airplay&&this.media.webkitShowPlaybackTargetPicker()}),o(this,`toggleControls`,e=>{if(this.supported.ui&&!this.isAudio){let t=ze(this.elements.container,this.config.classNames.hideControls),n=e===void 0?void 0:!e,r=k(this.elements.container,this.config.classNames.hideControls,n);if(r&&x.array(this.config.controls)&&this.config.controls.includes(`settings`)&&!x.empty(this.config.settings)&&q.toggleMenu.call(this,!1),r!==t){let e=r?`controlshidden`:`controlsshown`;L.call(this,this.media,e)}return!r}return!1}),o(this,`on`,(e,t)=>{F.call(this,this.elements.container,e,t)}),o(this,`once`,(e,t)=>{We.call(this,this.elements.container,e,t)}),o(this,`off`,(e,t)=>{I(this.elements.container,e,t)}),o(this,`destroy`,(e,t=!1)=>{if(!this.ready)return;let n=()=>{document.body.style.overflow=``,this.embed=null,t?(Object.keys(this.elements).length&&(w(this.elements.buttons.play),w(this.elements.captions),w(this.elements.controls),w(this.elements.wrapper),this.elements.buttons.play=null,this.elements.captions=null,this.elements.controls=null,this.elements.wrapper=null),x.function(e)&&e()):(Ge.call(this),V.cancelRequests.call(this),E(this.elements.original,this.elements.container),L.call(this,this.elements.original,`destroyed`,!0),x.function(e)&&e.call(this.elements.original),this.ready=!1,setTimeout(()=>{this.elements=null,this.media=null},200))};this.stop(),clearTimeout(this.timers.loading),clearTimeout(this.timers.controls),clearTimeout(this.timers.resized),this.isHTML5?(X.toggleNativeControls.call(this,!0),n()):this.isYouTube?(clearInterval(this.timers.buffering),clearInterval(this.timers.playing),this.embed!==null&&x.function(this.embed.destroy)&&this.embed.destroy(),n()):this.isVimeo&&(this.embed!==null&&this.embed.unload().then(n),setTimeout(n,200))}),o(this,`supports`,e=>N.mime.call(this,e)),this.timers={},this.ready=!1,this.loading=!1,this.failed=!1,this.touch=N.touch,this.media=t,x.string(this.media)&&(this.media=document.querySelectorAll(this.media)),(window.jQuery&&this.media instanceof jQuery||x.nodeList(this.media)||x.array(this.media))&&(this.media=this.media[0]),this.config=S({},_t,e.defaults,n||{},(()=>{try{return JSON.parse(this.media.getAttribute(`data-plyr-config`))}catch{return{}}})()),this.elements={container:null,fullscreen:null,captions:null,buttons:{},display:{},progress:{},inputs:{},settings:{popup:null,menu:null,panels:{},buttons:{}}},this.captions={active:null,currentTrack:-1,meta:new WeakMap},this.fullscreen={active:!1},this.options={speed:[],quality:[]},this.debug=new St(this.config.debug),this.debug.log(`Config`,this.config),this.debug.log(`Support`,N),x.nullOrUndefined(this.media)||!x.element(this.media)){this.debug.error(`Setup failed: no suitable element passed`);return}if(this.media.plyr){this.debug.warn(`Target already setup`);return}if(!this.config.enabled){this.debug.error(`Setup failed: disabled by config`);return}if(!N.check().api){this.debug.error(`Setup failed: no support`);return}let r=this.media.cloneNode(!0);r.autoplay=!1,this.elements.original=r;let i=this.media.tagName.toLowerCase(),a=null,s=null;switch(i){case`div`:if(a=this.media.querySelector(`iframe`),x.element(a)){if(s=ht(a.getAttribute(`src`)),this.provider=bt(s.toString()),this.elements.container=this.media,this.media=a,this.elements.container.className=``,s.search.length){let e=[`1`,`true`];e.includes(s.searchParams.get(`autoplay`))&&(this.config.autoplay=!0),e.includes(s.searchParams.get(`loop`))&&(this.config.loop.active=!0),this.isYouTube?(this.config.playsinline=e.includes(s.searchParams.get(`playsinline`)),this.config.youtube.hl=s.searchParams.get(`hl`)):this.config.playsinline=!0}}else this.provider=this.media.getAttribute(this.config.attributes.embed.provider),this.media.removeAttribute(this.config.attributes.embed.provider);if(x.empty(this.provider)||!Object.values(Y).includes(this.provider)){this.debug.error(`Setup failed: Invalid provider`);return}this.type=yt.video;break;case`video`:case`audio`:this.type=i,this.provider=Y.html5,this.media.hasAttribute(`crossorigin`)&&(this.config.crossorigin=!0),this.media.hasAttribute(`autoplay`)&&(this.config.autoplay=!0),(this.media.hasAttribute(`playsinline`)||this.media.hasAttribute(`webkit-playsinline`))&&(this.config.playsinline=!0),this.media.hasAttribute(`muted`)&&(this.config.muted=!0),this.media.hasAttribute(`loop`)&&(this.config.loop.active=!0);break;default:this.debug.error(`Setup failed: unsupported type`);return}if(this.supported=N.check(this.type,this.provider),!this.supported.api){this.debug.error(`Setup failed: no support`);return}this.eventListeners=[],this.listeners=new Tt(this),this.storage=new ut(this),this.media.plyr=this,x.element(this.elements.container)||(this.elements.container=C(`div`),Fe(this.media,this.elements.container)),X.migrateStyles.call(this),X.addStyleHook.call(this),Rt.setup.call(this),this.config.debug&&F.call(this,this.elements.container,this.config.events.join(` `),e=>{this.debug.log(`event: ${e.type}`)}),this.fullscreen=new Ct(this),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&X.build.call(this),this.listeners.container(),this.listeners.global(),this.config.ads.enabled&&(this.ads=new Bt(this)),this.isHTML5&&this.config.autoplay&&this.once(`canplay`,()=>R(this.play())),this.lastSeekTime=0,this.config.previewThumbnails.enabled&&(this.previewThumbnails=new Wt(this))}get isHTML5(){return this.provider===Y.html5}get isEmbed(){return this.isYouTube||this.isVimeo}get isYouTube(){return this.provider===Y.youtube}get isVimeo(){return this.provider===Y.vimeo}get isVideo(){return this.type===yt.video}get isAudio(){return this.type===yt.audio}get playing(){return!!(this.ready&&!this.paused&&!this.ended)}get paused(){return!!this.media.paused}get stopped(){return!!(this.paused&&this.currentTime===0)}get ended(){return!!this.media.ended}set currentTime(e){if(!this.duration)return;let t=x.number(e)&&e>0;this.media.currentTime=t?Math.min(e,this.duration):0,this.debug.log(`Seeking to ${this.currentTime} seconds`)}get currentTime(){return Number(this.media.currentTime)}get buffered(){let{buffered:e}=this.media;return x.number(e)?e:e&&e.length&&this.duration>0?e.end(0)/this.duration:0}get seeking(){return!!this.media.seeking}get duration(){let e=Number.parseFloat(this.config.duration),t=(this.media||{}).duration,n=!x.number(t)||t===1/0?0:t;return e||n}set volume(e){let t=e;x.string(t)&&(t=Number(t)),x.number(t)||(t=this.storage.get(`volume`)),x.number(t)||({volume:t}=this.config),t>1&&(t=1),t<0&&(t=0),this.config.volume=t,this.media.volume=t,!x.empty(e)&&this.muted&&t>0&&(this.muted=!1)}get volume(){return Number(this.media.volume)}set muted(e){let t=e;x.boolean(t)||(t=this.storage.get(`muted`)),x.boolean(t)||(t=this.config.muted),this.config.muted=t,this.media.muted=t}get muted(){return!!this.media.muted}get hasAudio(){return!this.isHTML5||this.isAudio?!0:!!this.media.mozHasAudio||!!this.media.webkitAudioDecodedByteCount||!!(this.media.audioTracks&&this.media.audioTracks.length)}set speed(e){let t=null;x.number(e)&&(t=e),x.number(t)||(t=this.storage.get(`speed`)),x.number(t)||(t=this.config.speed.selected);let{minimumSpeed:n,maximumSpeed:r}=this;t=Vt(t,n,r),this.config.speed.selected=t,setTimeout(()=>{this.media&&(this.media.playbackRate=t)},0)}get speed(){return Number(this.media.playbackRate)}get minimumSpeed(){return this.isYouTube?Math.min(...this.options.speed):this.isVimeo?.5:.0625}get maximumSpeed(){return this.isYouTube?Math.max(...this.options.speed):this.isVimeo?2:16}set quality(e){let t=this.config.quality,n=this.options.quality;if(!n.length)return;let r=[!x.empty(e)&&Number(e),this.storage.get(`quality`),t.selected,t.default].find(x.number),i=!0;if(!n.includes(r)){let e=Je(n,r);this.debug.warn(`Unsupported quality option: ${r}, using ${e} instead`),r=e,i=!1}t.selected=r,this.media.quality=r,i&&this.storage.set({quality:r})}get quality(){return this.media.quality}set loop(e){let t=x.boolean(e)?e:this.config.loop.active;this.config.loop.active=t,this.media.loop=t}get loop(){return!!this.media.loop}set source(e){Gt.change.call(this,e)}get source(){return this.media.currentSrc}get download(){let{download:e}=this.config.urls;return x.url(e)?e:this.source}set download(e){x.url(e)&&(this.config.urls.download=e,q.setDownloadUrl.call(this))}set poster(e){if(!this.isVideo){this.debug.warn(`Poster can only be set for video`);return}X.setPoster.call(this,e,!1).catch(()=>{})}get poster(){return this.isVideo?this.media.getAttribute(`poster`)||this.media.getAttribute(`data-poster`):null}get ratio(){if(!this.isVideo)return null;let e=z(Qe.call(this));return x.array(e)?e.join(`:`):e}set ratio(e){if(!this.isVideo){this.debug.warn(`Aspect ratio can only be set for video`);return}if(!x.string(e)||!Ze(e)){this.debug.error(`Invalid aspect ratio specified (${e})`);return}this.config.ratio=z(e),B.call(this)}set autoplay(e){this.config.autoplay=x.boolean(e)?e:this.config.autoplay}get autoplay(){return!!this.config.autoplay}toggleCaptions(e){J.toggle.call(this,e,!1)}set currentTrack(e){J.set.call(this,e,!1),J.setup.call(this)}get currentTrack(){let{toggled:e,currentTrack:t}=this.captions;return e?t:-1}set language(e){J.setLanguage.call(this,e,!1)}get language(){return(J.getCurrentTrack.call(this)||{}).language}set pip(e){if(!N.pip)return;let t=x.boolean(e)?e:!this.pip;x.function(this.media.webkitSetPresentationMode)&&this.media.webkitSetPresentationMode(t?vt.active:vt.inactive),x.function(this.media.requestPictureInPicture)&&(!this.pip&&t?this.media.requestPictureInPicture():this.pip&&!t&&document.exitPictureInPicture())}get pip(){return N.pip?x.empty(this.media.webkitPresentationMode)?this.media===document.pictureInPictureElement:this.media.webkitPresentationMode===vt.active:null}setPreviewThumbnails(e){this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),Object.assign(this.config.previewThumbnails,e),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new Wt(this))}static supported(e,t){return N.check(e,t)}static loadSprite(e,t){return dt(e,t)}static setup(t,n={}){let r=null;return x.string(t)?r=Array.from(document.querySelectorAll(t)):x.nodeList(t)?r=Array.from(t):x.array(t)&&(r=t.filter(x.element)),x.empty(r)?null:r.map(t=>new e(t,n))}};Kt.defaults=Ne(_t);var qt=[`src`],Jt=[`src`],Yt=a({__name:`VideoPlayer`,props:{f:{}},setup(a){let o=t();return n(()=>{new Kt(o.value)}),(t,n)=>(e(),r(`video`,{ref_key:`vid`,ref:o,src:a.f.url,preload:`auto`,loop:``,playsinline:``},[a.f.thumb?(e(),r(`img`,{key:0,src:a.f.thumb,alt:``},null,8,Jt)):i(``,!0)],8,qt))}});export{Yt as default}; |