"object"==typeof navigator&&function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Plyr",t):e.Plyr=t()}(this,function(){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n=Math.pow(2,32))return N(this.elements.display.currentTime,!0),void N(this.elements.progress,!0);g.element(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);var e=g.element(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&ce.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&ce.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),ce.updateSeekTooltip.call(this)}},toggleMenuButton:function(e,t){N(this.elements.settings.buttons[e],!t)},updateSetting:function(e,t,n){var i,a=this.elements.settings.panels[e],s=null,o=t;if("captions"===e)s=this.currentTrack;else{if(s=g.empty(n)?this[e]:n,g.empty(s)&&(s=this.config[e].default),!g.empty(this.options[e])&&!this.options[e].includes(s))return void this.debug.warn("Unsupported value of '".concat(s,"' for ").concat(e));if(!this.config[e].options.includes(s))return void this.debug.warn("Disabled value of '".concat(s,"' for ").concat(e))}g.element(o)||(o=a&&a.querySelector('[role="menu"]')),g.element(o)&&(this.elements.settings.buttons[e].querySelector(".".concat(this.config.classNames.menu.value)).innerHTML=ce.getLabel.call(this,e,s),i=o&&o.querySelector('[value="'.concat(s,'"]')),g.element(i)&&(i.checked=!0))},getLabel:function(e,t){switch(e){case"speed":return 1===t?te("normal",this.config):"".concat(t,"×");case"quality":if(g.number(t)){var n=te("qualityLabel.".concat(t),this.config);return n.length?n:"".concat(t,"p")}return G(t);case"captions":return he.getLabel.call(this);default:return null}},setQualityMenu:function(e){var n,i,t,a=this;g.element(this.elements.settings.panels.quality)&&(n="quality",i=this.elements.settings.panels.quality.querySelector('[role="menu"]'),g.array(e)&&(this.options.quality=K(e).filter(function(e){return a.config.quality.options.includes(e)})),t=!g.empty(this.options.quality)&&1n.indexOf(t)?1:-1}).forEach(function(e){var t;ce.createMenuItem.call(a,{value:e,list:i,type:n,title:ce.getLabel.call(a,"quality",e),badge:(t=te("qualityBadge.".concat(e),a.config)).length?ce.createBadge.call(a,t):null})}),ce.updateSetting.call(this,n,i)))},setCaptionsMenu:function(){var e,n,t,i,a,s=this;g.element(this.elements.settings.panels.captions)&&(e="captions",n=this.elements.settings.panels.captions.querySelector('[role="menu"]'),t=he.getTracks.call(this),i=Boolean(t.length),ce.toggleMenuButton.call(this,e,i),C(n),ce.checkMenu.call(this),i&&((a=t.map(function(e,t){return{value:t,checked:s.captions.toggled&&s.currentTrack===t,title:he.getLabel.call(s,e),badge:e.language&&ce.createBadge.call(s,e.language.toUpperCase()),list:n,type:"language"}})).unshift({value:-1,checked:!this.captions.toggled,title:te("disabled",this.config),list:n,type:"language"}),a.forEach(ce.createMenuItem.bind(this)),ce.updateSetting.call(this,e,n)))},setSpeedMenu:function(e){var t,n,i,a=this;g.element(this.elements.settings.panels.speed)&&(t="speed",n=this.elements.settings.panels.speed.querySelector('[role="menu"]'),g.array(e)?this.options.speed=e:(this.isHTML5||this.isVimeo)&&(this.options.speed=[.5,.75,1,1.25,1.5,1.75,2]),this.options.speed=this.options.speed.filter(function(e){return a.config.speed.options.includes(e)}),i=!g.empty(this.options.speed)&&1=s?e:t)(i)}var i=new Image;Object.assign(i,{onload:n,onerror:n,src:a})})}var Ee={addStyleHook:function(){L(this.elements.container,this.config.selectors.container.replace(".",""),!0),L(this.elements.container,this.config.classNames.uiSupported,this.supported.ui)},toggleNativeControls:function(e){0Date.now(),this.toggleControls(Boolean(e||this.loading||this.paused||n.pressed||n.hover||t)))}},Pe=function(){function t(e){u(this,t),this.player=e,this.lastKey=null,this.focusTimer=null,this.lastKeyDown=null,this.handleKey=this.handleKey.bind(this),this.toggleMenu=this.toggleMenu.bind(this),this.setTabFocus=this.setTabFocus.bind(this),this.firstTouch=this.firstTouch.bind(this)}return e(t,[{key:"handleKey",value:function(e){var t=this.player,n=t.elements,i=e.keyCode?e.keyCode:e.which,a="keydown"===e.type,s=a&&i===this.lastKey;if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)&&g.number(i)){if(a){var o=document.activeElement;if(g.element(o)){var r=t.config.selectors.editable;if(o!==n.inputs.seek&&I(o,r))return;if(32===e.which&&I(o,'button, [role^="menuitem"]'))return}switch([32,37,38,39,40,48,49,50,51,52,53,54,56,57,67,70,73,75,76,77,79].includes(i)&&(e.preventDefault(),e.stopPropagation()),i){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:s||(t.currentTime=t.duration/10*(i-48));break;case 32:case 75:s||t.togglePlay();break;case 38:t.increaseVolume(.1);break;case 40:t.decreaseVolume(.1);break;case 77:s||(t.muted=!t.muted);break;case 39:t.forward();break;case 37:t.rewind();break;case 70:t.fullscreen.toggle();break;case 67:s||t.toggleCaptions();break;case 76:t.loop=!t.loop}!t.fullscreen.enabled&&t.fullscreen.active&&27===i&&t.fullscreen.toggle(),this.lastKey=i}else this.lastKey=null}}},{key:"toggleMenu",value:function(e){ce.toggleMenu.call(this.player,e)}},{key:"firstTouch",value:function(){var e=this.player,t=e.elements;e.touch=!0,L(t.container,e.config.classNames.isTouch,!0)}},{key:"setTabFocus",value:function(e){var t,n,i=this.player,a=i.elements;clearTimeout(this.focusTimer),"keydown"===e.type&&9!==e.which||("keydown"===e.type&&(this.lastKeyDown=e.timeStamp),t=e.timeStamp-this.lastKeyDown<=20,"focus"===e.type&&!t||(n=i.config.classNames.tabFocus,L(_.call(i,".".concat(n)),n,!1),this.focusTimer=setTimeout(function(){var e=document.activeElement;a.container.contains(e)&&L(document.activeElement,i.config.classNames.tabFocus,!0)},10)))}},{key:"global",value:function(e){var t=!(0Math.abs(a)?i:a);r.increaseVolume(s/50);var o=r.media.volume;(1===s&&o<1||-1===s&&0