import{d as Ge,L as Xe,g as D,a7 as Ct,h as Je,O as St,i as Et,o as Oe,w as je,P as Pt,F as Mt,I as De,s as G,X as xt,a3 as Nt,a4 as Lt,a5 as It,a6 as $t}from"./index-1d4a9afa.js";import{c as He}from"./toolsValidate-2f258ec3.js";import{b as _t,c as Ot}from"./index-22c9ea74.js";import{I as jt}from"./index-c272bcfa.js";const Dt="_overlayPreview_5k51b_1",Ht="_imagePreview_5k51b_4",Re={overlayPreview:Dt,imagePreview:Ht},Rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAOVBMVEUAAAAAAADv7+80NDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADj4+PZ2dkAAAAAAABkZGT////w1mHvAAAAEnRSTlNMANxYRiQFOj8xKhkMzLxCHWlXlmF+AAABS0lEQVRYw6WX2ZLCIBBFzyiLBLKY///YcSynUEk6yz2PVu4pMKTp5meFkH2KowM3xuRzWHtuWVC6G1/curJXEPwr3Th8MAQ17ljF+bAlmBwmbjIFJbJJLOuC7NiBy2uCjp10y4LEbtKSIHKA2AoSBsYaMPZv0n0KMofJ74LiOIwrb4LICWIVTJxi+hcExylceAk8J/FPgbmA7SUgLAD8U9DWn3s/XPniOvT3tkb9CQoN/Txfrl/5yzz3NJSHoKNhmKuh5udh6UBTd/D5+MNg/FD3QADLYOchkLENdp6MxzbYeTwJ22DnSURsg50nMmIb7DwjDttg52vcMFh5kAXyFuQ/UX6N8kGSj7L8Mcmfs1pQ5JImF1W1rMsXi3y1qZerfL2rDYba4shNltrmqY2m2urKzbbe7usDhz7y6EOXPvbpg6c++urDtzz+/wLKehSFlfKj2AAAAABJRU5ErkJggg==",Bt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAaVBMVEUAAAAAAAB1dXUAAAAAAAAAAADV1dXV1dUAAAAAAAAAAAAAAAAAAAD7+/t6enqqqqoAAAAAAAAAAAAAAAD9/f37+/v09PSLi4tnZ2cAAADR0dHNzc3y8vLl5eW/v7+cnJxwcHA+Pj7///+d7TGsAAAAInRSTlNMAG9GJAW4tT87MSoZ9HOOQh0PCvn253tqNrOu482ghm1bnhpUjAAAAcZJREFUWMOl19mSgyAQheGTADMgTKLG7JON93/IIY6Waxul/8pFKhW+Ki4UGisi5WRiUgGI1CTSKep/40BuNXppm88FlNQYTUs1A1BSgEzUBA1kApOJbBLYGXzM7GjACcxIOAqwmJkdBxLMLhkDzljQeQgkWFTSBywWZruAw+JcG9iJ5YDYtQADotPhcAKRaYAMVBfvr6DKakDRG/jy/pvehKoAiTgA8h9QIhYQqgQkYgHIEtDxgH4DOeIB5AGwHMAGQHMAvYICB4CC4wEOkgdIUC+Sx7MNPB/UiwWm//xdj9VTtG2ArfcXhI7X/rNpkKLbwRcvADcfhBoI6/0NwKvwB3RLIdAt/HcNYP3zFkqgXP9T/hi+oJsAxgFsSuENlOs3GAdAALXwGz7VegIgtlALoXo9tYWUAhohrCeBFIYGglCtpwGDhAaCsPd+v8EEkEBOATju90dMARKOBppowEHxAIWV5gC6fKUxABuAfABs10TbAZAPX+v+Q70dDA+WYnp9gXZy5Gi7TwrFfeRoW0lEJpvjPSqhmgtGVFn7ihORYV+yuNc87kWTe9VlX7b5133+wMEfefhDF3/s4w+e/NGXP3yzx/8/aHIywATB/+4AAAAASUVORK5CYII=",Vt="_video_1hxfx_1",qt="_loadingVideo_1hxfx_35",ye={"video-container":"_video-container_1hxfx_1",video:Vt,loadingVideo:qt};function m(e,i,t){return(i=Ut(i))in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}function Ft(e,i){if(typeof e!="object"||e===null)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var s=t.call(e,i||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(e)}function Ut(e){var i=Ft(e,"string");return typeof i=="symbol"?i:String(i)}function Wt(e,i){if(!(e instanceof i))throw new TypeError("Cannot call a class as a function")}function Be(e,i){for(var t=0;ti){var t=ii(i);return parseFloat(e.toFixed(t))}return Math.round(e/i)*i}var ni=function(){function e(i,t){Wt(this,e),O.element(i)?this.element=i:O.string(i)&&(this.element=document.querySelector(i)),O.element(this.element)&&O.empty(this.element.rangeTouch)&&(this.config=qe({},Fe,{},t),this.init())}return zt(e,[{key:"init",value:function(){e.enabled&&(this.config.addCSS&&(this.element.style.userSelect="none",this.element.style.webKitUserSelect="none",this.element.style.touchAction="manipulation"),this.listeners(!0),this.element.rangeTouch=this)}},{key:"destroy",value:function(){e.enabled&&(this.config.addCSS&&(this.element.style.userSelect="",this.element.style.webKitUserSelect="",this.element.style.touchAction=""),this.listeners(!1),this.element.rangeTouch=null)}},{key:"listeners",value:function(i){var t=this,s=i?"addEventListener":"removeEventListener";["touchstart","touchmove","touchend"].forEach(function(a){t.element[s](a,function(n){return t.set(n)},!1)})}},{key:"get",value:function(i){if(!e.enabled||!O.event(i))return null;var t,s=i.target,a=i.changedTouches[0],n=parseFloat(s.getAttribute("min"))||0,r=parseFloat(s.getAttribute("max"))||100,o=parseFloat(s.getAttribute("step"))||1,c=s.getBoundingClientRect(),u=100/c.width*(this.config.thumbWidth/2)/100;return 0>(t=100/c.width*(a.clientX-c.left))?t=0:100t?t-=(100-2*t)*u:50e!=null?e.constructor:null,U=(e,i)=>!!(e&&i&&e instanceof i),Ne=e=>e==null,st=e=>ae(e)===Object,ai=e=>ae(e)===Number&&!Number.isNaN(e),pe=e=>ae(e)===String,li=e=>ae(e)===Boolean,nt=e=>typeof e=="function",at=e=>Array.isArray(e),ri=e=>U(e,WeakMap),lt=e=>U(e,NodeList),oi=e=>ae(e)===Text,ci=e=>U(e,Event),ui=e=>U(e,KeyboardEvent),hi=e=>U(e,window.TextTrackCue)||U(e,window.VTTCue),di=e=>U(e,TextTrack)||!Ne(e)&&pe(e.kind),mi=e=>U(e,Promise)&&nt(e.then),pi=e=>e!==null&&typeof e=="object"&&e.nodeType===1&&typeof e.style=="object"&&typeof e.ownerDocument=="object",rt=e=>Ne(e)||(pe(e)||at(e)||lt(e))&&!e.length||st(e)&&!Object.keys(e).length,gi=e=>{if(U(e,window.URL))return!0;if(!pe(e))return!1;let i=e;e.startsWith("http://")&&e.startsWith("https://")||(i=`http://${e}`);try{return!rt(new URL(i).hostname)}catch(t){return!1}};var l={nullOrUndefined:Ne,object:st,number:ai,string:pe,boolean:li,function:nt,array:at,weakMap:ri,nodeList:lt,element:pi,textNode:oi,event:ci,keyboardEvent:ui,cue:hi,track:di,promise:mi,url:gi,empty:rt};const ke=(()=>{const e=document.createElement("span"),i={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},t=Object.keys(i).find(s=>e.style[s]!==void 0);return!!l.string(t)&&i[t]})();function ot(e,i){setTimeout(()=>{try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch(t){}},i)}const fi=!!window.document.documentMode,yi=/Edge/g.test(navigator.userAgent),bi="WebkitAppearance"in document.documentElement.style&&!/Edge/g.test(navigator.userAgent),vi=/iPhone|iPod/gi.test(navigator.userAgent)&&navigator.maxTouchPoints>1,wi=navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,Ai=/iPad|iPhone|iPod/gi.test(navigator.userAgent)&&navigator.maxTouchPoints>1;var _={isIE:fi,isEdge:yi,isWebKit:bi,isIPhone:vi,isIPadOS:wi,isIos:Ai};function ki(e){return JSON.parse(JSON.stringify(e))}function ct(e,i){return i.split(".").reduce((t,s)=>t&&t[s],e)}function x(e={},...i){if(!i.length)return e;const t=i.shift();return l.object(t)?(Object.keys(t).forEach(s=>{l.object(t[s])?(Object.keys(e).includes(s)||Object.assign(e,{[s]:{}}),x(e[s],t[s])):Object.assign(e,{[s]:t[s]})}),x(e,...i)):e}function ut(e,i){const t=e.length?e:[e];Array.from(t).reverse().forEach((s,a)=>{const n=a>0?i.cloneNode(!0):i,r=s.parentNode,o=s.nextSibling;n.appendChild(s),o?r.insertBefore(n,o):r.appendChild(n)})}function Te(e,i){l.element(e)&&!l.empty(i)&&Object.entries(i).filter(([,t])=>!l.nullOrUndefined(t)).forEach(([t,s])=>e.setAttribute(t,s))}function y(e,i,t){const s=document.createElement(e);return l.object(i)&&Te(s,i),l.string(t)&&(s.innerText=t),s}function Ti(e,i){l.element(e)&&l.element(i)&&i.parentNode.insertBefore(e,i.nextSibling)}function Ue(e,i,t,s){l.element(i)&&i.appendChild(y(e,t,s))}function F(e){l.nodeList(e)||l.array(e)?Array.from(e).forEach(F):l.element(e)&&l.element(e.parentNode)&&e.parentNode.removeChild(e)}function oe(e){if(!l.element(e))return;let{length:i}=e.childNodes;for(;i>0;)e.removeChild(e.lastChild),i-=1}function he(e,i){return l.element(i)&&l.element(i.parentNode)&&l.element(e)?(i.parentNode.replaceChild(e,i),e):null}function V(e,i){if(!l.string(e)||l.empty(e))return{};const t={},s=x({},i);return e.split(",").forEach(a=>{const n=a.trim(),r=n.replace(".",""),o=n.replace(/[[\]]/g,"").split("="),[c]=o,u=o.length>1?o[1].replace(/["']/g,""):"";switch(n.charAt(0)){case".":l.string(s.class)?t.class=`${s.class} ${r}`:t.class=r;break;case"#":t.id=n.replace("#","");break;case"[":t[c]=u}}),x(s,t)}function K(e,i){if(!l.element(e))return;let t=i;l.boolean(t)||(t=!e.hidden),e.hidden=t}function E(e,i,t){if(l.nodeList(e))return Array.from(e).map(s=>E(s,i,t));if(l.element(e)){let s="toggle";return t!==void 0&&(s=t?"add":"remove"),e.classList[s](i),e.classList.contains(i)}return!1}function de(e,i){return l.element(e)&&e.classList.contains(i)}function Y(e,i){const{prototype:t}=Element;return(t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||function(){return Array.from(document.querySelectorAll(i)).includes(this)}).call(e,i)}function Ci(e,i){const{prototype:t}=Element;return(t.closest||function(){let s=this;do{if(Y.matches(s,i))return s;s=s.parentElement||s.parentNode}while(s!==null&&s.nodeType===1);return null}).call(e,i)}function ee(e){return this.elements.container.querySelectorAll(e)}function I(e){return this.elements.container.querySelector(e)}function be(e=null,i=!1){l.element(e)&&e.focus({preventScroll:!0,focusVisible:i})}const We={"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,i){const t=N[e]||i!=="html5";return{api:t,ui:t&&N.rangeInput}},pip:!(_.isIPhone||!l.function(y("video").webkitSetPresentationMode)&&(!document.pictureInPictureEnabled||y("video").disablePictureInPicture)),airplay:l.function(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime(e){if(l.empty(e))return!1;const[i]=e.split("/");let t=e;if(!this.isHTML5||i!==this.type)return!1;Object.keys(We).includes(t)&&(t+=`; codecs="${We[e]}"`);try{return!!(t&&this.media.canPlayType(t).replace(/no/,""))}catch(s){return!1}},textTracks:"textTracks"in document.createElement("video"),rangeInput:(()=>{const e=document.createElement("input");return e.type="range",e.type==="range"})(),touch:"ontouchstart"in document.documentElement,transitions:ke!==!1,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},Si=(()=>{let e=!1;try{const i=Object.defineProperty({},"passive",{get:()=>(e=!0,null)});window.addEventListener("test",null,i),window.removeEventListener("test",null,i)}catch(i){}return e})();function te(e,i,t,s=!1,a=!0,n=!1){if(!e||!("addEventListener"in e)||l.empty(i)||!l.function(t))return;const r=i.split(" ");let o=n;Si&&(o={passive:a,capture:n}),r.forEach(c=>{this&&this.eventListeners&&s&&this.eventListeners.push({element:e,type:c,callback:t,options:o}),e[s?"addEventListener":"removeEventListener"](c,t,o)})}function T(e,i="",t,s=!0,a=!1){te.call(this,e,i,t,!0,s,a)}function ge(e,i="",t,s=!0,a=!1){te.call(this,e,i,t,!1,s,a)}function Le(e,i="",t,s=!0,a=!1){const n=(...r)=>{ge(e,i,n,s,a),t.apply(this,r)};te.call(this,e,i,n,!0,s,a)}function b(e,i="",t=!1,s={}){if(!l.element(e)||l.empty(i))return;const a=new CustomEvent(i,{bubbles:t,detail:{...s,plyr:this}});e.dispatchEvent(a)}function Ei(){this&&this.eventListeners&&(this.eventListeners.forEach(e=>{const{element:i,type:t,callback:s,options:a}=e;i.removeEventListener(t,s,a)}),this.eventListeners=[])}function Pi(){return new Promise(e=>this.ready?setTimeout(e,0):T.call(this,this.elements.container,"ready",e)).then(()=>{})}function q(e){l.promise(e)&&e.then(null,()=>{})}function Ce(e){return l.array(e)?e.filter((i,t)=>e.indexOf(i)===t):e}function ht(e,i){return l.array(e)&&e.length?e.reduce((t,s)=>Math.abs(s-i)({...e,[i/t]:[i,t]}),{});function mt(e){return l.array(e)||l.string(e)&&e.includes(":")?(l.array(e)?e:e.split(":")).map(Number).every(l.number):!1}function me(e){if(!l.array(e)||!e.every(l.number))return null;const[i,t]=e,s=(n,r)=>r===0?n:s(r,n%r),a=s(i,t);return[i/a,t/a]}function Ie(e){const i=s=>mt(s)?s.split(":").map(Number):null;let t=i(e);if(t===null&&(t=i(this.config.ratio)),t===null&&!l.empty(this.embed)&&l.array(this.embed.ratio)&&({ratio:t}=this.embed),t===null&&this.isHTML5){const{videoWidth:s,videoHeight:a}=this.media;t=[s,a]}return me(t)}function X(e){if(!this.isVideo)return{};const{wrapper:i}=this.elements,t=Ie.call(this,e);if(!l.array(t))return{};const[s,a]=me(t),n=100/s*a;if(dt(`aspect-ratio: ${s}/${a}`)?i.style.aspectRatio=`${s}/${a}`:i.style.paddingBottom=`${n}%`,this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){const r=100/this.media.offsetWidth*parseInt(window.getComputedStyle(this.media).paddingBottom,10),o=(r-n)/(r/50);this.fullscreen.active?i.style.paddingBottom=null:this.media.style.transform=`translateY(-${o}%)`}else this.isHTML5&&i.classList.add(this.config.classNames.videoFixedRatio);return{padding:n,ratio:t}}function pt(e,i,t=.05){const s=e/i,a=ht(Object.keys(ze),s);return Math.abs(a-s)<=t?ze[a]:[e,i]}function Mi(){return[Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)]}const z={getSources(){return this.isHTML5?Array.from(this.media.querySelectorAll("source")).filter(e=>{const i=e.getAttribute("type");return!!l.empty(i)||N.mime.call(this,i)}):[]},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:z.getSources.call(this).map(e=>Number(e.getAttribute("size"))).filter(Boolean)},setup(){if(!this.isHTML5)return;const e=this;e.options.speed=e.config.speed.options,l.empty(this.config.ratio)||X.call(e),Object.defineProperty(e.media,"quality",{get(){const i=z.getSources.call(e).find(t=>t.getAttribute("src")===e.source);return i&&Number(i.getAttribute("size"))},set(i){if(e.quality!==i){if(e.config.quality.forced&&l.function(e.config.quality.onChange))e.config.quality.onChange(i);else{const t=z.getSources.call(e).find(c=>Number(c.getAttribute("size"))===i);if(!t)return;const{currentTime:s,paused:a,preload:n,readyState:r,playbackRate:o}=e.media;e.media.src=t.getAttribute("src"),(n!=="none"||r)&&(e.once("loadedmetadata",()=>{e.speed=o,e.currentTime=s,a||q(e.play())}),e.media.load())}b.call(e,e.media,"qualitychange",!1,{quality:i})}}})},cancelRequests(){this.isHTML5&&(F(z.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}};function xi(e){return`${e}-${Math.floor(1e4*Math.random())}`}function Se(e,...i){return l.empty(e)?e:e.toString().replace(/{(\d+)}/g,(t,s)=>i[s].toString())}function Ni(e,i){return e===0||i===0||Number.isNaN(e)||Number.isNaN(i)?0:(e/i*100).toFixed(2)}const Z=(e="",i="",t="")=>e.replace(new RegExp(i.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),t.toString()),gt=(e="")=>e.toString().replace(/\w\S*/g,i=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase());function Li(e=""){let i=e.toString();return i=Z(i,"-"," "),i=Z(i,"_"," "),i=gt(i),Z(i," ","")}function Ii(e=""){let i=e.toString();return i=Li(i),i.charAt(0).toLowerCase()+i.slice(1)}function $i(e){const i=document.createDocumentFragment(),t=document.createElement("div");return i.appendChild(t),t.innerHTML=e,i.firstChild.innerText}function _i(e){const i=document.createElement("div");return i.appendChild(e),i.innerHTML}const Ke={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},$={get(e="",i={}){if(l.empty(e)||l.empty(i))return"";let t=ct(i.i18n,e);if(l.empty(t))return Object.keys(Ke).includes(e)?Ke[e]:"";const s={"{seektime}":i.seekTime,"{title}":i.title};return Object.entries(s).forEach(([a,n])=>{t=Z(t,a,n)}),t}};class ie{constructor(i){m(this,"get",t=>{if(!ie.supported||!this.enabled)return null;const s=window.localStorage.getItem(this.key);if(l.empty(s))return null;const a=JSON.parse(s);return l.string(t)&&t.length?a[t]:a}),m(this,"set",t=>{if(!ie.supported||!this.enabled||!l.object(t))return;let s=this.get();l.empty(s)&&(s={}),x(s,t);try{window.localStorage.setItem(this.key,JSON.stringify(s))}catch(a){}}),this.enabled=i.config.storage.enabled,this.key=i.config.storage.key}static get supported(){try{if(!("localStorage"in window))return!1;const i="___test";return window.localStorage.setItem(i,i),window.localStorage.removeItem(i),!0}catch(i){return!1}}}function le(e,i="text"){return new Promise((t,s)=>{try{const a=new XMLHttpRequest;if(!("withCredentials"in a))return;a.addEventListener("load",()=>{if(i==="text")try{t(JSON.parse(a.responseText))}catch(n){t(a.responseText)}else t(a.response)}),a.addEventListener("error",()=>{throw new Error(a.status)}),a.open("GET",e,!0),a.responseType=i,a.send()}catch(a){s(a)}})}function ft(e,i){if(!l.string(e))return;const t="cache",s=l.string(i);let a=!1;const n=()=>document.getElementById(i)!==null,r=(o,c)=>{o.innerHTML=c,s&&n()||document.body.insertAdjacentElement("afterbegin",o)};if(!s||!n()){const o=ie.supported,c=document.createElement("div");if(c.setAttribute("hidden",""),s&&c.setAttribute("id",i),o){const u=window.localStorage.getItem(`${t}-${i}`);if(a=u!==null,a){const g=JSON.parse(u);r(c,g.content)}}le(e).then(u=>{if(!l.empty(u)){if(o)try{window.localStorage.setItem(`${t}-${i}`,JSON.stringify({content:u}))}catch(g){}r(c,u)}}).catch(()=>{})}}const yt=e=>Math.trunc(e/60/60%60,10),Oi=e=>Math.trunc(e/60%60,10),ji=e=>Math.trunc(e%60,10);function fe(e=0,i=!1,t=!1){if(!l.number(e))return fe(void 0,i,t);const s=o=>`0${o}`.slice(-2);let a=yt(e);const n=Oi(e),r=ji(e);return a=i||a>0?`${a}:`:"",`${t&&e>0?"-":""}${a}${s(n)}:${s(r)}`}const h={getIconUrl(){const e=new URL(this.config.iconUrl,window.location),i=window.location.host?window.location.host:window.top.location.host,t=e.host!==i||_.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:t}},findElements(){try{return this.elements.controls=I.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:ee.call(this,this.config.selectors.buttons.play),pause:I.call(this,this.config.selectors.buttons.pause),restart:I.call(this,this.config.selectors.buttons.restart),rewind:I.call(this,this.config.selectors.buttons.rewind),fastForward:I.call(this,this.config.selectors.buttons.fastForward),mute:I.call(this,this.config.selectors.buttons.mute),pip:I.call(this,this.config.selectors.buttons.pip),airplay:I.call(this,this.config.selectors.buttons.airplay),settings:I.call(this,this.config.selectors.buttons.settings),captions:I.call(this,this.config.selectors.buttons.captions),fullscreen:I.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=I.call(this,this.config.selectors.progress),this.elements.inputs={seek:I.call(this,this.config.selectors.inputs.seek),volume:I.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:I.call(this,this.config.selectors.display.buffer),currentTime:I.call(this,this.config.selectors.display.currentTime),duration:I.call(this,this.config.selectors.display.duration)},l.element(this.elements.progress)&&(this.elements.display.seekTooltip=this.elements.progress.querySelector(`.${this.config.classNames.tooltip}`)),!0}catch(e){return this.debug.warn("It looks like there is a problem with your custom controls HTML",e),this.toggleNativeControls(!0),!1}},createIcon(e,i){const t="http://www.w3.org/2000/svg",s=h.getIconUrl.call(this),a=`${s.cors?"":s.url}#${this.config.iconPrefix}`,n=document.createElementNS(t,"svg");Te(n,x(i,{"aria-hidden":"true",focusable:"false"}));const r=document.createElementNS(t,"use"),o=`${a}-${e}`;return"href"in r&&r.setAttributeNS("http://www.w3.org/1999/xlink","href",o),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o),n.appendChild(r),n},createLabel(e,i={}){const t=$.get(e,this.config);return y("span",{...i,class:[i.class,this.config.classNames.hidden].filter(Boolean).join(" ")},t)},createBadge(e){if(l.empty(e))return null;const i=y("span",{class:this.config.classNames.menu.value});return i.appendChild(y("span",{class:this.config.classNames.menu.badge},e)),i},createButton(e,i){const t=x({},i);let s=Ii(e);const a={element:"button",toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch(["element","icon","label"].forEach(r=>{Object.keys(t).includes(r)&&(a[r]=t[r],delete t[r])}),a.element!=="button"||Object.keys(t).includes("type")||(t.type="button"),Object.keys(t).includes("class")?t.class.split(" ").some(r=>r===this.config.classNames.control)||x(t,{class:`${t.class} ${this.config.classNames.control}`}):t.class=this.config.classNames.control,e){case"play":a.toggle=!0,a.label="play",a.labelPressed="pause",a.icon="play",a.iconPressed="pause";break;case"mute":a.toggle=!0,a.label="mute",a.labelPressed="unmute",a.icon="volume",a.iconPressed="muted";break;case"captions":a.toggle=!0,a.label="enableCaptions",a.labelPressed="disableCaptions",a.icon="captions-off",a.iconPressed="captions-on";break;case"fullscreen":a.toggle=!0,a.label="enterFullscreen",a.labelPressed="exitFullscreen",a.icon="enter-fullscreen",a.iconPressed="exit-fullscreen";break;case"play-large":t.class+=` ${this.config.classNames.control}--overlaid`,s="play",a.label="play",a.icon="play";break;default:l.empty(a.label)&&(a.label=s),l.empty(a.icon)&&(a.icon=e)}const n=y(a.element);return a.toggle?(n.appendChild(h.createIcon.call(this,a.iconPressed,{class:"icon--pressed"})),n.appendChild(h.createIcon.call(this,a.icon,{class:"icon--not-pressed"})),n.appendChild(h.createLabel.call(this,a.labelPressed,{class:"label--pressed"})),n.appendChild(h.createLabel.call(this,a.label,{class:"label--not-pressed"}))):(n.appendChild(h.createIcon.call(this,a.icon)),n.appendChild(h.createLabel.call(this,a.label))),x(t,V(this.config.selectors.buttons[s],t)),Te(n,t),s==="play"?(l.array(this.elements.buttons[s])||(this.elements.buttons[s]=[]),this.elements.buttons[s].push(n)):this.elements.buttons[s]=n,n},createRange(e,i){const t=y("input",x(V(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":$.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},i));return this.elements.inputs[e]=t,h.updateRangeFill.call(this,t),ni.setup(t),t},createProgress(e,i){const t=y("progress",x(V(this.config.selectors.display[e]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},i));if(e!=="volume"){t.appendChild(y("span",null,"0"));const s={played:"played",buffer:"buffered"}[e],a=s?$.get(s,this.config):"";t.innerText=`% ${a.toLowerCase()}`}return this.elements.display[e]=t,t},createTime(e,i){const t=V(this.config.selectors.display[e],i),s=y("div",x(t,{class:`${t.class?t.class:""} ${this.config.classNames.display.time} `.trim(),"aria-label":$.get(e,this.config),role:"timer"}),"00:00");return this.elements.display[e]=s,s},bindMenuItemShortcuts(e,i){T.call(this,e,"keydown keyup",t=>{if(![" ","ArrowUp","ArrowDown","ArrowRight"].includes(t.key)||(t.preventDefault(),t.stopPropagation(),t.type==="keydown"))return;const s=Y(e,'[role="menuitemradio"]');if(!s&&[" ","ArrowRight"].includes(t.key))h.showMenuPanel.call(this,i,!0);else{let a;t.key!==" "&&(t.key==="ArrowDown"||s&&t.key==="ArrowRight"?(a=e.nextElementSibling,l.element(a)||(a=e.parentNode.firstElementChild)):(a=e.previousElementSibling,l.element(a)||(a=e.parentNode.lastElementChild)),be.call(this,a,!0))}},!1),T.call(this,e,"keyup",t=>{t.key==="Return"&&h.focusFirstMenuItem.call(this,null,!0)})},createMenuItem({value:e,list:i,type:t,title:s,badge:a=null,checked:n=!1}){const r=V(this.config.selectors.inputs[t]),o=y("button",x(r,{type:"button",role:"menuitemradio",class:`${this.config.classNames.control} ${r.class?r.class:""}`.trim(),"aria-checked":n,value:e})),c=y("span");c.innerHTML=s,l.element(a)&&c.appendChild(a),o.appendChild(c),Object.defineProperty(o,"checked",{enumerable:!0,get:()=>o.getAttribute("aria-checked")==="true",set(u){u&&Array.from(o.parentNode.children).filter(g=>Y(g,'[role="menuitemradio"]')).forEach(g=>g.setAttribute("aria-checked","false")),o.setAttribute("aria-checked",u?"true":"false")}}),this.listeners.bind(o,"click keyup",u=>{if(!l.keyboardEvent(u)||u.key===" "){switch(u.preventDefault(),u.stopPropagation(),o.checked=!0,t){case"language":this.currentTrack=Number(e);break;case"quality":this.quality=e;break;case"speed":this.speed=parseFloat(e)}h.showMenuPanel.call(this,"home",l.keyboardEvent(u))}},t,!1),h.bindMenuItemShortcuts.call(this,o,t),i.appendChild(o)},formatTime(e=0,i=!1){return l.number(e)?fe(e,yt(this.duration)>0,i):e},updateTimeDisplay(e=null,i=0,t=!1){l.element(e)&&l.number(i)&&(e.innerText=h.formatTime(i,t))},updateVolume(){this.supported.ui&&(l.element(this.elements.inputs.volume)&&h.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),l.element(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||this.volume===0))},setRange(e,i=0){l.element(e)&&(e.value=i,h.updateRangeFill.call(this,e))},updateProgress(e){if(!this.supported.ui||!l.event(e))return;let i=0;const t=(s,a)=>{const n=l.number(a)?a:0,r=l.element(s)?s:this.elements.display.buffer;if(l.element(r)){r.value=n;const o=r.getElementsByTagName("span")[0];l.element(o)&&(o.childNodes[0].nodeValue=n)}};if(e)switch(e.type){case"timeupdate":case"seeking":case"seeked":i=Ni(this.currentTime,this.duration),e.type==="timeupdate"&&h.setRange.call(this,this.elements.inputs.seek,i);break;case"playing":case"progress":t(this.elements.display.buffer,100*this.buffered)}},updateRangeFill(e){const i=l.event(e)?e.target:e;if(l.element(i)&&i.getAttribute("type")==="range"){if(Y(i,this.config.selectors.inputs.seek)){i.setAttribute("aria-valuenow",this.currentTime);const t=h.formatTime(this.currentTime),s=h.formatTime(this.duration),a=$.get("seekLabel",this.config);i.setAttribute("aria-valuetext",a.replace("{currentTime}",t).replace("{duration}",s))}else if(Y(i,this.config.selectors.inputs.volume)){const t=100*i.value;i.setAttribute("aria-valuenow",t),i.setAttribute("aria-valuetext",`${t.toFixed(1)}%`)}else i.setAttribute("aria-valuenow",i.value);(_.isWebKit||_.isIPadOS)&&i.style.setProperty("--value",i.value/i.max*100+"%")}},updateSeekTooltip(e){var i,t;if(!this.config.tooltips.seek||!l.element(this.elements.inputs.seek)||!l.element(this.elements.display.seekTooltip)||this.duration===0)return;const s=this.elements.display.seekTooltip,a=`${this.config.classNames.tooltip}--visible`,n=g=>E(s,a,g);if(this.touch)return void n(!1);let r=0;const o=this.elements.progress.getBoundingClientRect();if(l.event(e))r=100/o.width*(e.pageX-o.left);else{if(!de(s,a))return;r=parseFloat(s.style.left,10)}r<0?r=0:r>100&&(r=100);const c=this.duration/100*r;s.innerText=h.formatTime(c);const u=(i=this.config.markers)===null||i===void 0||(t=i.points)===null||t===void 0?void 0:t.find(({time:g})=>g===Math.round(c));u&&s.insertAdjacentHTML("afterbegin",`${u.label}
`),s.style.left=`${r}%`,l.event(e)&&["mouseenter","mouseleave"].includes(e.type)&&n(e.type==="mouseenter")},timeUpdate(e){const i=!l.element(this.elements.display.duration)&&this.config.invertTime;h.updateTimeDisplay.call(this,this.elements.display.currentTime,i?this.duration-this.currentTime:this.currentTime,i),e&&e.type==="timeupdate"&&this.media.seeking||h.updateProgress.call(this,e)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32)return K(this.elements.display.currentTime,!0),void K(this.elements.progress,!0);l.element(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);const e=l.element(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&h.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&h.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),this.config.markers.enabled&&h.setMarkers.call(this),h.updateSeekTooltip.call(this)},toggleMenuButton(e,i){K(this.elements.settings.buttons[e],!i)},updateSetting(e,i,t){const s=this.elements.settings.panels[e];let a=null,n=i;if(e==="captions")a=this.currentTrack;else{if(a=l.empty(t)?this[e]:t,l.empty(a)&&(a=this.config[e].default),!l.empty(this.options[e])&&!this.options[e].includes(a))return void this.debug.warn(`Unsupported value of '${a}' for ${e}`);if(!this.config[e].options.includes(a))return void this.debug.warn(`Disabled value of '${a}' for ${e}`)}if(l.element(n)||(n=s&&s.querySelector('[role="menu"]')),!l.element(n))return;this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`).innerHTML=h.getLabel.call(this,e,a);const r=n&&n.querySelector(`[value="${a}"]`);l.element(r)&&(r.checked=!0)},getLabel(e,i){switch(e){case"speed":return i===1?$.get("normal",this.config):`${i}×`;case"quality":if(l.number(i)){const t=$.get(`qualityLabel.${i}`,this.config);return t.length?t:`${i}p`}return gt(i);case"captions":return S.getLabel.call(this);default:return null}},setQualityMenu(e){if(!l.element(this.elements.settings.panels.quality))return;const i="quality",t=this.elements.settings.panels.quality.querySelector('[role="menu"]');l.array(e)&&(this.options.quality=Ce(e).filter(n=>this.config.quality.options.includes(n)));const s=!l.empty(this.options.quality)&&this.options.quality.length>1;if(h.toggleMenuButton.call(this,i,s),oe(t),h.checkMenu.call(this),!s)return;const a=n=>{const r=$.get(`qualityBadge.${n}`,this.config);return r.length?h.createBadge.call(this,r):null};this.options.quality.sort((n,r)=>{const o=this.config.quality.options;return o.indexOf(n)>o.indexOf(r)?1:-1}).forEach(n=>{h.createMenuItem.call(this,{value:n,list:t,type:i,title:h.getLabel.call(this,"quality",n),badge:a(n)})}),h.updateSetting.call(this,i,t)},setCaptionsMenu(){if(!l.element(this.elements.settings.panels.captions))return;const e="captions",i=this.elements.settings.panels.captions.querySelector('[role="menu"]'),t=S.getTracks.call(this),s=!!t.length;if(h.toggleMenuButton.call(this,e,s),oe(i),h.checkMenu.call(this),!s)return;const a=t.map((n,r)=>({value:r,checked:this.captions.toggled&&this.currentTrack===r,title:S.getLabel.call(this,n),badge:n.language&&h.createBadge.call(this,n.language.toUpperCase()),list:i,type:"language"}));a.unshift({value:-1,checked:!this.captions.toggled,title:$.get("disabled",this.config),list:i,type:"language"}),a.forEach(h.createMenuItem.bind(this)),h.updateSetting.call(this,e,i)},setSpeedMenu(){if(!l.element(this.elements.settings.panels.speed))return;const e="speed",i=this.elements.settings.panels.speed.querySelector('[role="menu"]');this.options.speed=this.options.speed.filter(s=>s>=this.minimumSpeed&&s<=this.maximumSpeed);const t=!l.empty(this.options.speed)&&this.options.speed.length>1;h.toggleMenuButton.call(this,e,t),oe(i),h.checkMenu.call(this),t&&(this.options.speed.forEach(s=>{h.createMenuItem.call(this,{value:s,list:i,type:e,title:h.getLabel.call(this,"speed",s)})}),h.updateSetting.call(this,e,i))},checkMenu(){const{buttons:e}=this.elements.settings,i=!l.empty(e)&&Object.values(e).some(t=>!t.hidden);K(this.elements.settings.menu,!i)},focusFirstMenuItem(e,i=!1){if(this.elements.settings.popup.hidden)return;let t=e;l.element(t)||(t=Object.values(this.elements.settings.panels).find(a=>!a.hidden));const s=t.querySelector('[role^="menuitem"]');be.call(this,s,i)},toggleMenu(e){const{popup:i}=this.elements.settings,t=this.elements.buttons.settings;if(!l.element(i)||!l.element(t))return;const{hidden:s}=i;let a=s;if(l.boolean(e))a=e;else if(l.keyboardEvent(e)&&e.key==="Escape")a=!1;else if(l.event(e)){const n=l.function(e.composedPath)?e.composedPath()[0]:e.target,r=i.contains(n);if(r||!r&&e.target!==t&&a)return}t.setAttribute("aria-expanded",a),K(i,!a),E(this.elements.container,this.config.classNames.menu.open,a),a&&l.keyboardEvent(e)?h.focusFirstMenuItem.call(this,null,!0):a||s||be.call(this,t,l.keyboardEvent(e))},getMenuSize(e){const i=e.cloneNode(!0);i.style.position="absolute",i.style.opacity=0,i.removeAttribute("hidden"),e.parentNode.appendChild(i);const t=i.scrollWidth,s=i.scrollHeight;return F(i),{width:t,height:s}},showMenuPanel(e="",i=!1){const t=this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`);if(!l.element(t))return;const s=t.parentNode,a=Array.from(s.children).find(n=>!n.hidden);if(N.transitions&&!N.reducedMotion){s.style.width=`${a.scrollWidth}px`,s.style.height=`${a.scrollHeight}px`;const n=h.getMenuSize.call(this,t),r=o=>{o.target===s&&["width","height"].includes(o.propertyName)&&(s.style.width="",s.style.height="",ge.call(this,s,ke,r))};T.call(this,s,ke,r),s.style.width=`${n.width}px`,s.style.height=`${n.height}px`}K(a,!0),K(t,!1),h.focusFirstMenuItem.call(this,t,i)},setDownloadUrl(){const e=this.elements.buttons.download;l.element(e)&&e.setAttribute("href",this.download)},create(e){const{bindMenuItemShortcuts:i,createButton:t,createProgress:s,createRange:a,createTime:n,setQualityMenu:r,setSpeedMenu:o,showMenuPanel:c}=h;this.elements.controls=null,l.array(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(t.call(this,"play-large"));const u=y("div",V(this.config.selectors.controls.wrapper));this.elements.controls=u;const g={class:"plyr__controls__item"};return Ce(l.array(this.config.controls)?this.config.controls:[]).forEach(f=>{if(f==="restart"&&u.appendChild(t.call(this,"restart",g)),f==="rewind"&&u.appendChild(t.call(this,"rewind",g)),f==="play"&&u.appendChild(t.call(this,"play",g)),f==="fast-forward"&&u.appendChild(t.call(this,"fast-forward",g)),f==="progress"){const d=y("div",{class:`${g.class} plyr__progress__container`}),v=y("div",V(this.config.selectors.progress));if(v.appendChild(a.call(this,"seek",{id:`plyr-seek-${e.id}`})),v.appendChild(s.call(this,"buffer")),this.config.tooltips.seek){const A=y("span",{class:this.config.classNames.tooltip},"00:00");v.appendChild(A),this.elements.display.seekTooltip=A}this.elements.progress=v,d.appendChild(this.elements.progress),u.appendChild(d)}if(f==="current-time"&&u.appendChild(n.call(this,"currentTime",g)),f==="duration"&&u.appendChild(n.call(this,"duration",g)),f==="mute"||f==="volume"){let{volume:d}=this.elements;if(l.element(d)&&u.contains(d)||(d=y("div",x({},g,{class:`${g.class} plyr__volume`.trim()})),this.elements.volume=d,u.appendChild(d)),f==="mute"&&d.appendChild(t.call(this,"mute")),f==="volume"&&!_.isIos&&!_.isIPadOS){const v={max:1,step:.05,value:this.config.volume};d.appendChild(a.call(this,"volume",x(v,{id:`plyr-volume-${e.id}`})))}}if(f==="captions"&&u.appendChild(t.call(this,"captions",g)),f==="settings"&&!l.empty(this.config.settings)){const d=y("div",x({},g,{class:`${g.class} plyr__menu`.trim(),hidden:""}));d.appendChild(t.call(this,"settings",{"aria-haspopup":!0,"aria-controls":`plyr-settings-${e.id}`,"aria-expanded":!1}));const v=y("div",{class:"plyr__menu__container",id:`plyr-settings-${e.id}`,hidden:""}),A=y("div"),k=y("div",{id:`plyr-settings-${e.id}-home`}),M=y("div",{role:"menu"});k.appendChild(M),A.appendChild(k),this.elements.settings.panels.home=k,this.config.settings.forEach(w=>{const p=y("button",x(V(this.config.selectors.buttons.settings),{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--forward`,role:"menuitem","aria-haspopup":!0,hidden:""}));i.call(this,p,w),T.call(this,p,"click",()=>{c.call(this,w,!1)});const C=y("span",null,$.get(w,this.config)),L=y("span",{class:this.config.classNames.menu.value});L.innerHTML=e[w],C.appendChild(L),p.appendChild(C),M.appendChild(p);const j=y("div",{id:`plyr-settings-${e.id}-${w}`,hidden:""}),H=y("button",{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});H.appendChild(y("span",{"aria-hidden":!0},$.get(w,this.config))),H.appendChild(y("span",{class:this.config.classNames.hidden},$.get("menuBack",this.config))),T.call(this,j,"keydown",B=>{B.key==="ArrowLeft"&&(B.preventDefault(),B.stopPropagation(),c.call(this,"home",!0))},!1),T.call(this,H,"click",()=>{c.call(this,"home",!1)}),j.appendChild(H),j.appendChild(y("div",{role:"menu"})),A.appendChild(j),this.elements.settings.buttons[w]=p,this.elements.settings.panels[w]=j}),v.appendChild(A),d.appendChild(v),u.appendChild(d),this.elements.settings.popup=v,this.elements.settings.menu=d}if(f==="pip"&&N.pip&&u.appendChild(t.call(this,"pip",g)),f==="airplay"&&N.airplay&&u.appendChild(t.call(this,"airplay",g)),f==="download"){const d=x({},g,{element:"a",href:this.download,target:"_blank"});this.isHTML5&&(d.download="");const{download:v}=this.config.urls;!l.url(v)&&this.isEmbed&&x(d,{icon:`logo-${this.provider}`,label:this.provider}),u.appendChild(t.call(this,"download",d))}f==="fullscreen"&&u.appendChild(t.call(this,"fullscreen",g))}),this.isHTML5&&r.call(this,z.getQualityOptions.call(this)),o.call(this),u},inject(){if(this.config.loadSprite){const a=h.getIconUrl.call(this);a.cors&&ft(a.url,"sprite-plyr")}this.id=Math.floor(1e4*Math.random());let e=null;this.elements.controls=null;const i={id:this.id,seektime:this.config.seekTime,title:this.config.title};let t=!0;l.function(this.config.controls)&&(this.config.controls=this.config.controls.call(this,i)),this.config.controls||(this.config.controls=[]),l.element(this.config.controls)||l.string(this.config.controls)?e=this.config.controls:(e=h.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:S.getLabel.call(this)}),t=!1);let s;if(t&&l.string(this.config.controls)&&(e=(a=>{let n=a;return Object.entries(i).forEach(([r,o])=>{n=Z(n,`{${r}}`,o)}),n})(e)),l.string(this.config.selectors.controls.container)&&(s=document.querySelector(this.config.selectors.controls.container)),l.element(s)||(s=this.elements.container),s[l.element(e)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",e),l.element(this.elements.controls)||h.findElements.call(this),!l.empty(this.elements.buttons)){const a=n=>{const r=this.config.classNames.controlPressed;n.setAttribute("aria-pressed","false"),Object.defineProperty(n,"pressed",{configurable:!0,enumerable:!0,get:()=>de(n,r),set(o=!1){E(n,r,o),n.setAttribute("aria-pressed",o?"true":"false")}})};Object.values(this.elements.buttons).filter(Boolean).forEach(n=>{l.array(n)||l.nodeList(n)?Array.from(n).filter(Boolean).forEach(a):a(n)})}if(_.isEdge&&ot(s),this.config.tooltips.controls){const{classNames:a,selectors:n}=this.config,r=`${n.controls.wrapper} ${n.labels} .${a.hidden}`,o=ee.call(this,r);Array.from(o).forEach(c=>{E(c,this.config.classNames.hidden,!1),E(c,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(e){}},setMarkers(){var e,i;if(!this.duration||this.elements.markers)return;const t=(e=this.config.markers)===null||e===void 0||(i=e.points)===null||i===void 0?void 0:i.filter(({time:c})=>c>0&&cE(n,r,c);t.forEach(c=>{const u=y("span",{class:this.config.classNames.marker},""),g=c.time/this.duration*100+"%";n&&(u.addEventListener("mouseenter",()=>{c.label||(n.style.left=g,n.innerHTML=c.label,o(!0))}),u.addEventListener("mouseleave",()=>{o(!1)})),u.addEventListener("click",()=>{this.currentTime=c.time}),u.style.left=g,a.appendChild(u)}),s.appendChild(a),this.config.tooltips.seek||(n=y("span",{class:this.config.classNames.tooltip},""),s.appendChild(n)),this.elements.markers={points:a,tip:n},this.elements.progress.appendChild(s)}};function bt(e,i=!0){let t=e;if(i){const s=document.createElement("a");s.href=t,t=s.href}try{return new URL(t)}catch(s){return null}}function vt(e){const i=new URLSearchParams;return l.object(e)&&Object.entries(e).forEach(([t,s])=>{i.set(t,s)}),i}const S={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!N.textTracks)return void(l.array(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&h.setCaptionsMenu.call(this));if(l.element(this.elements.captions)||(this.elements.captions=y("div",V(this.config.selectors.captions)),this.elements.captions.setAttribute("dir","auto"),Ti(this.elements.captions,this.elements.wrapper)),_.isIE&&window.URL){const s=this.media.querySelectorAll("track");Array.from(s).forEach(a=>{const n=a.getAttribute("src"),r=bt(n);r!==null&&r.hostname!==window.location.href.hostname&&["http:","https:"].includes(r.protocol)&&le(n,"blob").then(o=>{a.setAttribute("src",window.URL.createObjectURL(o))}).catch(()=>{F(a)})})}const e=Ce((navigator.languages||[navigator.language||navigator.userLanguage||"en"]).map(s=>s.split("-")[0]));let i=(this.storage.get("language")||this.config.captions.language||"auto").toLowerCase();i==="auto"&&([i]=e);let t=this.storage.get("captions");if(l.boolean(t)||({active:t}=this.config.captions),Object.assign(this.captions,{toggled:!1,active:t,language:i,languages:e}),this.isHTML5){const s=this.config.captions.update?"addtrack removetrack":"removetrack";T.call(this,this.media.textTracks,s,S.update.bind(this))}setTimeout(S.update.bind(this),0)},update(){const e=S.getTracks.call(this,!0),{active:i,language:t,meta:s,currentTrackNode:a}=this.captions,n=!!e.find(r=>r.language===t);this.isHTML5&&this.isVideo&&e.filter(r=>!s.get(r)).forEach(r=>{this.debug.log("Track added",r),s.set(r,{default:r.mode==="showing"}),r.mode==="showing"&&(r.mode="hidden"),T.call(this,r,"cuechange",()=>S.updateCues.call(this))}),(n&&this.language!==t||!e.includes(a))&&(S.setLanguage.call(this,t),S.toggle.call(this,i&&n)),this.elements&&E(this.elements.container,this.config.classNames.captions.enabled,!l.empty(e)),l.array(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&h.setCaptionsMenu.call(this)},toggle(e,i=!0){if(!this.supported.ui)return;const{toggled:t}=this.captions,s=this.config.classNames.captions.active,a=l.nullOrUndefined(e)?!t:e;if(a!==t){if(i||(this.captions.active=a,this.storage.set({captions:a})),!this.language&&a&&!i){const n=S.getTracks.call(this),r=S.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);return this.captions.language=r.language,void S.set.call(this,n.indexOf(r))}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=a),E(this.elements.container,s,a),this.captions.toggled=a,h.updateSetting.call(this,"captions"),b.call(this,this.media,a?"captionsenabled":"captionsdisabled")}setTimeout(()=>{a&&this.captions.toggled&&(this.captions.currentTrackNode.mode="hidden")})},set(e,i=!0){const t=S.getTracks.call(this);if(e!==-1)if(l.number(e))if(e in t){if(this.captions.currentTrack!==e){this.captions.currentTrack=e;const s=t[e],{language:a}=s||{};this.captions.currentTrackNode=s,h.updateSetting.call(this,"captions"),i||(this.captions.language=a,this.storage.set({language:a})),this.isVimeo&&this.embed.enableTextTrack(a),b.call(this,this.media,"languagechange")}S.toggle.call(this,!0,i),this.isHTML5&&this.isVideo&&S.updateCues.call(this)}else this.debug.warn("Track not found",e);else this.debug.warn("Invalid caption argument",e);else S.toggle.call(this,!1,i)},setLanguage(e,i=!0){if(!l.string(e))return void this.debug.warn("Invalid language argument",e);const t=e.toLowerCase();this.captions.language=t;const s=S.getTracks.call(this),a=S.findTrack.call(this,[t]);S.set.call(this,s.indexOf(a),i)},getTracks(e=!1){return Array.from((this.media||{}).textTracks||[]).filter(i=>!this.isHTML5||e||this.captions.meta.has(i)).filter(i=>["captions","subtitles"].includes(i.kind))},findTrack(e,i=!1){const t=S.getTracks.call(this),s=r=>Number((this.captions.meta.get(r)||{}).default),a=Array.from(t).sort((r,o)=>s(o)-s(r));let n;return e.every(r=>(n=a.find(o=>o.language===r),!n)),n||(i?a[0]:void 0)},getCurrentTrack(){return S.getTracks.call(this)[this.currentTrack]},getLabel(e){let i=e;return!l.track(i)&&N.textTracks&&this.captions.toggled&&(i=S.getCurrentTrack.call(this)),l.track(i)?l.empty(i.label)?l.empty(i.language)?$.get("enabled",this.config):e.language.toUpperCase():i.label:$.get("disabled",this.config)},updateCues(e){if(!this.supported.ui)return;if(!l.element(this.elements.captions))return void this.debug.warn("No captions element to render to");if(!l.nullOrUndefined(e)&&!Array.isArray(e))return void this.debug.warn("updateCues: Invalid input",e);let i=e;if(!i){const s=S.getCurrentTrack.call(this);i=Array.from((s||{}).activeCues||[]).map(a=>a.getCueAsHTML()).map(_i)}const t=i.map(s=>s.trim()).join(` `);if(t!==this.elements.captions.innerHTML){oe(this.elements.captions);const s=y("span",V(this.config.selectors.caption));s.innerHTML=t,this.elements.captions.appendChild(s),b.call(this,this.media,"cuechange")}}},wt={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.7.8/plyr.svg",blankVideo:"https://cdn.plyr.io/static/blank.mp4",quality:{default:576,options:[4320,2880,2160,1440,1080,720,576,480,360,240],forced:!1,onChange:null},loop:{active:!1},speed:{selected:1,options:[.5,.75,1,1.25,1.5,1.75,2,4]},keyboard:{focused:!0,global:!1},tooltips:{controls:!1,seek:!0},captions:{active:!1,language:"auto",update:!1},fullscreen:{enabled:!0,fallback:!0,iosNative:!1},storage:{enabled:!0,key:"plyr"},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","pip","airplay","fullscreen"],settings:["captions","quality","speed"],i18n:{restart:"Restart",rewind:"Rewind {seektime}s",play:"Play",pause:"Pause",fastForward:"Forward {seektime}s",seek:"Seek",seekLabel:"{currentTime} of {duration}",played:"Played",buffered:"Buffered",currentTime:"Current time",duration:"Duration",volume:"Volume",mute:"Mute",unmute:"Unmute",enableCaptions:"Enable captions",disableCaptions:"Disable captions",download:"Download",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",frameTitle:"Player for {title}",captions:"Captions",settings:"Settings",pip:"PIP",menuBack:"Go back to previous menu",speed:"Speed",normal:"Normal",quality:"Quality",loop:"Loop",start:"Start",end:"End",all:"All",reset:"Reset",disabled:"Disabled",enabled:"Enabled",advertisement:"Ad",qualityBadge:{2160:"4K",1440:"HD",1080:"HD",720:"HD",576:"SD",480:"SD"}},urls:{download:null,vimeo:{sdk:"https://player.vimeo.com/api/player.js",iframe:"https://player.vimeo.com/video/{0}?{1}",api:"https://vimeo.com/api/oembed.json?url={0}"},youtube:{sdk:"https://www.youtube.com/iframe_api",api:"https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}"},googleIMA:{sdk:"https://imasdk.googleapis.com/js/sdkloader/ima3.js"}},listeners:{seek:null,play:null,pause:null,restart:null,rewind:null,fastForward:null,mute:null,volume:null,captions:null,download:null,fullscreen:null,pip:null,airplay:null,speed:null,quality:null,loop:null,language:null},events:["ended","progress","stalled","playing","waiting","canplay","canplaythrough","loadstart","loadeddata","loadedmetadata","timeupdate","volumechange","play","pause","error","seeking","seeked","emptied","ratechange","cuechange","download","enterfullscreen","exitfullscreen","captionsenabled","captionsdisabled","languagechange","controlshidden","controlsshown","ready","statechange","qualitychange","adsloaded","adscontentpause","adscontentresume","adstarted","adsmidpoint","adscomplete","adsallcomplete","adsimpression","adsclick"],selectors:{editable:"input, textarea, select, [contenteditable]",container:".plyr",controls:{container:null,wrapper:".plyr__controls"},labels:"[data-plyr]",buttons:{play:'[data-plyr="play"]',pause:'[data-plyr="pause"]',restart:'[data-plyr="restart"]',rewind:'[data-plyr="rewind"]',fastForward:'[data-plyr="fast-forward"]',mute:'[data-plyr="mute"]',captions:'[data-plyr="captions"]',download:'[data-plyr="download"]',fullscreen:'[data-plyr="fullscreen"]',pip:'[data-plyr="pip"]',airplay:'[data-plyr="airplay"]',settings:'[data-plyr="settings"]',loop:'[data-plyr="loop"]'},inputs:{seek:'[data-plyr="seek"]',volume:'[data-plyr="volume"]',speed:'[data-plyr="speed"]',language:'[data-plyr="language"]',quality:'[data-plyr="quality"]'},display:{currentTime:".plyr__time--current",duration:".plyr__time--duration",buffer:".plyr__progress__buffer",loop:".plyr__progress__loop",volume:".plyr__volume--display"},progress:".plyr__progress",captions:".plyr__captions",caption:".plyr__caption"},classNames:{type:"plyr--{0}",provider:"plyr--{0}",video:"plyr__video-wrapper",embed:"plyr__video-embed",videoFixedRatio:"plyr__video-wrapper--fixed-ratio",embedContainer:"plyr__video-embed__container",poster:"plyr__poster",posterEnabled:"plyr__poster-enabled",ads:"plyr__ads",control:"plyr__control",controlPressed:"plyr__control--pressed",playing:"plyr--playing",paused:"plyr--paused",stopped:"plyr--stopped",loading:"plyr--loading",hover:"plyr--hover",tooltip:"plyr__tooltip",cues:"plyr__cues",marker:"plyr__progress__marker",hidden:"plyr__sr-only",hideControls:"plyr--hide-controls",isTouch:"plyr--is-touch",uiSupported:"plyr--full-ui",noTransition:"plyr--no-transition",display:{time:"plyr__time"},menu:{value:"plyr__menu__value",badge:"plyr__badge",open:"plyr--menu-open"},captions:{enabled:"plyr--captions-enabled",active:"plyr--captions-active"},fullscreen:{enabled:"plyr--fullscreen-enabled",fallback:"plyr--fullscreen-fallback"},pip:{supported:"plyr--pip-supported",active:"plyr--pip-active"},airplay:{supported:"plyr--airplay-supported",active:"plyr--airplay-active"},previewThumbnails:{thumbContainer:"plyr__preview-thumb",thumbContainerShown:"plyr__preview-thumb--is-shown",imageContainer:"plyr__preview-thumb__image-container",timeContainer:"plyr__preview-thumb__time-container",scrubbingContainer:"plyr__preview-scrubbing",scrubbingContainerShown:"plyr__preview-scrubbing--is-shown"}},attributes:{embed:{provider:"data-plyr-provider",id:"data-plyr-embed-id",hash:"data-plyr-embed-hash"}},ads:{enabled:!1,publisherId:"",tagUrl:""},previewThumbnails:{enabled:!1,src:""},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:[]}},ve={active:"picture-in-picture",inactive:"inline"},W={html5:"html5",youtube:"youtube",vimeo:"vimeo"},we={audio:"audio",video:"video"};function Di(e){return/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(e)?W.youtube:/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(e)?W.vimeo:null}const Ae=()=>{};class Hi{constructor(i=!1){this.enabled=window.console&&i,this.enabled&&this.log("Debugging enabled")}get log(){return this.enabled?Function.prototype.bind.call(console.log,console):Ae}get warn(){return this.enabled?Function.prototype.bind.call(console.warn,console):Ae}get error(){return this.enabled?Function.prototype.bind.call(console.error,console):Ae}}class R{constructor(i){m(this,"onChange",()=>{if(!this.supported)return;const t=this.player.elements.buttons.fullscreen;l.element(t)&&(t.pressed=this.active);const s=this.target===this.player.media?this.target:this.player.elements.container;b.call(this.player,s,this.active?"enterfullscreen":"exitfullscreen",!0)}),m(this,"toggleFallback",(t=!1)=>{var s,a;if(t?this.scrollPosition={x:(s=window.scrollX)!=null?s:0,y:(a=window.scrollY)!=null?a:0}:window.scrollTo(this.scrollPosition.x,this.scrollPosition.y),document.body.style.overflow=t?"hidden":"",E(this.target,this.player.config.classNames.fullscreen.fallback,t),_.isIos){let n=document.head.querySelector('meta[name="viewport"]');const r="viewport-fit=cover";n||(n=document.createElement("meta"),n.setAttribute("name","viewport"));const o=l.string(n.content)&&n.content.includes(r);t?(this.cleanupViewport=!o,o||(n.content+=`,${r}`)):this.cleanupViewport&&(n.content=n.content.split(",").filter(c=>c.trim()!==r).join(","))}this.onChange()}),m(this,"trapFocus",t=>{if(_.isIos||_.isIPadOS||!this.active||t.key!=="Tab")return;const s=document.activeElement,a=ee.call(this.player,"a[href], button:not(:disabled), input:not(:disabled), [tabindex]"),[n]=a,r=a[a.length-1];s!==r||t.shiftKey?s===n&&t.shiftKey&&(r.focus(),t.preventDefault()):(n.focus(),t.preventDefault())}),m(this,"update",()=>{if(this.supported){let t;t=this.forceFallback?"Fallback (forced)":R.nativeSupported?"Native":"Fallback",this.player.debug.log(`${t} fullscreen enabled`)}else this.player.debug.log("Fullscreen not supported and fallback disabled");E(this.player.elements.container,this.player.config.classNames.fullscreen.enabled,this.supported)}),m(this,"enter",()=>{this.supported&&(_.isIos&&this.player.config.fullscreen.iosNative?this.player.isVimeo?this.player.embed.requestFullscreen():this.target.webkitEnterFullscreen():!R.nativeSupported||this.forceFallback?this.toggleFallback(!0):this.prefix?l.empty(this.prefix)||this.target[`${this.prefix}Request${this.property}`]():this.target.requestFullscreen({navigationUI:"hide"}))}),m(this,"exit",()=>{if(this.supported)if(_.isIos&&this.player.config.fullscreen.iosNative)this.player.isVimeo?this.player.embed.exitFullscreen():this.target.webkitEnterFullscreen(),q(this.player.play());else if(!R.nativeSupported||this.forceFallback)this.toggleFallback(!1);else if(this.prefix){if(!l.empty(this.prefix)){const t=this.prefix==="moz"?"Cancel":"Exit";document[`${this.prefix}${t}${this.property}`]()}}else(document.cancelFullScreen||document.exitFullscreen).call(document)}),m(this,"toggle",()=>{this.active?this.exit():this.enter()}),this.player=i,this.prefix=R.prefix,this.property=R.property,this.scrollPosition={x:0,y:0},this.forceFallback=i.config.fullscreen.fallback==="force",this.player.elements.fullscreen=i.config.fullscreen.container&&Ci(this.player.elements.container,i.config.fullscreen.container),T.call(this.player,document,this.prefix==="ms"?"MSFullscreenChange":`${this.prefix}fullscreenchange`,()=>{this.onChange()}),T.call(this.player,this.player.elements.container,"dblclick",t=>{l.element(this.player.elements.controls)&&this.player.elements.controls.contains(t.target)||this.player.listeners.proxy(t,this.toggle,"fullscreen")}),T.call(this,this.player.elements.container,"keydown",t=>this.trapFocus(t)),this.update()}static get nativeSupported(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}get useNative(){return R.nativeSupported&&!this.forceFallback}static get prefix(){if(l.function(document.exitFullscreen))return"";let i="";return["webkit","moz","ms"].some(t=>!(!l.function(document[`${t}ExitFullscreen`])&&!l.function(document[`${t}CancelFullScreen`]))&&(i=t,!0)),i}static get property(){return this.prefix==="moz"?"FullScreen":"Fullscreen"}get supported(){return[this.player.config.fullscreen.enabled,this.player.isVideo,R.nativeSupported||this.player.config.fullscreen.fallback,!this.player.isYouTube||R.nativeSupported||!_.isIos||this.player.config.playsinline&&!this.player.config.fullscreen.iosNative].every(Boolean)}get active(){if(!this.supported)return!1;if(!R.nativeSupported||this.forceFallback)return de(this.target,this.player.config.classNames.fullscreen.fallback);const i=this.prefix?this.target.getRootNode()[`${this.prefix}${this.property}Element`]:this.target.getRootNode().fullscreenElement;return i&&i.shadowRoot?i===this.target.getRootNode().host:i===this.target}get target(){var i;return _.isIos&&this.player.config.fullscreen.iosNative?this.player.media:(i=this.player.elements.fullscreen)!=null?i:this.player.elements.container}}function ce(e,i=1){return new Promise((t,s)=>{const a=new Image,n=()=>{delete a.onload,delete a.onerror,(a.naturalWidth>=i?t:s)(a)};Object.assign(a,{onload:n,onerror:n,src:e})})}const P={addStyleHook(){E(this.elements.container,this.config.selectors.container.replace(".",""),!0),E(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)return this.debug.warn(`Basic support only for ${this.provider} ${this.type}`),void P.toggleNativeControls.call(this,!0);l.element(this.elements.controls)||(h.inject.call(this),this.listeners.controls()),P.toggleNativeControls.call(this),this.isHTML5&&S.setup.call(this),this.volume=null,this.muted=null,this.loop=null,this.quality=null,this.speed=null,h.updateVolume.call(this),h.timeUpdate.call(this),h.durationUpdate.call(this),P.checkPlaying.call(this),E(this.elements.container,this.config.classNames.pip.supported,N.pip&&this.isHTML5&&this.isVideo),E(this.elements.container,this.config.classNames.airplay.supported,N.airplay&&this.isHTML5),E(this.elements.container,this.config.classNames.isTouch,this.touch),this.ready=!0,setTimeout(()=>{b.call(this,this.media,"ready")},0),P.setTitle.call(this),this.poster&&P.setPoster.call(this,this.poster,!1).catch(()=>{}),this.config.duration&&h.durationUpdate.call(this),this.config.mediaMetadata&&h.setMediaMetadata.call(this)},setTitle(){let e=$.get("play",this.config);if(l.string(this.config.title)&&!l.empty(this.config.title)&&(e+=`, ${this.config.title}`),Array.from(this.elements.buttons.play||[]).forEach(i=>{i.setAttribute("aria-label",e)}),this.isEmbed){const i=I.call(this,"iframe");if(!l.element(i))return;const t=l.empty(this.config.title)?"video":this.config.title,s=$.get("frameTitle",this.config);i.setAttribute("title",s.replace("{title}",t))}},togglePoster(e){E(this.elements.container,this.config.classNames.posterEnabled,e)},setPoster(e,i=!0){return i&&this.poster?Promise.reject(new Error("Poster already set")):(this.media.setAttribute("data-poster",e),this.elements.poster.removeAttribute("hidden"),Pi.call(this).then(()=>ce(e)).catch(t=>{throw e===this.poster&&P.togglePoster.call(this,!1),t}).then(()=>{if(e!==this.poster)throw new Error("setPoster cancelled by later call to setPoster")}).then(()=>(Object.assign(this.elements.poster.style,{backgroundImage:`url('${e}')`,backgroundSize:""}),P.togglePoster.call(this,!0),e)))},checkPlaying(e){E(this.elements.container,this.config.classNames.playing,this.playing),E(this.elements.container,this.config.classNames.paused,this.paused),E(this.elements.container,this.config.classNames.stopped,this.stopped),Array.from(this.elements.buttons.play||[]).forEach(i=>{Object.assign(i,{pressed:this.playing}),i.setAttribute("aria-label",$.get(this.playing?"pause":"play",this.config))}),l.event(e)&&e.type==="timeupdate"||P.toggleControls.call(this)},checkLoading(e){this.loading=["stalled","waiting"].includes(e.type),clearTimeout(this.timers.loading),this.timers.loading=setTimeout(()=>{E(this.elements.container,this.config.classNames.loading,this.loading),P.toggleControls.call(this)},this.loading?250:0)},toggleControls(e){const{controls:i}=this.elements;if(i&&this.config.hideControls){const t=this.touch&&this.lastSeekTime+2e3>Date.now();this.toggleControls(!!(e||this.loading||this.paused||i.pressed||i.hover||t))}},migrateStyles(){Object.values({...this.media.style}).filter(e=>!l.empty(e)&&l.string(e)&&e.startsWith("--plyr")).forEach(e=>{this.elements.container.style.setProperty(e,this.media.style.getPropertyValue(e)),this.media.style.removeProperty(e)}),l.empty(this.media.style)&&this.media.removeAttribute("style")}};class Ri{constructor(i){m(this,"firstTouch",()=>{const{player:t}=this,{elements:s}=t;t.touch=!0,E(s.container,t.config.classNames.isTouch,!0)}),m(this,"global",(t=!0)=>{const{player:s}=this;s.config.keyboard.global&&te.call(s,window,"keydown keyup",this.handleKey,t,!1),te.call(s,document.body,"click",this.toggleMenu,t),Le.call(s,document.body,"touchstart",this.firstTouch)}),m(this,"container",()=>{const{player:t}=this,{config:s,elements:a,timers:n}=t;!s.keyboard.global&&s.keyboard.focused&&T.call(t,a.container,"keydown keyup",this.handleKey,!1),T.call(t,a.container,"mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen",c=>{const{controls:u}=a;u&&c.type==="enterfullscreen"&&(u.pressed=!1,u.hover=!1);let g=0;["touchstart","touchmove","mousemove"].includes(c.type)&&(P.toggleControls.call(t,!0),g=t.touch?3e3:2e3),clearTimeout(n.controls),n.controls=setTimeout(()=>P.toggleControls.call(t,!1),g)});const r=()=>{if(!t.isVimeo||t.config.vimeo.premium)return;const c=a.wrapper,{active:u}=t.fullscreen,[g,f]=Ie.call(t),d=dt(`aspect-ratio: ${g} / ${f}`);if(!u)return void(d?(c.style.width=null,c.style.height=null):(c.style.maxWidth=null,c.style.margin=null));const[v,A]=Mi(),k=v/A>g/f;d?(c.style.width=k?"auto":"100%",c.style.height=k?"100%":"auto"):(c.style.maxWidth=k?A/f*g+"px":null,c.style.margin=k?"0 auto":null)},o=()=>{clearTimeout(n.resized),n.resized=setTimeout(r,50)};T.call(t,a.container,"enterfullscreen exitfullscreen",c=>{const{target:u}=t.fullscreen;u===a.container&&(!t.isEmbed&&l.empty(t.config.ratio)||(r(),(c.type==="enterfullscreen"?T:ge).call(t,window,"resize",o)))})}),m(this,"media",()=>{const{player:t}=this,{elements:s}=t;if(T.call(t,t.media,"timeupdate seeking seeked",n=>h.timeUpdate.call(t,n)),T.call(t,t.media,"durationchange loadeddata loadedmetadata",n=>h.durationUpdate.call(t,n)),T.call(t,t.media,"ended",()=>{t.isHTML5&&t.isVideo&&t.config.resetOnEnd&&(t.restart(),t.pause())}),T.call(t,t.media,"progress playing seeking seeked",n=>h.updateProgress.call(t,n)),T.call(t,t.media,"volumechange",n=>h.updateVolume.call(t,n)),T.call(t,t.media,"playing play pause ended emptied timeupdate",n=>P.checkPlaying.call(t,n)),T.call(t,t.media,"waiting canplay seeked playing",n=>P.checkLoading.call(t,n)),t.supported.ui&&t.config.clickToPlay&&!t.isAudio){const n=I.call(t,`.${t.config.classNames.video}`);if(!l.element(n))return;T.call(t,s.container,"click",r=>{([s.container,n].includes(r.target)||n.contains(r.target))&&(t.touch&&t.config.hideControls||(t.ended?(this.proxy(r,t.restart,"restart"),this.proxy(r,()=>{q(t.play())},"play")):this.proxy(r,()=>{q(t.togglePlay())},"play")))})}t.supported.ui&&t.config.disableContextMenu&&T.call(t,s.wrapper,"contextmenu",n=>{n.preventDefault()},!1),T.call(t,t.media,"volumechange",()=>{t.storage.set({volume:t.volume,muted:t.muted})}),T.call(t,t.media,"ratechange",()=>{h.updateSetting.call(t,"speed"),t.storage.set({speed:t.speed})}),T.call(t,t.media,"qualitychange",n=>{h.updateSetting.call(t,"quality",null,n.detail.quality)}),T.call(t,t.media,"ready qualitychange",()=>{h.setDownloadUrl.call(t)});const a=t.config.events.concat(["keyup","keydown"]).join(" ");T.call(t,t.media,a,n=>{let{detail:r={}}=n;n.type==="error"&&(r=t.media.error),b.call(t,s.container,n.type,!0,r)})}),m(this,"proxy",(t,s,a)=>{const{player:n}=this,r=n.config.listeners[a];let o=!0;l.function(r)&&(o=r.call(n,t)),o!==!1&&l.function(s)&&s.call(n,t)}),m(this,"bind",(t,s,a,n,r=!0)=>{const{player:o}=this,c=o.config.listeners[n],u=l.function(c);T.call(o,t,s,g=>this.proxy(g,a,n),r&&!u)}),m(this,"controls",()=>{const{player:t}=this,{elements:s}=t,a=_.isIE?"change":"input";if(s.buttons.play&&Array.from(s.buttons.play).forEach(n=>{this.bind(n,"click",()=>{q(t.togglePlay())},"play")}),this.bind(s.buttons.restart,"click",t.restart,"restart"),this.bind(s.buttons.rewind,"click",()=>{t.lastSeekTime=Date.now(),t.rewind()},"rewind"),this.bind(s.buttons.fastForward,"click",()=>{t.lastSeekTime=Date.now(),t.forward()},"fastForward"),this.bind(s.buttons.mute,"click",()=>{t.muted=!t.muted},"mute"),this.bind(s.buttons.captions,"click",()=>t.toggleCaptions()),this.bind(s.buttons.download,"click",()=>{b.call(t,t.media,"download")},"download"),this.bind(s.buttons.fullscreen,"click",()=>{t.fullscreen.toggle()},"fullscreen"),this.bind(s.buttons.pip,"click",()=>{t.pip="toggle"},"pip"),this.bind(s.buttons.airplay,"click",t.airplay,"airplay"),this.bind(s.buttons.settings,"click",n=>{n.stopPropagation(),n.preventDefault(),h.toggleMenu.call(t,n)},null,!1),this.bind(s.buttons.settings,"keyup",n=>{[" ","Enter"].includes(n.key)&&(n.key!=="Enter"?(n.preventDefault(),n.stopPropagation(),h.toggleMenu.call(t,n)):h.focusFirstMenuItem.call(t,null,!0))},null,!1),this.bind(s.settings.menu,"keydown",n=>{n.key==="Escape"&&h.toggleMenu.call(t,n)}),this.bind(s.inputs.seek,"mousedown mousemove",n=>{const r=s.progress.getBoundingClientRect(),o=100/r.width*(n.pageX-r.left);n.currentTarget.setAttribute("seek-value",o)}),this.bind(s.inputs.seek,"mousedown mouseup keydown keyup touchstart touchend",n=>{const r=n.currentTarget,o="play-on-seeked";if(l.keyboardEvent(n)&&!["ArrowLeft","ArrowRight"].includes(n.key))return;t.lastSeekTime=Date.now();const c=r.hasAttribute(o),u=["mouseup","touchend","keyup"].includes(n.type);c&&u?(r.removeAttribute(o),q(t.play())):!u&&t.playing&&(r.setAttribute(o,""),t.pause())}),_.isIos){const n=ee.call(t,'input[type="range"]');Array.from(n).forEach(r=>this.bind(r,a,o=>ot(o.target)))}this.bind(s.inputs.seek,a,n=>{const r=n.currentTarget;let o=r.getAttribute("seek-value");l.empty(o)&&(o=r.value),r.removeAttribute("seek-value"),t.currentTime=o/r.max*t.duration},"seek"),this.bind(s.progress,"mouseenter mouseleave mousemove",n=>h.updateSeekTooltip.call(t,n)),this.bind(s.progress,"mousemove touchmove",n=>{const{previewThumbnails:r}=t;r&&r.loaded&&r.startMove(n)}),this.bind(s.progress,"mouseleave touchend click",()=>{const{previewThumbnails:n}=t;n&&n.loaded&&n.endMove(!1,!0)}),this.bind(s.progress,"mousedown touchstart",n=>{const{previewThumbnails:r}=t;r&&r.loaded&&r.startScrubbing(n)}),this.bind(s.progress,"mouseup touchend",n=>{const{previewThumbnails:r}=t;r&&r.loaded&&r.endScrubbing(n)}),_.isWebKit&&Array.from(ee.call(t,'input[type="range"]')).forEach(n=>{this.bind(n,"input",r=>h.updateRangeFill.call(t,r.target))}),t.config.toggleInvert&&!l.element(s.display.duration)&&this.bind(s.display.currentTime,"click",()=>{t.currentTime!==0&&(t.config.invertTime=!t.config.invertTime,h.timeUpdate.call(t))}),this.bind(s.inputs.volume,a,n=>{t.volume=n.target.value},"volume"),this.bind(s.controls,"mouseenter mouseleave",n=>{s.controls.hover=!t.touch&&n.type==="mouseenter"}),s.fullscreen&&Array.from(s.fullscreen.children).filter(n=>!n.contains(s.container)).forEach(n=>{this.bind(n,"mouseenter mouseleave",r=>{s.controls&&(s.controls.hover=!t.touch&&r.type==="mouseenter")})}),this.bind(s.controls,"mousedown mouseup touchstart touchend touchcancel",n=>{s.controls.pressed=["mousedown","touchstart"].includes(n.type)}),this.bind(s.controls,"focusin",()=>{const{config:n,timers:r}=t;E(s.controls,n.classNames.noTransition,!0),P.toggleControls.call(t,!0),setTimeout(()=>{E(s.controls,n.classNames.noTransition,!1)},0);const o=this.touch?3e3:4e3;clearTimeout(r.controls),r.controls=setTimeout(()=>P.toggleControls.call(t,!1),o)}),this.bind(s.inputs.volume,"wheel",n=>{const r=n.webkitDirectionInvertedFromDevice,[o,c]=[n.deltaX,-n.deltaY].map(f=>r?-f:f),u=Math.sign(Math.abs(o)>Math.abs(c)?o:c);t.increaseVolume(u/50);const{volume:g}=t.media;(u===1&&g<1||u===-1&&g>0)&&n.preventDefault()},"volume",!1)}),this.player=i,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(i){const{player:t}=this,{elements:s}=t,{key:a,type:n,altKey:r,ctrlKey:o,metaKey:c,shiftKey:u}=i,g=n==="keydown",f=g&&a===this.lastKey;if(!(r||o||c||u)&&a){if(g){const v=document.activeElement;if(l.element(v)){const{editable:A}=t.config.selectors,{seek:k}=s.inputs;if(v!==k&&Y(v,A)||i.key===" "&&Y(v,'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(a)&&(i.preventDefault(),i.stopPropagation()),a){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":f||(d=parseInt(a,10),t.currentTime=t.duration/10*d);break;case" ":case"k":f||q(t.togglePlay());break;case"ArrowUp":t.increaseVolume(.1);break;case"ArrowDown":t.decreaseVolume(.1);break;case"m":f||(t.muted=!t.muted);break;case"ArrowRight":t.forward();break;case"ArrowLeft":t.rewind();break;case"f":t.fullscreen.toggle();break;case"c":f||t.toggleCaptions();break;case"l":t.loop=!t.loop}a==="Escape"&&!t.fullscreen.usingNative&&t.fullscreen.active&&t.fullscreen.toggle(),this.lastKey=a}else this.lastKey=null;var d}}toggleMenu(i){h.toggleMenu.call(this.player,i)}}function Bi(e,i){return e(i={exports:{}},i.exports),i.exports}var Vi=Bi(function(e,i){e.exports=function(){var t=function(){},s={},a={},n={};function r(d,v){d=d.push?d:[d];var A,k,M,w=[],p=d.length,C=p;for(A=function(L,j){j.length&&w.push(L),--C||v(w)};p--;)k=d[p],(M=a[k])?A(k,M):(n[k]=n[k]||[]).push(A)}function o(d,v){if(d){var A=n[d];if(a[d]=v,A)for(;A.length;)A[0](d,v),A.splice(0,1)}}function c(d,v){d.call&&(d={success:d}),v.length?(d.error||t)(v):(d.success||t)(d)}function u(d,v,A,k){var M,w,p=document,C=A.async,L=(A.numRetries||0)+1,j=A.before||t,H=d.replace(/[\?|#].*$/,""),B=d.replace(/^(css|img)!/,"");k=k||0,/(^css!|\.css$)/.test(H)?((w=p.createElement("link")).rel="stylesheet",w.href=B,(M="hideFocus"in w)&&w.relList&&(M=0,w.rel="preload",w.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(H)?(w=p.createElement("img")).src=B:((w=p.createElement("script")).src=d,w.async=C===void 0||C),w.onload=w.onerror=w.onbeforeload=function(_e){var re=_e.type[0];if(M)try{w.sheet.cssText.length||(re="e")}catch(Tt){Tt.code!=18&&(re="e")}if(re=="e"){if((k+=1){Vi(e,{success:i,error:t})})}function qi(e){return l.empty(e)?null:l.number(Number(e))?e:e.match(/^.*(vimeo.com\/|video\/)(\d+).*/)?RegExp.$2:e}function Fi(e){const i=e.match(/^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/);return i&&i.length===5?i[4]:null}function J(e){e&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===e&&(this.media.paused=!e,b.call(this,this.media,e?"play":"pause"))}const Ee={setup(){const e=this;E(e.elements.wrapper,e.config.classNames.embed,!0),e.options.speed=e.config.speed.options,X.call(e),l.object(window.Vimeo)?Ee.ready.call(e):$e(e.config.urls.vimeo.sdk).then(()=>{Ee.ready.call(e)}).catch(i=>{e.debug.warn("Vimeo SDK (player.js) failed to load",i)})},ready(){const e=this,i=e.config.vimeo,{premium:t,referrerPolicy:s,...a}=i;let n=e.media.getAttribute("src"),r="";l.empty(n)?(n=e.media.getAttribute(e.config.attributes.embed.id),r=e.media.getAttribute(e.config.attributes.embed.hash)):r=Fi(n);const o=r?{h:r}:{};t&&Object.assign(a,{controls:!1,sidedock:!1});const c=vt({loop:e.config.loop.active,autoplay:e.autoplay,muted:e.muted,gesture:"media",playsinline:e.config.playsinline,...o,...a}),u=qi(n),g=y("iframe"),f=Se(e.config.urls.vimeo.iframe,u,c);if(g.setAttribute("src",f),g.setAttribute("allowfullscreen",""),g.setAttribute("allow",["autoplay","fullscreen","picture-in-picture","encrypted-media","accelerometer","gyroscope"].join("; ")),l.empty(s)||g.setAttribute("referrerPolicy",s),t||!i.customControls)g.setAttribute("data-poster",e.poster),e.media=he(g,e.media);else{const p=y("div",{class:e.config.classNames.embedContainer,"data-poster":e.poster});p.appendChild(g),e.media=he(p,e.media)}i.customControls||le(Se(e.config.urls.vimeo.api,f)).then(p=>{!l.empty(p)&&p.thumbnail_url&&P.setPoster.call(e,p.thumbnail_url).catch(()=>{})}),e.embed=new window.Vimeo.Player(g,{autopause:e.config.autopause,muted:e.muted}),e.media.paused=!0,e.media.currentTime=0,e.supported.ui&&e.embed.disableTextTrack(),e.media.play=()=>(J.call(e,!0),e.embed.play()),e.media.pause=()=>(J.call(e,!1),e.embed.pause()),e.media.stop=()=>{e.pause(),e.currentTime=0};let{currentTime:d}=e.media;Object.defineProperty(e.media,"currentTime",{get:()=>d,set(p){const{embed:C,media:L,paused:j,volume:H}=e,B=j&&!C.hasPlayed;L.seeking=!0,b.call(e,L,"seeking"),Promise.resolve(B&&C.setVolume(0)).then(()=>C.setCurrentTime(p)).then(()=>B&&C.pause()).then(()=>B&&C.setVolume(H)).catch(()=>{})}});let v=e.config.speed.selected;Object.defineProperty(e.media,"playbackRate",{get:()=>v,set(p){e.embed.setPlaybackRate(p).then(()=>{v=p,b.call(e,e.media,"ratechange")}).catch(()=>{e.options.speed=[1]})}});let{volume:A}=e.config;Object.defineProperty(e.media,"volume",{get:()=>A,set(p){e.embed.setVolume(p).then(()=>{A=p,b.call(e,e.media,"volumechange")})}});let{muted:k}=e.config;Object.defineProperty(e.media,"muted",{get:()=>k,set(p){const C=!!l.boolean(p)&&p;e.embed.setMuted(!!C||e.config.muted).then(()=>{k=C,b.call(e,e.media,"volumechange")})}});let M,{loop:w}=e.config;Object.defineProperty(e.media,"loop",{get:()=>w,set(p){const C=l.boolean(p)?p:e.config.loop.active;e.embed.setLoop(C).then(()=>{w=C})}}),e.embed.getVideoUrl().then(p=>{M=p,h.setDownloadUrl.call(e)}).catch(p=>{this.debug.warn(p)}),Object.defineProperty(e.media,"currentSrc",{get:()=>M}),Object.defineProperty(e.media,"ended",{get:()=>e.currentTime===e.duration}),Promise.all([e.embed.getVideoWidth(),e.embed.getVideoHeight()]).then(p=>{const[C,L]=p;e.embed.ratio=pt(C,L),X.call(this)}),e.embed.setAutopause(e.config.autopause).then(p=>{e.config.autopause=p}),e.embed.getVideoTitle().then(p=>{e.config.title=p,P.setTitle.call(this)}),e.embed.getCurrentTime().then(p=>{d=p,b.call(e,e.media,"timeupdate")}),e.embed.getDuration().then(p=>{e.media.duration=p,b.call(e,e.media,"durationchange")}),e.embed.getTextTracks().then(p=>{e.media.textTracks=p,S.setup.call(e)}),e.embed.on("cuechange",({cues:p=[]})=>{const C=p.map(L=>$i(L.text));S.updateCues.call(e,C)}),e.embed.on("loaded",()=>{e.embed.getPaused().then(p=>{J.call(e,!p),p||b.call(e,e.media,"playing")}),l.element(e.embed.element)&&e.supported.ui&&e.embed.element.setAttribute("tabindex",-1)}),e.embed.on("bufferstart",()=>{b.call(e,e.media,"waiting")}),e.embed.on("bufferend",()=>{b.call(e,e.media,"playing")}),e.embed.on("play",()=>{J.call(e,!0),b.call(e,e.media,"playing")}),e.embed.on("pause",()=>{J.call(e,!1)}),e.embed.on("timeupdate",p=>{e.media.seeking=!1,d=p.seconds,b.call(e,e.media,"timeupdate")}),e.embed.on("progress",p=>{e.media.buffered=p.percent,b.call(e,e.media,"progress"),parseInt(p.percent,10)===1&&b.call(e,e.media,"canplaythrough"),e.embed.getDuration().then(C=>{C!==e.media.duration&&(e.media.duration=C,b.call(e,e.media,"durationchange"))})}),e.embed.on("seeked",()=>{e.media.seeking=!1,b.call(e,e.media,"seeked")}),e.embed.on("ended",()=>{e.media.paused=!0,b.call(e,e.media,"ended")}),e.embed.on("error",p=>{e.media.error=p,b.call(e,e.media,"error")}),i.customControls&&setTimeout(()=>P.build.call(e),0)}};function Ui(e){return l.empty(e)?null:e.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/)?RegExp.$2:e}function Q(e){e&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===e&&(this.media.paused=!e,b.call(this,this.media,e?"play":"pause"))}function Wi(e){return e.noCookie?"https://www.youtube-nocookie.com":window.location.protocol==="http:"?"http://www.youtube.com":void 0}const ue={setup(){if(E(this.elements.wrapper,this.config.classNames.embed,!0),l.object(window.YT)&&l.function(window.YT.Player))ue.ready.call(this);else{const e=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{l.function(e)&&e(),ue.ready.call(this)},$e(this.config.urls.youtube.sdk).catch(i=>{this.debug.warn("YouTube API failed to load",i)})}},getTitle(e){le(Se(this.config.urls.youtube.api,e)).then(i=>{if(l.object(i)){const{title:t,height:s,width:a}=i;this.config.title=t,P.setTitle.call(this),this.embed.ratio=pt(a,s)}X.call(this)}).catch(()=>{X.call(this)})},ready(){const e=this,i=e.config.youtube,t=e.media&&e.media.getAttribute("id");if(!l.empty(t)&&t.startsWith("youtube-"))return;let s=e.media.getAttribute("src");l.empty(s)&&(s=e.media.getAttribute(this.config.attributes.embed.id));const a=Ui(s),n=y("div",{id:xi(e.provider),"data-poster":i.customControls?e.poster:void 0});if(e.media=he(n,e.media),i.customControls){const r=o=>`https://i.ytimg.com/vi/${a}/${o}default.jpg`;ce(r("maxres"),121).catch(()=>ce(r("sd"),121)).catch(()=>ce(r("hq"))).then(o=>P.setPoster.call(e,o.src)).then(o=>{o.includes("maxres")||(e.elements.poster.style.backgroundSize="cover")}).catch(()=>{})}e.embed=new window.YT.Player(e.media,{videoId:a,host:Wi(i),playerVars:x({},{autoplay:e.config.autoplay?1:0,hl:e.config.hl,controls:e.supported.ui&&i.customControls?0:1,disablekb:1,playsinline:e.config.playsinline&&!e.config.fullscreen.iosNative?1:0,cc_load_policy:e.captions.active?1:0,cc_lang_pref:e.config.captions.language,widget_referrer:window?window.location.href:null},i),events:{onError(r){if(!e.media.error){const o=r.data,c={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."}[o]||"An unknown error occurred";e.media.error={code:o,message:c},b.call(e,e.media,"error")}},onPlaybackRateChange(r){const o=r.target;e.media.playbackRate=o.getPlaybackRate(),b.call(e,e.media,"ratechange")},onReady(r){if(l.function(e.media.play))return;const o=r.target;ue.getTitle.call(e,a),e.media.play=()=>{Q.call(e,!0),o.playVideo()},e.media.pause=()=>{Q.call(e,!1),o.pauseVideo()},e.media.stop=()=>{o.stopVideo()},e.media.duration=o.getDuration(),e.media.paused=!0,e.media.currentTime=0,Object.defineProperty(e.media,"currentTime",{get:()=>Number(o.getCurrentTime()),set(f){e.paused&&!e.embed.hasPlayed&&e.embed.mute(),e.media.seeking=!0,b.call(e,e.media,"seeking"),o.seekTo(f)}}),Object.defineProperty(e.media,"playbackRate",{get:()=>o.getPlaybackRate(),set(f){o.setPlaybackRate(f)}});let{volume:c}=e.config;Object.defineProperty(e.media,"volume",{get:()=>c,set(f){c=f,o.setVolume(100*c),b.call(e,e.media,"volumechange")}});let{muted:u}=e.config;Object.defineProperty(e.media,"muted",{get:()=>u,set(f){const d=l.boolean(f)?f:u;u=d,o[d?"mute":"unMute"](),o.setVolume(100*c),b.call(e,e.media,"volumechange")}}),Object.defineProperty(e.media,"currentSrc",{get:()=>o.getVideoUrl()}),Object.defineProperty(e.media,"ended",{get:()=>e.currentTime===e.duration});const g=o.getAvailablePlaybackRates();e.options.speed=g.filter(f=>e.config.speed.options.includes(f)),e.supported.ui&&i.customControls&&e.media.setAttribute("tabindex",-1),b.call(e,e.media,"timeupdate"),b.call(e,e.media,"durationchange"),clearInterval(e.timers.buffering),e.timers.buffering=setInterval(()=>{e.media.buffered=o.getVideoLoadedFraction(),(e.media.lastBuffered===null||e.media.lastBufferedP.build.call(e),50)},onStateChange(r){const o=r.target;switch(clearInterval(e.timers.playing),e.media.seeking&&[1,2].includes(r.data)&&(e.media.seeking=!1,b.call(e,e.media,"seeked")),r.data){case-1:b.call(e,e.media,"timeupdate"),e.media.buffered=o.getVideoLoadedFraction(),b.call(e,e.media,"progress");break;case 0:Q.call(e,!1),e.media.loop?(o.stopVideo(),o.playVideo()):b.call(e,e.media,"ended");break;case 1:i.customControls&&!e.config.autoplay&&e.media.paused&&!e.embed.hasPlayed?e.media.pause():(Q.call(e,!0),b.call(e,e.media,"playing"),e.timers.playing=setInterval(()=>{b.call(e,e.media,"timeupdate")},50),e.media.duration!==o.getDuration()&&(e.media.duration=o.getDuration(),b.call(e,e.media,"durationchange")));break;case 2:e.muted||e.embed.unMute(),Q.call(e,!1);break;case 3:b.call(e,e.media,"waiting")}b.call(e,e.elements.container,"statechange",!1,{code:r.data})}}})}},At={setup(){this.media?(E(this.elements.container,this.config.classNames.type.replace("{0}",this.type),!0),E(this.elements.container,this.config.classNames.provider.replace("{0}",this.provider),!0),this.isEmbed&&E(this.elements.container,this.config.classNames.type.replace("{0}","video"),!0),this.isVideo&&(this.elements.wrapper=y("div",{class:this.config.classNames.video}),ut(this.media,this.elements.wrapper),this.elements.poster=y("div",{class:this.config.classNames.poster}),this.elements.wrapper.appendChild(this.elements.poster)),this.isHTML5?z.setup.call(this):this.isYouTube?ue.setup.call(this):this.isVimeo&&Ee.setup.call(this)):this.debug.warn("No media element found!")}};class zi{constructor(i){m(this,"load",()=>{this.enabled&&(l.object(window.google)&&l.object(window.google.ima)?this.ready():$e(this.player.config.urls.googleIMA.sdk).then(()=>{this.ready()}).catch(()=>{this.trigger("error",new Error("Google IMA SDK failed to load"))}))}),m(this,"ready",()=>{var t;this.enabled||((t=this).manager&&t.manager.destroy(),t.elements.displayContainer&&t.elements.displayContainer.destroy(),t.elements.container.remove()),this.startSafetyTimer(12e3,"ready()"),this.managerPromise.then(()=>{this.clearSafetyTimer("onAdsManagerLoaded()")}),this.listeners(),this.setupIMA()}),m(this,"setupIMA",()=>{this.elements.container=y("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,t=>this.onAdsManagerLoaded(t),!1),this.loader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,t=>this.onAdError(t),!1),this.requestAds()}),m(this,"requestAds",()=>{const{container:t}=this.player.elements;try{const s=new google.ima.AdsRequest;s.adTagUrl=this.tagUrl,s.linearAdSlotWidth=t.offsetWidth,s.linearAdSlotHeight=t.offsetHeight,s.nonLinearAdSlotWidth=t.offsetWidth,s.nonLinearAdSlotHeight=t.offsetHeight,s.forceNonLinearFullSlot=!1,s.setAdWillPlayMuted(!this.player.muted),this.loader.requestAds(s)}catch(s){this.onAdError(s)}}),m(this,"pollCountdown",(t=!1)=>{if(!t)return clearInterval(this.countdownTimer),void this.elements.container.removeAttribute("data-badge-text");this.countdownTimer=setInterval(()=>{const s=fe(Math.max(this.manager.getRemainingTime(),0)),a=`${$.get("advertisement",this.player.config)} - ${s}`;this.elements.container.setAttribute("data-badge-text",a)},100)}),m(this,"onAdsManagerLoaded",t=>{if(!this.enabled)return;const s=new google.ima.AdsRenderingSettings;s.restoreCustomPlaybackStateOnAdBreakComplete=!0,s.enablePreloading=!0,this.manager=t.getAdsManager(this.player,s),this.cuePoints=this.manager.getCuePoints(),this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,a=>this.onAdError(a)),Object.keys(google.ima.AdEvent.Type).forEach(a=>{this.manager.addEventListener(google.ima.AdEvent.Type[a],n=>this.onAdEvent(n))}),this.trigger("loaded")}),m(this,"addCuePoints",()=>{l.empty(this.cuePoints)||this.cuePoints.forEach(t=>{if(t!==0&&t!==-1&&t{const{container:s}=this.player.elements,a=t.getAd(),n=t.getAdData();switch((r=>{b.call(this.player,this.player.media,`ads${r.replace(/_/g,"").toLowerCase()}`)})(t.type),t.type){case google.ima.AdEvent.Type.LOADED:this.trigger("loaded"),this.pollCountdown(!0),a.isLinear()||(a.width=s.offsetWidth,a.height=s.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:n.adError&&this.player.debug.warn(`Non-fatal ad error: ${n.adError.getMessage()}`)}}),m(this,"onAdError",t=>{this.cancel(),this.player.debug.warn("Ads error",t)}),m(this,"listeners",()=>{const{container:t}=this.player.elements;let s;this.player.on("canplay",()=>{this.addCuePoints()}),this.player.on("ended",()=>{this.loader.contentComplete()}),this.player.on("timeupdate",()=>{s=this.player.currentTime}),this.player.on("seeked",()=>{const a=this.player.currentTime;l.empty(this.cuePoints)||this.cuePoints.forEach((n,r)=>{s{this.manager&&this.manager.resize(t.offsetWidth,t.offsetHeight,google.ima.ViewMode.NORMAL)})}),m(this,"play",()=>{const{container:t}=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(t.offsetWidth,t.offsetHeight,google.ima.ViewMode.NORMAL),this.manager.start()),this.initialized=!0}catch(s){this.onAdError(s)}}).catch(()=>{})}),m(this,"resumeContent",()=>{this.elements.container.style.zIndex="",this.playing=!1,q(this.player.media.play())}),m(this,"pauseContent",()=>{this.elements.container.style.zIndex=3,this.playing=!0,this.player.media.pause()}),m(this,"cancel",()=>{this.initialized&&this.resumeContent(),this.trigger("error"),this.loadAds()}),m(this,"loadAds",()=>{this.managerPromise.then(()=>{this.manager&&this.manager.destroy(),this.managerPromise=new Promise(t=>{this.on("loaded",t),this.player.debug.log(this.manager)}),this.initialized=!1,this.requestAds()}).catch(()=>{})}),m(this,"trigger",(t,...s)=>{const a=this.events[t];l.array(a)&&a.forEach(n=>{l.function(n)&&n.apply(this,s)})}),m(this,"on",(t,s)=>(l.array(this.events[t])||(this.events[t]=[]),this.events[t].push(s),this)),m(this,"startSafetyTimer",(t,s)=>{this.player.debug.log(`Safety timer invoked from: ${s}`),this.safetyTimer=setTimeout(()=>{this.cancel(),this.clearSafetyTimer("startSafetyTimer()")},t)}),m(this,"clearSafetyTimer",t=>{l.nullOrUndefined(this.safetyTimer)||(this.player.debug.log(`Safety timer cleared from: ${t}`),clearTimeout(this.safetyTimer),this.safetyTimer=null)}),this.player=i,this.config=i.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((t,s)=>{this.on("loaded",t),this.on("error",s)}),this.load()}get enabled(){const{config:i}=this;return this.player.isHTML5&&this.player.isVideo&&i.enabled&&(!l.empty(i.publisherId)||l.url(i.tagUrl))}get tagUrl(){const{config:i}=this;return l.url(i.tagUrl)?i.tagUrl:`https://go.aniview.com/api/adserver6/vast/?${vt({AV_PUBLISHERID:"58c25bb0073ef448b1087ad6",AV_CHANNELID:"5a0458dc28a06145e4519d21",AV_URL:window.location.hostname,cb:Date.now(),AV_WIDTH:640,AV_HEIGHT:480,AV_CDIM2:i.publisherId})}`}}function kt(e=0,i=0,t=255){return Math.min(Math.max(e,i),t)}const Ki=e=>{const i=[];return e.split(/\r\n\r\n|\n\n|\r\r/).forEach(t=>{const s={};t.split(/\r\n|\n|\r/).forEach(a=>{if(l.number(s.startTime)){if(!l.empty(a.trim())&&l.empty(s.text)){const n=a.trim().split("#xywh=");[s.text]=n,n[1]&&([s.x,s.y,s.w,s.h]=n[1].split(","))}}else{const n=a.match(/([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})/);n&&(s.startTime=60*Number(n[1]||0)*60+60*Number(n[2])+Number(n[3])+ +`0.${n[4]}`,s.endTime=60*Number(n[6]||0)*60+60*Number(n[7])+Number(n[8])+ +`0.${n[9]}`)}}),s.text&&i.push(s)}),i},Ye=(e,i)=>{const t={};return e>i.width/i.height?(t.width=i.width,t.height=1/e*i.width):(t.height=i.height,t.width=e*i.height),t};class Pe{constructor(i){m(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)})}),m(this,"getThumbnails",()=>new Promise(t=>{const{src:s}=this.player.config.previewThumbnails;if(l.empty(s))throw new Error("Missing previewThumbnails.src config attribute");const a=()=>{this.thumbnails.sort((n,r)=>n.height-r.height),this.player.debug.log("Preview thumbnails",this.thumbnails),t()};if(l.function(s))s(n=>{this.thumbnails=n,a()});else{const n=(l.string(s)?[s]:s).map(r=>this.getThumbnail(r));Promise.all(n).then(a)}})),m(this,"getThumbnail",t=>new Promise(s=>{le(t).then(a=>{const n={frames:Ki(a),height:null,urlPrefix:""};n.frames[0].text.startsWith("/")||n.frames[0].text.startsWith("http://")||n.frames[0].text.startsWith("https://")||(n.urlPrefix=t.substring(0,t.lastIndexOf("/")+1));const r=new Image;r.onload=()=>{n.height=r.naturalHeight,n.width=r.naturalWidth,this.thumbnails.push(n),s()},r.src=n.urlPrefix+n.frames[0].text})})),m(this,"startMove",t=>{if(this.loaded&&l.event(t)&&["touchmove","mousemove"].includes(t.type)&&this.player.media.duration){if(t.type==="touchmove")this.seekTime=this.player.media.duration*(this.player.elements.inputs.seek.value/100);else{var s,a;const n=this.player.elements.progress.getBoundingClientRect(),r=100/n.width*(t.pageX-n.left);this.seekTime=this.player.media.duration*(r/100),this.seekTime<0&&(this.seekTime=0),this.seekTime>this.player.media.duration-1&&(this.seekTime=this.player.media.duration-1),this.mousePosX=t.pageX,this.elements.thumb.time.innerText=fe(this.seekTime);const o=(s=this.player.config.markers)===null||s===void 0||(a=s.points)===null||a===void 0?void 0:a.find(({time:c})=>c===Math.round(this.seekTime));o&&this.elements.thumb.time.insertAdjacentHTML("afterbegin",`${o.label}
`)}this.showImageAtCurrentTime()}}),m(this,"endMove",()=>{this.toggleThumbContainer(!1,!0)}),m(this,"startScrubbing",t=>{(l.nullOrUndefined(t.button)||t.button===!1||t.button===0)&&(this.mouseDown=!0,this.player.media.duration&&(this.toggleScrubbingContainer(!0),this.toggleThumbContainer(!1,!0),this.showImageAtCurrentTime()))}),m(this,"endScrubbing",()=>{this.mouseDown=!1,Math.ceil(this.lastTime)===Math.ceil(this.player.media.currentTime)?this.toggleScrubbingContainer(!1):Le.call(this.player,this.player.media,"timeupdate",()=>{this.mouseDown||this.toggleScrubbingContainer(!1)})}),m(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})}),m(this,"render",()=>{this.elements.thumb.container=y("div",{class:this.player.config.classNames.previewThumbnails.thumbContainer}),this.elements.thumb.imageContainer=y("div",{class:this.player.config.classNames.previewThumbnails.imageContainer}),this.elements.thumb.container.appendChild(this.elements.thumb.imageContainer);const t=y("div",{class:this.player.config.classNames.previewThumbnails.timeContainer});this.elements.thumb.time=y("span",{},"00:00"),t.appendChild(this.elements.thumb.time),this.elements.thumb.imageContainer.appendChild(t),l.element(this.player.elements.progress)&&this.player.elements.progress.appendChild(this.elements.thumb.container),this.elements.scrubbing.container=y("div",{class:this.player.config.classNames.previewThumbnails.scrubbingContainer}),this.player.elements.wrapper.appendChild(this.elements.scrubbing.container)}),m(this,"destroy",()=>{this.elements.thumb.container&&this.elements.thumb.container.remove(),this.elements.scrubbing.container&&this.elements.scrubbing.container.remove()}),m(this,"showImageAtCurrentTime",()=>{this.mouseDown?this.setScrubbingContainerSize():this.setThumbContainerSizeAndPos();const t=this.thumbnails[0].frames.findIndex(n=>this.seekTime>=n.startTime&&this.seekTime<=n.endTime),s=t>=0;let a=0;this.mouseDown||this.toggleThumbContainer(s),s&&(this.thumbnails.forEach((n,r)=>{this.loadedImages.includes(n.frames[t].text)&&(a=r)}),t!==this.showingThumb&&(this.showingThumb=t,this.loadImage(a)))}),m(this,"loadImage",(t=0)=>{const s=this.showingThumb,a=this.thumbnails[t],{urlPrefix:n}=a,r=a.frames[s],o=a.frames[s].text,c=n+o;if(this.currentImageElement&&this.currentImageElement.dataset.filename===o)this.showImage(this.currentImageElement,r,t,s,o,!1),this.currentImageElement.dataset.index=s,this.removeOldImages(this.currentImageElement);else{this.loadingImage&&this.usingSprites&&(this.loadingImage.onload=null);const u=new Image;u.src=c,u.dataset.index=s,u.dataset.filename=o,this.showingThumbFilename=o,this.player.debug.log(`Loading image: ${c}`),u.onload=()=>this.showImage(u,r,t,s,o,!0),this.loadingImage=u,this.removeOldImages(u)}}),m(this,"showImage",(t,s,a,n,r,o=!0)=>{this.player.debug.log(`Showing thumb: ${r}. num: ${n}. qual: ${a}. newimg: ${o}`),this.setImageSizeAndOffset(t,s),o&&(this.currentImageContainer.appendChild(t),this.currentImageElement=t,this.loadedImages.includes(r)||this.loadedImages.push(r)),this.preloadNearby(n,!0).then(this.preloadNearby(n,!1)).then(this.getHigherQuality(a,t,s,r))}),m(this,"removeOldImages",t=>{Array.from(this.currentImageContainer.children).forEach(s=>{if(s.tagName.toLowerCase()!=="img")return;const a=this.usingSprites?500:1e3;if(s.dataset.index!==t.dataset.index&&!s.dataset.deleting){s.dataset.deleting=!0;const{currentImageContainer:n}=this;setTimeout(()=>{n.removeChild(s),this.player.debug.log(`Removing thumb: ${s.dataset.filename}`)},a)}})}),m(this,"preloadNearby",(t,s=!0)=>new Promise(a=>{setTimeout(()=>{const n=this.thumbnails[0].frames[t].text;if(this.showingThumbFilename===n){let r;r=s?this.thumbnails[0].frames.slice(t):this.thumbnails[0].frames.slice(0,t).reverse();let o=!1;r.forEach(c=>{const u=c.text;if(u!==n&&!this.loadedImages.includes(u)){o=!0,this.player.debug.log(`Preloading thumb filename: ${u}`);const{urlPrefix:g}=this.thumbnails[0],f=g+u,d=new Image;d.src=f,d.onload=()=>{this.player.debug.log(`Preloaded thumb filename: ${u}`),this.loadedImages.includes(u)||this.loadedImages.push(u),a()}}}),o||a()}},300)})),m(this,"getHigherQuality",(t,s,a,n)=>{if(t{this.showingThumbFilename===n&&(this.player.debug.log(`Showing higher quality thumb for: ${n}`),this.loadImage(t+1))},300)}}),m(this,"toggleThumbContainer",(t=!1,s=!1)=>{const a=this.player.config.classNames.previewThumbnails.thumbContainerShown;this.elements.thumb.container.classList.toggle(a,t),!t&&s&&(this.showingThumb=null,this.showingThumbFilename=null)}),m(this,"toggleScrubbingContainer",(t=!1)=>{const s=this.player.config.classNames.previewThumbnails.scrubbingContainerShown;this.elements.scrubbing.container.classList.toggle(s,t),t||(this.showingThumb=null,this.showingThumbFilename=null)}),m(this,"determineContainerAutoSizing",()=>{(this.elements.thumb.imageContainer.clientHeight>20||this.elements.thumb.imageContainer.clientWidth>20)&&(this.sizeSpecifiedInCSS=!0)}),m(this,"setThumbContainerSizeAndPos",()=>{const{imageContainer:t}=this.elements.thumb;if(this.sizeSpecifiedInCSS){if(t.clientHeight>20&&t.clientWidth<20){const s=Math.floor(t.clientHeight*this.thumbAspectRatio);t.style.width=`${s}px`}else if(t.clientHeight<20&&t.clientWidth>20){const s=Math.floor(t.clientWidth/this.thumbAspectRatio);t.style.height=`${s}px`}}else{const s=Math.floor(this.thumbContainerHeight*this.thumbAspectRatio);t.style.height=`${this.thumbContainerHeight}px`,t.style.width=`${s}px`}this.setThumbContainerPos()}),m(this,"setThumbContainerPos",()=>{const t=this.player.elements.progress.getBoundingClientRect(),s=this.player.elements.container.getBoundingClientRect(),{container:a}=this.elements.thumb,n=s.left-t.left+10,r=s.right-t.left-a.clientWidth-10,o=this.mousePosX-t.left-a.clientWidth/2,c=kt(o,n,r);a.style.left=`${c}px`,a.style.setProperty("--preview-arrow-offset",o-c+"px")}),m(this,"setScrubbingContainerSize",()=>{const{width:t,height:s}=Ye(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});this.elements.scrubbing.container.style.width=`${t}px`,this.elements.scrubbing.container.style.height=`${s}px`}),m(this,"setImageSizeAndOffset",(t,s)=>{if(!this.usingSprites)return;const a=this.thumbContainerHeight/s.h;t.style.height=t.naturalHeight*a+"px",t.style.width=t.naturalWidth*a+"px",t.style.left=`-${s.x*a}px`,t.style.top=`-${s.y*a}px`}),this.player=i,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){const{height:i}=Ye(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});return i}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(i){this.mouseDown?this.currentScrubbingImageElement=i:this.currentThumbnailImageElement=i}}const Me={insertElements(e,i){l.string(i)?Ue(e,this.media,{src:i}):l.array(i)&&i.forEach(t=>{Ue(e,this.media,t)})},change(e){ct(e,"sources.length")?(z.cancelRequests.call(this),this.destroy.call(this,()=>{this.options.quality=[],F(this.media),this.media=null,l.element(this.elements.container)&&this.elements.container.removeAttribute("class");const{sources:i,type:t}=e,[{provider:s=W.html5,src:a}]=i,n=s==="html5"?t:"div",r=s==="html5"?{}:{src:a};Object.assign(this,{provider:s,type:t,supported:N.check(t,s,this.config.playsinline),media:y(n,r)}),this.elements.container.appendChild(this.media),l.boolean(e.autoplay)&&(this.config.autoplay=e.autoplay),this.isHTML5&&(this.config.crossorigin&&this.media.setAttribute("crossorigin",""),this.config.autoplay&&this.media.setAttribute("autoplay",""),l.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","")),P.addStyleHook.call(this),this.isHTML5&&Me.insertElements.call(this,"source",i),this.config.title=e.title,At.setup.call(this),this.isHTML5&&Object.keys(e).includes("tracks")&&Me.insertElements.call(this,"track",e.tracks),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&P.build.call(this),this.isHTML5&&this.media.load(),l.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 Pe(this))),this.fullscreen.update()},!0)):this.debug.warn("Invalid source format")}};class se{constructor(i,t){if(m(this,"play",()=>l.function(this.media.play)?(this.ads&&this.ads.enabled&&this.ads.managerPromise.then(()=>this.ads.play()).catch(()=>q(this.media.play())),this.media.play()):null),m(this,"pause",()=>this.playing&&l.function(this.media.pause)?this.media.pause():null),m(this,"togglePlay",o=>(l.boolean(o)?o:!this.playing)?this.play():this.pause()),m(this,"stop",()=>{this.isHTML5?(this.pause(),this.restart()):l.function(this.media.stop)&&this.media.stop()}),m(this,"restart",()=>{this.currentTime=0}),m(this,"rewind",o=>{this.currentTime-=l.number(o)?o:this.config.seekTime}),m(this,"forward",o=>{this.currentTime+=l.number(o)?o:this.config.seekTime}),m(this,"increaseVolume",o=>{const c=this.media.muted?0:this.volume;this.volume=c+(l.number(o)?o:0)}),m(this,"decreaseVolume",o=>{this.increaseVolume(-o)}),m(this,"airplay",()=>{N.airplay&&this.media.webkitShowPlaybackTargetPicker()}),m(this,"toggleControls",o=>{if(this.supported.ui&&!this.isAudio){const c=de(this.elements.container,this.config.classNames.hideControls),u=o===void 0?void 0:!o,g=E(this.elements.container,this.config.classNames.hideControls,u);if(g&&l.array(this.config.controls)&&this.config.controls.includes("settings")&&!l.empty(this.config.settings)&&h.toggleMenu.call(this,!1),g!==c){const f=g?"controlshidden":"controlsshown";b.call(this,this.media,f)}return!g}return!1}),m(this,"on",(o,c)=>{T.call(this,this.elements.container,o,c)}),m(this,"once",(o,c)=>{Le.call(this,this.elements.container,o,c)}),m(this,"off",(o,c)=>{ge(this.elements.container,o,c)}),m(this,"destroy",(o,c=!1)=>{if(!this.ready)return;const u=()=>{document.body.style.overflow="",this.embed=null,c?(Object.keys(this.elements).length&&(F(this.elements.buttons.play),F(this.elements.captions),F(this.elements.controls),F(this.elements.wrapper),this.elements.buttons.play=null,this.elements.captions=null,this.elements.controls=null,this.elements.wrapper=null),l.function(o)&&o()):(Ei.call(this),z.cancelRequests.call(this),he(this.elements.original,this.elements.container),b.call(this,this.elements.original,"destroyed",!0),l.function(o)&&o.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?(P.toggleNativeControls.call(this,!0),u()):this.isYouTube?(clearInterval(this.timers.buffering),clearInterval(this.timers.playing),this.embed!==null&&l.function(this.embed.destroy)&&this.embed.destroy(),u()):this.isVimeo&&(this.embed!==null&&this.embed.unload().then(u),setTimeout(u,200))}),m(this,"supports",o=>N.mime.call(this,o)),this.timers={},this.ready=!1,this.loading=!1,this.failed=!1,this.touch=N.touch,this.media=i,l.string(this.media)&&(this.media=document.querySelectorAll(this.media)),(window.jQuery&&this.media instanceof jQuery||l.nodeList(this.media)||l.array(this.media))&&(this.media=this.media[0]),this.config=x({},wt,se.defaults,t||{},(()=>{try{return JSON.parse(this.media.getAttribute("data-plyr-config"))}catch(o){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 Hi(this.config.debug),this.debug.log("Config",this.config),this.debug.log("Support",N),l.nullOrUndefined(this.media)||!l.element(this.media))return void this.debug.error("Setup failed: no suitable element passed");if(this.media.plyr)return void this.debug.warn("Target already setup");if(!this.config.enabled)return void this.debug.error("Setup failed: disabled by config");if(!N.check().api)return void this.debug.error("Setup failed: no support");const s=this.media.cloneNode(!0);s.autoplay=!1,this.elements.original=s;const a=this.media.tagName.toLowerCase();let n=null,r=null;switch(a){case"div":if(n=this.media.querySelector("iframe"),l.element(n)){if(r=bt(n.getAttribute("src")),this.provider=Di(r.toString()),this.elements.container=this.media,this.media=n,this.elements.container.className="",r.search.length){const o=["1","true"];o.includes(r.searchParams.get("autoplay"))&&(this.config.autoplay=!0),o.includes(r.searchParams.get("loop"))&&(this.config.loop.active=!0),this.isYouTube?(this.config.playsinline=o.includes(r.searchParams.get("playsinline")),this.config.youtube.hl=r.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(l.empty(this.provider)||!Object.values(W).includes(this.provider))return void this.debug.error("Setup failed: Invalid provider");this.type=we.video;break;case"video":case"audio":this.type=a,this.provider=W.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:return void this.debug.error("Setup failed: unsupported type")}this.supported=N.check(this.type,this.provider),this.supported.api?(this.eventListeners=[],this.listeners=new Ri(this),this.storage=new ie(this),this.media.plyr=this,l.element(this.elements.container)||(this.elements.container=y("div"),ut(this.media,this.elements.container)),P.migrateStyles.call(this),P.addStyleHook.call(this),At.setup.call(this),this.config.debug&&T.call(this,this.elements.container,this.config.events.join(" "),o=>{this.debug.log(`event: ${o.type}`)}),this.fullscreen=new R(this),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&P.build.call(this),this.listeners.container(),this.listeners.global(),this.config.ads.enabled&&(this.ads=new zi(this)),this.isHTML5&&this.config.autoplay&&this.once("canplay",()=>q(this.play())),this.lastSeekTime=0,this.config.previewThumbnails.enabled&&(this.previewThumbnails=new Pe(this))):this.debug.error("Setup failed: no support")}get isHTML5(){return this.provider===W.html5}get isEmbed(){return this.isYouTube||this.isVimeo}get isYouTube(){return this.provider===W.youtube}get isVimeo(){return this.provider===W.vimeo}get isVideo(){return this.type===we.video}get isAudio(){return this.type===we.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(i){if(!this.duration)return;const t=l.number(i)&&i>0;this.media.currentTime=t?Math.min(i,this.duration):0,this.debug.log(`Seeking to ${this.currentTime} seconds`)}get currentTime(){return Number(this.media.currentTime)}get buffered(){const{buffered:i}=this.media;return l.number(i)?i:i&&i.length&&this.duration>0?i.end(0)/this.duration:0}get seeking(){return!!this.media.seeking}get duration(){const i=parseFloat(this.config.duration),t=(this.media||{}).duration,s=l.number(t)&&t!==1/0?t:0;return i||s}set volume(i){let t=i;l.string(t)&&(t=Number(t)),l.number(t)||(t=this.storage.get("volume")),l.number(t)||({volume:t}=this.config),t>1&&(t=1),t<0&&(t=0),this.config.volume=t,this.media.volume=t,!l.empty(i)&&this.muted&&t>0&&(this.muted=!1)}get volume(){return Number(this.media.volume)}set muted(i){let t=i;l.boolean(t)||(t=this.storage.get("muted")),l.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||!!this.media.mozHasAudio||!!this.media.webkitAudioDecodedByteCount||!!(this.media.audioTracks&&this.media.audioTracks.length)}set speed(i){let t=null;l.number(i)&&(t=i),l.number(t)||(t=this.storage.get("speed")),l.number(t)||(t=this.config.speed.selected);const{minimumSpeed:s,maximumSpeed:a}=this;t=kt(t,s,a),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(i){const t=this.config.quality,s=this.options.quality;if(!s.length)return;let a=[!l.empty(i)&&Number(i),this.storage.get("quality"),t.selected,t.default].find(l.number),n=!0;if(!s.includes(a)){const r=ht(s,a);this.debug.warn(`Unsupported quality option: ${a}, using ${r} instead`),a=r,n=!1}t.selected=a,this.media.quality=a,n&&this.storage.set({quality:a})}get quality(){return this.media.quality}set loop(i){const t=l.boolean(i)?i:this.config.loop.active;this.config.loop.active=t,this.media.loop=t}get loop(){return!!this.media.loop}set source(i){Me.change.call(this,i)}get source(){return this.media.currentSrc}get download(){const{download:i}=this.config.urls;return l.url(i)?i:this.source}set download(i){l.url(i)&&(this.config.urls.download=i,h.setDownloadUrl.call(this))}set poster(i){this.isVideo?P.setPoster.call(this,i,!1).catch(()=>{}):this.debug.warn("Poster can only be set for video")}get poster(){return this.isVideo?this.media.getAttribute("poster")||this.media.getAttribute("data-poster"):null}get ratio(){if(!this.isVideo)return null;const i=me(Ie.call(this));return l.array(i)?i.join(":"):i}set ratio(i){this.isVideo?l.string(i)&&mt(i)?(this.config.ratio=me(i),X.call(this)):this.debug.error(`Invalid aspect ratio specified (${i})`):this.debug.warn("Aspect ratio can only be set for video")}set autoplay(i){this.config.autoplay=l.boolean(i)?i:this.config.autoplay}get autoplay(){return!!this.config.autoplay}toggleCaptions(i){S.toggle.call(this,i,!1)}set currentTrack(i){S.set.call(this,i,!1),S.setup.call(this)}get currentTrack(){const{toggled:i,currentTrack:t}=this.captions;return i?t:-1}set language(i){S.setLanguage.call(this,i,!1)}get language(){return(S.getCurrentTrack.call(this)||{}).language}set pip(i){if(!N.pip)return;const t=l.boolean(i)?i:!this.pip;l.function(this.media.webkitSetPresentationMode)&&this.media.webkitSetPresentationMode(t?ve.active:ve.inactive),l.function(this.media.requestPictureInPicture)&&(!this.pip&&t?this.media.requestPictureInPicture():this.pip&&!t&&document.exitPictureInPicture())}get pip(){return N.pip?l.empty(this.media.webkitPresentationMode)?this.media===document.pictureInPictureElement:this.media.webkitPresentationMode===ve.active:null}setPreviewThumbnails(i){this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),Object.assign(this.config.previewThumbnails,i),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new Pe(this))}static supported(i,t){return N.check(i,t)}static loadSprite(i,t){return ft(i,t)}static setup(i,t={}){let s=null;return l.string(i)?s=Array.from(document.querySelectorAll(i)):l.nodeList(i)?s=Array.from(i):l.array(i)&&(s=i.filter(l.element)),l.empty(s)?null:s.map(a=>new se(a,t))}}se.defaults=ki(wt);const Yi=Ge({name:"m-video",props:{setting:{type:Object,default:()=>({})},controls:Boolean,height:String,src:{type:String,default:""},poster:{type:String,default:""},styleValue:{type:Object,default:()=>({})},preload:{type:String,default:"auto"},currentTime:{type:Boolean,default:!0},playsinline:{type:Boolean,default:!0},preLoading:{type:Boolean,default:!0}},emits:["exitfullscreen","play"],data(){return{player:null,loading:!0}},mounted(){this.loading=this.preLoading,this._init()},methods:{_init(){const e=["play-large","play","progress","captions","fullscreen"];this.currentTime&&e.push("current-time");const i={controls:e,...this.setting,invertTime:!1};Xe().iPhone&&(i.fullscreen={enabled:!0,fallback:"force",iosNative:!0}),this.player=new se(this.$refs.video,i),this.player.elements.container&&(this.player.elements.container.style.height=this.height||"210px"),this.preload==="none"&&(this.loading=!1),this.player.on("loadedmetadata",()=>{this.loading=!1,this.domPlayVisibility(!1)}),this.player.on("play",()=>{this.$emit("play",this.player)}),this.player.on("enterfullscreen",()=>{console.log("fullscreen");const t=document.createElement("i");t.id="fullscreen-back",t.className="van-icon van-icon-arrow-left video-back",t.addEventListener("click",()=>{this.player.fullscreen.exit()}),console.log(document.getElementsByClassName("plyr")),document.getElementsByClassName("plyr")[0].appendChild(t)}),this.player.on("exitfullscreen",()=>{console.log("exitfullscreen");const t=document.getElementById("fullscreen-back");t&&t.remove(),this.$emit("exitfullscreen")})},domPlayVisibility(e=!0){const i=document.querySelector(".plyr__controls"),t=document.querySelector(".plyr__control--overlaid");e?(i==null||i.setAttribute("style","display:none"),t==null||t.setAttribute("style","display:none")):(i==null||i.removeAttribute("style"),setTimeout(()=>{t==null||t.removeAttribute("style")},200))},onStop(){this.player.stop()}},unmounted(){var e;(e=this.player)==null||e.destroy()},render(){return D("div",{class:ye["video-container"]},[D("video",{ref:"video",class:ye.video,src:this.src,playsinline:this.playsinline,poster:this.poster,preload:this.preload,style:{...this.styleValue}},null),this.loading&&D("div",{class:ye.loadingVideo,style:{height:this.height||"210px"}},[D(Ct,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[Je("加载中...")]})])])}});function Gi(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!xt(e)}const es=Ge({name:"m-image-preview",props:{show:{tyep:Boolean,default:!1},images:{type:Array,default:()=>[]},showIndex:{type:Boolean,default:!0},startPosition:{type:Number,default:0},loop:{type:Boolean,default:!1},showDownload:{type:Boolean,default:!0},teleport:{type:String,default:""}},emits:["update:show"],setup(e,{emit:i}){const t=St({show:!1,index:e.startPosition+1,saveLoading:!1}),s=async r=>{var o;if(!t.saveLoading){t.saveLoading=!0,Nt({message:"下载中...",forbidClick:!0});try{const c=await Lt({api:"saveFile",content:{img:r,type:He(r,"image")?"image":"video"}});((o=c==null?void 0:c.content)==null?void 0:o.status)==="success"?It("保存成功"):$t("保存失败")}catch(c){}t.saveLoading=!1}},a=Et([]),n=r=>{a.value.forEach((o,c)=>{c!==r&&(o==null||o.onStop())})};return Oe(()=>{t.show=e.show}),je(()=>e.show,()=>{t.show=e.show,t.index=e.startPosition+1}),je(()=>e.startPosition,()=>{t.index=e.startPosition+1}),Oe(()=>{}),()=>{let r;return D(Pt,{teleport:e.teleport,show:t.show,"onUpdate:show":o=>t.show=o,"overlay-class":Re.overlayPreview,class:["van-image-preview",Re.imagePreview]},{default:()=>[t.show?D(Mt,null,[D(De,{name:Rt,class:"van-image-preview__close-icon van-image-preview__close-icon--top-left van-haptics-feedback",style:{top:G.navBarHeight?G.navBarHeight+"px":"var(--van-padding-md)"},onClick:()=>{n(-1),i("update:show",!1)}},null),D("div",{class:"van-image-preview__index",style:{top:G.navBarHeight?G.navBarHeight+"px":"var(--van-padding-md)"}},[t.index,Je(" / "),e.images.length]),e.showDownload&&Xe().isApp?D(De,{name:Bt,class:"van-image-preview__close-icon van-image-preview__close-icon--top-right van-haptics-feedback",style:{top:G.navBarHeight?G.navBarHeight+"px":"var(--van-padding-md)"},onClick:()=>{console.log(t.index,"index",e.images[t.index-1]),s(e.images[t.index-1])}},null):"",D(_t,{autoplay:0,loop:!1,class:"van-image-preview__swipe",showIndicators:!1,initialSwipe:e.startPosition,onChange:o=>{t.index=o+1,n(o)},lazyRender:!0},Gi(r=e.images.map((o,c)=>D(Ot,{class:"van-image-preview__swipe-item",onClick:()=>{n(-1),i("update:show",!1)}},{default:()=>[He(o,"image")?D(jt,{class:"van-image-preview__image",src:o},null):D("div",{class:"van-image-preview__image",onClick:u=>{u.stopPropagation(),u.preventDefault()}},[D(Yi,{ref:u=>a.value[c]=u,src:o,onPlay:()=>n(c),preLoading:!1},null)])]})))?r:{default:()=>[r]})]):""]})}}});export{es as M};