mediacms/static/lib/video-js/8.2.0/video.es.js

2 wiersze
476 KiB
JavaScript
Czysty Wina Historia

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

/*! For license information please see video.es.js.LICENSE.txt */
import window$1 from"global/window";import document from"global/document";import keycode from"keycode";import safeParseTuple from"safe-json-parse/tuple";import XHR from"@videojs/xhr";import vtt from"videojs-vtt.js";import _resolveUrl from"@videojs/vhs-utils/es/resolve-url.js";import _extends from"@babel/runtime/helpers/extends";import{Parser}from"m3u8-parser";import{DEFAULT_VIDEO_CODEC,DEFAULT_AUDIO_CODEC,parseCodecs,muxerSupportsCodec,browserSupportsCodec,translateLegacyCodec,codecsFromDefault,isAudioCodec,getMimeForCodec}from"@videojs/vhs-utils/es/codecs.js";import{simpleTypeFromSourceType}from"@videojs/vhs-utils/es/media-types.js";import{isArrayBufferView,concatTypedArrays,stringToBytes,toUint8}from"@videojs/vhs-utils/es/byte-helpers";import{generateSidxKey,parseUTCTiming,parse,addSidxSegmentsToPlaylist}from"mpd-parser";import parseSidx from"mux.js/lib/tools/parse-sidx";import{getId3Offset}from"@videojs/vhs-utils/es/id3-helpers";import{detectContainerForBytes,isLikelyFmp4MediaSegment}from"@videojs/vhs-utils/es/containers";import{ONE_SECOND_IN_TS}from"mux.js/lib/utils/clock";var version$6="8.2.0";const hooks_={},hooks=function(e,t){return hooks_[e]=hooks_[e]||[],t&&(hooks_[e]=hooks_[e].concat(t)),hooks_[e]},hook=function(e,t){hooks(e,t)},removeHook=function(e,t){const i=hooks(e).indexOf(t);return!(i<=-1||(hooks_[e]=hooks_[e].slice(),hooks_[e].splice(i,1),0))},hookOnce=function(e,t){hooks(e,[].concat(t).map((t=>{const i=(...s)=>(removeHook(e,i),t(...s));return i})))},FullscreenApi={prefixed:!0},apiMap=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror","-moz-full-screen"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError","-ms-fullscreen"]],specApi=apiMap[0];let browserApi;for(let e=0;e<apiMap.length;e++)if(apiMap[e][1]in document){browserApi=apiMap[e];break}if(browserApi){for(let e=0;e<browserApi.length;e++)FullscreenApi[specApi[e]]=browserApi[e];FullscreenApi.prefixed=browserApi[0]!==specApi[0]}let history=[];const LogByTypeFactory=(e,t)=>(i,s,n)=>{const r=t.levels[s],a=new RegExp(`^(${r})$`);if("log"!==i&&n.unshift(i.toUpperCase()+":"),n.unshift(e+":"),history){history.push([].concat(n));const e=history.length-1e3;history.splice(0,e>0?e:0)}if(!window$1.console)return;let o=window$1.console[i];o||"debug"!==i||(o=window$1.console.info||window$1.console.log),o&&r&&a.test(i)&&o[Array.isArray(n)?"apply":"call"](window$1.console,n)};function createLogger$1(e){let t,i="info";const s=function(...e){t("log",i,e)};return t=LogByTypeFactory(e,s),s.createLogger=t=>createLogger$1(e+": "+t),s.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:i},s.level=e=>{if("string"==typeof e){if(!s.levels.hasOwnProperty(e))throw new Error(`"${e}" in not a valid log level`);i=e}return i},(s.history=()=>history?[].concat(history):[]).filter=e=>(history||[]).filter((t=>new RegExp(`.*${e}.*`).test(t[0]))),s.history.clear=()=>{history&&(history.length=0)},s.history.disable=()=>{null!==history&&(history.length=0,history=null)},s.history.enable=()=>{null===history&&(history=[])},s.error=(...e)=>t("error",i,e),s.warn=(...e)=>t("warn",i,e),s.debug=(...e)=>t("debug",i,e),s}const log$1=createLogger$1("VIDEOJS"),createLogger=log$1.createLogger,toString=Object.prototype.toString,keys=function(e){return isObject(e)?Object.keys(e):[]};function each(e,t){keys(e).forEach((i=>t(e[i],i)))}function reduce(e,t,i=0){return keys(e).reduce(((i,s)=>t(i,e[s],s)),i)}function isObject(e){return!!e&&"object"==typeof e}function isPlain(e){return isObject(e)&&"[object Object]"===toString.call(e)&&e.constructor===Object}function merge$1(...e){const t={};return e.forEach((e=>{e&&each(e,((e,i)=>{isPlain(e)?(isPlain(t[i])||(t[i]={}),t[i]=merge$1(t[i],e)):t[i]=e}))})),t}function defineLazyProperty(e,t,i,s=!0){const n=i=>Object.defineProperty(e,t,{value:i,enumerable:!0,writable:!0}),r={configurable:!0,enumerable:!0,get(){const e=i();return n(e),e}};return s&&(r.set=n),Object.defineProperty(e,t,r)}var Obj=Object.freeze({__proto__:null,each:each,reduce:reduce,isObject:isObject,isPlain:isPlain,merge:merge$1,defineLazyProperty:defineLazyProperty});let ANDROID_VERSION,IS_IPOD=!1,IOS_VERSION=null,IS_ANDROID=!1,IS_FIREFOX=!1,IS_EDGE=!1,IS_CHROMIUM=!1,IS_CHROME=!1,CHROMIUM_VERSION=null,CHROME_VERSION=null,IE_VERSION=null,IS_SAFARI=!1,IS_WINDOWS=!1,IS_IPAD=!1,IS_IPHONE=!1;const TOUCH_ENABLED=Boolean(isReal()&&("ontouchstart"in window$1||window$1.navigator.maxTouchPoints||window$1.DocumentTouch&&window$1.document instanceof window$1.DocumentTouch)),UAD=window$1.navigator&&window$1.navigator.userAgentData;if(UAD&&(IS_ANDROID="Android"===UAD.platform,IS_EDGE=Boolean(UAD.brands.find((e=>"Microsoft Edge"===e.brand))),IS_CHROMIUM=Boolean(UAD.brands.find((e=>"Chromium"===e.brand))),IS_CHROME=!IS_EDGE&&IS_CHROMIUM,CHROMIUM_VERSION=CHROME_VERSION=(UAD.brands.find((e=>"Chromium"===e.brand))||{}).version||null,IS_WINDOWS="Windows"===UAD.platform),!IS_CHROMIUM){const e=window$1.navigator&&window$1.navigator.userAgent||"";IS_IPOD=/iPod/i.test(e),IOS_VERSION=function(){const t=e.match(/OS (\d+)_/i);return t&&t[1]?t[1]:null}(),IS_ANDROID=/Android/i.test(e),ANDROID_VERSION=function(){const t=e.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!t)return null;const i=t[1]&&parseFloat(t[1]),s=t[2]&&parseFloat(t[2]);return i&&s?parseFloat(t[1]+"."+t[2]):i||null}(),IS_FIREFOX=/Firefox/i.test(e),IS_EDGE=/Edg/i.test(e),IS_CHROMIUM=/Chrome/i.test(e)||/CriOS/i.test(e),IS_CHROME=!IS_EDGE&&IS_CHROMIUM,CHROMIUM_VERSION=CHROME_VERSION=function(){const t=e.match(/(Chrome|CriOS)\/(\d+)/);return t&&t[2]?parseFloat(t[2]):null}(),IE_VERSION=function(){const t=/MSIE\s(\d+)\.\d/.exec(e);let i=t&&parseFloat(t[1]);return!i&&/Trident\/7.0/i.test(e)&&/rv:11.0/.test(e)&&(i=11),i}(),IS_SAFARI=/Safari/i.test(e)&&!IS_CHROME&&!IS_ANDROID&&!IS_EDGE,IS_WINDOWS=/Windows/i.test(e),IS_IPAD=/iPad/i.test(e)||IS_SAFARI&&TOUCH_ENABLED&&!/iPhone/i.test(e),IS_IPHONE=/iPhone/i.test(e)&&!IS_IPAD}const IS_IOS=IS_IPHONE||IS_IPAD||IS_IPOD,IS_ANY_SAFARI=(IS_SAFARI||IS_IOS)&&!IS_CHROME;var browser=Object.freeze({__proto__:null,get IS_IPOD(){return IS_IPOD},get IOS_VERSION(){return IOS_VERSION},get IS_ANDROID(){return IS_ANDROID},get ANDROID_VERSION(){return ANDROID_VERSION},get IS_FIREFOX(){return IS_FIREFOX},get IS_EDGE(){return IS_EDGE},get IS_CHROMIUM(){return IS_CHROMIUM},get IS_CHROME(){return IS_CHROME},get CHROMIUM_VERSION(){return CHROMIUM_VERSION},get CHROME_VERSION(){return CHROME_VERSION},get IE_VERSION(){return IE_VERSION},get IS_SAFARI(){return IS_SAFARI},get IS_WINDOWS(){return IS_WINDOWS},get IS_IPAD(){return IS_IPAD},get IS_IPHONE(){return IS_IPHONE},TOUCH_ENABLED:TOUCH_ENABLED,IS_IOS:IS_IOS,IS_ANY_SAFARI:IS_ANY_SAFARI});function isNonBlankString(e){return"string"==typeof e&&Boolean(e.trim())}function throwIfWhitespace(e){if(e.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}function isReal(){return document===window$1.document}function isEl(e){return isObject(e)&&1===e.nodeType}function isInFrame(){try{return window$1.parent!==window$1.self}catch(e){return!0}}function createQuerier(e){return function(t,i){if(!isNonBlankString(t))return document[e](null);isNonBlankString(i)&&(i=document.querySelector(i));const s=isEl(i)?i:document;return s[e]&&s[e](t)}}function createEl(e="div",t={},i={},s){const n=document.createElement(e);return Object.getOwnPropertyNames(t).forEach((function(e){const i=t[e];"textContent"===e?textContent(n,i):n[e]===i&&"tabIndex"!==e||(n[e]=i)})),Object.getOwnPropertyNames(i).forEach((function(e){n.setAttribute(e,i[e])})),s&&appendContent(n,s),n}function textContent(e,t){return void 0===e.textContent?e.innerText=t:e.textContent=t,e}function prependTo(e,t){t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)}function hasClass(e,t){return throwIfWhitespace(t),e.classList.contains(t)}function addClass(e,...t){return e.classList.add(...t.reduce(((e,t)=>e.concat(t.split(/\s+/))),[])),e}function removeClass(e,...t){return e?(e.classList.remove(...t.reduce(((e,t)=>e.concat(t.split(/\s+/))),[])),e):(log$1.warn("removeClass was called with an element that doesn't exist"),null)}function toggleClass(e,t,i){return"function"==typeof i&&(i=i(e,t)),"boolean"!=typeof i&&(i=void 0),t.split(/\s+/).forEach((t=>e.classList.toggle(t,i))),e}function setAttributes(e,t){Object.getOwnPropertyNames(t).forEach((function(i){const s=t[i];null==s||!1===s?e.removeAttribute(i):e.setAttribute(i,!0===s?"":s)}))}function getAttributes(e){const t={};if(e&&e.attributes&&e.attributes.length>0){const i=e.attributes;for(let s=i.length-1;s>=0;s--){const n=i[s].name;let r=i[s].value;"boolean"!=typeof e[n]&&-1===",autoplay,controls,playsinline,loop,muted,default,defaultMuted,".indexOf(","+n+",")||(r=null!==r),t[n]=r}}return t}function getAttribute(e,t){return e.getAttribute(t)}function setAttribute(e,t,i){e.setAttribute(t,i)}function removeAttribute(e,t){e.removeAttribute(t)}function blockTextSelection(){document.body.focus(),document.onselectstart=function(){return!1}}function unblockTextSelection(){document.onselectstart=function(){return!0}}function getBoundingClientRect(e){if(e&&e.getBoundingClientRect&&e.parentNode){const t=e.getBoundingClientRect(),i={};return["bottom","height","left","right","top","width"].forEach((e=>{void 0!==t[e]&&(i[e]=t[e])})),i.height||(i.height=parseFloat(computedStyle(e,"height"))),i.width||(i.width=parseFloat(computedStyle(e,"width"))),i}}function findPosition(e){if(!e||e&&!e.offsetParent)return{left:0,top:0,width:0,height:0};const t=e.offsetWidth,i=e.offsetHeight;let s=0,n=0;for(;e.offsetParent&&e!==document[FullscreenApi.fullscreenElement];)s+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;return{left:s,top:n,width:t,height:i}}function getPointerPosition(e,t){const i={x:0,y:0};if(IS_IOS){let t=e;for(;t&&"html"!==t.nodeName.toLowerCase();){const e=computedStyle(t,"transform");if(/^matrix/.test(e)){const t=e.slice(7,-1).split(/,\s/).map(Number);i.x+=t[4],i.y+=t[5]}else if(/^matrix3d/.test(e)){const t=e.slice(9,-1).split(/,\s/).map(Number);i.x+=t[12],i.y+=t[13]}t=t.parentNode}}const s={},n=findPosition(t.target),r=findPosition(e),a=r.width,o=r.height;let l=t.offsetY-(r.top-n.top),d=t.offsetX-(r.left-n.left);return t.changedTouches&&(d=t.changedTouches[0].pageX-r.left,l=t.changedTouches[0].pageY+r.top,IS_IOS&&(d-=i.x,l-=i.y)),s.y=1-Math.max(0,Math.min(1,l/o)),s.x=Math.max(0,Math.min(1,d/a)),s}function isTextNode(e){return isObject(e)&&3===e.nodeType}function emptyEl(e){for(;e.firstChild;)e.removeChild(e.firstChild);return e}function normalizeContent(e){return"function"==typeof e&&(e=e()),(Array.isArray(e)?e:[e]).map((e=>("function"==typeof e&&(e=e()),isEl(e)||isTextNode(e)?e:"string"==typeof e&&/\S/.test(e)?document.createTextNode(e):void 0))).filter((e=>e))}function appendContent(e,t){return normalizeContent(t).forEach((t=>e.appendChild(t))),e}function insertContent(e,t){return appendContent(emptyEl(e),t)}function isSingleLeftClick(e){return void 0===e.button&&void 0===e.buttons||0===e.button&&void 0===e.buttons||"mouseup"===e.type&&0===e.button&&0===e.buttons||0===e.button&&1===e.buttons}const $=createQuerier("querySelector"),$$=createQuerier("querySelectorAll");function computedStyle(e,t){if(!e||!t)return"";if("function"==typeof window$1.getComputedStyle){let i;try{i=window$1.getComputedStyle(e)}catch(e){return""}return i?i.getPropertyValue(t)||i[t]:""}return""}var Dom=Object.freeze({__proto__:null,isReal:isReal,isEl:isEl,isInFrame:isInFrame,createEl:createEl,textContent:textContent,prependTo:prependTo,hasClass:hasClass,addClass:addClass,removeClass:removeClass,toggleClass:toggleClass,setAttributes:setAttributes,getAttributes:getAttributes,getAttribute:getAttribute,setAttribute:setAttribute,removeAttribute:removeAttribute,blockTextSelection:blockTextSelection,unblockTextSelection:unblockTextSelection,getBoundingClientRect:getBoundingClientRect,findPosition:findPosition,getPointerPosition:getPointerPosition,isTextNode:isTextNode,emptyEl:emptyEl,normalizeContent:normalizeContent,appendContent:appendContent,insertContent:insertContent,isSingleLeftClick:isSingleLeftClick,$:$,$$:$$,computedStyle:computedStyle});let videojs$1,_windowLoaded=!1;const autoSetup=function(){if(!1===videojs$1.options.autoSetup)return;const e=Array.prototype.slice.call(document.getElementsByTagName("video")),t=Array.prototype.slice.call(document.getElementsByTagName("audio")),i=Array.prototype.slice.call(document.getElementsByTagName("video-js")),s=e.concat(t,i);if(s&&s.length>0)for(let e=0,t=s.length;e<t;e++){const t=s[e];if(!t||!t.getAttribute){autoSetupTimeout(1);break}void 0===t.player&&null!==t.getAttribute("data-setup")&&videojs$1(t)}else _windowLoaded||autoSetupTimeout(1)};function autoSetupTimeout(e,t){isReal()&&(t&&(videojs$1=t),window$1.setTimeout(autoSetup,e))}function setWindowLoaded(){_windowLoaded=!0,window$1.removeEventListener("load",setWindowLoaded)}isReal()&&("complete"===document.readyState?setWindowLoaded():window$1.addEventListener("load",setWindowLoaded));const createStyleElement=function(e){const t=document.createElement("style");return t.className=e,t},setTextContent=function(e,t){e.styleSheet?e.styleSheet.cssText=t:e.textContent=t};var DomData=new WeakMap;const _initialGuid=3;let _supportsPassive,_guid=3;function newGUID(){return _guid++}function _cleanUpEvents(e,t){if(!DomData.has(e))return;const i=DomData.get(e);0===i.handlers[t].length&&(delete i.handlers[t],e.removeEventListener?e.removeEventListener(t,i.dispatcher,!1):e.detachEvent&&e.detachEvent("on"+t,i.dispatcher)),Object.getOwnPropertyNames(i.handlers).length<=0&&(delete i.handlers,delete i.dispatcher,delete i.disabled),0===Object.getOwnPropertyNames(i).length&&DomData.delete(e)}function _handleMultipleEvents(e,t,i,s){i.forEach((function(i){e(t,i,s)}))}function fixEvent(e){if(e.fixed_)return e;function t(){return!0}function i(){return!1}if(!e||!e.isPropagationStopped||!e.isImmediatePropagationStopped){const s=e||window$1.event;e={};for(const t in s)"layerX"!==t&&"layerY"!==t&&"keyLocation"!==t&&"webkitMovementX"!==t&&"webkitMovementY"!==t&&"path"!==t&&("returnValue"===t&&s.preventDefault||(e[t]=s[t]));if(e.target||(e.target=e.srcElement||document),e.relatedTarget||(e.relatedTarget=e.fromElement===e.target?e.toElement:e.fromElement),e.preventDefault=function(){s.preventDefault&&s.preventDefault(),e.returnValue=!1,s.returnValue=!1,e.defaultPrevented=!0},e.defaultPrevented=!1,e.stopPropagation=function(){s.stopPropagation&&s.stopPropagation(),e.cancelBubble=!0,s.cancelBubble=!0,e.isPropagationStopped=t},e.isPropagationStopped=i,e.stopImmediatePropagation=function(){s.stopImmediatePropagation&&s.stopImmediatePropagation(),e.isImmediatePropagationStopped=t,e.stopPropagation()},e.isImmediatePropagationStopped=i,null!==e.clientX&&void 0!==e.clientX){const t=document.documentElement,i=document.body;e.pageX=e.clientX+(t&&t.scrollLeft||i&&i.scrollLeft||0)-(t&&t.clientLeft||i&&i.clientLeft||0),e.pageY=e.clientY+(t&&t.scrollTop||i&&i.scrollTop||0)-(t&&t.clientTop||i&&i.clientTop||0)}e.which=e.charCode||e.keyCode,null!==e.button&&void 0!==e.button&&(e.button=1&e.button?0:4&e.button?1:2&e.button?2:0)}return e.fixed_=!0,e}const supportsPassive=function(){if("boolean"!=typeof _supportsPassive){_supportsPassive=!1;try{const e=Object.defineProperty({},"passive",{get(){_supportsPassive=!0}});window$1.addEventListener("test",null,e),window$1.removeEventListener("test",null,e)}catch(e){}}return _supportsPassive},passiveEvents=["touchstart","touchmove"];function on(e,t,i){if(Array.isArray(t))return _handleMultipleEvents(on,e,t,i);DomData.has(e)||DomData.set(e,{});const s=DomData.get(e);if(s.handlers||(s.handlers={}),s.handlers[t]||(s.handlers[t]=[]),i.guid||(i.guid=newGUID()),s.handlers[t].push(i),s.dispatcher||(s.disabled=!1,s.dispatcher=function(t,i){if(s.disabled)return;t=fixEvent(t);const n=s.handlers[t.type];if(n){const s=n.slice(0);for(let n=0,r=s.length;n<r&&!t.isImmediatePropagationStopped();n++)try{s[n].call(e,t,i)}catch(e){log$1.error(e)}}}),1===s.handlers[t].length)if(e.addEventListener){let i=!1;supportsPassive()&&passiveEvents.indexOf(t)>-1&&(i={passive:!0}),e.addEventListener(t,s.dispatcher,i)}else e.attachEvent&&e.attachEvent("on"+t,s.dispatcher)}function off(e,t,i){if(!DomData.has(e))return;const s=DomData.get(e);if(!s.handlers)return;if(Array.isArray(t))return _handleMultipleEvents(off,e,t,i);const n=function(e,t){s.handlers[t]=[],_cleanUpEvents(e,t)};if(void 0===t){for(const t in s.handlers)Object.prototype.hasOwnProperty.call(s.handlers||{},t)&&n(e,t);return}const r=s.handlers[t];if(r)if(i){if(i.guid)for(let e=0;e<r.length;e++)r[e].guid===i.guid&&r.splice(e--,1);_cleanUpEvents(e,t)}else n(e,t)}function trigger(e,t,i){const s=DomData.has(e)?DomData.get(e):{},n=e.parentNode||e.ownerDocument;if("string"==typeof t?t={type:t,target:e}:t.target||(t.target=e),t=fixEvent(t),s.dispatcher&&s.dispatcher.call(e,t,i),n&&!t.isPropagationStopped()&&!0===t.bubbles)trigger.call(null,n,t,i);else if(!n&&!t.defaultPrevented&&t.target&&t.target[t.type]){DomData.has(t.target)||DomData.set(t.target,{});const e=DomData.get(t.target);t.target[t.type]&&(e.disabled=!0,"function"==typeof t.target[t.type]&&t.target[t.type](),e.disabled=!1)}return!t.defaultPrevented}function one(e,t,i){if(Array.isArray(t))return _handleMultipleEvents(one,e,t,i);const s=function(){off(e,t,s),i.apply(this,arguments)};s.guid=i.guid=i.guid||newGUID(),on(e,t,s)}function any(e,t,i){const s=function(){off(e,t,s),i.apply(this,arguments)};s.guid=i.guid=i.guid||newGUID(),on(e,t,s)}var Events=Object.freeze({__proto__:null,fixEvent:fixEvent,on:on,off:off,trigger:trigger,one:one,any:any});const UPDATE_REFRESH_INTERVAL=30,bind_=function(e,t,i){t.guid||(t.guid=newGUID());const s=t.bind(e);return s.guid=i?i+"_"+t.guid:t.guid,s},throttle=function(e,t){let i=window$1.performance.now();return function(...s){const n=window$1.performance.now();n-i>=t&&(e(...s),i=n)}},debounce=function(e,t,i,s=window$1){let n;const r=function(){const r=this,a=arguments;let o=function(){n=null,o=null,i||e.apply(r,a)};!n&&i&&e.apply(r,a),s.clearTimeout(n),n=s.setTimeout(o,t)};return r.cancel=()=>{s.clearTimeout(n),n=null},r};var Fn=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:30,bind_:bind_,throttle:throttle,debounce:debounce});let EVENT_MAP;class EventTarget$2{on(e,t){const i=this.addEventListener;this.addEventListener=()=>{},on(this,e,t),this.addEventListener=i}off(e,t){off(this,e,t)}one(e,t){const i=this.addEventListener;this.addEventListener=()=>{},one(this,e,t),this.addEventListener=i}any(e,t){const i=this.addEventListener;this.addEventListener=()=>{},any(this,e,t),this.addEventListener=i}trigger(e){const t=e.type||e;"string"==typeof e&&(e={type:t}),e=fixEvent(e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),trigger(this,e)}queueTrigger(e){EVENT_MAP||(EVENT_MAP=new Map);const t=e.type||e;let i=EVENT_MAP.get(this);i||(i=new Map,EVENT_MAP.set(this,i));const s=i.get(t);i.delete(t),window$1.clearTimeout(s);const n=window$1.setTimeout((()=>{i.delete(t),0===i.size&&(i=null,EVENT_MAP.delete(this)),this.trigger(e)}),0);i.set(t,n)}}EventTarget$2.prototype.allowedEvents_={},EventTarget$2.prototype.addEventListener=EventTarget$2.prototype.on,EventTarget$2.prototype.removeEventListener=EventTarget$2.prototype.off,EventTarget$2.prototype.dispatchEvent=EventTarget$2.prototype.trigger;const objName=e=>"function"==typeof e.name?e.name():"string"==typeof e.name?e.name:e.name_?e.name_:e.constructor&&e.constructor.name?e.constructor.name:typeof e,isEvented=e=>e instanceof EventTarget$2||!!e.eventBusEl_&&["on","one","off","trigger"].every((t=>"function"==typeof e[t])),addEventedCallback=(e,t)=>{isEvented(e)?t():(e.eventedCallbacks||(e.eventedCallbacks=[]),e.eventedCallbacks.push(t))},isValidEventType=e=>"string"==typeof e&&/\S/.test(e)||Array.isArray(e)&&!!e.length,validateTarget=(e,t,i)=>{if(!e||!e.nodeName&&!isEvented(e))throw new Error(`Invalid target for ${objName(t)}#${i}; must be a DOM node or evented object.`)},validateEventType=(e,t,i)=>{if(!isValidEventType(e))throw new Error(`Invalid event type for ${objName(t)}#${i}; must be a non-empty string or array.`)},validateListener=(e,t,i)=>{if("function"!=typeof e)throw new Error(`Invalid listener for ${objName(t)}#${i}; must be a function.`)},normalizeListenArgs=(e,t,i)=>{const s=t.length<3||t[0]===e||t[0]===e.eventBusEl_;let n,r,a;return s?(n=e.eventBusEl_,t.length>=3&&t.shift(),[r,a]=t):[n,r,a]=t,validateTarget(n,e,i),validateEventType(r,e,i),validateListener(a,e,i),a=bind_(e,a),{isTargetingSelf:s,target:n,type:r,listener:a}},listen=(e,t,i,s)=>{validateTarget(e,e,t),e.nodeName?Events[t](e,i,s):e[t](i,s)},EventedMixin={on(...e){const{isTargetingSelf:t,target:i,type:s,listener:n}=normalizeListenArgs(this,e,"on");if(listen(i,"on",s,n),!t){const e=()=>this.off(i,s,n);e.guid=n.guid;const t=()=>this.off("dispose",e);t.guid=n.guid,listen(this,"on","dispose",e),listen(i,"on","dispose",t)}},one(...e){const{isTargetingSelf:t,target:i,type:s,listener:n}=normalizeListenArgs(this,e,"one");if(t)listen(i,"one",s,n);else{const e=(...t)=>{this.off(i,s,e),n.apply(null,t)};e.guid=n.guid,listen(i,"one",s,e)}},any(...e){const{isTargetingSelf:t,target:i,type:s,listener:n}=normalizeListenArgs(this,e,"any");if(t)listen(i,"any",s,n);else{const e=(...t)=>{this.off(i,s,e),n.apply(null,t)};e.guid=n.guid,listen(i,"any",s,e)}},off(e,t,i){if(!e||isValidEventType(e))off(this.eventBusEl_,e,t);else{const s=e,n=t;validateTarget(s,this,"off"),validateEventType(n,this,"off"),validateListener(i,this,"off"),i=bind_(this,i),this.off("dispose",i),s.nodeName?(off(s,n,i),off(s,"dispose",i)):isEvented(s)&&(s.off(n,i),s.off("dispose",i))}},trigger(e,t){validateTarget(this.eventBusEl_,this,"trigger");const i=e&&"string"!=typeof e?e.type:e;if(!isValidEventType(i))throw new Error(`Invalid event type for ${objName(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return trigger(this.eventBusEl_,e,t)}};function evented(e,t={}){const{eventBusKey:i}=t;if(i){if(!e[i].nodeName)throw new Error(`The eventBusKey "${i}" does not refer to an element.`);e.eventBusEl_=e[i]}else e.eventBusEl_=createEl("span",{className:"vjs-event-bus"});return Object.assign(e,EventedMixin),e.eventedCallbacks&&e.eventedCallbacks.forEach((e=>{e()})),e.on("dispose",(()=>{e.off(),[e,e.el_,e.eventBusEl_].forEach((function(e){e&&DomData.has(e)&&DomData.delete(e)})),window$1.setTimeout((()=>{e.eventBusEl_=null}),0)})),e}const StatefulMixin={state:{},setState(e){let t;return"function"==typeof e&&(e=e()),each(e,((e,i)=>{this.state[i]!==e&&(t=t||{},t[i]={from:this.state[i],to:e}),this.state[i]=e})),t&&isEvented(this)&&this.trigger({changes:t,type:"statechanged"}),t}};function stateful(e,t){return Object.assign(e,StatefulMixin),e.state=Object.assign({},e.state,t),"function"==typeof e.handleStateChanged&&isEvented(e)&&e.on("statechanged",e.handleStateChanged),e}const toLowerCase=function(e){return"string"!=typeof e?e:e.replace(/./,(e=>e.toLowerCase()))},toTitleCase$1=function(e){return"string"!=typeof e?e:e.replace(/./,(e=>e.toUpperCase()))},titleCaseEquals=function(e,t){return toTitleCase$1(e)===toTitleCase$1(t)};var Str=Object.freeze({__proto__:null,toLowerCase:toLowerCase,toTitleCase:toTitleCase$1,titleCaseEquals:titleCaseEquals});class Component$1{constructor(e,t,i){if(!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=merge$1({},this.options_),t=this.options_=merge$1(this.options_,t),this.id_=t.id||t.el&&t.el.id,!this.id_){const t=e&&e.id&&e.id()||"no_player";this.id_=`${t}_component_${newGUID()}`}this.name_=t.name||null,t.el?this.el_=t.el:!1!==t.createEl&&(this.el_=this.createEl()),t.className&&this.el_&&t.className.split(" ").forEach((e=>this.addClass(e))),["on","off","one","any","trigger"].forEach((e=>{this[e]=void 0})),!1!==t.evented&&(evented(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),stateful(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,!1!==t.initChildren&&this.initChildren(),this.ready(i),!1!==t.reportTouchActivity&&this.enableTouchActivity()}on(e,t){}off(e,t){}one(e,t){}any(e,t){}trigger(e){}dispose(e={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let e=this.children_.length-1;e>=0;e--)this.children_[e].dispose&&this.children_[e].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(e.restoreEl?this.el_.parentNode.replaceChild(e.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return Boolean(this.isDisposed_)}player(){return this.player_}options(e){return e?(this.options_=merge$1(this.options_,e),this.options_):this.options_}el(){return this.el_}createEl(e,t,i){return createEl(e,t,i)}localize(e,t,i=e){const s=this.player_.language&&this.player_.language(),n=this.player_.languages&&this.player_.languages(),r=n&&n[s],a=s&&s.split("-")[0],o=n&&n[a];let l=i;return r&&r[e]?l=r[e]:o&&o[e]&&(l=o[e]),t&&(l=l.replace(/\{(\d+)\}/g,(function(e,i){const s=t[i-1];let n=s;return void 0===s&&(n=e),n}))),l}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(e)return this.childNameIndex_[e]}getDescendant(...e){e=e.reduce(((e,t)=>e.concat(t)),[]);let t=this;for(let i=0;i<e.length;i++)if(t=t.getChild(e[i]),!t||!t.getChild)return;return t}addChild(e,t={},i=this.children_.length){let s,n;if("string"==typeof e){n=toTitleCase$1(e);const i=t.componentClass||n;t.name=n;const r=Component$1.getComponent(i);if(!r)throw new Error(`Component ${i} does not exist`);if("function"!=typeof r)return null;s=new r(this.player_||this,t)}else s=e;if(s.parentComponent_&&s.parentComponent_.removeChild(s),this.children_.splice(i,0,s),s.parentComponent_=this,"function"==typeof s.id&&(this.childIndex_[s.id()]=s),n=n||s.name&&toTitleCase$1(s.name()),n&&(this.childNameIndex_[n]=s,this.childNameIndex_[toLowerCase(n)]=s),"function"==typeof s.el&&s.el()){let e=null;this.children_[i+1]&&(this.children_[i+1].el_?e=this.children_[i+1].el_:isEl(this.children_[i+1])&&(e=this.children_[i+1])),this.contentEl().insertBefore(s.el(),e)}return s}removeChild(e){if("string"==typeof e&&(e=this.getChild(e)),!e||!this.children_)return;let t=!1;for(let i=this.children_.length-1;i>=0;i--)if(this.children_[i]===e){t=!0,this.children_.splice(i,1);break}if(!t)return;e.parentComponent_=null,this.childIndex_[e.id()]=null,this.childNameIndex_[toTitleCase$1(e.name())]=null,this.childNameIndex_[toLowerCase(e.name())]=null;const i=e.el();i&&i.parentNode===this.contentEl()&&this.contentEl().removeChild(e.el())}initChildren(){const e=this.options_.children;if(e){const t=this.options_,i=e=>{const i=e.name;let s=e.opts;if(void 0!==t[i]&&(s=t[i]),!1===s)return;!0===s&&(s={}),s.playerOptions=this.options_.playerOptions;const n=this.addChild(i,s);n&&(this[i]=n)};let s;const n=Component$1.getComponent("Tech");s=Array.isArray(e)?e:Object.keys(e),s.concat(Object.keys(this.options_).filter((function(e){return!s.some((function(t){return"string"==typeof t?e===t:e===t.name}))}))).map((t=>{let i,s;return"string"==typeof t?(i=t,s=e[i]||this.options_[i]||{}):(i=t.name,s=t),{name:i,opts:s}})).filter((e=>{const t=Component$1.getComponent(e.opts.componentClass||toTitleCase$1(e.name));return t&&!n.isTech(t)})).forEach(i)}}buildCSSClass(){return""}ready(e,t=!1){if(e)return this.isReady_?void(t?e.call(this):this.setTimeout(e,1)):(this.readyQueue_=this.readyQueue_||[],void this.readyQueue_.push(e))}triggerReady(){this.isReady_=!0,this.setTimeout((function(){const e=this.readyQueue_;this.readyQueue_=[],e&&e.length>0&&e.forEach((function(e){e.call(this)}),this),this.trigger("ready")}),1)}$(e,t){return $(e,t||this.contentEl())}$$(e,t){return $$(e,t||this.contentEl())}hasClass(e){return hasClass(this.el_,e)}addClass(...e){addClass(this.el_,...e)}removeClass(...e){removeClass(this.el_,...e)}toggleClass(e,t){toggleClass(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return getAttribute(this.el_,e)}setAttribute(e,t){setAttribute(this.el_,e,t)}removeAttribute(e){removeAttribute(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,i){if(void 0!==t)return null!==t&&t==t||(t=0),-1!==(""+t).indexOf("%")||-1!==(""+t).indexOf("px")?this.el_.style[e]=t:this.el_.style[e]="auto"===t?"":t+"px",void(i||this.trigger("componentresize"));if(!this.el_)return 0;const s=this.el_.style[e],n=s.indexOf("px");return-1!==n?parseInt(s.slice(0,n),10):parseInt(this.el_["offset"+toTitleCase$1(e)],10)}currentDimension(e){let t=0;if("width"!==e&&"height"!==e)throw new Error("currentDimension only accepts width or height value");if(t=computedStyle(this.el_,e),t=parseFloat(t),0===t||isNaN(t)){const i=`offset${toTitleCase$1(e)}`;t=this.el_[i]}return t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){this.player_&&(keycode.isEventKey(e,"Tab")||e.stopPropagation(),this.player_.handleKeyDown(e))}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let e,t=0,i=null;this.on("touchstart",(function(s){1===s.touches.length&&(i={pageX:s.touches[0].pageX,pageY:s.touches[0].pageY},t=window$1.performance.now(),e=!0)})),this.on("touchmove",(function(t){if(t.touches.length>1)e=!1;else if(i){const s=t.touches[0].pageX-i.pageX,n=t.touches[0].pageY-i.pageY;Math.sqrt(s*s+n*n)>10&&(e=!1)}}));const s=function(){e=!1};this.on("touchleave",s),this.on("touchcancel",s),this.on("touchend",(function(s){i=null,!0===e&&window$1.performance.now()-t<200&&(s.preventDefault(),this.trigger("tap"))}))}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const e=bind_(this.player(),this.player().reportUserActivity);let t;this.on("touchstart",(function(){e(),this.clearInterval(t),t=this.setInterval(e,250)}));const i=function(i){e(),this.clearInterval(t)};this.on("touchmove",e),this.on("touchend",i),this.on("touchcancel",i)}setTimeout(e,t){var i;return e=bind_(this,e),this.clearTimersOnDispose_(),i=window$1.setTimeout((()=>{this.setTimeoutIds_.has(i)&&this.setTimeoutIds_.delete(i),e()}),t),this.setTimeoutIds_.add(i),i}clearTimeout(e){return this.setTimeoutIds_.has(e)&&(this.setTimeoutIds_.delete(e),window$1.clearTimeout(e)),e}setInterval(e,t){e=bind_(this,e),this.clearTimersOnDispose_();const i=window$1.setInterval(e,t);return this.setIntervalIds_.add(i),i}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),window$1.clearInterval(e)),e}requestAnimationFrame(e){var t;return this.clearTimersOnDispose_(),e=bind_(this,e),t=window$1.requestAnimationFrame((()=>{this.rafIds_.has(t)&&this.rafIds_.delete(t),e()})),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){if(this.namedRafs_.has(e))return;this.clearTimersOnDispose_(),t=bind_(this,t);const i=this.requestAnimationFrame((()=>{t(),this.namedRafs_.has(e)&&this.namedRafs_.delete(e)}));return this.namedRafs_.set(e,i),e}cancelNamedAnimationFrame(e){this.namedRafs_.has(e)&&(this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e))}cancelAnimationFrame(e){return this.rafIds_.has(e)&&(this.rafIds_.delete(e),window$1.cancelAnimationFrame(e)),e}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",(()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach((([e,t])=>{this[e].forEach(((e,i)=>this[t](i)))})),this.clearingTimersOnDispose_=!1})))}static registerComponent(e,t){if("string"!=typeof e||!e)throw new Error(`Illegal component name, "${e}"; must be a non-empty string.`);const i=Component$1.getComponent("Tech"),s=i&&i.isTech(t),n=Component$1===t||Component$1.prototype.isPrototypeOf(t.prototype);if(s||!n){let t;throw t=s?"techs must be registered using Tech.registerTech()":"must be a Component subclass",new Error(`Illegal component, "${e}"; ${t}.`)}e=toTitleCase$1(e),Component$1.components_||(Component$1.components_={});const r=Component$1.getComponent("Player");if("Player"===e&&r&&r.players){const e=r.players,t=Object.keys(e);if(e&&t.length>0&&t.map((t=>e[t])).every(Boolean))throw new Error("Can not register Player component after player has been created.")}return Component$1.components_[e]=t,Component$1.components_[toLowerCase(e)]=t,t}static getComponent(e){if(e&&Component$1.components_)return Component$1.components_[e]}}function rangeCheck(e,t,i){if("number"!=typeof t||t<0||t>i)throw new Error(`Failed to execute '${e}' on 'TimeRanges': The index provided (${t}) is non-numeric or out of bounds (0-${i}).`)}function getRange(e,t,i,s){return rangeCheck(e,s,i.length-1),i[s][t]}function createTimeRangesObj(e){let t;return t=void 0===e||0===e.length?{length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:{length:e.length,start:getRange.bind(null,"start",0,e),end:getRange.bind(null,"end",1,e)},window$1.Symbol&&window$1.Symbol.iterator&&(t[window$1.Symbol.iterator]=()=>(e||[]).values()),t}function createTimeRanges$1(e,t){return Array.isArray(e)?createTimeRangesObj(e):void 0===e||void 0===t?createTimeRangesObj():createTimeRangesObj([[e,t]])}Component$1.registerComponent("Component",Component$1);const defaultImplementation=function(e,t){e=e<0?0:e;let i=Math.floor(e%60),s=Math.floor(e/60%60),n=Math.floor(e/3600);const r=Math.floor(t/60%60),a=Math.floor(t/3600);return(isNaN(e)||e===1/0)&&(n=s=i="-"),n=n>0||a>0?n+":":"",s=((n||r>=10)&&s<10?"0"+s:s)+":",i=i<10?"0"+i:i,n+s+i};let implementation=defaultImplementation;function setFormatTime(e){implementation=e}function resetFormatTime(){implementation=defaultImplementation}function formatTime(e,t=e){return implementation(e,t)}var Time=Object.freeze({__proto__:null,createTimeRanges:createTimeRanges$1,createTimeRange:createTimeRanges$1,setFormatTime:setFormatTime,resetFormatTime:resetFormatTime,formatTime:formatTime});function bufferedPercent(e,t){let i,s,n=0;if(!t)return 0;e&&e.length||(e=createTimeRanges$1(0,0));for(let r=0;r<e.length;r++)i=e.start(r),s=e.end(r),s>t&&(s=t),n+=s-i;return n/t}function MediaError(e){if(e instanceof MediaError)return e;"number"==typeof e?this.code=e:"string"==typeof e?this.message=e:isObject(e)&&("number"==typeof e.code&&(this.code=e.code),Object.assign(this,e)),this.message||(this.message=MediaError.defaultMessages[this.code]||"")}MediaError.prototype.code=0,MediaError.prototype.message="",MediaError.prototype.status=null,MediaError.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"],MediaError.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};for(let e=0;e<MediaError.errorTypes.length;e++)MediaError[MediaError.errorTypes[e]]=e,MediaError.prototype[MediaError.errorTypes[e]]=e;function isPromise(e){return null!=e&&"function"==typeof e.then}function silencePromise(e){isPromise(e)&&e.then(null,(e=>{}))}const trackToJson_=function(e){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce(((t,i,s)=>(e[i]&&(t[i]=e[i]),t)),{cues:e.cues&&Array.prototype.map.call(e.cues,(function(e){return{startTime:e.startTime,endTime:e.endTime,text:e.text,id:e.id}}))})},textTracksToJson=function(e){const t=e.$$("track"),i=Array.prototype.map.call(t,(e=>e.track));return Array.prototype.map.call(t,(function(e){const t=trackToJson_(e.track);return e.src&&(t.src=e.src),t})).concat(Array.prototype.filter.call(e.textTracks(),(function(e){return-1===i.indexOf(e)})).map(trackToJson_))},jsonToTextTracks=function(e,t){return e.forEach((function(e){const i=t.addRemoteTextTrack(e).track;!e.src&&e.cues&&e.cues.forEach((e=>i.addCue(e)))})),t.textTracks()};var textTrackConverter={textTracksToJson:textTracksToJson,jsonToTextTracks:jsonToTextTracks,trackToJson_:trackToJson_};const MODAL_CLASS_NAME="vjs-modal-dialog";class ModalDialog extends Component$1{constructor(e,t){super(e,t),this.handleKeyDown_=e=>this.handleKeyDown(e),this.close_=e=>this.close(e),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=createEl("div",{className:"vjs-modal-dialog-content"},{role:"document"}),this.descEl_=createEl("p",{className:"vjs-modal-dialog-description vjs-control-text",id:this.el().getAttribute("aria-describedby")}),textContent(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`vjs-modal-dialog vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),e}open(){if(!this.opened_){const e=this.player();this.trigger("beforemodalopen"),this.opened_=!0,(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)&&this.fill(),this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&e.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}}opened(e){return"boolean"==typeof e&&this[e?"open":"close"](),this.opened_}close(){if(!this.opened_)return;const e=this.player();this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&e.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&e.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger("modalclose"),this.conditionalBlur_(),this.options_.temporary&&this.dispose()}closeable(e){if("boolean"==typeof e){const t=this.closeable_=!!e;let i=this.getChild("closeButton");if(t&&!i){const e=this.contentEl_;this.contentEl_=this.el_,i=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=e,this.on(i,"close",this.close_)}!t&&i&&(this.off(i,"close",this.close_),this.removeChild(i),i.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){const t=this.contentEl(),i=t.parentNode,s=t.nextSibling;this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,i.removeChild(t),this.empty(),insertContent(t,e),this.trigger("modalfill"),s?i.insertBefore(t,s):i.appendChild(t);const n=this.getChild("closeButton");n&&i.appendChild(n.el_)}empty(){this.trigger("beforemodalempty"),emptyEl(this.contentEl()),this.trigger("modalempty")}content(e){return void 0!==e&&(this.content_=e),this.content_}conditionalFocus_(){const e=document.activeElement,t=this.player_.el_;this.previouslyActiveEl_=null,(t.contains(e)||t===e)&&(this.previouslyActiveEl_=e,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(e){if(e.stopPropagation(),keycode.isEventKey(e,"Escape")&&this.closeable())return e.preventDefault(),void this.close();if(!keycode.isEventKey(e,"Tab"))return;const t=this.focusableEls_(),i=this.el_.querySelector(":focus");let s;for(let e=0;e<t.length;e++)if(i===t[e]){s=e;break}document.activeElement===this.el_&&(s=0),e.shiftKey&&0===s?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||s!==t.length-1||(t[0].focus(),e.preventDefault())}focusableEls_(){const e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,(e=>(e instanceof window$1.HTMLAnchorElement||e instanceof window$1.HTMLAreaElement)&&e.hasAttribute("href")||(e instanceof window$1.HTMLInputElement||e instanceof window$1.HTMLSelectElement||e instanceof window$1.HTMLTextAreaElement||e instanceof window$1.HTMLButtonElement)&&!e.hasAttribute("disabled")||e instanceof window$1.HTMLIFrameElement||e instanceof window$1.HTMLObjectElement||e instanceof window$1.HTMLEmbedElement||e.hasAttribute("tabindex")&&-1!==e.getAttribute("tabindex")||e.hasAttribute("contenteditable")))}}ModalDialog.prototype.options_={pauseOnOpen:!0,temporary:!0},Component$1.registerComponent("ModalDialog",ModalDialog);class TrackList extends EventTarget$2{constructor(e=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let t=0;t<e.length;t++)this.addTrack(e[t])}addTrack(e){const t=this.tracks_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.tracks_[t]}}),-1===this.tracks_.indexOf(e)&&(this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this})),e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},isEvented(e)&&e.addEventListener("labelchange",e.labelchange_)}removeTrack(e){let t;for(let i=0,s=this.length;i<s;i++)if(this[i]===e){t=this[i],t.off&&t.off(),this.tracks_.splice(i,1);break}t&&this.trigger({track:t,type:"removetrack",target:this})}getTrackById(e){let t=null;for(let i=0,s=this.length;i<s;i++){const s=this[i];if(s.id===e){t=s;break}}return t}}TrackList.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const e in TrackList.prototype.allowedEvents_)TrackList.prototype["on"+e]=null;const disableOthers$1=function(e,t){for(let i=0;i<e.length;i++)Object.keys(e[i]).length&&t.id!==e[i].id&&(e[i].enabled=!1)};class AudioTrackList extends TrackList{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){disableOthers$1(e,e[t]);break}super(e),this.changing_=!1}addTrack(e){e.enabled&&disableOthers$1(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,disableOthers$1(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("enabledchange",e.enabledChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null)}}const disableOthers=function(e,t){for(let i=0;i<e.length;i++)Object.keys(e[i]).length&&t.id!==e[i].id&&(e[i].selected=!1)};class VideoTrackList extends TrackList{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){disableOthers(e,e[t]);break}super(e),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let e=0;e<this.length;e++)if(this[e].selected)return e;return-1},set(){}})}addTrack(e){e.selected&&disableOthers(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,disableOthers(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("selectedchange",e.selectedChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.selectedChange_&&(e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null)}}class TextTrackList extends TrackList{addTrack(e){super.addTrack(e),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),e.addEventListener("modechange",this.queueChange_),-1===["metadata","chapters"].indexOf(e.kind)&&e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){super.removeTrack(e),e.removeEventListener&&(this.queueChange_&&e.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_&&e.removeEventListener("modechange",this.triggerSelectedlanguagechange_))}}class HtmlTrackElementList{constructor(e=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let t=0,i=e.length;t<i;t++)this.addTrackElement_(e[t])}addTrackElement_(e){const t=this.trackElements_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.trackElements_[t]}}),-1===this.trackElements_.indexOf(e)&&this.trackElements_.push(e)}getTrackElementByTrack_(e){let t;for(let i=0,s=this.trackElements_.length;i<s;i++)if(e===this.trackElements_[i].track){t=this.trackElements_[i];break}return t}removeTrackElement_(e){for(let t=0,i=this.trackElements_.length;t<i;t++)if(e===this.trackElements_[t]){this.trackElements_[t].track&&"function"==typeof this.trackElements_[t].track.off&&this.trackElements_[t].track.off(),"function"==typeof this.trackElements_[t].off&&this.trackElements_[t].off(),this.trackElements_.splice(t,1);break}}}class TextTrackCueList{constructor(e){TextTrackCueList.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){const t=this.length||0;let i=0;const s=e.length;this.cues_=e,this.length_=e.length;const n=function(e){""+e in this||Object.defineProperty(this,""+e,{get(){return this.cues_[e]}})};if(t<s)for(i=t;i<s;i++)n.call(this,i)}getCueById(e){let t=null;for(let i=0,s=this.length;i<s;i++){const s=this[i];if(s.id===e){t=s;break}}return t}}const VideoTrackKind={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},AudioTrackKind={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},TextTrackKind={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},TextTrackMode={disabled:"disabled",hidden:"hidden",showing:"showing"};class Track extends EventTarget$2{constructor(e={}){super();const t={id:e.id||"vjs_track_"+newGUID(),kind:e.kind||"",language:e.language||""};let i=e.label||"";for(const e in t)Object.defineProperty(this,e,{get:()=>t[e],set(){}});Object.defineProperty(this,"label",{get:()=>i,set(e){e!==i&&(i=e,this.trigger("labelchange"))}})}}const parseUrl=function(e){const t=["protocol","hostname","port","pathname","search","hash","host"],i=document.createElement("a");i.href=e;const s={};for(let e=0;e<t.length;e++)s[t[e]]=i[t[e]];return"http:"===s.protocol&&(s.host=s.host.replace(/:80$/,"")),"https:"===s.protocol&&(s.host=s.host.replace(/:443$/,"")),s.protocol||(s.protocol=window$1.location.protocol),s.host||(s.host=window$1.location.host),s},getAbsoluteURL=function(e){if(!e.match(/^https?:\/\//)){const t=document.createElement("a");t.href=e,e=t.href}return e},getFileExtension=function(e){if("string"==typeof e){const t=/^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/.exec(e);if(t)return t.pop().toLowerCase()}return""},isCrossOrigin=function(e,t=window$1.location){const i=parseUrl(e);return(":"===i.protocol?t.protocol:i.protocol)+i.host!==t.protocol+t.host};var Url=Object.freeze({__proto__:null,parseUrl:parseUrl,getAbsoluteURL:getAbsoluteURL,getFileExtension:getFileExtension,isCrossOrigin:isCrossOrigin});const parseCues=function(e,t){const i=new window$1.WebVTT.Parser(window$1,window$1.vttjs,window$1.WebVTT.StringDecoder()),s=[];i.oncue=function(e){t.addCue(e)},i.onparsingerror=function(e){s.push(e)},i.onflush=function(){t.trigger({type:"loadeddata",target:t})},i.parse(e),s.length>0&&(window$1.console&&window$1.console.groupCollapsed&&window$1.console.groupCollapsed(`Text Track parsing errors for ${t.src}`),s.forEach((e=>log$1.error(e))),window$1.console&&window$1.console.groupEnd&&window$1.console.groupEnd()),i.flush()},loadTrack=function(e,t){const i={uri:e},s=isCrossOrigin(e);s&&(i.cors=s);const n="use-credentials"===t.tech_.crossOrigin();n&&(i.withCredentials=n),XHR(i,bind_(this,(function(e,i,s){if(e)return log$1.error(e,i);t.loaded_=!0,"function"!=typeof window$1.WebVTT?t.tech_&&t.tech_.any(["vttjsloaded","vttjserror"],(e=>{if("vttjserror"!==e.type)return parseCues(s,t);log$1.error(`vttjs failed to load, stopping trying to process ${t.src}`)})):parseCues(s,t)})))};class TextTrack extends Track{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");const t=merge$1(e,{kind:TextTrackKind[e.kind]||"subtitles",language:e.language||e.srclang||""});let i=TextTrackMode[t.mode]||"disabled";const s=t.default;"metadata"!==t.kind&&"chapters"!==t.kind||(i="hidden"),super(t),this.tech_=t.tech,this.cues_=[],this.activeCues_=[],this.preload_=!1!==this.tech_.preloadTextTracks;const n=new TextTrackCueList(this.cues_),r=new TextTrackCueList(this.activeCues_);let a=!1;this.timeupdateHandler=bind_(this,(function(e={}){this.tech_.isDisposed()||(this.tech_.isReady_?(this.activeCues=this.activeCues,a&&(this.trigger("cuechange"),a=!1),"timeupdate"!==e.type&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler))):"timeupdate"!==e.type&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler)))})),this.tech_.one("dispose",(()=>{this.stopTracking()})),"disabled"!==i&&this.startTracking(),Object.defineProperties(this,{default:{get:()=>s,set(){}},mode:{get:()=>i,set(e){TextTrackMode[e]&&i!==e&&(i=e,this.preload_||"disabled"===i||0!==this.cues.length||loadTrack(this.src,this),this.stopTracking(),"disabled"!==i&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?n:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(0===this.cues.length)return r;const e=this.tech_.currentTime(),t=[];for(let i=0,s=this.cues.length;i<s;i++){const s=this.cues[i];s.startTime<=e&&s.endTime>=e&&t.push(s)}if(a=!1,t.length!==this.activeCues_.length)a=!0;else for(let e=0;e<t.length;e++)-1===this.activeCues_.indexOf(t[e])&&(a=!0);return this.activeCues_=t,r.setCues_(this.activeCues_),r},set(){}}}),t.src?(this.src=t.src,this.preload_||(this.loaded_=!0),(this.preload_||"subtitles"!==t.kind&&"captions"!==t.kind)&&loadTrack(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(window$1.vttjs&&!(e instanceof window$1.vttjs.VTTCue)){t=new window$1.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(const i in e)i in t||(t[i]=e[i]);t.id=e.id,t.originalCue_=e}const i=this.tech_.textTracks();for(let e=0;e<i.length;e++)i[e]!==this&&i[e].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}removeCue(e){let t=this.cues_.length;for(;t--;){const i=this.cues_[t];if(i===e||i.originalCue_&&i.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}TextTrack.prototype.allowedEvents_={cuechange:"cuechange"};class AudioTrack extends Track{constructor(e={}){const t=merge$1(e,{kind:AudioTrackKind[e.kind]||""});super(t);let i=!1;Object.defineProperty(this,"enabled",{get:()=>i,set(e){"boolean"==typeof e&&e!==i&&(i=e,this.trigger("enabledchange"))}}),t.enabled&&(this.enabled=t.enabled),this.loaded_=!0}}class VideoTrack extends Track{constructor(e={}){const t=merge$1(e,{kind:VideoTrackKind[e.kind]||""});super(t);let i=!1;Object.defineProperty(this,"selected",{get:()=>i,set(e){"boolean"==typeof e&&e!==i&&(i=e,this.trigger("selectedchange"))}}),t.selected&&(this.selected=t.selected)}}class HTMLTrackElement extends EventTarget$2{constructor(e={}){let t;super();const i=new TextTrack(e);this.kind=i.kind,this.src=i.src,this.srclang=i.language,this.label=i.label,this.default=i.default,Object.defineProperties(this,{readyState:{get:()=>t},track:{get:()=>i}}),t=HTMLTrackElement.NONE,i.addEventListener("loadeddata",(()=>{t=HTMLTrackElement.LOADED,this.trigger({type:"load",target:this})}))}}HTMLTrackElement.prototype.allowedEvents_={load:"load"},HTMLTrackElement.NONE=0,HTMLTrackElement.LOADING=1,HTMLTrackElement.LOADED=2,HTMLTrackElement.ERROR=3;const NORMAL={audio:{ListClass:AudioTrackList,TrackClass:AudioTrack,capitalName:"Audio"},video:{ListClass:VideoTrackList,TrackClass:VideoTrack,capitalName:"Video"},text:{ListClass:TextTrackList,TrackClass:TextTrack,capitalName:"Text"}};Object.keys(NORMAL).forEach((function(e){NORMAL[e].getterName=`${e}Tracks`,NORMAL[e].privateName=`${e}Tracks_`}));const REMOTE={remoteText:{ListClass:TextTrackList,TrackClass:TextTrack,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:HtmlTrackElementList,TrackClass:HTMLTrackElement,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},ALL=Object.assign({},NORMAL,REMOTE);function createTrackHelper(e,t,i,s,n={}){const r=e.textTracks();n.kind=t,i&&(n.label=i),s&&(n.language=s),n.tech=e;const a=new ALL.text.TrackClass(n);return r.addTrack(a),a}REMOTE.names=Object.keys(REMOTE),NORMAL.names=Object.keys(NORMAL),ALL.names=[].concat(REMOTE.names).concat(NORMAL.names);class Tech extends Component$1{constructor(e={},t=function(){}){e.reportTouchActivity=!1,super(null,e,t),this.onDurationChange_=e=>this.onDurationChange(e),this.trackProgress_=e=>this.trackProgress(e),this.trackCurrentTime_=e=>this.trackCurrentTime(e),this.stopTrackingCurrentTime_=e=>this.stopTrackingCurrentTime(e),this.disposeSourceHandler_=e=>this.disposeSourceHandler(e),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",(function(){this.hasStarted_=!0})),this.on("loadstart",(function(){this.hasStarted_=!1})),ALL.names.forEach((t=>{const i=ALL[t];e&&e[i.getterName]&&(this[i.privateName]=e[i.getterName])})),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach((t=>{!1===e[`native${t}Tracks`]&&(this[`featuresNative${t}Tracks`]=!1)})),!1===e.nativeCaptions||!1===e.nativeTextTracks?this.featuresNativeTextTracks=!1:!0!==e.nativeCaptions&&!0!==e.nativeTextTracks||(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=!1!==e.preloadTextTracks,this.autoRemoteTextTracks_=new ALL.text.ListClass,this.initTrackListeners(),e.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(e){this.isReady_||this.one("ready",(()=>this.setTimeout((()=>this.triggerSourceset(e)),1))),this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(bind_(this,(function(){const e=this.bufferedPercent();this.bufferedPercent_!==e&&this.trigger("progress"),this.bufferedPercent_=e,1===e&&this.stopTrackingProgress()})),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return createTimeRanges$1(0,0)}bufferedPercent(){return bufferedPercent(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval((function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}),250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(NORMAL.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(e){(e=[].concat(e)).forEach((e=>{const t=this[`${e}Tracks`]()||[];let i=t.length;for(;i--;){const s=t[i];"text"===e&&this.removeRemoteTextTrack(s),t.removeTrack(s)}}))}cleanupAutoTextTracks(){const e=this.autoRemoteTextTracks_||[];let t=e.length;for(;t--;){const i=e[t];this.removeRemoteTextTrack(i)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){return void 0!==e&&(this.error_=new MediaError(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?createTimeRanges$1(0,0):createTimeRanges$1()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){NORMAL.names.forEach((e=>{const t=NORMAL[e],i=()=>{this.trigger(`${e}trackchange`)},s=this[t.getterName]();s.addEventListener("removetrack",i),s.addEventListener("addtrack",i),this.on("dispose",(()=>{s.removeEventListener("removetrack",i),s.removeEventListener("addtrack",i)}))}))}addWebVttScript_(){if(!window$1.WebVTT)if(document.body.contains(this.el())){if(!this.options_["vtt.js"]&&isPlain(vtt)&&Object.keys(vtt).length>0)return void this.trigger("vttjsloaded");const e=document.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",(()=>{e.onload=null,e.onerror=null})),window$1.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const e=this.textTracks(),t=this.remoteTextTracks(),i=t=>e.addTrack(t.track),s=t=>e.removeTrack(t.track);t.on("addtrack",i),t.on("removetrack",s),this.addWebVttScript_();const n=()=>this.trigger("texttrackchange"),r=()=>{n();for(let t=0;t<e.length;t++){const i=e[t];i.removeEventListener("cuechange",n),"showing"===i.mode&&i.addEventListener("cuechange",n)}};r(),e.addEventListener("change",r),e.addEventListener("addtrack",r),e.addEventListener("removetrack",r),this.on("dispose",(function(){t.off("addtrack",i),t.off("removetrack",s),e.removeEventListener("change",r),e.removeEventListener("addtrack",r),e.removeEventListener("removetrack",r);for(let t=0;t<e.length;t++)e[t].removeEventListener("cuechange",n)}))}addTextTrack(e,t,i){if(!e)throw new Error("TextTrack kind is required but was not provided");return createTrackHelper(this,e,t,i)}createRemoteTextTrack(e){const t=merge$1(e,{tech:this});return new REMOTE.remoteTextEl.TrackClass(t)}addRemoteTextTrack(e={},t){const i=this.createRemoteTextTrack(e);return"boolean"!=typeof t&&(t=!1),this.remoteTextTrackEls().addTrackElement_(i),this.remoteTextTracks().addTrack(i.track),!1===t&&this.ready((()=>this.autoRemoteTextTracks_.addTrack(i.track))),i}removeRemoteTextTrack(e){const t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){const t=newGUID();return!this.isReady_||this.paused()?(this.queuedHanders_.add(t),this.one("playing",(()=>{this.queuedHanders_.has(t)&&(this.queuedHanders_.delete(t),e())}))):this.requestNamedAnimationFrame(t,e),t}cancelVideoFrameCallback(e){this.queuedHanders_.has(e)?this.queuedHanders_.delete(e):this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return Tech.canPlayType(e.type)}static isTech(e){return e.prototype instanceof Tech||e instanceof Tech||e===Tech}static registerTech(e,t){if(Tech.techs_||(Tech.techs_={}),!Tech.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!Tech.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!Tech.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return e=toTitleCase$1(e),Tech.techs_[e]=t,Tech.techs_[toLowerCase(e)]=t,"Tech"!==e&&Tech.defaultTechOrder_.push(e),t}static getTech(e){if(e)return Tech.techs_&&Tech.techs_[e]?Tech.techs_[e]:(e=toTitleCase$1(e),window$1&&window$1.videojs&&window$1.videojs[e]?(log$1.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),window$1.videojs[e]):void 0)}}ALL.names.forEach((function(e){const t=ALL[e];Tech.prototype[t.getterName]=function(){return this[t.privateName]=this[t.privateName]||new t.ListClass,this[t.privateName]}})),Tech.prototype.featuresVolumeControl=!0,Tech.prototype.featuresMuteControl=!0,Tech.prototype.featuresFullscreenResize=!1,Tech.prototype.featuresPlaybackRate=!1,Tech.prototype.featuresProgressEvents=!1,Tech.prototype.featuresSourceset=!1,Tech.prototype.featuresTimeupdateEvents=!1,Tech.prototype.featuresNativeTextTracks=!1,Tech.prototype.featuresVideoFrameCallback=!1,Tech.withSourceHandlers=function(e){e.registerSourceHandler=function(t,i){let s=e.sourceHandlers;s||(s=e.sourceHandlers=[]),void 0===i&&(i=s.length),s.splice(i,0,t)},e.canPlayType=function(t){const i=e.sourceHandlers||[];let s;for(let e=0;e<i.length;e++)if(s=i[e].canPlayType(t),s)return s;return""},e.selectSourceHandler=function(t,i){const s=e.sourceHandlers||[];let n;for(let e=0;e<s.length;e++)if(n=s[e].canHandleSource(t,i),n)return s[e];return null},e.canPlaySource=function(t,i){const s=e.selectSourceHandler(t,i);return s?s.canHandleSource(t,i):""},["seekable","seeking","duration"].forEach((function(e){const t=this[e];"function"==typeof t&&(this[e]=function(){return this.sourceHandler_&&this.sourceHandler_[e]?this.sourceHandler_[e].apply(this.sourceHandler_,arguments):t.apply(this,arguments)})}),e.prototype),e.prototype.setSource=function(t){let i=e.selectSourceHandler(t,this.options_);i||(e.nativeSourceHandler?i=e.nativeSourceHandler:log$1.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),i!==e.nativeSourceHandler&&(this.currentSource_=t),this.sourceHandler_=i.handleSource(t,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},e.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}},Component$1.registerComponent("Tech",Tech),Tech.registerTech("Tech",Tech),Tech.defaultTechOrder_=[];const middlewares={},middlewareInstances={},TERMINATOR={};function use(e,t){middlewares[e]=middlewares[e]||[],middlewares[e].push(t)}function setSource(e,t,i){e.setTimeout((()=>setSourceHelper(t,middlewares[t.type],i,e)),1)}function setTech(e,t){e.forEach((e=>e.setTech&&e.setTech(t)))}function get(e,t,i){return e.reduceRight(middlewareIterator(i),t[i]())}function set(e,t,i,s){return t[i](e.reduce(middlewareIterator(i),s))}function mediate(e,t,i,s=null){const n="call"+toTitleCase$1(i),r=e.reduce(middlewareIterator(n),s),a=r===TERMINATOR,o=a?null:t[i](r);return executeRight(e,i,o,a),o}const allowedGetters={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},allowedSetters={setCurrentTime:1,setMuted:1,setVolume:1},allowedMediators={play:1,pause:1};function middlewareIterator(e){return(t,i)=>t===TERMINATOR?TERMINATOR:i[e]?i[e](t):t}function executeRight(e,t,i,s){for(let n=e.length-1;n>=0;n--){const r=e[n];r[t]&&r[t](s,i)}}function clearCacheForPlayer(e){middlewareInstances[e.id()]=null}function getOrCreateFactory(e,t){const i=middlewareInstances[e.id()];let s=null;if(null==i)return s=t(e),middlewareInstances[e.id()]=[[t,s]],s;for(let e=0;e<i.length;e++){const[n,r]=i[e];n===t&&(s=r)}return null===s&&(s=t(e),i.push([t,s])),s}function setSourceHelper(e={},t=[],i,s,n=[],r=!1){const[a,...o]=t;if("string"==typeof a)setSourceHelper(e,middlewares[a],i,s,n,r);else if(a){const t=getOrCreateFactory(s,a);if(!t.setSource)return n.push(t),setSourceHelper(e,o,i,s,n,r);t.setSource(Object.assign({},e),(function(a,l){if(a)return setSourceHelper(e,o,i,s,n,r);n.push(t),setSourceHelper(l,e.type===l.type?o:middlewares[l.type],i,s,n,r)}))}else o.length?setSourceHelper(e,o,i,s,n,r):r?i(e,n):setSourceHelper(e,middlewares["*"],i,s,n,!0)}const MimetypesKind={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},getMimetype=function(e=""){const t=getFileExtension(e);return MimetypesKind[t.toLowerCase()]||""},findMimetype=(e,t)=>{if(!t)return"";if(e.cache_.source.src===t&&e.cache_.source.type)return e.cache_.source.type;const i=e.cache_.sources.filter((e=>e.src===t));if(i.length)return i[0].type;const s=e.$$("source");for(let e=0;e<s.length;e++){const i=s[e];if(i.type&&i.src&&i.src===t)return i.type}return getMimetype(t)},filterSource=function(e){if(Array.isArray(e)){let t=[];e.forEach((function(e){e=filterSource(e),Array.isArray(e)?t=t.concat(e):isObject(e)&&t.push(e)})),e=t}else e="string"==typeof e&&e.trim()?[fixSource({src:e})]:isObject(e)&&"string"==typeof e.src&&e.src&&e.src.trim()?[fixSource(e)]:[];return e};function fixSource(e){if(!e.type){const t=getMimetype(e.src);t&&(e.type=t)}return e}class MediaLoader extends Component$1{constructor(e,t,i){if(super(e,merge$1({createEl:!1},t),i),t.playerOptions.sources&&0!==t.playerOptions.sources.length)e.src(t.playerOptions.sources);else for(let i=0,s=t.playerOptions.techOrder;i<s.length;i++){const t=toTitleCase$1(s[i]);let n=Tech.getTech(t);if(t||(n=Component$1.getComponent(t)),n&&n.isSupported()){e.loadTech_(t);break}}}}Component$1.registerComponent("MediaLoader",MediaLoader);class ClickableComponent extends Component$1{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=e=>this.handleMouseOver(e),this.handleMouseOut_=e=>this.handleMouseOut(e),this.handleClick_=e=>this.handleClick(e),this.handleKeyDown_=e=>this.handleKeyDown(e),this.emitTapEvents(),this.enable()}createEl(e="div",t={},i={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),"button"===e&&log$1.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),i=Object.assign({role:"button"},i),this.tabIndex_=t.tabIndex;const s=createEl(e,t,i);return s.appendChild(createEl("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(s),s}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=createEl("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(void 0===e)return this.controlText_||"Need Text";const i=this.localize(e);this.controlText_=e,textContent(this.controlTextEl_,i),this.nonIconControl||this.player_.options_.noUITitleAttributes||t.setAttribute("title",i)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),void 0!==this.tabIndex_&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),void 0!==this.tabIndex_&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){keycode.isEventKey(e,"Space")||keycode.isEventKey(e,"Enter")?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}Component$1.registerComponent("ClickableComponent",ClickableComponent);class PosterImage extends ClickableComponent{constructor(e,t){super(e,t),this.update(),this.update_=e=>this.update(e),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return createEl("div",{className:"vjs-poster"})}crossOrigin(e){if(void 0===e)return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;null===e||"anonymous"===e||"use-credentials"===e?this.$("img")&&(this.$("img").crossOrigin=e):this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`)}update(e){const t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){e?(this.$("img")||this.el_.appendChild(createEl("picture",{className:"vjs-poster",tabIndex:-1},{},createEl("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=e):this.el_.textContent=""}handleClick(e){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?silencePromise(this.player_.play()):this.player_.pause())}}PosterImage.prototype.crossorigin=PosterImage.prototype.crossOrigin,Component$1.registerComponent("PosterImage",PosterImage);const darkGray="#222",lightGray="#ccc",fontMap={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function constructColor(e,t){let i;if(4===e.length)i=e[1]+e[1]+e[2]+e[2]+e[3]+e[3];else{if(7!==e.length)throw new Error("Invalid color code provided, "+e+"; must be formatted as e.g. #f0e or #f604e2.");i=e.slice(1)}return"rgba("+parseInt(i.slice(0,2),16)+","+parseInt(i.slice(2,4),16)+","+parseInt(i.slice(4,6),16)+","+t+")"}function tryUpdateStyle(e,t,i){try{e.style[t]=i}catch(e){return}}class TextTrackDisplay extends Component$1{constructor(e,t,i){super(e,t,i);const s=e=>this.updateDisplay(e);e.on("loadstart",(e=>this.toggleDisplay(e))),e.on("texttrackchange",s),e.on("loadedmetadata",(e=>this.preselectTrack(e))),e.ready(bind_(this,(function(){if(e.tech_&&e.tech_.featuresNativeTextTracks)return void this.hide();e.on("fullscreenchange",s),e.on("playerresize",s);const t=window$1.screen.orientation||window$1,i=window$1.screen.orientation?"change":"orientationchange";t.addEventListener(i,s),e.on("dispose",(()=>t.removeEventListener(i,s)));const n=this.options_.playerOptions.tracks||[];for(let e=0;e<n.length;e++)this.player_.addRemoteTextTrack(n[e],!0);this.preselectTrack()})))}preselectTrack(){const e={captions:1,subtitles:1},t=this.player_.textTracks(),i=this.player_.cache_.selectedLanguage;let s,n,r;for(let a=0;a<t.length;a++){const o=t[a];i&&i.enabled&&i.language&&i.language===o.language&&o.kind in e?o.kind===i.kind?r=o:r||(r=o):i&&!i.enabled?(r=null,s=null,n=null):o.default&&("descriptions"!==o.kind||s?o.kind in e&&!n&&(n=o):s=o)}r?r.mode="showing":n?n.mode="showing":s&&(s.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){"function"==typeof window$1.WebVTT&&window$1.WebVTT.processCues(window$1,[],this.el_)}updateDisplay(){const e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){const t=[];for(let i=0;i<e.length;++i){const s=e[i];"showing"===s.mode&&t.push(s)}return void this.updateForTrack(t)}let i=null,s=null,n=e.length;for(;n--;){const t=e[n];"showing"===t.mode&&("descriptions"===t.kind?i=t:s=t)}s?("off"!==this.getAttribute("aria-live")&&this.setAttribute("aria-live","off"),this.updateForTrack(s)):i&&("assertive"!==this.getAttribute("aria-live")&&this.setAttribute("aria-live","assertive"),this.updateForTrack(i))}updateDisplayState(e){const t=this.player_.textTrackSettings.getValues(),i=e.activeCues;let s=i.length;for(;s--;){const e=i[s];if(!e)continue;const n=e.displayState;if(t.color&&(n.firstChild.style.color=t.color),t.textOpacity&&tryUpdateStyle(n.firstChild,"color",constructColor(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(n.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&tryUpdateStyle(n.firstChild,"backgroundColor",constructColor(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?tryUpdateStyle(n,"backgroundColor",constructColor(t.windowColor,t.windowOpacity)):n.style.backgroundColor=t.windowColor),t.edgeStyle&&("dropshadow"===t.edgeStyle?n.firstChild.style.textShadow="2px 2px 3px #222, 2px 2px 4px #222, 2px 2px 5px #222":"raised"===t.edgeStyle?n.firstChild.style.textShadow="1px 1px #222, 2px 2px #222, 3px 3px #222":"depressed"===t.edgeStyle?n.firstChild.style.textShadow="1px 1px #ccc, 0 1px #ccc, -1px -1px #222, 0 -1px #222":"uniform"===t.edgeStyle&&(n.firstChild.style.textShadow="0 0 4px #222, 0 0 4px #222, 0 0 4px #222, 0 0 4px #222")),t.fontPercent&&1!==t.fontPercent){const e=window$1.parseFloat(n.style.fontSize);n.style.fontSize=e*t.fontPercent+"px",n.style.height="auto",n.style.top="auto"}t.fontFamily&&"default"!==t.fontFamily&&("small-caps"===t.fontFamily?n.firstChild.style.fontVariant="small-caps":n.firstChild.style.fontFamily=fontMap[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),"function"!=typeof window$1.WebVTT||e.every((e=>!e.activeCues)))return;const t=[];for(let i=0;i<e.length;++i){const s=e[i];for(let e=0;e<s.activeCues.length;++e)t.push(s.activeCues[e])}window$1.WebVTT.processCues(window$1,t,this.el_);for(let t=0;t<e.length;++t){const i=e[t];for(let e=0;e<i.activeCues.length;++e){const s=i.activeCues[e].displayState;addClass(s,"vjs-text-track-cue","vjs-text-track-cue-"+(i.language?i.language:t)),i.language&&setAttribute(s,"lang",i.language)}this.player_.textTrackSettings&&this.updateDisplayState(i)}}}Component$1.registerComponent("TextTrackDisplay",TextTrackDisplay);class LoadingSpinner extends Component$1{createEl(){const e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),i=createEl("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[t])}),s=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return s.appendChild(i),s}}Component$1.registerComponent("LoadingSpinner",LoadingSpinner);class Button extends ClickableComponent{createEl(e,t={},i={}){const s=createEl("button",t=Object.assign({className:this.buildCSSClass()},t),i=Object.assign({type:"button"},i));return s.appendChild(createEl("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(s),s}addChild(e,t={}){const i=this.constructor.name;return log$1.warn(`Adding an actionable (user controllable) child to a Button (${i}) is not supported; use a ClickableComponent instead.`),Component$1.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){keycode.isEventKey(e,"Space")||keycode.isEventKey(e,"Enter")?e.stopPropagation():super.handleKeyDown(e)}}Component$1.registerComponent("Button",Button);class BigPlayButton extends Button{constructor(e,t){super(e,t),this.mouseused_=!1,this.on("mousedown",(e=>this.handleMouseDown(e)))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){const t=this.player_.play();if(this.mouseused_&&e.clientX&&e.clientY)return silencePromise(t),void(this.player_.tech(!0)&&this.player_.tech(!0).focus());const i=this.player_.getChild("controlBar"),s=i&&i.getChild("playToggle");if(!s)return void this.player_.tech(!0).focus();const n=()=>s.focus();isPromise(t)?t.then(n,(()=>{})):this.setTimeout(n,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}BigPlayButton.prototype.controlText_="Play Video",Component$1.registerComponent("BigPlayButton",BigPlayButton);class CloseButton extends Button{constructor(e,t){super(e,t),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){keycode.isEventKey(e,"Esc")?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}Component$1.registerComponent("CloseButton",CloseButton);class PlayToggle extends Button{constructor(e,t={}){super(e,t),t.replay=void 0===t.replay||t.replay,this.on(e,"play",(e=>this.handlePlay(e))),this.on(e,"pause",(e=>this.handlePause(e))),t.replay&&this.on(e,"ended",(e=>this.handleEnded(e)))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?silencePromise(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.controlText("Replay"),this.one(this.player_,"seeked",(e=>this.handleSeeked(e)))}}PlayToggle.prototype.controlText_="Play",Component$1.registerComponent("PlayToggle",PlayToggle);class TimeDisplay extends Component$1{constructor(e,t){super(e,t),this.on(e,["timeupdate","ended"],(e=>this.updateContent(e))),this.updateTextNode_()}createEl(){const e=this.buildCSSClass(),t=super.createEl("div",{className:`${e} vjs-time-control vjs-control`}),i=createEl("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(i),this.contentEl_=createEl("span",{className:`${e}-display`},{"aria-live":"off",role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}updateTextNode_(e=0){e=formatTime(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",(()=>{if(!this.contentEl_)return;let e=this.textNode_;e&&this.contentEl_.firstChild!==e&&(e=null,log$1.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=document.createTextNode(this.formattedTime_),this.textNode_&&(e?this.contentEl_.replaceChild(this.textNode_,e):this.contentEl_.appendChild(this.textNode_))})))}updateContent(e){}}TimeDisplay.prototype.labelText_="Time",TimeDisplay.prototype.controlText_="Time",Component$1.registerComponent("TimeDisplay",TimeDisplay);class CurrentTimeDisplay extends TimeDisplay{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;t=this.player_.ended()?this.player_.duration():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}CurrentTimeDisplay.prototype.labelText_="Current Time",CurrentTimeDisplay.prototype.controlText_="Current Time",Component$1.registerComponent("CurrentTimeDisplay",CurrentTimeDisplay);class DurationDisplay extends TimeDisplay{constructor(e,t){super(e,t);const i=e=>this.updateContent(e);this.on(e,"durationchange",i),this.on(e,"loadstart",i),this.on(e,"loadedmetadata",i)}buildCSSClass(){return"vjs-duration"}updateContent(e){const t=this.player_.duration();this.updateTextNode_(t)}}DurationDisplay.prototype.labelText_="Duration",DurationDisplay.prototype.controlText_="Duration",Component$1.registerComponent("DurationDisplay",DurationDisplay);class TimeDivider extends Component$1{createEl(){const e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),i=super.createEl("span",{textContent:"/"});return t.appendChild(i),e.appendChild(t),e}}Component$1.registerComponent("TimeDivider",TimeDivider);class RemainingTimeDisplay extends TimeDisplay{constructor(e,t){super(e,t),this.on(e,"durationchange",(e=>this.updateContent(e)))}buildCSSClass(){return"vjs-remaining-time"}createEl(){const e=super.createEl();return!1!==this.options_.displayNegative&&e.insertBefore(createEl("span",{},{"aria-hidden":!0},"-"),this.contentEl_),e}updateContent(e){if("number"!=typeof this.player_.duration())return;let t;t=this.player_.ended()?0:this.player_.remainingTimeDisplay?this.player_.remainingTimeDisplay():this.player_.remainingTime(),this.updateTextNode_(t)}}RemainingTimeDisplay.prototype.labelText_="Remaining Time",RemainingTimeDisplay.prototype.controlText_="Remaining Time",Component$1.registerComponent("RemainingTimeDisplay",RemainingTimeDisplay);class LiveDisplay extends Component$1{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),"durationchange",(e=>this.updateShowing(e)))}createEl(){const e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=createEl("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(createEl("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(document.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}Component$1.registerComponent("LiveDisplay",LiveDisplay);class SeekToLive extends Button{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=e=>this.updateLiveEdgeStatus(e),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){const e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.textEl_=createEl("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}function clamp(e,t,i){return e=Number(e),Math.min(i,Math.max(t,isNaN(e)?t:e))}SeekToLive.prototype.controlText_="Seek to live, currently playing live",Component$1.registerComponent("SeekToLive",SeekToLive);var Num=Object.freeze({__proto__:null,clamp:clamp});class Slider extends Component$1{constructor(e,t){super(e,t),this.handleMouseDown_=e=>this.handleMouseDown(e),this.handleMouseUp_=e=>this.handleMouseUp(e),this.handleKeyDown_=e=>this.handleKeyDown(e),this.handleClick_=e=>this.handleClick(e),this.handleMouseMove_=e=>this.handleMouseMove(e),this.update_=e=>this.update(e),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){if(!this.enabled())return;const e=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},i={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),i=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},i),super.createEl(e,t,i)}handleMouseDown(e){const t=this.bar.el_.ownerDocument;"mousedown"===e.type&&e.preventDefault(),"touchstart"!==e.type||IS_CHROME||e.preventDefault(),blockTextSelection(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){const t=this.bar.el_.ownerDocument;unblockTextSelection(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;const e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame("Slider#update",(()=>{const t=this.vertical()?"height":"width";this.bar.el().style[t]=(100*e).toFixed(2)+"%"}))),e}getProgress(){return Number(clamp(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){const t=getPointerPosition(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){keycode.isEventKey(e,"Left")||keycode.isEventKey(e,"Down")?(e.preventDefault(),e.stopPropagation(),this.stepBack()):keycode.isEventKey(e,"Right")||keycode.isEventKey(e,"Up")?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(void 0===e)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}Component$1.registerComponent("Slider",Slider);const percentify=(e,t)=>clamp(e/t*100,0,100).toFixed(2)+"%";class LoadProgressBar extends Component$1{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,"progress",(e=>this.update(e)))}createEl(){const e=super.createEl("div",{className:"vjs-load-progress"}),t=createEl("span",{className:"vjs-control-text"}),i=createEl("span",{textContent:this.localize("Loaded")}),s=document.createTextNode(": ");return this.percentageEl_=createEl("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(i),t.appendChild(s),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",(()=>{const e=this.player_.liveTracker,t=this.player_.buffered(),i=e&&e.isLive()?e.seekableEnd():this.player_.duration(),s=this.player_.bufferedEnd(),n=this.partEls_,r=percentify(s,i);this.percent_!==r&&(this.el_.style.width=r,textContent(this.percentageEl_,r),this.percent_=r);for(let e=0;e<t.length;e++){const i=t.start(e),r=t.end(e);let a=n[e];a||(a=this.el_.appendChild(createEl()),n[e]=a),a.dataset.start===i&&a.dataset.end===r||(a.dataset.start=i,a.dataset.end=r,a.style.left=percentify(i,s),a.style.width=percentify(r-i,s))}for(let e=n.length;e>t.length;e--)this.el_.removeChild(n[e-1]);n.length=t.length}))}}Component$1.registerComponent("LoadProgressBar",LoadProgressBar);class TimeTooltip extends Component$1{constructor(e,t){super(e,t),this.update=throttle(bind_(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,i){const s=findPosition(this.el_),n=getBoundingClientRect(this.player_.el()),r=e.width*t;if(!n||!s)return;const a=e.left-n.left+r,o=e.width-r+(n.right-e.right);let l=s.width/2;a<l?l+=l-a:o<l&&(l=o),l<0?l=0:l>s.width&&(l=s.width),l=Math.round(l),this.el_.style.right=`-${l}px`,this.write(i)}write(e){textContent(this.el_,e)}updateTime(e,t,i,s){this.requestNamedAnimationFrame("TimeTooltip#updateTime",(()=>{let n;const r=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const e=this.player_.liveTracker.liveWindow(),i=e-t*e;n=(i<1?"":"-")+formatTime(i,e)}else n=formatTime(i,r);this.update(e,t,n),s&&s()}))}}Component$1.registerComponent("TimeTooltip",TimeTooltip);class PlayProgressBar extends Component$1{constructor(e,t){super(e,t),this.update=throttle(bind_(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t){const i=this.getChild("timeTooltip");if(!i)return;const s=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();i.updateTime(e,t,s)}}PlayProgressBar.prototype.options_={children:[]},IS_IOS||IS_ANDROID||PlayProgressBar.prototype.options_.children.push("timeTooltip"),Component$1.registerComponent("PlayProgressBar",PlayProgressBar);class MouseTimeDisplay extends Component$1{constructor(e,t){super(e,t),this.update=throttle(bind_(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){const i=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,i,(()=>{this.el_.style.left=e.width*t+"px"}))}}MouseTimeDisplay.prototype.options_={children:["timeTooltip"]},Component$1.registerComponent("MouseTimeDisplay",MouseTimeDisplay);const STEP_SECONDS=5,PAGE_KEY_MULTIPLIER=12;class SeekBar extends Slider{constructor(e,t){super(e,t),this.setEventHandlers_()}setEventHandlers_(){this.update_=bind_(this,this.update),this.update=throttle(this.update_,30),this.on(this.player_,["ended","durationchange","timeupdate"],this.update),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in document&&"visibilityState"in document&&this.on(document,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){"hidden"===document.visibilityState?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(this.player_.ended()||this.player_.paused()||this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,30))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&"ended"!==e.type||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if("hidden"===document.visibilityState)return;const t=super.update();return this.requestNamedAnimationFrame("SeekBar#update",(()=>{const e=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),i=this.player_.liveTracker;let s=this.player_.duration();i&&i.isLive()&&(s=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute("aria-valuenow",(100*t).toFixed(2)),this.percent_=t),this.currentTime_===e&&this.duration_===s||(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[formatTime(e,s),formatTime(s,s)],"{1} of {2}")),this.currentTime_=e,this.duration_=s),this.bar&&this.bar.update(getBoundingClientRect(this.el()),this.getProgress())})),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}getPercent(){const e=this.getCurrentTime_();let t;const i=this.player_.liveTracker;return i&&i.isLive()?(t=(e-i.seekableStart())/i.liveWindow(),i.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){isSingleLeftClick(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!isSingleLeftClick(e))return;let i;t||this.player_.scrubbing()||this.player_.scrubbing(!0);const s=this.calculateDistance(e),n=this.player_.liveTracker;if(n&&n.isLive()){if(s>=.99)return void n.seekToLiveEdge();const e=n.seekableStart(),t=n.liveCurrentTime();if(i=e+s*n.liveWindow(),i>=t&&(i=t),i<=e&&(i=e+.1),i===1/0)return}else i=s*this.player_.duration(),i===this.player_.duration()&&(i-=.1);this.userSeek_(i)}enable(){super.enable();const e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();const e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?silencePromise(this.player_.play()):this.update_()}stepForward(){this.userSeek_(this.player_.currentTime()+5)}stepBack(){this.userSeek_(this.player_.currentTime()-5)}handleAction(e){this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){const t=this.player_.liveTracker;if(keycode.isEventKey(e,"Space")||keycode.isEventKey(e,"Enter"))e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(keycode.isEventKey(e,"Home"))e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(keycode.isEventKey(e,"End"))e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(keycode(e))){e.preventDefault(),e.stopPropagation();const i=10*(keycode.codes[keycode(e)]-keycode.codes[0])/100;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*i):this.userSeek_(this.player_.duration()*i)}else keycode.isEventKey(e,"PgDn")?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-60)):keycode.isEventKey(e,"PgUp")?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+60)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["ended","durationchange","timeupdate"],this.update),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in document&&"visibilityState"in document&&this.off(document,"visibilitychange",this.toggleVisibility_),super.dispose()}}SeekBar.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar"},IS_IOS||IS_ANDROID||SeekBar.prototype.options_.children.splice(1,0,"mouseTimeDisplay"),Component$1.registerComponent("SeekBar",SeekBar);class ProgressControl extends Component$1{constructor(e,t){super(e,t),this.handleMouseMove=throttle(bind_(this,this.handleMouseMove),30),this.throttledHandleMouseSeek=throttle(bind_(this,this.handleMouseSeek),30),this.handleMouseUpHandler_=e=>this.handleMouseUp(e),this.handleMouseDownHandler_=e=>this.handleMouseDown(e),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){const t=this.getChild("seekBar");if(!t)return;const i=t.getChild("playProgressBar"),s=t.getChild("mouseTimeDisplay");if(!i&&!s)return;const n=t.el(),r=findPosition(n);let a=getPointerPosition(n,e).x;a=clamp(a,0,1),s&&s.update(r,a),i&&i.update(r,t.getProgress())}handleMouseSeek(e){const t=this.getChild("seekBar");t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach((e=>e.disable&&e.disable())),this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,"mousemove",this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const e=this.getChild("seekBar");this.player_.scrubbing(!1),e.videoWasPlaying&&silencePromise(this.player_.play())}}enable(){this.children().forEach((e=>e.enable&&e.enable())),this.enabled()||(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,"mousemove",this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){const t=this.el_.ownerDocument,i=this.getChild("seekBar");i&&i.handleMouseDown(e),this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.getChild("seekBar");t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}ProgressControl.prototype.options_={children:["seekBar"]},Component$1.registerComponent("ProgressControl",ProgressControl);class PictureInPictureToggle extends Button{constructor(e,t){super(e,t),this.on(e,["enterpictureinpicture","leavepictureinpicture"],(e=>this.handlePictureInPictureChange(e))),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],(e=>this.handlePictureInPictureEnabledChange(e))),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],(()=>{"audio"===e.currentType().substring(0,5)||e.audioPosterMode()||e.audioOnlyMode()?(e.isInPictureInPicture()&&e.exitPictureInPicture(),this.hide()):this.show()})),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control ${super.buildCSSClass()}`}handlePictureInPictureEnabledChange(){document.pictureInPictureEnabled&&!1===this.player_.disablePictureInPicture()?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?this.controlText("Exit Picture-in-Picture"):this.controlText("Picture-in-Picture"),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}}PictureInPictureToggle.prototype.controlText_="Picture-in-Picture",Component$1.registerComponent("PictureInPictureToggle",PictureInPictureToggle);class FullscreenToggle extends Button{constructor(e,t){super(e,t),this.on(e,"fullscreenchange",(e=>this.handleFullscreenChange(e))),!1===document[e.fsApi_.fullscreenEnabled]&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?this.controlText("Exit Fullscreen"):this.controlText("Fullscreen")}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}FullscreenToggle.prototype.controlText_="Fullscreen",Component$1.registerComponent("FullscreenToggle",FullscreenToggle);const checkVolumeSupport=function(e,t){t.tech_&&!t.tech_.featuresVolumeControl&&e.addClass("vjs-hidden"),e.on(t,"loadstart",(function(){t.tech_.featuresVolumeControl?e.removeClass("vjs-hidden"):e.addClass("vjs-hidden")}))};class VolumeLevel extends Component$1{createEl(){const e=super.createEl("div",{className:"vjs-volume-level"});return e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}Component$1.registerComponent("VolumeLevel",VolumeLevel);class VolumeLevelTooltip extends Component$1{constructor(e,t){super(e,t),this.update=throttle(bind_(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,i,s){if(!i){const i=getBoundingClientRect(this.el_),s=getBoundingClientRect(this.player_.el()),n=e.width*t;if(!s||!i)return;const r=e.left-s.left+n,a=e.width-n+(s.right-e.right);let o=i.width/2;r<o?o+=o-r:a<o&&(o=a),o<0?o=0:o>i.width&&(o=i.width),this.el_.style.right=`-${o}px`}this.write(`${s}%`)}write(e){textContent(this.el_,e)}updateVolume(e,t,i,s,n){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",(()=>{this.update(e,t,i,s.toFixed(0)),n&&n()}))}}Component$1.registerComponent("VolumeLevelTooltip",VolumeLevelTooltip);class MouseVolumeLevelDisplay extends Component$1{constructor(e,t){super(e,t),this.update=throttle(bind_(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,i){const s=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,i,s,(()=>{i?this.el_.style.bottom=e.height*t+"px":this.el_.style.left=e.width*t+"px"}))}}MouseVolumeLevelDisplay.prototype.options_={children:["volumeLevelTooltip"]},Component$1.registerComponent("MouseVolumeLevelDisplay",MouseVolumeLevelDisplay);class VolumeBar extends Slider{constructor(e,t){super(e,t),this.on("slideractive",(e=>this.updateLastVolume_(e))),this.on(e,"volumechange",(e=>this.updateARIAAttributes(e))),e.ready((()=>this.updateARIAAttributes()))}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){isSingleLeftClick(e)&&super.handleMouseDown(e)}handleMouseMove(e){const t=this.getChild("mouseVolumeLevelDisplay");if(t){const i=this.el(),s=getBoundingClientRect(i),n=this.vertical();let r=getPointerPosition(i,e);r=n?r.y:r.x,r=clamp(r,0,1),t.update(s,r,n)}isSingleLeftClick(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){const t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(100*this.player_.volume())}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",(()=>{0===this.player_.volume()&&this.player_.lastVolume_(e)}))}}VolumeBar.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"},IS_IOS||IS_ANDROID||VolumeBar.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay"),VolumeBar.prototype.playerEvent="volumechange",Component$1.registerComponent("VolumeBar",VolumeBar);class VolumeControl extends Component$1{constructor(e,t={}){t.vertical=t.vertical||!1,(void 0===t.volumeBar||isPlain(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),checkVolumeSupport(this,e),this.throttledHandleMouseMove=throttle(bind_(this,this.handleMouseMove),30),this.handleMouseUpHandler_=e=>this.handleMouseUp(e),this.on("mousedown",(e=>this.handleMouseDown(e))),this.on("touchstart",(e=>this.handleMouseDown(e))),this.on("mousemove",(e=>this.handleMouseMove(e))),this.on(this.volumeBar,["focus","slideractive"],(()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")})),this.on(this.volumeBar,["blur","sliderinactive"],(()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")}))}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){const t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}VolumeControl.prototype.options_={children:["volumeBar"]},Component$1.registerComponent("VolumeControl",VolumeControl);const checkMuteSupport=function(e,t){t.tech_&&!t.tech_.featuresMuteControl&&e.addClass("vjs-hidden"),e.on(t,"loadstart",(function(){t.tech_.featuresMuteControl?e.removeClass("vjs-hidden"):e.addClass("vjs-hidden")}))};class MuteToggle extends Button{constructor(e,t){super(e,t),checkMuteSupport(this,e),this.on(e,["loadstart","volumechange"],(e=>this.update(e)))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.volume(),i=this.player_.lastVolume_();if(0===t){const e=i<.1?.1:i;this.player_.volume(e),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const e=this.player_.volume();let t=3;IS_IOS&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),0===e||this.player_.muted()?t=0:e<.33?t=1:e<.67&&(t=2),removeClass(this.el_,[0,1,2,3].reduce(((e,t)=>e+`${t?" ":""}vjs-vol-${t}`),"")),addClass(this.el_,`vjs-vol-${t}`)}updateControlText_(){const e=this.player_.muted()||0===this.player_.volume()?"Unmute":"Mute";this.controlText()!==e&&this.controlText(e)}}MuteToggle.prototype.controlText_="Mute",Component$1.registerComponent("MuteToggle",MuteToggle);class VolumePanel extends Component$1{constructor(e,t={}){void 0!==t.inline?t.inline=t.inline:t.inline=!0,(void 0===t.volumeControl||isPlain(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=e=>this.handleKeyPress(e),this.on(e,["loadstart"],(e=>this.volumePanelState_(e))),this.on(this.muteToggle,"keyup",(e=>this.handleKeyPress(e))),this.on(this.volumeControl,"keyup",(e=>this.handleVolumeControlKeyUp(e))),this.on("keydown",(e=>this.handleKeyPress(e))),this.on("mouseover",(e=>this.handleMouseOver(e))),this.on("mouseout",(e=>this.handleMouseOut(e))),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){keycode.isEventKey(e,"Esc")&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),on(document,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),off(document,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){keycode.isEventKey(e,"Esc")&&this.handleMouseOut()}}VolumePanel.prototype.options_={children:["muteToggle","volumeControl"]},Component$1.registerComponent("VolumePanel",VolumePanel);class SkipForward extends Button{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime])),this.show()):this.hide()}getSkipForwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.currentTime(),i=this.player_.liveTracker,s=i&&i.isLive()?i.seekableEnd():this.player_.duration();let n;n=t+this.skipTime<=s?t+this.skipTime:s,this.player_.currentTime(n)}}Component$1.registerComponent("SkipForward",SkipForward);class SkipBackward extends Button{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime])),this.show()):this.hide()}getSkipBackwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.currentTime(),i=this.player_.liveTracker,s=i&&i.isLive()&&i.seekableStart();let n;n=s&&t-this.skipTime<=s?s:t>=this.skipTime?t-this.skipTime:0,this.player_.currentTime(n)}}SkipBackward.prototype.controlText_="Skip Backward",Component$1.registerComponent("SkipBackward",SkipBackward);class Menu extends Component$1{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on("keydown",(e=>this.handleKeyDown(e))),this.boundHandleBlur_=e=>this.handleBlur(e),this.boundHandleTapClick_=e=>this.handleTapClick(e)}addEventListenerForItem(e){e instanceof Component$1&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof Component$1&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){"string"==typeof e&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){const t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){const e=this.options_.contentElType||"ul";this.contentEl_=createEl(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const t=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return t.appendChild(this.contentEl_),on(t,"click",(function(e){e.preventDefault(),e.stopImmediatePropagation()})),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const t=e.relatedTarget||document.activeElement;if(!this.children().some((e=>e.el()===t))){const e=this.menuButton_;e&&e.buttonPressed_&&t!==e.el().firstChild&&e.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();const t=this.children();if(!Array.isArray(t))return;const i=t.filter((t=>t.el()===e.target))[0];if(!i)return;"CaptionSettingsMenuItem"!==i.name()&&this.menuButton_.focus()}}handleKeyDown(e){keycode.isEventKey(e,"Left")||keycode.isEventKey(e,"Down")?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(keycode.isEventKey(e,"Right")||keycode.isEventKey(e,"Up"))&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;void 0!==this.focusedChild_&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;void 0!==this.focusedChild_&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){const t=this.children().slice();t.length&&t[0].hasClass("vjs-menu-title")&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}Component$1.registerComponent("Menu",Menu);class MenuButton extends Component$1{constructor(e,t={}){super(e,t),this.menuButton_=new Button(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const i=Button.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+i,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const s=e=>this.handleClick(e);this.handleMenuKeyUp_=e=>this.handleMenuKeyUp(e),this.on(this.menuButton_,"tap",s),this.on(this.menuButton_,"click",s),this.on(this.menuButton_,"keydown",(e=>this.handleKeyDown(e))),this.on(this.menuButton_,"mouseenter",(()=>{this.addClass("vjs-hover"),this.menu.show(),on(document,"keyup",this.handleMenuKeyUp_)})),this.on("mouseleave",(e=>this.handleMouseLeave(e))),this.on("keydown",(e=>this.handleSubmenuKeyDown(e)))}update(){const e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const e=new Menu(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const t=createEl("li",{className:"vjs-menu-title",textContent:toTitleCase$1(this.options_.title),tabIndex:-1}),i=new Component$1(this.player_,{el:t});e.addItem(i)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}buildWrapperCSSClass(){let e="vjs-menu-button";return!0===this.options_.inline?e+="-inline":e+="-popup",`vjs-menu-button ${e} ${Button.prototype.buildCSSClass()} ${super.buildCSSClass()}`}buildCSSClass(){let e="vjs-menu-button";return!0===this.options_.inline?e+="-inline":e+="-popup",`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),off(document,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){keycode.isEventKey(e,"Esc")||keycode.isEventKey(e,"Tab")?(this.buttonPressed_&&this.unpressButton(),keycode.isEventKey(e,"Tab")||(e.preventDefault(),this.menuButton_.focus())):(keycode.isEventKey(e,"Up")||keycode.isEventKey(e,"Down"))&&(this.buttonPressed_||(e.preventDefault(),this.pressButton()))}handleMenuKeyUp(e){(keycode.isEventKey(e,"Esc")||keycode.isEventKey(e,"Tab"))&&this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(keycode.isEventKey(e,"Esc")||keycode.isEventKey(e,"Tab"))&&(this.buttonPressed_&&this.unpressButton(),keycode.isEventKey(e,"Tab")||(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),IS_IOS&&isInFrame())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}Component$1.registerComponent("MenuButton",MenuButton);class TrackButton extends MenuButton{constructor(e,t){const i=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),!i)return;const s=bind_(this,this.update);i.addEventListener("removetrack",s),i.addEventListener("addtrack",s),i.addEventListener("labelchange",s),this.player_.on("ready",s),this.player_.on("dispose",(function(){i.removeEventListener("removetrack",s),i.removeEventListener("addtrack",s),i.removeEventListener("labelchange",s)}))}}Component$1.registerComponent("TrackButton",TrackButton);const MenuKeys=["Tab","Esc","Up","Down","Right","Left"];class MenuItem extends ClickableComponent{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(e,t,i){this.nonIconControl=!0;const s=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),i);return s.replaceChild(createEl("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)}),s.querySelector(".vjs-icon-placeholder")),s}handleKeyDown(e){MenuKeys.some((t=>keycode.isEventKey(e,t)))||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}Component$1.registerComponent("MenuItem",MenuItem);class TextTrackMenuItem extends MenuItem{constructor(e,t){const i=t.track,s=e.textTracks();t.label=i.label||i.language||"Unknown",t.selected="showing"===i.mode,super(e,t),this.track=i,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);const n=(...e)=>{this.handleTracksChange.apply(this,e)},r=(...e)=>{this.handleSelectedLanguageChange.apply(this,e)};if(e.on(["loadstart","texttrackchange"],n),s.addEventListener("change",n),s.addEventListener("selectedlanguagechange",r),this.on("dispose",(function(){e.off(["loadstart","texttrackchange"],n),s.removeEventListener("change",n),s.removeEventListener("selectedlanguagechange",r)})),void 0===s.onchange){let e;this.on(["tap","click"],(function(){if("object"!=typeof window$1.Event)try{e=new window$1.Event("change")}catch(e){}e||(e=document.createEvent("Event"),e.initEvent("change",!0,!0)),s.dispatchEvent(e)}))}this.handleTracksChange()}handleClick(e){const t=this.track,i=this.player_.textTracks();if(super.handleClick(e),i)for(let e=0;e<i.length;e++){const s=i[e];-1!==this.kinds.indexOf(s.kind)&&(s===t?"showing"!==s.mode&&(s.mode="showing"):"disabled"!==s.mode&&(s.mode="disabled"))}}handleTracksChange(e){const t="showing"===this.track.mode;t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if("showing"===this.track.mode){const e=this.player_.cache_.selectedLanguage;if(e&&e.enabled&&e.language===this.track.language&&e.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}Component$1.registerComponent("TextTrackMenuItem",TextTrackMenuItem);class OffTextTrackMenuItem extends TextTrackMenuItem{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},t.kinds||(t.kinds=[t.kind]),t.label?t.track.label=t.label:t.track.label=t.kinds.join(" and ")+" off",t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){const t=this.player().textTracks();let i=!0;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(this.options_.kinds.indexOf(s.kind)>-1&&"showing"===s.mode){i=!1;break}}i!==this.isSelected_&&this.selected(i)}handleSelectedLanguageChange(e){const t=this.player().textTracks();let i=!0;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(["captions","descriptions","subtitles"].indexOf(s.kind)>-1&&"showing"===s.mode){i=!1;break}}i&&(this.player_.cache_.selectedLanguage={enabled:!1})}}Component$1.registerComponent("OffTextTrackMenuItem",OffTextTrackMenuItem);class TextTrackButton extends TrackButton{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=TextTrackMenuItem){let i;this.label_&&(i=`${this.label_} off`),e.push(new OffTextTrackMenuItem(this.player_,{kinds:this.kinds_,kind:this.kind_,label:i})),this.hideThreshold_+=1;const s=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let i=0;i<s.length;i++){const n=s[i];if(this.kinds_.indexOf(n.kind)>-1){const i=new t(this.player_,{track:n,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});i.addClass(`vjs-${n.kind}-menu-item`),e.push(i)}}return e}}Component$1.registerComponent("TextTrackButton",TextTrackButton);class ChaptersTrackMenuItem extends MenuItem{constructor(e,t){const i=t.track,s=t.cue,n=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=s.text,t.selected=s.startTime<=n&&n<s.endTime,super(e,t),this.track=i,this.cue=s}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}Component$1.registerComponent("ChaptersTrackMenuItem",ChaptersTrackMenuItem);class ChaptersButton extends TextTrackButton{constructor(e,t,i){super(e,t,i),this.selectCurrentItem_=()=>{this.items.forEach((e=>{e.selected(this.track_.activeCues[0]===e.cue)}))}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&"chapters"!==e.track.kind)return;const t=this.findChaptersTrack();t!==this.track_?(this.setTrack(t),super.update()):(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update()}setTrack(e){if(this.track_!==e){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const e=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);e&&e.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";const e=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);e&&e.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){const i=e[t];if(i.kind===this.kind_)return i}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(toTitleCase$1(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const e=[];if(!this.track_)return e;const t=this.track_.cues;if(!t)return e;for(let i=0,s=t.length;i<s;i++){const s=t[i],n=new ChaptersTrackMenuItem(this.player_,{track:this.track_,cue:s});e.push(n)}return e}}ChaptersButton.prototype.kind_="chapters",ChaptersButton.prototype.controlText_="Chapters",Component$1.registerComponent("ChaptersButton",ChaptersButton);class DescriptionsButton extends TextTrackButton{constructor(e,t,i){super(e,t,i);const s=e.textTracks(),n=bind_(this,this.handleTracksChange);s.addEventListener("change",n),this.on("dispose",(function(){s.removeEventListener("change",n)}))}handleTracksChange(e){const t=this.player().textTracks();let i=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s.kind!==this.kind_&&"showing"===s.mode){i=!0;break}}i?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}DescriptionsButton.prototype.kind_="descriptions",DescriptionsButton.prototype.controlText_="Descriptions",Component$1.registerComponent("DescriptionsButton",DescriptionsButton);class SubtitlesButton extends TextTrackButton{constructor(e,t,i){super(e,t,i)}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}SubtitlesButton.prototype.kind_="subtitles",SubtitlesButton.prototype.controlText_="Subtitles",Component$1.registerComponent("SubtitlesButton",SubtitlesButton);class CaptionSettingsMenuItem extends TextTrackMenuItem{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem",super(e,t),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}}Component$1.registerComponent("CaptionSettingsMenuItem",CaptionSettingsMenuItem);class CaptionsButton extends TextTrackButton{constructor(e,t,i){super(e,t,i)}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){const e=[];return this.player().tech_&&this.player().tech_.featuresNativeTextTracks||!this.player().getChild("textTrackSettings")||(e.push(new CaptionSettingsMenuItem(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}CaptionsButton.prototype.kind_="captions",CaptionsButton.prototype.controlText_="Captions",Component$1.registerComponent("CaptionsButton",CaptionsButton);class SubsCapsMenuItem extends TextTrackMenuItem{createEl(e,t,i){const s=super.createEl(e,t,i),n=s.querySelector(".vjs-menu-item-text");return"captions"===this.options_.track.kind&&(n.appendChild(createEl("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),n.appendChild(createEl("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),s}}Component$1.registerComponent("SubsCapsMenuItem",SubsCapsMenuItem);class SubsCapsButton extends TextTrackButton{constructor(e,t={}){super(e,t),this.label_="subtitles",["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1&&(this.label_="captions"),this.menuButton_.controlText(toTitleCase$1(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return this.player().tech_&&this.player().tech_.featuresNativeTextTracks||!this.player().getChild("textTrackSettings")||(e.push(new CaptionSettingsMenuItem(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,SubsCapsMenuItem),e}}SubsCapsButton.prototype.kinds_=["captions","subtitles"],SubsCapsButton.prototype.controlText_="Subtitles",Component$1.registerComponent("SubsCapsButton",SubsCapsButton);class AudioTrackMenuItem extends MenuItem{constructor(e,t){const i=t.track,s=e.audioTracks();t.label=i.label||i.language||"Unknown",t.selected=i.enabled,super(e,t),this.track=i,this.addClass(`vjs-${i.kind}-menu-item`);const n=(...e)=>{this.handleTracksChange.apply(this,e)};s.addEventListener("change",n),this.on("dispose",(()=>{s.removeEventListener("change",n)}))}createEl(e,t,i){const s=super.createEl(e,t,i),n=s.querySelector(".vjs-menu-item-text");return"main-desc"===this.options_.track.kind&&(n.appendChild(createEl("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),n.appendChild(createEl("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),s}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const e=this.player_.audioTracks();for(let t=0;t<e.length;t++){const i=e[t];i!==this.track&&(i.enabled=i===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}Component$1.registerComponent("AudioTrackMenuItem",AudioTrackMenuItem);class AudioTrackButton extends TrackButton{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t)}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;const t=this.player_.audioTracks();for(let i=0;i<t.length;i++){const s=t[i];e.push(new AudioTrackMenuItem(this.player_,{track:s,selectable:!0,multiSelectable:!1}))}return e}}AudioTrackButton.prototype.controlText_="Audio Track",Component$1.registerComponent("AudioTrackButton",AudioTrackButton);class PlaybackRateMenuItem extends MenuItem{constructor(e,t){const i=t.rate,s=parseFloat(i,10);t.label=i,t.selected=s===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=i,this.rate=s,this.on(e,"ratechange",(e=>this.update(e)))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}PlaybackRateMenuItem.prototype.contentElType="button",Component$1.registerComponent("PlaybackRateMenuItem",PlaybackRateMenuItem);class PlaybackRateMenuButton extends MenuButton{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",(e=>this.updateVisibility(e))),this.on(e,"ratechange",(e=>this.updateLabel(e))),this.on(e,"playbackrateschange",(e=>this.handlePlaybackRateschange(e)))}createEl(){const e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=createEl("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const e=this.playbackRates(),t=[];for(let i=e.length-1;i>=0;i--)t.push(new PlaybackRateMenuItem(this.player(),{rate:e[i]+"x"}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){const e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}PlaybackRateMenuButton.prototype.controlText_="Playback Rate",Component$1.registerComponent("PlaybackRateMenuButton",PlaybackRateMenuButton);class Spacer extends Component$1{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},i={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,i)}}Component$1.registerComponent("Spacer",Spacer);class CustomControlSpacer extends Spacer{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}Component$1.registerComponent("CustomControlSpacer",CustomControlSpacer);class ControlBar extends Component$1{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}ControlBar.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","fullscreenToggle"]},"exitPictureInPicture"in document&&ControlBar.prototype.options_.children.splice(ControlBar.prototype.options_.children.length-1,0,"pictureInPictureToggle"),Component$1.registerComponent("ControlBar",ControlBar);class ErrorDisplay extends ModalDialog{constructor(e,t){super(e,t),this.on(e,"error",(e=>this.open(e)))}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const e=this.player().error();return e?this.localize(e.message):""}}ErrorDisplay.prototype.options_=Object.assign({},ModalDialog.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0}),Component$1.registerComponent("ErrorDisplay",ErrorDisplay);const LOCAL_STORAGE_KEY$1="vjs-text-track-settings",COLOR_BLACK=["#000","Black"],COLOR_BLUE=["#00F","Blue"],COLOR_CYAN=["#0FF","Cyan"],COLOR_GREEN=["#0F0","Green"],COLOR_MAGENTA=["#F0F","Magenta"],COLOR_RED=["#F00","Red"],COLOR_WHITE=["#FFF","White"],COLOR_YELLOW=["#FF0","Yellow"],OPACITY_OPAQUE=["1","Opaque"],OPACITY_SEMI=["0.5","Semi-Transparent"],OPACITY_TRANS=["0","Transparent"],selectConfigs={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[COLOR_BLACK,COLOR_WHITE,COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_YELLOW,COLOR_MAGENTA,COLOR_CYAN]},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[OPACITY_OPAQUE,OPACITY_SEMI,OPACITY_TRANS]},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[COLOR_WHITE,COLOR_BLACK,COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_YELLOW,COLOR_MAGENTA,COLOR_CYAN]},edgeStyle:{selector:".vjs-edge-style > select",id:"%s",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Dropshadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"captions-font-family-%s",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"captions-font-size-%s",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:e=>"1.00"===e?null:Number(e)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[OPACITY_OPAQUE,OPACITY_SEMI]},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[OPACITY_TRANS,OPACITY_SEMI,OPACITY_OPAQUE]}};function parseOptionValue(e,t){if(t&&(e=t(e)),e&&"none"!==e)return e}function getSelectedOptionValue(e,t){return parseOptionValue(e.options[e.options.selectedIndex].value,t)}function setSelectedOption(e,t,i){if(t)for(let s=0;s<e.options.length;s++)if(parseOptionValue(e.options[s].value,i)===t){e.selectedIndex=s;break}}selectConfigs.windowColor.options=selectConfigs.backgroundColor.options;class TextTrackSettings extends ModalDialog{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.endDialog=createEl("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),void 0===t.persistTextTrackSettings&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.on(this.$(".vjs-done-button"),"click",(()=>{this.saveSettings(),this.close()})),this.on(this.$(".vjs-default-button"),"click",(()=>{this.setDefaults(),this.updateDisplay()})),each(selectConfigs,(e=>{this.on(this.$(e.selector),"change",this.updateDisplay)})),this.options_.persistTextTrackSettings&&this.restoreSettings()}dispose(){this.endDialog=null,super.dispose()}createElSelect_(e,t="",i="label"){const s=selectConfigs[e],n=s.id.replace("%s",this.id_),r=[t,n].join(" ").trim();return[`<${i} id="${n}" class="${"label"===i?"vjs-label":""}">`,this.localize(s.label),`</${i}>`,`<select aria-labelledby="${r}">`].concat(s.options.map((e=>{const t=n+"-"+e[1].replace(/\W+/g,"");return[`<option id="${t}" value="${e[0]}" `,`aria-labelledby="${r} ${t}">`,this.localize(e[1]),"</option>"].join("")}))).concat("</select>").join("")}createElFgColor_(){const e=`captions-text-legend-${this.id_}`;return['<fieldset class="vjs-fg vjs-track-setting">',`<legend id="${e}">`,this.localize("Text"),"</legend>",'<span class="vjs-text-color">',this.createElSelect_("color",e),"</span>",'<span class="vjs-text-opacity vjs-opacity">',this.createElSelect_("textOpacity",e),"</span>","</fieldset>"].join("")}createElBgColor_(){const e=`captions-background-${this.id_}`;return['<fieldset class="vjs-bg vjs-track-setting">',`<legend id="${e}">`,this.localize("Text Background"),"</legend>",'<span class="vjs-bg-color">',this.createElSelect_("backgroundColor",e),"</span>",'<span class="vjs-bg-opacity vjs-opacity">',this.createElSelect_("backgroundOpacity",e),"</span>","</fieldset>"].join("")}createElWinColor_(){const e=`captions-window-${this.id_}`;return['<fieldset class="vjs-window vjs-track-setting">',`<legend id="${e}">`,this.localize("Caption Area Background"),"</legend>",'<span class="vjs-window-color">',this.createElSelect_("windowColor",e),"</span>",'<span class="vjs-window-opacity vjs-opacity">',this.createElSelect_("windowOpacity",e),"</span>","</fieldset>"].join("")}createElColors_(){return createEl("div",{className:"vjs-track-settings-colors",innerHTML:[this.createElFgColor_(),this.createElBgColor_(),this.createElWinColor_()].join("")})}createElFont_(){return createEl("div",{className:"vjs-track-settings-font",innerHTML:['<fieldset class="vjs-font-percent vjs-track-setting">',this.createElSelect_("fontPercent","","legend"),"</fieldset>",'<fieldset class="vjs-edge-style vjs-track-setting">',this.createElSelect_("edgeStyle","","legend"),"</fieldset>",'<fieldset class="vjs-font-family vjs-track-setting">',this.createElSelect_("fontFamily","","legend"),"</fieldset>"].join("")})}createElControls_(){const e=this.localize("restore all settings to the default values");return createEl("div",{className:"vjs-track-settings-controls",innerHTML:[`<button type="button" class="vjs-default-button" title="${e}">`,this.localize("Reset"),`<span class="vjs-control-text"> ${e}</span>`,"</button>",`<button type="button" class="vjs-done-button">${this.localize("Done")}</button>`].join("")})}content(){return[this.createElColors_(),this.createElFont_(),this.createElControls_()]}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return reduce(selectConfigs,((e,t,i)=>{const s=getSelectedOptionValue(this.$(t.selector),t.parser);return void 0!==s&&(e[i]=s),e}),{})}setValues(e){each(selectConfigs,((t,i)=>{setSelectedOption(this.$(t.selector),e[i],t.parser)}))}setDefaults(){each(selectConfigs,(e=>{const t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t}))}restoreSettings(){let e;try{e=JSON.parse(window$1.localStorage.getItem(LOCAL_STORAGE_KEY$1))}catch(e){log$1.warn(e)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?window$1.localStorage.setItem(LOCAL_STORAGE_KEY$1,JSON.stringify(e)):window$1.localStorage.removeItem(LOCAL_STORAGE_KEY$1)}catch(e){log$1.warn(e)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}conditionalBlur_(){this.previouslyActiveEl_=null;const e=this.player_.controlBar,t=e&&e.subsCapsButton,i=e&&e.captionsButton;t?t.focus():i&&i.focus()}}Component$1.registerComponent("TextTrackSettings",TextTrackSettings);class ResizeManager extends Component$1{constructor(e,t){let i=t.ResizeObserver||window$1.ResizeObserver;null===t.ResizeObserver&&(i=!1),super(e,merge$1({createEl:!i,reportTouchActivity:!1},t)),this.ResizeObserver=t.ResizeObserver||window$1.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=debounce((()=>{this.resizeHandler()}),100,!1,this),i?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const e=this.debouncedHandler_;let t=this.unloadListener_=function(){off(this,"resize",e),off(this,"unload",t),t=null};on(this.el_.contentWindow,"unload",t),on(this.el_.contentWindow,"resize",e)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){this.player_&&this.player_.trigger&&this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}Component$1.registerComponent("ResizeManager",ResizeManager);const defaults={trackingThreshold:20,liveTolerance:15};class LiveTracker extends Component$1{constructor(e,t){super(e,merge$1(defaults,t,{createEl:!1})),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=e=>this.handlePlay(e),this.handleFirstTimeupdate_=e=>this.handleFirstTimeupdate(e),this.handleSeeked_=e=>this.handleSeeked(e),this.seekToLiveEdge_=e=>this.seekToLiveEdge(e),this.reset_(),this.on(this.player_,"durationchange",(e=>this.handleDurationchange(e))),this.on(this.player_,"canplay",(()=>this.toggleTracking()))}trackLive_(){const e=this.player_.seekable();if(!e||!e.length)return;const t=Number(window$1.performance.now().toFixed(4)),i=-1===this.lastTime_?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+i;const s=this.liveCurrentTime(),n=this.player_.currentTime();let r=this.player_.paused()||this.seekedBehindLive_||Math.abs(s-n)>this.options_.liveTolerance;this.timeupdateSeen_&&s!==1/0||(r=!1),r!==this.behindLiveEdge_&&(this.behindLiveEdge_=r,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,30),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.end(i));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){const e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.start(i));return t.length?t.sort()[0]:0}liveWindow(){const e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const e=this.seekableEnd();return-1!==this.lastSeekEnd_&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return"number"==typeof this.trackingInterval_}seekToLiveEdge(){this.seekedBehindLive_=!1,this.atLiveEdge()||(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}Component$1.registerComponent("LiveTracker",LiveTracker);class TitleBar extends Component$1{constructor(e,t){super(e,t),this.on("statechanged",(e=>this.updateDom_())),this.updateDom_()}createEl(){return this.els={title:createEl("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${newGUID()}`}),description:createEl("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${newGUID()}`})},createEl("div",{className:"vjs-title-bar"},{},Object.values(this.els))}updateDom_(){const e=this.player_.tech_,t=e&&e.el_,i={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach((e=>{const s=this.state[e],n=this.els[e],r=i[e];emptyEl(n),s&&textContent(n,s),t&&(t.removeAttribute(r),s&&t.setAttribute(r,n.id))})),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){const e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute("aria-labelledby"),t.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}Component$1.registerComponent("TitleBar",TitleBar);const sourcesetLoad=e=>{const t=e.el();if(t.hasAttribute("src"))return e.triggerSourceset(t.src),!0;const i=e.$$("source"),s=[];let n="";if(!i.length)return!1;for(let e=0;e<i.length;e++){const t=i[e].src;t&&-1===s.indexOf(t)&&s.push(t)}return!!s.length&&(1===s.length&&(n=s[0]),e.triggerSourceset(n),!0)},innerHTMLDescriptorPolyfill=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(e){const t=document.createElement(this.nodeName.toLowerCase());t.innerHTML=e;const i=document.createDocumentFragment();for(;t.childNodes.length;)i.appendChild(t.childNodes[0]);return this.innerText="",window$1.Element.prototype.appendChild.call(this,i),this.innerHTML}}),getDescriptor=(e,t)=>{let i={};for(let s=0;s<e.length&&(i=Object.getOwnPropertyDescriptor(e[s],t),!(i&&i.set&&i.get));s++);return i.enumerable=!0,i.configurable=!0,i},getInnerHTMLDescriptor=e=>getDescriptor([e.el(),window$1.HTMLMediaElement.prototype,window$1.Element.prototype,innerHTMLDescriptorPolyfill],"innerHTML"),firstSourceWatch=function(e){const t=e.el();if(t.resetSourceWatch_)return;const i={},s=getInnerHTMLDescriptor(e),n=i=>(...s)=>{const n=i.apply(t,s);return sourcesetLoad(e),n};["append","appendChild","insertAdjacentHTML"].forEach((e=>{t[e]&&(i[e]=t[e],t[e]=n(i[e]))})),Object.defineProperty(t,"innerHTML",merge$1(s,{set:n(s.set)})),t.resetSourceWatch_=()=>{t.resetSourceWatch_=null,Object.keys(i).forEach((e=>{t[e]=i[e]})),Object.defineProperty(t,"innerHTML",s)},e.one("sourceset",t.resetSourceWatch_)},srcDescriptorPolyfill=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?getAbsoluteURL(window$1.Element.prototype.getAttribute.call(this,"src")):""},set(e){return window$1.Element.prototype.setAttribute.call(this,"src",e),e}}),getSrcDescriptor=e=>getDescriptor([e.el(),window$1.HTMLMediaElement.prototype,srcDescriptorPolyfill],"src"),setupSourceset=function(e){if(!e.featuresSourceset)return;const t=e.el();if(t.resetSourceset_)return;const i=getSrcDescriptor(e),s=t.setAttribute,n=t.load;Object.defineProperty(t,"src",merge$1(i,{set:s=>{const n=i.set.call(t,s);return e.triggerSourceset(t.src),n}})),t.setAttribute=(i,n)=>{const r=s.call(t,i,n);return/src/i.test(i)&&e.triggerSourceset(t.src),r},t.load=()=>{const i=n.call(t);return sourcesetLoad(e)||(e.triggerSourceset(""),firstSourceWatch(e)),i},t.currentSrc?e.triggerSourceset(t.currentSrc):sourcesetLoad(e)||firstSourceWatch(e),t.resetSourceset_=()=>{t.resetSourceset_=null,t.load=n,t.setAttribute=s,Object.defineProperty(t,"src",i),t.resetSourceWatch_&&t.resetSourceWatch_()}};class Html5 extends Tech{constructor(e,t){super(e,t);const i=e.source;let s=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&"VIDEO"===this.el_.tagName,i&&(this.el_.currentSrc!==i.src||e.tag&&3===e.tag.initNetworkState_)?this.setSource(i):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const e=this.el_.childNodes;let t=e.length;const i=[];for(;t--;){const n=e[t];"track"===n.nodeName.toLowerCase()&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(n),this.remoteTextTracks().addTrack(n.track),this.textTracks().addTrack(n.track),s||this.el_.hasAttribute("crossorigin")||!isCrossOrigin(n.src)||(s=!0)):i.push(n))}for(let e=0;e<i.length;e++)this.el_.removeChild(i[e])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&s&&log$1.warn("Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.\nThis may prevent text tracks from loading."),this.restoreMetadataTracksInIOSNativePlayer_(),(TOUCH_ENABLED||IS_IPHONE)&&!0===e.nativeControlsForTouch&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),Html5.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){setupSourceset(this)}restoreMetadataTracksInIOSNativePlayer_(){const e=this.textTracks();let t;const i=()=>{t=[];for(let i=0;i<e.length;i++){const s=e[i];"metadata"===s.kind&&t.push({track:s,storedMode:s.mode})}};i(),e.addEventListener("change",i),this.on("dispose",(()=>e.removeEventListener("change",i)));const s=()=>{for(let e=0;e<t.length;e++){const i=t[e];"disabled"===i.track.mode&&i.track.mode!==i.storedMode&&(i.track.mode=i.storedMode)}e.removeEventListener("change",s)};this.on("webkitbeginfullscreen",(()=>{e.removeEventListener("change",i),e.removeEventListener("change",s),e.addEventListener("change",s)})),this.on("webkitendfullscreen",(()=>{e.removeEventListener("change",i),e.addEventListener("change",i),e.removeEventListener("change",s)}))}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;const i=e.toLowerCase();this[`${i}TracksListeners_`]&&Object.keys(this[`${i}TracksListeners_`]).forEach((e=>{this.el()[`${i}Tracks`].removeEventListener(e,this[`${i}TracksListeners_`][e])})),this[`featuresNative${e}Tracks`]=!t,this[`${i}TracksListeners_`]=null,this.proxyNativeTracksForType_(i)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){const t=NORMAL[e],i=this.el()[t.getterName],s=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!i||!i.addEventListener)return;const n={change:t=>{const i={type:"change",target:s,currentTarget:s,srcElement:s};s.trigger(i),"text"===e&&this[REMOTE.remoteText.getterName]().trigger(i)},addtrack(e){s.addTrack(e.track)},removetrack(e){s.removeTrack(e.track)}},r=function(){const e=[];for(let t=0;t<s.length;t++){let n=!1;for(let e=0;e<i.length;e++)if(i[e]===s[t]){n=!0;break}n||e.push(s[t])}for(;e.length;)s.removeTrack(e.shift())};this[t.getterName+"Listeners_"]=n,Object.keys(n).forEach((e=>{const t=n[e];i.addEventListener(e,t),this.on("dispose",(s=>i.removeEventListener(e,t)))})),this.on("loadstart",r),this.on("dispose",(e=>this.off("loadstart",r)))}proxyNativeTracks_(){NORMAL.names.forEach((e=>{this.proxyNativeTracksForType_(e)}))}createEl(){let e=this.options_.tag;if(!e||!this.options_.playerElIngest&&!this.movingMediaElementInDOM){if(e){const t=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(t,e),Html5.disposeMediaElement(e),e=t}else{e=document.createElement("video");const t=merge$1({},this.options_.tag&&getAttributes(this.options_.tag));TOUCH_ENABLED&&!0===this.options_.nativeControlsForTouch||delete t.controls,setAttributes(e,Object.assign(t,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}void 0!==this.options_.preload&&setAttribute(e,"preload",this.options_.preload),void 0!==this.options_.disablePictureInPicture&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);const t=["loop","muted","playsinline","autoplay"];for(let i=0;i<t.length;i++){const s=t[i],n=this.options_[s];void 0!==n&&(n?setAttribute(e,s,s):removeAttribute(e,s),e[s]=n)}return e}handleLateInit_(e){if(0===e.networkState||3===e.networkState)return;if(0===e.readyState){let e=!1;const t=function(){e=!0};this.on("loadstart",t);const i=function(){e||this.trigger("loadstart")};return this.on("loadedmetadata",i),void this.ready((function(){this.off("loadstart",t),this.off("loadedmetadata",i),e||this.trigger("loadstart")}))}const t=["loadstart"];t.push("loadedmetadata"),e.readyState>=2&&t.push("loadeddata"),e.readyState>=3&&t.push("canplay"),e.readyState>=4&&t.push("canplaythrough"),this.ready((function(){t.forEach((function(e){this.trigger(e)}),this)}))}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&IS_ANY_SAFARI?this.el_.fastSeek(e):this.el_.currentTime=e}catch(e){log$1(e,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&IS_ANDROID&&IS_CHROME&&0===this.el_.currentTime){const e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){"webkitPresentationMode"in this.el_&&"picture-in-picture"!==this.el_.webkitPresentationMode&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",t),this.on("dispose",(()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)}))}supportsFullScreen(){return"function"==typeof this.el_.webkitEnterFullScreen}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)silencePromise(this.el_.play()),this.setTimeout((function(){e.pause();try{e.webkitEnterFullScreen()}catch(e){this.trigger("fullscreenerror",e)}}),0);else try{e.webkitEnterFullScreen()}catch(e){this.trigger("fullscreenerror",e)}}exitFullScreen(){this.el_.webkitDisplayingFullscreen?this.el_.webkitExitFullScreen():this.trigger("fullscreenerror",new Error("The video is not fullscreen"))}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(void 0===e)return this.el_.src;this.setSrc(e)}reset(){Html5.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,i){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,i):super.addTextTrack(e,t,i)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);const t=document.createElement("track");return e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t}addRemoteTextTrack(e,t){const i=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(i),i}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){const t=this.$$("track");let i=t.length;for(;i--;)e!==t[i]&&e!==t[i].track||this.el().removeChild(t[i])}}getVideoPlaybackQuality(){if("function"==typeof this.el().getVideoPlaybackQuality)return this.el().getVideoPlaybackQuality();const e={};return void 0!==this.el().webkitDroppedFrameCount&&void 0!==this.el().webkitDecodedFrameCount&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),window$1.performance&&(e.creationTime=window$1.performance.now()),e}}defineLazyProperty(Html5,"TEST_VID",(function(){if(!isReal())return;const e=document.createElement("video"),t=document.createElement("track");return t.kind="captions",t.srclang="en",t.label="English",e.appendChild(t),e})),Html5.isSupported=function(){try{Html5.TEST_VID.volume=.5}catch(e){return!1}return!(!Html5.TEST_VID||!Html5.TEST_VID.canPlayType)},Html5.canPlayType=function(e){return Html5.TEST_VID.canPlayType(e)},Html5.canPlaySource=function(e,t){return Html5.canPlayType(e.type)},Html5.canControlVolume=function(){try{const e=Html5.TEST_VID.volume;Html5.TEST_VID.volume=e/2+.1;const t=e!==Html5.TEST_VID.volume;return t&&IS_IOS?(window$1.setTimeout((()=>{Html5&&Html5.prototype&&(Html5.prototype.featuresVolumeControl=e!==Html5.TEST_VID.volume)})),!1):t}catch(e){return!1}},Html5.canMuteVolume=function(){try{const e=Html5.TEST_VID.muted;return Html5.TEST_VID.muted=!e,Html5.TEST_VID.muted?setAttribute(Html5.TEST_VID,"muted","muted"):removeAttribute(Html5.TEST_VID,"muted","muted"),e!==Html5.TEST_VID.muted}catch(e){return!1}},Html5.canControlPlaybackRate=function(){if(IS_ANDROID&&IS_CHROME&&CHROME_VERSION<58)return!1;try{const e=Html5.TEST_VID.playbackRate;return Html5.TEST_VID.playbackRate=e/2+.1,e!==Html5.TEST_VID.playbackRate}catch(e){return!1}},Html5.canOverrideAttributes=function(){try{const e=()=>{};Object.defineProperty(document.createElement("video"),"src",{get:e,set:e}),Object.defineProperty(document.createElement("audio"),"src",{get:e,set:e}),Object.defineProperty(document.createElement("video"),"innerHTML",{get:e,set:e}),Object.defineProperty(document.createElement("audio"),"innerHTML",{get:e,set:e})}catch(e){return!1}return!0},Html5.supportsNativeTextTracks=function(){return IS_ANY_SAFARI||IS_IOS&&IS_CHROME},Html5.supportsNativeVideoTracks=function(){return!(!Html5.TEST_VID||!Html5.TEST_VID.videoTracks)},Html5.supportsNativeAudioTracks=function(){return!(!Html5.TEST_VID||!Html5.TEST_VID.audioTracks)},Html5.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"],[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach((function([e,t]){defineLazyProperty(Html5.prototype,e,(()=>Html5[t]()),!0)})),Html5.prototype.featuresVolumeControl=Html5.canControlVolume(),Html5.prototype.movingMediaElementInDOM=!IS_IOS,Html5.prototype.featuresFullscreenResize=!0,Html5.prototype.featuresProgressEvents=!0,Html5.prototype.featuresTimeupdateEvents=!0,Html5.prototype.featuresVideoFrameCallback=!(!Html5.TEST_VID||!Html5.TEST_VID.requestVideoFrameCallback),Html5.disposeMediaElement=function(e){if(e){for(e.parentNode&&e.parentNode.removeChild(e);e.hasChildNodes();)e.removeChild(e.firstChild);e.removeAttribute("src"),"function"==typeof e.load&&function(){try{e.load()}catch(e){}}()}},Html5.resetMediaElement=function(e){if(!e)return;const t=e.querySelectorAll("source");let i=t.length;for(;i--;)e.removeChild(t[i]);e.removeAttribute("src"),"function"==typeof e.load&&function(){try{e.load()}catch(e){}}()},["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach((function(e){Html5.prototype[e]=function(){return this.el_[e]||this.el_.hasAttribute(e)}})),["muted","defaultMuted","autoplay","loop","playsinline"].forEach((function(e){Html5.prototype["set"+toTitleCase$1(e)]=function(t){this.el_[e]=t,t?this.el_.setAttribute(e,e):this.el_.removeAttribute(e)}})),["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach((function(e){Html5.prototype[e]=function(){return this.el_[e]}})),["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach((function(e){Html5.prototype["set"+toTitleCase$1(e)]=function(t){this.el_[e]=t}})),["pause","load","play"].forEach((function(e){Html5.prototype[e]=function(){return this.el_[e]()}})),Tech.withSourceHandlers(Html5),Html5.nativeSourceHandler={},Html5.nativeSourceHandler.canPlayType=function(e){try{return Html5.TEST_VID.canPlayType(e)}catch(e){return""}},Html5.nativeSourceHandler.canHandleSource=function(e,t){if(e.type)return Html5.nativeSourceHandler.canPlayType(e.type);if(e.src){const t=getFileExtension(e.src);return Html5.nativeSourceHandler.canPlayType(`video/${t}`)}return""},Html5.nativeSourceHandler.handleSource=function(e,t,i){t.setSrc(e.src)},Html5.nativeSourceHandler.dispose=function(){},Html5.registerSourceHandler(Html5.nativeSourceHandler),Tech.registerTech("Html5",Html5);const TECH_EVENTS_RETRIGGER=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],TECH_EVENTS_QUEUE={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},BREAKPOINT_ORDER=["tiny","xsmall","small","medium","large","xlarge","huge"],BREAKPOINT_CLASSES={};BREAKPOINT_ORDER.forEach((e=>{const t="x"===e.charAt(0)?`x-${e.substring(1)}`:e;BREAKPOINT_CLASSES[e]=`vjs-layout-${t}`}));const DEFAULT_BREAKPOINTS={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class Player extends Component$1{constructor(e,t,i){if(e.id=e.id||t.id||`vjs_video_${newGUID()}`,(t=Object.assign(Player.getTagSettings(e),t)).initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){const i=e.closest("[lang]");i&&(t.language=i.getAttribute("lang"))}if(super(null,t,i),this.boundDocumentFullscreenChange_=e=>this.documentFullscreenChange_(e),this.boundFullWindowOnEscKey_=e=>this.fullWindowOnEscKey(e),this.boundUpdateStyleEl_=e=>this.updateStyleEl_(e),this.boundApplyInitTime_=e=>this.applyInitTime_(e),this.boundUpdateCurrentBreakpoint_=e=>this.updateCurrentBreakpoint_(e),this.boundHandleTechClick_=e=>this.handleTechClick_(e),this.boundHandleTechDoubleClick_=e=>this.handleTechDoubleClick_(e),this.boundHandleTechTouchStart_=e=>this.handleTechTouchStart_(e),this.boundHandleTechTouchMove_=e=>this.handleTechTouchMove_(e),this.boundHandleTechTouchEnd_=e=>this.handleTechTouchEnd_(e),this.boundHandleTechTap_=e=>this.handleTechTap_(e),this.isFullscreen_=!1,this.log=createLogger(this.id_),this.fsApi_=FullscreenApi,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&getAttributes(e),this.language(this.options_.language),t.languages){const e={};Object.getOwnPropertyNames(t.languages).forEach((function(i){e[i.toLowerCase()]=t.languages[i]})),this.languages_=e}else this.languages_=Player.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach((e=>{if("function"!=typeof this[e])throw new Error(`plugin "${e}" does not exist`)})),this.scrubbing_=!1,this.el_=this.createEl(),evented(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(on(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const s=merge$1(this.options_);t.plugins&&Object.keys(t.plugins).forEach((e=>{this[e](t.plugins[e])})),t.debug&&this.debug(!0),this.options_.playerOptions=s,this.middleware_=[],this.playbackRates(t.playbackRates),this.initChildren(),this.isAudio("audio"===e.nodeName.toLowerCase()),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),TOUCH_ENABLED&&this.addClass("vjs-touch-enabled"),IS_IOS||this.addClass("vjs-workinghover"),Player.players[this.id_]=this;const n=version$6.split(".")[0];this.addClass(`vjs-v${n}`),this.userActive(!0),this.reportUserActivity(),this.one("play",(e=>this.listenForUserActivity_(e))),this.on("keydown",(e=>this.handleKeyDown(e))),this.on("languagechange",(e=>this.handleLanguagechange(e))),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",(()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)}))}dispose(){this.trigger("dispose"),this.off("dispose"),off(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),off(document,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),Player.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),clearCacheForPlayer(this),ALL.names.forEach((e=>{const t=this[ALL[e].getterName]();t&&t.off&&t.off()})),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e,t=this.tag,i=this.playerElIngest_=t.parentNode&&t.parentNode.hasAttribute&&t.parentNode.hasAttribute("data-vjs-player");const s="video-js"===this.tag.tagName.toLowerCase();i?e=this.el_=t.parentNode:s||(e=this.el_=super.createEl("div"));const n=getAttributes(t);if(s){for(e=this.el_=t,t=this.tag=document.createElement("video");e.children.length;)t.appendChild(e.firstChild);hasClass(e,"video-js")||addClass(e,"video-js"),e.appendChild(t),i=this.playerElIngest_=e,Object.keys(e).forEach((i=>{try{t[i]=e[i]}catch(e){}}))}if(t.setAttribute("tabindex","-1"),n.tabindex="-1",IS_CHROME&&IS_WINDOWS&&(t.setAttribute("role","application"),n.role="application"),t.removeAttribute("width"),t.removeAttribute("height"),"width"in n&&delete n.width,"height"in n&&delete n.height,Object.getOwnPropertyNames(n).forEach((function(i){s&&"class"===i||e.setAttribute(i,n[i]),s&&t.setAttribute(i,n[i])})),t.playerId=t.id,t.id+="_html5_api",t.className="vjs-tech",t.player=e.player=this,this.addClass("vjs-paused"),!0!==window$1.VIDEOJS_NO_DYNAMIC_STYLE){this.styleEl_=createStyleElement("vjs-styles-dimensions");const e=$(".vjs-styles-defaults"),t=$("head");t.insertBefore(this.styleEl_,e?e.nextSibling:t.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const r=t.getElementsByTagName("a");for(let e=0;e<r.length;e++){const t=r.item(e);addClass(t,"vjs-hidden"),t.setAttribute("hidden","hidden")}return t.initNetworkState_=t.networkState,t.parentNode&&!i&&t.parentNode.insertBefore(e,t),prependTo(t,e),this.children_.unshift(t),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=e,e}crossOrigin(e){if(void 0===e)return this.techGet_("crossOrigin");null===e||"anonymous"===e||"use-credentials"===e?(this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e)):log$1.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`)}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){const i=e+"_";if(void 0===t)return this[i]||0;if(""===t||"auto"===t)return this[i]=void 0,void this.updateStyleEl_();const s=parseFloat(t);isNaN(s)?log$1.error(`Improper value "${t}" supplied for for ${e}`):(this[i]=s,this.updateStyleEl_())}fluid(e){if(void 0===e)return!!this.fluid_;var t,i;this.fluid_=!!e,isEvented(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),i=()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)},isEvented(t=this)?i():(t.eventedCallbacks||(t.eventedCallbacks=[]),t.eventedCallbacks.push(i))):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(void 0===e)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(void 0===e)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(!0===window$1.VIDEOJS_NO_DYNAMIC_STYLE){const e="number"==typeof this.width_?this.width_:this.options_.width,t="number"==typeof this.height_?this.height_:this.options_.height,i=this.tech_&&this.tech_.el();return void(i&&(e>=0&&(i.width=e),t>=0&&(i.height=t)))}let e,t,i,s;i=void 0!==this.aspectRatio_&&"auto"!==this.aspectRatio_?this.aspectRatio_:this.videoWidth()>0?this.videoWidth()+":"+this.videoHeight():"16:9";const n=i.split(":"),r=n[1]/n[0];e=void 0!==this.width_?this.width_:void 0!==this.height_?this.height_/r:this.videoWidth()||300,t=void 0!==this.height_?this.height_:e*r,s=/^[^a-zA-Z]/.test(this.id())?"dimensions-"+this.id():this.id()+"-dimensions",this.addClass(s),setTextContent(this.styleEl_,`\n .${s} {\n width: ${e}px;\n height: ${t}px;\n }\n\n .${s}.vjs-fluid:not(.vjs-audio-only-mode) {\n padding-top: ${100*r}%;\n }\n `)}loadTech_(e,t){this.tech_&&this.unloadTech_();const i=toTitleCase$1(e),s=e.charAt(0).toLowerCase()+e.slice(1);"Html5"!==i&&this.tag&&(Tech.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=i,this.isReady_=!1;let n=this.autoplay();("string"==typeof this.autoplay()||!0===this.autoplay()&&this.options_.normalizeAutoplay)&&(n=!1);const r={source:t,autoplay:n,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${s}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};ALL.names.forEach((e=>{const t=ALL[e];r[t.getterName]=this[t.privateName]})),Object.assign(r,this.options_[i]),Object.assign(r,this.options_[s]),Object.assign(r,this.options_[e.toLowerCase()]),this.tag&&(r.tag=this.tag),t&&t.src===this.cache_.src&&this.cache_.currentTime>0&&(r.startTime=this.cache_.currentTime);const a=Tech.getTech(e);if(!a)throw new Error(`No Tech named '${i}' exists! '${i}' should be registered using videojs.registerTech()'`);this.tech_=new a(r),this.tech_.ready(bind_(this,this.handleTechReady_),!0),textTrackConverter.jsonToTextTracks(this.textTracksJson_||[],this.tech_),TECH_EVENTS_RETRIGGER.forEach((e=>{this.on(this.tech_,e,(t=>this[`handleTech${toTitleCase$1(e)}_`](t)))})),Object.keys(TECH_EVENTS_QUEUE).forEach((e=>{this.on(this.tech_,e,(t=>{0===this.tech_.playbackRate()&&this.tech_.seeking()?this.queuedCallbacks_.push({callback:this[`handleTech${TECH_EVENTS_QUEUE[e]}_`].bind(this),event:t}):this[`handleTech${TECH_EVENTS_QUEUE[e]}_`](t)}))})),this.on(this.tech_,"loadstart",(e=>this.handleTechLoadStart_(e))),this.on(this.tech_,"sourceset",(e=>this.handleTechSourceset_(e))),this.on(this.tech_,"waiting",(e=>this.handleTechWaiting_(e))),this.on(this.tech_,"ended",(e=>this.handleTechEnded_(e))),this.on(this.tech_,"seeking",(e=>this.handleTechSeeking_(e))),this.on(this.tech_,"play",(e=>this.handleTechPlay_(e))),this.on(this.tech_,"pause",(e=>this.handleTechPause_(e))),this.on(this.tech_,"durationchange",(e=>this.handleTechDurationChange_(e))),this.on(this.tech_,"fullscreenchange",((e,t)=>this.handleTechFullscreenChange_(e,t))),this.on(this.tech_,"fullscreenerror",((e,t)=>this.handleTechFullscreenError_(e,t))),this.on(this.tech_,"enterpictureinpicture",(e=>this.handleTechEnterPictureInPicture_(e))),this.on(this.tech_,"leavepictureinpicture",(e=>this.handleTechLeavePictureInPicture_(e))),this.on(this.tech_,"error",(e=>this.handleTechError_(e))),this.on(this.tech_,"posterchange",(e=>this.handleTechPosterChange_(e))),this.on(this.tech_,"textdata",(e=>this.handleTechTextData_(e))),this.on(this.tech_,"ratechange",(e=>this.handleTechRateChange_(e))),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls()&&this.addTechControlsListeners_(),this.tech_.el().parentNode===this.el()||"Html5"===i&&this.tag||prependTo(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){ALL.names.forEach((e=>{const t=ALL[e];this[t.privateName]=this[t.getterName]()})),this.textTracksJson_=textTrackConverter.textTracksToJson(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_&&(this.poster_="",this.trigger("posterchange")),this.isPosterFromTech_=!1}tech(e){return void 0===e&&log$1.warn("Using the tech directly can be dangerous. I hope you know what you're doing.\nSee https://github.com/videojs/video.js/issues/2617 for more info.\n"),this.tech_}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(!0===this.autoplay()&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||"string"!=typeof e)return;const t=()=>{const e=this.muted();this.muted(!0);const t=()=>{this.muted(e)};this.playTerminatedQueue_.push(t);const i=this.play();if(isPromise(i))return i.catch((e=>{throw t(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${e||""}`)}))};let i;return"any"!==e||this.muted()?i="muted"!==e||this.muted()?this.play():t():(i=this.play(),isPromise(i)&&(i=i.catch(t))),isPromise(i)?i.then((()=>{this.trigger({type:"autoplay-success",autoplay:e})})).catch((()=>{this.trigger({type:"autoplay-failure",autoplay:e})})):void 0}updateSourceCaches_(e=""){let t=e,i="";"string"!=typeof t&&(t=e.src,i=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!i&&(i=findMimetype(this,t)),this.cache_.source=merge$1({},e,{src:t,type:i});const s=this.cache_.sources.filter((e=>e.src&&e.src===t)),n=[],r=this.$$("source"),a=[];for(let e=0;e<r.length;e++){const i=getAttributes(r[e]);n.push(i),i.src&&i.src===t&&a.push(i.src)}a.length&&!s.length?this.cache_.sources=n:s.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=t}handleTechSourceset_(e){if(!this.changingSrc_){let t=e=>this.updateSourceCaches_(e);const i=this.currentSource().src,s=e.src;i&&!/^blob:/.test(i)&&/^blob:/.test(s)&&(!this.lastSource_||this.lastSource_.tech!==s&&this.lastSource_.player!==i)&&(t=()=>{}),t(s),e.src||this.tech_.any(["sourceset","loadstart"],(e=>{if("sourceset"===e.type)return;const t=this.techGet("currentSrc");this.lastSource_.tech=t,this.updateSourceCaches_(t)}))}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(void 0===e)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&0===this.cache_.lastPlaybackRate&&(this.queuedCallbacks_.forEach((e=>e.callback(e.event))),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),t=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",t))};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){this.controls_&&(void 0!==this.options_&&void 0!==this.options_.userActions&&void 0!==this.options_.userActions.click&&!1===this.options_.userActions.click||(void 0!==this.options_&&void 0!==this.options_.userActions&&"function"==typeof this.options_.userActions.click?this.options_.userActions.click.call(this,e):this.paused()?silencePromise(this.play()):this.pause()))}handleTechDoubleClick_(e){this.controls_&&(Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),(t=>t.contains(e.target)))||void 0!==this.options_&&void 0!==this.options_.userActions&&void 0!==this.options_.userActions.doubleClick&&!1===this.options_.userActions.doubleClick||(void 0!==this.options_&&void 0!==this.options_.userActions&&"function"==typeof this.options_.userActions.doubleClick?this.options_.userActions.doubleClick.call(this,e):this.isFullscreen()?this.exitFullscreen():this.requestFullscreen()))}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){const t=e.target.player;if(t&&t!==this)return;const i=this.el();let s=document[this.fsApi_.fullscreenElement]===i;!s&&i.matches?s=i.matches(":"+this.fsApi_.fullscreen):!s&&i.msMatchesSelector&&(s=i.msMatchesSelector(":"+this.fsApi_.fullscreen)),this.isFullscreen(s)}handleTechFullscreenChange_(e,t){t&&(t.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",(()=>{this.removeClass("vjs-ios-native-fs")}))),this.isFullscreen(t.isFullscreen))}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){const e=this.tech_.error();this.error(e)}handleTechTextData_(){let e=null;arguments.length>1&&(e=arguments[1]),this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,t){this.ready((function(){if(e in allowedSetters)return set(this.middleware_,this.tech_,e,t);if(e in allowedMediators)return mediate(this.middleware_,this.tech_,e,t);try{this.tech_&&this.tech_[e](t)}catch(e){throw log$1(e),e}}),!0)}techGet_(e){if(this.tech_&&this.tech_.isReady_){if(e in allowedGetters)return get(this.middleware_,this.tech_,e);if(e in allowedMediators)return mediate(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){if(void 0===this.tech_[e])throw log$1(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t;if("TypeError"===t.name)throw log$1(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t;throw log$1(t),t}}}play(){return new Promise((e=>{this.play_(e)}))}play_(e=silencePromise){this.playCallbacks_.push(e);const t=Boolean(!this.changingSrc_&&(this.src()||this.currentSrc()));if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!t)return this.waitToPlay_=e=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),void(t||!IS_ANY_SAFARI&&!IS_IOS||this.load());const i=this.techGet_("play");null===i?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(i)}runPlayTerminatedQueue_(){const e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach((function(e){e()}))}runPlayCallbacks_(e){const t=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],t.forEach((function(t){t(e)}))}pause(){this.techCall_("pause")}paused(){return!1!==this.techGet_("paused")}played(){return this.techGet_("played")||createTimeRanges$1(0,0)}scrubbing(e){if(void 0===e)return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){return void 0!==e?(e<0&&(e=0),this.isReady_&&!this.changingSrc_&&this.tech_&&this.tech_.isReady_?(this.techCall_("setCurrentTime",e),void(this.cache_.initTime=0)):(this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),void this.one("canplay",this.boundApplyInitTime_))):(this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime)}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(void 0===e)return void 0!==this.cache_.duration?this.cache_.duration:NaN;(e=parseFloat(e))<0&&(e=1/0),e!==this.cache_.duration&&(this.cache_.duration=e,e===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return e&&e.length||(e=createTimeRanges$1(0,0)),e}bufferedPercent(){return bufferedPercent(this.buffered(),this.duration())}bufferedEnd(){const e=this.buffered(),t=this.duration();let i=e.end(e.length-1);return i>t&&(i=t),i}volume(e){let t;return void 0!==e?(t=Math.max(0,Math.min(1,parseFloat(e))),this.cache_.volume=t,this.techCall_("setVolume",t),void(t>0&&this.lastVolume_(t))):(t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t)}muted(e){if(void 0===e)return this.techGet_("muted")||!1;this.techCall_("setMuted",e)}defaultMuted(e){return void 0!==e?this.techCall_("setDefaultMuted",e):this.techGet_("defaultMuted")||!1}lastVolume_(e){if(void 0===e||0===e)return this.cache_.lastVolume;this.cache_.lastVolume=e}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(void 0!==e){const t=this.isFullscreen_;return this.isFullscreen_=Boolean(e),this.isFullscreen_!==t&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),void this.toggleFullscreenClass_()}return this.isFullscreen_}requestFullscreen(e){this.isInPictureInPicture()&&this.exitPictureInPicture();const t=this;return new Promise(((i,s)=>{function n(){t.off("fullscreenerror",a),t.off("fullscreenchange",r)}function r(){n(),i()}function a(e,t){n(),s(t)}t.one("fullscreenchange",r),t.one("fullscreenerror",a);const o=t.requestFullscreenHelper_(e);o&&(o.then(n,n),o.then(i,s))}))}requestFullscreenHelper_(e){let t;if(this.fsApi_.prefixed||(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},void 0!==e&&(t=e)),this.fsApi_.requestFullscreen){const e=this.el_[this.fsApi_.requestFullscreen](t);return e&&e.then((()=>this.isFullscreen(!0)),(()=>this.isFullscreen(!1))),e}this.tech_.supportsFullScreen()&&1==!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const e=this;return new Promise(((t,i)=>{function s(){e.off("fullscreenerror",r),e.off("fullscreenchange",n)}function n(){s(),t()}function r(e,t){s(),i(t)}e.one("fullscreenchange",n),e.one("fullscreenerror",r);const a=e.exitFullscreenHelper_();a&&(a.then(s,s),a.then(t,i))}))}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=document[this.fsApi_.exitFullscreen]();return e&&silencePromise(e.then((()=>this.isFullscreen(!1)))),e}this.tech_.supportsFullScreen()&&1==!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=document.documentElement.style.overflow,on(document,"keydown",this.boundFullWindowOnEscKey_),document.documentElement.style.overflow="hidden",addClass(document.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){keycode.isEventKey(e,"Esc")&&!0===this.isFullscreen()&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,off(document,"keydown",this.boundFullWindowOnEscKey_),document.documentElement.style.overflow=this.docOrigOverflow,removeClass(document.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(void 0===e)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){return void 0!==e?(this.isInPictureInPicture_=!!e,void this.togglePictureInPictureClass_()):!!this.isInPictureInPicture_}requestPictureInPicture(){if("pictureInPictureEnabled"in document&&!1===this.disablePictureInPicture())return this.techGet_("requestPictureInPicture")}exitPictureInPicture(){if("pictureInPictureEnabled"in document)return document.exitPictureInPicture()}handleKeyDown(e){const{userActions:t}=this.options_;t&&t.hotkeys&&((e=>{const t=e.tagName.toLowerCase();return!!e.isContentEditable||("input"===t?-1===["button","checkbox","hidden","radio","reset","submit"].indexOf(e.type):-1!==["textarea"].indexOf(t))})(this.el_.ownerDocument.activeElement)||("function"==typeof t.hotkeys?t.hotkeys.call(this,e):this.handleHotkeys(e)))}handleHotkeys(e){const t=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:i=(e=>keycode.isEventKey(e,"f")),muteKey:s=(e=>keycode.isEventKey(e,"m")),playPauseKey:n=(e=>keycode.isEventKey(e,"k")||keycode.isEventKey(e,"Space"))}=t;if(i.call(this,e)){e.preventDefault(),e.stopPropagation();const t=Component$1.getComponent("FullscreenToggle");!1!==document[this.fsApi_.fullscreenEnabled]&&t.prototype.handleClick.call(this,e)}else s.call(this,e)?(e.preventDefault(),e.stopPropagation(),Component$1.getComponent("MuteToggle").prototype.handleClick.call(this,e)):n.call(this,e)&&(e.preventDefault(),e.stopPropagation(),Component$1.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(e){let t;for(let i=0,s=this.options_.techOrder;i<s.length;i++){const n=s[i];let r=Tech.getTech(n);if(r||(r=Component$1.getComponent(n)),r){if(r.isSupported()&&(t=r.canPlayType(e),t))return t}else log$1.error(`The "${n}" tech is undefined. Skipped browser support check for that tech.`)}return""}selectSource(e){const t=this.options_.techOrder.map((e=>[e,Tech.getTech(e)])).filter((([e,t])=>t?t.isSupported():(log$1.error(`The "${e}" tech is undefined. Skipped browser support check for that tech.`),!1))),i=function(e,t,i){let s;return e.some((e=>t.some((t=>{if(s=i(e,t),s)return!0})))),s};let s;const n=([e,t],i)=>{if(t.canPlaySource(i,this.options_[e.toLowerCase()]))return{source:i,tech:e}};var r;return s=this.options_.sourceOrder?i(e,t,(r=n,(e,t)=>r(t,e))):i(t,e,n),s||!1}handleSrc_(e,t){if(void 0===e)return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const i=filterSource(e);if(i.length){if(this.changingSrc_=!0,t||(this.cache_.sources=i),this.updateSourceCaches_(i[0]),setSource(this,i[0],((e,s)=>{if(this.middleware_=s,t||(this.cache_.sources=i),this.updateSourceCaches_(e),this.src_(e))return i.length>1?this.handleSrc_(i.slice(1)):(this.changingSrc_=!1,this.setTimeout((function(){this.error({code:4,message:this.options_.notSupportedMessage})}),0),void this.triggerReady());setTech(s,this.tech_)})),i.length>1){const e=()=>{this.error(null),this.handleSrc_(i.slice(1),!0)},t=()=>{this.off("error",e)};this.one("error",e),this.one("playing",t),this.resetRetryOnError_=()=>{this.off("error",e),this.off("playing",t)}}}else this.setTimeout((function(){this.error({code:4,message:this.options_.notSupportedMessage})}),0)}src(e){return this.handleSrc_(e,!1)}src_(e){const t=this.selectSource([e]);return!t||(titleCaseEquals(t.tech,this.techName_)?(this.ready((function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1}),!0),!1):(this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready((()=>{this.changingSrc_=!1})),!1))}load(){this.techCall_("load")}reset(){this.paused()?this.doReset_():silencePromise(this.play().then((()=>this.doReset_())))}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),isEvented(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{durationDisplay:e,remainingTimeDisplay:t}=this.controlBar||{};e&&e.updateContent(),t&&t.updateContent()}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const e=this.currentSource(),t=[];return 0!==Object.keys(e).length&&t.push(e),this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){return void 0!==e?(this.techCall_("setPreload",e),void(this.options_.preload=e)):this.techGet_("preload")}autoplay(e){if(void 0===e)return this.options_.autoplay||!1;let t;"string"==typeof e&&/(any|play|muted)/.test(e)||!0===e&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_("string"==typeof e?e:"play"),t=!1):this.options_.autoplay=!!e,t=void 0===t?this.options_.autoplay:t,this.tech_&&this.techCall_("setAutoplay",t)}playsinline(e){return void 0!==e?(this.techCall_("setPlaysinline",e),this.options_.playsinline=e,this):this.techGet_("playsinline")}loop(e){return void 0!==e?(this.techCall_("setLoop",e),void(this.options_.loop=e)):this.techGet_("loop")}poster(e){if(void 0===e)return this.poster_;e||(e=""),e!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const e=this.tech_.poster()||"";e!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(e){if(void 0===e)return!!this.controls_;e=!!e,this.controls_!==e&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(void 0===e)return!!this.usingNativeControls_;e=!!e,this.usingNativeControls_!==e&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(e){if(void 0===e)return this.error_||null;if(hooks("beforeerror").forEach((t=>{const i=t(this,e);isObject(i)&&!Array.isArray(i)||"string"==typeof i||"number"==typeof i||null===i?e=i:this.log.error("please return a value that MediaError expects in beforeerror hooks")})),this.options_.suppressNotSupportedError&&e&&4===e.code){const t=function(){this.error(e)};return this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],t),void this.one("loadstart",(function(){this.off(["click","touchstart"],t)}))}if(null===e)return this.error_=e,this.removeClass("vjs-error"),void(this.errorDisplay&&this.errorDisplay.close());this.error_=new MediaError(e),this.addClass("vjs-error"),log$1.error(`(CODE:${this.error_.code} ${MediaError.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),hooks("error").forEach((e=>e(this,this.error_)))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(void 0===e)return this.userActive_;if((e=!!e)!==this.userActive_){if(this.userActive_=e,this.userActive_)return this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),void this.trigger("useractive");this.tech_&&this.tech_.one("mousemove",(function(e){e.stopPropagation(),e.preventDefault()})),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let e,t,i;const s=bind_(this,this.reportUserActivity),n=function(t){s(),this.clearInterval(e)};this.on("mousedown",(function(){s(),this.clearInterval(e),e=this.setInterval(s,250)})),this.on("mousemove",(function(e){e.screenX===t&&e.screenY===i||(t=e.screenX,i=e.screenY,s())})),this.on("mouseup",n),this.on("mouseleave",n);const r=this.getChild("controlBar");let a;!r||IS_IOS||IS_ANDROID||(r.on("mouseenter",(function(e){0!==this.player().options_.inactivityTimeout&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0})),r.on("mouseleave",(function(e){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout}))),this.on("keydown",s),this.on("keyup",s),this.setInterval((function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(a);const e=this.options_.inactivityTimeout;e<=0||(a=this.setTimeout((function(){this.userActivity_||this.userActive(!1)}),e))}),250)}playbackRate(e){if(void 0===e)return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1;this.techCall_("setPlaybackRate",e)}defaultPlaybackRate(e){return void 0!==e?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(void 0===e)return!!this.isAudio_;this.isAudio_=!!e}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const e=this.children(),t=this.getChild("ControlBar"),i=t&&t.currentHeight();e.forEach((e=>{e!==t&&e.el_&&!e.hasClass("vjs-hidden")&&(e.hide(),this.audioOnlyCache_.hiddenChildren.push(e))})),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.height(i),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.audioOnlyCache_.hiddenChildren.forEach((e=>e.show())),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if("boolean"!=typeof e||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){const e=[];return this.isInPictureInPicture()&&e.push(this.exitPictureInPicture()),this.isFullscreen()&&e.push(this.exitFullscreen()),this.audioPosterMode()&&e.push(this.audioPosterMode(!1)),Promise.all(e).then((()=>this.enableAudioOnlyUI_()))}return Promise.resolve().then((()=>this.disableAudioOnlyUI_()))}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return"boolean"!=typeof e||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e,e?this.audioOnlyMode()?this.audioOnlyMode(!1).then((()=>{this.enablePosterModeUI_()})):Promise.resolve().then((()=>{this.enablePosterModeUI_()})):Promise.resolve().then((()=>{this.disablePosterModeUI_()})))}addTextTrack(e,t,i){if(this.tech_)return this.tech_.addTextTrack(e,t,i)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let{track:t}=e;if(t||(t=e),this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(void 0===e)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),isEvented(this)&&this.trigger("languagechange"))}languages(){return merge$1(Player.prototype.options_.languages,this.languages_)}toJSON(){const e=merge$1(this.options_),t=e.tracks;e.tracks=[];for(let i=0;i<t.length;i++){let s=t[i];s=merge$1(s),s.player=void 0,e.tracks[i]=s}return e}createModal(e,t){(t=t||{}).content=e||"";const i=new ModalDialog(this,t);return this.addChild(i),i.on("dispose",(()=>{this.removeChild(i)})),i.open(),i}updateCurrentBreakpoint_(){if(!this.responsive())return;const e=this.currentBreakpoint(),t=this.currentWidth();for(let i=0;i<BREAKPOINT_ORDER.length;i++){const s=BREAKPOINT_ORDER[i];if(t<=this.breakpoints_[s]){if(e===s)return;e&&this.removeClass(BREAKPOINT_CLASSES[e]),this.addClass(BREAKPOINT_CLASSES[s]),this.breakpoint_=s;break}}}removeCurrentBreakpoint_(){const e=this.currentBreakpointClass();this.breakpoint_="",e&&this.removeClass(e)}breakpoints(e){return void 0===e||(this.breakpoint_="",this.breakpoints_=Object.assign({},DEFAULT_BREAKPOINTS,e),this.updateCurrentBreakpoint_()),Object.assign(this.breakpoints_)}responsive(e){return void 0===e?this.responsive_:(e=Boolean(e))!==this.responsive_?(this.responsive_=e,e?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),e):void 0}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return BREAKPOINT_CLASSES[this.breakpoint_]||""}loadMedia(e,t){if(!e||"object"!=typeof e)return;this.reset(),this.cache_.media=merge$1(e);const{artist:i,artwork:s,description:n,poster:r,src:a,textTracks:o,title:l}=this.cache_.media;!s&&r&&(this.cache_.media.artwork=[{src:r,type:getMimetype(r)}]),a&&this.src(a),r&&this.poster(r),Array.isArray(o)&&o.forEach((e=>this.addRemoteTextTrack(e,!1))),this.titleBar&&this.titleBar.update({title:l,description:n||i||""}),this.ready(t)}getMedia(){if(!this.cache_.media){const e=this.poster(),t={src:this.currentSources(),textTracks:Array.prototype.map.call(this.remoteTextTracks(),(e=>({kind:e.kind,label:e.label,language:e.language,src:e.src})))};return e&&(t.poster=e,t.artwork=[{src:t.poster,type:getMimetype(t.poster)}]),t}return merge$1(this.cache_.media)}static getTagSettings(e){const t={sources:[],tracks:[]},i=getAttributes(e),s=i["data-setup"];if(hasClass(e,"vjs-fill")&&(i.fill=!0),hasClass(e,"vjs-fluid")&&(i.fluid=!0),null!==s){const[e,t]=safeParseTuple(s||"{}");e&&log$1.error(e),Object.assign(i,t)}if(Object.assign(t,i),e.hasChildNodes()){const i=e.childNodes;for(let e=0,s=i.length;e<s;e++){const s=i[e],n=s.nodeName.toLowerCase();"source"===n?t.sources.push(getAttributes(s)):"track"===n&&t.tracks.push(getAttributes(s))}}return t}debug(e){if(void 0===e)return this.debugEnabled_;e?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(e){if(void 0===e)return this.cache_.playbackRates;Array.isArray(e)&&e.every((e=>"number"==typeof e))&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}}ALL.names.forEach((function(e){const t=ALL[e];Player.prototype[t.getterName]=function(){return this.tech_?this.tech_[t.getterName]():(this[t.privateName]=this[t.privateName]||new t.ListClass,this[t.privateName])}})),Player.prototype.crossorigin=Player.prototype.crossOrigin,Player.players={};const navigator=window$1.navigator;Player.prototype.options_={techOrder:Tech.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:navigator&&(navigator.languages&&navigator.languages[0]||navigator.userLanguage||navigator.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1},["ended","seeking","seekable","networkState","readyState"].forEach((function(e){Player.prototype[e]=function(){return this.techGet_(e)}})),TECH_EVENTS_RETRIGGER.forEach((function(e){Player.prototype[`handleTech${toTitleCase$1(e)}_`]=function(){return this.trigger(e)}})),Component$1.registerComponent("Player",Player);const BASE_PLUGIN_NAME="plugin",PLUGIN_CACHE_KEY="activePlugins_",pluginStorage={},pluginExists=e=>pluginStorage.hasOwnProperty(e),getPlugin=e=>pluginExists(e)?pluginStorage[e]:void 0,markPluginAsActive=(e,t)=>{e.activePlugins_=e.activePlugins_||{},e.activePlugins_[t]=!0},triggerSetupEvent=(e,t,i)=>{const s=(i?"before":"")+"pluginsetup";e.trigger(s,t),e.trigger(s+":"+t.name,t)},createBasicPlugin=function(e,t){const i=function(){triggerSetupEvent(this,{name:e,plugin:t,instance:null},!0);const i=t.apply(this,arguments);return markPluginAsActive(this,e),triggerSetupEvent(this,{name:e,plugin:t,instance:i}),i};return Object.keys(t).forEach((function(e){i[e]=t[e]})),i},createPluginFactory=(e,t)=>(t.prototype.name=e,function(...i){triggerSetupEvent(this,{name:e,plugin:t,instance:null},!0);const s=new t(...[this,...i]);return this[e]=()=>s,triggerSetupEvent(this,s.getEventHash()),s});class Plugin{constructor(e){if(this.constructor===Plugin)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),evented(this),delete this.trigger,stateful(this,this.constructor.defaultState),markPluginAsActive(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return trigger(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){const{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t.activePlugins_[e]=!1,this.player=this.state=null,t[e]=createPluginFactory(e,pluginStorage[e])}static isBasic(e){const t="string"==typeof e?getPlugin(e):e;return"function"==typeof t&&!Plugin.prototype.isPrototypeOf(t.prototype)}static registerPlugin(e,t){if("string"!=typeof e)throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(pluginExists(e))log$1.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(Player.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if("function"!=typeof t)throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);return pluginStorage[e]=t,"plugin"!==e&&(Plugin.isBasic(t)?Player.prototype[e]=createBasicPlugin(e,t):Player.prototype[e]=createPluginFactory(e,t)),t}static deregisterPlugin(e){if("plugin"===e)throw new Error("Cannot de-register base plugin.");pluginExists(e)&&(delete pluginStorage[e],delete Player.prototype[e])}static getPlugins(e=Object.keys(pluginStorage)){let t;return e.forEach((e=>{const i=getPlugin(e);i&&(t=t||{},t[e]=i)})),t}static getPluginVersion(e){const t=getPlugin(e);return t&&t.VERSION||""}}function deprecate(e,t){let i=!1;return function(...s){return i||log$1.warn(e),i=!0,t.apply(this,s)}}function deprecateForMajor(e,t,i,s){return deprecate(`${t} is deprecated and will be removed in ${e}.0; please use ${i} instead.`,s)}Plugin.getPlugin=getPlugin,Plugin.BASE_PLUGIN_NAME="plugin",Plugin.registerPlugin("plugin",Plugin),Player.prototype.usingPlugin=function(e){return!!this.activePlugins_&&!0===this.activePlugins_[e]},Player.prototype.hasPlugin=function(e){return!!pluginExists(e)};const normalizeId=e=>0===e.indexOf("#")?e.slice(1):e;function videojs(e,t,i){let s=videojs.getPlayer(e);if(s)return t&&log$1.warn(`Player "${e}" is already initialised. Options will not be applied.`),i&&s.ready(i),s;const n="string"==typeof e?$("#"+normalizeId(e)):e;if(!isEl(n))throw new TypeError("The element or ID supplied is not valid. (videojs)");n.ownerDocument.defaultView&&n.ownerDocument.body.contains(n)||log$1.warn("The element supplied is not included in the DOM"),!0===(t=t||{}).restoreEl&&(t.restoreEl=(n.parentNode&&n.parentNode.hasAttribute("data-vjs-player")?n.parentNode:n).cloneNode(!0)),hooks("beforesetup").forEach((e=>{const i=e(n,merge$1(t));isObject(i)&&!Array.isArray(i)?t=merge$1(t,i):log$1.error("please return an object in beforesetup hooks")}));const r=Component$1.getComponent("Player");return s=new r(n,t,i),hooks("setup").forEach((e=>e(s))),s}if(videojs.hooks_=hooks_,videojs.hooks=hooks,videojs.hook=hook,videojs.hookOnce=hookOnce,videojs.removeHook=removeHook,!0!==window$1.VIDEOJS_NO_DYNAMIC_STYLE&&isReal()){let e=$(".vjs-styles-defaults");if(!e){e=createStyleElement("vjs-styles-defaults");const t=$("head");t&&t.insertBefore(e,t.firstChild),setTextContent(e,"\n .video-js {\n width: 300px;\n height: 150px;\n }\n\n .vjs-fluid:not(.vjs-audio-only-mode) {\n padding-top: 56.25%\n }\n ")}}autoSetupTimeout(1,videojs),videojs.VERSION=version$6,videojs.options=Player.prototype.options_,videojs.getPlayers=()=>Player.players,videojs.getPlayer=e=>{const t=Player.players;let i;if("string"==typeof e){const s=normalizeId(e),n=t[s];if(n)return n;i=$("#"+s)}else i=e;if(isEl(i)){const{player:e,playerId:s}=i;if(e||t[s])return e||t[s]}},videojs.getAllPlayers=()=>Object.keys(Player.players).map((e=>Player.players[e])).filter(Boolean),videojs.players=Player.players,videojs.getComponent=Component$1.getComponent,videojs.registerComponent=(e,t)=>{Tech.isTech(t)&&log$1.warn(`The ${e} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),Component$1.registerComponent.call(Component$1,e,t)},videojs.getTech=Tech.getTech,videojs.registerTech=Tech.registerTech,videojs.use=use,Object.defineProperty(videojs,"middleware",{value:{},writeable:!1,enumerable:!0}),Object.defineProperty(videojs.middleware,"TERMINATOR",{value:TERMINATOR,writeable:!1,enumerable:!0}),videojs.browser=browser,videojs.obj=Obj,videojs.mergeOptions=deprecateForMajor(9,"videojs.mergeOptions","videojs.obj.merge",merge$1),videojs.defineLazyProperty=deprecateForMajor(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",defineLazyProperty),videojs.bind=deprecateForMajor(9,"videojs.bind","native Function.prototype.bind",bind_),videojs.registerPlugin=Plugin.registerPlugin,videojs.deregisterPlugin=Plugin.deregisterPlugin,videojs.plugin=(e,t)=>(log$1.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),Plugin.registerPlugin(e,t)),videojs.getPlugins=Plugin.getPlugins,videojs.getPlugin=Plugin.getPlugin,videojs.getPluginVersion=Plugin.getPluginVersion,videojs.addLanguage=function(e,t){return e=(""+e).toLowerCase(),videojs.options.languages=merge$1(videojs.options.languages,{[e]:t}),videojs.options.languages[e]},videojs.log=log$1,videojs.createLogger=createLogger,videojs.time=Time,videojs.createTimeRange=deprecateForMajor(9,"videojs.createTimeRange","videojs.time.createTimeRanges",createTimeRanges$1),videojs.createTimeRanges=deprecateForMajor(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",createTimeRanges$1),videojs.formatTime=deprecateForMajor(9,"videojs.formatTime","videojs.time.formatTime",formatTime),videojs.setFormatTime=deprecateForMajor(9,"videojs.setFormatTime","videojs.time.setFormatTime",setFormatTime),videojs.resetFormatTime=deprecateForMajor(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",resetFormatTime),videojs.parseUrl=deprecateForMajor(9,"videojs.parseUrl","videojs.url.parseUrl",parseUrl),videojs.isCrossOrigin=deprecateForMajor(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",isCrossOrigin),videojs.EventTarget=EventTarget$2,videojs.any=any,videojs.on=on,videojs.one=one,videojs.off=off,videojs.trigger=trigger,videojs.xhr=XHR,videojs.TextTrack=TextTrack,videojs.AudioTrack=AudioTrack,videojs.VideoTrack=VideoTrack,["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach((e=>{videojs[e]=function(){return log$1.warn(`videojs.${e}() is deprecated; use videojs.dom.${e}() instead`),Dom[e].apply(null,arguments)}})),videojs.computedStyle=deprecateForMajor(9,"videojs.computedStyle","videojs.dom.computedStyle",computedStyle),videojs.dom=Dom,videojs.fn=Fn,videojs.num=Num,videojs.str=Str,videojs.url=Url;class QualityLevel{constructor(e){let t=this;return t.id=e.id,t.label=t.id,t.width=e.width,t.height=e.height,t.bitrate=e.bandwidth,t.frameRate=e.frameRate,t.enabled_=e.enabled,Object.defineProperty(t,"enabled",{get:()=>t.enabled_(),set(e){t.enabled_(e)}}),t}}class QualityLevelList extends videojs.EventTarget{constructor(){super();let e=this;return e.levels_=[],e.selectedIndex_=-1,Object.defineProperty(e,"selectedIndex",{get:()=>e.selectedIndex_}),Object.defineProperty(e,"length",{get:()=>e.levels_.length}),e}addQualityLevel(e){let t=this.getQualityLevelById(e.id);if(t)return t;const i=this.levels_.length;return t=new QualityLevel(e),""+i in this||Object.defineProperty(this,i,{get(){return this.levels_[i]}}),this.levels_.push(t),this.trigger({qualityLevel:t,type:"addqualitylevel"}),t}removeQualityLevel(e){let t=null;for(let i=0,s=this.length;i<s;i++)if(this[i]===e){t=this.levels_.splice(i,1)[0],this.selectedIndex_===i?this.selectedIndex_=-1:this.selectedIndex_>i&&this.selectedIndex_--;break}return t&&this.trigger({qualityLevel:e,type:"removequalitylevel"}),t}getQualityLevelById(e){for(let t=0,i=this.length;t<i;t++){const i=this[t];if(i.id===e)return i}return null}dispose(){this.selectedIndex_=-1,this.levels_.length=0}}QualityLevelList.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(const e in QualityLevelList.prototype.allowedEvents_)QualityLevelList.prototype["on"+e]=null;var version$5="3.0.0";const registerPlugin=videojs.registerPlugin||videojs.plugin,initPlugin$1=function(e,t){const i=e.qualityLevels,s=new QualityLevelList,n=function(){s.dispose(),e.qualityLevels=i,e.off("dispose",n)};return e.on("dispose",n),e.qualityLevels=()=>s,e.qualityLevels.VERSION=version$5,s},qualityLevels=function(e){return initPlugin$1(this,videojs.mergeOptions({},e))};registerPlugin("qualityLevels",qualityLevels),qualityLevels.VERSION=version$5;const resolveUrl=_resolveUrl,resolveManifestRedirect=(e,t)=>t&&t.responseURL&&e!==t.responseURL?t.responseURL:e,logger=e=>videojs.log.debug?videojs.log.debug.bind(videojs,"VHS:",`${e} >`):function(){};function merge(...e){const t=videojs.obj||videojs;return(t.merge||t.mergeOptions).apply(t,e)}function createTimeRanges(...e){const t=videojs.time||videojs;return(t.createTimeRanges||t.createTimeRanges).apply(t,e)}const TIME_FUDGE_FACTOR=1/30,SAFE_TIME_DELTA=.1,filterRanges=function(e,t){const i=[];let s;if(e&&e.length)for(s=0;s<e.length;s++)t(e.start(s),e.end(s))&&i.push([e.start(s),e.end(s)]);return createTimeRanges(i)},findRange=function(e,t){return filterRanges(e,(function(e,i){return e-.1<=t&&i+.1>=t}))},findNextRange=function(e,t){return filterRanges(e,(function(e){return e-TIME_FUDGE_FACTOR>=t}))},findGaps=function(e){if(e.length<2)return createTimeRanges();const t=[];for(let i=1;i<e.length;i++){const s=e.end(i-1),n=e.start(i);t.push([s,n])}return createTimeRanges(t)},bufferIntersection=function(e,t){let i=null,s=null,n=0;const r=[],a=[];if(!(e&&e.length&&t&&t.length))return createTimeRanges();let o=e.length;for(;o--;)r.push({time:e.start(o),type:"start"}),r.push({time:e.end(o),type:"end"});for(o=t.length;o--;)r.push({time:t.start(o),type:"start"}),r.push({time:t.end(o),type:"end"});for(r.sort((function(e,t){return e.time-t.time})),o=0;o<r.length;o++)"start"===r[o].type?(n++,2===n&&(i=r[o].time)):"end"===r[o].type&&(n--,1===n&&(s=r[o].time)),null!==i&&null!==s&&(a.push([i,s]),i=null,s=null);return createTimeRanges(a)},printableRange=e=>{const t=[];if(!e||!e.length)return"";for(let i=0;i<e.length;i++)t.push(e.start(i)+" => "+e.end(i));return t.join(", ")},timeUntilRebuffer=function(e,t,i=1){return((e.length?e.end(e.length-1):0)-t)/i},timeRangesToArray=e=>{const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t},isRangeDifferent=function(e,t){if(e===t)return!1;if(!e&&t||!t&&e)return!0;if(e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(e.start(i)!==t.start(i)||e.end(i)!==t.end(i))return!0;return!1},lastBufferedEnd=function(e){if(e&&e.length&&e.end)return e.end(e.length-1)},timeAheadOf=function(e,t){let i=0;if(!e||!e.length)return i;for(let s=0;s<e.length;s++){const n=e.start(s),r=e.end(s);t>r||(i+=t>n&&t<=r?r-t:r-n)}return i},segmentDurationWithParts=(e,t)=>{if(!t.preload)return t.duration;let i=0;return(t.parts||[]).forEach((function(e){i+=e.duration})),(t.preloadHints||[]).forEach((function(t){"PART"===t.type&&(i+=e.partTargetDuration)})),i},getPartsAndSegments=e=>(e.segments||[]).reduce(((e,t,i)=>(t.parts?t.parts.forEach((function(s,n){e.push({duration:s.duration,segmentIndex:i,partIndex:n,part:s,segment:t})})):e.push({duration:t.duration,segmentIndex:i,partIndex:null,segment:t,part:null}),e)),[]),getLastParts=e=>{const t=e.segments&&e.segments.length&&e.segments[e.segments.length-1];return t&&t.parts||[]},getKnownPartCount=({preloadSegment:e})=>{if(!e)return;const{parts:t,preloadHints:i}=e;let s=(i||[]).reduce(((e,t)=>e+("PART"===t.type?1:0)),0);return s+=t&&t.length?t.length:0,s},liveEdgeDelay=(e,t)=>{if(t.endList)return 0;if(e&&e.suggestedPresentationDelay)return e.suggestedPresentationDelay;const i=getLastParts(t).length>0;return i&&t.serverControl&&t.serverControl.partHoldBack?t.serverControl.partHoldBack:i&&t.partTargetDuration?3*t.partTargetDuration:t.serverControl&&t.serverControl.holdBack?t.serverControl.holdBack:t.targetDuration?3*t.targetDuration:0},backwardDuration=function(e,t){let i=0,s=t-e.mediaSequence,n=e.segments[s];if(n){if(void 0!==n.start)return{result:n.start,precise:!0};if(void 0!==n.end)return{result:n.end-n.duration,precise:!0}}for(;s--;){if(n=e.segments[s],void 0!==n.end)return{result:i+n.end,precise:!0};if(i+=segmentDurationWithParts(e,n),void 0!==n.start)return{result:i+n.start,precise:!0}}return{result:i,precise:!1}},forwardDuration=function(e,t){let i,s=0,n=t-e.mediaSequence;for(;n<e.segments.length;n++){if(i=e.segments[n],void 0!==i.start)return{result:i.start-s,precise:!0};if(s+=segmentDurationWithParts(e,i),void 0!==i.end)return{result:i.end-s,precise:!0}}return{result:-1,precise:!1}},intervalDuration=function(e,t,i){if(void 0===t&&(t=e.mediaSequence+e.segments.length),t<e.mediaSequence)return 0;const s=backwardDuration(e,t);if(s.precise)return s.result;const n=forwardDuration(e,t);return n.precise?n.result:s.result+i},duration=function(e,t,i){if(!e)return 0;if("number"!=typeof i&&(i=0),void 0===t){if(e.totalDuration)return e.totalDuration;if(!e.endList)return window$1.Infinity}return intervalDuration(e,t,i)},sumDurations=function({defaultDuration:e,durationList:t,startIndex:i,endIndex:s}){let n=0;if(i>s&&([i,s]=[s,i]),i<0){for(let t=i;t<Math.min(0,s);t++)n+=e;i=0}for(let e=i;e<s;e++)n+=t[e].duration;return n},playlistEnd=function(e,t,i,s){if(!e||!e.segments)return null;if(e.endList)return duration(e);if(null===t)return null;t=t||0;let n=intervalDuration(e,e.mediaSequence+e.segments.length,t);return i&&(n-=s="number"==typeof s?s:liveEdgeDelay(null,e)),Math.max(0,n)},seekable=function(e,t,i){const s=t||0,n=playlistEnd(e,t,!0,i);return null===n?createTimeRanges():createTimeRanges(s,n)},getMediaInfoForTime=function({playlist:e,currentTime:t,startingSegmentIndex:i,startingPartIndex:s,startTime:n,exactManifestTimings:r}){let a=t-n;const o=getPartsAndSegments(e);let l=0;for(let e=0;e<o.length;e++){const t=o[e];if(i===t.segmentIndex&&("number"!=typeof s||"number"!=typeof t.partIndex||s===t.partIndex)){l=e;break}}if(a<0){if(l>0)for(let t=l-1;t>=0;t--){const i=o[t];if(a+=i.duration,r){if(a<0)continue}else if(a+TIME_FUDGE_FACTOR<=0)continue;return{partIndex:i.partIndex,segmentIndex:i.segmentIndex,startTime:n-sumDurations({defaultDuration:e.targetDuration,durationList:o,startIndex:l,endIndex:t})}}return{partIndex:o[0]&&o[0].partIndex||null,segmentIndex:o[0]&&o[0].segmentIndex||0,startTime:t}}if(l<0){for(let i=l;i<0;i++)if(a-=e.targetDuration,a<0)return{partIndex:o[0]&&o[0].partIndex||null,segmentIndex:o[0]&&o[0].segmentIndex||0,startTime:t};l=0}for(let t=l;t<o.length;t++){const i=o[t];if(a-=i.duration,r){if(a>0)continue}else if(a-TIME_FUDGE_FACTOR>=0)continue;return{partIndex:i.partIndex,segmentIndex:i.segmentIndex,startTime:n+sumDurations({defaultDuration:e.targetDuration,durationList:o,startIndex:l,endIndex:t})}}return{segmentIndex:o[o.length-1].segmentIndex,partIndex:o[o.length-1].partIndex,startTime:t}},isExcluded=function(e){return e.excludeUntil&&e.excludeUntil>Date.now()},isIncompatible=function(e){return e.excludeUntil&&e.excludeUntil===1/0},isEnabled=function(e){const t=isExcluded(e);return!e.disabled&&!t},isDisabled=function(e){return e.disabled},isAes=function(e){for(let t=0;t<e.segments.length;t++)if(e.segments[t].key)return!0;return!1},hasAttribute=function(e,t){return t.attributes&&t.attributes[e]},estimateSegmentRequestTime=function(e,t,i,s=0){return hasAttribute("BANDWIDTH",i)?(e*i.attributes.BANDWIDTH-8*s)/t:NaN},isLowestEnabledRendition=(e,t)=>{if(1===e.playlists.length)return!0;const i=t.attributes.BANDWIDTH||Number.MAX_VALUE;return 0===e.playlists.filter((e=>!!isEnabled(e)&&(e.attributes.BANDWIDTH||0)<i)).length},playlistMatch=(e,t)=>!(!e&&!t||!e&&t||e&&!t||e!==t&&(!e.id||!t.id||e.id!==t.id)&&(!e.resolvedUri||!t.resolvedUri||e.resolvedUri!==t.resolvedUri)&&(!e.uri||!t.uri||e.uri!==t.uri)),someAudioVariant=function(e,t){const i=e&&e.mediaGroups&&e.mediaGroups.AUDIO||{};let s=!1;for(const e in i){for(const n in i[e])if(s=t(i[e][n]),s)break;if(s)break}return!!s},isAudioOnly=e=>{if(!e||!e.playlists||!e.playlists.length)return someAudioVariant(e,(e=>e.playlists&&e.playlists.length||e.uri));for(let t=0;t<e.playlists.length;t++){const i=e.playlists[t],s=i.attributes&&i.attributes.CODECS;if((!s||!s.split(",").every((e=>isAudioCodec(e))))&&!someAudioVariant(e,(e=>playlistMatch(i,e))))return!1}return!0};var Playlist={liveEdgeDelay:liveEdgeDelay,duration:duration,seekable:seekable,getMediaInfoForTime:getMediaInfoForTime,isEnabled:isEnabled,isDisabled:isDisabled,isExcluded:isExcluded,isIncompatible:isIncompatible,playlistEnd:playlistEnd,isAes:isAes,hasAttribute:hasAttribute,estimateSegmentRequestTime:estimateSegmentRequestTime,isLowestEnabledRendition:isLowestEnabledRendition,isAudioOnly:isAudioOnly,playlistMatch:playlistMatch,segmentDurationWithParts:segmentDurationWithParts};const{log:log}=videojs,createPlaylistID=(e,t)=>`${e}-${t}`,groupID=(e,t,i)=>`placeholder-uri-${e}-${t}-${i}`,parseManifest=({onwarn:e,oninfo:t,manifestString:i,customTagParsers:s=[],customTagMappers:n=[],llhls:r})=>{const a=new Parser;e&&a.on("warn",e),t&&a.on("info",t),s.forEach((e=>a.addParser(e))),n.forEach((e=>a.addTagMapper(e))),a.push(i),a.end();const o=a.manifest;if(r||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach((function(e){o.hasOwnProperty(e)&&delete o[e]})),o.segments&&o.segments.forEach((function(e){["parts","preloadHints"].forEach((function(t){e.hasOwnProperty(t)&&delete e[t]}))}))),!o.targetDuration){let t=10;o.segments&&o.segments.length&&(t=o.segments.reduce(((e,t)=>Math.max(e,t.duration)),0)),e&&e(`manifest has no targetDuration defaulting to ${t}`),o.targetDuration=t}const l=getLastParts(o);if(l.length&&!o.partTargetDuration){const t=l.reduce(((e,t)=>Math.max(e,t.duration)),0);e&&(e(`manifest has no partTargetDuration defaulting to ${t}`),log.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),o.partTargetDuration=t}return o},forEachMediaGroup=(e,t)=>{e.mediaGroups&&["AUDIO","SUBTITLES"].forEach((i=>{if(e.mediaGroups[i])for(const s in e.mediaGroups[i])for(const n in e.mediaGroups[i][s]){const r=e.mediaGroups[i][s][n];t(r,i,s,n)}}))},setupMediaPlaylist=({playlist:e,uri:t,id:i})=>{e.id=i,e.playlistErrors_=0,t&&(e.uri=t),e.attributes=e.attributes||{}},setupMediaPlaylists=e=>{let t=e.playlists.length;for(;t--;){const i=e.playlists[t];setupMediaPlaylist({playlist:i,id:createPlaylistID(t,i.uri)}),i.resolvedUri=resolveUrl(e.uri,i.uri),e.playlists[i.id]=i,e.playlists[i.uri]=i,i.attributes.BANDWIDTH||log.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},resolveMediaGroupUris=e=>{forEachMediaGroup(e,(t=>{t.uri&&(t.resolvedUri=resolveUrl(e.uri,t.uri))}))},mainForMedia=(e,t)=>{const i=createPlaylistID(0,t),s={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:window$1.location.href,resolvedUri:window$1.location.href,playlists:[{uri:t,id:i,resolvedUri:t,attributes:{}}]};return s.playlists[i]=s.playlists[0],s.playlists[t]=s.playlists[0],s},addPropertiesToMain=(e,t,i=groupID)=>{e.uri=t;for(let t=0;t<e.playlists.length;t++)if(!e.playlists[t].uri){const i=`placeholder-uri-${t}`;e.playlists[t].uri=i}const s=isAudioOnly(e);forEachMediaGroup(e,((t,n,r,a)=>{if(!t.playlists||!t.playlists.length){if(s&&"AUDIO"===n&&!t.uri)for(let t=0;t<e.playlists.length;t++){const i=e.playlists[t];if(i.attributes&&i.attributes.AUDIO&&i.attributes.AUDIO===r)return}t.playlists=[_extends({},t)]}t.playlists.forEach((function(t,s){const o=i(n,r,a,t),l=createPlaylistID(s,o);t.uri?t.resolvedUri=t.resolvedUri||resolveUrl(e.uri,t.uri):(t.uri=0===s?o:l,t.resolvedUri=t.uri),t.id=t.id||l,t.attributes=t.attributes||{},e.playlists[t.id]=t,e.playlists[t.uri]=t}))})),setupMediaPlaylists(e),resolveMediaGroupUris(e)},{EventTarget:EventTarget$1}=videojs,addLLHLSQueryDirectives=(e,t)=>{if(t.endList||!t.serverControl)return e;const i={};if(t.serverControl.canBlockReload){const{preloadSegment:e}=t;let s=t.mediaSequence+t.segments.length;if(e){const n=e.parts||[],r=getKnownPartCount(t)-1;r>-1&&r!==n.length-1&&(i._HLS_part=r),(r>-1||n.length)&&s--}i._HLS_msn=s}if(t.serverControl&&t.serverControl.canSkipUntil&&(i._HLS_skip=t.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(i).length){const t=new window$1.URL(e);["_HLS_skip","_HLS_msn","_HLS_part"].forEach((function(e){i.hasOwnProperty(e)&&t.searchParams.set(e,i[e])})),e=t.toString()}return e},updateSegment=(e,t)=>{if(!e)return t;const i=merge(e,t);if(e.preloadHints&&!t.preloadHints&&delete i.preloadHints,e.parts&&!t.parts)delete i.parts;else if(e.parts&&t.parts)for(let s=0;s<t.parts.length;s++)e.parts&&e.parts[s]&&(i.parts[s]=merge(e.parts[s],t.parts[s]));return!e.skipped&&t.skipped&&(i.skipped=!1),e.preload&&!t.preload&&(i.preload=!1),i},updateSegments=(e,t,i)=>{const s=e.slice(),n=t.slice();i=i||0;const r=[];let a;for(let e=0;e<n.length;e++){const t=s[e+i],o=n[e];t?(a=t.map||a,r.push(updateSegment(t,o))):(a&&!o.map&&(o.map=a),r.push(o))}return r},resolveSegmentUris=(e,t)=>{!e.resolvedUri&&e.uri&&(e.resolvedUri=resolveUrl(t,e.uri)),e.key&&!e.key.resolvedUri&&(e.key.resolvedUri=resolveUrl(t,e.key.uri)),e.map&&!e.map.resolvedUri&&(e.map.resolvedUri=resolveUrl(t,e.map.uri)),e.map&&e.map.key&&!e.map.key.resolvedUri&&(e.map.key.resolvedUri=resolveUrl(t,e.map.key.uri)),e.parts&&e.parts.length&&e.parts.forEach((e=>{e.resolvedUri||(e.resolvedUri=resolveUrl(t,e.uri))})),e.preloadHints&&e.preloadHints.length&&e.preloadHints.forEach((e=>{e.resolvedUri||(e.resolvedUri=resolveUrl(t,e.uri))}))},getAllSegments=function(e){const t=e.segments||[],i=e.preloadSegment;if(i&&i.parts&&i.parts.length){if(i.preloadHints)for(let e=0;e<i.preloadHints.length;e++)if("MAP"===i.preloadHints[e].type)return t;i.duration=e.targetDuration,i.preload=!0,t.push(i)}return t},isPlaylistUnchanged=(e,t)=>e===t||e.segments&&t.segments&&e.segments.length===t.segments.length&&e.endList===t.endList&&e.mediaSequence===t.mediaSequence&&e.preloadSegment===t.preloadSegment,updateMain$1=(e,t,i=isPlaylistUnchanged)=>{const s=merge(e,{}),n=s.playlists[t.id];if(!n)return null;if(i(n,t))return null;t.segments=getAllSegments(t);const r=merge(n,t);if(r.preloadSegment&&!t.preloadSegment&&delete r.preloadSegment,n.segments){if(t.skip){t.segments=t.segments||[];for(let e=0;e<t.skip.skippedSegments;e++)t.segments.unshift({skipped:!0})}r.segments=updateSegments(n.segments,t.segments,t.mediaSequence-n.mediaSequence)}r.segments.forEach((e=>{resolveSegmentUris(e,r.resolvedUri)}));for(let e=0;e<s.playlists.length;e++)s.playlists[e].id===t.id&&(s.playlists[e]=r);return s.playlists[t.id]=r,s.playlists[t.uri]=r,forEachMediaGroup(e,((e,i,s,n)=>{if(e.playlists)for(let i=0;i<e.playlists.length;i++)t.id===e.playlists[i].id&&(e.playlists[i]=r)})),s},refreshDelay=(e,t)=>{const i=e.segments||[],s=i[i.length-1],n=s&&s.parts&&s.parts[s.parts.length-1],r=n&&n.duration||s&&s.duration;return t&&r?1e3*r:500*(e.partTargetDuration||e.targetDuration||10)};class PlaylistLoader extends EventTarget$1{constructor(e,t,i={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=logger("PlaylistLoader");const{withCredentials:s=!1}=i;this.src=e,this.vhs_=t,this.withCredentials=s;const n=t.options_;this.customTagParsers=n&&n.customTagParsers||[],this.customTagMappers=n&&n.customTagMappers||[],this.llhls=n&&n.llhls,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_)}handleMediaupdatetimeout_(){if("HAVE_METADATA"!==this.state)return;const e=this.media();let t=resolveUrl(this.main.uri,e.uri);this.llhls&&(t=addLLHLSQueryDirectives(t,e)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:t,withCredentials:this.withCredentials},((e,t)=>{if(this.request)return e?this.playlistRequestError(this.request,this.media(),"HAVE_METADATA"):void this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})}))}playlistRequestError(e,t,i){const{uri:s,id:n}=t;this.request=null,i&&(this.state=i),this.error={playlist:this.main.playlists[n],status:e.status,message:`HLS playlist request error at URL: ${s}.`,responseText:e.responseText,code:e.status>=500?4:2},this.trigger("error")}parseManifest_({url:e,manifestString:t}){return parseManifest({onwarn:({message:t})=>this.logger_(`m3u8-parser warn for ${e}: ${t}`),oninfo:({message:t})=>this.logger_(`m3u8-parser info for ${e}: ${t}`),manifestString:t,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls})}haveMetadata({playlistString:e,playlistObject:t,url:i,id:s}){this.request=null,this.state="HAVE_METADATA";const n=t||this.parseManifest_({url:i,manifestString:e});n.lastRequest=Date.now(),setupMediaPlaylist({playlist:n,uri:i,id:s});const r=updateMain$1(this.main,n);this.targetDuration=n.partTargetDuration||n.targetDuration,this.pendingMedia_=null,r?(this.main=r,this.media_=this.main.playlists[s]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(refreshDelay(this.media(),!!r)),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),window$1.clearTimeout(this.mediaUpdateTimeout),window$1.clearTimeout(this.finalRenditionTimeout),this.off()}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,t){if(!e)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);if("string"==typeof e){if(!this.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(window$1.clearTimeout(this.finalRenditionTimeout),t){const t=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;return void(this.finalRenditionTimeout=window$1.setTimeout(this.media.bind(this,e,!1),t))}const i=this.state,s=!this.media_||e.id!==this.media_.id,n=this.main.playlists[e.id];if(n&&n.endList||e.endList&&e.segments.length)return this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,void(s&&(this.trigger("mediachanging"),"HAVE_MAIN_MANIFEST"===i?this.trigger("loadedmetadata"):this.trigger("mediachange")));if(this.updateMediaUpdateTimeout_(refreshDelay(e,!0)),s){if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=e,this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials},((t,s)=>{if(this.request){if(e.lastRequest=Date.now(),e.resolvedUri=resolveManifestRedirect(e.resolvedUri,s),t)return this.playlistRequestError(this.request,e,i);this.haveMetadata({playlistString:s.responseText,url:e.uri,id:e.id}),"HAVE_MAIN_MANIFEST"===i?this.trigger("loadedmetadata"):this.trigger("mediachange")}}))}}pause(){this.mediaUpdateTimeout&&(window$1.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),"HAVE_NOTHING"===this.state&&(this.started=!1),"SWITCHING_MEDIA"===this.state?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":"HAVE_CURRENT_METADATA"===this.state&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(window$1.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const t=this.media();if(e){const e=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=window$1.setTimeout((()=>{this.mediaUpdateTimeout=null,this.load()}),e)}else this.started?t&&!t.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start()}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(window$1.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.media()&&!this.media().endList&&(this.mediaUpdateTimeout=window$1.setTimeout((()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)}),e))}start(){if(this.started=!0,"object"==typeof this.src)return this.src.uri||(this.src.uri=window$1.location.href),this.src.resolvedUri=this.src.uri,void setTimeout((()=>{this.setupInitialPlaylist(this.src)}),0);this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials},((e,t)=>{if(!this.request)return;if(this.request=null,e)return this.error={status:t.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:t.responseText,code:2},"HAVE_NOTHING"===this.state&&(this.started=!1),this.trigger("error");this.src=resolveManifestRedirect(this.src,t);const i=this.parseManifest_({manifestString:t.responseText,url:this.src});this.setupInitialPlaylist(i)}))}srcUri(){return"string"==typeof this.src?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists)return this.main=e,addPropertiesToMain(this.main,this.srcUri()),e.playlists.forEach((e=>{e.segments=getAllSegments(e),e.segments.forEach((t=>{resolveSegmentUris(t,e.resolvedUri)}))})),this.trigger("loadedplaylist"),void(this.request||this.media(this.main.playlists[0]));const t=this.srcUri()||window$1.location.href;this.main=mainForMedia(0,t),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}}const{xhr:videojsXHR}=videojs,callbackWrapper=function(e,t,i,s){const n="arraybuffer"===e.responseType?e.response:e.responseText;!t&&n&&(e.responseTime=Date.now(),e.roundTripTime=e.responseTime-e.requestTime,e.bytesReceived=n.byteLength||n.length,e.bandwidth||(e.bandwidth=Math.floor(e.bytesReceived/e.roundTripTime*8*1e3))),i.headers&&(e.responseHeaders=i.headers),t&&"ETIMEDOUT"===t.code&&(e.timedout=!0),t||e.aborted||200===i.statusCode||206===i.statusCode||0===i.statusCode||(t=new Error("XHR Failed with a response of: "+(e&&(n||e.responseText)))),s(t,e)},xhrFactory=function(){const e=function e(t,i){t=merge({timeout:45e3},t);const s=e.beforeRequest||videojs.Vhs.xhr.beforeRequest;if(s&&"function"==typeof s){const e=s(t);e&&(t=e)}const n=(!0===videojs.Vhs.xhr.original?videojsXHR:videojs.Vhs.xhr)(t,(function(e,t){return callbackWrapper(n,e,t,i)})),r=n.abort;return n.abort=function(){return n.aborted=!0,r.apply(n,arguments)},n.uri=t.uri,n.requestTime=Date.now(),n};return e.original=!0,e},byterangeStr=function(e){let t;const i=e.offset;return t="bigint"==typeof e.offset||"bigint"==typeof e.length?window$1.BigInt(e.offset)+window$1.BigInt(e.length)-window$1.BigInt(1):e.offset+e.length-1,"bytes="+i+"-"+t},segmentXhrHeaders=function(e){const t={};return e.byterange&&(t.Range=byterangeStr(e.byterange)),t},textRange=function(e,t){return e.start(t)+"-"+e.end(t)},formatHexString=function(e,t){const i=e.toString(16);return"00".substring(0,2-i.length)+i+(t%2?" ":"")},formatAsciiString=function(e){return e>=32&&e<126?String.fromCharCode(e):"."},createTransferableMessage=function(e){const t={};return Object.keys(e).forEach((i=>{const s=e[i];isArrayBufferView(s)?t[i]={bytes:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength}:t[i]=s})),t},initSegmentId=function(e){const t=e.byterange||{length:1/0,offset:0};return[t.length,t.offset,e.resolvedUri].join(",")},segmentKeyId=function(e){return e.resolvedUri},hexDump=e=>{const t=Array.prototype.slice.call(e),i=16;let s,n,r="";for(let e=0;e<t.length/i;e++)s=t.slice(e*i,e*i+i).map(formatHexString).join(""),n=t.slice(e*i,e*i+i).map(formatAsciiString).join(""),r+=s+" "+n+"\n";return r},tagDump=({bytes:e})=>hexDump(e),textRanges=e=>{let t,i="";for(t=0;t<e.length;t++)i+=textRange(e,t)+" ";return i};var utils=Object.freeze({__proto__:null,createTransferableMessage:createTransferableMessage,initSegmentId:initSegmentId,segmentKeyId:segmentKeyId,hexDump:hexDump,tagDump:tagDump,textRanges:textRanges});const SEGMENT_END_FUDGE_PERCENT=.25,playerTimeToProgramTime=(e,t)=>{if(!t.dateTimeObject)return null;const i=t.videoTimingInfo.transmuxerPrependedSeconds,s=e-(t.videoTimingInfo.transmuxedPresentationStart+i);return new Date(t.dateTimeObject.getTime()+1e3*s)},originalSegmentVideoDuration=e=>e.transmuxedPresentationEnd-e.transmuxedPresentationStart-e.transmuxerPrependedSeconds,findSegmentForProgramTime=(e,t)=>{let i;try{i=new Date(e)}catch(e){return null}if(!t||!t.segments||0===t.segments.length)return null;let s=t.segments[0];if(i<s.dateTimeObject)return null;for(let e=0;e<t.segments.length-1&&(s=t.segments[e],!(i<t.segments[e+1].dateTimeObject));e++);const n=t.segments[t.segments.length-1],r=n.dateTimeObject,a=n.videoTimingInfo?(o=n.videoTimingInfo).transmuxedPresentationEnd-o.transmuxedPresentationStart-o.transmuxerPrependedSeconds:n.duration+.25*n.duration;var o;return i>new Date(r.getTime()+1e3*a)?null:(i>r&&(s=n),{segment:s,estimatedStart:s.videoTimingInfo?s.videoTimingInfo.transmuxedPresentationStart:Playlist.duration(t,t.mediaSequence+t.segments.indexOf(s)),type:s.videoTimingInfo?"accurate":"estimate"})},findSegmentForPlayerTime=(e,t)=>{if(!t||!t.segments||0===t.segments.length)return null;let i,s=0;for(let n=0;n<t.segments.length&&(i=t.segments[n],s=i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationEnd:s+i.duration,!(e<=s));n++);const n=t.segments[t.segments.length-1];if(n.videoTimingInfo&&n.videoTimingInfo.transmuxedPresentationEnd<e)return null;if(e>s){if(e>s+.25*n.duration)return null;i=n}return{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:s-i.duration,type:i.videoTimingInfo?"accurate":"estimate"}},getOffsetFromTimestamp=(e,t)=>{let i,s;try{i=new Date(e),s=new Date(t)}catch(e){}const n=i.getTime();return(s.getTime()-n)/1e3},verifyProgramDateTimeTags=e=>{if(!e.segments||0===e.segments.length)return!1;for(let t=0;t<e.segments.length;t++)if(!e.segments[t].dateTimeObject)return!1;return!0},getProgramTime=({playlist:e,time:t,callback:i})=>{if(!i)throw new Error("getProgramTime: callback must be provided");if(!e||void 0===t)return i({message:"getProgramTime: playlist and time must be provided"});const s=findSegmentForPlayerTime(t,e);if(!s)return i({message:"valid programTime was not found"});if("estimate"===s.type)return i({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:s.estimatedStart});const n={mediaSeconds:t},r=playerTimeToProgramTime(t,s.segment);return r&&(n.programDateTime=r.toISOString()),i(null,n)},seekToProgramTime=({programTime:e,playlist:t,retryCount:i=2,seekTo:s,pauseAfterSeek:n=!0,tech:r,callback:a})=>{if(!a)throw new Error("seekToProgramTime: callback must be provided");if(void 0===e||!t||!s)return a({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!t.endList&&!r.hasStarted_)return a({message:"player must be playing a live stream to start buffering"});if(!verifyProgramDateTimeTags(t))return a({message:"programDateTime tags must be provided in the manifest "+t.resolvedUri});const o=findSegmentForProgramTime(e,t);if(!o)return a({message:`${e} was not found in the stream`});const l=o.segment,d=getOffsetFromTimestamp(l.dateTimeObject,e);if("estimate"===o.type)return 0===i?a({message:`${e} is not buffered yet. Try again`}):(s(o.estimatedStart+d),void r.one("seeked",(()=>{seekToProgramTime({programTime:e,playlist:t,retryCount:i-1,seekTo:s,pauseAfterSeek:n,tech:r,callback:a})})));const h=l.start+d;r.one("seeked",(()=>a(null,r.currentTime()))),n&&r.pause(),s(h)},callbackOnCompleted=(e,t)=>{if(4===e.readyState)return t()},containerRequest=(e,t,i)=>{let s,n=[],r=!1;const a=function(e,t,s,n){return t.abort(),r=!0,i(e,t,s,n)},o=function(e,t){if(r)return;if(e)return a(e,t,"",n);const i=t.responseText.substring(n&&n.byteLength||0,t.responseText.length);if(n=concatTypedArrays(n,stringToBytes(i,!0)),s=s||getId3Offset(n),n.length<10||s&&n.length<s+2)return callbackOnCompleted(t,(()=>a(e,t,"",n)));const o=detectContainerForBytes(n);return"ts"===o&&n.length<188||!o&&n.length<376?callbackOnCompleted(t,(()=>a(e,t,"",n))):a(null,t,o,n)},l=t({uri:e,beforeSend(e){e.overrideMimeType("text/plain; charset=x-user-defined"),e.addEventListener("progress",(function({total:t,loaded:i}){return callbackWrapper(e,null,{statusCode:e.status},o)}))}},(function(e,t){return callbackWrapper(l,e,t,o)}));return l},{EventTarget:EventTarget}=videojs,dashPlaylistUnchanged=function(e,t){if(!isPlaylistUnchanged(e,t))return!1;if(e.sidx&&t.sidx&&(e.sidx.offset!==t.sidx.offset||e.sidx.length!==t.sidx.length))return!1;if(!e.sidx&&t.sidx||e.sidx&&!t.sidx)return!1;if(e.segments&&!t.segments||!e.segments&&t.segments)return!1;if(!e.segments&&!t.segments)return!0;for(let i=0;i<e.segments.length;i++){const s=e.segments[i],n=t.segments[i];if(s.uri!==n.uri)return!1;if(!s.byterange&&!n.byterange)continue;const r=s.byterange,a=n.byterange;if(r&&!a||!r&&a)return!1;if(r.offset!==a.offset||r.length!==a.length)return!1}return!0},dashGroupId=(e,t,i,s)=>`placeholder-uri-${e}-${t}-${s.attributes.NAME||i}`,parseMainXml=({mainXml:e,srcUrl:t,clientOffset:i,sidxMapping:s,previousManifest:n})=>{const r=parse(e,{manifestUri:t,clientOffset:i,sidxMapping:s,previousManifest:n});return addPropertiesToMain(r,t,dashGroupId),r},removeOldMediaGroupLabels=(e,t)=>{forEachMediaGroup(e,((i,s,n,r)=>{r in t.mediaGroups[s][n]||delete e.mediaGroups[s][n][r]}))},updateMain=(e,t,i)=>{let s=!0,n=merge(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod,timelineStarts:t.timelineStarts});for(let e=0;e<t.playlists.length;e++){const r=t.playlists[e];if(r.sidx){const e=generateSidxKey(r.sidx);i&&i[e]&&i[e].sidx&&addSidxSegmentsToPlaylist(r,i[e].sidx,r.sidx.resolvedUri)}const a=updateMain$1(n,r,dashPlaylistUnchanged);a&&(n=a,s=!1)}return forEachMediaGroup(t,((e,t,i,r)=>{if(e.playlists&&e.playlists.length){const a=e.playlists[0].id,o=updateMain$1(n,e.playlists[0],dashPlaylistUnchanged);o&&(n=o,r in n.mediaGroups[t][i]||(n.mediaGroups[t][i][r]=e),n.mediaGroups[t][i][r].playlists[0]=n.playlists[a],s=!1)}})),removeOldMediaGroupLabels(n,t),t.minimumUpdatePeriod!==e.minimumUpdatePeriod&&(s=!1),s?null:n},equivalentSidx=(e,t)=>(Boolean(!e.map&&!t.map)||Boolean(e.map&&t.map&&e.map.byterange.offset===t.map.byterange.offset&&e.map.byterange.length===t.map.byterange.length))&&e.uri===t.uri&&e.byterange.offset===t.byterange.offset&&e.byterange.length===t.byterange.length,compareSidxEntry=(e,t)=>{const i={};for(const r in e){const a=e[r].sidx;if(a){const e=generateSidxKey(a);if(!t[e])break;s=t[e].sidxInfo,n=a,(Boolean(!s.map&&!n.map)||Boolean(s.map&&n.map&&s.map.byterange.offset===n.map.byterange.offset&&s.map.byterange.length===n.map.byterange.length))&&s.uri===n.uri&&s.byterange.offset===n.byterange.offset&&s.byterange.length===n.byterange.length&&(i[e]=t[e])}}var s,n;return i},filterChangedSidxMappings=(e,t)=>{let i=compareSidxEntry(e.playlists,t);return forEachMediaGroup(e,((e,s,n,r)=>{if(e.playlists&&e.playlists.length){const s=e.playlists;i=merge(i,compareSidxEntry(s,t))}})),i};class DashPlaylistLoader extends EventTarget{constructor(e,t,i={},s){super(),this.mainPlaylistLoader_=s||this,s||(this.isMain_=!0);const{withCredentials:n=!1}=i;if(this.vhs_=t,this.withCredentials=n,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",(()=>{this.refreshXml_()})),this.on("mediaupdatetimeout",(()=>{this.refreshMedia_(this.media().id)})),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=logger("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}requestErrored_(e,t,i){return!this.request||(this.request=null,e?(this.error="object"!=typeof e||e instanceof Error?{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2}:e,i&&(this.state=i),this.trigger("error"),!0):void 0)}addSidxSegments_(e,t,i){const s=e.sidx&&generateSidxKey(e.sidx);if(!e.sidx||!s||this.mainPlaylistLoader_.sidxMapping_[s])return void(this.mediaRequest_=window$1.setTimeout((()=>i(!1)),0));const n=resolveManifestRedirect(e.sidx.resolvedUri),r=(n,r)=>{if(this.requestErrored_(n,r,t))return;const a=this.mainPlaylistLoader_.sidxMapping_;let o;try{o=parseSidx(toUint8(r.response).subarray(8))}catch(e){return void this.requestErrored_(e,r,t)}return a[s]={sidxInfo:e.sidx,sidx:o},addSidxSegmentsToPlaylist(e,o,e.sidx.resolvedUri),i(!0)};this.request=containerRequest(n,this.vhs_.xhr,((t,i,s,a)=>{if(t)return r(t,i);if(!s||"mp4"!==s)return r({status:i.status,message:`Unsupported ${s||"unknown"} container type for sidx segment at URL: ${n}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},i);const{offset:o,length:l}=e.sidx.byterange;if(a.length>=l+o)return r(t,{response:a.subarray(o,o+l),status:i.status,uri:i.uri});this.request=this.vhs_.xhr({uri:n,responseType:"arraybuffer",headers:segmentXhrHeaders({byterange:e.sidx.byterange})},r)}))}dispose(){this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},window$1.clearTimeout(this.minimumUpdatePeriodTimeout_),window$1.clearTimeout(this.mediaRequest_),window$1.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);const t=this.state;if("string"==typeof e){if(!this.mainPlaylistLoader_.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}const i=!this.media_||e.id!==this.media_.id;if(i&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList)return this.state="HAVE_METADATA",this.media_=e,void(i&&(this.trigger("mediachanging"),this.trigger("mediachange")));i&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,t,(i=>{this.haveMetadata({startingState:t,playlist:e})})))}haveMetadata({startingState:e,playlist:t}){this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,this.mediaRequest_=null,this.refreshMedia_(t.id),"HAVE_MAIN_MANIFEST"===e?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),window$1.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(window$1.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),"HAVE_NOTHING"===this.state&&(this.started=!1)}load(e){window$1.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const t=this.media();if(e){const e=t?t.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=window$1.setTimeout((()=>this.load()),e)}else this.started?t&&!t.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist"):this.start()}start(){this.started=!0,this.isMain_?this.requestMain_(((e,t)=>{this.haveMain_(),this.hasPendingRequest()||this.media_||this.media(this.mainPlaylistLoader_.main.playlists[0])})):this.mediaRequest_=window$1.setTimeout((()=>this.haveMain_()),0)}requestMain_(e){this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials},((t,i)=>{if(this.requestErrored_(t,i))return void("HAVE_NOTHING"===this.state&&(this.started=!1));const s=i.responseText!==this.mainPlaylistLoader_.mainXml_;return this.mainPlaylistLoader_.mainXml_=i.responseText,i.responseHeaders&&i.responseHeaders.date?this.mainLoaded_=Date.parse(i.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=resolveManifestRedirect(this.mainPlaylistLoader_.srcUrl,i),s?(this.handleMain_(),void this.syncClientServerClock_((()=>e(i,s)))):e(i,s)}))}syncClientServerClock_(e){const t=parseUTCTiming(this.mainPlaylistLoader_.mainXml_);return null===t?(this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e()):"DIRECT"===t.method?(this.mainPlaylistLoader_.clientOffset_=t.value-Date.now(),e()):void(this.request=this.vhs_.xhr({uri:resolveUrl(this.mainPlaylistLoader_.srcUrl,t.value),method:t.method,withCredentials:this.withCredentials},((i,s)=>{if(!this.request)return;if(i)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();let n;n="HEAD"===t.method?s.responseHeaders&&s.responseHeaders.date?Date.parse(s.responseHeaders.date):this.mainLoaded_:Date.parse(s.responseText),this.mainPlaylistLoader_.clientOffset_=n-Date.now(),e()})))}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){this.mediaRequest_=null;const e=this.mainPlaylistLoader_.main;let t=parseMainXml({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e});e&&(t=updateMain(e,t,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=t||e;const i=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];return i&&i!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=i),(!e||t&&t.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),Boolean(t)}updateMinimumUpdatePeriodTimeout_(){const e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(window$1.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let t=e.main&&e.main.minimumUpdatePeriod;0===t&&(e.media()?t=1e3*e.media().targetDuration:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),"number"!=typeof t||t<=0?t<0&&this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`):this.createMUPTimeout_(t)}createMUPTimeout_(e){const t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=window$1.setTimeout((()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)}),e)}refreshXml_(){this.requestMain_(((e,t)=>{t&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=filterChangedSidxMappings(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,(e=>{this.refreshMedia_(this.media().id)})))}))}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();const t=this.mainPlaylistLoader_.main.playlists,i=!this.media_||this.media_!==t[e];if(i?this.media_=t[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const e=()=>{this.media().endList||(this.mediaUpdateTimeout=window$1.setTimeout((()=>{this.trigger("mediaupdatetimeout"),e()}),refreshDelay(this.media(),Boolean(i))))};e()}this.trigger("loadedplaylist")}}var Config={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};const stringToArrayBuffer=e=>{const t=new Uint8Array(new ArrayBuffer(e.length));for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t.buffer},browserWorkerPolyFill=function(e){return e.on=e.addEventListener,e.off=e.removeEventListener,e},createObjectURL=function(e){try{return URL.createObjectURL(new Blob([e],{type:"application/javascript"}))}catch(t){const i=new BlobBuilder;return i.append(e),URL.createObjectURL(i.getBlob())}},factory=function(e){return function(){const t=createObjectURL(e),i=browserWorkerPolyFill(new Worker(t));i.objURL=t;const s=i.terminate;return i.on=i.addEventListener,i.off=i.removeEventListener,i.terminate=function(){return URL.revokeObjectURL(t),s.call(this)},i}},transform=function(e){return`var browserWorkerPolyFill = ${browserWorkerPolyFill.toString()};\nbrowserWorkerPolyFill(self);\n`+e},getWorkerString=function(e){return e.toString().replace(/^function.+?{/,"").slice(0,-1)},workerCode$1=transform(getWorkerString((function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=function(){this.init=function(){var e={};this.on=function(t,i){e[t]||(e[t]=[]),e[t]=e[t].concat(i)},this.off=function(t,i){var s;return!!e[t]&&(s=e[t].indexOf(i),e[t]=e[t].slice(),e[t].splice(s,1),s>-1)},this.trigger=function(t){var i,s,n,r;if(i=e[t])if(2===arguments.length)for(n=i.length,s=0;s<n;++s)i[s].call(this,arguments[1]);else{for(r=[],s=arguments.length,s=1;s<arguments.length;++s)r.push(arguments[s]);for(n=i.length,s=0;s<n;++s)i[s].apply(this,r)}},this.dispose=function(){e={}}}};t.prototype.pipe=function(e){return this.on("data",(function(t){e.push(t)})),this.on("done",(function(t){e.flush(t)})),this.on("partialdone",(function(t){e.partialFlush(t)})),this.on("endedtimeline",(function(t){e.endTimeline(t)})),this.on("reset",(function(t){e.reset(t)})),e},t.prototype.push=function(e){this.trigger("data",e)},t.prototype.flush=function(e){this.trigger("done",e)},t.prototype.partialFlush=function(e){this.trigger("partialdone",e)},t.prototype.endTimeline=function(e){this.trigger("endedtimeline",e)},t.prototype.reset=function(e){this.trigger("reset",e)};var i,s,n,r,a,o,l,d,h,u,c,p,m,g,f,_,y,T,v,b,S,C,k,E,w,I,x,P,A,L,O,D,M,R,$,U,B,N,F,j,H=t,V=Math.pow(2,32),q={getUint64:function(e){var t,i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.getBigUint64?(t=i.getBigUint64(0))<Number.MAX_SAFE_INTEGER?Number(t):t:i.getUint32(0)*V+i.getUint32(4)},MAX_UINT32:V},W=q.MAX_UINT32;!function(){var e;if(C={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},"undefined"!=typeof Uint8Array){for(e in C)C.hasOwnProperty(e)&&(C[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);k=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),w=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),E=new Uint8Array([0,0,0,1]),I=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),x=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),P={video:I,audio:x},O=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),L=new Uint8Array([0,0,0,0,0,0,0,0]),D=new Uint8Array([0,0,0,0,0,0,0,0]),M=D,R=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),$=D,A=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}}(),i=function(e){var t,i,s=[],n=0;for(t=1;t<arguments.length;t++)s.push(arguments[t]);for(t=s.length;t--;)n+=s[t].byteLength;for(i=new Uint8Array(n+8),new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,i.byteLength),i.set(e,4),t=0,n=8;t<s.length;t++)i.set(s[t],n),n+=s[t].byteLength;return i},s=function(){return i(C.dinf,i(C.dref,O))},n=function(e){return i(C.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,e.audioobjecttype<<3|e.samplingfrequencyindex>>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},f=function(e){return i(C.hdlr,P[e])},g=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(t[12]=e.samplerate>>>24&255,t[13]=e.samplerate>>>16&255,t[14]=e.samplerate>>>8&255,t[15]=255&e.samplerate),i(C.mdhd,t)},m=function(e){return i(C.mdia,g(e),f(e.type),o(e))},a=function(e){return i(C.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},o=function(e){return i(C.minf,"video"===e.type?i(C.vmhd,A):i(C.smhd,L),s(),y(e))},l=function(e,t){for(var s=[],n=t.length;n--;)s[n]=v(t[n]);return i.apply(null,[C.moof,a(e)].concat(s))},d=function(e){for(var t=e.length,s=[];t--;)s[t]=c(e[t]);return i.apply(null,[C.moov,u(4294967295)].concat(s).concat(h(e)))},h=function(e){for(var t=e.length,s=[];t--;)s[t]=b(e[t]);return i.apply(null,[C.mvex].concat(s))},u=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i(C.mvhd,t)},_=function(e){var t,s,n=e.samples||[],r=new Uint8Array(4+n.length);for(s=0;s<n.length;s++)t=n[s].flags,r[s+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return i(C.sdtp,r)},y=function(e){return i(C.stbl,T(e),i(C.stts,$),i(C.stsc,M),i(C.stsz,R),i(C.stco,D))},T=function(e){return i(C.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),"video"===e.type?U(e):B(e))},U=function(e){var t,s,n=e.sps||[],r=e.pps||[],a=[],o=[];for(t=0;t<n.length;t++)a.push((65280&n[t].byteLength)>>>8),a.push(255&n[t].byteLength),a=a.concat(Array.prototype.slice.call(n[t]));for(t=0;t<r.length;t++)o.push((65280&r[t].byteLength)>>>8),o.push(255&r[t].byteLength),o=o.concat(Array.prototype.slice.call(r[t]));if(s=[C.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),i(C.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([n.length],a,[r.length],o))),i(C.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],e.sarRatio){var l=e.sarRatio[0],d=e.sarRatio[1];s.push(i(C.pasp,new Uint8Array([(4278190080&l)>>24,(16711680&l)>>16,(65280&l)>>8,255&l,(4278190080&d)>>24,(16711680&d)>>16,(65280&d)>>8,255&d])))}return i.apply(null,s)},B=function(e){return i(C.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),n(e))},p=function(e){var t=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,0,(4278190080&e.duration)>>24,(16711680&e.duration)>>16,(65280&e.duration)>>8,255&e.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&e.width)>>8,255&e.width,0,0,(65280&e.height)>>8,255&e.height,0,0]);return i(C.tkhd,t)},v=function(e){var t,s,n,r,a,o;return t=i(C.tfhd,new Uint8Array([0,0,0,58,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),a=Math.floor(e.baseMediaDecodeTime/W),o=Math.floor(e.baseMediaDecodeTime%W),s=i(C.tfdt,new Uint8Array([1,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o])),"audio"===e.type?(n=S(e,92),i(C.traf,t,s,n)):(r=_(e),n=S(e,r.length+92),i(C.traf,t,s,n,r))},c=function(e){return e.duration=e.duration||4294967295,i(C.trak,p(e),m(e))},b=function(e){var t=new Uint8Array([0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return"video"!==e.type&&(t[t.length-1]=0),i(C.trex,t)},j=function(e,t){var i=0,s=0,n=0,r=0;return e.length&&(void 0!==e[0].duration&&(i=1),void 0!==e[0].size&&(s=2),void 0!==e[0].flags&&(n=4),void 0!==e[0].compositionTimeOffset&&(r=8)),[0,0,i|s|n|r,1,(4278190080&e.length)>>>24,(16711680&e.length)>>>16,(65280&e.length)>>>8,255&e.length,(4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t]},F=function(e,t){var s,n,r,a,o,l;for(t+=20+16*(a=e.samples||[]).length,r=j(a,t),(n=new Uint8Array(r.length+16*a.length)).set(r),s=r.length,l=0;l<a.length;l++)o=a[l],n[s++]=(4278190080&o.duration)>>>24,n[s++]=(16711680&o.duration)>>>16,n[s++]=(65280&o.duration)>>>8,n[s++]=255&o.duration,n[s++]=(4278190080&o.size)>>>24,n[s++]=(16711680&o.size)>>>16,n[s++]=(65280&o.size)>>>8,n[s++]=255&o.size,n[s++]=o.flags.isLeading<<2|o.flags.dependsOn,n[s++]=o.flags.isDependedOn<<6|o.flags.hasRedundancy<<4|o.flags.paddingValue<<1|o.flags.isNonSyncSample,n[s++]=61440&o.flags.degradationPriority,n[s++]=15&o.flags.degradationPriority,n[s++]=(4278190080&o.compositionTimeOffset)>>>24,n[s++]=(16711680&o.compositionTimeOffset)>>>16,n[s++]=(65280&o.compositionTimeOffset)>>>8,n[s++]=255&o.compositionTimeOffset;return i(C.trun,n)},N=function(e,t){var s,n,r,a,o,l;for(t+=20+8*(a=e.samples||[]).length,r=j(a,t),(s=new Uint8Array(r.length+8*a.length)).set(r),n=r.length,l=0;l<a.length;l++)o=a[l],s[n++]=(4278190080&o.duration)>>>24,s[n++]=(16711680&o.duration)>>>16,s[n++]=(65280&o.duration)>>>8,s[n++]=255&o.duration,s[n++]=(4278190080&o.size)>>>24,s[n++]=(16711680&o.size)>>>16,s[n++]=(65280&o.size)>>>8,s[n++]=255&o.size;return i(C.trun,s)},S=function(e,t){return"audio"===e.type?N(e,t):F(e,t)};var G,K,z,Q,Y,X,J,Z,ee={ftyp:r=function(){return i(C.ftyp,k,E,k,w)},mdat:function(e){return i(C.mdat,e)},moof:l,moov:d,initSegment:function(e){var t,i=r(),s=d(e);return(t=new Uint8Array(i.byteLength+s.byteLength)).set(i),t.set(s,i.byteLength),t}},te=function(e,t){var i={size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}};return i.dataOffset=t,i.compositionTimeOffset=e.pts-e.dts,i.duration=e.duration,i.size=4*e.length,i.size+=e.byteLength,e.keyFrame&&(i.flags.dependsOn=2,i.flags.isNonSyncSample=0),i},ie={groupNalsIntoFrames:function(e){var t,i,s=[],n=[];for(n.byteLength=0,n.nalCount=0,n.duration=0,s.byteLength=0,t=0;t<e.length;t++)"access_unit_delimiter_rbsp"===(i=e[t]).nalUnitType?(s.length&&(s.duration=i.dts-s.dts,n.byteLength+=s.byteLength,n.nalCount+=s.length,n.duration+=s.duration,n.push(s)),(s=[i]).byteLength=i.data.byteLength,s.pts=i.pts,s.dts=i.dts):("slice_layer_without_partitioning_rbsp_idr"===i.nalUnitType&&(s.keyFrame=!0),s.duration=i.dts-s.dts,s.byteLength+=i.data.byteLength,s.push(i));return n.length&&(!s.duration||s.duration<=0)&&(s.duration=n[n.length-1].duration),n.byteLength+=s.byteLength,n.nalCount+=s.length,n.duration+=s.duration,n.push(s),n},groupFramesIntoGops:function(e){var t,i,s=[],n=[];for(s.byteLength=0,s.nalCount=0,s.duration=0,s.pts=e[0].pts,s.dts=e[0].dts,n.byteLength=0,n.nalCount=0,n.duration=0,n.pts=e[0].pts,n.dts=e[0].dts,t=0;t<e.length;t++)(i=e[t]).keyFrame?(s.length&&(n.push(s),n.byteLength+=s.byteLength,n.nalCount+=s.nalCount,n.duration+=s.duration),(s=[i]).nalCount=i.length,s.byteLength=i.byteLength,s.pts=i.pts,s.dts=i.dts,s.duration=i.duration):(s.duration+=i.duration,s.nalCount+=i.length,s.byteLength+=i.byteLength,s.push(i));return n.length&&s.duration<=0&&(s.duration=n[n.length-1].duration),n.byteLength+=s.byteLength,n.nalCount+=s.nalCount,n.duration+=s.duration,n.push(s),n},extendFirstKeyFrame:function(e){var t;return!e[0][0].keyFrame&&e.length>1&&(t=e.shift(),e.byteLength-=t.byteLength,e.nalCount-=t.nalCount,e[0][0].dts=t.dts,e[0][0].pts=t.pts,e[0][0].duration+=t.duration),e},generateSampleTable:function(e,t){var i,s,n,r,a,o=t||0,l=[];for(i=0;i<e.length;i++)for(r=e[i],s=0;s<r.length;s++)a=r[s],o+=(n=te(a,o)).size,l.push(n);return l},concatenateNalData:function(e){var t,i,s,n,r,a,o=0,l=e.byteLength,d=e.nalCount,h=new Uint8Array(l+4*d),u=new DataView(h.buffer);for(t=0;t<e.length;t++)for(n=e[t],i=0;i<n.length;i++)for(r=n[i],s=0;s<r.length;s++)a=r[s],u.setUint32(o,a.data.byteLength),o+=4,h.set(a.data,o),o+=a.data.byteLength;return h},generateSampleTableForFrame:function(e,t){var i,s=[];return i=te(e,t||0),s.push(i),s},concatenateNalDataForFrame:function(e){var t,i,s=0,n=e.byteLength,r=e.length,a=new Uint8Array(n+4*r),o=new DataView(a.buffer);for(t=0;t<e.length;t++)i=e[t],o.setUint32(s,i.data.byteLength),s+=4,a.set(i.data,s),s+=i.data.byteLength;return a}},se=[33,16,5,32,164,27],ne=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],re=function(e){for(var t=[];e--;)t.push(0);return t},ae=9e4;X=function(e,t){return K(Y(e,t))},J=function(e,t){return z(Q(e),t)},Z=function(e,t,i){return Q(i?e:e-t)};var oe={ONE_SECOND_IN_TS:ae,secondsToVideoTs:K=function(e){return e*ae},secondsToAudioTs:z=function(e,t){return e*t},videoTsToSeconds:Q=function(e){return e/ae},audioTsToSeconds:Y=function(e,t){return e/t},audioTsToVideoTs:X,videoTsToAudioTs:J,metadataTsToSeconds:Z},le=oe,de={prefixWithSilence:function(e,t,i,s){var n,r,a,o,l,d=0,h=0,u=0;if(t.length&&(n=le.audioTsToVideoTs(e.baseMediaDecodeTime,e.samplerate),r=Math.ceil(le.ONE_SECOND_IN_TS/(e.samplerate/1024)),i&&s&&(d=n-Math.max(i,s),u=(h=Math.floor(d/r))*r),!(h<1||u>le.ONE_SECOND_IN_TS/2))){for((a=function(){if(!G){var e={96e3:[se,[227,64],re(154),[56]],88200:[se,[231],re(170),[56]],64e3:[se,[248,192],re(240),[56]],48e3:[se,[255,192],re(268),[55,148,128],re(54),[112]],44100:[se,[255,192],re(268),[55,163,128],re(84),[112]],32e3:[se,[255,192],re(268),[55,234],re(226),[112]],24e3:[se,[255,192],re(268),[55,255,128],re(268),[111,112],re(126),[224]],16e3:[se,[255,192],re(268),[55,255,128],re(268),[111,255],re(269),[223,108],re(195),[1,192]],12e3:[ne,re(268),[3,127,248],re(268),[6,255,240],re(268),[13,255,224],re(268),[27,253,128],re(259),[56]],11025:[ne,re(268),[3,127,248],re(268),[6,255,240],re(268),[13,255,224],re(268),[27,255,192],re(268),[55,175,128],re(108),[112]],8e3:[ne,re(268),[3,121,16],re(47),[7]]};t=e,G=Object.keys(t).reduce((function(e,i){return e[i]=new Uint8Array(t[i].reduce((function(e,t){return e.concat(t)}),[])),e}),{})}var t;return G}()[e.samplerate])||(a=t[0].data),o=0;o<h;o++)l=t[0],t.splice(0,0,{data:a,dts:l.dts-r,pts:l.pts-r});return e.baseMediaDecodeTime-=Math.floor(le.videoTsToAudioTs(u,e.samplerate)),u}},trimAdtsFramesByEarliestDts:function(e,t,i){return t.minSegmentDts>=i?e:(t.minSegmentDts=1/0,e.filter((function(e){return e.dts>=i&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)})))},generateSampleTable:function(e){var t,i,s=[];for(t=0;t<e.length;t++)i=e[t],s.push({size:i.data.byteLength,duration:1024});return s},concatenateFrameData:function(e){var t,i,s=0,n=new Uint8Array(function(e){var t,i=0;for(t=0;t<e.length;t++)i+=e[t].data.byteLength;return i}(e));for(t=0;t<e.length;t++)i=e[t],n.set(i.data,s),s+=i.data.byteLength;return n}},he=oe.ONE_SECOND_IN_TS,ue={clearDtsInfo:function(e){delete e.minSegmentDts,delete e.maxSegmentDts,delete e.minSegmentPts,delete e.maxSegmentPts},calculateTrackBaseMediaDecodeTime:function(e,t){var i,s=e.minSegmentDts;return t||(s-=e.timelineStartInfo.dts),i=e.timelineStartInfo.baseMediaDecodeTime,i+=s,i=Math.max(0,i),"audio"===e.type&&(i*=e.samplerate/he,i=Math.floor(i)),i},collectDtsInfo:function(e,t){"number"==typeof t.pts&&(void 0===e.timelineStartInfo.pts&&(e.timelineStartInfo.pts=t.pts),void 0===e.minSegmentPts?e.minSegmentPts=t.pts:e.minSegmentPts=Math.min(e.minSegmentPts,t.pts),void 0===e.maxSegmentPts?e.maxSegmentPts=t.pts:e.maxSegmentPts=Math.max(e.maxSegmentPts,t.pts)),"number"==typeof t.dts&&(void 0===e.timelineStartInfo.dts&&(e.timelineStartInfo.dts=t.dts),void 0===e.minSegmentDts?e.minSegmentDts=t.dts:e.minSegmentDts=Math.min(e.minSegmentDts,t.dts),void 0===e.maxSegmentDts?e.maxSegmentDts=t.dts:e.maxSegmentDts=Math.max(e.maxSegmentDts,t.dts))}},ce={parseSei:function(e){for(var t=0,i={payloadType:-1,payloadSize:0},s=0,n=0;t<e.byteLength&&128!==e[t];){for(;255===e[t];)s+=255,t++;for(s+=e[t++];255===e[t];)n+=255,t++;if(n+=e[t++],!i.payload&&4===s){if("GA94"===String.fromCharCode(e[t+3],e[t+4],e[t+5],e[t+6])){i.payloadType=s,i.payloadSize=n,i.payload=e.subarray(t,t+n);break}i.payload=void 0}t+=n,s=0,n=0}return i},parseUserData:function(e){return 181!==e.payload[0]||49!=(e.payload[1]<<8|e.payload[2])||"GA94"!==String.fromCharCode(e.payload[3],e.payload[4],e.payload[5],e.payload[6])||3!==e.payload[7]?null:e.payload.subarray(8,e.payload.length-1)},parseCaptionPackets:function(e,t){var i,s,n,r,a=[];if(!(64&t[0]))return a;for(s=31&t[0],i=0;i<s;i++)r={type:3&t[2+(n=3*i)],pts:e},4&t[n+2]&&(r.ccData=t[n+3]<<8|t[n+4],a.push(r));return a},discardEmulationPreventionBytes:function(e){for(var t,i,s=e.byteLength,n=[],r=1;r<s-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(n.push(r+2),r+=2):r++;if(0===n.length)return e;t=s-n.length,i=new Uint8Array(t);var a=0;for(r=0;r<t;a++,r++)a===n[0]&&(a++,n.shift()),i[r]=e[a];return i},USER_DATA_REGISTERED_ITU_T_T35:4},pe=H,me=ce,ge=function(e){e=e||{},ge.prototype.init.call(this),this.parse708captions_="boolean"!=typeof e.parse708captions||e.parse708captions,this.captionPackets_=[],this.ccStreams_=[new Ee(0,0),new Ee(0,1),new Ee(1,0),new Ee(1,1)],this.parse708captions_&&(this.cc708Stream_=new ve({captionServices:e.captionServices})),this.reset(),this.ccStreams_.forEach((function(e){e.on("data",this.trigger.bind(this,"data")),e.on("partialdone",this.trigger.bind(this,"partialdone")),e.on("done",this.trigger.bind(this,"done"))}),this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};ge.prototype=new pe,ge.prototype.push=function(e){var t,i,s;if("sei_rbsp"===e.nalUnitType&&(t=me.parseSei(e.escapedRBSP)).payload&&t.payloadType===me.USER_DATA_REGISTERED_ITU_T_T35&&(i=me.parseUserData(t)))if(e.dts<this.latestDts_)this.ignoreNextEqualDts_=!0;else{if(e.dts===this.latestDts_&&this.ignoreNextEqualDts_)return this.numSameDts_--,void(this.numSameDts_||(this.ignoreNextEqualDts_=!1));s=me.parseCaptionPackets(e.pts,i),this.captionPackets_=this.captionPackets_.concat(s),this.latestDts_!==e.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=e.dts}},ge.prototype.flushCCStreams=function(e){this.ccStreams_.forEach((function(t){return"flush"===e?t.flush():t.partialFlush()}),this)},ge.prototype.flushStream=function(e){this.captionPackets_.length?(this.captionPackets_.forEach((function(e,t){e.presortIndex=t})),this.captionPackets_.sort((function(e,t){return e.pts===t.pts?e.presortIndex-t.presortIndex:e.pts-t.pts})),this.captionPackets_.forEach((function(e){e.type<2?this.dispatchCea608Packet(e):this.dispatchCea708Packet(e)}),this),this.captionPackets_.length=0,this.flushCCStreams(e)):this.flushCCStreams(e)},ge.prototype.flush=function(){return this.flushStream("flush")},ge.prototype.partialFlush=function(){return this.flushStream("partialFlush")},ge.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach((function(e){e.reset()}))},ge.prototype.dispatchCea608Packet=function(e){this.setsTextOrXDSActive(e)?this.activeCea608Channel_[e.type]=null:this.setsChannel1Active(e)?this.activeCea608Channel_[e.type]=0:this.setsChannel2Active(e)&&(this.activeCea608Channel_[e.type]=1),null!==this.activeCea608Channel_[e.type]&&this.ccStreams_[(e.type<<1)+this.activeCea608Channel_[e.type]].push(e)},ge.prototype.setsChannel1Active=function(e){return 4096==(30720&e.ccData)},ge.prototype.setsChannel2Active=function(e){return 6144==(30720&e.ccData)},ge.prototype.setsTextOrXDSActive=function(e){return 256==(28928&e.ccData)||4138==(30974&e.ccData)||6186==(30974&e.ccData)},ge.prototype.dispatchCea708Packet=function(e){this.parse708captions_&&this.cc708Stream_.push(e)};var fe={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},_e=function(e){return 32<=e&&e<=127||160<=e&&e<=255},ye=function(e){this.windowNum=e,this.reset()};ye.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},ye.prototype.getText=function(){return this.rows.join("\n")},ye.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},ye.prototype.newLine=function(e){for(this.rows.length>=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(e),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},ye.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},ye.prototype.addText=function(e){this.rows[this.rowIdx]+=e},ye.prototype.backspace=function(){if(!this.isEmpty()){var e=this.rows[this.rowIdx];this.rows[this.rowIdx]=e.substr(0,e.length-1)}};var Te=function(e,t,i){this.serviceNum=e,this.text="",this.currentWindow=new ye(-1),this.windows=[],this.stream=i,"string"==typeof t&&this.createTextDecoder(t)};Te.prototype.init=function(e,t){this.startPts=e;for(var i=0;i<8;i++)this.windows[i]=new ye(i),"function"==typeof t&&(this.windows[i].beforeRowOverflow=t)},Te.prototype.setCurrentWindow=function(e){this.currentWindow=this.windows[e]},Te.prototype.createTextDecoder=function(e){if("undefined"==typeof TextDecoder)this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(e)}catch(t){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+e+" encoding. "+t})}};var ve=function(e){e=e||{},ve.prototype.init.call(this);var t,i=this,s=e.captionServices||{},n={};Object.keys(s).forEach((e=>{t=s[e],/^SERVICE/.test(e)&&(n[e]=t.encoding)})),this.serviceEncodings=n,this.current708Packet=null,this.services={},this.push=function(e){3===e.type?(i.new708Packet(),i.add708Bytes(e)):(null===i.current708Packet&&i.new708Packet(),i.add708Bytes(e))}};ve.prototype=new pe,ve.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},ve.prototype.add708Bytes=function(e){var t=e.ccData,i=t>>>8,s=255&t;this.current708Packet.ptsVals.push(e.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(s)},ve.prototype.push708Packet=function(){var e=this.current708Packet,t=e.data,i=null,s=null,n=0,r=t[n++];for(e.seq=r>>6,e.sizeCode=63&r;n<t.length;n++)s=31&(r=t[n++]),7==(i=r>>5)&&s>0&&(i=r=t[n++]),this.pushServiceBlock(i,n,s),s>0&&(n+=s-1)},ve.prototype.pushServiceBlock=function(e,t,i){var s,n=t,r=this.current708Packet.data,a=this.services[e];for(a||(a=this.initService(e,n));n<t+i&&n<r.length;n++)s=r[n],_e(s)?n=this.handleText(n,a):24===s?n=this.multiByteCharacter(n,a):16===s?n=this.extendedCommands(n,a):128<=s&&s<=135?n=this.setCurrentWindow(n,a):152<=s&&s<=159?n=this.defineWindow(n,a):136===s?n=this.clearWindows(n,a):140===s?n=this.deleteWindows(n,a):137===s?n=this.displayWindows(n,a):138===s?n=this.hideWindows(n,a):139===s?n=this.toggleWindows(n,a):151===s?n=this.setWindowAttributes(n,a):144===s?n=this.setPenAttributes(n,a):145===s?n=this.setPenColor(n,a):146===s?n=this.setPenLocation(n,a):143===s?a=this.reset(n,a):8===s?a.currentWindow.backspace():12===s?a.currentWindow.clearText():13===s?a.currentWindow.pendingNewLine=!0:14===s?a.currentWindow.clearText():141===s&&n++},ve.prototype.extendedCommands=function(e,t){var i=this.current708Packet.data[++e];return _e(i)&&(e=this.handleText(e,t,{isExtended:!0})),e},ve.prototype.getPts=function(e){return this.current708Packet.ptsVals[Math.floor(e/2)]},ve.prototype.initService=function(e,t){var i,s,n=this;return(i="SERVICE"+e)in this.serviceEncodings&&(s=this.serviceEncodings[i]),this.services[e]=new Te(e,s,n),this.services[e].init(this.getPts(t),(function(t){n.flushDisplayed(t,n.services[e])})),this.services[e]},ve.prototype.handleText=function(e,t,i){var s,n,r,a,o=i&&i.isExtended,l=i&&i.isMultiByte,d=this.current708Packet.data,h=o?4096:0,u=d[e],c=d[e+1],p=t.currentWindow;return t.textDecoder_&&!o?(l?(n=[u,c],e++):n=[u],s=t.textDecoder_.decode(new Uint8Array(n))):(a=fe[r=h|u]||r,s=4096&r&&r===a?"":String.fromCharCode(a)),p.pendingNewLine&&!p.isEmpty()&&p.newLine(this.getPts(e)),p.pendingNewLine=!1,p.addText(s),e},ve.prototype.multiByteCharacter=function(e,t){var i=this.current708Packet.data,s=i[e+1],n=i[e+2];return _e(s)&&_e(n)&&(e=this.handleText(++e,t,{isMultiByte:!0})),e},ve.prototype.setCurrentWindow=function(e,t){var i=7&this.current708Packet.data[e];return t.setCurrentWindow(i),e},ve.prototype.defineWindow=function(e,t){var i=this.current708Packet.data,s=i[e],n=7&s;t.setCurrentWindow(n);var r=t.currentWindow;return s=i[++e],r.visible=(32&s)>>5,r.rowLock=(16&s)>>4,r.columnLock=(8&s)>>3,r.priority=7&s,s=i[++e],r.relativePositioning=(128&s)>>7,r.anchorVertical=127&s,s=i[++e],r.anchorHorizontal=s,s=i[++e],r.anchorPoint=(240&s)>>4,r.rowCount=15&s,s=i[++e],r.columnCount=63&s,s=i[++e],r.windowStyle=(56&s)>>3,r.penStyle=7&s,r.virtualRowCount=r.rowCount+1,e},ve.prototype.setWindowAttributes=function(e,t){var i=this.current708Packet.data,s=i[e],n=t.currentWindow.winAttr;return s=i[++e],n.fillOpacity=(192&s)>>6,n.fillRed=(48&s)>>4,n.fillGreen=(12&s)>>2,n.fillBlue=3&s,s=i[++e],n.borderType=(192&s)>>6,n.borderRed=(48&s)>>4,n.borderGreen=(12&s)>>2,n.borderBlue=3&s,s=i[++e],n.borderType+=(128&s)>>5,n.wordWrap=(64&s)>>6,n.printDirection=(48&s)>>4,n.scrollDirection=(12&s)>>2,n.justify=3&s,s=i[++e],n.effectSpeed=(240&s)>>4,n.effectDirection=(12&s)>>2,n.displayEffect=3&s,e},ve.prototype.flushDisplayed=function(e,t){for(var i=[],s=0;s<8;s++)t.windows[s].visible&&!t.windows[s].isEmpty()&&i.push(t.windows[s].getText());t.endPts=e,t.text=i.join("\n\n"),this.pushCaption(t),t.startPts=e},ve.prototype.pushCaption=function(e){""!==e.text&&(this.trigger("data",{startPts:e.startPts,endPts:e.endPts,text:e.text,stream:"cc708_"+e.serviceNum}),e.text="",e.startPts=e.endPts)},ve.prototype.displayWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var n=0;n<8;n++)i&1<<n&&(t.windows[n].visible=1);return e},ve.prototype.hideWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var n=0;n<8;n++)i&1<<n&&(t.windows[n].visible=0);return e},ve.prototype.toggleWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var n=0;n<8;n++)i&1<<n&&(t.windows[n].visible^=1);return e},ve.prototype.clearWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var n=0;n<8;n++)i&1<<n&&t.windows[n].clearText();return e},ve.prototype.deleteWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var n=0;n<8;n++)i&1<<n&&t.windows[n].reset();return e},ve.prototype.setPenAttributes=function(e,t){var i=this.current708Packet.data,s=i[e],n=t.currentWindow.penAttr;return s=i[++e],n.textTag=(240&s)>>4,n.offset=(12&s)>>2,n.penSize=3&s,s=i[++e],n.italics=(128&s)>>7,n.underline=(64&s)>>6,n.edgeType=(56&s)>>3,n.fontStyle=7&s,e},ve.prototype.setPenColor=function(e,t){var i=this.current708Packet.data,s=i[e],n=t.currentWindow.penColor;return s=i[++e],n.fgOpacity=(192&s)>>6,n.fgRed=(48&s)>>4,n.fgGreen=(12&s)>>2,n.fgBlue=3&s,s=i[++e],n.bgOpacity=(192&s)>>6,n.bgRed=(48&s)>>4,n.bgGreen=(12&s)>>2,n.bgBlue=3&s,s=i[++e],n.edgeRed=(48&s)>>4,n.edgeGreen=(12&s)>>2,n.edgeBlue=3&s,e},ve.prototype.setPenLocation=function(e,t){var i=this.current708Packet.data,s=i[e],n=t.currentWindow.penLoc;return t.currentWindow.pendingNewLine=!0,s=i[++e],n.row=15&s,s=i[++e],n.column=63&s,e},ve.prototype.reset=function(e,t){var i=this.getPts(e);return this.flushDisplayed(i,t),this.initService(t.serviceNum,e)};var be={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},Se=function(e){return null===e?"":(e=be[e]||e,String.fromCharCode(e))},Ce=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],ke=function(){for(var e=[],t=15;t--;)e.push("");return e},Ee=function(e,t){Ee.prototype.init.call(this),this.field_=e||0,this.dataChannel_=t||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(e){var t,i,s,n,r;if((t=32639&e.ccData)!==this.lastControlCode_){if(4096==(61440&t)?this.lastControlCode_=t:t!==this.PADDING_&&(this.lastControlCode_=null),s=t>>>8,n=255&t,t!==this.PADDING_)if(t===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(t===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(e.pts),this.flushDisplayed(e.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(e.pts);else if(t===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(e.pts);else if(t===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(e.pts);else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=ke();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=ke();else if(t===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=ke()),this.mode_="paintOn",this.startPts_=e.pts;else if(this.isSpecialCharacter(s,n))r=Se((s=(3&s)<<8)|n),this[this.mode_](e.pts,r),this.column_++;else if(this.isExtCharacter(s,n))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),r=Se((s=(3&s)<<8)|n),this[this.mode_](e.pts,r),this.column_++;else if(this.isMidRowCode(s,n))this.clearFormatting(e.pts),this[this.mode_](e.pts," "),this.column_++,14==(14&n)&&this.addFormatting(e.pts,["i"]),1==(1&n)&&this.addFormatting(e.pts,["u"]);else if(this.isOffsetControlCode(s,n))this.column_+=3&n;else if(this.isPAC(s,n)){var a=Ce.indexOf(7968&t);"rollUp"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(e.pts,a)),a!==this.row_&&(this.clearFormatting(e.pts),this.row_=a),1&n&&-1===this.formatting_.indexOf("u")&&this.addFormatting(e.pts,["u"]),16==(16&t)&&(this.column_=4*((14&t)>>1)),this.isColorPAC(n)&&14==(14&n)&&this.addFormatting(e.pts,["i"])}else this.isNormalChar(s)&&(0===n&&(n=null),r=Se(s),r+=Se(n),this[this.mode_](e.pts,r),this.column_+=r.length)}else this.lastControlCode_=null}};Ee.prototype=new pe,Ee.prototype.flushDisplayed=function(e){var t=this.displayed_.map((function(e,t){try{return e.trim()}catch(e){return this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+t+"."}),""}}),this).join("\n").replace(/^\n+|\n+$/g,"");t.length&&this.trigger("data",{startPts:this.startPts_,endPts:e,text:t,stream:this.name_})},Ee.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=ke(),this.nonDisplayed_=ke(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},Ee.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},Ee.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},Ee.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},Ee.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},Ee.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},Ee.prototype.isPAC=function(e,t){return e>=this.BASE_&&e<this.BASE_+8&&t>=64&&t<=127},Ee.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},Ee.prototype.isNormalChar=function(e){return e>=32&&e<=127},Ee.prototype.setRollUp=function(e,t){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(e),this.nonDisplayed_=ke(),this.displayed_=ke()),void 0!==t&&t!==this.row_)for(var i=0;i<this.rollUpRows_;i++)this.displayed_[t-i]=this.displayed_[this.row_-i],this.displayed_[this.row_-i]="";void 0===t&&(t=this.row_),this.topRow_=t-this.rollUpRows_+1},Ee.prototype.addFormatting=function(e,t){this.formatting_=this.formatting_.concat(t);var i=t.reduce((function(e,t){return e+"<"+t+">"}),"");this[this.mode_](e,i)},Ee.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce((function(e,t){return e+"</"+t+">"}),"");this.formatting_=[],this[this.mode_](e,t)}},Ee.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i},Ee.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i},Ee.prototype.shiftRowsUp_=function(){var e;for(e=0;e<this.topRow_;e++)this.displayed_[e]="";for(e=this.row_+1;e<15;e++)this.displayed_[e]="";for(e=this.topRow_;e<this.row_;e++)this.displayed_[e]=this.displayed_[e+1];this.displayed_[this.row_]=""},Ee.prototype.paintOn=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i};var we={CaptionStream:ge,Cea608Stream:Ee,Cea708Stream:ve},Ie={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},xe=H,Pe="shared",Ae=function(e,t){var i=1;for(e>t&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e},Le=function(e){var t,i;Le.prototype.init.call(this),this.type_=e||Pe,this.push=function(e){this.type_!==Pe&&e.type!==this.type_||(void 0===i&&(i=e.dts),e.dts=Ae(e.dts,i),e.pts=Ae(e.pts,i),t=e.dts,this.trigger("data",e))},this.flush=function(){i=t,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){i=void 0,t=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};Le.prototype=new xe;var Oe,De={TimestampRolloverStream:Le,handleRollover:Ae},Me=(e,t,i)=>{if(!e)return-1;for(var s=i;s<e.length;s++)if(e[s]===t)return s;return-1},Re=function(e,t,i){var s,n="";for(s=t;s<i;s++)n+="%"+("00"+e[s].toString(16)).slice(-2);return n},$e=function(e,t,i){return decodeURIComponent(Re(e,t,i))},Ue=function(e,t,i){return unescape(Re(e,t,i))},Be=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},Ne={APIC:function(e){var t,i,s=1;3===e.data[0]&&((t=Me(e.data,0,s))<0||(e.mimeType=Ue(e.data,s,t),s=t+1,e.pictureType=e.data[s],s++,(i=Me(e.data,0,s))<0||(e.description=$e(e.data,s,i),s=i+1,"--\x3e"===e.mimeType?e.url=Ue(e.data,s,e.data.length):e.pictureData=e.data.subarray(s,e.data.length))))},"T*":function(e){3===e.data[0]&&(e.value=$e(e.data,1,e.data.length).replace(/\0*$/,""),e.values=e.value.split("\0"))},TXXX:function(e){var t;3===e.data[0]&&-1!==(t=Me(e.data,0,1))&&(e.description=$e(e.data,1,t),e.value=$e(e.data,t+1,e.data.length).replace(/\0*$/,""),e.data=e.value)},"W*":function(e){e.url=Ue(e.data,0,e.data.length).replace(/\0.*$/,"")},WXXX:function(e){var t;3===e.data[0]&&-1!==(t=Me(e.data,0,1))&&(e.description=$e(e.data,1,t),e.url=Ue(e.data,t+1,e.data.length).replace(/\0.*$/,""))},PRIV:function(e){var t;for(t=0;t<e.data.length;t++)if(0===e.data[t]){e.owner=Ue(e.data,0,t);break}e.privateData=e.data.subarray(t+1),e.data=e.privateData}},Fe={parseId3Frames:function(e){var t,i=10,s=0,n=[];if(!(e.length<10||e[0]!=="I".charCodeAt(0)||e[1]!=="D".charCodeAt(0)||e[2]!=="3".charCodeAt(0))){s=Be(e.subarray(6,10)),s+=10,64&e[5]&&(i+=4,i+=Be(e.subarray(10,14)),s-=Be(e.subarray(16,20)));do{if((t=Be(e.subarray(i+4,i+8)))<1)break;var r={id:String.fromCharCode(e[i],e[i+1],e[i+2],e[i+3]),data:e.subarray(i+10,i+t+10)};r.key=r.id,Ne[r.id]?Ne[r.id](r):"T"===r.id[0]?Ne["T*"](r):"W"===r.id[0]&&Ne["W*"](r),n.push(r),i+=10,i+=t}while(i<s);return n}},parseSyncSafeInteger:Be,frameParsers:Ne},je=Ie,He=Fe;(Oe=function(e){var t,i={descriptor:e&&e.descriptor},s=0,n=[],r=0;if(Oe.prototype.init.call(this),this.dispatchType=je.METADATA_STREAM_TYPE.toString(16),i.descriptor)for(t=0;t<i.descriptor.length;t++)this.dispatchType+=("00"+i.descriptor[t].toString(16)).slice(-2);this.push=function(e){var t,i,a,o,l;if("timed-metadata"===e.type)if(e.dataAlignmentIndicator&&(r=0,n.length=0),0===n.length&&(e.data.length<10||e.data[0]!=="I".charCodeAt(0)||e.data[1]!=="D".charCodeAt(0)||e.data[2]!=="3".charCodeAt(0)))this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});else if(n.push(e),r+=e.data.byteLength,1===n.length&&(s=He.parseSyncSafeInteger(e.data.subarray(6,10)),s+=10),!(r<s)){for(t={data:new Uint8Array(s),frames:[],pts:n[0].pts,dts:n[0].dts},l=0;l<s;)t.data.set(n[0].data.subarray(0,s-l),l),l+=n[0].data.byteLength,r-=n[0].data.byteLength,n.shift();i=10,64&t.data[5]&&(i+=4,i+=He.parseSyncSafeInteger(t.data.subarray(10,14)),s-=He.parseSyncSafeInteger(t.data.subarray(16,20)));do{if((a=He.parseSyncSafeInteger(t.data.subarray(i+4,i+8)))<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if((o={id:String.fromCharCode(t.data[i],t.data[i+1],t.data[i+2],t.data[i+3]),data:t.data.subarray(i+10,i+a+10)}).key=o.id,He.frameParsers[o.id]?He.frameParsers[o.id](o):"T"===o.id[0]?He.frameParsers["T*"](o):"W"===o.id[0]&&He.frameParsers["W*"](o),"com.apple.streaming.transportStreamTimestamp"===o.owner){var d=o.data,h=(1&d[3])<<30|d[4]<<22|d[5]<<14|d[6]<<6|d[7]>>>2;h*=4,h+=3&d[7],o.timeStamp=h,void 0===t.pts&&void 0===t.dts&&(t.pts=o.timeStamp,t.dts=o.timeStamp),this.trigger("timestamp",o)}t.frames.push(o),i+=10,i+=a}while(i<s);this.trigger("data",t)}}}).prototype=new H;var Ve,qe,We,Ge=Oe,Ke=H,ze=we,Qe=Ie,Ye=De.TimestampRolloverStream,Xe=188;(Ve=function(){var e=new Uint8Array(Xe),t=0;Ve.prototype.init.call(this),this.push=function(i){var s,n=0,r=Xe;for(t?((s=new Uint8Array(i.byteLength+t)).set(e.subarray(0,t)),s.set(i,t),t=0):s=i;r<s.byteLength;)71!==s[n]||71!==s[r]?(n++,r++):(this.trigger("data",s.subarray(n,r)),n+=Xe,r+=Xe);n<s.byteLength&&(e.set(s.subarray(n),0),t=s.byteLength-n)},this.flush=function(){t===Xe&&71===e[0]&&(this.trigger("data",e),t=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){t=0,this.trigger("reset")}}).prototype=new Ke,(qe=function(){var e,t,i,s;qe.prototype.init.call(this),s=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,e=function(e,s){var n=0;s.payloadUnitStartIndicator&&(n+=e[n]+1),"pat"===s.type?t(e.subarray(n),s):i(e.subarray(n),s)},t=function(e,t){t.section_number=e[7],t.last_section_number=e[8],s.pmtPid=(31&e[10])<<8|e[11],t.pmtPid=s.pmtPid},i=function(e,t){var i,n;if(1&e[5]){for(s.programMapTable={video:null,audio:null,"timed-metadata":{}},i=3+((15&e[1])<<8|e[2])-4,n=12+((15&e[10])<<8|e[11]);n<i;){var r=e[n],a=(31&e[n+1])<<8|e[n+2];r===Qe.H264_STREAM_TYPE&&null===s.programMapTable.video?s.programMapTable.video=a:r===Qe.ADTS_STREAM_TYPE&&null===s.programMapTable.audio?s.programMapTable.audio=a:r===Qe.METADATA_STREAM_TYPE&&(s.programMapTable["timed-metadata"][a]=r),n+=5+((15&e[n+3])<<8|e[n+4])}t.programMapTable=s.programMapTable}},this.push=function(t){var i={},s=4;if(i.payloadUnitStartIndicator=!!(64&t[1]),i.pid=31&t[1],i.pid<<=8,i.pid|=t[2],(48&t[3])>>>4>1&&(s+=t[s]+1),0===i.pid)i.type="pat",e(t.subarray(s),i),this.trigger("data",i);else if(i.pid===this.pmtPid)for(i.type="pmt",e(t.subarray(s),i),this.trigger("data",i);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([t,s,i]):this.processPes_(t,s,i)},this.processPes_=function(e,t,i){i.pid===this.programMapTable.video?i.streamType=Qe.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=Qe.ADTS_STREAM_TYPE:i.streamType=this.programMapTable["timed-metadata"][i.pid],i.type="pes",i.data=e.subarray(t),this.trigger("data",i)}}).prototype=new Ke,qe.STREAM_TYPES={h264:27,adts:15},(We=function(){var e,t=this,i=!1,s={data:[],size:0},n={data:[],size:0},r={data:[],size:0},a=function(e,i,s){var n,r,a=new Uint8Array(e.size),o={type:i},l=0,d=0;if(e.data.length&&!(e.size<9)){for(o.trackId=e.data[0].pid,l=0;l<e.data.length;l++)r=e.data[l],a.set(r.data,d),d+=r.data.byteLength;!function(e,t){var i;const s=e[0]<<16|e[1]<<8|e[2];t.data=new Uint8Array,1===s&&(t.packetLength=6+(e[4]<<8|e[5]),t.dataAlignmentIndicator=0!=(4&e[6]),192&(i=e[7])&&(t.pts=(14&e[9])<<27|(255&e[10])<<20|(254&e[11])<<12|(255&e[12])<<5|(254&e[13])>>>3,t.pts*=4,t.pts+=(6&e[13])>>>1,t.dts=t.pts,64&i&&(t.dts=(14&e[14])<<27|(255&e[15])<<20|(254&e[16])<<12|(255&e[17])<<5|(254&e[18])>>>3,t.dts*=4,t.dts+=(6&e[18])>>>1)),t.data=e.subarray(9+e[8]))}(a,o),n="video"===i||o.packetLength<=e.size,(s||n)&&(e.size=0,e.data.length=0),n&&t.trigger("data",o)}};We.prototype.init.call(this),this.push=function(o){({pat:function(){},pes:function(){var e,t;switch(o.streamType){case Qe.H264_STREAM_TYPE:e=s,t="video";break;case Qe.ADTS_STREAM_TYPE:e=n,t="audio";break;case Qe.METADATA_STREAM_TYPE:e=r,t="timed-metadata";break;default:return}o.payloadUnitStartIndicator&&a(e,t,!0),e.data.push(o),e.size+=o.data.byteLength},pmt:function(){var s={type:"metadata",tracks:[]};null!==(e=o.programMapTable).video&&s.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.video,codec:"avc",type:"video"}),null!==e.audio&&s.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.audio,codec:"adts",type:"audio"}),i=!0,t.trigger("data",s)}})[o.type]()},this.reset=function(){s.size=0,s.data.length=0,n.size=0,n.data.length=0,this.trigger("reset")},this.flushStreams_=function(){a(s,"video"),a(n,"audio"),a(r,"timed-metadata")},this.flush=function(){if(!i&&e){var s={type:"metadata",tracks:[]};null!==e.video&&s.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.video,codec:"avc",type:"video"}),null!==e.audio&&s.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.audio,codec:"adts",type:"audio"}),t.trigger("data",s)}i=!1,this.flushStreams_(),this.trigger("done")}}).prototype=new Ke;var Je={PAT_PID:0,MP2T_PACKET_LENGTH:Xe,TransportPacketStream:Ve,TransportParseStream:qe,ElementaryStream:We,TimestampRolloverStream:Ye,CaptionStream:ze.CaptionStream,Cea608Stream:ze.Cea608Stream,Cea708Stream:ze.Cea708Stream,MetadataStream:Ge};for(var Ze in Qe)Qe.hasOwnProperty(Ze)&&(Je[Ze]=Qe[Ze]);var et,tt=Je,it=oe.ONE_SECOND_IN_TS,st=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];(et=function(e){var t,i=0;et.prototype.init.call(this),this.skipWarn_=function(e,t){this.trigger("log",{level:"warn",message:`adts skiping bytes ${e} to ${t} in frame ${i} outside syncword`})},this.push=function(s){var n,r,a,o,l,d=0;if(e||(i=0),"audio"===s.type){var h;for(t&&t.length?(a=t,(t=new Uint8Array(a.byteLength+s.data.byteLength)).set(a),t.set(s.data,a.byteLength)):t=s.data;d+7<t.length;)if(255===t[d]&&240==(246&t[d+1])){if("number"==typeof h&&(this.skipWarn_(h,d),h=null),r=2*(1&~t[d+1]),n=(3&t[d+3])<<11|t[d+4]<<3|(224&t[d+5])>>5,l=(o=1024*(1+(3&t[d+6])))*it/st[(60&t[d+2])>>>2],t.byteLength-d<n)break;this.trigger("data",{pts:s.pts+i*l,dts:s.dts+i*l,sampleCount:o,audioobjecttype:1+(t[d+2]>>>6&3),channelcount:(1&t[d+2])<<2|(192&t[d+3])>>>6,samplerate:st[(60&t[d+2])>>>2],samplingfrequencyindex:(60&t[d+2])>>>2,samplesize:16,data:t.subarray(d+7+r,d+n)}),i++,d+=n}else"number"!=typeof h&&(h=d),d++;"number"==typeof h&&(this.skipWarn_(h,d),h=null),t=t.subarray(d)}},this.flush=function(){i=0,this.trigger("done")},this.reset=function(){t=void 0,this.trigger("reset")},this.endTimeline=function(){t=void 0,this.trigger("endedtimeline")}}).prototype=new H;var nt,rt,at,ot=et,lt=H,dt=function(e){var t=e.byteLength,i=0,s=0;this.length=function(){return 8*t},this.bitsAvailable=function(){return 8*t+s},this.loadWord=function(){var n=e.byteLength-t,r=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");r.set(e.subarray(n,n+a)),i=new DataView(r.buffer).getUint32(0),s=8*a,t-=a},this.skipBits=function(e){var n;s>e?(i<<=e,s-=e):(e-=s,e-=8*(n=Math.floor(e/8)),t-=n,this.loadWord(),i<<=e,s-=e)},this.readBits=function(e){var n=Math.min(s,e),r=i>>>32-n;return(s-=n)>0?i<<=n:t>0&&this.loadWord(),(n=e-n)>0?r<<n|this.readBits(n):r},this.skipLeadingZeros=function(){var e;for(e=0;e<s;++e)if(0!=(i&2147483648>>>e))return i<<=e,s-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};(rt=function(){var e,t,i=0;rt.prototype.init.call(this),this.push=function(s){var n;t?((n=new Uint8Array(t.byteLength+s.data.byteLength)).set(t),n.set(s.data,t.byteLength),t=n):t=s.data;for(var r=t.byteLength;i<r-3;i++)if(1===t[i+2]){e=i+5;break}for(;e<r;)switch(t[e]){case 0:if(0!==t[e-1]){e+=2;break}if(0!==t[e-2]){e++;break}i+3!==e-2&&this.trigger("data",t.subarray(i+3,e-2));do{e++}while(1!==t[e]&&e<r);i=e-2,e+=3;break;case 1:if(0!==t[e-1]||0!==t[e-2]){e+=3;break}this.trigger("data",t.subarray(i+3,e-2)),i=e-2,e+=3;break;default:e+=3}t=t.subarray(i),e-=i,i=0},this.reset=function(){t=null,i=0,this.trigger("reset")},this.flush=function(){t&&t.byteLength>3&&this.trigger("data",t.subarray(i+3)),t=null,i=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}}).prototype=new lt,at={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},(nt=function(){var e,t,i,s,n,r,a,o=new rt;nt.prototype.init.call(this),e=this,this.push=function(e){"video"===e.type&&(t=e.trackId,i=e.pts,s=e.dts,o.push(e))},o.on("data",(function(a){var o={trackId:t,pts:i,dts:s,data:a,nalUnitTypeCode:31&a[0]};switch(o.nalUnitTypeCode){case 5:o.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:o.nalUnitType="sei_rbsp",o.escapedRBSP=n(a.subarray(1));break;case 7:o.nalUnitType="seq_parameter_set_rbsp",o.escapedRBSP=n(a.subarray(1)),o.config=r(o.escapedRBSP);break;case 8:o.nalUnitType="pic_parameter_set_rbsp";break;case 9:o.nalUnitType="access_unit_delimiter_rbsp"}e.trigger("data",o)})),o.on("done",(function(){e.trigger("done")})),o.on("partialdone",(function(){e.trigger("partialdone")})),o.on("reset",(function(){e.trigger("reset")})),o.on("endedtimeline",(function(){e.trigger("endedtimeline")})),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},a=function(e,t){var i,s=8,n=8;for(i=0;i<e;i++)0!==n&&(n=(s+t.readExpGolomb()+256)%256),s=0===n?s:n},n=function(e){for(var t,i,s=e.byteLength,n=[],r=1;r<s-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(n.push(r+2),r+=2):r++;if(0===n.length)return e;t=s-n.length,i=new Uint8Array(t);var a=0;for(r=0;r<t;a++,r++)a===n[0]&&(a++,n.shift()),i[r]=e[a];return i},r=function(e){var t,i,s,n,r,o,l,d,h,u,c,p,m=0,g=0,f=0,_=0,y=[1,1];if(i=(t=new dt(e)).readUnsignedByte(),n=t.readUnsignedByte(),s=t.readUnsignedByte(),t.skipUnsignedExpGolomb(),at[i]&&(3===(r=t.readUnsignedExpGolomb())&&t.skipBits(1),t.skipUnsignedExpGolomb(),t.skipUnsignedExpGolomb(),t.skipBits(1),t.readBoolean()))for(c=3!==r?8:12,p=0;p<c;p++)t.readBoolean()&&a(p<6?16:64,t);if(t.skipUnsignedExpGolomb(),0===(o=t.readUnsignedExpGolomb()))t.readUnsignedExpGolomb();else if(1===o)for(t.skipBits(1),t.skipExpGolomb(),t.skipExpGolomb(),l=t.readUnsignedExpGolomb(),p=0;p<l;p++)t.skipExpGolomb();if(t.skipUnsignedExpGolomb(),t.skipBits(1),d=t.readUnsignedExpGolomb(),h=t.readUnsignedExpGolomb(),0===(u=t.readBits(1))&&t.skipBits(1),t.skipBits(1),t.readBoolean()&&(m=t.readUnsignedExpGolomb(),g=t.readUnsignedExpGolomb(),f=t.readUnsignedExpGolomb(),_=t.readUnsignedExpGolomb()),t.readBoolean()&&t.readBoolean()){switch(t.readUnsignedByte()){case 1:y=[1,1];break;case 2:y=[12,11];break;case 3:y=[10,11];break;case 4:y=[16,11];break;case 5:y=[40,33];break;case 6:y=[24,11];break;case 7:y=[20,11];break;case 8:y=[32,11];break;case 9:y=[80,33];break;case 10:y=[18,11];break;case 11:y=[15,11];break;case 12:y=[64,33];break;case 13:y=[160,99];break;case 14:y=[4,3];break;case 15:y=[3,2];break;case 16:y=[2,1];break;case 255:y=[t.readUnsignedByte()<<8|t.readUnsignedByte(),t.readUnsignedByte()<<8|t.readUnsignedByte()]}y&&(y[0],y[1])}return{profileIdc:i,levelIdc:s,profileCompatibility:n,width:16*(d+1)-2*m-2*g,height:(2-u)*(h+1)*16-2*f-2*_,sarRatio:y}}}).prototype=new lt;var ht,ut={H264Stream:nt,NalByteStream:rt},ct=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],pt=function(e,t){var i=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9];return i=i>=0?i:0,(16&e[t+5])>>4?i+20:i+10},mt=function(e,t){return e.length-t<10||e[t]!=="I".charCodeAt(0)||e[t+1]!=="D".charCodeAt(0)||e[t+2]!=="3".charCodeAt(0)?t:(t+=pt(e,t),mt(e,t))},gt=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},ft={isLikelyAacData:function(e){var t=mt(e,0);return e.length>=t+2&&255==(255&e[t])&&240==(240&e[t+1])&&16==(22&e[t+1])},parseId3TagSize:pt,parseAdtsSize:function(e,t){var i=(224&e[t+5])>>5,s=e[t+4]<<3;return 6144&e[t+3]|s|i},parseType:function(e,t){return e[t]==="I".charCodeAt(0)&&e[t+1]==="D".charCodeAt(0)&&e[t+2]==="3".charCodeAt(0)?"timed-metadata":!0&e[t]&&240==(240&e[t+1])?"audio":null},parseSampleRate:function(e){for(var t=0;t+5<e.length;){if(255===e[t]&&240==(246&e[t+1]))return ct[(60&e[t+2])>>>2];t++}return null},parseAacTimestamp:function(e){var t,i,s;t=10,64&e[5]&&(t+=4,t+=gt(e.subarray(10,14)));do{if((i=gt(e.subarray(t+4,t+8)))<1)return null;if("PRIV"===String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3])){s=e.subarray(t+10,t+i+10);for(var n=0;n<s.byteLength;n++)if(0===s[n]){if("com.apple.streaming.transportStreamTimestamp"===unescape(function(e,t,i){var s,n="";for(s=0;s<i;s++)n+="%"+("00"+e[s].toString(16)).slice(-2);return n}(s,0,n))){var r=s.subarray(n+1),a=(1&r[3])<<30|r[4]<<22|r[5]<<14|r[6]<<6|r[7]>>>2;return(a*=4)+(3&r[7])}break}}t+=10,t+=i}while(t<e.byteLength);return null}},_t=ft;(ht=function(){var e=new Uint8Array,t=0;ht.prototype.init.call(this),this.setTimestamp=function(e){t=e},this.push=function(i){var s,n,r,a,o=0,l=0;for(e.length?(a=e.length,(e=new Uint8Array(i.byteLength+a)).set(e.subarray(0,a)),e.set(i,a)):e=i;e.length-l>=3;)if(e[l]!=="I".charCodeAt(0)||e[l+1]!=="D".charCodeAt(0)||e[l+2]!=="3".charCodeAt(0))if(255!=(255&e[l])||240!=(240&e[l+1]))l++;else{if(e.length-l<7)break;if(l+(o=_t.parseAdtsSize(e,l))>e.length)break;r={type:"audio",data:e.subarray(l,l+o),pts:t,dts:t},this.trigger("data",r),l+=o}else{if(e.length-l<10)break;if(l+(o=_t.parseId3TagSize(e,l))>e.length)break;n={type:"timed-metadata",data:e.subarray(l,l+o)},this.trigger("data",n),l+=o}s=e.length-l,e=s>0?e.subarray(l):new Uint8Array},this.reset=function(){e=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){e=new Uint8Array,this.trigger("endedtimeline")}}).prototype=new H;var yt,Tt,vt,bt,St=H,Ct=ee,kt=ie,Et=de,wt=ue,It=tt,xt=oe,Pt=ot,At=ut.H264Stream,Lt=ht,Ot=ft.isLikelyAacData,Dt=oe.ONE_SECOND_IN_TS,Mt=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Rt=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],$t=function(e,t){t.stream=e,this.trigger("log",t)},Ut=function(e,t){for(var i=Object.keys(t),s=0;s<i.length;s++){var n=i[s];"headOfPipeline"!==n&&t[n].on&&t[n].on("log",$t.bind(e,n))}},Bt=function(e,t){var i;if(e.length!==t.length)return!1;for(i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0},Nt=function(e,t,i,s,n,r){return{start:{dts:e,pts:e+(i-t)},end:{dts:e+(s-t),pts:e+(n-i)},prependedContentDuration:r,baseMediaDecodeTime:e}};(Tt=function(e,t){var i,s=[],n=0,r=0,a=1/0;i=(t=t||{}).firstSequenceNumber||0,Tt.prototype.init.call(this),this.push=function(t){wt.collectDtsInfo(e,t),e&&Mt.forEach((function(i){e[i]=t[i]})),s.push(t)},this.setEarliestDts=function(e){n=e},this.setVideoBaseMediaDecodeTime=function(e){a=e},this.setAudioAppendStart=function(e){r=e},this.flush=function(){var o,l,d,h,u,c,p;0!==s.length?(o=Et.trimAdtsFramesByEarliestDts(s,e,n),e.baseMediaDecodeTime=wt.calculateTrackBaseMediaDecodeTime(e,t.keepOriginalTimestamps),p=Et.prefixWithSilence(e,o,r,a),e.samples=Et.generateSampleTable(o),d=Ct.mdat(Et.concatenateFrameData(o)),s=[],l=Ct.moof(i,[e]),h=new Uint8Array(l.byteLength+d.byteLength),i++,h.set(l),h.set(d,l.byteLength),wt.clearDtsInfo(e),u=Math.ceil(1024*Dt/e.samplerate),o.length&&(c=o.length*u,this.trigger("segmentTimingInfo",Nt(xt.audioTsToVideoTs(e.baseMediaDecodeTime,e.samplerate),o[0].dts,o[0].pts,o[0].dts+c,o[0].pts+c,p||0)),this.trigger("timingInfo",{start:o[0].pts,end:o[0].pts+c})),this.trigger("data",{track:e,boxes:h}),this.trigger("done","AudioSegmentStream")):this.trigger("done","AudioSegmentStream")},this.reset=function(){wt.clearDtsInfo(e),s=[],this.trigger("reset")}}).prototype=new St,(yt=function(e,t){var i,s,n,r=[],a=[];i=(t=t||{}).firstSequenceNumber||0,yt.prototype.init.call(this),delete e.minPTS,this.gopCache_=[],this.push=function(t){wt.collectDtsInfo(e,t),"seq_parameter_set_rbsp"!==t.nalUnitType||s||(s=t.config,e.sps=[t.data],Rt.forEach((function(t){e[t]=s[t]}),this)),"pic_parameter_set_rbsp"!==t.nalUnitType||n||(n=t.data,e.pps=[t.data]),r.push(t)},this.flush=function(){for(var s,n,o,l,d,h,u,c,p=0;r.length&&"access_unit_delimiter_rbsp"!==r[0].nalUnitType;)r.shift();if(0===r.length)return this.resetStream_(),void this.trigger("done","VideoSegmentStream");if(s=kt.groupNalsIntoFrames(r),(o=kt.groupFramesIntoGops(s))[0][0].keyFrame||((n=this.getGopForFusion_(r[0],e))?(p=n.duration,o.unshift(n),o.byteLength+=n.byteLength,o.nalCount+=n.nalCount,o.pts=n.pts,o.dts=n.dts,o.duration+=n.duration):o=kt.extendFirstKeyFrame(o)),a.length){var m;if(!(m=t.alignGopsAtEnd?this.alignGopsAtEnd_(o):this.alignGopsAtStart_(o)))return this.gopCache_.unshift({gop:o.pop(),pps:e.pps,sps:e.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),r=[],this.resetStream_(),void this.trigger("done","VideoSegmentStream");wt.clearDtsInfo(e),o=m}wt.collectDtsInfo(e,o),e.samples=kt.generateSampleTable(o),d=Ct.mdat(kt.concatenateNalData(o)),e.baseMediaDecodeTime=wt.calculateTrackBaseMediaDecodeTime(e,t.keepOriginalTimestamps),this.trigger("processedGopsInfo",o.map((function(e){return{pts:e.pts,dts:e.dts,byteLength:e.byteLength}}))),u=o[0],c=o[o.length-1],this.trigger("segmentTimingInfo",Nt(e.baseMediaDecodeTime,u.dts,u.pts,c.dts+c.duration,c.pts+c.duration,p)),this.trigger("timingInfo",{start:o[0].pts,end:o[o.length-1].pts+o[o.length-1].duration}),this.gopCache_.unshift({gop:o.pop(),pps:e.pps,sps:e.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),r=[],this.trigger("baseMediaDecodeTime",e.baseMediaDecodeTime),this.trigger("timelineStartInfo",e.timelineStartInfo),l=Ct.moof(i,[e]),h=new Uint8Array(l.byteLength+d.byteLength),i++,h.set(l),h.set(d,l.byteLength),this.trigger("data",{track:e,boxes:h}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),r=[],this.gopCache_.length=0,a.length=0,this.trigger("reset")},this.resetStream_=function(){wt.clearDtsInfo(e),s=void 0,n=void 0},this.getGopForFusion_=function(t){var i,s,n,r,a,o=1/0;for(a=0;a<this.gopCache_.length;a++)n=(r=this.gopCache_[a]).gop,e.pps&&Bt(e.pps[0],r.pps[0])&&e.sps&&Bt(e.sps[0],r.sps[0])&&(n.dts<e.timelineStartInfo.dts||(i=t.dts-n.dts-n.duration)>=-1e4&&i<=45e3&&(!s||o>i)&&(s=r,o=i));return s?s.gop:null},this.alignGopsAtStart_=function(e){var t,i,s,n,r,o,l,d;for(r=e.byteLength,o=e.nalCount,l=e.duration,t=i=0;t<a.length&&i<e.length&&(s=a[t],n=e[i],s.pts!==n.pts);)n.pts>s.pts?t++:(i++,r-=n.byteLength,o-=n.nalCount,l-=n.duration);return 0===i?e:i===e.length?null:((d=e.slice(i)).byteLength=r,d.duration=l,d.nalCount=o,d.pts=d[0].pts,d.dts=d[0].dts,d)},this.alignGopsAtEnd_=function(e){var t,i,s,n,r,o,l;for(t=a.length-1,i=e.length-1,r=null,o=!1;t>=0&&i>=0;){if(s=a[t],n=e[i],s.pts===n.pts){o=!0;break}s.pts>n.pts?t--:(t===a.length-1&&(r=i),i--)}if(!o&&null===r)return null;if(0===(l=o?i:r))return e;var d=e.slice(l),h=d.reduce((function(e,t){return e.byteLength+=t.byteLength,e.duration+=t.duration,e.nalCount+=t.nalCount,e}),{byteLength:0,duration:0,nalCount:0});return d.byteLength=h.byteLength,d.duration=h.duration,d.nalCount=h.nalCount,d.pts=d[0].pts,d.dts=d[0].dts,d},this.alignGopsWith=function(e){a=e}}).prototype=new St,(bt=function(e,t){this.numberOfTracks=0,this.metadataStream=t,void 0!==(e=e||{}).remux?this.remuxTracks=!!e.remux:this.remuxTracks=!0,"boolean"==typeof e.keepOriginalTimestamps?this.keepOriginalTimestamps=e.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,bt.prototype.init.call(this),this.push=function(e){return e.text?this.pendingCaptions.push(e):e.frames?this.pendingMetadata.push(e):(this.pendingTracks.push(e.track),this.pendingBytes+=e.boxes.byteLength,"video"===e.track.type&&(this.videoTrack=e.track,this.pendingBoxes.push(e.boxes)),void("audio"===e.track.type&&(this.audioTrack=e.track,this.pendingBoxes.unshift(e.boxes))))}}).prototype=new St,bt.prototype.flush=function(e){var t,i,s,n,r=0,a={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length<this.numberOfTracks){if("VideoSegmentStream"!==e&&"AudioSegmentStream"!==e)return;if(this.remuxTracks)return;if(0===this.pendingTracks.length)return this.emittedTracks++,void(this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,Rt.forEach((function(e){a.info[e]=this.videoTrack[e]}),this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,Mt.forEach((function(e){a.info[e]=this.audioTrack[e]}),this)),this.videoTrack||this.audioTrack){for(1===this.pendingTracks.length?a.type=this.pendingTracks[0].type:a.type="combined",this.emittedTracks+=this.pendingTracks.length,s=Ct.initSegment(this.pendingTracks),a.initSegment=new Uint8Array(s.byteLength),a.initSegment.set(s),a.data=new Uint8Array(this.pendingBytes),n=0;n<this.pendingBoxes.length;n++)a.data.set(this.pendingBoxes[n],r),r+=this.pendingBoxes[n].byteLength;for(n=0;n<this.pendingCaptions.length;n++)(t=this.pendingCaptions[n]).startTime=xt.metadataTsToSeconds(t.startPts,o,this.keepOriginalTimestamps),t.endTime=xt.metadataTsToSeconds(t.endPts,o,this.keepOriginalTimestamps),a.captionStreams[t.stream]=!0,a.captions.push(t);for(n=0;n<this.pendingMetadata.length;n++)(i=this.pendingMetadata[n]).cueTime=xt.metadataTsToSeconds(i.pts,o,this.keepOriginalTimestamps),a.metadata.push(i);for(a.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",a),n=0;n<a.captions.length;n++)t=a.captions[n],this.trigger("caption",t);for(n=0;n<a.metadata.length;n++)i=a.metadata[n],this.trigger("id3Frame",i)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},bt.prototype.setRemux=function(e){this.remuxTracks=e},(vt=function(e){var t,i,s=this,n=!0;vt.prototype.init.call(this),e=e||{},this.baseMediaDecodeTime=e.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var n={};this.transmuxPipeline_=n,n.type="aac",n.metadataStream=new It.MetadataStream,n.aacStream=new Lt,n.audioTimestampRolloverStream=new It.TimestampRolloverStream("audio"),n.timedMetadataTimestampRolloverStream=new It.TimestampRolloverStream("timed-metadata"),n.adtsStream=new Pt,n.coalesceStream=new bt(e,n.metadataStream),n.headOfPipeline=n.aacStream,n.aacStream.pipe(n.audioTimestampRolloverStream).pipe(n.adtsStream),n.aacStream.pipe(n.timedMetadataTimestampRolloverStream).pipe(n.metadataStream).pipe(n.coalesceStream),n.metadataStream.on("timestamp",(function(e){n.aacStream.setTimestamp(e.timeStamp)})),n.aacStream.on("data",(function(r){"timed-metadata"!==r.type&&"audio"!==r.type||n.audioSegmentStream||(i=i||{timelineStartInfo:{baseMediaDecodeTime:s.baseMediaDecodeTime},codec:"adts",type:"audio"},n.coalesceStream.numberOfTracks++,n.audioSegmentStream=new Tt(i,e),n.audioSegmentStream.on("log",s.getLogTrigger_("audioSegmentStream")),n.audioSegmentStream.on("timingInfo",s.trigger.bind(s,"audioTimingInfo")),n.adtsStream.pipe(n.audioSegmentStream).pipe(n.coalesceStream),s.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!t}))})),n.coalesceStream.on("data",this.trigger.bind(this,"data")),n.coalesceStream.on("done",this.trigger.bind(this,"done")),Ut(this,n)},this.setupTsPipeline=function(){var n={};this.transmuxPipeline_=n,n.type="ts",n.metadataStream=new It.MetadataStream,n.packetStream=new It.TransportPacketStream,n.parseStream=new It.TransportParseStream,n.elementaryStream=new It.ElementaryStream,n.timestampRolloverStream=new It.TimestampRolloverStream,n.adtsStream=new Pt,n.h264Stream=new At,n.captionStream=new It.CaptionStream(e),n.coalesceStream=new bt(e,n.metadataStream),n.headOfPipeline=n.packetStream,n.packetStream.pipe(n.parseStream).pipe(n.elementaryStream).pipe(n.timestampRolloverStream),n.timestampRolloverStream.pipe(n.h264Stream),n.timestampRolloverStream.pipe(n.adtsStream),n.timestampRolloverStream.pipe(n.metadataStream).pipe(n.coalesceStream),n.h264Stream.pipe(n.captionStream).pipe(n.coalesceStream),n.elementaryStream.on("data",(function(r){var a;if("metadata"===r.type){for(a=r.tracks.length;a--;)t||"video"!==r.tracks[a].type?i||"audio"!==r.tracks[a].type||((i=r.tracks[a]).timelineStartInfo.baseMediaDecodeTime=s.baseMediaDecodeTime):(t=r.tracks[a]).timelineStartInfo.baseMediaDecodeTime=s.baseMediaDecodeTime;t&&!n.videoSegmentStream&&(n.coalesceStream.numberOfTracks++,n.videoSegmentStream=new yt(t,e),n.videoSegmentStream.on("log",s.getLogTrigger_("videoSegmentStream")),n.videoSegmentStream.on("timelineStartInfo",(function(t){i&&!e.keepOriginalTimestamps&&(i.timelineStartInfo=t,n.audioSegmentStream.setEarliestDts(t.dts-s.baseMediaDecodeTime))})),n.videoSegmentStream.on("processedGopsInfo",s.trigger.bind(s,"gopInfo")),n.videoSegmentStream.on("segmentTimingInfo",s.trigger.bind(s,"videoSegmentTimingInfo")),n.videoSegmentStream.on("baseMediaDecodeTime",(function(e){i&&n.audioSegmentStream.setVideoBaseMediaDecodeTime(e)})),n.videoSegmentStream.on("timingInfo",s.trigger.bind(s,"videoTimingInfo")),n.h264Stream.pipe(n.videoSegmentStream).pipe(n.coalesceStream)),i&&!n.audioSegmentStream&&(n.coalesceStream.numberOfTracks++,n.audioSegmentStream=new Tt(i,e),n.audioSegmentStream.on("log",s.getLogTrigger_("audioSegmentStream")),n.audioSegmentStream.on("timingInfo",s.trigger.bind(s,"audioTimingInfo")),n.audioSegmentStream.on("segmentTimingInfo",s.trigger.bind(s,"audioSegmentTimingInfo")),n.adtsStream.pipe(n.audioSegmentStream).pipe(n.coalesceStream)),s.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!t})}})),n.coalesceStream.on("data",this.trigger.bind(this,"data")),n.coalesceStream.on("id3Frame",(function(e){e.dispatchType=n.metadataStream.dispatchType,s.trigger("id3Frame",e)})),n.coalesceStream.on("caption",this.trigger.bind(this,"caption")),n.coalesceStream.on("done",this.trigger.bind(this,"done")),Ut(this,n)},this.setBaseMediaDecodeTime=function(s){var n=this.transmuxPipeline_;e.keepOriginalTimestamps||(this.baseMediaDecodeTime=s),i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,wt.clearDtsInfo(i),n.audioTimestampRolloverStream&&n.audioTimestampRolloverStream.discontinuity()),t&&(n.videoSegmentStream&&(n.videoSegmentStream.gopCache_=[]),t.timelineStartInfo.dts=void 0,t.timelineStartInfo.pts=void 0,wt.clearDtsInfo(t),n.captionStream.reset()),n.timestampRolloverStream&&n.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(e){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e)},this.setRemux=function(t){var i=this.transmuxPipeline_;e.remux=t,i&&i.coalesceStream&&i.coalesceStream.setRemux(t)},this.alignGopsWith=function(e){t&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(e)},this.getLogTrigger_=function(e){var t=this;return function(i){i.stream=e,t.trigger("log",i)}},this.push=function(e){if(n){var t=Ot(e);t&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():t||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),n=!1}this.transmuxPipeline_.headOfPipeline.push(e)},this.flush=function(){n=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}}).prototype=new St;var Ft,jt,Ht={Transmuxer:vt,VideoSegmentStream:yt,AudioSegmentStream:Tt,AUDIO_PROPERTIES:Mt,VIDEO_PROPERTIES:Rt,generateSegmentTimingInfo:Nt},Vt=function(e){return e>>>0},qt=function(e){var t="";return t+=String.fromCharCode(e[0]),t+=String.fromCharCode(e[1]),(t+=String.fromCharCode(e[2]))+String.fromCharCode(e[3])},Wt=Vt,Gt=qt,Kt=function(e,t){var i,s,n,r,a,o=[];if(!t.length)return null;for(i=0;i<e.byteLength;)s=Wt(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),n=Gt(e.subarray(i+4,i+8)),r=s>1?i+s:e.byteLength,n===t[0]&&(1===t.length?o.push(e.subarray(i+8,r)):(a=Kt(e.subarray(i+8,r),t.slice(1))).length&&(o=o.concat(a))),i=r;return o},zt=Vt,Qt=q.getUint64,Yt=function(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4))};return 1===t.version?t.baseMediaDecodeTime=Qt(e.subarray(4)):t.baseMediaDecodeTime=zt(e[4]<<24|e[5]<<16|e[6]<<8|e[7]),t},Xt=function(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}},Jt=function(e){var t,i={version:e[0],flags:new Uint8Array(e.subarray(1,4)),samples:[]},s=new DataView(e.buffer,e.byteOffset,e.byteLength),n=1&i.flags[2],r=4&i.flags[2],a=1&i.flags[1],o=2&i.flags[1],l=4&i.flags[1],d=8&i.flags[1],h=s.getUint32(4),u=8;for(n&&(i.dataOffset=s.getInt32(u),u+=4),r&&h&&(t={flags:Xt(e.subarray(u,u+4))},u+=4,a&&(t.duration=s.getUint32(u),u+=4),o&&(t.size=s.getUint32(u),u+=4),d&&(1===i.version?t.compositionTimeOffset=s.getInt32(u):t.compositionTimeOffset=s.getUint32(u),u+=4),i.samples.push(t),h--);h--;)t={},a&&(t.duration=s.getUint32(u),u+=4),o&&(t.size=s.getUint32(u),u+=4),l&&(t.flags=Xt(e.subarray(u,u+4)),u+=4),d&&(1===i.version?t.compositionTimeOffset=s.getInt32(u):t.compositionTimeOffset=s.getUint32(u),u+=4),i.samples.push(t);return i},Zt=function(e){var t,i=new DataView(e.buffer,e.byteOffset,e.byteLength),s={version:e[0],flags:new Uint8Array(e.subarray(1,4)),trackId:i.getUint32(4)},n=1&s.flags[2],r=2&s.flags[2],a=8&s.flags[2],o=16&s.flags[2],l=32&s.flags[2],d=65536&s.flags[0],h=131072&s.flags[0];return t=8,n&&(t+=4,s.baseDataOffset=i.getUint32(12),t+=4),r&&(s.sampleDescriptionIndex=i.getUint32(t),t+=4),a&&(s.defaultSampleDuration=i.getUint32(t),t+=4),o&&(s.defaultSampleSize=i.getUint32(t),t+=4),l&&(s.defaultSampleFlags=i.getUint32(t)),d&&(s.durationIsEmpty=!0),!n&&h&&(s.baseDataOffsetIsMoof=!0),s},ei=(Ft="undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:{},ce.discardEmulationPreventionBytes),ti=we.CaptionStream,ii=Kt,si=Yt,ni=Jt,ri=Zt,ai=Ft,oi=function(e,t){for(var i=e,s=0;s<t.length;s++){var n=t[s];if(i<n.size)return n;i-=n.size}return null},li=function(){var e,t,i,s,n,r,a=!1;this.isInitialized=function(){return a},this.init=function(t){e=new ti,a=!0,r=!!t&&t.isPartial,e.on("data",(function(e){e.startTime=e.startPts/s,e.endTime=e.endPts/s,n.captions.push(e),n.captionStreams[e.stream]=!0})),e.on("log",(function(e){n.logs.push(e)}))},this.isNewInit=function(e,t){return!(e&&0===e.length||t&&"object"==typeof t&&0===Object.keys(t).length||i===e[0]&&s===t[i])},this.parse=function(e,r,a){var o;if(!this.isInitialized())return null;if(!r||!a)return null;if(this.isNewInit(r,a))i=r[0],s=a[i];else if(null===i||!s)return t.push(e),null;for(;t.length>0;){var l=t.shift();this.parse(l,r,a)}return(o=function(e,t,i){if(null===t)return null;var s=function(e,t){var i=ii(e,["moof","traf"]),s=ii(e,["mdat"]),n={},r=[];return s.forEach((function(e,t){var s=i[t];r.push({mdat:e,traf:s})})),r.forEach((function(e){var i,s=e.mdat,r=e.traf,a=ii(r,["tfhd"]),o=ri(a[0]),l=o.trackId,d=ii(r,["tfdt"]),h=d.length>0?si(d[0]).baseMediaDecodeTime:0,u=ii(r,["trun"]);t===l&&u.length>0&&(i=function(e,t,i){var s,n,r,a,o=new DataView(e.buffer,e.byteOffset,e.byteLength),l={logs:[],seiNals:[]};for(n=0;n+4<e.length;n+=r)if(r=o.getUint32(n),n+=4,!(r<=0))switch(31&e[n]){case 6:var d=e.subarray(n+1,n+1+r),h=oi(n,t);if(s={nalUnitType:"sei_rbsp",size:r,data:d,escapedRBSP:ei(d),trackId:i},h)s.pts=h.pts,s.dts=h.dts,a=h;else{if(!a){l.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+n+" for trackId "+i+". See mux.js#223."});break}s.pts=a.pts,s.dts=a.dts}l.seiNals.push(s)}return l}(s,function(e,t,i){var s=t,n=i.defaultSampleDuration||0,r=i.defaultSampleSize||0,a=i.trackId,o=[];return e.forEach((function(e){var t=ni(e).samples;t.forEach((function(e){void 0===e.duration&&(e.duration=n),void 0===e.size&&(e.size=r),e.trackId=a,e.dts=s,void 0===e.compositionTimeOffset&&(e.compositionTimeOffset=0),"bigint"==typeof s?(e.pts=s+ai.BigInt(e.compositionTimeOffset),s+=ai.BigInt(e.duration)):(e.pts=s+e.compositionTimeOffset,s+=e.duration)})),o=o.concat(t)})),o}(u,h,o),l),n[l]||(n[l]={seiNals:[],logs:[]}),n[l].seiNals=n[l].seiNals.concat(i.seiNals),n[l].logs=n[l].logs.concat(i.logs))})),n}(e,t)[t]||{};return{seiNals:s.seiNals,logs:s.logs,timescale:i}}(e,i,s))&&o.logs&&(n.logs=n.logs.concat(o.logs)),null!==o&&o.seiNals?(this.pushNals(o.seiNals),this.flushStream(),n):n.logs.length?{logs:n.logs,captions:[],captionStreams:[]}:null},this.pushNals=function(t){if(!this.isInitialized()||!t||0===t.length)return null;t.forEach((function(t){e.push(t)}))},this.flushStream=function(){if(!this.isInitialized())return null;r?e.partialFlush():e.flush()},this.clearParsedCaptions=function(){n.captions=[],n.captionStreams={},n.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;e.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){t=[],i=null,s=null,n?this.clearParsedCaptions():n={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},di=Vt,hi=function(e){return("00"+e.toString(16)).slice(-2)},ui=Kt,ci=qt,pi=q.getUint64,mi=Ft,gi=function(e,t){var i=ui(t,["moof","traf"]).reduce((function(t,i){var s,n=ui(i,["tfhd"])[0],r=di(n[4]<<24|n[5]<<16|n[6]<<8|n[7]),a=e[r]||9e4,o=ui(i,["tfdt"])[0],l=new DataView(o.buffer,o.byteOffset,o.byteLength);let d;return"bigint"==typeof(s=1===o[0]?pi(o.subarray(4,12)):l.getUint32(4))?d=s/mi.BigInt(a):"number"!=typeof s||isNaN(s)||(d=s/a),d<Number.MAX_SAFE_INTEGER&&(d=Number(d)),d<t&&(t=d),t}),1/0);return"bigint"==typeof i||isFinite(i)?i:0},fi=function(e){var t=ui(e,["moov","trak"]),i=[];return t.forEach((function(e){var t,s,n={},r=ui(e,["tkhd"])[0];r&&(s=(t=new DataView(r.buffer,r.byteOffset,r.byteLength)).getUint8(0),n.id=0===s?t.getUint32(12):t.getUint32(20));var a=ui(e,["mdia","hdlr"])[0];if(a){var o=ci(a.subarray(8,12));n.type="vide"===o?"video":"soun"===o?"audio":o}var l=ui(e,["mdia","minf","stbl","stsd"])[0];if(l){var d=l.subarray(8);n.codec=ci(d.subarray(4,8));var h,u=ui(d,[n.codec])[0];u&&(/^[asm]vc[1-9]$/i.test(n.codec)?(h=u.subarray(78),"avcC"===ci(h.subarray(4,8))&&h.length>11?(n.codec+=".",n.codec+=hi(h[9]),n.codec+=hi(h[10]),n.codec+=hi(h[11])):n.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(n.codec)?(h=u.subarray(28),"esds"===ci(h.subarray(4,8))&&h.length>20&&0!==h[19]?(n.codec+="."+hi(h[19]),n.codec+="."+hi(h[20]>>>2&63).replace(/^0/,"")):n.codec="mp4a.40.2"):n.codec=n.codec.toLowerCase())}var c=ui(e,["mdia","mdhd"])[0];c&&(n.timescale=jt(c)),i.push(n)})),i},_i=(jt=function(e){var t=0===e[0]?12:20;return di(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])},Ie),yi=function(e){var t=31&e[1];return(t<<=8)|e[2]},Ti=function(e){return!!(64&e[1])},vi=function(e){var t=0;return(48&e[3])>>>4>1&&(t+=e[4]+1),t},bi=function(e){switch(e){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},Si={parseType:function(e,t){var i=yi(e);return 0===i?"pat":i===t?"pmt":t?"pes":null},parsePat:function(e){var t=Ti(e),i=4+vi(e);return t&&(i+=e[i]+1),(31&e[i+10])<<8|e[i+11]},parsePmt:function(e){var t={},i=Ti(e),s=4+vi(e);if(i&&(s+=e[s]+1),1&e[s+5]){var n;n=3+((15&e[s+1])<<8|e[s+2])-4;for(var r=12+((15&e[s+10])<<8|e[s+11]);r<n;){var a=s+r;t[(31&e[a+1])<<8|e[a+2]]=e[a],r+=5+((15&e[a+3])<<8|e[a+4])}return t}},parsePayloadUnitStartIndicator:Ti,parsePesType:function(e,t){switch(t[yi(e)]){case _i.H264_STREAM_TYPE:return"video";case _i.ADTS_STREAM_TYPE:return"audio";case _i.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},parsePesTime:function(e){if(!Ti(e))return null;var t=4+vi(e);if(t>=e.byteLength)return null;var i,s=null;return 192&(i=e[t+7])&&((s={}).pts=(14&e[t+9])<<27|(255&e[t+10])<<20|(254&e[t+11])<<12|(255&e[t+12])<<5|(254&e[t+13])>>>3,s.pts*=4,s.pts+=(6&e[t+13])>>>1,s.dts=s.pts,64&i&&(s.dts=(14&e[t+14])<<27|(255&e[t+15])<<20|(254&e[t+16])<<12|(255&e[t+17])<<5|(254&e[t+18])>>>3,s.dts*=4,s.dts+=(6&e[t+18])>>>1)),s},videoPacketContainsKeyFrame:function(e){for(var t=4+vi(e),i=e.subarray(t),s=0,n=0,r=!1;n<i.byteLength-3;n++)if(1===i[n+2]){s=n+5;break}for(;s<i.byteLength;)switch(i[s]){case 0:if(0!==i[s-1]){s+=2;break}if(0!==i[s-2]){s++;break}n+3!==s-2&&"slice_layer_without_partitioning_rbsp_idr"===bi(31&i[n+3])&&(r=!0);do{s++}while(1!==i[s]&&s<i.length);n=s-2,s+=3;break;case 1:if(0!==i[s-1]||0!==i[s-2]){s+=3;break}"slice_layer_without_partitioning_rbsp_idr"===bi(31&i[n+3])&&(r=!0),n=s-2,s+=3;break;default:s+=3}return i=i.subarray(n),s-=n,n=0,i&&i.byteLength>3&&"slice_layer_without_partitioning_rbsp_idr"===bi(31&i[n+3])&&(r=!0),r}},Ci=Ie,ki=De.handleRollover,Ei={};Ei.ts=Si,Ei.aac=ft;var wi=oe.ONE_SECOND_IN_TS,Ii=188,xi=71,Pi=function(e,t,i){for(var s,n,r,a,o=0,l=Ii,d=!1;l<=e.byteLength;)if(e[o]!==xi||e[l]!==xi&&l!==e.byteLength)o++,l++;else{switch(s=e.subarray(o,l),Ei.ts.parseType(s,t.pid)){case"pes":n=Ei.ts.parsePesType(s,t.table),r=Ei.ts.parsePayloadUnitStartIndicator(s),"audio"===n&&r&&(a=Ei.ts.parsePesTime(s))&&(a.type="audio",i.audio.push(a),d=!0)}if(d)break;o+=Ii,l+=Ii}for(o=(l=e.byteLength)-Ii,d=!1;o>=0;)if(e[o]!==xi||e[l]!==xi&&l!==e.byteLength)o--,l--;else{switch(s=e.subarray(o,l),Ei.ts.parseType(s,t.pid)){case"pes":n=Ei.ts.parsePesType(s,t.table),r=Ei.ts.parsePayloadUnitStartIndicator(s),"audio"===n&&r&&(a=Ei.ts.parsePesTime(s))&&(a.type="audio",i.audio.push(a),d=!0)}if(d)break;o-=Ii,l-=Ii}},Ai=function(e,t,i){for(var s,n,r,a,o,l,d,h=0,u=Ii,c=!1,p={data:[],size:0};u<e.byteLength;)if(e[h]!==xi||e[u]!==xi)h++,u++;else{switch(s=e.subarray(h,u),Ei.ts.parseType(s,t.pid)){case"pes":if(n=Ei.ts.parsePesType(s,t.table),r=Ei.ts.parsePayloadUnitStartIndicator(s),"video"===n&&(r&&!c&&(a=Ei.ts.parsePesTime(s))&&(a.type="video",i.video.push(a),c=!0),!i.firstKeyFrame)){if(r&&0!==p.size){for(o=new Uint8Array(p.size),l=0;p.data.length;)d=p.data.shift(),o.set(d,l),l+=d.byteLength;if(Ei.ts.videoPacketContainsKeyFrame(o)){var m=Ei.ts.parsePesTime(o);m?(i.firstKeyFrame=m,i.firstKeyFrame.type="video"):console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.")}p.size=0}p.data.push(s),p.size+=s.byteLength}}if(c&&i.firstKeyFrame)break;h+=Ii,u+=Ii}for(h=(u=e.byteLength)-Ii,c=!1;h>=0;)if(e[h]!==xi||e[u]!==xi)h--,u--;else{switch(s=e.subarray(h,u),Ei.ts.parseType(s,t.pid)){case"pes":n=Ei.ts.parsePesType(s,t.table),r=Ei.ts.parsePayloadUnitStartIndicator(s),"video"===n&&r&&(a=Ei.ts.parsePesTime(s))&&(a.type="video",i.video.push(a),c=!0)}if(c)break;h-=Ii,u-=Ii}},Li=function(e,t){var i;return(i=Ei.aac.isLikelyAacData(e)?function(e){for(var t,i=!1,s=0,n=null,r=null,a=0,o=0;e.length-o>=3;){switch(Ei.aac.parseType(e,o)){case"timed-metadata":if(e.length-o<10){i=!0;break}if((a=Ei.aac.parseId3TagSize(e,o))>e.length){i=!0;break}null===r&&(t=e.subarray(o,o+a),r=Ei.aac.parseAacTimestamp(t)),o+=a;break;case"audio":if(e.length-o<7){i=!0;break}if((a=Ei.aac.parseAdtsSize(e,o))>e.length){i=!0;break}null===n&&(t=e.subarray(o,o+a),n=Ei.aac.parseSampleRate(t)),s++,o+=a;break;default:o++}if(i)return null}if(null===n||null===r)return null;var l=wi/n;return{audio:[{type:"audio",dts:r,pts:r},{type:"audio",dts:r+1024*s*l,pts:r+1024*s*l}]}}(e):function(e){var t={pid:null,table:null},i={};for(var s in function(e,t){for(var i,s=0,n=Ii;n<e.byteLength;)if(e[s]!==xi||e[n]!==xi)s++,n++;else{switch(i=e.subarray(s,n),Ei.ts.parseType(i,t.pid)){case"pat":t.pid=Ei.ts.parsePat(i);break;case"pmt":var r=Ei.ts.parsePmt(i);t.table=t.table||{},Object.keys(r).forEach((function(e){t.table[e]=r[e]}))}s+=Ii,n+=Ii}}(e,t),t.table)if(t.table.hasOwnProperty(s))switch(t.table[s]){case Ci.H264_STREAM_TYPE:i.video=[],Ai(e,t,i),0===i.video.length&&delete i.video;break;case Ci.ADTS_STREAM_TYPE:i.audio=[],Pi(e,t,i),0===i.audio.length&&delete i.audio}return i}(e))&&(i.audio||i.video)?(function(e,t){if(e.audio&&e.audio.length){var i=t;(void 0===i||isNaN(i))&&(i=e.audio[0].dts),e.audio.forEach((function(e){e.dts=ki(e.dts,i),e.pts=ki(e.pts,i),e.dtsTime=e.dts/wi,e.ptsTime=e.pts/wi}))}if(e.video&&e.video.length){var s=t;if((void 0===s||isNaN(s))&&(s=e.video[0].dts),e.video.forEach((function(e){e.dts=ki(e.dts,s),e.pts=ki(e.pts,s),e.dtsTime=e.dts/wi,e.ptsTime=e.pts/wi})),e.firstKeyFrame){var n=e.firstKeyFrame;n.dts=ki(n.dts,s),n.pts=ki(n.pts,s),n.dtsTime=n.dts/wi,n.ptsTime=n.pts/wi}}}(i,t),i):null};class Oi{constructor(e,t){this.options=t||{},this.self=e,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Ht.Transmuxer(this.options),function(e,t){t.on("data",(function(t){const i=t.initSegment;t.initSegment={data:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength};const s=t.data;t.data=s.buffer,e.postMessage({action:"data",segment:t,byteOffset:s.byteOffset,byteLength:s.byteLength},[t.data])})),t.on("done",(function(t){e.postMessage({action:"done"})})),t.on("gopInfo",(function(t){e.postMessage({action:"gopInfo",gopInfo:t})})),t.on("videoSegmentTimingInfo",(function(t){const i={start:{decode:oe.videoTsToSeconds(t.start.dts),presentation:oe.videoTsToSeconds(t.start.pts)},end:{decode:oe.videoTsToSeconds(t.end.dts),presentation:oe.videoTsToSeconds(t.end.pts)},baseMediaDecodeTime:oe.videoTsToSeconds(t.baseMediaDecodeTime)};t.prependedContentDuration&&(i.prependedContentDuration=oe.videoTsToSeconds(t.prependedContentDuration)),e.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:i})})),t.on("audioSegmentTimingInfo",(function(t){const i={start:{decode:oe.videoTsToSeconds(t.start.dts),presentation:oe.videoTsToSeconds(t.start.pts)},end:{decode:oe.videoTsToSeconds(t.end.dts),presentation:oe.videoTsToSeconds(t.end.pts)},baseMediaDecodeTime:oe.videoTsToSeconds(t.baseMediaDecodeTime)};t.prependedContentDuration&&(i.prependedContentDuration=oe.videoTsToSeconds(t.prependedContentDuration)),e.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:i})})),t.on("id3Frame",(function(t){e.postMessage({action:"id3Frame",id3Frame:t})})),t.on("caption",(function(t){e.postMessage({action:"caption",caption:t})})),t.on("trackinfo",(function(t){e.postMessage({action:"trackinfo",trackInfo:t})})),t.on("audioTimingInfo",(function(t){e.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:oe.videoTsToSeconds(t.start),end:oe.videoTsToSeconds(t.end)}})})),t.on("videoTimingInfo",(function(t){e.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:oe.videoTsToSeconds(t.start),end:oe.videoTsToSeconds(t.end)}})})),t.on("log",(function(t){e.postMessage({action:"log",log:t})}))}(this.self,this.transmuxer)}pushMp4Captions(e){this.captionParser||(this.captionParser=new li,this.captionParser.init());const t=new Uint8Array(e.data,e.byteOffset,e.byteLength),i=this.captionParser.parse(t,e.trackIds,e.timescales);this.self.postMessage({action:"mp4Captions",captions:i&&i.captions||[],logs:i&&i.logs||[],data:t.buffer},[t.buffer])}probeMp4StartTime({timescales:e,data:t}){const i=gi(e,t);this.self.postMessage({action:"probeMp4StartTime",startTime:i,data:t},[t.buffer])}probeMp4Tracks({data:e}){const t=fi(e);this.self.postMessage({action:"probeMp4Tracks",tracks:t,data:e},[e.buffer])}probeTs({data:e,baseStartTime:t}){const i="number"!=typeof t||isNaN(t)?void 0:t*oe.ONE_SECOND_IN_TS,s=Li(e,i);let n=null;s&&(n={hasVideo:s.video&&2===s.video.length||!1,hasAudio:s.audio&&2===s.audio.length||!1},n.hasVideo&&(n.videoStart=s.video[0].ptsTime),n.hasAudio&&(n.audioStart=s.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:n,data:e},[e.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(e){const t=new Uint8Array(e.data,e.byteOffset,e.byteLength);this.transmuxer.push(t)}reset(){this.transmuxer.reset()}setTimestampOffset(e){const t=e.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(oe.secondsToVideoTs(t)))}setAudioAppendStart(e){this.transmuxer.setAudioAppendStart(Math.ceil(oe.secondsToVideoTs(e.appendStart)))}setRemux(e){this.transmuxer.setRemux(e.remux)}flush(e){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(e){this.transmuxer.alignGopsWith(e.gopsToAlignWith.slice())}}self.onmessage=function(e){"init"===e.data.action&&e.data.options?this.messageHandlers=new Oi(self,e.data.options):(this.messageHandlers||(this.messageHandlers=new Oi(self)),e.data&&e.data.action&&"init"!==e.data.action&&this.messageHandlers[e.data.action]&&this.messageHandlers[e.data.action](e.data))}})));var TransmuxWorker=factory(workerCode$1);const handleData_=(e,t,i)=>{const{type:s,initSegment:n,captions:r,captionStreams:a,metadata:o,videoFrameDtsTime:l,videoFramePtsTime:d}=e.data.segment;t.buffer.push({captions:r,captionStreams:a,metadata:o});const h=e.data.segment.boxes||{data:e.data.segment.data},u={type:s,data:new Uint8Array(h.data,h.data.byteOffset,h.data.byteLength),initSegment:new Uint8Array(n.data,n.byteOffset,n.byteLength)};void 0!==l&&(u.videoFrameDtsTime=l),void 0!==d&&(u.videoFramePtsTime=d),i(u)},handleDone_=({transmuxedData:e,callback:t})=>{e.buffer=[],t(e)},handleGopInfo_=(e,t)=>{t.gopInfo=e.data.gopInfo},processTransmux=e=>{const{transmuxer:t,bytes:i,audioAppendStart:s,gopsToAlignWith:n,remux:r,onData:a,onTrackInfo:o,onAudioTimingInfo:l,onVideoTimingInfo:d,onVideoSegmentTimingInfo:h,onAudioSegmentTimingInfo:u,onId3:c,onCaptions:p,onDone:m,onEndedTimeline:g,onTransmuxerLog:f,isEndOfTimeline:_}=e,y={buffer:[]};let T=_;if(t.onmessage=i=>{t.currentTransmux===e&&("data"===i.data.action&&handleData_(i,y,a),"trackinfo"===i.data.action&&o(i.data.trackInfo),"gopInfo"===i.data.action&&handleGopInfo_(i,y),"audioTimingInfo"===i.data.action&&l(i.data.audioTimingInfo),"videoTimingInfo"===i.data.action&&d(i.data.videoTimingInfo),"videoSegmentTimingInfo"===i.data.action&&h(i.data.videoSegmentTimingInfo),"audioSegmentTimingInfo"===i.data.action&&u(i.data.audioSegmentTimingInfo),"id3Frame"===i.data.action&&c([i.data.id3Frame],i.data.id3Frame.dispatchType),"caption"===i.data.action&&p(i.data.caption),"endedtimeline"===i.data.action&&(T=!1,g()),"log"===i.data.action&&f(i.data.log),"transmuxed"===i.data.type&&(T||(t.onmessage=null,handleDone_({transmuxedData:y,callback:m}),dequeue(t))))},s&&t.postMessage({action:"setAudioAppendStart",appendStart:s}),Array.isArray(n)&&t.postMessage({action:"alignGopsWith",gopsToAlignWith:n}),void 0!==r&&t.postMessage({action:"setRemux",remux:r}),i.byteLength){const e=i instanceof ArrayBuffer?i:i.buffer,s=i instanceof ArrayBuffer?0:i.byteOffset;t.postMessage({action:"push",data:e,byteOffset:s,byteLength:i.byteLength},[e])}_&&t.postMessage({action:"endTimeline"}),t.postMessage({action:"flush"})},dequeue=e=>{e.currentTransmux=null,e.transmuxQueue.length&&(e.currentTransmux=e.transmuxQueue.shift(),"function"==typeof e.currentTransmux?e.currentTransmux():processTransmux(e.currentTransmux))},processAction=(e,t)=>{e.postMessage({action:t}),dequeue(e)},enqueueAction=(e,t)=>{if(!t.currentTransmux)return t.currentTransmux=e,void processAction(t,e);t.transmuxQueue.push(processAction.bind(null,t,e))},reset=e=>{enqueueAction("reset",e)},endTimeline=e=>{enqueueAction("endTimeline",e)},transmux=e=>{if(!e.transmuxer.currentTransmux)return e.transmuxer.currentTransmux=e,void processTransmux(e);e.transmuxer.transmuxQueue.push(e)},createTransmuxer=e=>{const t=new TransmuxWorker;t.currentTransmux=null,t.transmuxQueue=[];const i=t.terminate;return t.terminate=()=>(t.currentTransmux=null,t.transmuxQueue.length=0,i.call(t)),t.postMessage({action:"init",options:e}),t};var segmentTransmuxer={reset:reset,endTimeline:endTimeline,transmux:transmux,createTransmuxer:createTransmuxer};const workerCallback=function(e){const t=e.transmuxer,i=e.endAction||e.action,s=e.callback,n=_extends({},e,{endAction:null,transmuxer:null,callback:null}),r=n=>{n.data.action===i&&(t.removeEventListener("message",r),n.data.data&&(n.data.data=new Uint8Array(n.data.data,e.byteOffset||0,e.byteLength||n.data.data.byteLength),e.data&&(e.data=n.data.data)),s(n.data))};if(t.addEventListener("message",r),e.data){const i=e.data instanceof ArrayBuffer;n.byteOffset=i?0:e.data.byteOffset,n.byteLength=e.data.byteLength;const s=[i?e.data:e.data.buffer];t.postMessage(n,s)}else t.postMessage(n)},REQUEST_ERRORS={FAILURE:2,TIMEOUT:-101,ABORTED:-102},abortAll=e=>{e.forEach((e=>{e.abort()}))},getRequestStats=e=>({bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}),getProgressStats=e=>{const t=e.target,i={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0};return i.bytesReceived=e.loaded,i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3),i},handleErrors=(e,t)=>t.timedout?{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:REQUEST_ERRORS.TIMEOUT,xhr:t}:t.aborted?{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:REQUEST_ERRORS.ABORTED,xhr:t}:e?{status:t.status,message:"HLS request errored at URL: "+t.uri,code:REQUEST_ERRORS.FAILURE,xhr:t}:"arraybuffer"===t.responseType&&0===t.response.byteLength?{status:t.status,message:"Empty HLS response at URL: "+t.uri,code:REQUEST_ERRORS.FAILURE,xhr:t}:null,handleKeyResponse=(e,t,i)=>(s,n)=>{const r=n.response,a=handleErrors(s,n);if(a)return i(a,e);if(16!==r.byteLength)return i({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:REQUEST_ERRORS.FAILURE,xhr:n},e);const o=new DataView(r),l=new Uint32Array([o.getUint32(0),o.getUint32(4),o.getUint32(8),o.getUint32(12)]);for(let e=0;e<t.length;e++)t[e].bytes=l;return i(null,e)},parseInitSegment=(e,t)=>{const i=detectContainerForBytes(e.map.bytes);if("mp4"!==i){const s=e.map.resolvedUri||e.map.uri;return t({internal:!0,message:`Found unsupported ${i||"unknown"} container for initialization segment at URL: ${s}`,code:REQUEST_ERRORS.FAILURE})}workerCallback({action:"probeMp4Tracks",data:e.map.bytes,transmuxer:e.transmuxer,callback:({tracks:i,data:s})=>(e.map.bytes=s,i.forEach((function(t){e.map.tracks=e.map.tracks||{},e.map.tracks[t.type]||(e.map.tracks[t.type]=t,"number"==typeof t.id&&t.timescale&&(e.map.timescales=e.map.timescales||{},e.map.timescales[t.id]=t.timescale))})),t(null))})},handleInitSegmentResponse=({segment:e,finishProcessingFn:t})=>(i,s)=>{const n=handleErrors(i,s);if(n)return t(n,e);const r=new Uint8Array(s.response);if(e.map.key)return e.map.encryptedBytes=r,t(null,e);e.map.bytes=r,parseInitSegment(e,(function(i){if(i)return i.xhr=s,i.status=s.status,t(i,e);t(null,e)}))},handleSegmentResponse=({segment:e,finishProcessingFn:t,responseType:i})=>(s,n)=>{const r=handleErrors(s,n);if(r)return t(r,e);const a="arraybuffer"!==i&&n.responseText?stringToArrayBuffer(n.responseText.substring(e.lastReachedChar||0)):n.response;return e.stats=getRequestStats(n),e.key?e.encryptedBytes=new Uint8Array(a):e.bytes=new Uint8Array(a),t(null,e)},transmuxAndNotify=({segment:e,bytes:t,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})=>{const p=e.map&&e.map.tracks||{},m=Boolean(p.audio&&p.video);let g=s.bind(null,e,"audio","start");const f=s.bind(null,e,"audio","end");let _=s.bind(null,e,"video","start");const y=s.bind(null,e,"video","end");workerCallback({action:"probeTs",transmuxer:e.transmuxer,data:t,baseStartTime:e.baseStartTime,callback:s=>{e.bytes=t=s.data;const p=s.result;p&&(i(e,{hasAudio:p.hasAudio,hasVideo:p.hasVideo,isMuxed:m}),i=null,p.hasAudio&&!m&&g(p.audioStart),p.hasVideo&&_(p.videoStart),g=null,_=null),transmux({bytes:t,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,remux:m,onData:t=>{t.type="combined"===t.type?"video":t.type,h(e,t)},onTrackInfo:t=>{i&&(m&&(t.isMuxed=!0),i(e,t))},onAudioTimingInfo:e=>{g&&void 0!==e.start&&(g(e.start),g=null),f&&void 0!==e.end&&f(e.end)},onVideoTimingInfo:e=>{_&&void 0!==e.start&&(_(e.start),_=null),y&&void 0!==e.end&&y(e.end)},onVideoSegmentTimingInfo:e=>{n(e)},onAudioSegmentTimingInfo:e=>{r(e)},onId3:(t,i)=>{a(e,t,i)},onCaptions:t=>{o(e,[t])},isEndOfTimeline:l,onEndedTimeline:()=>{d()},onTransmuxerLog:c,onDone:t=>{u&&(t.type="combined"===t.type?"video":t.type,u(null,e,t))}})}})},handleSegmentBytes=({segment:e,bytes:t,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})=>{let p=new Uint8Array(t);if(isLikelyFmp4MediaSegment(p)){e.isFmp4=!0;const{tracks:n}=e.map,r={isFmp4:!0,hasVideo:!!n.video,hasAudio:!!n.audio};n.audio&&n.audio.codec&&"enca"!==n.audio.codec&&(r.audioCodec=n.audio.codec),n.video&&n.video.codec&&"encv"!==n.video.codec&&(r.videoCodec=n.video.codec),n.video&&n.audio&&(r.isMuxed=!0),i(e,r);const a=t=>{h(e,{data:p,type:r.hasAudio&&!r.isMuxed?"audio":"video"}),t&&t.length&&o(e,t),u(null,e,{})};workerCallback({action:"probeMp4StartTime",timescales:e.map.timescales,data:p,transmuxer:e.transmuxer,callback:({data:i,startTime:o})=>{t=i.buffer,e.bytes=p=i,r.hasAudio&&!r.isMuxed&&s(e,"audio","start",o),r.hasVideo&&s(e,"video","start",o),n.video&&i.byteLength&&e.transmuxer?workerCallback({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:e.transmuxer,data:p,timescales:e.map.timescales,trackIds:[n.video.id],callback:i=>{t=i.data.buffer,e.bytes=p=i.data,i.logs.forEach((function(e){c(merge(e,{stream:"mp4CaptionParser"}))})),a(i.captions)}}):a()}})}else if(e.transmuxer){if(void 0===e.container&&(e.container=detectContainerForBytes(p)),"ts"!==e.container&&"aac"!==e.container)return i(e,{hasAudio:!1,hasVideo:!1}),void u(null,e,{});transmuxAndNotify({segment:e,bytes:t,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})}else u(null,e,{})},decrypt=function({id:e,key:t,encryptedBytes:i,decryptionWorker:s},n){const r=t=>{if(t.data.source===e){s.removeEventListener("message",r);const e=t.data.decrypted;n(new Uint8Array(e.bytes,e.byteOffset,e.byteLength))}};let a;s.addEventListener("message",r),a=t.bytes.slice?t.bytes.slice():new Uint32Array(Array.prototype.slice.call(t.bytes)),s.postMessage(createTransferableMessage({source:e,encrypted:i,key:a,iv:t.iv}),[i.buffer,a.buffer])},decryptSegment=({decryptionWorker:e,segment:t,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})=>{decrypt({id:t.requestId,key:t.key,encryptedBytes:t.encryptedBytes,decryptionWorker:e},(e=>{t.bytes=e,handleSegmentBytes({segment:t,bytes:t.bytes,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})}))},waitForCompletion=({activeXhrs:e,decryptionWorker:t,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})=>{let p=0,m=!1;return(g,f)=>{if(!m){if(g)return m=!0,abortAll(e),u(g,f);if(p+=1,p===e.length){const p=function(){if(f.encryptedBytes)return decryptSegment({decryptionWorker:t,segment:f,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c});handleSegmentBytes({segment:f,bytes:f.bytes,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})};if(f.endOfAllRequests=Date.now(),f.map&&f.map.encryptedBytes&&!f.map.bytes)return decrypt({decryptionWorker:t,id:f.requestId+"-init",encryptedBytes:f.map.encryptedBytes,key:f.map.key},(t=>{f.map.bytes=t,parseInitSegment(f,(t=>{if(t)return abortAll(e),u(t,f);p()}))}));p()}}}},handleLoadEnd=({loadendState:e,abortFn:t})=>i=>{i.target.aborted&&t&&!e.calledAbortFn&&(t(),e.calledAbortFn=!0)},handleProgress=({segment:e,progressFn:t,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h})=>i=>{if(!i.target.aborted)return e.stats=merge(e.stats,getProgressStats(i)),!e.stats.firstBytesReceivedAt&&e.stats.bytesReceived&&(e.stats.firstBytesReceivedAt=Date.now()),t(i,e)},mediaSegmentRequest=({xhr:e,xhrOptions:t,decryptionWorker:i,segment:s,abortFn:n,progressFn:r,trackInfoFn:a,timingInfoFn:o,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:d,id3Fn:h,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:p,dataFn:m,doneFn:g,onTransmuxerLog:f})=>{const _=[],y=waitForCompletion({activeXhrs:_,decryptionWorker:i,trackInfoFn:a,timingInfoFn:o,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:d,id3Fn:h,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:p,dataFn:m,doneFn:g,onTransmuxerLog:f});if(s.key&&!s.key.bytes){const i=[s.key];s.map&&!s.map.bytes&&s.map.key&&s.map.key.resolvedUri===s.key.resolvedUri&&i.push(s.map.key);const n=e(merge(t,{uri:s.key.resolvedUri,responseType:"arraybuffer"}),handleKeyResponse(s,i,y));_.push(n)}if(s.map&&!s.map.bytes){if(s.map.key&&(!s.key||s.key.resolvedUri!==s.map.key.resolvedUri)){const i=e(merge(t,{uri:s.map.key.resolvedUri,responseType:"arraybuffer"}),handleKeyResponse(s,[s.map.key],y));_.push(i)}const i=e(merge(t,{uri:s.map.resolvedUri,responseType:"arraybuffer",headers:segmentXhrHeaders(s.map)}),handleInitSegmentResponse({segment:s,finishProcessingFn:y}));_.push(i)}const T=merge(t,{uri:s.part&&s.part.resolvedUri||s.resolvedUri,responseType:"arraybuffer",headers:segmentXhrHeaders(s)}),v=e(T,handleSegmentResponse({segment:s,finishProcessingFn:y,responseType:T.responseType}));v.addEventListener("progress",handleProgress({segment:s,progressFn:r,trackInfoFn:a,timingInfoFn:o,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:d,id3Fn:h,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:p,dataFn:m})),_.push(v);const b={};return _.forEach((e=>{e.addEventListener("loadend",handleLoadEnd({loadendState:b,abortFn:n}))})),()=>abortAll(_)},logFn$1=logger("CodecUtils"),getCodecs=function(e){const t=e.attributes||{};if(t.CODECS)return parseCodecs(t.CODECS)},isMaat=(e,t)=>{const i=t.attributes||{};return e&&e.mediaGroups&&e.mediaGroups.AUDIO&&i.AUDIO&&e.mediaGroups.AUDIO[i.AUDIO]},isMuxed=(e,t)=>{if(!isMaat(e,t))return!0;const i=t.attributes||{},s=e.mediaGroups.AUDIO[i.AUDIO];for(const e in s)if(!s[e].uri&&!s[e].playlists)return!0;return!1},unwrapCodecList=function(e){const t={};return e.forEach((({mediaType:e,type:i,details:s})=>{t[e]=t[e]||[],t[e].push(translateLegacyCodec(`${i}${s}`))})),Object.keys(t).forEach((function(e){if(t[e].length>1)return logFn$1(`multiple ${e} codecs found as attributes: ${t[e].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),void(t[e]=null);t[e]=t[e][0]})),t},codecCount=function(e){let t=0;return e.audio&&t++,e.video&&t++,t},codecsForPlaylist=function(e,t){const i=t.attributes||{},s=unwrapCodecList(getCodecs(t)||[]);if(isMaat(e,t)&&!s.audio&&!isMuxed(e,t)){const t=unwrapCodecList(codecsFromDefault(e,i.AUDIO)||[]);t.audio&&(s.audio=t.audio)}return s},logFn=logger("PlaylistSelector"),representationToString=function(e){if(!e||!e.playlist)return;const t=e.playlist;return JSON.stringify({id:t.id,bandwidth:e.bandwidth,width:e.width,height:e.height,codecs:t.attributes&&t.attributes.CODECS||""})},safeGetComputedStyle=function(e,t){if(!e)return"";const i=window$1.getComputedStyle(e);return i?i[t]:""},stableSort=function(e,t){const i=e.slice();e.sort((function(e,s){const n=t(e,s);return 0===n?i.indexOf(e)-i.indexOf(s):n}))},comparePlaylistBandwidth=function(e,t){let i,s;return e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||window$1.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(s=t.attributes.BANDWIDTH),s=s||window$1.Number.MAX_VALUE,i-s},comparePlaylistResolution=function(e,t){let i,s;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||window$1.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(s=t.attributes.RESOLUTION.width),s=s||window$1.Number.MAX_VALUE,i===s&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:i-s};let simpleSelector=function(e,t,i,s,n,r){if(!e)return;const a={bandwidth:t,width:i,height:s,limitRenditionByPlayerDimensions:n};let o=e.playlists;Playlist.isAudioOnly(e)&&(o=r.getAudioTrackPlaylists_(),a.audioOnly=!0);let l=o.map((e=>{let t;const i=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,s=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height;return t=e.attributes&&e.attributes.BANDWIDTH,t=t||window$1.Number.MAX_VALUE,{bandwidth:t,width:i,height:s,playlist:e}}));stableSort(l,((e,t)=>e.bandwidth-t.bandwidth)),l=l.filter((e=>!Playlist.isIncompatible(e.playlist)));let d=l.filter((e=>Playlist.isEnabled(e.playlist)));d.length||(d=l.filter((e=>!Playlist.isDisabled(e.playlist))));const h=d.filter((e=>e.bandwidth*Config.BANDWIDTH_VARIANCE<t));let u=h[h.length-1];const c=h.filter((e=>e.bandwidth===u.bandwidth))[0];if(!1===n){const e=c||d[0]||l[0];if(e&&e.playlist){let t="sortedPlaylistReps";return c&&(t="bandwidthBestRep"),d[0]&&(t="enabledPlaylistReps"),logFn(`choosing ${representationToString(e)} using ${t} with options`,a),e.playlist}return logFn("could not choose a playlist with options",a),null}const p=h.filter((e=>e.width&&e.height));stableSort(p,((e,t)=>e.width-t.width));const m=p.filter((e=>e.width===i&&e.height===s));u=m[m.length-1];const g=m.filter((e=>e.bandwidth===u.bandwidth))[0];let f,_,y,T;if(g||(f=p.filter((e=>e.width>i||e.height>s)),_=f.filter((e=>e.width===f[0].width&&e.height===f[0].height)),u=_[_.length-1],y=_.filter((e=>e.bandwidth===u.bandwidth))[0]),r.leastPixelDiffSelector){const e=p.map((e=>(e.pixelDiff=Math.abs(e.width-i)+Math.abs(e.height-s),e)));stableSort(e,((e,t)=>e.pixelDiff===t.pixelDiff?t.bandwidth-e.bandwidth:e.pixelDiff-t.pixelDiff)),T=e[0]}const v=T||y||g||c||d[0]||l[0];if(v&&v.playlist){let e="sortedPlaylistReps";return T?e="leastPixelDiffRep":y?e="resolutionPlusOneRep":g?e="resolutionBestRep":c?e="bandwidthBestRep":d[0]&&(e="enabledPlaylistReps"),logFn(`choosing ${representationToString(v)} using ${e} with options`,a),v.playlist}return logFn("could not choose a playlist with options",a),null};const lastBandwidthSelector=function(){const e=this.useDevicePixelRatio&&window$1.devicePixelRatio||1;return simpleSelector(this.playlists.main,this.systemBandwidth,parseInt(safeGetComputedStyle(this.tech_.el(),"width"),10)*e,parseInt(safeGetComputedStyle(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions,this.playlistController_)},movingAverageBandwidthSelector=function(e){let t=-1,i=-1;if(e<0||e>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){const s=this.useDevicePixelRatio&&window$1.devicePixelRatio||1;return t<0&&(t=this.systemBandwidth,i=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==i&&(t=e*this.systemBandwidth+(1-e)*t,i=this.systemBandwidth),simpleSelector(this.playlists.main,t,parseInt(safeGetComputedStyle(this.tech_.el(),"width"),10)*s,parseInt(safeGetComputedStyle(this.tech_.el(),"height"),10)*s,this.limitRenditionByPlayerDimensions,this.playlistController_)}},minRebufferMaxBandwidthSelector=function(e){const{main:t,currentTime:i,bandwidth:s,duration:n,segmentDuration:r,timeUntilRebuffer:a,currentTimeline:o,syncController:l}=e,d=t.playlists.filter((e=>!Playlist.isIncompatible(e)));let h=d.filter(Playlist.isEnabled);h.length||(h=d.filter((e=>!Playlist.isDisabled(e))));const u=h.filter(Playlist.hasAttribute.bind(null,"BANDWIDTH")).map((e=>{const t=l.getSyncPoint(e,n,o,i)?1:2;return{playlist:e,rebufferingImpact:Playlist.estimateSegmentRequestTime(r,s,e)*t-a}})),c=u.filter((e=>e.rebufferingImpact<=0));return stableSort(c,((e,t)=>comparePlaylistBandwidth(t.playlist,e.playlist))),c.length?c[0]:(stableSort(u,((e,t)=>e.rebufferingImpact-t.rebufferingImpact)),u[0]||null)},lowestBitrateCompatibleVariantSelector=function(){const e=this.playlists.main.playlists.filter(Playlist.isEnabled);return stableSort(e,((e,t)=>comparePlaylistBandwidth(e,t))),e.filter((e=>!!codecsForPlaylist(this.playlists.main,e).video))[0]||null},concatSegments=e=>{let t,i=0;return e.bytes&&(t=new Uint8Array(e.bytes),e.segments.forEach((e=>{t.set(e,i),i+=e.byteLength}))),t},createCaptionsTrackIfNotExists=function(e,t,i){if(!e[i]){t.trigger({type:"usage",name:"vhs-608"});let s=i;/^cc708_/.test(i)&&(s="SERVICE"+i.split("_")[1]);const n=t.textTracks().getTrackById(s);if(n)e[i]=n;else{let n=i,r=i,a=!1;const o=(t.options_.vhs&&t.options_.vhs.captionServices||{})[s];o&&(n=o.label,r=o.language,a=o.default),e[i]=t.addRemoteTextTrack({kind:"captions",id:s,default:a,label:n,language:r},!1).track}}},addCaptionData=function({inbandTextTracks:e,captionArray:t,timestampOffset:i}){if(!t)return;const s=window$1.WebKitDataCue||window$1.VTTCue;t.forEach((t=>{const n=t.stream;e[n].addCue(new s(t.startTime+i,t.endTime+i,t.text))}))},deprecateOldCue=function(e){Object.defineProperties(e.frame,{id:{get:()=>(videojs.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),e.value.key)},value:{get:()=>(videojs.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),e.value.data)},privateData:{get:()=>(videojs.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),e.value.data)}})},addMetadata=({inbandTextTracks:e,metadataArray:t,timestampOffset:i,videoDuration:s})=>{if(!t)return;const n=window$1.WebKitDataCue||window$1.VTTCue,r=e.metadataTrack_;if(!r)return;if(t.forEach((e=>{const t=e.cueTime+i;!("number"!=typeof t||window$1.isNaN(t)||t<0)&&t<1/0&&e.frames.forEach((e=>{const i=new n(t,t,e.value||e.url||e.data||"");i.frame=e,i.value=e,deprecateOldCue(i),r.addCue(i)}))})),!r.cues||!r.cues.length)return;const a=r.cues,o=[];for(let e=0;e<a.length;e++)a[e]&&o.push(a[e]);const l=o.reduce(((e,t)=>{const i=e[t.startTime]||[];return i.push(t),e[t.startTime]=i,e}),{}),d=Object.keys(l).sort(((e,t)=>Number(e)-Number(t)));d.forEach(((e,t)=>{const i=l[e],n=Number(d[t+1])||s;i.forEach((e=>{e.endTime=n}))}))},createMetadataTrackIfNotExists=(e,t,i)=>{e.metadataTrack_||(e.metadataTrack_=i.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,e.metadataTrack_.inBandMetadataTrackDispatchType=t)},removeCuesFromTrack=function(e,t,i){let s,n;if(i&&i.cues)for(s=i.cues.length;s--;)n=i.cues[s],n.startTime>=e&&n.endTime<=t&&i.removeCue(n)},removeDuplicateCuesFromTrack=function(e){const t=e.cues;if(t)for(let i=0;i<t.length;i++){const s=[];let n=0;for(let e=0;e<t.length;e++)t[i].startTime===t[e].startTime&&t[i].endTime===t[e].endTime&&t[i].text===t[e].text&&(n++,n>1&&s.push(t[e]));s.length&&s.forEach((t=>e.removeCue(t)))}},gopsSafeToAlignWith=(e,t,i)=>{if(null==t||!e.length)return[];const s=Math.ceil((t-i+3)*ONE_SECOND_IN_TS);let n;for(n=0;n<e.length&&!(e[n].pts>s);n++);return e.slice(n)},updateGopBuffer=(e,t,i)=>{if(!t.length)return e;if(i)return t.slice();const s=t[0].pts;let n=0;for(;n<e.length&&!(e[n].pts>=s);n++);return e.slice(0,n).concat(t)},removeGopBuffer=(e,t,i,s)=>{const n=Math.ceil((t-s)*ONE_SECOND_IN_TS),r=Math.ceil((i-s)*ONE_SECOND_IN_TS),a=e.slice();let o=e.length;for(;o--&&!(e[o].pts<=r););if(-1===o)return a;let l=o+1;for(;l--&&!(e[l].pts<=n););return l=Math.max(l,0),a.splice(l,o-l+1),a},shallowEqual=function(e,t){if(!e&&!t||!e&&t||e&&!t)return!1;if(e===t)return!0;const i=Object.keys(e).sort(),s=Object.keys(t).sort();if(i.length!==s.length)return!1;for(let n=0;n<i.length;n++){const r=i[n];if(r!==s[n])return!1;if(e[r]!==t[r])return!1}return!0},QUOTA_EXCEEDED_ERR=22,getSyncSegmentCandidate=function(e,t,i){t=t||[];const s=[];let n=0;for(let r=0;r<t.length;r++){const a=t[r];if(e===a.timeline&&(s.push(r),n+=a.duration,n>i))return r}return 0===s.length?0:s[s.length-1]},MIN_BACK_BUFFER=1,CHECK_BUFFER_DELAY=500,finite=e=>"number"==typeof e&&isFinite(e),MIN_SEGMENT_DURATION_TO_SAVE_STATS=1/60,illegalMediaSwitch=(e,t,i)=>"main"===e&&t&&i?i.hasAudio||i.hasVideo?t.hasVideo&&!i.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!t.hasVideo&&i.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null:"Neither audio nor video found in segment.":null,safeBackBufferTrimTime=(e,t,i)=>{let s=t-Config.BACK_BUFFER_LENGTH;e.length&&(s=Math.max(s,e.start(0)));const n=t-i;return Math.min(n,s)},segmentInfoString=e=>{const{startOfSegment:t,duration:i,segment:s,part:n,playlist:{mediaSequence:r,id:a,segments:o=[]},mediaIndex:l,partIndex:d,timeline:h}=e,u=o.length-1;let c="mediaIndex/partIndex increment";e.getMediaInfoForTime?c=`getMediaInfoForTime (${e.getMediaInfoForTime})`:e.isSyncRequest&&(c="getSyncSegmentCandidate (isSyncRequest)"),e.independent&&(c+=` with independent ${e.independent}`);const p="number"==typeof d,m=e.segment.uri?"segment":"pre-segment",g=p?getKnownPartCount({preloadSegment:s})-1:0;return`${m} [${r+l}/${r+u}]`+(p?` part [${d}/${g}]`:"")+` segment start/end [${s.start} => ${s.end}]`+(p?` part start/end [${n.start} => ${n.end}]`:"")+` startOfSegment [${t}]`+` duration [${i}]`+` timeline [${h}]`+` selected by [${c}]`+` playlist [${a}]`},timingInfoPropertyForMedia=e=>`${e}TimingInfo`,timestampOffsetForSegment=({segmentTimeline:e,currentTimeline:t,startOfSegment:i,buffered:s,overrideCheck:n})=>n||e!==t?e<t?i:s.length?s.end(s.length-1):i:null,shouldWaitForTimelineChange=({timelineChangeController:e,currentTimeline:t,segmentTimeline:i,loaderType:s,audioDisabled:n})=>{if(t===i)return!1;if("audio"===s){const t=e.lastTimelineChange({type:"main"});return!t||t.to!==i}if("main"===s&&n){const t=e.pendingTimelineChange({type:"audio"});return!t||t.to!==i}return!1},mediaDuration=e=>{let t=0;return["video","audio"].forEach((function(i){const s=e[`${i}TimingInfo`];if(!s)return;const{start:n,end:r}=s;let a;"bigint"==typeof n||"bigint"==typeof r?a=window$1.BigInt(r)-window$1.BigInt(n):"number"==typeof n&&"number"==typeof r&&(a=r-n),void 0!==a&&a>t&&(t=a)})),"bigint"==typeof t&&t<Number.MAX_SAFE_INTEGER&&(t=Number(t)),t},segmentTooLong=({segmentDuration:e,maxDuration:t})=>!!e&&Math.round(e)>t+TIME_FUDGE_FACTOR,getTroublesomeSegmentDurationMessage=(e,t)=>{if("hls"!==t)return null;const i=mediaDuration({audioTimingInfo:e.audioTimingInfo,videoTimingInfo:e.videoTimingInfo});if(!i)return null;const s=e.playlist.targetDuration,n=segmentTooLong({segmentDuration:i,maxDuration:2*s}),r=segmentTooLong({segmentDuration:i,maxDuration:s}),a=`Segment with index ${e.mediaIndex} from playlist ${e.playlist.id} has a duration of ${i} when the reported duration is ${e.duration} and the target duration is ${s}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return n||r?{severity:n?"warn":"info",message:a}:null};class SegmentLoader extends videojs.EventTarget{constructor(e,t={}){if(super(),!e)throw new TypeError("Initialization settings are required");if("function"!=typeof e.currentTime)throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=videojs.browser.IE_VERSION>=11,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",(()=>{this.isEndOfStream_()||(this.ended_=!1)})),this.fetchAtBuffer_=!1,this.logger_=logger(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(e){e!==this.state_&&(this.logger_(`${this.state_} -> ${e}`),this.state_=e,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",(()=>{this.hasEnoughInfoToAppend_()&&this.processCallQueue_()})),"main"===this.loaderType_&&this.timelineChangeController_.on("pendingtimelinechange",(()=>{this.hasEnoughInfoToAppend_()&&this.processCallQueue_()})),"audio"===this.loaderType_&&this.timelineChangeController_.on("timelinechange",(()=>{this.hasEnoughInfoToLoad_()&&this.processLoadQueue_(),this.hasEnoughInfoToAppend_()&&this.processCallQueue_()}))}createTransmuxer_(){return segmentTransmuxer.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&window$1.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){"WAITING"===this.state?(this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()):this.pendingSegment_&&(this.pendingSegment_=null)}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,window$1.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return"APPENDING"!==this.state||this.pendingSegment_?!this.pendingSegment_||this.pendingSegment_.requestId!==e:(this.state="READY",!0)}error(e){return void 0!==e&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&segmentTransmuxer.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return createTimeRanges();if("main"===this.loaderType_){const{hasAudio:t,hasVideo:i,isMuxed:s}=e;if(i&&t&&!this.audioDisabled_&&!s)return this.sourceUpdater_.buffered();if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;const i=initSegmentId(e);let s=this.initSegments_[i];return t&&!s&&e.bytes&&(this.initSegments_[i]=s={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),s||e}segmentKey(e,t=!1){if(!e)return null;const i=segmentKeyId(e);let s=this.keyCache_[i];this.cacheEncryptionKeys_&&t&&!s&&e.bytes&&(this.keyCache_[i]=s={resolvedUri:e.resolvedUri,bytes:e.bytes});const n={resolvedUri:(s||e).resolvedUri};return s&&(n.bytes=s.bytes),n}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),this.playlist_)return"INIT"===this.state&&this.couldBeginLoading_()?this.init_():void(!this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY"))}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e)return;const i=this.playlist_,s=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,"INIT"===this.state&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},"main"===this.loaderType_&&this.syncController_.setDateTimeMappingForStart(e));let n=null;if(i&&(i.id?n=i.id:i.uri&&(n=i.uri)),this.logger_(`playlist update [${n} => ${e.id||e.uri}]`),this.trigger("syncinfoupdate"),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();if(!i||i.uri!==e.uri)return null!==this.mediaIndex&&(e.endList?this.resyncLoader():this.resetLoader()),this.currentMediaInfo_=void 0,void this.trigger("playlistupdate");const r=e.mediaSequence-i.mediaSequence;if(this.logger_(`live window shift [${r}]`),null!==this.mediaIndex)if(this.mediaIndex-=r,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{const e=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!e.parts||!e.parts.length||!e.parts[this.partIndex])){const e=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=e}}s&&(s.mediaIndex-=r,s.mediaIndex<0?(s.mediaIndex=null,s.partIndex=null):(s.mediaIndex>=0&&(s.segment=e.segments[s.mediaIndex]),s.partIndex>=0&&s.segment.parts&&(s.part=s.segment.parts[s.partIndex]))),this.syncController_.saveExpiredSegmentInfo(i,e)}pause(){this.checkBufferTimeout_&&(window$1.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}paused(){return null===this.checkBufferTimeout_}resetEverything(e){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"}))}resetLoader(){this.fetchAtBuffer_=!1,this.resyncLoader()}resyncLoader(){this.transmuxer_&&segmentTransmuxer.reset(this.transmuxer_),this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}remove(e,t,i=(()=>{}),s=!1){if(t===1/0&&(t=this.duration_()),t<=e)return void this.logger_("skipping remove because end ${end} is <= start ${start}");if(!this.sourceUpdater_||!this.getMediaInfo_())return void this.logger_("skipping remove because no source updater or starting media info");let n=1;const r=()=>{n--,0===n&&i()};!s&&this.audioDisabled_||(n++,this.sourceUpdater_.removeAudio(e,t,r)),(s||"main"===this.loaderType_)&&(this.gopBuffer_=removeGopBuffer(this.gopBuffer_,e,t,this.timeMapping_),n++,this.sourceUpdater_.removeVideo(e,t,r));for(const i in this.inbandTextTracks_)removeCuesFromTrack(e,t,this.inbandTextTracks_[i]);removeCuesFromTrack(e,t,this.segmentMetadataTrack_),r()}monitorBuffer_(){this.checkBufferTimeout_&&window$1.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=window$1.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){"READY"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&window$1.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=window$1.setTimeout(this.monitorBufferTick_.bind(this),500)}fillBuffer_(){if(this.sourceUpdater_.updating())return;const e=this.chooseNextRequest_();e&&("number"==typeof e.timestampOffset&&(this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})),this.loadSegment_(e))}isEndOfStream_(e=this.mediaIndex,t=this.playlist_,i=this.partIndex){if(!t||!this.mediaSource_)return!1;const s="number"==typeof e&&t.segments[e],n=e+1===t.segments.length,r=!s||!s.parts||i+1===s.parts.length;return t.endList&&"open"===this.mediaSource_.readyState&&n&&r}chooseNextRequest_(){const e=this.buffered_(),t=lastBufferedEnd(e)||0,i=timeAheadOf(e,this.currentTime_()),s=!this.hasPlayed_()&&i>=1,n=i>=this.goalBufferLength_(),r=this.playlist_.segments;if(!r.length||s||n)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_());const a={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:Boolean(!this.syncPoint_)};if(a.isSyncRequest)a.mediaIndex=getSyncSegmentCandidate(this.currentTimeline_,r,t);else if(null!==this.mediaIndex){const e=r[this.mediaIndex],i="number"==typeof this.partIndex?this.partIndex:-1;a.startOfSegment=e.end?e.end:t,e.parts&&e.parts[i+1]?(a.mediaIndex=this.mediaIndex,a.partIndex=i+1):a.mediaIndex=this.mediaIndex+1}else{const{segmentIndex:e,startTime:i,partIndex:s}=Playlist.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:this.fetchAtBuffer_?t:this.currentTime_(),startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});a.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${t}`:`currentTime ${this.currentTime_()}`,a.mediaIndex=e,a.startOfSegment=i,a.partIndex=s}const o=r[a.mediaIndex];let l=o&&"number"==typeof a.partIndex&&o.parts&&o.parts[a.partIndex];if(!o||"number"==typeof a.partIndex&&!l)return null;if("number"!=typeof a.partIndex&&o.parts&&(a.partIndex=0,l=o.parts[0]),!i&&l&&!l.independent)if(0===a.partIndex){const e=r[a.mediaIndex-1],t=e.parts&&e.parts.length&&e.parts[e.parts.length-1];t&&t.independent&&(a.mediaIndex-=1,a.partIndex=e.parts.length-1,a.independent="previous segment")}else o.parts[a.partIndex-1].independent&&(a.partIndex-=1,a.independent="previous part");const d=this.mediaSource_&&"ended"===this.mediaSource_.readyState;return a.mediaIndex>=r.length-1&&d&&!this.seeking_()?null:this.generateSegmentInfo_(a)}generateSegmentInfo_(e){const{independent:t,playlist:i,mediaIndex:s,startOfSegment:n,isSyncRequest:r,partIndex:a,forceTimestampOffset:o,getMediaInfoForTime:l}=e,d=i.segments[s],h="number"==typeof a&&d.parts[a],u={requestId:"segment-loader-"+Math.random(),uri:h&&h.resolvedUri||d.resolvedUri,mediaIndex:s,partIndex:h?a:null,isSyncRequest:r,startOfSegment:n,playlist:i,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:d.timeline,duration:h&&h.duration||d.duration,segment:d,part:h,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:l,independent:t},c=void 0!==o?o:this.isPendingTimestampOffset_;u.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:d.timeline,currentTimeline:this.currentTimeline_,startOfSegment:n,buffered:this.buffered_(),overrideCheck:c});const p=lastBufferedEnd(this.sourceUpdater_.audioBuffered());return"number"==typeof p&&(u.audioAppendStart=p-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(u.gopsToAlignWith=gopsSafeToAlignWith(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),u}timestampOffsetForSegment_(e){return timestampOffsetForSegment(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH)return;if(Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;const t=this.currentTime_(),i=e.bandwidth,s=this.pendingSegment_.duration,n=Playlist.estimateSegmentRequestTime(s,i,this.playlist_,e.bytesReceived),r=timeUntilRebuffer(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(n<=r)return;const a=minRebufferMaxBandwidthSelector({main:this.vhs_.playlists.main,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:r,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!a)return;const o=n-r-a.rebufferingImpact;let l=.5;r<=TIME_FUDGE_FACTOR&&(l=1),!a.playlist||a.playlist.uri===this.playlist_.uri||o<l||(this.bandwidth=a.playlist.attributes.BANDWIDTH*Config.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}handleAbort_(e){this.logger_(`Aborting ${segmentInfoString(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),this.checkForAbort_(t.requestId)||this.trigger("progress")}handleTrackInfo_(e,t){this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId)||this.checkForIllegalMediaSwitch(t)||(t=t||{},shallowEqual(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),this.checkForAbort_(e.requestId)||(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()&&this.processCallQueue_()))}handleTimingInfo_(e,t,i,s){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;const n=this.pendingSegment_,r=timingInfoPropertyForMedia(t);n[r]=n[r]||{},n[r][i]=s,this.logger_(`timinginfo: ${t} - ${i} - ${s}`),this.hasEnoughInfoToAppend_()&&this.processCallQueue_()}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(0===t.length)return void this.logger_("SegmentLoader received no captions from a caption event");if(!this.pendingSegment_.hasAppendedData_)return void this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));const i=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),s={};t.forEach((e=>{s[e.stream]=s[e.stream]||{startTime:1/0,captions:[],endTime:0};const t=s[e.stream];t.startTime=Math.min(t.startTime,e.startTime+i),t.endTime=Math.max(t.endTime,e.endTime+i),t.captions.push(e)})),Object.keys(s).forEach((e=>{const{startTime:t,endTime:n,captions:r}=s[e],a=this.inbandTextTracks_;this.logger_(`adding cues from ${t} -> ${n} for ${e}`),createCaptionsTrackIfNotExists(a,this.vhs_.tech_,e),removeCuesFromTrack(t,n,a[e]),addCaptionData({captionArray:r,inbandTextTracks:a,timestampOffset:i})})),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,t,i){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(!this.pendingSegment_.hasAppendedData_)return void this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,i));const s=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();createMetadataTrackIfNotExists(this.inbandTextTracks_,i,this.vhs_.tech_),addMetadata({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:s,videoDuration:this.duration_()})}processMetadataQueue_(){this.metadataQueue_.id3.forEach((e=>e())),this.metadataQueue_.caption.forEach((e=>e())),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){const e=this.callQueue_;this.callQueue_=[],e.forEach((e=>e()))}processLoadQueue_(){const e=this.loadQueue_;this.loadQueue_=[],e.forEach((e=>e()))}hasEnoughInfoToLoad_(){if("audio"!==this.loaderType_)return!0;const e=this.pendingSegment_;return!(!e||this.getCurrentMediaInfo_()&&shouldWaitForTimelineChange({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready())return!1;if(this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;const e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;const{hasAudio:i,hasVideo:s,isMuxed:n}=t;return!(s&&!e.videoTimingInfo||i&&!this.audioDisabled_&&!n&&!e.audioTimingInfo||shouldWaitForTimelineChange({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_())return void this.callQueue_.push(this.handleData_.bind(this,e,t));const i=this.pendingSegment_;if(this.setTimeMapping_(i.timeline),this.updateMediaSecondsLoaded_(i.part||i.segment),"closed"!==this.mediaSource_.readyState){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),i.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),i.isFmp4=e.isFmp4,i.timingInfo=i.timingInfo||{},i.isFmp4)this.trigger("fmp4"),i.timingInfo.start=i[timingInfoPropertyForMedia(t.type)].start;else{const e=this.getCurrentMediaInfo_(),t="main"===this.loaderType_&&e&&e.hasVideo;let s;t&&(s=i.videoTimingInfo.start),i.timingInfo.start=this.trueSegmentStart_({currentStart:i.timingInfo.start,playlist:i.playlist,mediaIndex:i.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:t,firstVideoFrameTimeForData:s,videoTimingInfo:i.videoTimingInfo,audioTimingInfo:i.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(i,t.type),this.updateSourceBufferTimestampOffset_(i),i.isSyncRequest){this.updateTimingInfoEnd_(i),this.syncController_.saveSegmentTimingInfo({segmentInfo:i,shouldSaveTimelineMapping:"main"===this.loaderType_});const e=this.chooseNextRequest_();if(e.mediaIndex!==i.mediaIndex||e.partIndex!==i.partIndex)return void this.logger_("sync segment was incorrect, not appending");this.logger_("sync segment was correct, appending")}i.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(i,t)}}updateAppendInitSegmentStatus(e,t){"main"!==this.loaderType_||"number"!=typeof e.timestampOffset||e.changedTimestampOffset||(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:i,playlist:s}){if(i){const e=initSegmentId(i);if(this.activeInitSegmentId_===e)return null;t=this.initSegmentForMap(i,!0).bytes,this.activeInitSegmentId_=e}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=s,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i},s){const n=this.sourceUpdater_.audioBuffered(),r=this.sourceUpdater_.videoBuffered();n.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+timeRangesToArray(n).join(", ")),r.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+timeRangesToArray(r).join(", "));const a=n.length?n.start(0):0,o=n.length?n.end(n.length-1):0,l=r.length?r.start(0):0,d=r.length?r.end(r.length-1):0;if(o-a<=1&&d-l<=1)return this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${i.byteLength}, audio buffer: ${timeRangesToArray(n).join(", ")}, video buffer: ${timeRangesToArray(r).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),void this.trigger("error");this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:i}));const h=this.currentTime_()-1;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${h}`),this.remove(0,h,(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, retrying append in 1s"),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=window$1.setTimeout((()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()}),1e3)}),!0)}handleAppendError_({segmentInfo:e,type:t,bytes:i},s){s&&(22!==s.code?(this.logger_("Received non QUOTA_EXCEEDED_ERR on append",s),this.error(`${t} append of ${i.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`),this.trigger("appenderror")):this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i}))}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:i,data:s,bytes:n}){if(!n){const e=[s];let t=s.byteLength;i&&(e.unshift(i),t+=i.byteLength),n=concatSegments({bytes:t,segments:e})}this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:n},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:n}))}handleSegmentTimingInfo_(e,t,i){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;const s=this.pendingSegment_.segment,n=`${e}TimingInfo`;s[n]||(s[n]={}),s[n].transmuxerPrependedSeconds=i.prependedContentDuration||0,s[n].transmuxedPresentationStart=i.start.presentation,s[n].transmuxedDecodeStart=i.start.decode,s[n].transmuxedPresentationEnd=i.end.presentation,s[n].transmuxedDecodeEnd=i.end.decode,s[n].baseMediaDecodeTime=i.baseMediaDecodeTime}appendData_(e,t){const{type:i,data:s}=t;if(!s||!s.byteLength)return;if("audio"===i&&this.audioDisabled_)return;const n=this.getInitSegmentAndUpdateState_({type:i,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:n,data:s})}loadSegment_(e){this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),"number"==typeof e.timestampOffset&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.hasEnoughInfoToLoad_()?this.updateTransmuxerAndRequestSegment_(e):this.loadQueue_.push((()=>{const t=_extends({},e,{forceTimestampOffset:!0});_extends(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)}))}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));const t=this.createSimplifiedSegmentObj_(e),i=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),s=null!==this.mediaIndex,n=e.timeline!==this.currentTimeline_&&e.timeline>0,r=i||s&&n;this.logger_(`Requesting ${segmentInfoString(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=mediaSegmentRequest({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:r,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:t,level:i,stream:s})=>{this.logger_(`${segmentInfoString(e)} logged from transmuxer stream ${s} as a ${i}: ${t}`)}})}trimBackBuffer_(e){const t=safeBackBufferTrimTime(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){const t=e.segment,i=e.part,s={resolvedUri:i?i.resolvedUri:t.resolvedUri,byterange:i?i.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part},n=e.playlist.segments[e.mediaIndex-1];if(n&&n.timeline===t.timeline&&(n.videoTimingInfo?s.baseStartTime=n.videoTimingInfo.transmuxedDecodeEnd:n.audioTimingInfo&&(s.baseStartTime=n.audioTimingInfo.transmuxedDecodeEnd)),t.key){const i=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);s.key=this.segmentKey(t.key),s.key.iv=i}return t.map&&(s.map=this.initSegmentForMap(t.map)),s}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){this.pendingSegment_.byteLength=t.bytesReceived,e<.016666666666666666?this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record 0.016666666666666666`):(this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime)}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,i){if(this.callQueue_.length)return void this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,i));if(this.saveTransferStats_(t.stats),!this.pendingSegment_)return;if(t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state="READY",e.code===REQUEST_ERRORS.ABORTED)return;return this.pause(),e.code===REQUEST_ERRORS.TIMEOUT?void this.handleTimeout_():(this.mediaRequestsErrored+=1,this.error(e),void this.trigger("error"))}const s=this.pendingSegment_;this.saveBandwidthRelatedStats_(s.duration,t.stats),s.endOfAllRequests=t.endOfAllRequests,i.gopInfo&&(this.gopBuffer_=updateGopBuffer(this.gopBuffer_,i.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(s)}setTimeMapping_(e){const t=this.syncController_.mappingForTimeline(e);null!==t&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){"number"==typeof e.start&&"number"==typeof e.end?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return null!==e&&("main"===this.loaderType_&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset())}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:i,firstVideoFrameTimeForData:s,currentVideoTimestampOffset:n,useVideoTimingInfo:r,videoTimingInfo:a,audioTimingInfo:o}){if(void 0!==e)return e;if(!r)return o.start;const l=t.segments[i-1];return 0!==i&&l&&void 0!==l.start&&l.end===s+n?a.start:s}waitForAppendsToComplete_(e){const t=this.getCurrentMediaInfo_(e);if(!t)return this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),void this.trigger("error");const{hasAudio:i,hasVideo:s,isMuxed:n}=t,r="main"===this.loaderType_&&s,a=!this.audioDisabled_&&i&&!n;if(e.waitingOnAppends=0,!e.hasAppendedData_)return e.timingInfo||"number"!=typeof e.timestampOffset||(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),void this.checkAppendsDone_(e);r&&e.waitingOnAppends++,a&&e.waitingOnAppends++,r&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),a&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,0===e.waitingOnAppends&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){const t=illegalMediaSwitch(this.loaderType_,this.getCurrentMediaInfo_(),e);return!!t&&(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger("error"),!0)}updateSourceBufferTimestampOffset_(e){if(null===e.timestampOffset||"number"!=typeof e.timingInfo.start||e.changedTimestampOffset||"main"!==this.loaderType_)return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:i}){return this.useDtsForTimestampOffset_?e&&"number"==typeof e.transmuxedDecodeStart?e.transmuxedDecodeStart:t&&"number"==typeof t.transmuxedDecodeStart?t.transmuxedDecodeStart:i.start:i.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};const t=this.getMediaInfo_(),i="main"===this.loaderType_&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;i&&(e.timingInfo.end="number"==typeof i.end?i.end:i.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_&&this.trigger("appendsdone"),!this.pendingSegment_)return this.state="READY",void(this.paused()||this.monitorBuffer_());const e=this.pendingSegment_;this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:"main"===this.loaderType_});const t=getTroublesomeSegmentDurationMessage(e,this.sourceType_);if(t&&("warn"===t.severity?videojs.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_))return void this.logger_(`Throwing away un-appended sync request ${segmentInfoString(e)}`);this.logger_(`Appended ${segmentInfoString(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),"main"!==this.loaderType_||this.audioDisabled_||this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");const i=e.segment,s=e.part,n=i.end&&this.currentTime_()-i.end>3*e.playlist.targetDuration,r=s&&s.end&&this.currentTime_()-s.end>3*e.playlist.partTargetDuration;if(n||r)return this.logger_(`bad ${n?"segment":"part"} ${segmentInfoString(e)}`),void this.resetEverything();null!==this.mediaIndex&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()}recordThroughput_(e){if(e.duration<.016666666666666666)return void this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record 0.016666666666666666`);const t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,s=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(s-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;const t=e.segment,i=t.start,s=t.end;if(!finite(i)||!finite(s))return;removeCuesFromTrack(i,s,this.segmentMetadataTrack_);const n=window$1.WebKitDataCue||window$1.VTTCue,r={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:i,end:s},a=new n(i,s,JSON.stringify(r));a.value=r,this.segmentMetadataTrack_.addCue(a)}}function noop(){}const toTitleCase=function(e){return"string"!=typeof e?e:e.replace(/./,(e=>e.toUpperCase()))},bufferTypes=["video","audio"],updating=(e,t)=>{const i=t[`${e}Buffer`];return i&&i.updating||t.queuePending[e]},nextQueueIndexOfType=(e,t)=>{for(let i=0;i<t.length;i++){const s=t[i];if("mediaSource"===s.type)return null;if(s.type===e)return i}return null},shiftQueue=(e,t)=>{if(0===t.queue.length)return;let i=0,s=t.queue[i];if("mediaSource"!==s.type){if("mediaSource"!==e&&t.ready()&&"closed"!==t.mediaSource.readyState&&!updating(e,t)){if(s.type!==e){if(i=nextQueueIndexOfType(e,t.queue),null===i)return;s=t.queue[i]}return t.queue.splice(i,1),t.queuePending[e]=s,s.action(e,t),s.doneFn?void 0:(t.queuePending[e]=null,void shiftQueue(e,t))}}else t.updating()||"closed"===t.mediaSource.readyState||(t.queue.shift(),s.action(t),s.doneFn&&s.doneFn(),shiftQueue("audio",t),shiftQueue("video",t))},cleanupBuffer=(e,t)=>{const i=t[`${e}Buffer`],s=toTitleCase(e);i&&(i.removeEventListener("updateend",t[`on${s}UpdateEnd_`]),i.removeEventListener("error",t[`on${s}Error_`]),t.codecs[e]=null,t[`${e}Buffer`]=null)},inSourceBuffers=(e,t)=>e&&t&&-1!==Array.prototype.indexOf.call(e.sourceBuffers,t),actions={appendBuffer:(e,t,i)=>(s,n)=>{const r=n[`${s}Buffer`];if(inSourceBuffers(n.mediaSource,r)){n.logger_(`Appending segment ${t.mediaIndex}'s ${e.length} bytes to ${s}Buffer`);try{r.appendBuffer(e)}catch(e){n.logger_(`Error with code ${e.code} `+(22===e.code?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${t.mediaIndex} to ${s}Buffer`),n.queuePending[s]=null,i(e)}}},remove:(e,t)=>(i,s)=>{const n=s[`${i}Buffer`];if(inSourceBuffers(s.mediaSource,n)){s.logger_(`Removing ${e} to ${t} from ${i}Buffer`);try{n.remove(e,t)}catch(n){s.logger_(`Remove ${e} to ${t} from ${i}Buffer failed`)}}},timestampOffset:e=>(t,i)=>{const s=i[`${t}Buffer`];inSourceBuffers(i.mediaSource,s)&&(i.logger_(`Setting ${t}timestampOffset to ${e}`),s.timestampOffset=e)},callback:e=>(t,i)=>{e()},endOfStream:e=>t=>{if("open"===t.mediaSource.readyState){t.logger_(`Calling mediaSource endOfStream(${e||""})`);try{t.mediaSource.endOfStream(e)}catch(e){videojs.log.warn("Failed to call media source endOfStream",e)}}},duration:e=>t=>{t.logger_(`Setting mediaSource duration to ${e}`);try{t.mediaSource.duration=e}catch(e){videojs.log.warn("Failed to set media source duration",e)}},abort:()=>(e,t)=>{if("open"!==t.mediaSource.readyState)return;const i=t[`${e}Buffer`];if(inSourceBuffers(t.mediaSource,i)){t.logger_(`calling abort on ${e}Buffer`);try{i.abort()}catch(t){videojs.log.warn(`Failed to abort on ${e}Buffer`,t)}}},addSourceBuffer:(e,t)=>i=>{const s=toTitleCase(e),n=getMimeForCodec(t);i.logger_(`Adding ${e}Buffer with codec ${t} to mediaSource`);const r=i.mediaSource.addSourceBuffer(n);r.addEventListener("updateend",i[`on${s}UpdateEnd_`]),r.addEventListener("error",i[`on${s}Error_`]),i.codecs[e]=t,i[`${e}Buffer`]=r},removeSourceBuffer:e=>t=>{const i=t[`${e}Buffer`];if(cleanupBuffer(e,t),inSourceBuffers(t.mediaSource,i)){t.logger_(`Removing ${e}Buffer with codec ${t.codecs[e]} from mediaSource`);try{t.mediaSource.removeSourceBuffer(i)}catch(t){videojs.log.warn(`Failed to removeSourceBuffer ${e}Buffer`,t)}}},changeType:e=>(t,i)=>{const s=i[`${t}Buffer`],n=getMimeForCodec(e);inSourceBuffers(i.mediaSource,s)&&i.codecs[t]!==e&&(i.logger_(`changing ${t}Buffer codec from ${i.codecs[t]} to ${e}`),s.changeType(n),i.codecs[t]=e)}},pushQueue=({type:e,sourceUpdater:t,action:i,doneFn:s,name:n})=>{t.queue.push({type:e,action:i,doneFn:s,name:n}),shiftQueue(e,t)},onUpdateend=(e,t)=>i=>{if(t.queuePending[e]){const i=t.queuePending[e].doneFn;t.queuePending[e]=null,i&&i(t[`${e}Error_`])}shiftQueue(e,t)};class SourceUpdater extends videojs.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>shiftQueue("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=logger("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=onUpdateend("video",this),this.onAudioUpdateEnd_=onUpdateend("audio",this),this.onVideoError_=e=>{this.videoError_=e},this.onAudioError_=e=>{this.audioError_=e},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,t){pushQueue({type:"mediaSource",sourceUpdater:this,action:actions.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){pushQueue({type:e,sourceUpdater:this,action:actions.abort(e),name:"abort"})}removeSourceBuffer(e){this.canRemoveSourceBuffer()?pushQueue({type:"mediaSource",sourceUpdater:this,action:actions.removeSourceBuffer(e),name:"removeSourceBuffer"}):videojs.log.error("removeSourceBuffer is not supported!")}canRemoveSourceBuffer(){return!videojs.browser.IE_VERSION&&!videojs.browser.IS_FIREFOX&&window$1.MediaSource&&window$1.MediaSource.prototype&&"function"==typeof window$1.MediaSource.prototype.removeSourceBuffer}static canChangeType(){return window$1.SourceBuffer&&window$1.SourceBuffer.prototype&&"function"==typeof window$1.SourceBuffer.prototype.changeType}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){this.canChangeType()?pushQueue({type:e,sourceUpdater:this,action:actions.changeType(t),name:"changeType"}):videojs.log.error("changeType is not supported!")}addOrChangeSourceBuffers(e){if(!e||"object"!=typeof e||0===Object.keys(e).length)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach((t=>{const i=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,i);this.canChangeType()&&this.changeType(t,i)}))}appendBuffer(e,t){const{segmentInfo:i,type:s,bytes:n}=e;if(this.processedAppend_=!0,"audio"===s&&this.videoBuffer&&!this.videoAppendQueued_)return this.delayedAudioAppendQueue_.push([e,t]),void this.logger_(`delayed audio append of ${n.length} until video append`);if(pushQueue({type:s,sourceUpdater:this,action:actions.appendBuffer(n,i||{mediaIndex:-1},t),doneFn:t,name:"appendBuffer"}),"video"===s){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;const e=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${e.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,e.forEach((e=>{this.appendBuffer.apply(this,e)}))}}audioBuffered(){return inSourceBuffers(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:createTimeRanges()}videoBuffered(){return inSourceBuffers(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:createTimeRanges()}buffered(){const e=inSourceBuffers(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=inSourceBuffers(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():bufferIntersection(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=noop){pushQueue({type:"mediaSource",sourceUpdater:this,action:actions.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=noop){"string"!=typeof e&&(e=void 0),pushQueue({type:"mediaSource",sourceUpdater:this,action:actions.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,i=noop){this.audioBuffered().length&&0!==this.audioBuffered().end(0)?pushQueue({type:"audio",sourceUpdater:this,action:actions.remove(e,t),doneFn:i,name:"remove"}):i()}removeVideo(e,t,i=noop){this.videoBuffered().length&&0!==this.videoBuffered().end(0)?pushQueue({type:"video",sourceUpdater:this,action:actions.remove(e,t),doneFn:i,name:"remove"}):i()}updating(){return!(!updating("audio",this)&&!updating("video",this))}audioTimestampOffset(e){return void 0!==e&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(pushQueue({type:"audio",sourceUpdater:this,action:actions.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return void 0!==e&&this.videoBuffer&&this.videoTimestampOffset!==e&&(pushQueue({type:"video",sourceUpdater:this,action:actions.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&pushQueue({type:"audio",sourceUpdater:this,action:actions.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&pushQueue({type:"video",sourceUpdater:this,action:actions.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),bufferTypes.forEach((e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`]((()=>cleanupBuffer(e,this)))})),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const uint8ToUtf8=e=>decodeURIComponent(escape(String.fromCharCode.apply(null,e))),VTT_LINE_TERMINATORS=new Uint8Array("\n\n".split("").map((e=>e.charCodeAt(0))));class NoVttJsError extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class VTTSegmentLoader extends SegmentLoader{constructor(e,t={}){super(e,t),this.mediaSource_=null,this.subtitlesTrack_=null,this.loaderType_="subtitle",this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}createTransmuxer_(){return null}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return createTimeRanges();const e=this.subtitlesTrack_.cues;return createTimeRanges([[e[0].startTime,e[e.length-1].startTime]])}initSegmentForMap(e,t=!1){if(!e)return null;const i=initSegmentId(e);let s=this.initSegments_[i];if(t&&!s&&e.bytes){const t=VTT_LINE_TERMINATORS.byteLength+e.bytes.byteLength,n=new Uint8Array(t);n.set(e.bytes),n.set(VTT_LINE_TERMINATORS,e.bytes.byteLength),this.initSegments_[i]=s={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:n}}return s||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return void 0===e||(this.subtitlesTrack_=e,"INIT"===this.state&&this.couldBeginLoading_()&&this.init_()),this.subtitlesTrack_}remove(e,t){removeCuesFromTrack(e,t,this.subtitlesTrack_)}fillBuffer_(){const e=this.chooseNextRequest_();if(e){if(null===this.syncController_.timestampOffsetForTimeline(e.timeline)){const e=()=>{this.state="READY",this.paused()||this.monitorBuffer_()};return this.syncController_.one("timestampoffset",e),void(this.state="WAITING_ON_TIMELINE")}this.loadSegment_(e)}}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,t,i){if(!this.subtitlesTrack_)return void(this.state="READY");if(this.saveTransferStats_(t.stats),!this.pendingSegment_)return this.state="READY",void(this.mediaRequestsAborted+=1);if(e)return e.code===REQUEST_ERRORS.TIMEOUT&&this.handleTimeout_(),e.code===REQUEST_ERRORS.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,void this.stopForError(e);const s=this.pendingSegment_;this.saveBandwidthRelatedStats_(s.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state="APPENDING",this.trigger("appending");const n=s.segment;if(n.map&&(n.map.bytes=t.map.bytes),s.bytes=t.bytes,"function"!=typeof window$1.WebVTT&&"function"==typeof this.loadVttJs)return this.state="WAITING_ON_VTTJS",void this.loadVttJs().then((()=>this.segmentRequestFinished_(e,t,i)),(()=>this.stopForError({message:"Error loading vtt.js"})));n.requested=!0;try{this.parseVTTCues_(s)}catch(e){return void this.stopForError({message:e.message})}if(this.updateTimeMapping_(s,this.syncController_.timelines[s.timeline],this.playlist_),s.cues.length?s.timingInfo={start:s.cues[0].startTime,end:s.cues[s.cues.length-1].endTime}:s.timingInfo={start:s.startOfSegment,end:s.startOfSegment+s.duration},s.isSyncRequest)return this.trigger("syncinfoupdate"),this.pendingSegment_=null,void(this.state="READY");s.byteLength=s.bytes.byteLength,this.mediaSecondsLoaded+=n.duration,s.cues.forEach((e=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new window$1.VTTCue(e.startTime,e.endTime,e.text):e)})),removeDuplicateCuesFromTrack(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(){}updateTimingInfoEnd_(){}parseVTTCues_(e){let t,i=!1;if("function"!=typeof window$1.WebVTT)throw new NoVttJsError;"function"==typeof window$1.TextDecoder?t=new window$1.TextDecoder("utf8"):(t=window$1.WebVTT.StringDecoder(),i=!0);const s=new window$1.WebVTT.Parser(window$1,window$1.vttjs,t);if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=e.cues.push.bind(e.cues),s.ontimestampmap=t=>{e.timestampmap=t},s.onparsingerror=e=>{videojs.log.warn("Error encountered when parsing cues: "+e.message)},e.segment.map){let t=e.segment.map.bytes;i&&(t=uint8ToUtf8(t)),s.parse(t)}let n=e.bytes;i&&(n=uint8ToUtf8(n)),s.parse(n),s.flush()}updateTimeMapping_(e,t,i){const s=e.segment;if(!t)return;if(!e.cues.length)return void(s.empty=!0);const n=e.timestampmap,r=n.MPEGTS/ONE_SECOND_IN_TS-n.LOCAL+t.mapping;if(e.cues.forEach((e=>{e.startTime+=r,e.endTime+=r})),!i.syncInfo){const t=e.cues[0].startTime,n=e.cues[e.cues.length-1].startTime;i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(t,n-s.duration)}}}}const findAdCue=function(e,t){const i=e.cues;for(let e=0;e<i.length;e++){const s=i[e];if(t>=s.adStartTime&&t<=s.adEndTime)return s}return null},updateAdCues=function(e,t,i=0){if(!e.segments)return;let s,n=i;for(let i=0;i<e.segments.length;i++){const r=e.segments[i];if(s||(s=findAdCue(t,n+r.duration/2)),s){if("cueIn"in r){s.endTime=n,s.adEndTime=n,n+=r.duration,s=null;continue}if(n<s.endTime){n+=r.duration;continue}s.endTime+=r.duration}else if("cueOut"in r&&(s=new window$1.VTTCue(n,n+r.duration,r.cueOut),s.adStartTime=n,s.adEndTime=n+parseFloat(r.cueOut),t.addCue(s)),"cueOutCont"in r){const[e,i]=r.cueOutCont.split("/").map(parseFloat);s=new window$1.VTTCue(n,n+r.duration,""),s.adStartTime=n-e,s.adEndTime=s.adStartTime+i,t.addCue(s)}n+=r.duration}},MAX_MEDIA_SEQUENCE_DIFF_FOR_SYNC=86400,syncPointStrategies=[{name:"VOD",run:(e,t,i,s,n)=>i!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"ProgramDateTime",run:(e,t,i,s,n)=>{if(!Object.keys(e.timelineToDatetimeMappings).length)return null;let r=null,a=null;const o=getPartsAndSegments(t);n=n||0;for(let i=0;i<o.length;i++){const s=o[t.endList||0===n?i:o.length-(i+1)],l=s.segment,d=e.timelineToDatetimeMappings[l.timeline];if(!d||!l.dateTimeObject)continue;let h=l.dateTimeObject.getTime()/1e3+d;if(l.parts&&"number"==typeof s.partIndex)for(let e=0;e<s.partIndex;e++)h+=l.parts[e].duration;const u=Math.abs(n-h);if(null!==a&&(0===u||a<u))break;a=u,r={time:h,segmentIndex:s.segmentIndex,partIndex:s.partIndex}}return r}},{name:"Segment",run:(e,t,i,s,n)=>{let r=null,a=null;n=n||0;const o=getPartsAndSegments(t);for(let e=0;e<o.length;e++){const i=o[t.endList||0===n?e:o.length-(e+1)],l=i.segment,d=i.part&&i.part.start||l&&l.start;if(l.timeline===s&&void 0!==d){const e=Math.abs(n-d);if(null!==a&&a<e)break;(!r||null===a||a>=e)&&(a=e,r={time:d,segmentIndex:i.segmentIndex,partIndex:i.partIndex})}}return r}},{name:"Discontinuity",run:(e,t,i,s,n)=>{let r=null;if(n=n||0,t.discontinuityStarts&&t.discontinuityStarts.length){let i=null;for(let s=0;s<t.discontinuityStarts.length;s++){const a=t.discontinuityStarts[s],o=t.discontinuitySequence+s+1,l=e.discontinuities[o];if(l){const e=Math.abs(n-l.time);if(null!==i&&i<e)break;(!r||null===i||i>=e)&&(i=e,r={time:l.time,segmentIndex:a,partIndex:null})}}}return r}},{name:"Playlist",run:(e,t,i,s,n)=>t.syncInfo?{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence,partIndex:null}:null}];class SyncController extends videojs.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={},this.logger_=logger("SyncController")}getSyncPoint(e,t,i,s){const n=this.runStrategies_(e,t,i,s);return n.length?this.selectSyncPoint_(n,{key:"time",value:s}):null}getExpiredTime(e,t){if(!e||!e.segments)return null;const i=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!i.length)return null;const s=this.selectSyncPoint_(i,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+sumDurations({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:s.segmentIndex,endIndex:0}))}runStrategies_(e,t,i,s){const n=[];for(let r=0;r<syncPointStrategies.length;r++){const a=syncPointStrategies[r],o=a.run(this,e,t,i,s);o&&(o.strategy=a.name,n.push({strategy:a.name,syncPoint:o}))}return n}selectSyncPoint_(e,t){let i=e[0].syncPoint,s=Math.abs(e[0].syncPoint[t.key]-t.value),n=e[0].strategy;for(let r=1;r<e.length;r++){const a=Math.abs(e[r].syncPoint[t.key]-t.value);a<s&&(s=a,i=e[r].syncPoint,n=e[r].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${n}]: [time:${i.time}, segmentIndex:${i.segmentIndex}`+("number"==typeof i.partIndex?`,partIndex:${i.partIndex}`:"")+"]"),i}saveExpiredSegmentInfo(e,t){const i=t.mediaSequence-e.mediaSequence;if(i>86400)videojs.log.warn(`Not saving expired segment info. Media sequence gap ${i} is too large.`);else for(let s=i-1;s>=0;s--){const i=e.segments[s];if(i&&void 0!==i.start){t.syncInfo={mediaSequence:e.mediaSequence+s,time:i.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],i=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-i}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const i=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),s=e.segment;i&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:s.start}));const n=s.dateTimeObject;s.discontinuity&&t&&n&&(this.timelineToDatetimeMappings[s.timeline]=-n.getTime()/1e3)}timestampOffsetForTimeline(e){return void 0===this.timelines[e]?null:this.timelines[e].time}mappingForTimeline(e){return void 0===this.timelines[e]?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,i){const s=e.segment,n=e.part;let r,a,o=this.timelines[e.timeline];if("number"==typeof e.timestampOffset)o={time:e.startOfSegment,mapping:e.startOfSegment-t.start},i&&(this.timelines[e.timeline]=o,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${o.time}] [mapping: ${o.mapping}]`)),r=e.startOfSegment,a=t.end+o.mapping;else{if(!o)return!1;r=t.start+o.mapping,a=t.end+o.mapping}return n&&(n.start=r,n.end=a),(!s.start||r<s.start)&&(s.start=r),s.end=a,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,i=e.segment;if(i.discontinuity)this.discontinuities[i.timeline]={time:i.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let s=0;s<t.discontinuityStarts.length;s++){const n=t.discontinuityStarts[s],r=t.discontinuitySequence+s+1,a=n-e.mediaIndex,o=Math.abs(a);if(!this.discontinuities[r]||this.discontinuities[r].accuracy>o){let s;s=a<0?i.start-sumDurations({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:n}):i.end+sumDurations({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:n}),this.discontinuities[r]={time:s,accuracy:o}}}}dispose(){this.trigger("dispose"),this.off()}}class TimelineChangeController extends videojs.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:i}){return"number"==typeof t&&"number"==typeof i&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:i},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:i}){return"number"==typeof t&&"number"==typeof i&&(this.lastTimelineChanges_[e]={type:e,from:t,to:i},delete this.pendingTimelineChanges_[e],this.trigger("timelinechange")),this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const workerCode=transform(getWorkerString((function(){var e=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){if(!this.listeners[e])return!1;var i=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(i,1),i>-1},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,s=0;s<i;++s)t[s].call(this,arguments[1]);else for(var n=Array.prototype.slice.call(arguments,1),r=t.length,a=0;a<r;++a)t[a].apply(this,n)},t.dispose=function(){this.listeners={}},t.pipe=function(e){this.on("data",(function(t){e.push(t)}))},e}();let t=null;class i{constructor(e){let i,s,n;t||(t=function(){const e=[[[],[],[],[],[]],[[],[],[],[],[]]],t=e[0],i=e[1],s=t[4],n=i[4];let r,a,o;const l=[],d=[];let h,u,c,p,m,g;for(r=0;r<256;r++)d[(l[r]=r<<1^283*(r>>7))^r]=r;for(a=o=0;!s[a];a^=h||1,o=d[o]||1)for(p=o^o<<1^o<<2^o<<3^o<<4,p=p>>8^255&p^99,s[a]=p,n[p]=a,c=l[u=l[h=l[a]]],g=16843009*c^65537*u^257*h^16843008*a,m=257*l[p]^16843008*p,r=0;r<4;r++)t[r][a]=m=m<<24^m>>>8,i[r][p]=g=g<<24^g>>>8;for(r=0;r<5;r++)t[r]=t[r].slice(0),i[r]=i[r].slice(0);return e}()),this._tables=[[t[0][0].slice(),t[0][1].slice(),t[0][2].slice(),t[0][3].slice(),t[0][4].slice()],[t[1][0].slice(),t[1][1].slice(),t[1][2].slice(),t[1][3].slice(),t[1][4].slice()]];const r=this._tables[0][4],a=this._tables[1],o=e.length;let l=1;if(4!==o&&6!==o&&8!==o)throw new Error("Invalid aes key size");const d=e.slice(0),h=[];for(this._key=[d,h],i=o;i<4*o+28;i++)n=d[i-1],(i%o==0||8===o&&i%o==4)&&(n=r[n>>>24]<<24^r[n>>16&255]<<16^r[n>>8&255]<<8^r[255&n],i%o==0&&(n=n<<8^n>>>24^l<<24,l=l<<1^283*(l>>7))),d[i]=d[i-o]^n;for(s=0;i;s++,i--)n=d[3&s?i:i-4],h[s]=i<=4||s<4?n:a[0][r[n>>>24]]^a[1][r[n>>16&255]]^a[2][r[n>>8&255]]^a[3][r[255&n]]}decrypt(e,t,i,s,n,r){const a=this._key[1];let o,l,d,h=e^a[0],u=s^a[1],c=i^a[2],p=t^a[3];const m=a.length/4-2;let g,f=4;const _=this._tables[1],y=_[0],T=_[1],v=_[2],b=_[3],S=_[4];for(g=0;g<m;g++)o=y[h>>>24]^T[u>>16&255]^v[c>>8&255]^b[255&p]^a[f],l=y[u>>>24]^T[c>>16&255]^v[p>>8&255]^b[255&h]^a[f+1],d=y[c>>>24]^T[p>>16&255]^v[h>>8&255]^b[255&u]^a[f+2],p=y[p>>>24]^T[h>>16&255]^v[u>>8&255]^b[255&c]^a[f+3],f+=4,h=o,u=l,c=d;for(g=0;g<4;g++)n[(3&-g)+r]=S[h>>>24]<<24^S[u>>16&255]<<16^S[c>>8&255]<<8^S[255&p]^a[f++],o=h,h=u,u=c,c=p,p=o}}class s extends e{constructor(){super(e),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(e){this.jobs.push(e),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const n=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24};class r{constructor(e,t,i,a){const o=r.STEP,l=new Int32Array(e.buffer),d=new Uint8Array(e.byteLength);let h=0;for(this.asyncStream_=new s,this.asyncStream_.push(this.decryptChunk_(l.subarray(h,h+o),t,i,d)),h=o;h<l.length;h+=o)i=new Uint32Array([n(l[h-4]),n(l[h-3]),n(l[h-2]),n(l[h-1])]),this.asyncStream_.push(this.decryptChunk_(l.subarray(h,h+o),t,i,d));this.asyncStream_.push((function(){var e;a(null,(e=d).subarray(0,e.byteLength-e[e.byteLength-1]))}))}static get STEP(){return 32e3}decryptChunk_(e,t,s,r){return function(){const a=function(e,t,s){const r=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),a=new i(Array.prototype.slice.call(t)),o=new Uint8Array(e.byteLength),l=new Int32Array(o.buffer);let d,h,u,c,p,m,g,f,_;for(d=s[0],h=s[1],u=s[2],c=s[3],_=0;_<r.length;_+=4)p=n(r[_]),m=n(r[_+1]),g=n(r[_+2]),f=n(r[_+3]),a.decrypt(p,m,g,f,l,_),l[_]=n(l[_]^d),l[_+1]=n(l[_+1]^h),l[_+2]=n(l[_+2]^u),l[_+3]=n(l[_+3]^c),d=p,h=m,u=g,c=f;return o}(e,t,s);r.set(a,e.byteOffset)}}}var a,o,l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},d=("undefined"!=typeof window?window:void 0!==l?l:"undefined"!=typeof self?self:{}).BigInt||Number;d("0x1"),d("0x100"),d("0x10000"),d("0x1000000"),d("0x100000000"),d("0x10000000000"),d("0x1000000000000"),d("0x100000000000000"),d("0x10000000000000000"),a=new Uint16Array([65484]),255===(o=new Uint8Array(a.buffer,a.byteOffset,a.byteLength))[0]||o[0];self.onmessage=function(e){const t=e.data,i=new Uint8Array(t.encrypted.bytes,t.encrypted.byteOffset,t.encrypted.byteLength),s=new Uint32Array(t.key.bytes,t.key.byteOffset,t.key.byteLength/4),n=new Uint32Array(t.iv.bytes,t.iv.byteOffset,t.iv.byteLength/4);new r(i,s,n,(function(e,i){self.postMessage(function(e){const t={};return Object.keys(e).forEach((i=>{const s=e[i];var n;n=s,("function"===ArrayBuffer.isView?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer)?t[i]={bytes:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength}:t[i]=s})),t}({source:t.source,decrypted:i}),[i.buffer])}))}})));var Decrypter=factory(workerCode);const audioTrackKind_=e=>{let t=e.default?"main":"alternative";return e.characteristics&&e.characteristics.indexOf("public.accessibility.describes-video")>=0&&(t="main-desc"),t},stopLoaders=(e,t)=>{e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null)},startLoaders=(e,t)=>{t.activePlaylistLoader=e,e.load()},onGroupChanged=(e,t)=>()=>{const{segmentLoaders:{[e]:i,main:s},mediaTypes:{[e]:n}}=t,r=n.activeTrack(),a=n.getActiveGroup(),o=n.activePlaylistLoader,l=n.lastGroup_;a&&l&&a.id===l.id||(n.lastGroup_=a,n.lastTrack_=r,stopLoaders(i,n),a&&!a.isMainPlaylist&&(a.playlistLoader?(i.resyncLoader(),startLoaders(a.playlistLoader,n)):o&&s.resetEverything()))},onGroupChanging=(e,t)=>()=>{const{segmentLoaders:{[e]:i},mediaTypes:{[e]:s}}=t;s.lastGroup_=null,i.abort(),i.pause()},onTrackChanged=(e,t)=>()=>{const{mainPlaylistLoader:i,segmentLoaders:{[e]:s,main:n},mediaTypes:{[e]:r}}=t,a=r.activeTrack(),o=r.getActiveGroup(),l=r.activePlaylistLoader,d=r.lastTrack_;if((!d||!a||d.id!==a.id)&&(r.lastGroup_=o,r.lastTrack_=a,stopLoaders(s,r),o)){if(o.isMainPlaylist){if(!a||!d||a.id===d.id)return;const e=t.vhs.playlistController_,s=e.selectPlaylist();if(e.media()===s)return;return r.logger_(`track change. Switching main audio from ${d.id} to ${a.id}`),i.pause(),n.resetEverything(),void e.fastQualityChange_(s)}if("AUDIO"===e){if(!o.playlistLoader)return n.setAudio(!0),void n.resetEverything();s.setAudio(!0),n.setAudio(!1)}l!==o.playlistLoader?(s.track&&s.track(a),s.resetEverything(),startLoaders(o.playlistLoader,r)):startLoaders(o.playlistLoader,r)}},onError={AUDIO:(e,t)=>()=>{const{segmentLoaders:{[e]:i},mediaTypes:{[e]:s},excludePlaylist:n}=t;stopLoaders(i,s);const r=s.activeTrack(),a=s.activeGroup(),o=(a.filter((e=>e.default))[0]||a[0]).id,l=s.tracks[o];if(r!==l){videojs.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const e in s.tracks)s.tracks[e].enabled=s.tracks[e]===l;s.onTrackChanged()}else n({error:{message:"Problem encountered loading the default audio track."}})},SUBTITLES:(e,t)=>()=>{const{segmentLoaders:{[e]:i},mediaTypes:{[e]:s}}=t;videojs.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),stopLoaders(i,s);const n=s.activeTrack();n&&(n.mode="disabled"),s.onTrackChanged()}},setupListeners={AUDIO:(e,t,i)=>{if(!t)return;const{tech:s,requestOptions:n,segmentLoaders:{[e]:r}}=i;t.on("loadedmetadata",(()=>{const e=t.media();r.playlist(e,n),(!s.paused()||e.endList&&"none"!==s.preload())&&r.load()})),t.on("loadedplaylist",(()=>{r.playlist(t.media(),n),s.paused()||r.load()})),t.on("error",onError[e](e,i))},SUBTITLES:(e,t,i)=>{const{tech:s,requestOptions:n,segmentLoaders:{[e]:r},mediaTypes:{[e]:a}}=i;t.on("loadedmetadata",(()=>{const e=t.media();r.playlist(e,n),r.track(a.activeTrack()),(!s.paused()||e.endList&&"none"!==s.preload())&&r.load()})),t.on("loadedplaylist",(()=>{r.playlist(t.media(),n),s.paused()||r.load()})),t.on("error",onError[e](e,i))}},initialize={AUDIO:(e,t)=>{const{vhs:i,sourceType:s,segmentLoaders:{[e]:n},requestOptions:r,main:{mediaGroups:a},mediaTypes:{[e]:{groups:o,tracks:l,logger_:d}},mainPlaylistLoader:h}=t,u=isAudioOnly(h.main);a[e]&&0!==Object.keys(a[e]).length||(a[e]={main:{default:{default:!0}}},u&&(a[e].main.default.playlists=h.main.playlists));for(const n in a[e]){o[n]||(o[n]=[]);for(const c in a[e][n]){let p,m=a[e][n][c];if(u?(d(`AUDIO group '${n}' label '${c}' is a main playlist`),m.isMainPlaylist=!0,p=null):p="vhs-json"===s&&m.playlists?new PlaylistLoader(m.playlists[0],i,r):m.resolvedUri?new PlaylistLoader(m.resolvedUri,i,r):m.playlists&&"dash"===s?new DashPlaylistLoader(m.playlists[0],i,r,h):null,m=merge({id:c,playlistLoader:p},m),setupListeners[e](e,m.playlistLoader,t),o[n].push(m),void 0===l[c]){const e=new videojs.AudioTrack({id:c,kind:audioTrackKind_(m),enabled:!1,language:m.language,default:m.default,label:c});l[c]=e}}}n.on("error",onError[e](e,t))},SUBTITLES:(e,t)=>{const{tech:i,vhs:s,sourceType:n,segmentLoaders:{[e]:r},requestOptions:a,main:{mediaGroups:o},mediaTypes:{[e]:{groups:l,tracks:d}},mainPlaylistLoader:h}=t;for(const r in o[e]){l[r]||(l[r]=[]);for(const u in o[e][r]){if(o[e][r][u].forced)continue;let c,p=o[e][r][u];if("hls"===n)c=new PlaylistLoader(p.resolvedUri,s,a);else if("dash"===n){if(!p.playlists.filter((e=>e.excludeUntil!==1/0)).length)return;c=new DashPlaylistLoader(p.playlists[0],s,a,h)}else"vhs-json"===n&&(c=new PlaylistLoader(p.playlists?p.playlists[0]:p.resolvedUri,s,a));if(p=merge({id:u,playlistLoader:c},p),setupListeners[e](e,p.playlistLoader,t),l[r].push(p),void 0===d[u]){const e=i.addRemoteTextTrack({id:u,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:u},!1).track;d[u]=e}}}r.on("error",onError[e](e,t))},"CLOSED-CAPTIONS":(e,t)=>{const{tech:i,main:{mediaGroups:s},mediaTypes:{[e]:{groups:n,tracks:r}}}=t;for(const t in s[e]){n[t]||(n[t]=[]);for(const a in s[e][t]){const o=s[e][t][a];if(!/^(?:CC|SERVICE)/.test(o.instreamId))continue;const l=i.options_.vhs&&i.options_.vhs.captionServices||{};let d={label:a,language:o.language,instreamId:o.instreamId,default:o.default&&o.autoselect};if(l[d.instreamId]&&(d=merge(d,l[d.instreamId])),void 0===d.default&&delete d.default,n[t].push(merge({id:a},o)),void 0===r[a]){const e=i.addRemoteTextTrack({id:d.instreamId,kind:"captions",default:d.default,language:d.language,label:d.label},!1).track;r[a]=e}}}}},groupMatch=(e,t)=>{for(let i=0;i<e.length;i++){if(playlistMatch(t,e[i]))return!0;if(e[i].playlists&&groupMatch(e[i].playlists,t))return!0}return!1},activeGroup=(e,t)=>i=>{const{mainPlaylistLoader:s,mediaTypes:{[e]:{groups:n}}}=t,r=s.media();if(!r)return null;let a=null;r.attributes[e]&&(a=n[r.attributes[e]]);const o=Object.keys(n);if(!a)if("AUDIO"===e&&o.length>1&&isAudioOnly(t.main))for(let e=0;e<o.length;e++){const t=n[o[e]];if(groupMatch(t,r)){a=t;break}}else n.main?a=n.main:1===o.length&&(a=n[o[0]]);return void 0===i?a:null!==i&&a&&a.filter((e=>e.id===i.id))[0]||null},activeTrack={AUDIO:(e,t)=>()=>{const{mediaTypes:{[e]:{tracks:i}}}=t;for(const e in i)if(i[e].enabled)return i[e];return null},SUBTITLES:(e,t)=>()=>{const{mediaTypes:{[e]:{tracks:i}}}=t;for(const e in i)if("showing"===i[e].mode||"hidden"===i[e].mode)return i[e];return null}},getActiveGroup=(e,{mediaTypes:t})=>()=>{const i=t[e].activeTrack();return i?t[e].activeGroup(i):null},setupMediaGroups=e=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((t=>{initialize[t](t,e)}));const{mediaTypes:t,mainPlaylistLoader:i,tech:s,vhs:n,segmentLoaders:{AUDIO:r,main:a}}=e;["AUDIO","SUBTITLES"].forEach((i=>{t[i].activeGroup=activeGroup(i,e),t[i].activeTrack=activeTrack[i](i,e),t[i].onGroupChanged=onGroupChanged(i,e),t[i].onGroupChanging=onGroupChanging(i,e),t[i].onTrackChanged=onTrackChanged(i,e),t[i].getActiveGroup=getActiveGroup(i,e)}));const o=t.AUDIO.activeGroup();if(o){const e=(o.filter((e=>e.default))[0]||o[0]).id;t.AUDIO.tracks[e].enabled=!0,t.AUDIO.onGroupChanged(),t.AUDIO.onTrackChanged(),t.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),r.setAudio(!0)):a.setAudio(!0)}i.on("mediachange",(()=>{["AUDIO","SUBTITLES"].forEach((e=>t[e].onGroupChanged()))})),i.on("mediachanging",(()=>{["AUDIO","SUBTITLES"].forEach((e=>t[e].onGroupChanging()))}));const l=()=>{t.AUDIO.onTrackChanged(),s.trigger({type:"usage",name:"vhs-audio-change"})};s.audioTracks().addEventListener("change",l),s.remoteTextTracks().addEventListener("change",t.SUBTITLES.onTrackChanged),n.on("dispose",(()=>{s.audioTracks().removeEventListener("change",l),s.remoteTextTracks().removeEventListener("change",t.SUBTITLES.onTrackChanged)})),s.clearTracks("audio");for(const e in t.AUDIO.tracks)s.audioTracks().addTrack(t.AUDIO.tracks[e])},createMediaTypes=()=>{const e={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((t=>{e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:noop,activeTrack:noop,getActiveGroup:noop,onGroupChanged:noop,onTrackChanged:noop,lastTrack_:null,logger_:logger(`MediaGroups[${t}]`)}})),e},ABORT_EARLY_EXCLUSION_SECONDS=120;let Vhs$1;const loaderStats=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],sumLoaderStat=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},shouldSwitchToMedia=function({currentPlaylist:e,buffered:t,currentTime:i,nextPlaylist:s,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:a,bufferBasedABR:o,log:l}){if(!s)return videojs.log.warn("We received no playlist to switch to. Please check your stream."),!1;const d=`allowing switch ${e&&e.id||"null"} -> ${s.id}`;if(!e)return l(`${d} as current playlist is not set`),!0;if(s.id===e.id)return!1;const h=Boolean(findRange(t,i).length);if(!e.endList)return h||"number"!=typeof e.partTargetDuration?(l(`${d} as current playlist is live`),!0):(l(`not ${d} as current playlist is live llhls, but currentTime isn't in buffered.`),!1);const u=timeAheadOf(t,i),c=o?Config.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Config.MAX_BUFFER_LOW_WATER_LINE;if(a<c)return l(`${d} as duration < max low water line (${a} < ${c})`),!0;const p=s.attributes.BANDWIDTH,m=e.attributes.BANDWIDTH;if(p<m&&(!o||u<r)){let e=`${d} as next bandwidth < current bandwidth (${p} < ${m})`;return o&&(e+=` and forwardBuffer < bufferHighWaterLine (${u} < ${r})`),l(e),!0}if((!o||p>m)&&u>=n){let e=`${d} as forwardBuffer >= bufferLowWaterLine (${u} >= ${n})`;return o&&(e+=` and next bandwidth > current bandwidth (${p} > ${m})`),l(e),!0}return l(`not ${d} as no switching criteria met`),!1};class PlaylistController extends videojs.EventTarget{constructor(e){super();const{src:t,withCredentials:i,tech:s,bandwidth:n,externVhs:r,useCueTags:a,playlistExclusionDuration:o,enableLowInitialPlaylist:l,sourceType:d,cacheEncryptionKeys:h,bufferBasedABR:u,leastPixelDiffSelector:c,captionServices:p}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:m}=e;null==m&&(m=1/0),Vhs$1=r,this.bufferBasedABR=Boolean(u),this.leastPixelDiffSelector=Boolean(c),this.withCredentials=i,this.tech_=s,this.vhs_=s.vhs,this.sourceType_=d,this.useCueTags_=a,this.playlistExclusionDuration=o,this.maxPlaylistRetries=m,this.enableLowInitialPlaylist=l,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:i,maxPlaylistRetries:m,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=createMediaTypes(),this.mediaSource=new window$1.MediaSource,this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.seekable_=createTimeRanges(),this.hasPlayed_=!1,this.syncController_=new SyncController(e),this.segmentMetadataTrack_=s.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new Decrypter,this.sourceUpdater_=new SourceUpdater(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new TimelineChangeController;const g={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:p,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:n,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:h,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings};this.mainPlaylistLoader_="dash"===this.sourceType_?new DashPlaylistLoader(t,this.vhs_,this.requestOptions_):new PlaylistLoader(t,this.vhs_,this.requestOptions_),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new SegmentLoader(merge(g,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new SegmentLoader(merge(g,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new VTTSegmentLoader(merge(g,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise(((e,t)=>{function i(){s.off("vttjserror",n),e()}function n(){s.off("vttjsloaded",i),t()}s.one("vttjsloaded",i),s.one("vttjserror",n),s.addWebVttScript_()}))}),e),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",(()=>this.startABRTimer_())),this.tech_.on("pause",(()=>this.stopABRTimer_())),this.tech_.on("play",(()=>this.startABRTimer_()))),loaderStats.forEach((e=>{this[e+"_"]=sumLoaderStat.bind(this,e)})),this.logger_=logger("pc"),this.triggeredFmp4Usage=!1,"none"===this.tech_.preload()?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const f="none"===this.tech_.preload()?"play":"loadstart";this.tech_.one(f,(()=>{const e=Date.now();this.tech_.one("loadeddata",(()=>{this.timeToLoadedData__=Date.now()-e,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends}))}))}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return-1===e||-1===t?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,i){const s=this.media(),n=s&&(s.id||s.uri),r=e.id||e.uri;n&&n!==r&&(this.logger_(`switch media ${n} -> ${r} from ${t}`),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})),this.mainPlaylistLoader_.media(e,i)}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=window$1.setInterval((()=>this.checkABR_()),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(window$1.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const i=e.mediaGroups.AUDIO,s=Object.keys(i);let n;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)n=this.mediaTypes_.AUDIO.activeTrack();else{const e=i.main||s.length&&i[s[0]];for(const t in e)if(e[t].default){n={label:t};break}}if(!n)return t;const r=[];for(const t in i)if(i[t][n.label]){const s=i[t][n.label];if(s.playlists&&s.playlists.length)r.push.apply(r,s.playlists);else if(s.uri)r.push(s);else if(e.playlists.length)for(let i=0;i<e.playlists.length;i++){const s=e.playlists[i];s.attributes&&s.attributes.AUDIO&&s.attributes.AUDIO===t&&r.push(s)}}return r.length?r:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",(()=>{const e=this.mainPlaylistLoader_.media(),t=1.5*e.targetDuration*1e3;isLowestEnabledRendition(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&"none"!==this.tech_.preload()&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),setupMediaGroups({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",(()=>{this.trigger("selectedinitialmedia")}))})),this.mainPlaylistLoader_.on("loadedplaylist",(()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){let t;if(this.excludeUnsupportedVariants_(),this.enableLowInitialPlaylist&&(t=this.selectInitialPlaylist()),t||(t=this.selectPlaylist()),!t||!this.shouldSwitchToMedia_(t))return;if(this.initialMedia_=t,this.switchMedia_(this.initialMedia_,"initial"),"vhs-json"!==this.sourceType_||!this.initialMedia_.segments)return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)})),this.mainPlaylistLoader_.on("error",(()=>{const e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})})),this.mainPlaylistLoader_.on("mediachanging",(()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()})),this.mainPlaylistLoader_.on("mediachange",(()=>{const e=this.mainPlaylistLoader_.media(),t=1.5*e.targetDuration*1e3;isLowestEnabledRendition(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})})),this.mainPlaylistLoader_.on("playlistunchanged",(()=>{const e=this.mainPlaylistLoader_.media();"playlist-unchanged"!==e.lastExcludeReason_&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))})),this.mainPlaylistLoader_.on("renditiondisabled",(()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})})),this.mainPlaylistLoader_.on("renditionenabled",(()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}))}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const i=e.mediaGroups||{};let s=!0;const n=Object.keys(i.AUDIO);for(const e in i.AUDIO)for(const t in i.AUDIO[e])i.AUDIO[e][t].uri||(s=!1);s&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(i.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),Vhs$1.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),n.length&&Object.keys(i.AUDIO[n[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,i=this.tech_.currentTime(),s=this.bufferLowWaterLine(),n=this.bufferHighWaterLine(),r=this.tech_.buffered();return shouldSwitchToMedia({buffered:r,currentTime:i,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:s,bufferHighWaterLine:n,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",(()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")})),this.mainSegmentLoader_.on("timeout",(()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()})),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",(()=>{this.trigger("progress")})),this.mainSegmentLoader_.on("error",(()=>{const e=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:e.playlist,error:e})})),this.mainSegmentLoader_.on("appenderror",(()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")})),this.mainSegmentLoader_.on("syncinfoupdate",(()=>{this.onSyncInfoUpdate_()})),this.mainSegmentLoader_.on("timestampoffset",(()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})})),this.audioSegmentLoader_.on("syncinfoupdate",(()=>{this.onSyncInfoUpdate_()})),this.audioSegmentLoader_.on("appenderror",(()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")})),this.mainSegmentLoader_.on("ended",(()=>{this.logger_("main segment loader ended"),this.onEndOfStream()})),this.mainSegmentLoader_.on("earlyabort",(e=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:120}))}));const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const e=this.getCodecsOrExclude_();e&&this.sourceUpdater_.addOrChangeSourceBuffers(e)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",(()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)})),this.audioSegmentLoader_.on("fmp4",(()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)})),this.audioSegmentLoader_.on("ended",(()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}))}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}fastQualityChange_(e=this.selectPlaylist()){e!==this.mainPlaylistLoader_.media()?(this.switchMedia_(e,"fast-quality"),this.mainSegmentLoader_.resetEverything((()=>{videojs.browser.IE_VERSION||videojs.browser.IS_EDGE?this.tech_.setCurrentTime(this.tech_.currentTime()+.04):this.tech_.setCurrentTime(this.tech_.currentTime())}))):this.logger_("skipping fastQualityChange because new media is same as old")}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();return this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0)?this.tech_.setCurrentTime(e.end(e.length-1)):void 0}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList){const e=this.seekable();if(!e.length)return!1;if(videojs.browser.IE_VERSION&&0===this.tech_.readyState())return this.tech_.one("loadedmetadata",(()=>{this.trigger("firstplay"),this.tech_.setCurrentTime(e.end(0)),this.hasPlayed_=!0})),!1;this.trigger("firstplay"),this.tech_.setCurrentTime(e.end(0))}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();void 0!==e&&"function"==typeof e.then&&e.then(null,(e=>{}))}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();e=!t||t.hasVideo?e&&this.audioSegmentLoader_.ended_:this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const t=this.syncController_.getExpiredTime(e,this.duration());if(null===t)return!1;const i=Vhs$1.Playlist.playlistEnd(e,t),s=this.tech_.currentTime(),n=this.tech_.buffered();if(!n.length)return i-s<=.1;const r=n.end(n.length-1);return r-s<=.1&&i-r<=.1}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:i}){if(e=e||this.mainPlaylistLoader_.media(),i=i||t.playlistExclusionDuration||this.playlistExclusionDuration,!e)return this.error=t,void("open"!==this.mediaSource.readyState?this.trigger("error"):this.sourceUpdater_.endOfStream("network"));e.playlistErrors_++;const s=this.mainPlaylistLoader_.main.playlists,n=s.filter(isEnabled),r=1===n.length&&n[0]===e;if(1===s.length&&i!==1/0)return videojs.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(r);if(r){let t=!1;s.forEach((i=>{if(i===e)return;const s=i.excludeUntil;void 0!==s&&s!==1/0&&(t=!0,delete i.excludeUntil)})),t&&(videojs.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let a;a=e.playlistErrors_>this.maxPlaylistRetries?1/0:Date.now()+1e3*i,e.excludeUntil=a,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const o=this.selectPlaylist();if(!o)return this.error="Playback cannot continue. No available working or supported playlists.",void this.trigger("error");const l=t.internal?this.logger_:videojs.log.warn,d=t.message?" "+t.message:"";l(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${d} Switching to playlist ${o.id}.`),o.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),o.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const h=o.targetDuration/2*1e3||5e3,u="number"==typeof o.lastRequest&&Date.now()-o.lastRequest<=h;return this.switchMedia_(o,"exclude",r||u)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const i=[],s="all"===e;(s||"main"===e)&&i.push(this.mainPlaylistLoader_);const n=[];(s||"audio"===e)&&n.push("AUDIO"),(s||"subtitle"===e)&&(n.push("CLOSED-CAPTIONS"),n.push("SUBTITLES")),n.forEach((e=>{const t=this.mediaTypes_[e]&&this.mediaTypes_[e].activePlaylistLoader;t&&i.push(t)})),["main","audio","subtitle"].forEach((t=>{const s=this[`${t}SegmentLoader_`];!s||e!==t&&"all"!==e||i.push(s)})),i.forEach((e=>t.forEach((t=>{"function"==typeof e[t]&&e[t]()}))))}setCurrentTime(e){const t=findRange(this.tech_.buffered(),e);return this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media()&&this.mainPlaylistLoader_.media().segments?t&&t.length?e:(this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),void this.load()):0}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:Vhs$1.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}onSyncInfoUpdate_(){let e;if(!this.mainPlaylistLoader_)return;let t=this.mainPlaylistLoader_.media();if(!t)return;let i=this.syncController_.getExpiredTime(t,this.duration());if(null===i)return;const s=this.mainPlaylistLoader_.main,n=Vhs$1.Playlist.seekable(t,i,Vhs$1.Playlist.liveEdgeDelay(s,t));if(0===n.length)return;if(this.mediaTypes_.AUDIO.activePlaylistLoader){if(t=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),i=this.syncController_.getExpiredTime(t,this.duration()),null===i)return;if(e=Vhs$1.Playlist.seekable(t,i,Vhs$1.Playlist.liveEdgeDelay(s,t)),0===e.length)return}let r,a;this.seekable_&&this.seekable_.length&&(r=this.seekable_.end(0),a=this.seekable_.start(0)),e?e.start(0)>n.end(0)||n.start(0)>e.end(0)?this.seekable_=n:this.seekable_=createTimeRanges([[e.start(0)>n.start(0)?e.start(0):n.start(0),e.end(0)<n.end(0)?e.end(0):n.end(0)]]):this.seekable_=n,this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===r&&this.seekable_.start(0)===a||(this.logger_(`seekable updated [${printableRange(this.seekable_)}]`),this.tech_.trigger("seekablechanged"))}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),"open"!==this.mediaSource.readyState)return this.updateDuration_=this.updateDuration.bind(this,e),void this.mediaSource.addEventListener("sourceopen",this.updateDuration_);if(e){const e=this.seekable();if(!e.length)return;return void((isNaN(this.mediaSource.duration)||this.mediaSource.duration<e.end(e.length-1))&&this.sourceUpdater_.setDuration(e.end(e.length-1)))}const t=this.tech_.buffered();let i=Vhs$1.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(i=Math.max(i,t.end(t.length-1))),this.mediaSource.duration!==i&&this.sourceUpdater_.setDuration(i)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach((e=>{const t=this.mediaTypes_[e].groups;for(const e in t)t[e].forEach((e=>{e.playlistLoader&&e.playlistLoader.dispose()}))})),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),i=!e||!!this.audioSegmentLoader_.getCurrentMediaInfo_();return!(!t||!i)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const i=codecsForPlaylist(this.main(),t),s={},n=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(s.video=i.video||e.main.videoCodec||DEFAULT_VIDEO_CODEC),e.main.isMuxed&&(s.video+=`,${i.audio||e.main.audioCodec||DEFAULT_AUDIO_CODEC}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||n)&&(s.audio=i.audio||e.main.audioCodec||e.audio.audioCodec||DEFAULT_AUDIO_CODEC,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!s.audio&&!s.video)return void this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});const r={};let a;if(["video","audio"].forEach((function(t){if(s.hasOwnProperty(t)&&(i=e[t].isFmp4,n=s[t],!(i?browserSupportsCodec(n):muxerSupportsCodec(n)))){const i=e[t].isFmp4?"browser":"muxer";r[i]=r[i]||[],r[i].push(s[t]),"audio"===t&&(a=i)}var i,n})),n&&a&&t.attributes.AUDIO){const e=t.attributes.AUDIO;this.main().playlists.forEach((i=>{(i.attributes&&i.attributes.AUDIO)===e&&i!==t&&(i.excludeUntil=1/0)})),this.logger_(`excluding audio group ${e} as ${a} does not support codec(s): "${s.audio}"`)}if(!Object.keys(r).length){if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const e=[];if(["video","audio"].forEach((t=>{const i=(parseCodecs(this.sourceUpdater_.codecs[t]||"")[0]||{}).type,n=(parseCodecs(s[t]||"")[0]||{}).type;i&&n&&i.toLowerCase()!==n.toLowerCase()&&e.push(`"${this.sourceUpdater_.codecs[t]}" -> "${s[t]}"`)})),e.length)return void this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${e.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0})}return s}{const e=Object.keys(r).reduce(((e,t)=>(e&&(e+=", "),e+`${t} does not support codec(s): "${r[t].join(",")}"`)),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:e},playlistExclusionDuration:1/0})}}tryToCreateSourceBuffers_(){if("open"!==this.mediaSource.readyState||this.sourceUpdater_.hasCreatedSourceBuffers())return;if(!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach((i=>{const s=e[i];if(-1!==t.indexOf(s.id))return;t.push(s.id);const n=codecsForPlaylist(this.main,s),r=[];!n.audio||muxerSupportsCodec(n.audio)||browserSupportsCodec(n.audio)||r.push(`audio codec ${n.audio}`),!n.video||muxerSupportsCodec(n.video)||browserSupportsCodec(n.video)||r.push(`video codec ${n.video}`),n.text&&"stpp.ttml.im1t"===n.text&&r.push(`text codec ${n.text}`),r.length&&(s.excludeUntil=1/0,this.logger_(`excluding ${s.id} for unsupported: ${r.join(", ")}`))}))}excludeIncompatibleVariants_(e){const t=[],i=this.main().playlists,s=unwrapCodecList(parseCodecs(e)),n=codecCount(s),r=s.video&&parseCodecs(s.video)[0]||null,a=s.audio&&parseCodecs(s.audio)[0]||null;Object.keys(i).forEach((e=>{const s=i[e];if(-1!==t.indexOf(s.id)||s.excludeUntil===1/0)return;t.push(s.id);const o=[],l=codecsForPlaylist(this.mainPlaylistLoader_.main,s),d=codecCount(l);if(l.audio||l.video){if(d!==n&&o.push(`codec count "${d}" !== "${n}"`),!this.sourceUpdater_.canChangeType()){const e=l.video&&parseCodecs(l.video)[0]||null,t=l.audio&&parseCodecs(l.audio)[0]||null;e&&r&&e.type.toLowerCase()!==r.type.toLowerCase()&&o.push(`video codec "${e.type}" !== "${r.type}"`),t&&a&&t.type.toLowerCase()!==a.type.toLowerCase()&&o.push(`audio codec "${t.type}" !== "${a.type}"`)}o.length&&(s.excludeUntil=1/0,this.logger_(`excluding ${s.id}: ${o.join(" && ")}`))}}))}updateAdCues_(e){let t=0;const i=this.seekable();i.length&&(t=i.start(0)),updateAdCues(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=Config.GOAL_BUFFER_LENGTH,i=Config.GOAL_BUFFER_LENGTH_RATE,s=Math.max(t,Config.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*i,s)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=Config.BUFFER_LOW_WATER_LINE,i=Config.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(t,Config.MAX_BUFFER_LOW_WATER_LINE),n=Math.max(t,Config.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*i,this.bufferBasedABR?n:s)}bufferHighWaterLine(){return Config.BUFFER_HIGH_WATER_LINE}}const enableFunction=(e,t,i)=>s=>{const n=e.main.playlists[t],r=isIncompatible(n),a=isEnabled(n);return void 0===s?a:(s?delete n.disabled:n.disabled=!0,s===a||r||(i(),s?e.trigger("renditionenabled"):e.trigger("renditiondisabled")),s)};class Representation{constructor(e,t,i){const{playlistController_:s}=e,n=s.fastQualityChange_.bind(s);if(t.attributes){const e=t.attributes.RESOLUTION;this.width=e&&e.width,this.height=e&&e.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}var r,a,o;this.codecs=codecsForPlaylist(s.main(),t),this.playlist=t,this.id=i,this.enabled=(r=e.playlists,a=t.id,o=n,e=>{const t=r.main.playlists[a],i=isIncompatible(t),s=isEnabled(t);return void 0===e?s:(e?delete t.disabled:t.disabled=!0,e===s||i||(o(),e?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),e)})}}const renditionSelectionMixin=function(e){e.representations=()=>{const t=e.playlistController_.main(),i=isAudioOnly(t)?e.playlistController_.getAudioTrackPlaylists_():t.playlists;return i?i.filter((e=>!isIncompatible(e))).map(((t,i)=>new Representation(e,t,t.id))):[]}},timerCancelEvents=["seeking","seeked","pause","playing","error"];class PlaybackWatcher{constructor(e){this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=logger("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),i=()=>this.monitorCurrentTime_(),s=()=>this.techWaiting_(),n=()=>this.resetTimeUpdate_(),r=this.playlistController_,a=["main","subtitle","audio"],o={};a.forEach((e=>{o[e]={reset:()=>this.resetSegmentDownloads_(e),updateend:()=>this.checkSegmentDownloads_(e)},r[`${e}SegmentLoader_`].on("appendsdone",o[e].updateend),r[`${e}SegmentLoader_`].on("playlistupdate",o[e].reset),this.tech_.on(["seeked","seeking"],o[e].reset)}));const l=e=>{["main","audio"].forEach((t=>{r[`${t}SegmentLoader_`][e]("appended",this.seekingAppendCheck_)}))};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),l("off"))},this.clearSeekingAppendCheck_=()=>l("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),l("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",s),this.tech_.on(timerCancelEvents,n),this.tech_.on("canplay",i),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",s),this.tech_.off(timerCancelEvents,n),this.tech_.off("canplay",i),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),a.forEach((e=>{r[`${e}SegmentLoader_`].off("appendsdone",o[e].updateend),r[`${e}SegmentLoader_`].off("playlistupdate",o[e].reset),this.tech_.off(["seeked","seeking"],o[e].reset)})),this.checkCurrentTimeTimeout_&&window$1.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&window$1.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=window$1.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,i=t[`${e}SegmentLoader_`],s=i.buffered_(),n=isRangeDifferent(this[`${e}Buffered_`],s);this[`${e}Buffered_`]=s,n?this.resetSegmentDownloads_(e):(this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:i.playlist_&&i.playlist_.id,buffered:timeRangesToArray(s)}),this[`${e}StalledDownloads_`]<10||(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),"subtitle"!==e&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0})))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+.1>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e)}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const e=this.seekable(),t=this.tech_.currentTime();let i;if(this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow)&&(i=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)){const t=e.start(0);i=t+(t===e.end(0)?0:.1)}if(void 0!==i)return this.logger_(`Trying to seek outside of seekable at time ${t} with seekable range ${printableRange(e)}. Seeking to ${i}.`),this.tech_.setCurrentTime(i),!0;const s=this.playlistController_.sourceUpdater_,n=this.tech_.buffered(),r=s.audioBuffer?s.audioBuffered():null,a=s.videoBuffer?s.videoBuffered():null,o=this.media(),l=o.partTargetDuration?o.partTargetDuration:2*(o.targetDuration-TIME_FUDGE_FACTOR),d=[r,a];for(let e=0;e<d.length;e++)if(d[e]&&timeAheadOf(d[e],t)<l)return!1;const h=findNextRange(n,t);return 0!==h.length&&(i=h.start(0)+.1,this.logger_(`Buffered region starts (${h.start(0)}) just beyond seek point (${t}). Seeking to ${i}.`),this.tech_.setCurrentTime(i),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),i=findRange(t,e);return i.length&&e+3<=i.end(0)?(this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${i.start(0)} -> ${i.end(0)}]. Attempting to resume playback by seeking to the current time.`),void this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"})):void 0}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const i=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${i}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const i=this.tech_.vhs.playlistController_.sourceUpdater_,s=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:i.audioBuffered(),videoBuffered:i.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const n=findNextRange(s,t);return n.length>0&&(this.logger_(`Stopped at ${t} and seeking to ${n.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0)}afterSeekableWindow_(e,t,i,s=!1){if(!e.length)return!1;let n=e.end(e.length-1)+.1;return!i.endList&&s&&(n=e.end(e.length-1)+3*i.targetDuration),t>n}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:i}){if(!e)return;let s;if(e.length&&t.length){const n=findRange(e,i-3),r=findRange(e,i),a=findRange(t,i);a.length&&!r.length&&n.length&&(s={start:n.end(0),end:a.end(0)})}else findNextRange(e,i).length||(s=this.gapFromVideoUnderflow_(e,i));return!!s&&(this.logger_(`Encountered a gap in video from ${s.start} to ${s.end}. Seeking to current time ${i}`),!0)}skipTheGap_(e){const t=this.tech_.buffered(),i=this.tech_.currentTime(),s=findNextRange(t,i);this.resetTimeUpdate_(),0!==s.length&&i===e&&(this.logger_("skipTheGap_:","currentTime:",i,"scheduled currentTime:",e,"nextRange start:",s.start(0)),this.tech_.setCurrentTime(s.start(0)+TIME_FUDGE_FACTOR),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"}))}gapFromVideoUnderflow_(e,t){const i=findGaps(e);for(let e=0;e<i.length;e++){const s=i.start(e),n=i.end(e);if(t-s<4&&t-s>2)return{start:s,end:n}}return null}}const defaultOptions={errorInterval:30,getSource(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},initPlugin=function(e,t){let i=0,s=0;const n=merge(defaultOptions,t);e.ready((()=>{e.trigger({type:"usage",name:"vhs-error-reload-initialized"})}));const r=function(){s&&e.currentTime(s)},a=function(t){null!=t&&(s=e.duration()!==1/0&&e.currentTime()||0,e.one("loadedmetadata",r),e.src(t),e.trigger({type:"usage",name:"vhs-error-reload"}),e.play())},o=function(){if(Date.now()-i<1e3*n.errorInterval)e.trigger({type:"usage",name:"vhs-error-reload-canceled"});else{if(n.getSource&&"function"==typeof n.getSource)return i=Date.now(),n.getSource.call(e,a);videojs.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")}},l=function(){e.off("loadedmetadata",r),e.off("error",o),e.off("dispose",l)};e.on("error",o),e.on("dispose",l),e.reloadSourceOnError=function(t){l(),initPlugin(e,t)}},reloadSourceOnError=function(e){initPlugin(this,e)};var version$4="3.0.2",version$3="6.3.0",version$2="1.0.1",version$1="6.0.0",version="4.0.1";const Vhs={PlaylistLoader:PlaylistLoader,Playlist:Playlist,utils:utils,STANDARD_PLAYLIST_SELECTOR:lastBandwidthSelector,INITIAL_PLAYLIST_SELECTOR:lowestBitrateCompatibleVariantSelector,lastBandwidthSelector:lastBandwidthSelector,movingAverageBandwidthSelector:movingAverageBandwidthSelector,comparePlaylistBandwidth:comparePlaylistBandwidth,comparePlaylistResolution:comparePlaylistResolution,xhr:xhrFactory()};Object.keys(Config).forEach((e=>{Object.defineProperty(Vhs,e,{get:()=>(videojs.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),Config[e]),set(t){videojs.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),"number"!=typeof t||t<0?videojs.log.warn(`value of Vhs.${e} must be greater than or equal to 0`):Config[e]=t}})}));const LOCAL_STORAGE_KEY="videojs-vhs",handleVhsMediaChange=function(e,t){const i=t.media();let s=-1;for(let t=0;t<e.length;t++)if(e[t].id===i.id){s=t;break}e.selectedIndex_=s,e.trigger({selectedIndex:s,type:"change"})},handleVhsLoadedMetadata=function(e,t){t.representations().forEach((t=>{e.addQualityLevel(t)})),handleVhsMediaChange(e,t.playlists)};Vhs.canPlaySource=function(){return videojs.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const emeKeySystems=(e,t,i)=>{if(!e)return e;let s={};t&&t.attributes&&t.attributes.CODECS&&(s=unwrapCodecList(parseCodecs(t.attributes.CODECS))),i&&i.attributes&&i.attributes.CODECS&&(s.audio=i.attributes.CODECS);const n=getMimeForCodec(s.video),r=getMimeForCodec(s.audio),a={};for(const i in e)a[i]={},r&&(a[i].audioContentType=r),n&&(a[i].videoContentType=n),t.contentProtection&&t.contentProtection[i]&&t.contentProtection[i].pssh&&(a[i].pssh=t.contentProtection[i].pssh),"string"==typeof e[i]&&(a[i].url=e[i]);return merge(e,a)},getAllPsshKeySystemsOptions=(e,t)=>e.reduce(((e,i)=>{if(!i.contentProtection)return e;const s=t.reduce(((e,t)=>{const s=i.contentProtection[t];return s&&s.pssh&&(e[t]={pssh:s.pssh}),e}),{});return Object.keys(s).length&&e.push(s),e}),[]),waitForKeySessionCreation=({player:e,sourceKeySystems:t,audioMedia:i,mainPlaylists:s})=>{if(!e.eme.initializeMediaKeys)return Promise.resolve();const n=i?s.concat([i]):s,r=getAllPsshKeySystemsOptions(n,Object.keys(t)),a=[],o=[];return r.forEach((t=>{o.push(new Promise(((t,i)=>{e.tech_.one("keysessioncreated",t)}))),a.push(new Promise(((i,s)=>{e.eme.initializeMediaKeys({keySystems:t},(e=>{e?s(e):i()}))})))})),Promise.race([Promise.all(a),Promise.race(o)])},setupEmeOptions=({player:e,sourceKeySystems:t,media:i,audioMedia:s})=>{const n=emeKeySystems(t,i,s);return!(!n||(e.currentSource().keySystems=n,n&&!e.eme&&(videojs.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),1)))},getVhsLocalStorage=()=>{if(!window$1.localStorage)return null;const e=window$1.localStorage.getItem("videojs-vhs");if(!e)return null;try{return JSON.parse(e)}catch(e){return null}},updateVhsLocalStorage=e=>{if(!window$1.localStorage)return!1;let t=getVhsLocalStorage();t=t?merge(t,e):e;try{window$1.localStorage.setItem("videojs-vhs",JSON.stringify(t))}catch(e){return!1}return t},expandDataUri=e=>0===e.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")?JSON.parse(e.substring(e.indexOf(",")+1)):e;Vhs.supportsNativeHls=function(){if(!document||!document.createElement)return!1;const e=document.createElement("video");return!!videojs.getTech("Html5").isSupported()&&["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some((function(t){return/maybe|probably/i.test(e.canPlayType(t))}))}(),Vhs.supportsNativeDash=!!(document&&document.createElement&&videojs.getTech("Html5").isSupported())&&/maybe|probably/i.test(document.createElement("video").canPlayType("application/dash+xml")),Vhs.supportsTypeNatively=e=>"hls"===e?Vhs.supportsNativeHls:"dash"===e&&Vhs.supportsNativeDash,Vhs.isSupported=function(){return videojs.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const Component=videojs.getComponent("Component");class VhsHandler extends Component{constructor(e,t,i){if(super(t,i.vhs),"number"==typeof i.initialBandwidth&&(this.options_.bandwidth=i.initialBandwidth),this.logger_=logger("VhsHandler"),t.options_&&t.options_.playerId){const e=videojs.getPlayer(t.options_.playerId);this.player_=e}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(document,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],(e=>{const t=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;t&&t.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()})),this.on(this.tech_,"seeking",(function(){this.ignoreNextSeekingEvent_?this.ignoreNextSeekingEvent_=!1:this.setCurrentTime(this.tech_.currentTime())})),this.on(this.tech_,"error",(function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()})),this.on(this.tech_,"play",this.play)}setOptions_(){if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=!1!==this.options_.limitRenditionByPlayerDimensions,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=void 0!==this.source_.useBandwidthFromLocalStorage?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=!1!==this.options_.llhls,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,"number"!=typeof this.options_.playlistExclusionDuration&&(this.options_.playlistExclusionDuration=300),"number"!=typeof this.options_.bandwidth&&this.options_.useBandwidthFromLocalStorage){const e=getVhsLocalStorage();e&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),e&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}"number"!=typeof this.options_.bandwidth&&(this.options_.bandwidth=Config.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Config.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach((e=>{void 0!==this.source_[e]&&(this.options_[e]=this.source_[e])})),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio}src(e,t){if(!e)return;var i;this.setOptions_(),this.options_.src=0===(i=this.source_.src).toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")?JSON.parse(i.substring(i.indexOf(",")+1)):i,this.options_.tech=this.tech_,this.options_.externVhs=Vhs,this.options_.sourceType=simpleTypeFromSourceType(t),this.options_.seekTo=e=>{this.tech_.setCurrentTime(e)},this.playlistController_=new PlaylistController(this.options_);const s=merge({liveRangeSafeTimeDelta:.1},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new PlaybackWatcher(s),this.playlistController_.on("error",(()=>{const e=videojs.players[this.tech_.options_.playerId];let t=this.playlistController_.error;"object"!=typeof t||t.code?"string"==typeof t&&(t={message:t,code:3}):t.code=3,e.error(t)}));const n=this.options_.bufferBasedABR?Vhs.movingAverageBandwidthSelector(.55):Vhs.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=Vhs.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(e){this.playlistController_.selectPlaylist=e.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(e){this.playlistController_.mainSegmentLoader_.throughput.rate=e,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let e=this.playlistController_.mainSegmentLoader_.bandwidth;const t=window$1.navigator.connection||window$1.navigator.mozConnection||window$1.navigator.webkitConnection,i=1e7;if(this.options_.useNetworkInformationApi&&t){const s=1e3*t.downlink*1e3;e=s>=i&&e>=i?Math.max(e,s):s}return e},set(e){this.playlistController_.mainSegmentLoader_.bandwidth=e,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const e=1/(this.bandwidth||1);let t;return t=this.throughput>0?1/this.throughput:0,Math.floor(1/(e+t))},set(){videojs.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>timeRangesToArray(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>timeRangesToArray(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",(()=>{this.options_.useBandwidthFromLocalStorage&&updateVhsLocalStorage({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})})),this.playlistController_.on("selectedinitialmedia",(()=>{var e;(e=this).representations=()=>{const t=e.playlistController_.main(),i=isAudioOnly(t)?e.playlistController_.getAudioTrackPlaylists_():t.playlists;return i?i.filter((e=>!isIncompatible(e))).map(((t,i)=>new Representation(e,t,t.id))):[]}})),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",(()=>{this.setupEme_()})),this.on(this.playlistController_,"progress",(function(){this.tech_.trigger("progress")})),this.on(this.playlistController_,"firstplay",(function(){this.ignoreNextSeekingEvent_=!0})),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=window$1.URL.createObjectURL(this.playlistController_.mediaSource),this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),waitForKeySessionCreation({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then((()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()})).catch((e=>{this.logger_("error while creating EME key session",e),this.player_.error({message:"Failed to initialize media keys for EME",code:3})}))}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=setupEmeOptions({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});this.player_.tech_.on("keystatuschange",(e=>{if("output-restricted"!==e.status)return;const t=this.playlistController_.main();if(!t||!t.playlists)return;const i=[];t.playlists.forEach((e=>{e&&e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height>=720&&(!e.excludeUntil||e.excludeUntil<1/0)&&(e.excludeUntil=1/0,i.push(e))})),i.length&&(videojs.log.warn('DRM keystatus changed to "output-restricted." Removing the following HD playlists that will most likely fail to play and clearing the buffer. This may be due to HDCP restrictions on the stream and the capabilities of the current device.',...i),this.playlistController_.fastQualityChange_())})),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),11!==videojs.browser.IE_VERSION&&t?this.createKeySessions_():this.playlistController_.sourceUpdater_.initializedEme()}setupQualityLevels_(){const e=videojs.players[this.tech_.options_.playerId];e&&e.qualityLevels&&!this.qualityLevels_&&(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",(()=>{handleVhsLoadedMetadata(this.qualityLevels_,this)})),this.playlists.on("mediachange",(()=>{handleVhsMediaChange(this.qualityLevels_,this.playlists)})))}static version(){return{"@videojs/http-streaming":version$4,"mux.js":version$3,"mpd-parser":version$2,"m3u8-parser":version$1,"aes-decrypter":version}}version(){return this.constructor.version()}canChangeType(){return SourceUpdater.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&window$1.URL.revokeObjectURL&&(window$1.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return getProgramTime({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,i=!0,s=2){return seekToProgramTime({programTime:e,playlist:this.playlistController_.media(),retryCount:s,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}}const VhsSourceHandler={name:"videojs-http-streaming",VERSION:version$4,canHandleSource(e,t={}){const i=merge(videojs.options,t);return VhsSourceHandler.canPlayType(e.type,i)},handleSource(e,t,i={}){const s=merge(videojs.options,i);return t.vhs=new VhsHandler(e,t,s),t.vhs.xhr=xhrFactory(),t.vhs.src(e.src,e.type),t.vhs},canPlayType(e,t){const i=simpleTypeFromSourceType(e);if(!i)return"";const s=VhsSourceHandler.getOverrideNative(t);return!Vhs.supportsTypeNatively(i)||s?"maybe":""},getOverrideNative(e={}){const{vhs:t={}}=e,i=!(videojs.browser.IS_ANY_SAFARI||videojs.browser.IS_IOS),{overrideNative:s=i}=t;return s}},supportsNativeMediaSources=()=>browserSupportsCodec("avc1.4d400d,mp4a.40.2");browserSupportsCodec("avc1.4d400d,mp4a.40.2")&&videojs.getTech("Html5").registerSourceHandler(VhsSourceHandler,0),videojs.VhsHandler=VhsHandler,videojs.VhsSourceHandler=VhsSourceHandler,videojs.Vhs=Vhs,videojs.use||videojs.registerComponent("Vhs",Vhs),videojs.options.vhs=videojs.options.vhs||{},videojs.getPlugin&&videojs.getPlugin("reloadSourceOnError")||videojs.registerPlugin("reloadSourceOnError",reloadSourceOnError);export{videojs as default};