rx-player 4.0.0-dev.202402213 → 4.0.0-dev.2024022600
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rx-player.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see rx-player.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RxPlayer=t():e.RxPlayer=t()}(self,(function(){return function(){var e={61:function(e,t,n){var r=n(698).default;function i(){"use strict";e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},a=Object.prototype,o=a.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},l=u.iterator||"@@iterator",d=u.asyncIterator||"@@asyncIterator",c=u.toStringTag||"@@toStringTag";function f(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,n){return e[t]=n}}function v(e,t,n,r){var i=t&&t.prototype instanceof b?t:b,a=Object.create(i.prototype),o=new D(r||[]);return s(a,"_invoke",{value:x(e,n,o)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=v;var h="suspendedStart",m="suspendedYield",g="executing",y="completed",_={};function b(){}function S(){}function E(){}var T={};f(T,l,(function(){return this}));var k=Object.getPrototypeOf,w=k&&k(k(O([])));w&&w!==a&&o.call(w,l)&&(T=w);var A=E.prototype=b.prototype=Object.create(T);function I(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(i,a,s,u){var l=p(e[i],e,a);if("throw"!==l.type){var d=l.arg,c=d.value;return c&&"object"==r(c)&&o.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(c).then((function(e){d.value=e,s(d)}),(function(e){return n("throw",e,s,u)}))}u(l.arg)}var i;s(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(a,a):a()}})}function x(e,n,r){var i=h;return function(a,o){if(i===g)throw new Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=C(s,r);if(u){if(u===_)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var l=p(e,n,r);if("normal"===l.type){if(i=r.done?y:m,l.arg===_)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i=y,r.method="throw",r.arg=l.arg)}}}function C(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,C(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var a=p(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,_;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,_):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function M(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(M,this),this.reset(!0)}function O(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function n(){for(;++i<e.length;)if(o.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(r(e)+" is not iterable")}return S.prototype=E,s(A,"constructor",{value:E,configurable:!0}),s(E,"constructor",{value:S,configurable:!0}),S.displayName=f(E,c,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===S||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,f(e,c,"GeneratorFunction")),e.prototype=Object.create(A),e},n.awrap=function(e){return{__await:e}},I(R.prototype),f(R.prototype,d,(function(){return this})),n.AsyncIterator=R,n.async=function(e,t,r,i,a){void 0===a&&(a=Promise);var o=new R(v(e,t,r,i),a);return n.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(A),f(A,c,"Generator"),f(A,l,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=O,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var n in this)"t"===n.charAt(0)&&o.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),l=o.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,_):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),P(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:O(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},n}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},698:function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:function(e,t,n){var r=n(61)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var r={};return function(){"use strict";function e(){return"boolean"==typeof __RX_PLAYER_DEBUG_MODE__&&__RX_PLAYER_DEBUG_MODE__}function t(e){return null==e}n.d(r,{default:function(){return Bv}});var i=function(){function e(){this._listeners={}}var n=e.prototype;return n.addEventListener=function(e,t,n){var r=this,i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],void 0!==n&&n.register((function(){r.removeEventListener(e,t)}))},n.removeEventListener=function(e,n){if(t(e))this._listeners={};else{var r=this._listeners[e];if(Array.isArray(r))if(t(n))delete this._listeners[e];else{var i=r.indexOf(n);-1!==i&&r.splice(i,1),0===r.length&&delete this._listeners[e]}}},n.trigger=function(e,t){var n=this._listeners[e];Array.isArray(n)&&n.slice().forEach((function(e){try{e(t)}catch(e){0,console.error("RxPlayer: EventEmitter error",e instanceof Error?e:null)}}))},e}(),a="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,o="undefined"==typeof window&&!a,s=a?self:o?n.g:window,u="function"==typeof queueMicrotask?queueMicrotask:function(e){Promise.resolve().then(e,(function(){return e()}))};function l(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function d(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){l(a,r,i,o,s,"next",e)}function s(e){l(a,r,i,o,s,"throw",e)}o(void 0)}))}}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function f(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}var v=n(687),p=n.n(v);var h={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:"native",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:"continue",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MINIMUM_MAX_BUFFER_AHEAD:{text:120},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:"none",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,BITRATE_REBUFFERING_RATIO:1.5,DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:500,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,SEGMENT_SYNCHRONIZATION_DELAY:1500,MISSING_DATA_TRIGGER_SYNC_DELAY:.1,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.005,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs="avc1.4d401e"','video/mp4;codecs="avc1.42e01e"','video/webm;codecs="vp8"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs="mp4a.40.2"',"audio/webm;codecs=opus"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:["HW_SECURE_ALL","HW_SECURE_DECODE","HW_SECURE_CRYPTO","SW_SECURE_DECODE","SW_SECURE_CRYPTO"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:["3000","2000"],EME_KEY_SYSTEMS:{clearkey:["webkit-org.w3.clearkey","org.w3.clearkey"],widevine:["com.widevine.alpha"],playready:["com.microsoft.playready.recommendation","com.microsoft.playready","com.chromecast.playready","com.youtube.playready"],fairplay:["com.apple.fps.1_0"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:"reload",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:"seamless"};var m="function"==typeof Object.assign?Object.assign:function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=0;n<(arguments.length<=1?0:arguments.length-1);n++){var r=n+1<1||arguments.length<=n+1?void 0:arguments[n+1];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};function g(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}function y(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(0===n.length)return e;var i=n.shift();if(g(e)&&g(i))for(var a in i)if(g(i[a])){var o=e[a];void 0===o&&(o={},e[a]=o),y(o,i[a])}else{var s;m(e,((s={})[a]=i[a],s))}return y.apply(void 0,[e].concat(n))}var _=function(){function e(){this._config=h}var t=e.prototype;return t.update=function(e){var t=y(this._config,e);this._config=t},t.getCurrent=function(){return this._config},e}(),b=new _;function S(){}var E=function(e){function t(){var t;return(t=e.call(this)||this).error=S,t.warn=S,t.info=S,t.debug=S,t._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},t._currentLevel="NONE",t}f(t,e);var n=t.prototype;return n.setLevel=function(e,t){var n,r=this._levels[e];"number"==typeof r?(n=r,this._currentLevel=e):(n=0,this._currentLevel="NONE"),void 0===t?(this.error=n>=this._levels.ERROR?console.error.bind(console):S,this.warn=n>=this._levels.WARNING?console.warn.bind(console):S,this.info=n>=this._levels.INFO?console.info.bind(console):S,this.debug=n>=this._levels.DEBUG?console.log.bind(console):S):(this.error=n>=this._levels.ERROR?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("ERROR",n)}:S,this.warn=n>=this._levels.WARNING?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("WARNING",n)}:S,this.info=n>=this._levels.INFO?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("INFO",n)}:S,this.debug=n>=this._levels.DEBUG?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("DEBUG",n)}:S),this.trigger("onLogLevelChange",this._currentLevel)},n.getLevel=function(){return this._currentLevel},n.hasLevel=function(e){return this._levels[e]>=this._levels[this._currentLevel]},t}(i),T=new E,k=1/60;function w(e,t){return Math.abs(e-t)<k}function A(e,t){return{start:Math.min(e.start,t.start),end:Math.max(e.end,t.end)}}function I(e,t){return e.end<=t.start}function R(e,t){var n=e.start,r=e.end;return n<=t&&t<r}function x(e,t){return R(e,t.start)||e.start<t.end&&t.end<e.end||R(t,e.start)}function C(e,t){return w(t.start,e.end)||w(t.end,e.start)}function M(e){for(var t=[],n=0;n<e.length;n++)t.push({start:e.start(n),end:e.end(n)});return t}function P(e,t){for(var n=e.length-1;n>=0;n--){var r=e.start(n);if(t>=r){var i=e.end(n);if(t<i)return{start:r,end:i}}}return null}function D(e,t){for(var n=e.length-1;n>=0;n--){if(t>=e[n].start)if(t<e[n].end)return e[n]}return null}function O(e,t){for(var n=null,r=[],i=0;i<e.length;i++){var a=e[i].start,o=e[i].end;t<a||t>=o?r.push({start:a,end:o}):n={start:a,end:o}}return{outerRanges:r,innerRange:n}}function N(e,t){var n=D(e,t);return null!==n?n.end-t:1/0}function L(e,t){if(t.start===t.end)return e;for(var n=t,r=0;r<e.length;r++){var i=e[r],a=x(n,i),o=C(n,i);if(a||o)n=A(n,i),e.splice(r--,1);else if(0===r){if(I(n,e[0]))break}else if(I(e[r-1],n)&&I(n,i))break}return e.splice(r,0,n),function(e){for(var t=1;t<e.length;t++){var n=e[t-1],r=e[t];if(C(n,r)){var i=A(n,r);e.splice(--t,2,i)}}return e}(function(e){for(var t=0;t<e.length;t++){var n=e[t];n.start===n.end&&e.splice(t--,1)}return e}(e))}function U(e,t){for(var n=[],r=0;r<t.length;r++)x(e,t[r])&&n.push(t[r]);return n}function F(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=[],o=U(i,t);if(o.length>0)for(var s=0;s<o.length;s++){var u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(0===a.length)n.push(i);else{for(var l=i.start,d=0;d<a.length;d++)a[d].start>l&&n.push({start:l,end:a[d].start}),l=a[d].end;l<i.end&&n.push({start:l,end:i.end})}}return n}function B(e,t,n){if("function"==typeof Array.prototype.findIndex)return e.findIndex(t,n);for(var r=e.length>>>0,i=0;i<r;i++)if(t.call(n,e[i],i,e))return i;return-1}function z(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return V(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return V(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var K=function(){function e(e,t){var n=this;this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],void 0!==t&&(this._deregisterCancellation=t.register((function(){return n.finish()})))}var t=e.prototype;return t.getValue=function(){return this._value},t.setValue=function(e){if(!this._isFinished&&(this._value=e,0!==this._listeners.length))for(var t,n=z(this._listeners.slice());!(t=n()).done;){var r=t.value;try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(e){}}},t.setValueIfChanged=function(e){e!==this._value&&this.setValue(e)},t.onUpdate=function(e,t){var n=this,r=function e(){if(void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.deregister(e),!i.hasBeenCleared){i.hasBeenCleared=!0;var r=n._listeners.indexOf(i);r>=0&&n._listeners.splice(r,1)}},i={trigger:e,complete:r,hasBeenCleared:!1};this._listeners.push(i),!0===(null==t?void 0:t.emitCurrentValue)&&e(this._value,r),this._isFinished||i.hasBeenCleared?r():void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.register(r)},t.waitUntilDefined=function(e,t){var n=this;this.onUpdate((function(t,r){void 0!==t&&(r(),e(n._value))}),{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:!0})},t._onFinished=function(e,t){var n=this;if(t.isCancelled())return S;var r=function(){var e=B(n._onFinishCbs,(function(e){return e.trigger===i}));e>=0&&(n._onFinishCbs[e].hasBeenCleared=!0,n._onFinishCbs.splice(e,1))},i=function(){r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a},t.finish=function(){void 0!==this._deregisterCancellation&&this._deregisterCancellation(),this._isFinished=!0;for(var e,t=z(this._listeners.slice());!(e=t()).done;){var n=e.value;try{n.hasBeenCleared||(n.complete(),n.hasBeenCleared=!0)}catch(e){}}if(this._listeners.length=0,this._onFinishCbs.length>0){for(var r,i=z(this._onFinishCbs.slice());!(r=i()).done;){var a=r.value;try{a.hasBeenCleared||(a.trigger(),a.hasBeenCleared=!0)}catch(e){}}this._onFinishCbs.length=0}},e}();function W(e,t,n){var r=new K(t(e.getValue()),n);return e.onUpdate((function(e){r.setValue(t(e))}),{clearSignal:n}),e._onFinished((function(){r.finish()}),n),r}var G=K;function j(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function H(e){return H=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},H(e)}function q(e,t,n){return q=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&c(i,n.prototype),i},q.apply(null,arguments)}function Y(e){var t="function"==typeof Map?new Map:void 0;return Y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return q(e,arguments,H(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)},Y(e)}var Q=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(j(r),t.prototype),r.name="AssertionError",r.message=n,r}return f(t,e),t}(Y(Error));function $(e,t){0}function X(e){throw new Q("Unreachable path taken")}var Z=function(){function e(){var e,t=(e=S,[function(t){e(t)},function(t){e=t}]),n=t[0],r=t[1];this._isUsed=!1,this._trigger=n,this.signal=new J(r)}var t=e.prototype;return t.isUsed=function(){return this._isUsed},t.linkToSignal=function(e){var t=this,n=e.register((function(){t.cancel()}));return this.signal.register(n),n},t.cancel=function(e){if(!this._isUsed){this._isUsed=!0;var t=null!=e?e:new ee;this._trigger(t)}},e.isCancellationError=function(e){return e instanceof ee},e}(),J=function(){function e(e){var t=this;this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e((function(e){for(t.cancellationError=e,t._isCancelled=!0;t._listeners.length>0;)try{var n=t._listeners.pop();null==n||n(e)}catch(e){T.error("Error while calling clean up listener",e instanceof Error?e.toString():"Unknown error")}}))}var t=e.prototype;return t.isCancelled=function(){return this._isCancelled},t.register=function(e){var t=this;return this._isCancelled?($(this.cancellationError),e(this.cancellationError),S):(this._listeners.push(e),function(){return t.deregister(e)})},t.deregister=function(e){for(var t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)},e}(),ee=function(e){function t(){var n;return n=e.call(this)||this,Object.setPrototypeOf(j(n),t.prototype),n.name="CancellationError",n.message="This task was cancelled.",n}return f(t,e),t}(Y(Error));var te=new G(0);function ne(){return performance.now()+te.getValue()}function re(e){var t=e.map((function(t){return Math.log(t/e[0])})),n=t.map((function(e){return e-t[0]+1})),r=(n[n.length-1]-1)/(2*e.length+10),i=1/r;return e.map((function(e,t){return a(t)}));function a(t){if(0===t)return 0;var o=Math.min(Math.max(1,t),e.length-1);return e[o]===e[o-1]?a(t-1):i*(r+(e[o]*n[o-1]-e[o-1]*n[o])/(e[o]-e[o-1]))+4}}var ie=function(){function e(e){this._levelsMap=re(e).map((function(e){return e+4})),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=6e3,T.debug("ABR: Steps for buffer based chooser.",this._levelsMap.map((function(t,n){return"bufferLevel: "+t+", bitrate: "+e[n]})).join(" ,"))}var n=e.prototype;return n.onAddedSegment=function(e){var n=this._levelsMap,r=this._bitrates,i=e.bufferGap,a=e.currentBitrate,o=e.currentScore,s=e.speed;if(t(a))this._currentEstimate=r[0];else{for(var u,l=-1,d=0;d<r.length;d++){var c=r[d];if(c===a)l=d;else if(c>a)break}if(l<0||r.length!==n.length)return T.info("ABR: Current Bitrate not found in the calculated levels"),void(this._currentEstimate=r[0]);void 0!==o&&(u=0===s?o.score:o.score/s);var f=isFinite(i)?i:0,v=ne();if(f<n[l]||void 0!==u&&u<1&&1===(null==o?void 0:o.confidenceLevel)){if((void 0===this._lastUnsuitableQualityTimestamp?-1:v-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+9e3){var p=this._blockRaiseDelay+3e3;this._blockRaiseDelay=Math.min(p,15e3),T.debug("ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality",this._blockRaiseDelay)}else{var h=this._blockRaiseDelay-1e3;this._blockRaiseDelay=Math.max(6e3,h),T.debug("ABR: Lowering quality in BufferBasedChooser",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=v;for(var m=B(r,(function(e){return e===a}))-1;m>=0;m--)if(f>=n[m])return void(this._currentEstimate=r[m]);this._currentEstimate=r[0]}else if(void 0!==this._lastUnsuitableQualityTimestamp&&v-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||void 0===u||u<1.15||1!==(null==o?void 0:o.confidenceLevel))this._currentEstimate=a;else{var g=n[l],y=function(){for(var e=l+1;e<n.length;e++)if(n[e]>g)return e}();if(void 0!==y)if(i>=n[y])return T.debug("ABR: Raising quality in BufferBasedChooser",r[y]),void(this._currentEstimate=r[y]);this._currentEstimate=a}}},n.getLastEstimate=function(){return this._currentEstimate},e}();function ae(e,t,n){if("function"==typeof Array.prototype.find)return e.find(t,n);for(var r=e.length>>>0,i=0;i<r;i++){var a=e[i];if(t.call(n,a,i,e))return a}}var oe=function(){function e(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}var t=e.prototype;return t.addSample=function(e,t){var n=Math.pow(this._alpha,e),r=t*(1-n)+n*this._lastEstimate;isNaN(r)||(this._lastEstimate=r,this._totalWeight+=e)},t.getEstimate=function(){var e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e},e}();function se(e){if(!(e.progress.length<5)){for(var t=new oe(2),n=e.progress,r=1;r<n.length;r++){var i=n[r].size-n[r-1].size,a=n[r].timestamp-n[r-1].timestamp,o=8*i/(a/1e3);t.addSample(a/1e3,o)}return t.getEstimate()}}function ue(e,t){var n=8*(e.totalSize-e.size);return Math.max(n/t,0)}var le=function(){function e(e,t){var n=b.getCurrent(),r=n.ABR_STARVATION_GAP,i=n.OUT_OF_STARVATION_GAP,a=n.ABR_STARVATION_FACTOR,o=n.ABR_REGULAR_FACTOR;this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,this._config=t?{starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:{starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}var n=e.prototype;return n.getBandwidthEstimate=function(e,n,r,i,a){var o,s,u=this._config,l=e.bufferGap,d=e.position,c=e.duration,f=isFinite(l)?l:0,v=b.getCurrent().ABR_STARVATION_DURATION_DELTA;return isNaN(c)||f+d.getWanted()<c-v?!this._inStarvationMode&&f<=u.starvationGap?(T.info("ABR: enter starvation mode."),this._inStarvationMode=!0):this._inStarvationMode&&f>=u.outOfStarvationGap&&(T.info("ABR: exit starvation mode."),this._inStarvationMode=!1):this._inStarvationMode&&(T.info("ABR: exit starvation mode."),this._inStarvationMode=!1),this._inStarvationMode&&(s=function(e,n,r,i,a){if(!i){var o=n.bufferGap,s=n.speed,u=n.position,l=isFinite(o)?o:0,d=function(e,t){for(var n=-1,r=0;r<e.length;r++){var i=e[r].content.segment;if(!(i.duration<=0)){var a=i.time+i.duration;if(!i.complete&&r===e.length-1&&t-i.time>-1.2){n=r;break}if(a>t&&t-i.time>-1.2){n=r;break}}}if(n<0)return[];for(var o=e[n],s=o.content.segment.time,u=[o],l=n+1;l<e.length&&e[l].content.segment.time===s;l++)u.push(e[l]);return u}(e,u.getWanted()+l);if(1===d.length){var c=d[0],f=ne(),v=1.5*c.content.segment.duration;if(v=Math.min(v,3e3),v=Math.max(v,12e3),!(f-c.requestTimestamp<v)){var p=c.progress.length>0?c.progress[c.progress.length-1]:void 0,h=se(c);if(void 0!==p&&void 0!==h){var m=ue(p,h);if((f-p.timestamp)/1e3<=m&&m-l/s>2500)return h}if(c.content.segment.complete){var g=c.content.segment.duration,y=(f-c.requestTimestamp)/1e3,_=y<=(1.5*g+2)/s;if(!t(r)&&!_){var b=g/y,S=r.bitrate*Math.min(.7,b);return void 0===a||S<a?S:void 0}}}}}}(i,e,r,this._lowLatencyMode,a),void 0!==s&&(T.info("ABR: starvation mode emergency estimate:",s),n.reset(),o=t(r)?s:Math.min(s,r.bitrate))),t(o)&&(o=void 0!==(s=n.getEstimate())?s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):void 0!==a?a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}},n.isUrgent=function(e,t,n,r){return null===t||!(e>=t.bitrate)&&function(e,t,n){if(n)return!0;var r=isFinite(e.bufferGap)?e.bufferGap:0,i=e.position.getWanted()+r,a=ae(t,(function(e){var t=e.content;return t.segment.duration>0&&t.segment.time+t.segment.duration>i}));if(void 0===a)return!0;var o=ne(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=se(a);if(void 0===s||void 0===u)return!0;var l=ue(s,u);return(o-s.timestamp)/1e3>1.2*l||l-r/e.speed>-1.5}(r,n,this._lowLatencyMode)},e}();function de(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ce(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var fe=function(){function e(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}var t=e.prototype;return t.getGuess=function(e,t,n,r,i){var a=t.bufferGap,o=t.speed,s=this._lastAbrEstimate.representation;if(null===s)return null;if(r>s.bitrate)return 2===this._lastAbrEstimate.algorithmType&&(null!==this._lastAbrEstimate.representation&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;var u=this._scoreCalculator.getEstimate(n);if(2!==this._lastAbrEstimate.algorithmType){if(void 0===u)return null;if(this._canGuessHigher(a,o,u)){var l=ve(e,n);if(null!==l)return l}return null}if(this._isLastGuessValidated(s,r,u)&&(T.debug("ABR: Guessed Representation validated",s.bitrate),this._lastMaintanableBitrate=s.bitrate,this._consecutiveWrongGuesses=0),n.id!==s.id)return s;if(this._shouldStopGuess(n,u,a,i))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=ne()+Math.min(15e3*this._consecutiveWrongGuesses,12e4),function(e,t){var n=B(e,(function(e){return e.id===t.id}));if(n<0)return T.error("ABR: Current Representation not found."),null;for(;--n>=0;)if(e[n].bitrate<t.bitrate)return e[n];return null}(e,n);if(void 0===u)return n;if(this._canGuessHigher(a,o,u)){var d=ve(e,n);if(null!==d)return d}return n},t._canGuessHigher=function(e,t,n){var r=n.score,i=n.confidenceLevel;return isFinite(e)&&e>=2.5&&ne()>this._blockGuessesUntil&&1===i&&r/t>1.01},t._shouldStopGuess=function(e,t,n,r){if(void 0!==t&&t.score<1.01)return!0;if((void 0===t||t.score<1.2)&&n<.6)return!0;for(var i,a=r.filter((function(t){return t.content.representation.id===e.id})),o=ne(),s=de(a);!(i=s()).done;){var u=i.value,l=o-u.requestTimestamp;if(u.content.segment.isInit){if(l>1e3)return!0}else{if(l>1e3*u.content.segment.duration+200)return!0;var d=se(u);if(void 0!==d&&d<.8*e.bitrate)return!0}}return!1},t._isLastGuessValidated=function(e,t,n){return void 0!==n&&1===n.confidenceLevel&&n.score>1.5||t>=e.bitrate&&(null===this._lastMaintanableBitrate||this._lastMaintanableBitrate<e.bitrate)},e}();function ve(e,t){var n=e.length,r=B(e,(function(e){return e.id===t.id}));if(r<0)return T.error("ABR: Current Representation not found."),null;for(;++r<n;)if(e[r].bitrate>t.bitrate)return e[r];return null}var pe=function(){function e(){var e=b.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new oe(t),this._slowEWMA=new oe(n),this._bytesSampled=0}var t=e.prototype;return t.addSample=function(e,t){if(!(t<b.getCurrent().ABR_MINIMUM_CHUNK_SIZE)){var n=8e3*t/e,r=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(r,n),this._slowEWMA.addSample(r,n)}},t.getEstimate=function(){var e=b.getCurrent().ABR_MINIMUM_TOTAL_BYTES;if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())},t.reset=function(){var e=b.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new oe(t),this._slowEWMA=new oe(n),this._bytesSampled=0},e}();var he=function(){function e(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}return e.prototype.update=function(e,t,n){this.representation=e,this.bandwidth=t,this.algorithmType=n},e}();function me(e){return Object.keys(e).map((function(t){return e[t]}))}var ge="function"==typeof Object.values?Object.values:me,ye=function(){function e(){this._currentRequests={}}var n=e.prototype;return n.add=function(e){var t=e.id,n=e.requestTimestamp,r=e.content;this._currentRequests[t]={requestTimestamp:n,progress:[],content:r}},n.addProgress=function(e){var n=this._currentRequests[e.id];t(n)?T.warn("ABR: progress for a request not added"):n.progress.push(e)},n.remove=function(e){t(this._currentRequests[e])&&T.warn("ABR: can't remove unknown request"),delete this._currentRequests[e]},n.getRequests=function(){return ge(this._currentRequests).filter((function(e){return!t(e)})).sort((function(e,t){return e.content.segment.time-t.content.segment.time}))},e}(),_e=function(){function e(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}var t=e.prototype;return t.addSample=function(e,t,n){var r,i=n/t,a=this._currentRepresentationData;null!==a&&a.representation.id===e.id?(r=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=n,a.loadedSegments++):((r=new oe(5)).addSample(t,i),this._currentRepresentationData={representation:e,ewma:r,loadedDuration:n,loadedSegments:0}),r.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(T.debug("ABR: New last stable representation",e.bitrate),this._lastRepresentationWithGoodScore=e)},t.getEstimate=function(e){if(null!==this._currentRepresentationData&&this._currentRepresentationData.representation.id===e.id){var t=this._currentRepresentationData,n=t.ewma,r=t.loadedSegments,i=t.loadedDuration;return{score:n.getEstimate(),confidenceLevel:r>=5&&i>=10?1:0}}},t.getLastStableRepresentation=function(){return this._lastRepresentationWithGoodScore},e}();function be(e,t){var n=B(e,(function(e){return e.bitrate>t}));return-1===n?e[e.length-1]:0===n?e[0]:e[n-1]}var Se=new G(void 0);Se.finish();var Ee=new G(1/0);Ee.finish();var Te=function(e){var n={},r=e.initialBitrates,i=e.throttlers,a=e.lowLatencyMode;return function(e,o,s,u,l){var d,c,f,v=e.adaptation.type,p=function(e){var r=n[e];if(t(r)){T.debug("ABR: Creating new BandwidthEstimator for ",e);var i=new pe;return n[e]=i,i}return r}(v),h=null!==(d=r[v])&&void 0!==d?d:0;return function(e,t){var n=e.bandwidthEstimator,r=e.context,i=e.currentRepresentation,a=e.filters,o=e.initialBitrate,s=e.lowLatencyMode,u=e.playbackObserver,l=e.representations,d=new _e,c=new le(null!=o?o:0,s),f=new ye,v=S,p={metrics:_,requestBegin:E,requestProgress:k,requestEnd:w,addedSegment:function(e){v(e)}},h=new Z;h.linkToSignal(t);var m=g(l.getValue(),h.signal);return l.onUpdate(y,{clearSignal:t}),{estimates:m,callbacks:p};function g(e,t){if(e.length<=1)return new G({bitrate:void 0,representation:e[0],urgent:!0,knownStableBitrate:void 0});var o=!1,l=e.sort((function(e,t){return e.bitrate-t.bitrate})),p=new ie(l.map((function(e){return e.bitrate}))),h=new he,m=new fe(d,h),g=u.getReference().getValue(),y=new G(E());return u.listen((function(e){g=e,_()}),{includeLastObservation:!1,clearSignal:t}),v=function(e){if(null!==g){var t=g,n=t.position,r=t.speed,i=N(e.buffered,n.getWanted()),a=e.content.representation,o=d.getEstimate(a),s={bufferGap:i,currentBitrate:a.bitrate,currentScore:o,speed:r};p.onAddedSegment(s),_()}},t.register((function(){v=S})),a.throttleBitrate.onUpdate(_,{clearSignal:t}),a.limitResolution.onUpdate(_,{clearSignal:t}),y;function _(){y.setValue(E())}function E(){var e=g,t=e.bufferGap,u=e.position,v=e.maximumPosition,y=a.limitResolution.getValue(),_=a.throttleBitrate.getValue(),S=i.getValue(),E=function(e,t,n){var r=e;void 0!==n&&n<1/0&&(r=function(e,t){if(0===e.length)return[];e.sort((function(e,t){return e.bitrate-t.bitrate}));var n=e[0].bitrate,r=Math.max(t,n),i=B(e,(function(e){return e.bitrate>r}));return-1===i?e:e.slice(0,i)}(r,n));void 0!==t&&(r=function(e,t){if(void 0===t.width||void 0===t.height)return e;var n=t.width*t.pixelRatio,r=t.height*t.pixelRatio,i=ae(e.slice().sort((function(e,t){var n,r;return(null!==(n=e.width)&&void 0!==n?n:0)-(null!==(r=t.width)&&void 0!==r?r:0)})),(function(e){return"number"==typeof e.width&&e.width>=n&&"number"==typeof e.height&&e.height>=r}));if(void 0===i)return e;var a="number"==typeof i.width?i.width:0;return e.filter((function(e){return"number"!=typeof e.width||e.width<=a}))}(r,t));return r}(l,y,_),k=f.getRequests(),w=c.getBandwidthEstimate(g,n,S,k,h.bandwidth),A=w.bandwidthEstimate,I=w.bitrateChosen,R=d.getLastStableRepresentation(),x=null===R?void 0:R.bitrate/(g.speed>0?g.speed:1),C=b.getCurrent(),M=C.ABR_ENTER_BUFFER_BASED_ALGO,P=C.ABR_EXIT_BUFFER_BASED_ALGO;o&&t<=P?o=!1:!o&&isFinite(t)&&t>=M&&(o=!0);var D=be(E,I),O=p.getLastEstimate(),N=D.bitrate,L=null;o&&void 0!==O&&O>N&&(N=(L=be(E,O)).bitrate);var U=null;return s&&null!==S&&r.manifest.isDynamic&&v-u.getWanted()<40&&(U=m.getGuess(l,g,S,N,k)),null!==U&&U.bitrate>N?(T.debug("ABR: Choosing representation with guess-based estimation.",U.bitrate,U.id),h.update(U,A,2),{bitrate:A,representation:U,urgent:null===S||U.bitrate<S.bitrate,knownStableBitrate:x}):null!==L?(T.debug("ABR: Choosing representation with buffer-based estimation.",L.bitrate,L.id),h.update(L,A,0),{bitrate:A,representation:L,urgent:c.isUrgent(L.bitrate,S,k,g),knownStableBitrate:x}):(T.debug("ABR: Choosing representation with bandwidth estimation.",D.bitrate,D.id),h.update(D,A,1),{bitrate:A,representation:D,urgent:c.isUrgent(D.bitrate,S,k,g),knownStableBitrate:x})}}function y(){var e=l.getValue();h.cancel(),(h=new Z).linkToSignal(t),g(e,h.signal).onUpdate((function(e){m.setValue(e)}),{clearSignal:h.signal,emitCurrentValue:!0})}function _(e){var t=e.requestDuration,r=e.segmentDuration,i=e.size,a=e.content;if(n.addSample(t,i),!a.segment.isInit){var o=a.segment,s=a.representation;if(void 0===r&&!o.complete)return;var u=null!=r?r:o.duration;d.addSample(s,t/1e3,u)}}function E(e){f.add(e)}function k(e){f.addProgress(e)}function w(e){f.remove(e.id)}}({bandwidthEstimator:p,context:e,currentRepresentation:o,filters:{limitResolution:null!==(c=i.limitResolution[v])&&void 0!==c?c:Se,throttleBitrate:null!==(f=i.throttleBitrate[v])&&void 0!==f?f:Ee},initialBitrate:h,playbackObserver:u,representations:s,lowLatencyMode:a},l)}},ke=function(e){function t(n,r,i){var a;switch(a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="RequestError",a.url=n,a.status=r,a.type=i,i){case"TIMEOUT":a.message="The request timed out";break;case"ERROR_EVENT":a.message="An error prevented the request to be performed successfully";break;case"PARSE_ERROR":a.message="An error happened while formatting the response data";break;case"ERROR_HTTP_CODE":a.message="An HTTP status code indicating failure was received: "+String(a.status)}return a}return f(t,e),t.prototype.serialize=function(){return{url:this.url,status:this.status,type:this.type}},t}(Y(Error)),we={TIMEOUT:"TIMEOUT",ERROR_EVENT:"ERROR_EVENT",ERROR_HTTP_CODE:"ERROR_HTTP_CODE",PARSE_ERROR:"PARSE_ERROR"},Ae=we,Ie={NETWORK_ERROR:"NETWORK_ERROR",MEDIA_ERROR:"MEDIA_ERROR",ENCRYPTED_MEDIA_ERROR:"ENCRYPTED_MEDIA_ERROR",OTHER_ERROR:"OTHER_ERROR"},Re={PIPELINE_LOAD_ERROR:"PIPELINE_LOAD_ERROR",PIPELINE_PARSE_ERROR:"PIPELINE_PARSE_ERROR",INTEGRITY_ERROR:"INTEGRITY_ERROR",MANIFEST_PARSE_ERROR:"MANIFEST_PARSE_ERROR",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"MANIFEST_INCOMPATIBLE_CODECS_ERROR",MANIFEST_UPDATE_ERROR:"MANIFEST_UPDATE_ERROR",MANIFEST_UNSUPPORTED_ADAPTATION_TYPE:"MANIFEST_UNSUPPORTED_ADAPTATION_TYPE",MEDIA_STARTING_TIME_NOT_FOUND:"MEDIA_STARTING_TIME_NOT_FOUND",MEDIA_TIME_BEFORE_MANIFEST:"MEDIA_TIME_BEFORE_MANIFEST",MEDIA_TIME_AFTER_MANIFEST:"MEDIA_TIME_AFTER_MANIFEST",MEDIA_TIME_NOT_FOUND:"MEDIA_TIME_NOT_FOUND",NO_PLAYABLE_REPRESENTATION:"NO_PLAYABLE_REPRESENTATION",MEDIA_IS_ENCRYPTED_ERROR:"MEDIA_IS_ENCRYPTED_ERROR",CREATE_MEDIA_KEYS_ERROR:"CREATE_MEDIA_KEYS_ERROR",KEY_ERROR:"KEY_ERROR",KEY_STATUS_CHANGE_ERROR:"KEY_STATUS_CHANGE_ERROR",KEY_UPDATE_ERROR:"KEY_UPDATE_ERROR",KEY_LOAD_ERROR:"KEY_LOAD_ERROR",KEY_LOAD_TIMEOUT:"KEY_LOAD_TIMEOUT",KEY_GENERATE_REQUEST_ERROR:"KEY_GENERATE_REQUEST_ERROR",INCOMPATIBLE_KEYSYSTEMS:"INCOMPATIBLE_KEYSYSTEMS",INVALID_ENCRYPTED_EVENT:"INVALID_ENCRYPTED_EVENT",INVALID_KEY_SYSTEM:"INVALID_KEY_SYSTEM",LICENSE_SERVER_CERTIFICATE_ERROR:"LICENSE_SERVER_CERTIFICATE_ERROR",MULTIPLE_SESSIONS_SAME_INIT_DATA:"MULTIPLE_SESSIONS_SAME_INIT_DATA",BUFFER_APPEND_ERROR:"BUFFER_APPEND_ERROR",BUFFER_FULL_ERROR:"BUFFER_FULL_ERROR",BUFFER_TYPE_UNKNOWN:"BUFFER_TYPE_UNKNOWN",MEDIA_ERR_BLOCKED_AUTOPLAY:"MEDIA_ERR_BLOCKED_AUTOPLAY",MEDIA_ERR_PLAY_NOT_ALLOWED:"MEDIA_ERR_PLAY_NOT_ALLOWED",MEDIA_ERR_NOT_LOADED_METADATA:"MEDIA_ERR_NOT_LOADED_METADATA",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_UNKNOWN:"MEDIA_ERR_UNKNOWN",MEDIA_SOURCE_NOT_SUPPORTED:"MEDIA_SOURCE_NOT_SUPPORTED",MEDIA_KEYS_NOT_SUPPORTED:"MEDIA_KEYS_NOT_SUPPORTED",DISCONTINUITY_ENCOUNTERED:"DISCONTINUITY_ENCOUNTERED",NONE:"NONE"};function xe(e,t){return e+": "+t}var Ce=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="EncryptedMediaError",a.type=Ie.ENCRYPTED_MEDIA_ERROR,a.code=n,a._originalMessage=r,a.message=xe(a.code,r),a.fatal=!1,"string"==typeof(null==i?void 0:i.keyStatuses)&&(a.keyStatuses=i.keyStatuses),a}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}},t}(Y(Error)),Me=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="MediaError",a.type=Ie.MEDIA_ERROR,a._originalMessage=r,a.code=n,a.message=xe(a.code,r),a.fatal=!1,void 0!==(null==i?void 0:i.tracks)&&(null==i?void 0:i.tracks.length)>0&&(a.tracksInfo=i.tracks),a}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}},t}(Y(Error)),Pe=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(j(i),t.prototype),i.name="NetworkError",i.type=Ie.NETWORK_ERROR,i.url=r.url,i.status=r.status,i.errorType=r.type,i._baseError=r,i.code=n,i.message=xe(i.code,r.message),i.fatal=!1,i}f(t,e);var n=t.prototype;return n.isHttpError=function(e){return this.errorType===Ae.ERROR_HTTP_CODE&&this.status===e},n.serialize=function(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}},t}(Y(Error)),De=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(j(i),t.prototype),i.name="OtherError",i.type=Ie.OTHER_ERROR,i.code=n,i.message=xe(i.code,r),i.fatal=!1,i._originalMessage=r,i}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage}},t}(Y(Error));function Oe(e){return(e instanceof Ce||e instanceof Me||e instanceof De||e instanceof Pe)&&Object.keys(Ie).indexOf(e.type)>=0}function Ne(e,t){var n=t.defaultCode,r=t.defaultReason;if(Oe(e))return e;var i=e instanceof Error?e.toString():r;return new De(n,i)}function Le(){var e="",t=-1;return function(){return++t>=Number.MAX_SAFE_INTEGER&&(e+="0",t=0),e+String(t)}}function Ue(e,t,n){if("function"==typeof Array.prototype.includes)return e.includes(t,n);var r=e.length>>>0;if(0===r)return!1;for(var i,a,o=0|n,s=o>=0?Math.min(o,r-1):Math.max(r+o,0);s<r;){if((i=e[s])===(a=t)||"number"==typeof i&&"number"==typeof a&&isNaN(i)&&isNaN(a))return!0;s++}return!1}var Fe=[];function Be(e){Ue(Fe,e)||(console.warn(e),Fe.push(e))}var ze=["audio","video","text"];function Ve(e){var t,n,r=e.timeBounds;if(null===r.timeshiftDepth)return null!==(t=r.minimumSafePosition)&&void 0!==t?t:0;var i,a=r.maximumTimeData;if(r.maximumTimeData.isLinear){var o=ne()-a.time;i=a.maximumSafePosition+o/1e3}else i=a.maximumSafePosition;var s=i-r.timeshiftDepth;return Math.max(null!==(n=r.minimumSafePosition)&&void 0!==n?n:0,s)}function Ke(e){var t=e.timeBounds.maximumTimeData;if(e.isLive&&void 0!==t.livePosition){if(!t.isLinear)return t.livePosition;var n=ne()-t.time;return t.livePosition+n/1e3}}function We(e){var t=e.timeBounds.maximumTimeData;if(!t.isLinear)return t.maximumSafePosition;var n=ne()-t.time;return t.maximumSafePosition+n/1e3}function Ge(e,t){if(void 0===t)return qe(e).filter((function(e){return!0===e.isSupported}));var n=e.adaptations[t];return void 0===n?[]:n.filter((function(e){return!0===e.isSupported}))}function je(e,t){var n=t.end;if(void 0===n)return null;var r=ae(e.periods,(function(e){return void 0===e.end||n<e.end}));return void 0===r?null:r}function He(e,t,n){return t>=e.start&&(void 0===e.end||t<e.end)||t===e.end&&(null===n||n.start>e.end)}function qe(e){return me(e.adaptations).reduce((function(e,n){return t(n)?e:e.concat(n)}),[])}function Ye(e,t){var n,r,i={language:null!==(n=e.language)&&void 0!==n?n:"",normalized:null!==(r=e.normalizedLanguage)&&void 0!==r?r:"",audioDescription:!0===e.isAudioDescription,id:e.id,representations:(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(Xe),label:e.label};return!0===e.isDub&&(i.dub=!0),i}function Qe(e){var t,n;return{language:null!==(t=e.language)&&void 0!==t?t:"",normalized:null!==(n=e.normalizedLanguage)&&void 0!==n?n:"",closedCaption:!0===e.isClosedCaption,id:e.id,label:e.label,forced:e.isForcedSubtitles}}function $e(e,t){var n=void 0!==e.trickModeTracks?e.trickModeTracks.map((function(e){var n=(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(Ze),r={id:e.id,representations:n,isTrickModeTrack:!0};return!0===e.isSignInterpreted&&(r.signInterpreted=!0),r})):void 0,r={id:e.id,representations:(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(Ze),label:e.label};return!0===e.isSignInterpreted&&(r.signInterpreted=!0),!0===e.isTrickModeTrack&&(r.isTrickModeTrack=!0),void 0!==n&&(r.trickModeTracks=n),r}function Xe(e){var t=e.id,n=e.bitrate,r=e.codecs,i=e.isSpatialAudio,a=e.isSupported,o=e.decipherable;return{id:t,bitrate:n,codec:null==r?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function Ze(e){var t=e.id,n=e.bitrate,r=e.frameRate,i=e.width,a=e.height,o=e.codecs,s=e.hdrInfo,u=e.isSupported,l=e.decipherable;return{id:t,bitrate:n,frameRate:r,width:i,height:a,codec:null==o?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:l}}function Je(e){switch(e.type){case"audio":return{type:"audio",track:Ye(e,!1)};case"video":return{type:"video",track:$e(e,!1)};case"text":return{type:"text",track:Qe(e)}}}function et(e){return"string"==typeof e&&e.length>0}var tt={aa:"aar",ab:"abk",ae:"ave",af:"afr",ak:"aka",am:"amh",an:"arg",ar:"ara",as:"asm",av:"ava",ay:"aym",az:"aze",ba:"bak",be:"bel",bg:"bul",bi:"bis",bm:"bam",bn:"ben",bo:"bod",br:"bre",bs:"bos",ca:"cat",ce:"che",ch:"cha",co:"cos",cr:"cre",cs:"ces",cu:"chu",cv:"chv",cy:"cym",da:"dan",de:"deu",dv:"div",dz:"dzo",ee:"ewe",el:"ell",en:"eng",eo:"epo",es:"spa",et:"est",eu:"eus",fa:"fas",ff:"ful",fi:"fin",fj:"fij",fo:"fao",fr:"fra",fy:"fry",ga:"gle",gd:"gla",gl:"glg",gn:"grn",gu:"guj",gv:"glv",ha:"hau",he:"heb",hi:"hin",ho:"hmo",hr:"hrv",ht:"hat",hu:"hun",hy:"hye",hz:"her",ia:"ina",id:"ind",ie:"ile",ig:"ibo",ii:"iii",ik:"ipk",io:"ido",is:"isl",it:"ita",iu:"iku",ja:"jpn",jv:"jav",ka:"kat",kg:"kon",ki:"kik",kj:"kua",kk:"kaz",kl:"kal",km:"khm",kn:"kan",ko:"kor",kr:"kau",ks:"kas",ku:"kur",kv:"kom",kw:"cor",ky:"kir",la:"lat",lb:"ltz",lg:"lug",li:"lim",ln:"lin",lo:"lao",lt:"lit",lu:"lub",lv:"lav",mg:"mlg",mh:"mah",mi:"mri",mk:"mkd",ml:"mal",mn:"mon",mr:"mar",ms:"msa",mt:"mlt",my:"mya",na:"nau",nb:"nob",nd:"nde",ne:"nep",ng:"ndo",nl:"nld",nn:"nno",no:"nor",nr:"nbl",nv:"nav",ny:"nya",oc:"oci",oj:"oji",om:"orm",or:"ori",os:"oss",pa:"pan",pi:"pli",pl:"pol",ps:"pus",pt:"por",qu:"que",rm:"roh",rn:"run",ro:"ron",ru:"rus",rw:"kin",sa:"san",sc:"srd",sd:"snd",se:"sme",sg:"sag",si:"sin",sk:"slk",sl:"slv",sm:"smo",sn:"sna",so:"som",sq:"sqi",sr:"srp",ss:"ssw",st:"sot",su:"sun",sv:"swe",sw:"swa",ta:"tam",te:"tel",tg:"tgk",th:"tha",ti:"tir",tk:"tuk",tl:"tgl",tn:"tsn",to:"ton",tr:"tur",ts:"tso",tt:"tat",tw:"twi",ty:"tah",ug:"uig",uk:"ukr",ur:"urd",uz:"uzb",ve:"ven",vi:"vie",vo:"vol",wa:"wln",wo:"wol",xh:"xho",yi:"yid",yo:"yor",za:"zha",zh:"zho",zu:"zul"},nt={alb:"sqi",arm:"hye",baq:"eus",bur:"mya",chi:"zho",cze:"ces",dut:"nld",fre:"fra",geo:"kat",ger:"deu",gre:"ell",ice:"isl",mac:"mkd",mao:"mri",may:"msa",per:"fas",slo:"slk",rum:"ron",tib:"bod",wel:"cym"};function rt(e){if(t(e)||""===e)return"";var n=function(e){var t;switch(e.length){case 2:t=tt[e];break;case 3:t=nt[e]}return t}((""+e).toLowerCase().split("-")[0]);return et(n)?n:e}var it=rt,at={dashParsers:{wasm:null,js:null},codecSupportProber:null,createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},ot=at;function st(e,t){if(e.length!==t.length)return!1;if(e===t)return!0;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return!1;return!0}function ut(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return lt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function lt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var dt=Le(),ct=function(){function e(e,t){var n,r,i,a,o;if(this.id=e.id,this.uniqueId=dt(),this.bitrate=e.bitrate,this.codecs=[],void 0!==e.isSpatialAudio&&(this.isSpatialAudio=e.isSpatialAudio),void 0!==e.height&&(this.height=e.height),void 0!==e.width&&(this.width=e.width),void 0!==e.mimeType&&(this.mimeType=e.mimeType),void 0!==e.contentProtections&&(this.contentProtections=e.contentProtections),void 0!==e.frameRate&&(this.frameRate=e.frameRate),void 0!==e.hdrInfo&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index,"audio"===t||"video"===t)if(null!==ot.codecSupportProber){if(void 0!==e.supplementalCodecs){var s=ot.codecSupportProber.isSupported(null!==(n=this.mimeType)&&void 0!==n?n:"",null!==(r=e.supplementalCodecs)&&void 0!==r?r:"");!1!==s&&(this.codecs=[e.supplementalCodecs],!0===s&&(this.isSupported=!0))}!0!==this.isSupported&&(this.codecs.length>0?this.codecs.push(null!==(i=e.codecs)&&void 0!==i?i:""):(this.codecs=void 0===e.codecs?[]:[e.codecs],this.isSupported=ot.codecSupportProber.isSupported(null!==(a=this.mimeType)&&void 0!==a?a:"",null!==(o=e.codecs)&&void 0!==o?o:"")))}else void 0!==e.supplementalCodecs&&this.codecs.push(e.supplementalCodecs),void 0!==e.codecs&&this.codecs.push(e.codecs);else void 0!==e.codecs&&this.codecs.push(e.codecs),this.isSupported=!0}var t=e.prototype;return t.refreshCodecSupport=function(e){var t,n=null!==(t=this.mimeType)&&void 0!==t?t:"",r=this.codecs;0===r.length&&(r=[""]);for(var i=0;i<r.length;i++)for(var a,o=ut(e);!(a=o()).done;){var s=a.value,u=r[i];if(s.codec===u&&s.mimeType===n){if(s.result)return this.isSupported=!0,void(this.codecs=[u]);if(i===r.length)return this.isSupported=!1,void(this.codecs=[u])}}},t.getMimeTypeString=function(){var e,t,n;return(null!==(e=this.mimeType)&&void 0!==e?e:"")+';codecs="'+(null!==(n=null===(t=this.codecs)||void 0===t?void 0:t[0])&&void 0!==n?n:"")+'"'},t.getEncryptionData=function(e){for(var t,n,r=this.getAllEncryptionData(),i=[],a=0;a<r.length;a++)for(var o=!1,s=r[a],u=0;u<s.values.length;u++)if(s.values[u].systemId.toLowerCase()===e.toLowerCase())if(o)i[i.length-1].values.push(s.values[u]);else{var l=null===(n=null===(t=this.contentProtections)||void 0===t?void 0:t.keyIds)||void 0===n?void 0:n.map((function(e){return e.keyId}));i.push({type:s.type,keyIds:l,values:[s.values[u]]}),o=!0}return i},t.getAllEncryptionData=function(){var e,t;if(void 0===this.contentProtections||0===this.contentProtections.initData.length)return[];var n=null===(t=null===(e=this.contentProtections)||void 0===e?void 0:e.keyIds)||void 0===t?void 0:t.map((function(e){return e.keyId}));return this.contentProtections.initData.map((function(e){return{type:e.type,keyIds:n,values:e.values}}))},t.addProtectionData=function(e,t,n){var r=!1;if(void 0===this.contentProtections)return this.contentProtections={keyIds:void 0!==t?[{keyId:t}]:[],initData:[{type:e,values:n}]},!0;if(void 0!==t){var i=this.contentProtections.keyIds;if(void 0===i)this.contentProtections.keyIds=[{keyId:t}];else{for(var a,o=!1,s=ut(i);!(a=s()).done;){st(a.value.keyId,t)&&(o=!0)}o||(T.warn("Manifest: found unanounced key id."),i.push({keyId:t}))}}for(var u=this.contentProtections.initData,l=0;l<u.length;l++)if(u[l].type===e){for(var d=u[l].values,c=0;c<n.length;c++){var f=n[c],v=void 0;for(v=0;v<d.length;v++)if(f.systemId===d[v].systemId){if(st(f.data,d[v].data))break;T.warn("Manifest: different init data for the same system ID")}v===d.length&&(d.push(f),r=!0)}return r}return this.contentProtections.initData.push({type:e,values:n}),!0},t.getMetadataSnapshot=function(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,codecs:this.codecs,mimeType:this.mimeType,width:this.width,height:this.height,frameRate:this.frameRate,isSupported:this.isSupported,hdrInfo:this.hdrInfo,contentProtections:this.contentProtections,decipherable:this.decipherable}},e}(),ft=ct;function vt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return pt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ht=function(){function e(n,r){void 0===r&&(r={});var i=n.trickModeTracks,a=r,o=a.representationFilter,s=a.isManuallyAdded;this.id=n.id,this.type=n.type,void 0!==n.isTrickModeTrack&&(this.isTrickModeTrack=n.isTrickModeTrack),void 0!==n.language&&(this.language=n.language,this.normalizedLanguage=it(n.language)),void 0!==n.closedCaption&&(this.isClosedCaption=n.closedCaption),void 0!==n.audioDescription&&(this.isAudioDescription=n.audioDescription),void 0!==n.isDub&&(this.isDub=n.isDub),void 0!==n.forcedSubtitles&&(this.isForcedSubtitles=n.forcedSubtitles),void 0!==n.isSignInterpreted&&(this.isSignInterpreted=n.isSignInterpreted),void 0!==n.label&&(this.label=n.label),void 0!==i&&i.length>0&&(this.trickModeTracks=i.map((function(t){return new e(t)})));for(var u,l=n.representations,d=[],c=0;c<l.length;c++){var f=new ft(l[c],this.type),v=!0;if(!t(o)){var p={id:f.id,bitrate:f.bitrate,codecs:f.codecs,height:f.height,width:f.width,frameRate:f.frameRate,hdrInfo:f.hdrInfo};if(void 0!==f.contentProtections&&(p.contentProtections={},void 0!==f.contentProtections.keyIds)){var h=f.contentProtections.keyIds.map((function(e){return e.keyId}));p.contentProtections.keyIds=h}v=o(p,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}v?(d.push(f),void 0===u&&(!0===f.isSupported?u=!0:!1===f.isSupported&&(u=!1))):T.debug("Filtering Representation due to representationFilter",this.type,"Adaptation: "+this.id,"Representation: "+f.id,"("+f.bitrate+")")}d.sort((function(e,t){return e.bitrate-t.bitrate})),this.representations=d,this.isSupported=u,this.manuallyAdded=!0===s}var n=e.prototype;return n.refreshCodecSupport=function(e){for(var t,n=vt(this.representations);!(t=n()).done;){var r=t.value;void 0===r.isSupported&&(r.refreshCodecSupport(e),!0!==this.isSupported&&!0===r.isSupported?this.isSupported=!0:void 0===this.isSupported&&!1===r.isSupported&&(this.isSupported=!1))}},n.getRepresentation=function(e){return ae(this.representations,(function(t){var n=t.id;return e===n}))},n.getMetadataSnapshot=function(){for(var e,t=[],n=vt(this.representations);!(e=n()).done;){var r=e.value;t.push(r.getMetadataSnapshot())}return{id:this.id,type:this.type,isSupported:this.isSupported,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:t,label:this.label,isDub:this.isDub}},e}();function mt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return gt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function gt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var yt,_t=function(){function e(e,n,r){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((function(i,a){var o=e.adaptations[a];if(t(o))return i;var s=o.map((function(e){var t=new ht(e,{representationFilter:r});return t.representations.length>0&&!1===t.isSupported&&n.push(t),t})).filter((function(e){return e.representations.length>0}));if(s.every((function(e){return!1===e.isSupported}))&&o.length>0&&("video"===a||"audio"===a))throw new Me("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+a+" adaptations",{tracks:void 0});return s.length>0&&(i[a]=s),i}),{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new Me("MANIFEST_PARSE_ERROR","No supported audio and video tracks.");this.duration=e.duration,this.start=e.start,t(this.duration)||t(this.start)||(this.end=this.start+this.duration),this.streamEvents=void 0===e.streamEvents?[]:e.streamEvents}var n=e.prototype;return n.refreshCodecSupport=function(e,t){var n=this;Object.keys(this.adaptations).forEach((function(r){var i=n.adaptations[r];if(void 0!==i){for(var a,o=!1,s=mt(i);!(a=s()).done;){var u=a.value,l=u.isSupported;u.refreshCodecSupport(e),!1!==l&&!1===u.isSupported&&t.push(u),!1===o?o=u.isSupported:void 0===o&&!0===u.isSupported&&(o=!0)}if(("video"===r||"audio"===r)&&!1===o)throw new Me("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+r+" adaptations",{tracks:void 0})}}),{})},n.getAdaptations=function(){return qe(this)},n.getAdaptationsForType=function(e){var t=this.adaptations[e];return null!=t?t:[]},n.getAdaptation=function(e){return ae(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n.getSupportedAdaptations=function(e){return Ge(this,e)},n.containsTime=function(e,t){return He(this,e,t)},n.getMetadataSnapshot=function(){for(var e,t={},n=mt(this.getAdaptations());!(e=n()).done;){var r=e.value,i=t[r.type];void 0===i&&(i=[],t[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:t}},e}();function bt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return St(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return St(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function St(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Et(e,t,n){var r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};e.start=t.start,e.end=t.end,e.duration=t.duration,e.streamEvents=t.streamEvents;for(var i=e.getAdaptations(),a=t.getAdaptations(),o=function(e){var t=i[e],o=B(a,(function(e){return e.id===t.id}));if(-1===o){T.warn('Manifest: Adaptation "'+i[e].id+'" not found when merging.');var u=i.splice(e,1)[0];e--,r.removedAdaptations.push({id:u.id,trackType:u.type})}else{var l=a.splice(o,1)[0],d=[],c=[],f=[];r.updatedAdaptations.push({adaptation:t.id,trackType:t.type,updatedRepresentations:d,addedRepresentations:c,removedRepresentations:f});for(var v,p=t.representations,h=l.representations.slice(),m=function(e){var t=p[e],r=B(h,(function(e){return e.id===t.id}));if(-1===r){T.warn('Manifest: Representation "'+p[e].id+'" not found when merging.');var i=p.splice(e,1)[0];e--,f.push(i.id)}else{var a=h.splice(r,1)[0];d.push(t.getMetadataSnapshot()),t.cdnMetadata=a.cdnMetadata,n===yt.Full?t.index._replace(a.index):t.index._update(a.index)}g=e},g=0;g<p.length;g++)m(g);if(h.length>0)T.warn("Manifest: "+h.length+" new Representations found when merging."),(v=t.representations).push.apply(v,h),c.push.apply(c,h.map((function(e){return e.getMetadataSnapshot()})))}s=e},s=0;s<i.length;s++)o(s);if(a.length>0){T.warn("Manifest: "+a.length+" new Adaptations found when merging.");for(var u,l=bt(a);!(u=l()).done;){var d=u.value,c=e.adaptations[d.type];void 0===c?e.adaptations[d.type]=[d]:c.push(d),r.addedAdaptations.push(d.getMetadataSnapshot())}}return r}function Tt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function kt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}!function(e){e[e.Full=0]="Full",e[e.Partial=1]="Partial"}(yt||(yt={}));var wt=Le(),At=function(e){function t(t,n,r){var i,a;i=e.call(this)||this;var o=n.representationFilter,s=n.manifestUpdateUrl;i.manifestFormat=0,i.id=wt(),i.expired=null!==(a=t.expired)&&void 0!==a?a:null,i.transport=t.transportType,i.clockOffset=t.clockOffset;var u=[];if(i.periods=t.periods.map((function(e){return new _t(e,u,o)})).sort((function(e,t){return e.start-t.start})),u.length>0){var l=new Me("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{tracks:u.map(Je)});r.push(l)}return i.adaptations=void 0===i.periods[0]?{}:i.periods[0].adaptations,i.timeBounds=t.timeBounds,i.isDynamic=t.isDynamic,i.isLive=t.isLive,i.isLastPeriodKnown=t.isLastPeriodKnown,i.uris=void 0===t.uris?[]:t.uris,i.updateUrl=s,i.lifetime=t.lifetime,i.clockOffset=t.clockOffset,i.suggestedPresentationDelay=t.suggestedPresentationDelay,i.availabilityStartTime=t.availabilityStartTime,i.publishTime=t.publishTime,i}f(t,e);var n=t.prototype;return n.refreshCodecSupport=function(e){for(var t,n=[],r=Tt(this.periods);!(t=r()).done;){t.value.refreshCodecSupport(e,n)}return n.length>0?new Me("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{tracks:n.map(Je)}):null},n.getPeriod=function(e){return ae(this.periods,(function(t){return e===t.id}))},n.getPeriodForTime=function(e){return function(e,t){for(var n=null,r=e.periods.length-1;r>=0;r--){var i=e.periods[r];if(He(i,t,n))return i;n=i}}(this,e)},n.getNextPeriod=function(e){return ae(this.periods,(function(t){return t.start>e}))},n.getPeriodAfter=function(e){return je(this,e)},n.getUrls=function(){return this.uris},n.replace=function(e){this._performUpdate(e,yt.Full)},n.update=function(e){this._performUpdate(e,yt.Partial)},n.getMinimumSafePosition=function(){return Ve(this)},n.getLivePosition=function(){return Ke(this)},n.getMaximumSafePosition=function(){return We(this)},n.updateRepresentationsDeciperability=function(e){var t=function(e,t){for(var n,r=[],i=Tt(e.periods);!(n=i()).done;)for(var a,o=n.value,s=Tt(o.getAdaptations());!(a=s()).done;)for(var u,l=a.value,d=Tt(l.representations);!(u=d()).done;){var c=u.value,f={manifest:e,period:o,adaptation:l,representation:c},v=t(f);v!==c.decipherable&&(r.push(f),c.decipherable=v,T.debug('Decipherability changed for "'+c.id+'"',"("+c.bitrate+")",String(c.decipherable)))}return r}(this,e);t.length>0&&this.trigger("decipherabilityUpdate",t)},n.getAdaptations=function(){Be("manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead");var e=this.periods[0];if(void 0===e)return[];var t=e.adaptations,n=[];for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];n.push.apply(n,i)}return n},n.getAdaptationsForType=function(e){Be("manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead");var t=this.periods[0];if(void 0===t)return[];var n=t.adaptations[e];return void 0===n?[]:n},n.getAdaptation=function(e){return Be("manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead"),ae(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n.getMetadataSnapshot=function(){for(var e,t=[],n=Tt(this.periods);!(e=n()).done;){var r=e.value;t.push(r.getMetadataSnapshot())}return{manifestFormat:1,id:this.id,periods:t,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}},n._performUpdate=function(e,t){var n;if(this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime,t===yt.Full)this.timeBounds=e.timeBounds,this.uris=e.uris,n=function(e,t){for(var n={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0,i=0;i<t.length;i++){for(var a=t[i],o=r,s=e[o];void 0!==s&&s.id!==a.id;)s=e[++o];if(void 0!==s){var u,l,d=Et(s,a,yt.Full);n.updatedPeriods.push({period:{id:s.id,start:s.start,end:s.end,duration:s.duration,streamEvents:s.streamEvents},result:d});var c=t.slice(r,i),f=o-r,v=e.splice.apply(e,[r,f].concat(c));(u=n.removedPeriods).push.apply(u,v.map((function(e){return{id:e.id,start:e.start,end:e.end}}))),(l=n.addedPeriods).push.apply(l,c.map((function(e){return e.getMetadataSnapshot()}))),r=i+1}}if(r>e.length)return T.error("Manifest: error when updating Periods"),n;if(r<e.length){var p,h=e.splice(r,e.length-r);(p=n.removedPeriods).push.apply(p,h.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}var m,g=t.slice(r,t.length);return g.length>0&&(e.push.apply(e,g),(m=n.addedPeriods).push.apply(m,g.map((function(e){return e.getMetadataSnapshot()})))),n}(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],n=function(e,t){var n,r={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(0===e.length)return e.splice.apply(e,[0,0].concat(t)),(n=r.addedPeriods).push.apply(n,t.map((function(e){return e.getMetadataSnapshot()}))),r;if(0===t.length)return r;var i=e[e.length-1];if(i.start<t[0].start){var a;if(i.end!==t[0].start)throw new Me("MANIFEST_UPDATE_ERROR","Cannot perform partial update: not enough data");return e.push.apply(e,t),(a=r.addedPeriods).push.apply(a,t.map((function(e){return e.getMetadataSnapshot()}))),r}var o=B(e,(function(e){return e.id===t[0].id}));if(o<0)throw new Me("MANIFEST_UPDATE_ERROR","Cannot perform partial update: incoherent data");var s=Et(e[o],t[0],yt.Partial);r.updatedPeriods.push({period:m(e[o].getMetadataSnapshot(),{adaptations:void 0}),result:s});for(var u=o+1,l=1;l<t.length;l++){for(var d=t[l],c=-1,f=u;f<e.length;f++)if(d.id===e[f].id){c=f;break}if(c<0){for(var v,p=-1,h=u;h<e.length;h++)if(d.start<e[h].start){p=h;break}var g=p-u,y=e.splice(u,g,d);r.addedPeriods.push(d.getMetadataSnapshot()),(v=r.removedPeriods).push.apply(v,y.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}else{if(c>u){var _;T.warn("Manifest: old Periods not found in new when updating, removing");var b=e.splice(u,c-u);(_=r.removedPeriods).push.apply(_,b.map((function(e){return{id:e.id,start:e.start,end:e.end}}))),c=u}var S=Et(e[c],d,yt.Full);r.updatedPeriods.push({period:m(e[c].getMetadataSnapshot(),{adaptations:void 0}),result:S})}u++}if(u<e.length){var E;T.warn("Manifest: Ending Periods not found in new when updating, removing");var k=e.splice(u,e.length-u);(E=r.removedPeriods).push.apply(E,k.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}return r}(this.periods,e.periods);for(var r=this.getMinimumSafePosition();this.periods.length>0;){var i=this.periods[0];if(void 0===i.end||i.end>r)break;this.periods.shift()}}this.adaptations=void 0===this.periods[0]?{}:this.periods[0].adaptations,this.trigger("manifestUpdate",n)},t}(i);var It=At;function Rt(e){return e instanceof ke?new Pe("PIPELINE_LOAD_ERROR",e):Ne(e,{defaultCode:"PIPELINE_LOAD_ERROR",defaultReason:"Unknown error when fetching the Manifest"})}var xt=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="CustomLoaderError",a.message=n,a.canRetry=r,a.xhr=i,a}return f(t,e),t}(Y(Error));function Ct(e,t){var n;return new Promise((function(r,i){if(null!==e.cancellationError)return i(e.cancellationError);var a=!1;function o(e){void 0!==n&&n(),i(e)}n=t((function(t){e.deregister(o),a=!0,r(t)}),(function(t){e.deregister(o),a=!0,i(t)})),a||e.register(o)}))}function Mt(e,t){return Ct(t,(function(t){var n=setTimeout((function(){return t()}),e);return function(){return clearTimeout(n)}}))}var Pt=.3;function Dt(e){return e*((2*Math.random()-1)*Pt+1)}function Ot(e,t,n,r,i){return Nt.apply(this,arguments)}function Nt(){return Nt=d(p().mark((function e(t,n,r,i,a){var o,s,u,l,c,f,v,h,m,g,y,_,b;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(b=function(e){var t;if(0===c.size)return e[0];var n=ne();return null===(t=e.filter((function(e){var t;return!0!==(null===(t=c.get(e))||void 0===t?void 0:t.isBlacklisted)})).reduce((function(e,t){var r,i=null===(r=c.get(t))||void 0===r?void 0:r.blockedUntil;return void 0!==i&&i<=n&&(i=void 0),void 0===e?[t,i]:void 0===e[1]?e:void 0===i?[t,void 0]:i<e[1]?[t,i]:e}),void 0))||void 0===t?void 0:t[0]},_=function(e,t){var r=c.get(e);if(void 0===r||void 0===r.blockedUntil)return h(e);var i=ne(),o=r.blockedUntil-i;if(o<=0)return h(e);var s=new Z,u=s.linkToSignal(a);return new Promise((function(r,i){function l(e){u(),r(e)}function d(e){u(),i(e)}null==n||n.addEventListener("priorityChange",(function(){var n=v();if(a.isCancelled())throw a.cancellationError;if(void 0===n)return d(t);n!==e&&(s.cancel(),_(n,t).then(l,d))}),s.signal),Mt(o,s.signal).then((function(){return h(e).then(l,d)}),S)}))},y=function(){return(y=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=v(),!a.isCancelled()){e.next=3;break}throw a.cancellationError;case 3:if(void 0!==n){e.next=5;break}throw t;case 5:if(l(t),!a.isCancelled()){e.next=8;break}throw a.cancellationError;case 8:return e.abrupt("return",_(n,t));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)},g=function(e){return y.apply(this,arguments)},m=function(){return(m=d(p().mark((function e(t){var i,l,d,f,v;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r(t,a);case 3:return i=e.sent,e.abrupt("return",i);case 7:if(e.prev=7,e.t0=e.catch(0),!Z.isCancellationError(e.t0)){e.next=11;break}throw e.t0;case 11:if(null!==t&&null!==n&&n.downgradeCdn(t),void 0===(l=c.get(t))?(l={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},c.set(t,l)):l.errorCounter++,(p=e.t0)instanceof ke?p.type===Ae.ERROR_HTTP_CODE?p.status>=500||404===p.status||415===p.status||412===p.status:p.type===Ae.TIMEOUT||p.type===Ae.ERROR_EVENT:p instanceof xt?"boolean"==typeof p.canRetry?p.canRetry:void 0!==p.xhr&&(p.xhr.status>=500||404===p.xhr.status||415===p.xhr.status||412===p.xhr.status):Oe(p)&&"INTEGRITY_ERROR"===p.code){e.next=18;break}return l.blockedUntil=void 0,l.isBlacklisted=!0,e.abrupt("return",g(e.t0));case 18:return l.errorCounter>u?(l.blockedUntil=void 0,l.isBlacklisted=!0):(d=l.errorCounter,f=Math.min(o*Math.pow(2,d-1),s),v=Dt(f),l.blockedUntil=ne()+v),e.abrupt("return",g(e.t0));case 20:case"end":return e.stop()}var p}),e,null,[[0,7]])})))).apply(this,arguments)},h=function(e){return m.apply(this,arguments)},v=function(){if(null===t){var e=c.get(null);if(void 0!==e&&e.isBlacklisted)return;return null}if(null===n)return b(t);var r=n.getCdnPreferenceForResource(t);return b(r)},null===a.cancellationError){e.next=9;break}return e.abrupt("return",Promise.reject(a.cancellationError));case 9:if(o=i.baseDelay,s=i.maxDelay,u=i.maxRetry,l=i.onRetry,null!==t&&0===t.length&&T.warn("Fetchers: no CDN given to `scheduleRequestWithCdns`."),c=new Map,void 0!==(f=v())){e.next=15;break}throw new Error("No CDN to request");case 15:return e.abrupt("return",h(f));case 16:case"end":return e.stop()}}),e)}))),Nt.apply(this,arguments)}function Lt(e,t,n){return Ot(null,null,e,t,n)}function Ut(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ft(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ft(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ft(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Bt=function(e){function t(t,n,r){var i;return(i=e.call(this)||this).scheduleManualRefresh=S,i._manifestUrls=t,i._pipelines=n.manifest,i._settings=r,i._canceller=new Z,i._isStarted=!1,i._isRefreshPending=!1,i._consecutiveUnsafeMode=0,i._prioritizedContentUrl=null,i}f(t,e);var n=t.prototype;return n.dispose=function(){this._canceller.cancel(),this.removeEventListener()},n.start=function(){var e=this;if(!this._isStarted){this._isStarted=!0;var t=this._settings.initialManifest;(t instanceof It?Promise.resolve({manifest:t}):void 0!==t?this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):this._fetchManifest(void 0).then((function(e){return e.parse({previousManifest:null,unsafeMode:!1})}))).then((function(t){e.trigger("manifestReady",t.manifest),e._canceller.isUsed()||e._recursivelyRefreshManifest(t.manifest,t)})).catch((function(t){return e._onFatalError(t)}))}},n.updateContentUrls=function(e,t){var n;this._prioritizedContentUrl=null!==(n=null==e?void 0:e[0])&&void 0!==n?n:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})},n._fetchManifest=function(){var e=d(p().mark((function e(t){var n,r,i,a,o,s,u,l,d=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=function(e){var t=a.loadManifest,n=void 0===i.requestTimeout?b.getCurrent().DEFAULT_REQUEST_TIMEOUT:i.requestTimeout,o=void 0===i.connectionTimeout?b.getCurrent().DEFAULT_CONNECTION_TIMEOUT:i.connectionTimeout;n<0&&(n=void 0),o<0&&(o=void 0);return Lt((function(){return t(e,{timeout:n,connectionTimeout:o},r)}),s,r)},r=this._canceller.signal,i=this._settings,a=this._pipelines,o=null!=t?t:null===(n=this._manifestUrls)||void 0===n?void 0:n[0],s=this._getBackoffSetting((function(e){d.trigger("warning",Rt(e))})),e.prev=6,e.next=9,l(o);case 9:return u=e.sent,e.abrupt("return",{parse:function(e){return d._parseLoadedManifest(u,e,o)}});case 13:throw e.prev=13,e.t0=e.catch(6),Rt(e.t0);case 16:case"end":return e.stop()}}),e,this,[[6,13]])})));return function(t){return e.apply(this,arguments)}}(),n.parse=function(e,t,n){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,n)},n._parseLoadedManifest=function(){var e=d(p().mark((function e(t,n,r){var i,a,o,s,u,l,c,f,v,h,m,g,y,_,b,S,E,k=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(E=function(e,t){S(t);var n=ne()-a;return T.info("MF: Manifest parsed in "+n+"ms"),{manifest:e,sendingTime:u,receivedTime:l,parsingTime:n}},S=function(e){for(var t,n=Ut(e);!(t=n()).done;){var r=t.value;if(o.isCancelled())return;var i=Ne(r,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown error when parsing the Manifest"});s("warning",i)}},b=function(){return(b=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Lt(t,c,o);case 3:return n=e.sent,e.abrupt("return",n);case 7:throw e.prev=7,e.t0=e.catch(0),Rt(e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)},_=function(e){return b.apply(this,arguments)},a=ne(),o=this._canceller.signal,s=this.trigger.bind(this),u=t.sendingTime,l=t.receivedTime,c=this._getBackoffSetting((function(e){k.trigger("warning",Rt(e))})),f=null!=r?r:null===(i=this._manifestUrls)||void 0===i?void 0:i[0],v={externalClockOffset:n.externalClockOffset,unsafeMode:n.unsafeMode,previousManifest:n.previousManifest,originalUrl:f},e.prev=11,h=this._pipelines.parseManifest(t,v,S,o,_),h instanceof Promise){e.next=17;break}return e.abrupt("return",E(h.manifest,h.warnings));case 17:return e.next=19,h;case 19:return m=e.sent,g=m.manifest,y=m.warnings,e.abrupt("return",E(g,y));case 23:e.next=29;break;case 25:throw e.prev=25,e.t0=e.catch(11),Ne(e.t0,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown error when parsing the Manifest"});case 29:case"end":return e.stop()}}),e,this,[[11,25]])})));return function(t,n,r){return e.apply(this,arguments)}}(),n._getBackoffSetting=function(e){var t=b.getCurrent(),n=t.DEFAULT_MAX_MANIFEST_REQUEST_RETRY,r=t.INITIAL_BACKOFF_DELAY_BASE,i=t.MAX_BACKOFF_DELAY_BASE,a=this._settings,o=a.lowLatencyMode,s=a.maxRetry;return{onRetry:e,baseDelay:o?r.LOW_LATENCY:r.REGULAR,maxDelay:o?i.LOW_LATENCY:i.REGULAR,maxRetry:null!=s?s:n}},n._recursivelyRefreshManifest=function(e,t){var n=this,r=t.sendingTime,i=t.parsingTime,a=t.updatingTime,o=b.getCurrent(),s=o.MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE,u=o.MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE,l=void 0!==i?i+(null!=a?a:0):void 0,d=!1;this._consecutiveUnsafeMode>0?d=this._consecutiveUnsafeMode<s:void 0!==l&&(d=l>=u);var c=void 0===r?0:ne()-r,f=Math.max(this._settings.minimumManifestUpdateInterval-c,0),v=new Z;if(v.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=function(t){var i=t.enablePartialRefresh,a=t.delay,o=t.canUseUnsafeMode&&d,s=void 0===r?0:ne()-r,u=Math.max(n._settings.minimumManifestUpdateInterval-s,0),l=setTimeout((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:i,unsafeMode:o})}),Math.max((null!=a?a:0)-s,u));v.signal.register((function(){clearTimeout(l)}))},null!==e.expired){var p=setTimeout((function(){var t;null===(t=e.expired)||void 0===t||t.then((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})}),S)}),f);v.signal.register((function(){clearTimeout(p)}))}if(void 0!==e.lifetime&&e.lifetime>=0){var h,m=1e3*e.lifetime-c;void 0===l?h=m:e.lifetime<3&&l>=100?(h=Math.min(Math.max(3e3-c,Math.max(m,0)+l),6*m),T.info("MUS: Manifest update rythm is too frequent. Postponing next request.",m,h)):l>=1e3*e.lifetime/10?(h=Math.min(Math.max(m,0)+l,6*m),T.info("MUS: Manifest took too long to parse. Postponing next request",h,h)):h=m;var g=setTimeout((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})}),Math.max(h,f));v.signal.register((function(){clearTimeout(g)}))}},n._triggerNextManifestRefresh=function(e,t){var n,r,i=this,a=t.enablePartialRefresh,o=t.unsafeMode,s=e.updateUrl;null!==this._prioritizedContentUrl?(n=!0,r=this._prioritizedContentUrl,this._prioritizedContentUrl=null):r=(n=!a||void 0===s)?e.getUrls()[0]:s;var u=e.clockOffset;o?(this._consecutiveUnsafeMode+=1,T.info('Init: Refreshing the Manifest in "unsafeMode" for the '+String(this._consecutiveUnsafeMode)+" consecutive time.")):this._consecutiveUnsafeMode>0&&(T.info('Init: Not parsing the Manifest in "unsafeMode" anymore after '+String(this._consecutiveUnsafeMode)+" consecutive times."),this._consecutiveUnsafeMode=0),this._isRefreshPending||(this._isRefreshPending=!0,this._fetchManifest(r).then((function(t){return t.parse({externalClockOffset:u,previousManifest:e,unsafeMode:o})})).then((function(t){i._isRefreshPending=!1;var r=t.manifest,a=t.sendingTime,o=t.parsingTime,s=ne();if(n)e.replace(r);else try{e.update(r)}catch(t){var u=t instanceof Error?t.message:"unknown error";T.warn("MUS: Attempt to update Manifest failed: "+u,"Re-downloading the Manifest fully");var l=b.getCurrent().FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY,d=void 0===a?0:ne()-a,c=Math.max(i._settings.minimumManifestUpdateInterval-d,0),f=S,v=setTimeout((function(){f(),i._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})}),Math.max(l-d,c));return void(f=i._canceller.signal.register((function(){clearTimeout(v)})))}var p=ne()-s;i._recursivelyRefreshManifest(e,{sendingTime:a,parsingTime:o,updatingTime:p})})).catch((function(e){i._isRefreshPending=!1,i._onFatalError(e)})))},n._onFatalError=function(e){this._canceller.isUsed()||(this.trigger("error",e),this.dispose())},t}(i);var zt=Bt;function Vt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Kt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Kt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Wt=function(e){function t(t){var n;return(n=e.call(this)||this)._downgradedCdnList={metadata:[],timeouts:[]},t.register((function(){for(var e,t=Vt(n._downgradedCdnList.timeouts);!(e=t()).done;){var r=e.value;clearTimeout(r)}n._downgradedCdnList={metadata:[],timeouts:[]}})),n}f(t,e);var n=t.prototype;return n.getCdnPreferenceForResource=function(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)},n.downgradeCdn=function(e){var t=this,n=Gt(this._downgradedCdnList.metadata,e);n>=0&&this._removeIndexFromDowngradeList(n);var r=b.getCurrent().DEFAULT_CDN_DOWNGRADE_TIME;this._downgradedCdnList.metadata.push(e);var i=setTimeout((function(){var n=Gt(t._downgradedCdnList.metadata,e);n>=0&&t._removeIndexFromDowngradeList(n),t.trigger("priorityChange",null)}),r);this._downgradedCdnList.timeouts.push(i),this.trigger("priorityChange",null)},n._innerGetCdnPreferenceForResource=function(e){var t=this,n=e.reduce((function(e,n){return t._downgradedCdnList.metadata.some((function(e){return e.id===n.id&&e.baseUrl===n.baseUrl}))?e[1].push(n):e[0].push(n),e}),[[],[]]),r=n[0],i=n[1];return r.concat(i)},n._removeIndexFromDowngradeList=function(e){this._downgradedCdnList.metadata.splice(e,1);var t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])},t}(i);function Gt(e,t){return 0===e.length?-1:void 0!==t.id?B(e,(function(e){return e.id===t.id})):B(e,(function(e){return e.baseUrl===t.baseUrl}))}function jt(e,t){return e.segment.id===t.segment.id&&e.representation.uniqueId===t.representation.uniqueId}function Ht(e){if(t(e))return"";var n,r=e.period,i=e.adaptation,a=e.representation,o=e.segment;return n=o.isInit?"init":o.complete?o.time+"-"+o.duration:""+o.time,i.type+" P: "+r.id+" A: "+i.id+" R: "+a.id+" S: "+n}var qt=function(){function e(){this._cache=new WeakMap}var t=e.prototype;return t.add=function(e,t){var n=e.representation;e.segment.isInit&&this._cache.set(n,t)},t.get=function(e){var t=e.representation;if(e.segment.isInit){var n=this._cache.get(t);if(void 0!==n)return n}return null},e}(),Yt=Le();var Qt=function(){function e(e){var t=e.prioritySteps;if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=t,this._prioritySteps.high>=this._prioritySteps.low)throw new Error("TP: the max high level priority should be given a lowerpriority number than the min low priority.")}var t=e.prototype;return t.create=function(e,t,n,r){var i,a=this;return Ct(r,(function(o,s){return i={hasEnded:!1,priority:t,trigger:function(){if(!i.hasEnded){var e=function(){u(),a._endTask(i)},t=new Z,u=t.linkToSignal(r);i.interrupter=t,t.signal.register((function(){i.interrupter=null,r.isCancelled()||n.beforeInterrupted()})),a._minPendingPriority=null===a._minPendingPriority?i.priority:Math.min(a._minPendingPriority,i.priority),a._pendingTasks.push(i),i.taskFn(t.signal).then((function(t){n.beforeEnded(),e(),o(t)})).catch((function(n){!r.isCancelled()&&t.isUsed()&&n instanceof ee||function(t){e(),s(t)}(n)}))}},taskFn:e,interrupter:null},a._canBeStartedNow(i)?(i.trigger(),a._isRunningHighPriorityTasks()&&a._interruptCancellableTasks()):a._waitingQueue.push(i),function(){return a._endTask(i)}}))},t._endTask=function(e){e.hasEnded=!0;var t=$t(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{var n=$t(e.taskFn,this._pendingTasks);if(n<0)return;this._pendingTasks.splice(n,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}},t.updatePriority=function(e,t){var n=$t(e,this._waitingQueue);if(n>=0){var r=this._waitingQueue[n];if(r.priority===t)return;if(r.priority=t,!this._canBeStartedNow(r))return;return this._findAndRunWaitingQueueTask(n),void(this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks())}var i=$t(e,this._pendingTasks);if(i<0)T.warn("TP: request to update the priority of a non-existent task");else{var a=this._pendingTasks[i];if(a.priority!==t){var o=a.priority;a.priority=t,null===this._minPendingPriority||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(1===this._pendingTasks.length?this._minPendingPriority=t:this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority}))),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}}},t._loopThroughWaitingQueue=function(){var e=this._waitingQueue.reduce((function(e,t){return null===e||e>t.priority?t.priority:e}),null);if(!(null===e||null!==this._minPendingPriority&&this._minPendingPriority<e))for(var t=0;t<this._waitingQueue.length;t++){var n=null===this._minPendingPriority?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=n&&(this._findAndRunWaitingQueueTask(t),t--)}},t._interruptCancellableTasks=function(){for(var e=0;e<this._pendingTasks.length;e++){var t=this._pendingTasks[e];if(t.priority>=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}},t._findAndRunWaitingQueueTask=function(e){return e>=this._waitingQueue.length||e<0?(T.warn("TP : Tried to start a non existing task"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)},t._interruptPendingTask=function(e){var t,n=$t(e.taskFn,this._pendingTasks);n<0?T.warn("TP: Interrupting a non-existent pending task. Aborting..."):(this._pendingTasks.splice(n,1),this._waitingQueue.push(e),0===this._pendingTasks.length?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))),null===(t=e.interrupter)||void 0===t||t.cancel())},t._canBeStartedNow=function(e){return null===this._minPendingPriority||e.priority<=this._minPendingPriority},t._isRunningHighPriorityTasks=function(){return null!==this._minPendingPriority&&this._minPendingPriority<=this._prioritySteps.high},e}();function $t(e,t){return B(t,(function(t){return t.taskFn===e}))}var Xt=function(){function e(e,t,n){var r=new Wt(n),i=b.getCurrent(),a=i.MIN_CANCELABLE_PRIORITY,o=i.MAX_HIGH_PRIORITY_LEVEL;this._transport=e,this._prioritizer=new Qt({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=r,this._backoffOptions=t}return e.prototype.createSegmentFetcher=function(e,n){var r,i,a,o,s,u,l,c,f,v,h,g,y,_,S=(r=this._backoffOptions,i=r.maxRetry,a=r.lowLatencyMode,o=r.requestTimeout,s=r.connectionTimeout,u=b.getCurrent(),l=u.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,c=u.DEFAULT_REQUEST_TIMEOUT,f=u.DEFAULT_CONNECTION_TIMEOUT,v=u.INITIAL_BACKOFF_DELAY_BASE,h=u.MAX_BACKOFF_DELAY_BASE,{maxRetry:null!=i?i:l,baseDelay:a?v.LOW_LATENCY:v.REGULAR,maxDelay:a?h.LOW_LATENCY:h.REGULAR,requestTimeout:void 0===o?c:o,connectionTimeout:void 0===s?f:s}),E=function(e,n,r,i,a){var o;o=void 0===a.connectionTimeout||a.connectionTimeout<0?void 0:a.connectionTimeout;var s={timeout:a.requestTimeout<0?void 0:a.requestTimeout,connectionTimeout:o},u=Ue(["audio","video"],e)?new qt:void 0,l=n.loadSegment,c=n.parseSegment;return function(){var e=d(p().mark((function e(n,o,d){var f,v,h,g,y,_,b,S,E,k,w,A,I,R,x,C,M,P,D,O,N,L,U,F;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(F=function(){var e;R||!t(w)&&void 0!==w.size&&void 0!==w.requestDuration&&A.length>0&&A.every((function(e){return e}))&&(R=!0,null===(e=i.onMetrics)||void 0===e||e.call(i,{size:w.size,requestDuration:w.requestDuration,content:n,segmentDuration:I}))},U=function(e){o.onRetry(Rt(e))},L=function(e,t){A.push(!1);var n=A.length-1;return function(r){var i={data:e,isChunked:t};try{var a=c(i,x,r);return A[n]||(I=void 0!==I&&"media"===a.segmentType&&null!==a.chunkInfos&&void 0!==a.chunkInfos.duration?I+a.chunkInfos.duration:void 0,A[n]=!0,F()),a}catch(e){throw Ne(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown parsing error"})}}},N=function(e){return l(e,x,s,d,C)},O=function(){var e;void 0===w&&(T.debug("SF: Segment request cancelled",E),w=null,null===(e=i.onRequestEnd)||void 0===e||e.call(i,{id:k}))},g=n.segment,y=n.adaptation,_=n.representation,b=n.manifest,S=n.period,E=Ht(n),k=Yt(),A=[],I=0,R=!1,x={segment:g,type:y.type,language:y.language,isLive:b.isLive,periodStart:S.start,periodEnd:S.end,mimeType:_.mimeType,codecs:_.codecs[0],manifestPublishTime:b.publishTime},C={onProgress:function(e){var t;void 0===w&&void 0!==e.totalSize&&e.size<e.totalSize&&(null===(t=i.onProgress)||void 0===t||t.call(i,{duration:e.duration,size:e.size,totalSize:e.totalSize,timestamp:ne(),id:k}))},onNewChunk:function(e){o.onChunk(L(e,!0))}},null===(M=void 0!==u?u.get(n):null)){e.next=18;break}return T.debug("SF: Found wanted segment in cache",E),o.onChunk(L(M,!1)),e.abrupt("return",Promise.resolve());case 18:return T.debug("SF: Beginning request",E),null===(f=i.onRequestBegin)||void 0===f||f.call(i,{requestTimestamp:ne(),id:k,content:n}),d.register(O),e.prev=21,e.next=24,Ot(n.representation.cdnMetadata,r,N,m({onRetry:U},a),d);case 24:"segment-loaded"===(P=e.sent).resultType?(D=P.resultData.responseData,void 0!==u&&u.add(n,P.resultData.responseData),o.onChunk(L(D,!1))):"segment-created"===P.resultType&&o.onChunk(L(P.resultData,!1)),T.debug("SF: Segment request ended with success",E),o.onAllChunksReceived(),"segment-created"!==P.resultType?(w=P.resultData,F()):w=null,d.isCancelled()||null===(v=i.onRequestEnd)||void 0===v||v.call(i,{id:k}),d.deregister(O),e.next=43;break;case 33:if(e.prev=33,e.t0=e.catch(21),d.deregister(O),w=null,!(e.t0 instanceof ee)){e.next=40;break}throw T.debug("SF: Segment request aborted",E),e.t0;case 40:throw T.debug("SF: Segment request failed",E),null===(h=i.onRequestEnd)||void 0===h||h.call(i,{id:k}),Rt(e.t0);case 43:case"end":return e.stop()}}),e,null,[[21,33]])})));return function(t,n,r){return e.apply(this,arguments)}}()}(e,this._transport[e],this._cdnPrioritizer,n,S);return g=this._prioritizer,y=E,_=new WeakMap,{createRequest:function(e,t,n,r){var i=function(t){return y(e,n,t)},a=g.create(i,t,n,r);return _.set(a,i),a},updatePriority:function(e,t){var n=_.get(e);void 0!==n?g.updatePriority(n,t):T.warn("Fetchers: Cannot update the priority of a request: task not found.")}}},e}(),Zt=Xt,Jt=function(){function e(e){this._array=[],this._sortingFn=e}var t=e.prototype;return t.add=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.sort(this._sortingFn);for(var r=0,i=0;i<t.length;i++){for(var a=t[i],o=!1;!o&&r<this._array.length;)this._sortingFn(a,this._array[r])<0?(this._array.splice(r,0,a),o=!0):r++;o||this._array.push(a)}},t.length=function(){return this._array.length},t.get=function(e){if(e<0||e>=this._array.length)throw new Error("Invalid index.");return this._array[e]},t.toArray=function(){return this._array.slice()},t.findFirst=function(e){return ae(this._array,e)},t.has=function(e){return Ue(this._array,e)},t.removeElement=function(e){var t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t},t.head=function(){return this._array[0]},t.last=function(){return this._array[this._array.length-1]},t.shift=function(){return this._array.shift()},t.pop=function(){return this._array.pop()},e}();function en(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return tn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function tn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var nn=function(e){function t(t,n,r){var i;(i=e.call(this)||this)._canceller=new Z,i._manifest=t,i._activeStreams=new Map,i._allBufferTypes=r,i._lastCurrentPeriodId=null;var a=new rn(t);i._maximumPositionCalculator=a;var o=i._canceller.signal;return n.listen((function(e){var n=e.position.getWanted();if(n<t.getMinimumSafePosition()){var r=new Me("MEDIA_TIME_BEFORE_MANIFEST","The current position is behind the earliest time announced in the Manifest.");i.trigger("warning",r)}else if(n>a.getMaximumAvailablePosition()){var o=new Me("MEDIA_TIME_AFTER_MANIFEST","The current position is after the latest time announced in the Manifest.");i.trigger("warning",o)}}),{includeLastObservation:!0,clearSignal:o}),t.addEventListener("manifestUpdate",(function(){i.trigger("endingPositionChange",i._getManifestEndTime()),o.isCancelled()||i._checkEndOfStream()}),o),i}f(t,e);var n=t.prototype;return n.getCurrentEndingTime=function(){return this._getManifestEndTime()},n.onAdaptationChange=function(e,t,n){if(this._manifest.isLastPeriodKnown){var r=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(null==r?void 0:r.id)&&("audio"===e||"video"===e)){"audio"===e?this._maximumPositionCalculator.updateLastAudioAdaptation(n):this._maximumPositionCalculator.updateLastVideoAdaptation(n);var i=this._maximumPositionCalculator.getEndingPosition(),a=void 0!==i?{isEnd:!0,endingPosition:i}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger("endingPositionChange",a)}}this._canceller.isUsed()||null===n&&this._addActivelyLoadedPeriod(t,e)},n.onRepresentationChange=function(e,t){this._addActivelyLoadedPeriod(t,e)},n.onPeriodCleared=function(e,t){this._removeActivelyLoadedPeriod(t,e)},n.onLastSegmentFinishedLoading=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())},n.onLastSegmentLoadingResume=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())},n.dispose=function(){this.removeEventListener(),this._canceller.cancel()},n._addActivelyLoadedPeriod=function(e,t){var n=this._lazilyCreateActiveStreamInfo(t);n.activePeriods.has(e)||(n.activePeriods.add(e),this._checkCurrentPeriod())},n._removeActivelyLoadedPeriod=function(e,t){var n=this._activeStreams.get(t);void 0!==n&&n.activePeriods.has(e)&&(n.activePeriods.removeElement(e),this._checkCurrentPeriod())},n._checkCurrentPeriod=function(){var e=this;if(0!==this._allBufferTypes.length){var t=this._activeStreams.get(this._allBufferTypes[0]);if(void 0!==t)for(var n,r,i=function(){for(var t=r.value,n=!0,i=1;i<e._allBufferTypes.length;i++){var a=e._activeStreams.get(e._allBufferTypes[i]);if(void 0===a)return{v:void 0};if(!a.activePeriods.toArray().some((function(e){return e.id===t.id}))){n=!1;break}}if(n)return e._lastCurrentPeriodId!==t.id&&(e._lastCurrentPeriodId=t.id,e.trigger("periodChange",t)),{v:void 0}},a=en(t.activePeriods.toArray());!(r=a()).done;)if(n=i())return n.v}},n._getManifestEndTime=function(){var e=this._maximumPositionCalculator.getEndingPosition();return void 0!==e?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}},n._lazilyCreateActiveStreamInfo=function(e){var t=this._activeStreams.get(e);return void 0===t&&(t={activePeriods:new Jt((function(e,t){return e.start-t.start})),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t},n._checkEndOfStream=function(){var e=this;this._manifest.isLastPeriodKnown&&(this._allBufferTypes.every((function(t){var n=e._activeStreams.get(t);return void 0!==n&&n.hasFinishedLoadingLastPeriod}))?this.trigger("endOfStream",null):this.trigger("resumeStream",null))},t}(i),rn=function(){function e(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}var t=e.prototype;return t.updateLastAudioAdaptation=function(e){this._lastAudioAdaptation=e},t.updateLastVideoAdaptation=function(e){this._lastVideoAdaptation=e},t.getMaximumAvailablePosition=function(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(void 0===this._lastVideoAdaptation||void 0===this._lastAudioAdaptation)return this._manifest.getMaximumSafePosition();if(null===this._lastAudioAdaptation){if(null===this._lastVideoAdaptation)return this._manifest.getMaximumSafePosition();var e=an(this._lastVideoAdaptation);return"number"!=typeof e?this._manifest.getMaximumSafePosition():e}if(null===this._lastVideoAdaptation){var t=an(this._lastAudioAdaptation);return"number"!=typeof t?this._manifest.getMaximumSafePosition():t}var n=an(this._lastAudioAdaptation),r=an(this._lastVideoAdaptation);return"number"!=typeof n||"number"!=typeof r?this._manifest.getMaximumSafePosition():Math.min(n,r)},t.getEndingPosition=function(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(void 0!==this._lastVideoAdaptation&&void 0!==this._lastAudioAdaptation){if(null===this._lastAudioAdaptation)return null===this._lastVideoAdaptation?void 0:null!==(e=on(this._lastVideoAdaptation))&&void 0!==e?e:void 0;if(null===this._lastVideoAdaptation)return null!==(t=on(this._lastAudioAdaptation))&&void 0!==t?t:void 0;var n=on(this._lastAudioAdaptation),r=on(this._lastVideoAdaptation);return"number"!=typeof n||"number"!=typeof r?void 0:Math.min(n,r)}},e}();function an(e){for(var n,r=e.representations,i=null,a=0;a<r.length;a++)if(r[a].index!==n){n=r[a].index;var o=r[a].index.getLastAvailablePosition();if(void 0===o)return;null!==o&&(i=t(i)?o:Math.min(i,o))}return i}function on(e){for(var n,r=e.representations,i=null,a=0;a<r.length;a++)if(r[a].index!==n){n=r[a].index;var o=r[a].index.getEnd();if(void 0===o)return;null!==o&&(i=t(i)?o:Math.min(i,o))}return i}function sn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return un(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return un(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function un(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ln=function(){function e(e){this._segmentSinksStore=e,this._currentFreezeTimestamp=null}return e.prototype.needToReload=function(e){var t=e.readyState,n=e.rebuffering,r=e.freezing;if((void 0!==e.bufferGap&&isFinite(e.bufferGap)?e.bufferGap:0)<6||null===n&&null===r||t>1)return this._currentFreezeTimestamp=null,!1;var i=ne();null===this._currentFreezeTimestamp&&(this._currentFreezeTimestamp=i);var a=null!==n&&i-n.timestamp>4e3,o=null!==r&&i-r.timestamp>4e3;if((a||o)&&ne()-this._currentFreezeTimestamp>4e3){for(var s=!0,u=!0,l=0,d=[this._segmentSinksStore.getStatus("audio"),this._segmentSinksStore.getStatus("video")];l<d.length;l++){var c=d[l];if("initialized"===c.type)for(var f,v=sn(c.value.getLastKnownInventory());!(f=v()).done;){var p=f.value.infos.representation;if(!1===p.decipherable)return T.warn("Init: we have undecipherable segments left in the buffer, reloading"),this._currentFreezeTimestamp=null,!0;void 0!==p.contentProtections&&(u=!1,!0!==p.decipherable&&(s=!1))}}if(!u&&s)return T.warn("Init: we are frozen despite only having decipherable segments left in the buffer, reloading"),this._currentFreezeTimestamp=null,!0}return!1},e}();function dn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var fn=function(){function e(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}var t=e.prototype;return t.addBufferedSegment=function(e,t){var n=ne();this._history.push({date:n,buffered:t,context:e}),this._cleanHistory(n)},t.getHistoryFor=function(e){return this._history.filter((function(t){return jt(t.context,e)}))},t._cleanHistory=function(e){for(var t,n=e-this._lifetime,r=0,i=dn(this._history);!(t=i()).done;){if(!(t.value.date<n))break;r++}if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){var a=this._history.length-this._maxHistoryLength;this._history=this._history.splice(a)}},e}();function vn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return pn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var hn=function(){function e(){var e=b.getCurrent(),t=e.BUFFERED_HISTORY_RETENTION_TIME,n=e.BUFFERED_HISTORY_MAXIMUM_ENTRIES;this._inventory=[],this._bufferedHistory=new fn(t,n)}var n=e.prototype;return n.reset=function(){this._inventory.length=0},n.synchronizeBuffered=function(e){for(var n,r,i,a,o,s,u,l=this._inventory,d=0,c=l[0],f=b.getCurrent().MINIMUM_SEGMENT_SIZE,v=null==c?void 0:c.infos.adaptation.type,p=e.length,h=0;h<p;h++){if(void 0===c)return;var m=e[h].start,g=e[h].end;if(g-m<f)T.warn("SI: skipped range when synchronizing because it was too small",v,m,g);else{for(var y=d;void 0!==c&&(null!==(n=c.bufferedEnd)&&void 0!==n?n:c.end)-m<f;)c=l[++d];var _=null,S=d-y;if(S>0){var E=l[y+S-1];_={end:null!==(r=E.bufferedEnd)&&void 0!==r?r:E.end,precizeEnd:E.precizeEnd},T.debug("SI: "+S+" segments GCed.",v);for(var k,w=vn(l.splice(y,S));!(k=w()).done;){var A=k.value;void 0===A.bufferedStart&&void 0===A.bufferedEnd&&2!==A.status&&this._bufferedHistory.addBufferedSegment(A.infos,null)}d=y}if(void 0===c)return;if(g-(null!==(i=c.bufferedStart)&&void 0!==i?i:c.start)>=f){if(yn(c,m,_,v),d===l.length-1)return void _n(c,g,v);for(var I=null!==(a=(c=l[++d]).bufferedStart)&&void 0!==a?a:c.start,R=null!==(o=c.bufferedEnd)&&void 0!==o?o:c.end,x=h<p-1?e[h+1].start:void 0;void 0!==c&&g-I>=f&&(void 0===x||g-I>=R-x);){var C=l[d-1];void 0===C.bufferedEnd&&(C.bufferedEnd=c.precizeStart?c.start:C.end,T.debug("SI: calculating buffered end of contiguous segment",v,C.bufferedEnd,C.end)),c.bufferedStart=C.bufferedEnd,void 0!==(c=l[++d])&&(I=null!==(s=c.bufferedStart)&&void 0!==s?s:c.start,R=null!==(u=c.bufferedEnd)&&void 0!==u?u:c.end)}}var M=l[d-1];void 0!==M&&_n(M,g,v)}}if(!t(c)){T.debug("SI: last segments have been GCed",v,d,l.length);for(var P,D=vn(l.splice(d,l.length-d));!(P=D()).done;){var O=P.value;void 0===O.bufferedStart&&void 0===O.bufferedEnd&&2!==O.status&&this._bufferedHistory.addBufferedSegment(O.infos,null)}}void 0!==v&&T.hasLevel("DEBUG")&&T.debug("SI: current "+v+" inventory timeline:\n"+function(e){var t=1/60,n={},r=[],i=null,a=null;function o(e){var t=String.fromCharCode(r.length+65);return r.push({letter:t,periodId:e.period.id,representationId:e.representation.id,bitrate:e.representation.bitrate}),t}for(var s="",u=0;u<e.length;u++){var l=e[u];if(void 0!==l.bufferedStart&&void 0!==l.bufferedEnd){var d,c=l.infos.period.id,f=l.infos.representation.id,v=n[c],p=void 0;if(void 0===v)p=o(l.infos),n[c]=((d={})[f]=p,d);else void 0===v[f]?(p=o(l.infos),v[f]=p):p=v[f];null===i?s+=l.bufferedStart.toFixed(2)+"|"+p+"|":a===p?i.bufferedEnd+t<l.bufferedStart&&(s+=i.bufferedEnd.toFixed(2)+" ~ "+l.bufferedStart.toFixed(2)+"|"+p+"|"):s+=i.bufferedEnd.toFixed(2)+" ~ "+l.bufferedStart.toFixed(2)+"|"+p+"|",i=l,a=p}}null!==i&&(s+=String(i.end.toFixed(2)));return r.forEach((function(e){var t;s+="\n["+e.letter+"] P: "+e.periodId+" || R: "+e.representationId+"("+(null!==(t=e.bitrate)&&void 0!==t?t:"unknown bitrate")+")"})),s}(this._inventory))},n.insertChunk=function(e,t,n){var r=e.period,i=e.adaptation,a=e.representation,o=e.segment,s=e.chunkSize,u=e.start,l=e.end;if(!o.isInit){var d=i.type;if(u>=l)T.warn("SI: Invalid chunked inserted: starts before it ends",d,u,l);else{for(var c=this._inventory,f={status:t?0:2,insertionTs:n,chunkSize:s,splitted:!1,start:u,end:l,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:o,period:r,adaptation:i,representation:a}},v=c.length-1;v>=0;v--){var p=c[v];if(p.start<=u){if(p.end<=u){for(T.debug("SI: Pushing segment strictly after previous one.",d,u,p.end),this._inventory.splice(v+1,0,f),v+=2;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return T.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);T.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}if(p.start===u){if(p.end<=l){for(T.debug("SI: Segment pushed replace another one",d,u,l,p.end),this._inventory.splice(v,1,f),v+=1;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return T.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);T.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}return T.debug("SI: Segment pushed ends before another with the same start",d,u,l,p.end),c.splice(v,0,f),p.start=f.end,p.bufferedStart=void 0,void(p.precizeStart=p.precizeStart&&f.precizeEnd)}if(p.end<=f.end){for(T.debug("SI: Segment pushed updates end of previous one",d,u,l,p.start,p.end),this._inventory.splice(v+1,0,f),p.end=f.start,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&f.precizeStart,v+=2;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return T.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);T.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}T.warn("SI: Segment pushed is contained in a previous one",d,u,l,p.start,p.end);var h={status:p.status,insertionTs:p.insertionTs,chunkSize:p.chunkSize,splitted:!0,start:f.end,end:p.end,precizeStart:p.precizeStart&&p.precizeEnd&&f.precizeEnd,precizeEnd:p.precizeEnd,bufferedStart:void 0,bufferedEnd:p.end,infos:p.infos};return p.end=f.start,p.splitted=!0,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&f.precizeStart,c.splice(v+1,0,f),void c.splice(v+2,0,h)}}var m=this._inventory[0];if(void 0===m)return T.debug("SI: first segment pushed",d,u,l),void this._inventory.push(f);if(!(m.start>=l)){if(m.end<=l){for(T.debug("SI: Segment pushed starts before and completely recovers the previous first one",d,u,l,m.start,m.end),this._inventory.splice(0,1,f);c.length>1&&c[1].start<f.end;){if(c[1].end>f.end)return T.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[1].start),c[1].start=f.end,c[1].bufferedStart=void 0,void(c[1].precizeStart=f.precizeEnd);T.debug("SI: Segment pushed removes the next one",d,u,l,c[1].start,c[1].end),c.splice(1,1)}return}return T.debug("SI: Segment pushed start of the next one",d,u,l,m.start,m.end),m.start=l,m.bufferedStart=void 0,m.precizeStart=f.precizeEnd,void this._inventory.splice(0,0,f)}T.debug("SI: Segment pushed comes before all previous ones",d,u,l,m.start),this._inventory.splice(0,0,f)}}},n.completeSegment=function(e){if(!e.segment.isInit){for(var t=this._inventory,n=[],r=0;r<t.length;r++)if(jt(t[r].infos,e)){var i=!1;n.length>0&&(i=!0,1===n.length&&(T.warn("SI: Completed Segment is splitted.",e.segment.id,e.segment.time,e.segment.end),n[0].splitted=!0));var a=r,o=t[r].chunkSize;for(r+=1;r<t.length&&jt(t[r].infos,e);){var s=t[r].chunkSize;void 0!==o&&void 0!==s&&(o+=s),r++}var u=r-1,l=u-a,d=t[u].end,c=t[u].bufferedEnd;l>0&&(this._inventory.splice(a+1,l),r-=l),0===this._inventory[a].status&&(this._inventory[a].status=1),this._inventory[a].chunkSize=o,this._inventory[a].end=d,this._inventory[a].bufferedEnd=c,this._inventory[a].splitted=i,n.push(this._inventory[a])}if(0===n.length)T.warn("SI: Completed Segment not found",e.segment.id,e.segment.time);else for(var f,v=vn(n);!(f=v()).done;){var p=f.value;void 0!==p.bufferedStart&&void 0!==p.bufferedEnd?2!==p.status&&this._bufferedHistory.addBufferedSegment(p.infos,{start:p.bufferedStart,end:p.bufferedEnd}):T.debug("SI: buffered range not known after sync. Skipping history.",p.start,p.end)}}},n.getInventory=function(){return this._inventory},n.getHistoryFor=function(e){return this._bufferedHistory.getHistoryFor(e)},e}();function mn(e){if(void 0===e.bufferedStart||1!==e.status)return!1;var t=e.start,n=e.end-t,r=b.getCurrent(),i=r.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,a=r.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(t-e.bufferedStart)<=i&&(void 0===e.bufferedEnd||e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-n)<=Math.min(a,n/3))}function gn(e){if(void 0===e.bufferedEnd||1!==e.status)return!1;var t=e.start,n=e.end,r=n-t,i=b.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(n-e.bufferedEnd)<=a&&void 0!==e.bufferedStart&&e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-r)<=Math.min(o,r/3)}function yn(e,t,n,r){var i=b.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MISSING_DATA_TRIGGER_SYNC_DELAY,s=i.SEGMENT_SYNCHRONIZATION_DELAY;if(void 0!==e.bufferedStart)e.bufferedStart<t&&(T.debug("SI: Segment partially GCed at the start",r,e.bufferedStart,t),e.bufferedStart=t),!e.precizeStart&&mn(e)&&(e.start=e.bufferedStart,e.precizeStart=!0);else if(e.precizeStart)T.debug("SI: buffered start is precize start",r,e.start),e.bufferedStart=e.start;else if(null!==n&&n.end>t&&(n.precizeEnd||e.start-n.end<=a))T.debug("SI: buffered start is end of previous segment",r,t,e.start,n.end),e.bufferedStart=n.end,mn(e)&&(e.start=n.end,e.precizeStart=!0);else if(e.start-t<=a){var u=ne();if(e.start-t>=o&&u-e.insertionTs<s)return void T.debug("SI: Ignored bufferedStart synchronization",r,t,e.start,u-e.insertionTs);T.debug("SI: found true buffered start",r,t,e.start),e.bufferedStart=t,mn(e)&&(e.start=t,e.precizeStart=!0)}else if(t<e.start)T.debug("SI: range start too far from expected start",r,t,e.start),e.bufferedStart=e.start;else{var l=ne();if(e.start-t>=o&&l-e.insertionTs<s)return void T.debug("SI: Ignored bufferedStart synchronization",r,t,e.start,l-e.insertionTs);T.debug("SI: Segment appears immediately garbage collected at the start",r,t,e.start),e.bufferedStart=t}}function _n(e,t,n){var r=b.getCurrent(),i=r.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,a=r.MISSING_DATA_TRIGGER_SYNC_DELAY,o=r.SEGMENT_SYNCHRONIZATION_DELAY;if(void 0!==e.bufferedEnd)e.bufferedEnd>t&&(T.debug("SI: Segment partially GCed at the end",n,e.bufferedEnd,t),e.bufferedEnd=t),!e.precizeEnd&&t-e.end<=i&&gn(e)&&(e.precizeEnd=!0,e.end=t);else if(e.precizeEnd)T.debug("SI: buffered end is precize end",n,e.end),e.bufferedEnd=e.end;else if(t-e.end<=i){var s=ne();if(t-e.end>=a&&s-e.insertionTs<o)return void T.debug("SI: Ignored bufferedEnd synchronization",n,t,e.end,s-e.insertionTs);T.debug("SI: found true buffered end",n,t,e.end),e.bufferedEnd=t,gn(e)&&(e.end=t,e.precizeEnd=!0)}else if(t>e.end)T.debug("SI: range end too far from expected end",n,t,e.end),e.bufferedEnd=e.end;else{var u=ne();if(t-e.end>=a&&u-e.insertionTs<o)return void T.debug("SI: Ignored bufferedEnd synchronization",n,t,e.end,u-e.insertionTs);T.debug("SI: Segment appears immediately garbage collected at the end",n,e.bufferedEnd,t),e.bufferedEnd=t}}var bn,Sn=hn,En=function(){function e(){this._segmentInventory=new Sn}var t=e.prototype;return t.synchronizeInventory=function(e){this._segmentInventory.synchronizeBuffered(e)},t.getLastKnownInventory=function(){return this._segmentInventory.getInventory()},t.getSegmentHistory=function(e){return this._segmentInventory.getHistoryFor(e)},e}();!function(e){e[e.Push=0]="Push",e[e.Remove=1]="Remove",e[e.SignalSegmentComplete=2]="SignalSegmentComplete"}(bn||(bn={}));var Tn=function(e){function t(t,n,r){var i;i=e.call(this)||this,T.info("AVSB: calling `mediaSource.addSourceBuffer`",n);var a=r.addSourceBuffer(t,n);return i.bufferType=t,i._sourceBuffer=a,i._lastInitSegmentUniqueId=null,i.codec=n,i._initSegmentsMap=new Map,i._pendingOperations=[],i}f(t,e);var n=t.prototype;return n.declareInitSegment=function(e,t){kn(t),this._initSegmentsMap.set(e,t)},n.freeInitSegment=function(e){this._initSegmentsMap.delete(e)},n.pushChunk=function(){var e=d(p().mark((function e(t){var n,r,i,a,o=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return kn(t.data.chunk),T.debug("AVSB: receiving order to push data to the SourceBuffer",this.bufferType,Ht(t.inventoryInfos)),0===(n=this._getActualDataToPush(t.data)).length&&n.push(new Uint8Array),r=Promise.all(n.map((function(e){var n=t.data,r=n.codec,i=n.timestampOffset,a=n.appendWindow;return T.debug("AVSB: pushing segment",o.bufferType,Ht(t.inventoryInfos)),o._sourceBuffer.appendBuffer(e,{codec:r,timestampOffset:i,appendWindow:a})}))),this._addToOperationQueue(r,{type:bn.Push,value:t}),e.prev=6,e.next=9,r;case 9:i=e.sent,e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(6),this._segmentInventory.insertChunk(t.inventoryInfos,!1,ne()),e.t0;case 16:return null!==t.inventoryInfos&&this._segmentInventory.insertChunk(t.inventoryInfos,!0,ne()),a=i[i.length-1],this._segmentInventory.synchronizeBuffered(a),e.abrupt("return",a);case 20:case"end":return e.stop()}}),e,this,[[6,12]])})));return function(t){return e.apply(this,arguments)}}(),n.removeBuffer=function(){var e=d(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.debug("AVSB: receiving order to remove data from the SourceBuffer",this.bufferType,t,n),r=this._sourceBuffer.remove(t,n),this._addToOperationQueue(r,{type:bn.Remove,value:{start:t,end:n}}),e.next=5,r;case 5:return i=e.sent,this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.signalSegmentComplete=function(){var e=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._pendingOperations.length>0)){e.next=10;break}return n=this._pendingOperations[this._pendingOperations.length-1].promise,this._addToOperationQueue(n,{type:bn.SignalSegmentComplete,value:t}),e.prev=3,e.next=6,n;case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:this._segmentInventory.completeSegment(t);case 11:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(t){return e.apply(this,arguments)}}(),n.getPendingOperations=function(){return this._pendingOperations.map((function(e){return e.operation}))},n.dispose=function(){try{T.debug("AVSB: Calling `dispose` on the SourceBufferInterface"),this._sourceBuffer.dispose()}catch(e){T.debug("AVSB: Failed to dispose a "+this.bufferType+" SourceBufferInterface:",e instanceof Error?e:"")}},n._getActualDataToPush=function(e){var t=[];if(null!==e.initSegmentUniqueId&&!this._isLastInitSegment(e.initSegmentUniqueId)){var n=this._initSegmentsMap.get(e.initSegmentUniqueId);if(void 0===n)throw new Error("Invalid initialization segment uniqueId");var r=new ArrayBuffer(n.byteLength),i=new Uint8Array(r);i.set(n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)),n=i,t.push(n),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return null!==e.chunk&&t.push(e.chunk),t},n._isLastInitSegment=function(e){return null!==this._lastInitSegmentUniqueId&&this._lastInitSegmentUniqueId===e},n._addToOperationQueue=function(e,t){var n=this,r={operation:t,promise:e};this._pendingOperations.push(r);var i=function(){var e=n._pendingOperations.indexOf(r);e>=0&&n._pendingOperations.splice(e,1)};e.then(i,i)},t}(En);function kn(e){}var wn=Tn,An=function(e){function t(t){var n;return T.debug("HTSB: Creating TextSegmentSink"),(n=e.call(this)||this).bufferType="text",n._sender=t,n._pendingOperations=[],n._sender.reset(),n}f(t,e);var n=t.prototype;return n.declareInitSegment=function(e){T.warn("HTSB: Declaring initialization segment for Text SegmentSink",e)},n.freeInitSegment=function(e){T.warn("HTSB: Freeing initialization segment for Text SegmentSink",e)},n.pushChunk=function(){var e=d(p().mark((function e(t){var n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return In((n=t.data).chunk),r=this._sender.pushTextData(Object.assign(Object.assign({},n),{chunk:n.chunk})),this._addToOperationQueue(r,{type:bn.Push,value:t}),e.next=6,r;case 6:return i=e.sent,null!==t.inventoryInfos&&this._segmentInventory.insertChunk(t.inventoryInfos,!0,ne()),this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.removeBuffer=function(){var e=d(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._sender.remove(t,n),this._addToOperationQueue(r,{type:bn.Remove,value:{start:t,end:n}}),e.next=4,r;case 4:return i=e.sent,this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.signalSegmentComplete=function(){var e=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._pendingOperations.length>0)){e.next=10;break}return n=this._pendingOperations[this._pendingOperations.length-1].promise,this._addToOperationQueue(n,{type:bn.SignalSegmentComplete,value:t}),e.prev=3,e.next=6,n;case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:this._segmentInventory.completeSegment(t);case 11:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(t){return e.apply(this,arguments)}}(),n.getPendingOperations=function(){return this._pendingOperations.map((function(e){return e.operation}))},n.dispose=function(){T.debug("HTSB: Disposing TextSegmentSink"),this._sender.reset()},n._addToOperationQueue=function(e,t){var n=this,r={operation:t,promise:e};this._pendingOperations.push(r);var i=function(){var e=n._pendingOperations.indexOf(r);e>=0&&n._pendingOperations.splice(e,1)};e.then(i,i)},t}(En);function In(e){}var Rn=An,xn=["audio","video","text"];function Cn(e){return"audio"===e||"video"===e}var Mn=function(){function e(e,t,n){this._mediaSource=e,this._textInterface=n,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}e.isNative=function(e){return Cn(e)};var n=e.prototype;return n.getBufferTypes=function(){var e=this.getNativeBufferTypes();return null!==this._textInterface&&e.push("text"),e},n.getNativeBufferTypes=function(){return this._hasVideo?["video","audio"]:["audio"]},n.getStatus=function(e){var t=this._initializedSegmentSinks[e];return void 0===t?{type:"uninitialized"}:null===t?{type:"disabled"}:{type:"initialized",value:t}},n.waitForUsableBuffers=function(e){var t=this;return this._areNativeBuffersUsable()?Promise.resolve():Ct(e,(function(e){var n,r=function(){var e=t._onNativeBufferAddedOrDisabled.indexOf(n);e>=0&&t._onNativeBufferAddedOrDisabled.splice(e,1)};return n=function(){t._areNativeBuffersUsable()&&(r(),e())},t._onNativeBufferAddedOrDisabled.push(n),r}))},n.disableSegmentSink=function(t){var n=this._initializedSegmentSinks[t];if(null!==n){if(void 0!==n)throw new Error("Cannot disable an active SegmentSink.");this._initializedSegmentSinks[t]=null,e.isNative(t)&&this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()}))}else T.warn("SBS: The "+t+" SegmentSink was already disabled.")},n.createSegmentSink=function(e,n){var r,i=this._initializedSegmentSinks[e];if(Cn(e)){if(!t(i))return i instanceof wn&&i.codec!==n?T.warn("SB: Reusing native SegmentSink with codec",i.codec,"for codec",n):T.info("SB: Reusing native SegmentSink with codec",n),i;T.info("SB: Adding native SegmentSink with codec",n);var a=new wn("audio"===e?"audio":"video",n,this._mediaSource);return this._initializedSegmentSinks[e]=a,this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()})),a}if(!t(i))return T.info("SB: Reusing a previous custom SegmentSink for the type",e),i;if("text"===e){if(T.info("SB: Creating a new text SegmentSink"),null===this._textInterface)throw new Error("HTML Text track feature not activated");return r=new Rn(this._textInterface),this._initializedSegmentSinks.text=r,r}throw T.error("SB: Unknown buffer type:",e),new Me("BUFFER_TYPE_UNKNOWN","The player wants to create a SegmentSink of an unknown type.")},n.disposeSegmentSink=function(e){var n=this._initializedSegmentSinks[e];t(n)?T.warn("SB: Trying to dispose a SegmentSink that does not exist"):(T.info("SB: Aborting SegmentSink",e),n.dispose(),delete this._initializedSegmentSinks[e])},n.disposeAll=function(){var e=this;xn.forEach((function(t){"initialized"===e.getStatus(t).type&&e.disposeSegmentSink(t)}))},n._areNativeBuffersUsable=function(){var e=this,t=this.getNativeBufferTypes();return!t.some((function(t){return void 0===e._initializedSegmentSinks[t]}))&&!t.every((function(t){return null===e._initializedSegmentSinks[t]}))},e}(),Pn=function(){function e(e){this._weakMap=new WeakMap,this._fn=e}var t=e.prototype;return t.get=function(e){var t=this._weakMap.get(e);if(void 0===t){var n=this._fn(e);return this._weakMap.set(e,n),n}return t},t.destroy=function(e){this._weakMap.delete(e)},e}();function Dn(e,t){var n,r=e.segmentSink,i=e.playbackObserver,a=e.maxBufferBehind,o=e.maxBufferAhead,s=[];function u(){null!==s&&function(e,t,n,r,i,a){return On.apply(this,arguments)}(r,n,s,a.getValue(),o.getValue(),t).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";T.error("Could not run BufferGarbageCollector:",t)}))}i.listen((function(e){n=e.position.getWanted(),s=e.buffered[r.bufferType],u()}),{includeLastObservation:!0,clearSignal:t}),a.onUpdate(u,{clearSignal:t}),o.onUpdate(u,{clearSignal:t}),u()}function On(){return(On=d(p().mark((function e(n,r,i,a,o,s){var u,l,d,c,f,v,h,m;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(isFinite(a)||isFinite(o)){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:u=[],l=O(i,r),d=l.innerRange,c=l.outerRanges,f=function(){if(isFinite(o)){for(var e=0;e<c.length;e++){var n=c[e];r+o<=n.start?u.push(n):r<=n.start&&r+o<n.end&&r+o>n.start&&u.push({start:r+o,end:n.end})}t(d)||r+o<d.end&&u.push({start:r+o,end:d.end})}},function(){if(isFinite(a)){for(var e=0;e<c.length;e++){var n=c[e];r-a>=n.end?u.push(n):r>=n.end&&r-a>n.start&&r-a<n.end&&u.push({start:n.start,end:r-a})}t(d)||r-a>d.start&&u.push({start:d.start,end:r-a})}}(),f(),v=0,h=u;case 9:if(!(v<h.length)){e.next=20;break}if(!((m=h[v]).start<m.end)){e.next=17;break}if(T.debug("GC: cleaning range from SegmentSink",m.start,m.end),null===s.cancellationError){e.next=15;break}throw s.cancellationError;case 15:return e.next=17,n.removeBuffer(m.start,m.end);case 17:v++,e.next=9;break;case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Nn=function(e){function t(t,n,r,i){var a;return(a=e.call(this)||this)._content=t,a._currentCanceller=null,a._downloadQueue=n,a._initSegmentRequest=null,a._mediaSegmentRequest=null,a._segmentFetcher=r,a._initSegmentInfoRef=new G(void 0),a._mediaSegmentAwaitingInitMetadata=null,i||a._initSegmentInfoRef.setValue(null),a}f(t,e);var n=t.prototype;return n.getRequestedInitSegment=function(){return null===this._initSegmentRequest?null:this._initSegmentRequest.segment},n.getRequestedMediaSegment=function(){return null===this._mediaSegmentRequest?null:this._mediaSegmentRequest.segment},n.start=function(){var e=this;null===this._currentCanceller&&(this._currentCanceller=new Z,this._downloadQueue.onUpdate((function(t){var n=t.segmentQueue;if(!(n.length>0&&n[0].segment.id===e._mediaSegmentAwaitingInitMetadata)){var r=e._mediaSegmentRequest;if(0===n.length){if(null===r)return;return T.debug("Stream: no more media segment to request. Cancelling queue.",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()}if(null===r)return T.debug("Stream: Media segments now need to be requested. Starting queue.",e._content.adaptation.type,n.length),void e._restartMediaSegmentDownloadingQueue();var i=n[0];return r.segment.id!==i.segment.id?(T.debug("Stream: Next media segment changed, cancelling previous",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()):void(r.priority!==i.priority&&(T.debug("Stream: Priority of next media segment changed, updating",e._content.adaptation.type,r.priority,i.priority),e._segmentFetcher.updatePriority(r.request,i.priority)))}}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate((function(t){var n,r=e._initSegmentRequest;null===t.initSegment||null===r?(null===(n=t.initSegment)||void 0===n?void 0:n.segment.id)!==(null==r?void 0:r.segment.id)&&(null===t.initSegment&&T.debug("Stream: no more init segment to request. Cancelling queue.",e._content.adaptation.type),e._restartInitSegmentDownloadingQueue(t.initSegment)):t.initSegment.priority!==r.priority&&e._segmentFetcher.updatePriority(r.request,t.initSegment.priority)}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))},n.stop=function(){var e;null===(e=this._currentCanceller)||void 0===e||e.cancel(),this._currentCanceller=null},n._restartMediaSegmentDownloadingQueue=function(){var e=this;null!==this._mediaSegmentRequest&&this._mediaSegmentRequest.canceller.cancel();!function t(n){if(null!==e._currentCanceller&&e._currentCanceller.isUsed())e._mediaSegmentRequest=null;else{if(void 0===n)return e._mediaSegmentRequest=null,void e.trigger("emptyQueue",null);var r=new Z,i=null===e._currentCanceller?S:r.linkToSignal(e._currentCanceller.signal),a=n.segment,o=n.priority,s=m({segment:a},e._content),u=!1,l=!1;r.signal.register((function(){e._mediaSegmentRequest=null,u||(e._mediaSegmentAwaitingInitMetadata===a.id&&(e._mediaSegmentAwaitingInitMetadata=null),u=!0,l=!1)}));var d=function(t){$(t.segmentType),e.trigger("parsedMediaSegment",m({},t,{segment:a}))},c=function(){var n=e._downloadQueue.getValue().segmentQueue;if(0===n.length)return u=!0,void e.trigger("emptyQueue",null);n[0].segment.id===a.id&&n.shift(),u=!0,t(n[0])},f=e._segmentFetcher.createRequest(s,o,{onRetry:function(t){e.trigger("requestRetry",{segment:a,error:t})},beforeInterrupted:function(){T.info("Stream: segment request interrupted temporarly.",a.id,a.time)},onChunk:function(t){var n=e._initSegmentInfoRef.getValue();void 0!==n?d(t(null!=n?n:void 0)):(l=!0,e._initSegmentInfoRef.waitUntilDefined((function(e){d(t(null!=e?e:void 0))}),{clearSignal:r.signal}))},onAllChunksReceived:function(){l?(e._mediaSegmentAwaitingInitMetadata=a.id,e._initSegmentInfoRef.waitUntilDefined((function(){e._mediaSegmentAwaitingInitMetadata=null,l=!1,e.trigger("fullyLoadedSegment",a)}),{clearSignal:r.signal})):e.trigger("fullyLoadedSegment",a)},beforeEnded:function(){i(),e._mediaSegmentRequest=null,l?e._initSegmentInfoRef.waitUntilDefined(c,{clearSignal:r.signal}):c()}},r.signal);f.catch((function(t){i(),u||(u=!0,e.stop(),e.trigger("error",t))})),e._mediaSegmentRequest={segment:a,priority:o,request:f,canceller:r}}}(this._downloadQueue.getValue().segmentQueue[0])},n._restartInitSegmentDownloadingQueue=function(e){var t=this;if((null===this._currentCanceller||!this._currentCanceller.isUsed())&&(null!==this._initSegmentRequest&&this._initSegmentRequest.canceller.cancel(),null!==e)){var n=new Z,r=null===this._currentCanceller?S:n.linkToSignal(this._currentCanceller.signal),i=e.segment,a=e.priority,o=m({segment:i},this._content),s=!1,u=this._segmentFetcher.createRequest(o,a,{onRetry:function(e){t.trigger("requestRetry",{segment:i,error:e})},beforeInterrupted:function(){T.info("Stream: init segment request interrupted temporarly.",i.id)},beforeEnded:function(){r(),t._initSegmentRequest=null,s=!0},onChunk:function(e){var n,r=e(void 0);$(r.segmentType),t.trigger("parsedInitSegment",m({},r,{segment:i})),"init"===r.segmentType&&t._initSegmentInfoRef.setValue(null!==(n=r.initTimescale)&&void 0!==n?n:null)},onAllChunksReceived:function(){t.trigger("fullyLoadedSegment",i)}},n.signal);u.catch((function(e){r(),s||(s=!0,t.stop(),t.trigger("error",e))})),n.signal.register((function(){t._initSegmentRequest=null,s||(s=!0)})),this._initSegmentRequest={segment:i,priority:a,request:u,canceller:n}}},t}(i);function Ln(e,t,n,r,i){var a=e.period,o=e.adaptation,s=e.representation,u=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(void 0===r.bufferedStart||void 0===r.bufferedEnd||r.bufferedStart>=t.end)return null;if(r.bufferedEnd>t.start)return n}return null}(i,t);if(null===u){if(null===n){if(r&&void 0!==a.end&&t.end>=a.end)return{start:void 0,end:null};var l=s.index.checkDiscontinuity(t.start);if(null!==l)return{start:void 0,end:l}}return null}var d=i[u];if(void 0!==d.bufferedStart&&d.bufferedStart>t.start&&(null===n||d.infos.segment.end<=n)){var c=d.bufferedStart;return r||!1===s.index.awaitSegmentBetween(t.start,c)?(T.debug("RS: current discontinuity encountered",o.type,d.bufferedStart),{start:void 0,end:c}):null}var f=function(e,t,n){if(n<=0)return T.error("RS: Asked to check a discontinuity before the first chunk."),null;for(var r=n;r<e.length;r++){var i=e[r],a=e[r-1];if(void 0===i.bufferedStart||void 0===a.bufferedEnd||i.bufferedStart>=t.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}(i,t,u+1);if(null!==f){var v=i[f-1],p=i[f];if(null===n||p.infos.segment.end<=n){if(!r&&!1!==s.index.awaitSegmentBetween(v.infos.segment.end,p.infos.segment.time))return null;var h=v.bufferedEnd,m=p.bufferedStart;return T.debug("RS: future discontinuity encountered",o.type,h,m),{start:h,end:m}}}if(null===n){if(r&&void 0!==a.end){if(t.end<a.end)return null;var g=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(void 0===r.bufferedStart)return null;if(r.bufferedStart<t)return n}return null}(i,a.end);if(null!==g){var y=i[g];if(void 0!==y.bufferedEnd&&y.bufferedEnd<a.end)return T.debug("RS: discontinuity encountered at the end of the current period",o.type,y.bufferedEnd,a.end),{start:y.bufferedEnd,end:null}}}if(void 0!==a.end&&t.end>=a.end)return null;for(var _=i.length-1;_>=0;_--){var b=i[_];if(void 0===b.bufferedStart)break;if(b.bufferedStart<t.end){if(void 0!==b.bufferedEnd&&b.bufferedEnd<t.end){var S=s.index.checkDiscontinuity(t.end);if(null!==S)return{start:b.bufferedEnd,end:S}}return null}}}return null}function Un(e){var t=e.bufferedSegments,n=e.content,r=e.currentPlaybackTime,i=e.fastSwitchThreshold,a=e.getBufferedHistory,o=e.neededRange,s=e.segmentsBeingPushed,u=e.maxBufferSize,l=n.adaptation,d=n.representation,c=function(e,t,n){var r=8e3*n;return r-=t.reduce((function(e,t){return e+t.representation.bitrate*t.segment.duration}),0),e.reduce((function(e,t){return void 0!==t.chunkSize?e-8*t.chunkSize:e}),r)}(t,s,u),f=d.index.getSegments(o.start,o.end-o.start),v=t.filter((function(e){return!Bn(e.infos,n,r,i)})).filter((function(e,t,n){var r=0===t?null:n[t-1],i=t>=n.length-1?null:n[t+1],s=null;if(function(e,t,n){var r=b.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedStart)return!1;if(null!==t&&void 0!==t.bufferedEnd&&e.bufferedStart-t.bufferedEnd<.1)return!1;if(n<e.bufferedStart&&e.bufferedStart-e.start>r)return T.info("Stream: The start of the wanted segment has been garbage collected",e.start,e.bufferedStart),!0;return!1}(e,r,o.start)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.start;if(void 0!==t&&void 0!==a&&t-a>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.start;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(s=a(e.infos),e.bufferedStart))return!1;T.debug("Stream: skipping segment gc-ed at the start",e.start,e.bufferedStart)}if(function(e,t,n){var r=b.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedEnd)return!1;if(null!==t&&void 0!==t.bufferedStart&&t.bufferedStart-e.bufferedEnd<.1)return!1;if(n>e.bufferedEnd&&e.end-e.bufferedEnd>r)return T.info("Stream: The end of the wanted segment has been garbage collected",e.end,e.bufferedEnd),!0;return!1}(e,i,o.end)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.end;if(void 0!==t&&void 0!==a&&a-t>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.end;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(s=null!=s?s:a(e.infos),e.bufferedEnd))return!1;T.debug("Stream: skipping segment gc-ed at the end",e.end,e.bufferedEnd)}return!0})),p=b.getCurrent(),h=p.MINIMUM_SEGMENT_SIZE,g=p.MIN_BUFFER_AHEAD,y=!1,_=Math.min(1/60,h),S=!1,E=[],k=f.filter((function(e){var t=m({segment:e},n);if(s.length>0&&s.some((function(e){return jt(t,e)})))return!1;var u=e.duration,f=e.time,p=e.end;if(e.isInit)return!0;if(y)return E.push(e),!1;if(e.complete&&u<h)return!1;if(s.length>0&&s.some((function(e){if(e.period.id!==n.period.id||e.adaptation.id!==n.adaptation.id)return!1;var a=e.segment;return!(a.time-_>f)&&(!(a.end+_<p)&&!Bn(e,t,r,i))})))return!1;for(var b=0;b<v.length;b++){var k=v[b];if(k.infos.period.id===n.period.id){var w=k.infos.segment;if(f-w.time>-_&&w.end-p>-_)return!1}}var A=u*n.representation.bitrate;if(c-A<0&&(S=!0,f>o.start+g))return y=!0,E.push(e),!1;var I=a(t);if(I.length>1){var R=I[I.length-1],x=I[I.length-2];if(null===R.buffered&&null===x.buffered)return T.warn("Stream: Segment GCed multiple times in a row, ignoring it.","If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering."+l.type,d.id,e.time),!1}for(var C=0;C<v.length;C++){var M=v[C];if(M.end+_>f){var P=M.start>f+_||Fn(v,C).end<p-_;return P&&(c-=A),P}}return c-=A,!0}));return{segmentsToLoad:k,segmentsOnHold:E,isBufferFull:S}}function Fn(e,t){for(var n=t+1,r=b.getCurrent().MINIMUM_SEGMENT_SIZE,i=Math.min(1/60,r);n<e.length-1&&e[n-1].end+i>e[n].start;)n++;return e[--n]}function Bn(e,t,n,r){var i=b.getCurrent().CONTENT_REPLACEMENT_PADDING;return e.period.id===t.period.id&&(!(e.segment.time<n+i)&&(e.adaptation.id!==t.adaptation.id||function(e,t,n){var r=e.bitrate,i=b.getCurrent().BITRATE_REBUFFERING_RATIO;if(void 0===n){var a=r*i;return t.bitrate>a}return r<n&&t.bitrate>r}(e.representation,t.representation,r)))}function zn(e,t){for(var n=e-t,r=b.getCurrent().SEGMENT_PRIORITIES_STEPS,i=0;i<r.length;i++)if(n<r[i])return i;return r.length}function Vn(e,n,r,i,a,o,s){var u,l,d,c=e.representation,f=null!==(l=null!==(u=r.getIsPaused())&&void 0!==u?u:r.getReference().getValue().paused.pending)&&void 0!==l?l:r.getReference().getValue().paused.last,v=null!==(d=r.getPlaybackRate())&&void 0!==d?d:r.getReference().getValue().speed,p=n;(void 0===f||void 0===v||f||v<=0)&&(p-=.1);var h=function(e,n,r){var i,a,o=e.manifest,s=e.period,u=e.representation,l=u.index.getLastAvailablePosition(),d=u.index;a=!t(l)&&Mn.isNative(e.adaptation.type)&&n>=l&&d.isInitialized()&&!d.isStillAwaitingFutureSegments()&&function(e,t,n){var r,i=e.getPeriodAfter(t);return t.containsTime(n,i)&&e.isLastPeriodKnown&&t.id===(null===(r=e.periods[e.periods.length-1])||void 0===r?void 0:r.id)}(o,s,n)?l-1:n-.1;var c,f=a+r;c=!(!u.index.isInitialized()||u.index.isStillAwaitingFutureSegments()||void 0===s.end)&&(void 0===l?f>=s.end:null===l||f>=l);return{start:Math.max(a,s.start),end:Math.min(f,null!==(i=s.end)&&void 0!==i?i:1/0),hasReachedPeriodEnd:c}}(e,p,a),m=c.index.shouldRefresh(h.start,h.end),g=s.getPendingOperations().filter((function(e){return e.type===bn.SignalSegmentComplete})).map((function(e){return e.value})),y=function(e,t){for(var n=b.getCurrent().MINIMUM_SEGMENT_SIZE,r=Math.max(1/60,n),i=e.start+r,a=e.end-r,o=[],s=t.length-1;s>=0;s--){var u=t[s],l=u.infos.representation;if(1===u.status&&!1!==l.decipherable&&!1!==l.isSupported){var d=u.infos.segment,c=d.time/d.timescale;((d.complete?c+d.duration/d.timescale:u.end)>i&&c<a||u.end>i&&u.start<a)&&o.unshift(u)}}return o}({start:Math.max(h.start-.5,0),end:h.end+.5},s.getLastKnownInventory()),_=r.getCurrentTime();void 0===_&&(_=r.getReference().getValue().position.getWanted());var S=Un({content:e,bufferedSegments:y,currentPlaybackTime:_,fastSwitchThreshold:i,getBufferedHistory:s.getSegmentHistory.bind(s),neededRange:h,segmentsBeingPushed:g,maxBufferSize:o}),E=S.segmentsToLoad,T=S.segmentsOnHold,k=S.isBufferFull,w=E.map((function(e){return{priority:zn(e.time,p),segment:e}})),A=c.index.isInitialized()&&!c.index.isStillAwaitingFutureSegments()&&h.hasReachedPeriodEnd&&0===w.length&&0===T.length,I=null;return g.length>0&&(I=Math.min.apply(Math,g.map((function(e){return e.segment.time})))),T.length>0&&(I=null!==I?Math.min(I,T[0].time):T[0].time),w.length>0&&(I=null!==I?Math.min(I,w[0].segment.time):w[0].segment.time),{imminentDiscontinuity:Ln(e,h,I,A,y),hasFinishedLoading:A,neededSegments:w,isBufferFull:k,shouldRefreshManifest:m}}var Kn=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="SourceBufferError",a.errorName=n,a.message=r,a.isBufferFull=i,a}f(t,e);var n=t.prototype;return n.serialize=function(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}},n.toString=function(){return this.errorName+": "+this.message},t}(Y(Error));function Wn(e){return new Promise((function(t){setTimeout(t,e)}))}function Gn(e,t,n,r,i){return jn.apply(this,arguments)}function jn(){return(jn=d(p().mark((function e(t,n,r,i,a){var o,s,u,l,d,c,f;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,n.pushChunk(r);case 3:case 31:return e.abrupt("return",e.sent);case 6:if(e.prev=6,e.t0=e.catch(0),!(a.isCancelled()&&e.t0 instanceof ee)){e.next=12;break}throw e.t0;case 12:if(e.t0 instanceof Kn&&e.t0.isBufferFull){e.next=15;break}throw o=e.t0 instanceof Error?e.t0.toString():"An unknown error happened when pushing content",new Me("BUFFER_APPEND_ERROR",o,{tracks:[Je(r.inventoryInfos.adaptation)]});case 15:return s=t.getReference().getValue(),u=s.position,l=u.getWanted(),e.prev=17,T.warn("Stream: Running garbage collector"),d=Math.max(l-5,0),c=l+i.getValue()+12,e.next=23,n.removeBuffer(0,d);case 23:return e.next=25,n.removeBuffer(c,Number.MAX_VALUE);case 25:return e.next=27,Wn(200);case 27:if(null===a.cancellationError){e.next=29;break}throw a.cancellationError;case 29:return e.next=31,n.pushChunk(r);case 34:if(e.prev=34,e.t1=e.catch(17),!(e.t1 instanceof ee)){e.next=38;break}throw e.t1;case 38:throw f=e.t1 instanceof Error?e.t1.toString():"Could not clean the buffer",new Me("BUFFER_FULL_ERROR",f,{tracks:[Je(r.inventoryInfos.adaptation)]});case 40:case"end":return e.stop()}}),e,null,[[0,6],[17,34]])})))).apply(this,arguments)}function Hn(){return Hn=d(p().mark((function e(t,n){var r,i,a,o,s,u,l,d,c,f;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.playbackObserver,i=t.content,a=t.initSegmentUniqueId,o=t.segment,s=t.segmentSink,u=t.bufferGoal,null===n.cancellationError){e.next=3;break}throw n.cancellationError;case 3:return l=i.representation.getMimeTypeString(),d={initSegmentUniqueId:a,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:l},c=m({segment:o,chunkSize:void 0,start:0,end:0},i),e.next=8,Gn(r,s,{data:d,inventoryInfos:c},u,n);case 8:return f=e.sent,e.abrupt("return",{content:i,segment:o,buffered:f});case 10:case"end":return e.stop()}}),e)}))),Hn.apply(this,arguments)}function qn(){return qn=d(p().mark((function e(t,n){var r,i,a,o,s,u,l,d,c,f,v,h,g,y,_,S,E,T,k,w,A,I,R,x;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.playbackObserver,i=t.bufferGoal,a=t.content,o=t.initSegmentUniqueId,s=t.parsedSegment,u=t.segment,l=t.segmentSink,null!==s.chunkData){e.next=3;break}return e.abrupt("return",null);case 3:if(null===n.cancellationError){e.next=5;break}throw n.cancellationError;case 5:return f=s.chunkData,v=s.chunkInfos,h=s.chunkOffset,g=s.chunkSize,y=s.appendWindow,_=a.representation.getMimeTypeString(),S=b.getCurrent(),E=S.APPEND_WINDOW_SECURITIES,T=[void 0!==y[0]?Math.max(0,y[0]-E.START):void 0,void 0!==y[1]?y[1]+E.END:void 0],k={initSegmentUniqueId:o,chunk:f,timestampOffset:h,appendWindow:T,codec:_},w=null!==(d=null==v?void 0:v.time)&&void 0!==d?d:u.time,A=null!==(c=null==v?void 0:v.duration)&&void 0!==c?c:u.duration,I=w+A,void 0!==T[0]&&(w=Math.max(w,T[0])),void 0!==T[1]&&(I=Math.min(I,T[1])),R=m({segment:u,chunkSize:g,start:w,end:I},a),e.next=18,Gn(r,l,{data:k,inventoryInfos:R},i,n);case 18:return x=e.sent,e.abrupt("return",{content:a,segment:u,buffered:x});case 20:case"end":return e.stop()}}),e)}))),qn.apply(this,arguments)}function Yn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Qn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Qn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Qn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var $n=function(e,t,n){var r=e.content,i=e.options,a=e.playbackObserver,o=e.segmentSink,s=e.segmentFetcher,u=e.terminate,l=r.period,d=r.adaptation,c=r.representation,f=i.bufferGoal,v=i.maxBufferSize,p=i.drmSystemId,h=i.fastSwitchThreshold,g=d.type,y=new Z;y.linkToSignal(n);var _=new Z;_.linkToSignal(y.signal);var S={segment:c.index.getInitSegment(),uniqueId:null,isLoaded:!1};y.signal.register((function(){null!==S.uniqueId&&o.freeInitSegment(S.uniqueId)}));var E=new G({initSegment:null,segmentQueue:[]},_.signal),k=null!==S.segment;k||(S.isLoaded=!0);var w=!1;if(void 0!==p){var A=c.getEncryptionData(p);if(A.length>0&&A.every((function(e){return void 0!==e.keyIds}))&&(w=!0,t.encryptionDataEncountered(A.map((function(e){return m({content:r},e)}))),y.isUsed()))return}var I=new Nn(r,E,s,k);return I.addEventListener("error",(function(e){_.signal.isCancelled()||(y.cancel(),t.error(e))})),I.addEventListener("parsedInitSegment",x),I.addEventListener("parsedMediaSegment",x),I.addEventListener("emptyQueue",R),I.addEventListener("requestRetry",(function(e){if(t.warning(e.error),!_.signal.isCancelled()){var n=e.segment,r=c.index;!1===r.isSegmentStillAvailable(n)?R():r.canBeOutOfSyncError(e.error,n)&&t.manifestMightBeOufOfSync()}})),I.addEventListener("fullyLoadedSegment",(function(e){o.signalSegmentComplete(m({segment:e},r)).catch(C)})),I.start(),_.signal.register((function(){I.removeEventListener(),I.stop()})),a.listen(R,{includeLastObservation:!1,clearSignal:_.signal}),r.manifest.addEventListener("manifestUpdate",R,_.signal),f.onUpdate(R,{emitCurrentValue:!1,clearSignal:_.signal}),v.onUpdate(R,{emitCurrentValue:!1,clearSignal:_.signal}),u.onUpdate(R,{emitCurrentValue:!1,clearSignal:_.signal}),void R();function R(){if(!_.isUsed()){var e=a.getReference().getValue(),n=e.position.getWanted(),i=Vn(r,n,a,h.getValue(),f.getValue(),v.getValue(),o),s=i.neededSegments,d=null;if(c.index.isInitialized()){if(s.length>0&&!S.isLoaded&&null!==S.segment){var p=s[0].priority;d={segment:S.segment,priority:p}}}else if(null===S.segment)T.warn("Stream: Uninitialized index without an initialization segment");else if(S.isLoaded)T.warn("Stream: Uninitialized index with an already loaded initialization segment");else{var m=e.position.getWanted();d={segment:S.segment,priority:zn(l.start,m)}}var y=u.getValue();if(null===y)E.setValue({initSegment:d,segmentQueue:s});else{if(y.urgent)return T.debug("Stream: Urgent switch, terminate now.",g),E.setValue({initSegment:null,segmentQueue:[]}),E.finish(),_.cancel(),void t.terminating();var k=s[0],w=I.getRequestedInitSegment(),A=I.getRequestedMediaSegment(),R=null===A||void 0===k||A.id!==k.segment.id?[]:[k],x=null===w?null:d;if(E.setValue({initSegment:x,segmentQueue:R}),0===R.length&&null===x)return T.debug("Stream: No request left, terminate",g),E.finish(),_.cancel(),void t.terminating()}if(t.streamStatusUpdate({period:l,position:e.position.getWanted(),bufferType:g,imminentDiscontinuity:i.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:i.hasFinishedLoading,neededSegments:i.neededSegments}),!_.signal.isCancelled()){var M=b.getCurrent().UPTO_CURRENT_POSITION_CLEANUP;if(i.isBufferFull){var P=Math.max(0,n-M);P>0&&o.removeBuffer(0,P).catch(C)}i.shouldRefreshManifest&&t.needsManifestRefresh()}}}function x(e){if(!y.isUsed()){for(var n,i=Yn(e.protectionData);!(n=i()).done;){var s=n.value;c.addProtectionData(s.initDataType,s.keyId,s.initData)}if(!w){var u=c.getAllEncryptionData();if(u.length>0&&(t.encryptionDataEncountered(u.map((function(e){return m({content:r},e)}))),w=!0,y.isUsed()))return}if("init"!==e.segmentType){var l=e.inbandEvents,d=e.predictedSegments,v=e.needsManifestRefresh;if(!(void 0!==d&&c.index.addPredictedSegments(d,e.segment),!0===v&&(t.needsManifestRefresh(),y.isUsed())||void 0!==l&&l.length>0&&(t.inbandEvent(l),y.isUsed()))){var p=S.uniqueId;(function(e,t){return qn.apply(this,arguments)})({playbackObserver:a,bufferGoal:f,content:r,initSegmentUniqueId:p,parsedSegment:e,segment:e.segment,segmentSink:o},y.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(C)}}else{if(c.index.isInitialized()||void 0===e.segmentList||c.index.initialize(e.segmentList),S.isLoaded=!0,null!==e.initializationData){var h=c.uniqueId;S.uniqueId=h,o.declareInitSegment(h,e.initializationData),function(e,t){return Hn.apply(this,arguments)}({playbackObserver:a,bufferGoal:f,content:r,initSegmentUniqueId:h,segment:e.segment,segmentData:e.initializationData,segmentSink:o},y.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(C)}R()}}}function C(e){y.isUsed()&&e instanceof ee||(y.cancel(),t.error(e))}};function Xn(e,t){for(var n=0;n<e.length;n++)if(e[n].infos.period.start>=t.start)return n>0?e[n-1]:null;return e.length>0?e[e.length-1]:null}function Zn(e,t){for(var n=0;n<e.length;n++)if(e[n].infos.period.start>t.start)return e[n];return null}function Jn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return er(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return er(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function tr(e,t,n,r,i){var a,o,s,u;if("lazy"===n.switchingMode)return{type:"continue",value:void 0};for(var l,d=r.getLastKnownInventory(),c=[],f=Jn(d);!(l=f()).done;){var v=l.value;v.infos.period.id!==e.id||v.infos.adaptation.id===t.id&&Ue(n.representationIds,v.infos.representation.id)||L(c,{start:null!==(a=v.bufferedStart)&&void 0!==a?a:v.start,end:null!==(o=v.bufferedEnd)&&void 0!==o?o:v.end})}for(var p,h=Jn(r.getPendingOperations());!(p=h()).done;){var m=p.value;if(m.type===bn.Push){var g=m.value.inventoryInfos;if(g.period.id===e.id&&(g.adaptation.id!==t.id||!Ue(n.representationIds,g.representation.id))){var y=g.segment.time;L(c,{start:y,end:y+g.segment.duration})}}}if(0===c.length)return{type:"continue",value:void 0};if("reload"===n.switchingMode){var _=i.getReadyState();if(void 0===_||_>1)return{type:"needs-reload",value:void 0}}var S="direct"===n.switchingMode,E=[],T=Xn(d,e);if(null!==T&&(void 0===T.bufferedEnd||e.start-T.bufferedEnd<1)&&E.push({start:0,end:e.start+1}),!S){var k=b.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,w=t.type,A=null!==(s=k[w].before)&&void 0!==s?s:0,I=null!==(u=k[w].after)&&void 0!==u?u:0,R=i.getCurrentTime();if(void 0===R)R=i.getReference().getValue().position.getPolled();E.push({start:R-A,end:R+I})}if(void 0!==e.end){var x=Zn(d,e);null!==x&&(void 0===x.bufferedStart||x.bufferedStart-e.end<1)&&E.push({start:e.end-1,end:Number.MAX_VALUE})}var C=F(c,E);return 0===C.length?{type:"continue",value:void 0}:S?{type:"flush-buffer",value:C}:{type:"clean-buffer",value:C}}function nr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return rr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function rr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ir=function(e,t,n){var r=e.playbackObserver,i=e.content,a=e.options,o=e.representationEstimator,s=e.segmentSink,l=e.segmentFetcherCreator,c=e.wantedBufferAhead,f=e.maxVideoBufferSize,v=i.manifest,h=i.period,g=i.adaptation,y=new Z;y.linkToSignal(n);var _,E,k=new Map,w=new G(null,y.signal),A=i.representations.getValue().representationIds,I=i.adaptation.representations.filter((function(e){return Ue(A,e.id)&&!1!==e.decipherable&&!1!==e.isSupported})),R=new G(I,y.signal),x=o({manifest:v,period:h,adaptation:g},w,R,r,y.signal),C=x.estimates,M=x.callbacks,P=l.createSegmentFetcher(g.type,{onRequestBegin:M.requestBegin,onRequestEnd:M.requestEnd,onProgress:M.requestProgress,onMetrics:M.metrics}),D=new G(0);return C.onUpdate((function(e){var n=e.bitrate,r=e.knownStableBitrate;a.enableFastSwitching&&D.setValueIfChanged(r),void 0!==n&&n!==_&&(_=n,T.debug("Stream: new "+g.type+" bitrate estimate",n),t.bitrateEstimateChange({type:g.type,bitrate:n}))}),{emitCurrentValue:!0,clearSignal:y.signal}),void i.representations.onUpdate((function(e){void 0!==E&&E.cancel();var n=i.representations.getValue().representationIds,r=i.adaptation.representations.filter((function(e){return Ue(n,e.id)}));R.setValueIfChanged(r),(E=new Z).linkToSignal(y.signal),function(e,t){return O.apply(this,arguments)}(e,E.signal).catch((function(e){!0===(null==E?void 0:E.isUsed())&&Z.isCancellationError(e)||(y.cancel(),t.error(e))}))}),{clearSignal:y.signal,emitCurrentValue:!0});function O(){return(O=d(p().mark((function e(n,i){var a,o,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=tr(h,g,n,s,r),e.t0=a.type,e.next="continue"===e.t0?4:"needs-reload"===e.t0?5:"flush-buffer"===e.t0||"clean-buffer"===e.t0?6:20;break;case 4:return e.abrupt("break",21);case 5:return e.abrupt("return",u((function(){r.listen((function(){if(!i.isCancelled()){var e=b.getCurrent().DELTA_POSITION_AFTER_RELOAD.bitrateSwitch;return t.waitingMediaSourceReload({bufferType:g.type,period:h,timeOffset:e,stayInPeriod:!0})}}),{includeLastObservation:!0,clearSignal:i})})));case 6:o=nr(a.value);case 7:if((l=o()).done){e.next=15;break}return d=l.value,e.next=11,s.removeBuffer(d.start,d.end);case 11:if(!i.isCancelled()){e.next=13;break}return e.abrupt("return");case 13:e.next=7;break;case 15:if("flush-buffer"!==a.type){e.next=19;break}if(t.needsBufferFlush(),!i.isCancelled()){e.next=19;break}return e.abrupt("return");case 19:return e.abrupt("break",21);case 20:X();case 21:N(i);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function N(e){var n=new Z;n.linkToSignal(e);var r=C.getValue().representation;if(null!==r){var i=new G(null,n.signal);C.onUpdate((function(e){if(null!==e.representation&&e.representation.id!==r.id)return e.urgent?(T.info("Stream: urgent Representation switch",g.type),i.setValue({urgent:!0})):(T.info("Stream: slow Representation switch",g.type),i.setValue({urgent:!1}))}),{clearSignal:n.signal,emitCurrentValue:!0});var a={type:g.type,adaptation:g,period:h,representation:r};if(w.setValue(r),!y.isUsed()&&(t.representationChange(a),!y.isUsed())){var o={streamStatusUpdate:t.streamStatusUpdate,encryptionDataEncountered:t.encryptionDataEncountered,manifestMightBeOufOfSync:t.manifestMightBeOufOfSync,needsManifestRefresh:t.needsManifestRefresh,inbandEvent:t.inbandEvent,warning:t.warning,error:function(e){y.cancel(),t.error(e)},addedSegment:function(e){M.addedSegment(e)},terminating:function(){if(!n.isUsed())return n.cancel(),N(e)}};L(r,i,o,e)}}}function L(e,n,i,o){var u=new Z;u.linkToSignal(o);var l=W(c,(function(t){return t*function(e){var t=k.get(e.id),n=void 0!==t?t:1;void 0===t&&k.set(e.id,n);return n}(e)}),u.signal),d="video"===g.type?f:new G(1/0);T.info("Stream: changing representation",g.type,e.id,e.bitrate);var p=m({},i,{error:function(t){var r,a=Ne(t,{defaultCode:"NONE",defaultReason:"Unknown `RepresentationStream` error"});if("BUFFER_FULL_ERROR"!==a.code)i.error(t);else{var s=c.getValue(),u=.7*(null!==(r=k.get(e.id))&&void 0!==r?r:1);if(u<=.05||s*u<=2)throw a;k.set(e.id,u),Mt(4e3,y.signal).then((function(){return L(e,n,i,o)})).catch(S)}},terminating:function(){u.cancel(),i.terminating()}});$n({playbackObserver:r,content:{representation:e,adaptation:g,period:h,manifest:v},segmentSink:s,segmentFetcher:P,terminate:n,options:{bufferGoal:l,maxBufferSize:d,drmSystemId:a.drmSystemId,fastSwitchThreshold:D}},p,o),v.addEventListener("manifestUpdate",(function(n){for(var r,i=nr(n.updatedPeriods);!(r=i()).done;){var a=r.value;if(a.period.id===h.id)for(var s,u=nr(a.result.updatedAdaptations);!(s=u()).done;){var l=s.value;if(l.adaptation===g.id)for(var d,c=nr(l.removedRepresentations);!(d=c()).done;){if(d.value===e.id){if(o.isCancelled())return;return t.waitingMediaSourceReload({bufferType:g.type,period:h,timeOffset:0,stayInPeriod:!0})}}}else if(a.period.start>h.start)break}}),o)}};function ar(e,t,n){if("function"==typeof String.prototype.startsWith)return e.startsWith(t,n);var r="number"==typeof n?Math.max(n,0):0;return e.substring(r,r+t.length)===t}var or=function(e,t){var n=e.split(";"),r=n[0],i=n.slice(1),a=t.split(";"),o=a[0],s=a.slice(1);if(r!==o)return!1;var u=ae(i,(function(e){return ar(e,"codecs=")})),l=ae(s,(function(e){return ar(e,"codecs=")}));if(void 0===u||void 0===l)return!1;var d=u.substring(7),c=l.substring(7);return d.split(".")[0]===c.split(".")[0]};function sr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ur(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ur(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ur(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function lr(e,t,n,r,i,a){var o,s,u,l;if(void 0!==e.codec&&"reload"===a.onCodecSwitch&&!function(e,t){return e.representations.some((function(e){return!0===e.isSupported&&!1!==e.decipherable&&or(e.getMimeTypeString(),t)}))}(n,e.codec))return{type:"needs-reload",value:void 0};for(var d,c=e.getLastKnownInventory(),f=[],v=sr(c);!(d=v()).done;){var p=d.value;p.infos.period.id===t.id&&p.infos.adaptation.id!==n.id&&L(f,{start:null!==(o=p.bufferedStart)&&void 0!==o?o:p.start,end:null!==(s=p.bufferedEnd)&&void 0!==s?s:p.end})}for(var h,m=sr(e.getPendingOperations());!(h=m()).done;){var g=h.value;if(g.type===bn.Push){var y=g.value.inventoryInfos;if(y.period.id===t.id&&y.adaptation.id!==n.id){var _=y.segment.time;L(f,{start:_,end:_+y.segment.duration})}}}if(0===f.length)return{type:"continue",value:void 0};if("reload"===r){var S=i.getReadyState();if(void 0===S||S>1)return{type:"needs-reload",value:void 0}}var E="direct"===r,T=[],k=Xn(c,t);if(null!==k&&(void 0===k.bufferedEnd||t.start-k.bufferedEnd<1)&&T.push({start:0,end:t.start+1}),!E){var w=n.type,A=b.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,I=null!==(u=A[w].before)&&void 0!==u?u:0,R=null!==(l=A[w].after)&&void 0!==l?l:0,x=i.getCurrentTime();if(void 0===x)x=i.getReference().getValue().position.getPolled();T.push({start:x-I,end:x+R})}if(void 0!==t.end){var C=Zn(c,t);null!==C&&(void 0===C.bufferedStart||C.bufferedStart-t.end<1)&&T.push({start:t.end-1,end:Number.MAX_VALUE})}var M=F(f,T);return 0===M.length?{type:"continue",value:void 0}:E&&"text"!==n.type?{type:"flush-buffer",value:M}:{type:"clean-buffer",value:M}}function dr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function fr(e,t,n){var r=e.getStatus(t);if("initialized"===r.type)return T.info("Stream: Reusing a previous SegmentSink for the type",t),r.value;var i=function(e){var t=e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable}));if(0===t.length){throw new Me("NO_PLAYABLE_REPRESENTATION","No Representation in the chosen "+e.type+" Adaptation can be played",{tracks:[Je(e)]})}return t[0].getMimeTypeString()}(n);return e.createSegmentSink(t,i)}function vr(e,t,n,r,i,a){var o=r.period,s=!1;function u(){var r=e.getReference().getValue(),a=t.getValue(),u=r.position.getWanted();void 0!==o.end&&u+a>=o.end&&(T.debug('Stream: full "empty" AdaptationStream',n),s=!0),i.streamStatusUpdate({period:o,bufferType:n,imminentDiscontinuity:null,position:u,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}t.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),e.listen(u,{includeLastObservation:!1,clearSignal:a}),u()}var pr=function(e,t,n){var r=e.bufferType,i=e.content,a=e.garbageCollectors,o=e.playbackObserver,s=e.representationEstimator,l=e.segmentFetcherCreator,c=e.segmentSinksStore,f=e.options,v=e.wantedBufferAhead,h=e.maxVideoBufferSize,g=i.manifest,y=i.period,_=new G(void 0,n);if(t.periodStreamReady({type:r,manifest:g,period:y,adaptationRef:_}),!n.isCancelled()){var S,E=!0;_.onUpdate((function(e){d(p().mark((function i(){var s,u,l,d,h,m,_,A,I,R,x,C,M,P,D,O,N,L;return p().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==e){i.next=2;break}return i.abrupt("return");case 2:if((u=new Z).linkToSignal(n),null==S||S.cancel(),S=u,null!==e){i.next=34;break}if(T.info("Stream: Set no "+r+" Adaptation. P:",y.start),"initialized"!==(l=c.getStatus(r)).type){i.next=26;break}if(T.info("Stream: Clearing previous "+r+" SegmentSink"),!Mn.isNative(r)){i.next=15;break}return i.abrupt("return",w(0,!0,u.signal));case 15:if(d=null!==(s=y.end)&&void 0!==s?s:1/0,!(y.start>d)){i.next=20;break}T.warn("Stream: Can't free buffer: period's start is after its end"),i.next=24;break;case 20:return i.next=22,l.value.removeBuffer(y.start,d);case 22:if(!u.isUsed()){i.next=24;break}return i.abrupt("return");case 24:i.next=30;break;case 26:if("uninitialized"!==l.type){i.next=30;break}if(c.disableSegmentSink(r),!u.isUsed()){i.next=30;break}return i.abrupt("return");case 30:if(t.adaptationChange({type:r,adaptation:null,period:y}),!u.isUsed()){i.next=33;break}return i.abrupt("return");case 33:return i.abrupt("return",vr(o,v,r,{period:y},t,u.signal));case 34:if(h=y.adaptations[r],void 0!==(m=ae(null!=h?h:[],(function(t){return t.id===e.adaptationId})))){i.next=40;break}return S.cancel(),T.warn("Stream: Unfound chosen Adaptation choice",e.adaptationId),i.abrupt("return");case 40:if(_=b.getCurrent(),A=_.DELTA_POSITION_AFTER_RELOAD,I=!1,!E){i.next=46;break}R=0,i.next=60;break;case 46:if(void 0===e.relativeResumingPosition){i.next=50;break}R=e.relativeResumingPosition,i.next=60;break;case 50:I=!0,i.t0=r,i.next="audio"===i.t0?54:"video"===i.t0?56:58;break;case 54:return R=A.trackSwitch.audio,i.abrupt("break",60);case 56:return R=A.trackSwitch.video,i.abrupt("break",60);case 58:return R=A.trackSwitch.other,i.abrupt("break",60);case 60:if(E=!1,!Mn.isNative(r)||"disabled"!==c.getStatus(r).type){i.next=63;break}return i.abrupt("return",w(R,!0,u.signal));case 63:if(g.addEventListener("manifestUpdate",(function(e){for(var t,n=dr(e.updatedPeriods);!(t=n()).done;){var r=t.value;if(r.period.id===y.id)for(var i,a=dr(r.result.removedAdaptations);!(i=a()).done;){if(i.value.id===m.id)return w(R,!0,u.signal)}else if(r.period.start>y.start)break}}),S.signal),x=e.representations,T.info("Stream: Updating "+r+" adaptation","A: "+m.id,"P: "+y.start),t.adaptationChange({type:r,adaptation:m,period:y}),!u.isUsed()){i.next=69;break}return i.abrupt("return");case 69:if(C=fr(c,r,m),"needs-reload"!==(M=lr(C,y,m,e.switchingMode,o,f)).type){i.next=73;break}return i.abrupt("return",w(R,!0,u.signal));case 73:return i.next=75,c.waitForUsableBuffers(u.signal);case 75:if(!u.isUsed()){i.next=77;break}return i.abrupt("return");case 77:if("flush-buffer"!==M.type&&"clean-buffer"!==M.type){i.next=91;break}P=dr(M.value);case 79:if((D=P()).done){i.next=87;break}return O=D.value,N=O.start,L=O.end,i.next=83,C.removeBuffer(N,L);case 83:if(!u.isUsed()){i.next=85;break}return i.abrupt("return");case 85:i.next=79;break;case 87:if("flush-buffer"!==M.type){i.next=91;break}if(t.needsBufferFlush({relativeResumingPosition:R,relativePosHasBeenDefaulted:I}),!u.isUsed()){i.next=91;break}return i.abrupt("return");case 91:a.get(C)(u.signal),k(m,x,C,u.signal);case 93:case"end":return i.stop()}}),i)})))().catch((function(e){e instanceof ee||(null==S||S.cancel(),t.error(e))}))}),{clearSignal:n,emitCurrentValue:!0})}function k(e,n,i,a){var u,d,p=(u=o,d=e.type,u.deriveReadOnlyObserver((function(e,t){var n=new G(r(),t);return e.onUpdate(i,{clearSignal:t,emitCurrentValue:!1}),n;function r(){var t=e.getValue(),n=t.buffered[d],r=null!==n?N(n,t.position.getWanted()):0;return m({},t,{bufferGap:r,buffered:n})}function i(){n.setValue(r())}})));ir({content:{manifest:g,period:y,adaptation:e,representations:n},options:f,playbackObserver:p,representationEstimator:s,segmentSink:i,segmentFetcherCreator:l,wantedBufferAhead:v,maxVideoBufferSize:h},Object.assign(Object.assign({},t),{error:function(e){if(!Mn.isNative(r)){T.error("Stream: "+r+" Stream crashed. Aborting it.",e instanceof Error?e:""),c.disposeSegmentSink(r);var n=Ne(e,{defaultCode:"NONE",defaultReason:"Unknown `AdaptationStream` error"});if(t.warning(n),a.isCancelled())return;return vr(o,v,r,{period:y},t,a)}T.error("Stream: "+r+" Stream crashed. Stopping playback.",e instanceof Error?e:""),t.error(e)}}),a)}function w(e,n,i){u((function(){o.listen((function(){i.isCancelled()||t.waitingMediaSourceReload({bufferType:r,period:y,timeOffset:e,stayInPeriod:n})}),{includeLastObservation:!0,clearSignal:i})}))}};function hr(e,t){if(0===t.length)return[];for(var n,r=[],i=e.getLastKnownInventory(),a=function(){var e=i[o];if(t.some((function(t){return e.infos.period.id===t.period.id&&e.infos.adaptation.id===t.adaptation.id&&e.infos.representation.id===t.representation.id}))){var n=e.bufferedStart,a=e.bufferedEnd;if(void 0===n||void 0===a)return T.warn("SO: No buffered start or end found from a segment."),{v:[{start:0,end:Number.MAX_VALUE}]};var s=r[r.length-1];void 0!==s&&s.end===n?s.end=a:r.push({start:n,end:a})}},o=0;o<i.length;o++)if(n=a())return n.v;return r}function mr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return gr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function gr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){if(0===t.length)return!1;var n=e.position.getPolled();return e.speed>=0?t[t.length-1].end>=n-5:t[0].start<=n+5}var _r=function(e,n,r,i,a,o,s,l){for(var c,f=e.manifest,v=e.initialPeriod,h=o.maxBufferAhead,m=o.maxBufferBehind,g=o.wantedBufferAhead,y=o.maxVideoBufferSize,_=b.getCurrent(),S=_.MINIMUM_MAX_BUFFER_AHEAD,E=_.MAXIMUM_MAX_BUFFER_AHEAD,k=_.MAXIMUM_MAX_BUFFER_BEHIND,w=new Pn((function(e){var t,r,i=e.bufferType,a=null!==(t=k[i])&&void 0!==t?t:1/0,o=null!==(r=E[i])&&void 0!==r?r:1/0;return function(t){Dn({segmentSink:e,playbackObserver:n,maxBufferBehind:W(m,(function(e){return Math.min(e,a)}),t),maxBufferAhead:W(h,(function(e){var t,n=Math.max(e,null!==(t=S[i])&&void 0!==t?t:0);return Math.min(n,o)}),t)},t)}})),A=mr(i.getBufferTypes());!(c=A()).done;){I(c.value,v)}function I(e,r){var a=new Jt((function(e,t){return e.start-t.start})),o=!1,c=new Z;return c.linkToSignal(l),n.listen((function(n){var r,i=n.position.getWanted();if(o&&function(e){var n=a.head(),r=a.last();if(void 0===n||void 0===r)return!0;return n.start>e||(t(r.end)?1/0:r.end)<e}(i)){for(T.info("Stream: Destroying all PeriodStreams due to out of bounds situation",e,i),o=!1;a.length()>0;){var u=a.get(a.length()-1);a.removeElement(u),s.periodStreamCleared({type:e,manifest:f,period:u})}c.cancel(),(c=new Z).linkToSignal(l);var d=null!==(r=f.getPeriodForTime(i))&&void 0!==r?r:f.getNextPeriod(i);if(void 0===d)return T.warn("Stream: The wanted position is not found in the Manifest."),void(o=!0);v(d)}}),{clearSignal:l,includeLastObservation:!0}),f.addEventListener("decipherabilityUpdate",(function(e){l.isCancelled()||function(e){return h.apply(this,arguments)}(e).catch((function(e){l.isCancelled()||(c.cancel(),s.error(e))}))}),l),v(r);function v(t){var n=Object.assign(Object.assign({},s),{waitingMediaSourceReload:function(e){var t=a.head();void 0===t||t.id!==e.period.id?s.lockedStream({bufferType:e.bufferType,period:e.period}):s.needsMediaSourceReload({timeOffset:e.timeOffset,minimumPosition:e.stayInPeriod?e.period.start:void 0,maximumPosition:e.stayInPeriod?e.period.end:void 0})},periodStreamReady:function(e){o=!0,a.add(e.period),s.periodStreamReady(e)},periodStreamCleared:function(e){a.removeElement(e.period),s.periodStreamCleared(e)},error:function(e){c.cancel(),s.error(e)}});R(e,t,n,c.signal)}function h(){return h=d(p().mark((function t(r){var d,h,m,g,y,_,b,S,E,k,w,A,I;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(d=i.getStatus(e),0!==(h=r.filter((function(t){return t.adaptation.type===e}))).length&&"initialized"===d.type&&!h.every((function(e){return!0===e.representation.decipherable}))){t.next=4;break}return t.abrupt("return");case 4:for(m=d.value,g=h.filter((function(e){return void 0===e.representation.decipherable})),y=h.filter((function(e){return!1===e.representation.decipherable})),_=hr(m,y),b=hr(m,g),o=!1,T.info("Stream: Destroying all PeriodStreams for decipherability matters",e);a.length()>0;)S=a.get(a.length()-1),a.removeElement(S),s.periodStreamCleared({type:e,manifest:f,period:S});c.cancel(),(c=new Z).linkToSignal(l),E=0,k=[].concat(_,b);case 16:if(!(E<k.length)){t.next=28;break}if(w=k[E],A=w.start,I=w.end,!l.isCancelled()){t.next=20;break}return t.abrupt("return");case 20:if(!(A<I)){t.next=25;break}if(!l.isCancelled()){t.next=23;break}return t.abrupt("return");case 23:return t.next=25,m.removeBuffer(A,I);case 25:E++,t.next=16;break;case 28:u((function(){if(!l.isCancelled()){var e=n.getReference().getValue();if(yr(e,_)){if(s.needsDecipherabilityFlush(),l.isCancelled())return}else if(yr(e,b)&&(s.needsBufferFlush(),l.isCancelled()))return;var t=e.position.getWanted(),r=f.getPeriodForTime(t);void 0!==r?v(r):s.error(new Me("MEDIA_TIME_NOT_FOUND","The wanted position is not found in the Manifest."))}}));case 29:case"end":return t.stop()}}),t)}))),h.apply(this,arguments)}}function R(e,t,l,d){T.info("Stream: Creating new Stream for",e,t.start);var c=null,v=new Z;v.linkToSignal(d),n.listen((function(n,r){var i=n.position;if(void 0!==t.end&&i.getWanted()>=t.end){var a=f.getPeriodAfter(t);if(t.containsTime(i.getWanted(),a))return;T.info("Stream: Destroying PeriodStream as the current playhead moved above it",e,t.start,i.getWanted(),t.end),r(),l.periodStreamCleared({type:e,manifest:f,period:t}),v.cancel()}}),{clearSignal:d,includeLastObservation:!0});var p,h={bufferType:e,content:{manifest:f,period:t},garbageCollectors:w,maxVideoBufferSize:y,segmentFetcherCreator:a,segmentSinksStore:i,options:o,playbackObserver:n,representationEstimator:r,wantedBufferAhead:g},m=Object.assign(Object.assign({},l),{streamStatusUpdate:function(n){if(n.hasFinishedLoading){var r=f.getPeriodAfter(t);null!==r&&function(t){if(null!==c){if(c.period.id===t.id)return;T.warn("Stream: Creating next `PeriodStream` while one was already created.",e,t.id,c.period.id),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel()}var n=new Z;n.linkToSignal(d),c={canceller:n,period:t},R(e,t,l,c.canceller.signal)}(r)}else null!==c&&(T.info("Stream: Destroying next PeriodStream due to current one being active",e,c.period.start),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel(),c=null);l.streamStatusUpdate(n)},error:function(e){null!==c&&(c.canceller.cancel(),c=null),v.cancel(),l.error(e)}});pr(h,m,v.signal),p=v.signal,f.addEventListener("manifestUpdate",(function(n){for(var r,i=mr(n.removedPeriods);!(r=i()).done;){var a=r.value;if(a.id===t.id){if(f.periods.length>0&&f.periods[0].start<=a.start)return u((function(){if(!p.isCancelled())return s.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})}))}else if(a.start>t.start)break}if(n.addedPeriods.length>0&&null!==c){var o=f.getPeriodAfter(t);null!==o&&c.period.id===o.id||(T.warn("Stream: Destroying next PeriodStream due to new one being added",e,c.period.start),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel(),c=null)}}),p)}},br=_r,Sr={createSync:function(e){return{syncValue:e,getValueAsAsync:function(){return Promise.resolve(e)}}},createAsync:function(e){var t=null;return e.then((function(e){t=e}),S),{syncValue:t,getValueAsAsync:function(){return e}}}},Er=new WeakMap,Tr={setState:function(e,t){Er.set(e,t)},getState:function(e){var t=Er.get(e);return void 0===t?null:t},clearState:function(e){Er.set(e,null)}};function kr(e){var t=Tr.getState(e);return null===t?null:[t.mediaKeySystemAccess.keySystem,t.mediaKeySystemAccess.getConfiguration()]}var wr=function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(i);function Ar(e,t){var n={audio:null,video:null,text:null};if(null!==t&&(n.text=t.getBufferedRanges()),null===e)return n;var r=ae(e.sourceBuffers,(function(e){return"audio"===e.type})),i=ae(e.sourceBuffers,(function(e){return"video"===e.type})),a=null==r?void 0:r.getBuffered();void 0!==a&&(n.audio=a);var o=null==i?void 0:i.getBuffered();return void 0!==o&&(n.video=o),n}function Ir(e,t,n){var r=t.autoPlay,i=t.initialPlayPerformed,a=t.manifest,o=t.mediaSource,s=t.speed,u=t.textDisplayer;return e.deriveReadOnlyObserver((function(e,t){var l=new Z;l.linkToSignal(t),l.linkToSignal(n);var d=new G(c(),l.signal);return s.onUpdate(f,{clearSignal:l.signal,emitCurrentValue:!1}),e.onUpdate(f,{clearSignal:l.signal,emitCurrentValue:!1}),d;function c(){var t=e.getValue(),n=s.getValue();return function(e,t){if(!t.isDynamic||t.isLastPeriodKnown){var n=t.periods[t.periods.length-1];if(void 0!==n&&void 0!==n.end){var r=e.position.getWanted();if(r>=n.start&&r>=n.end-1){var i=e.buffered;(0===i.length||i.end(i.length-1)<e.duration-1)&&e.position.forceWantedPosition(n.end-1)}}}}(t,a),{maximumPosition:We(a),bufferGap:t.bufferGap,position:t.position,buffered:Ar(o,u),duration:t.duration,rebuffering:t.rebuffering,freezing:t.freezing,paused:{last:t.paused,pending:Rr(i,r)},readyState:t.readyState,speed:n}}function f(){d.setValue(c())}}))}function Rr(e,t){return e.getValue()?void 0:!t}function xr(e){var n=e.textTracks;if(!t(n)){for(var r=0;r<n.length;r++)n[r].mode="disabled";if(e.hasChildNodes())for(var i=e.childNodes,a=i.length-1;a>=0;a--)if("track"===i[a].nodeName)try{e.removeChild(i[a])}catch(e){T.warn("Compat: Could not remove text track child from element.")}}e.src="",e.removeAttribute("src")}var Cr=s,Mr=void 0===Cr?void 0:t(Cr.MediaSource)?t(Cr.MozMediaSource)?t(Cr.WebKitMediaSource)?Cr.MSMediaSource:Cr.WebKitMediaSource:Cr.MozMediaSource:Cr.MediaSource;var Pr=["","webkit","moz","ms"];function Dr(e,t){return t.filter((function(t){return function(e,t){var n=document.createElement(e.tagName),r="on"+t;return r in n||(n.setAttribute(r,"return;"),"function"==typeof n[r])}(e,t)}))[0]}function Or(e,t){var n,r=function(e,t){return e.reduce((function(e,n){return e.concat((void 0===t?Pr:t).map((function(e){return e+n})))}),[])}(e,t);return function(e,t,i){if(!i.isCancelled()){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement){if(void 0===n&&(n=Dr(e,r)),!et(n))return void 0;e.addEventListener(n,t),i.register((function(){void 0!==n&&e.removeEventListener(n,t)}))}r.forEach((function(n){var r=!1;"function"==typeof e.addEventListener?e.addEventListener(n,t):(r=!0,e["on"+n]=t),i.register((function(){"function"==typeof e.removeEventListener&&e.removeEventListener(n,t),r&&delete e["on"+n]}))}))}}}function Nr(e,n){var r,i=function(e){var n,r=document;t(r.hidden)?t(r.mozHidden)?t(r.msHidden)?t(r.webkitHidden)||(n="webkit"):n="ms":n="moz":n="";var i=et(n)?n+"Hidden":"hidden",a=et(n)?n+"visibilitychange":"visibilitychange",o=document[i],s=new G(!o,e);return $r(document,a,(function(){var e=!document[i];s.setValueIfChanged(e)}),e),s}(n),a=new G(!0,n);return n.register((function(){clearTimeout(r),r=void 0})),i.onUpdate(o,{clearSignal:n}),e.onUpdate(o,{clearSignal:n}),o(),a;function o(){if(clearTimeout(r),r=void 0,e.getValue().isEnabled||i.getValue())a.setValueIfChanged(!0);else{var t=b.getCurrent().INACTIVITY_DELAY;r=setTimeout((function(){a.setValueIfChanged(!1)}),t)}}}function Lr(e){var n,r,i=t(s.devicePixelRatio)||0===s.devicePixelRatio?1:s.devicePixelRatio,a=new G({width:null===(n=s.screen)||void 0===n?void 0:n.width,height:null===(r=s.screen)||void 0===r?void 0:r.height,pixelRatio:i},e),o=setInterval((function(){var e=a.getValue();e.width===screen.width&&e.height===screen.height&&e.pixelRatio===i||a.setValue({width:screen.width,height:screen.height,pixelRatio:i})}),2e4);return e.register((function(){clearInterval(o)})),a}function Ur(e,n,r){var i=t(s.devicePixelRatio)||0===s.devicePixelRatio?1:s.devicePixelRatio,a=new G({width:e.clientWidth,height:e.clientHeight,pixelRatio:i},r),o=S;n.onUpdate(l,{clearSignal:r}),$r(s,"resize",l,r),$r(e,"enterpictureinpicture",l,r),$r(e,"leavepictureinpicture",l,r);var u=setInterval(l,2e4);return l(),r.register((function(){o(),clearInterval(u)})),a;function l(){o();var r=n.getValue(),s=r.pipWindow;if(r.isEnabled)if(t(s)){var u=a.getValue();void 0===u.width&&void 0===u.height&&u.pixelRatio===i||a.setValue({width:void 0,height:void 0,pixelRatio:i})}else{var l=function(){c()};s.addEventListener("resize",l),o=function(){s.removeEventListener("resize",l),o=S},c()}else{var d=a.getValue();d.width===e.clientWidth&&d.height===e.clientHeight&&d.pixelRatio===i||a.setValue({width:e.clientWidth,height:e.clientHeight,pixelRatio:i})}function c(){var e=a.getValue();e.width===(null==s?void 0:s.width)&&e.height===(null==s?void 0:s.height)&&e.pixelRatio===i||a.setValue({width:null==s?void 0:s.width,height:null==s?void 0:s.height,pixelRatio:i})}}}Or(["loadedmetadata"]),Or(["timeupdate"]),Or(["addtrack"]),Or(["removetrack"]);var Fr=Or(["sourceopen","webkitsourceopen"]),Br=Or(["sourceclose","webkitsourceclose"]),zr=Or(["sourceended","webkitsourceended"]),Vr=Or(["update"]),Kr=Or(["removesourcebuffer"]),Wr=Or(["keymessage","message"]),Gr=Or(["keyadded","ready"]),jr=Or(["keyerror","error"]),Hr=Or(["keystatuseschange"]),qr=Or(["seeking"]),Yr=Or(["seeked"]),Qr=Or(["ended"]);function $r(e,t,n,r){e.addEventListener(t,n),r.register((function(){e.removeEventListener(t,n)}))}function Xr(){for(var e,t=arguments.length,n=-1,r=0;++n<t;)r+="number"==typeof(e=n<0||arguments.length<=n?void 0:arguments[n])?e:e.length;var i=new Uint8Array(r),a=0;for(n=-1;++n<t;)"number"==typeof(e=n<0||arguments.length<=n?void 0:arguments[n])?a+=e:e.length>0&&(i.set(e,a),a+=e.length);return i}function Zr(e,t){return(e[t+0]<<8)+(e[t+1]<<0)}function Jr(e,t){return 65536*e[t+0]+256*e[t+1]+e[t+2]}function ei(e,t){return 16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3]}function ti(e,t){return 4294967296*(16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3])+16777216*e[t+4]+65536*e[t+5]+256*e[t+6]+e[t+7]}function ni(e){return new Uint8Array([e>>>8&255,255&e])}function ri(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}function ii(e){var t=e%4294967296,n=(e-t)/4294967296;return new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n,t>>>24&255,t>>>16&255,t>>>8&255,255&t])}function ai(e){return new Uint8Array([255&e,e>>>8&255,e>>>16&255,e>>>24&255])}function oi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return si(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return si(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function si(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ui(e,t){if(T.debug("Init: Trying to call endOfStream"),"open"===e.readyState){var n=e.sourceBuffers,r=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];r.updating&&t.push(r)}return t}(n);if(0===r.length)return T.info("Init: Triggering end of stream"),void e.endOfStream();T.debug("Init: Waiting SourceBuffers to be updated before calling endOfStream.");var i=new Z;i.linkToSignal(t);for(var a,o=oi(r);!(a=o()).done;){var s=a.value;Vr(s,(function(){i.cancel(),ui(e,t)}),i.signal)}Kr(n,(function(){i.cancel(),ui(e,t)}),i.signal)}else T.debug("Init: MediaSource not open, cancel endOfStream")}var li,di,ci,fi=!1,vi=!1,pi=!1,hi=!1,mi=!1,gi=!1,yi=!1,_i=!1,bi=!1,Si=!1,Ei=!1;o||(void 0!==s.MSInputMethodContext&&void 0!==document.documentMode?(vi=!0,pi=!0):"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&/(Trident|Edge)\//.test(navigator.userAgent)?pi=!0:-1!==navigator.userAgent.toLowerCase().indexOf("edg/")?fi=!0:-1!==navigator.userAgent.toLowerCase().indexOf("firefox")?hi=!0:"string"==typeof navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)?gi=!0:(Object.prototype.toString.call(s.HTMLElement).indexOf("Constructor")>=0||"[object SafariRemoteNotification]"===(null===(di=null===(li=s.safari)||void 0===li?void 0:li.pushNotification)||void 0===di?void 0:di.toString())||/Safari\/(\d+)/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&-1!==(null===(ci=navigator.vendor)||void 0===ci?void 0:ci.indexOf("Apple"))&&!/Chrome\/(\d+)/.test(navigator.userAgent)&&!/Chromium\/(\d+)/.test(navigator.userAgent))&&(mi=!0),/SamsungBrowser/.test(navigator.userAgent)&&(yi=!0),-1!==navigator.userAgent.indexOf("PlayStation 5")?Ei=!0:/Tizen/.test(navigator.userAgent)?_i=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(bi=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\/87/.test(navigator.userAgent)||(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\/79/.test(navigator.userAgent))):/[Pp]anasonic/.test(navigator.userAgent)?Si=!0:navigator.userAgent.indexOf("Xbox"));var Ti=31536e3,ki=function(){function e(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}var t=e.prototype;return t.updateDuration=function(e,t){null!==this._currentMediaSourceDurationUpdateCanceller&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new Z;var n=this._mediaSource,r=this._currentMediaSourceDurationUpdateCanceller.signal,i=function(e,t){var n=new G("open"===e.readyState,t);return Fr(e,(function(){T.debug("Init: Reacting to MediaSource open in duration updater"),n.setValueIfChanged(!0)}),t),zr(e,(function(){T.debug("Init: Reacting to MediaSource ended in duration updater"),n.setValueIfChanged(!1)}),t),Br(e,(function(){T.debug("Init: Reacting to MediaSource close in duration updater"),n.setValueIfChanged(!1)}),t),n}(n,r),a=new Z;a.linkToSignal(r),i.onUpdate((function(){if(a.cancel(),!i.getValue())return;(a=new Z).linkToSignal(r);var o=function(e,t){if(0===e.length){var n=new G(!1);return n.finish(),n}var r=new G(!1,t);o();for(var i=function(){var n=e[a];n.addEventListener("updatestart",o),n.addEventListener("update",o),t.register((function(){n.removeEventListener("updatestart",o),n.removeEventListener("update",o)}))},a=0;a<e.length;a++)i();return r;function o(){for(var t=0;t<e.length;t++){if(e[t].updating)return void r.setValueIfChanged(!0)}r.setValueIfChanged(!1)}}(n.sourceBuffers,a.signal),s=new Z;return s.linkToSignal(a.signal),o.onUpdate((function(r){s.cancel(),(s=new Z).linkToSignal(a.signal),r||Ai(n,e,t,s.signal)}),{clearSignal:a.signal,emitCurrentValue:!0})}),{emitCurrentValue:!0,clearSignal:r})},t.stopUpdating=function(){null!==this._currentMediaSourceDurationUpdateCanceller&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)},e}();function wi(e,t,n){var r=t;n||(r=Ei?1/0:Ii(t));for(var i=0,a=0;a<e.sourceBuffers.length;a++){var o=e.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===e.duration)return"success";if(i>r){if(i<e.duration)try{T.info("Init: Updating duration to what is currently buffered",i),e.duration=i}catch(e){return T.warn("Duration Updater: Can't update duration on the MediaSource.",e instanceof Error?e:""),"failed"}return"partial"}var u=e.duration;try{if(T.info("Init: Updating duration",r),e.duration=r,"open"===e.readyState&&!isFinite(r)){var l=Ii(t);T.info("Init: calling `mediaSource.setLiveSeekableRange`",l),e.setLiveSeekableRange(0,l)}}catch(e){return T.warn("Duration Updater: Can't update duration on the MediaSource.",e instanceof Error?e:""),"failed"}var d=Math.abs(e.duration-r);return d>=.1?d<Math.abs(e.duration-u)?"partial":"failed":"success"}function Ai(e,t,n,r){if("success"!==wi(e,t,n))var i=setTimeout((function(){a(),Ai(e,t,n,r)}),2e3),a=r.register((function(){clearTimeout(i)}))}function Ii(e){return Math.max(Math.pow(2,32),e+Ti)}function Ri(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return xi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function xi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ci=function(e){function n(n){var r;if((r=e.call(this)||this).id=n,r.sourceBuffers=[],r._canceller=new Z,t(Mr))throw new Me("MEDIA_SOURCE_NOT_SUPPORTED","No MediaSource Object was found in the current browser.");T.info("Init: Creating MediaSource");var i=new Mr;r.readyState=i.readyState;var a=i.handle;return r.handle=t(a)?{type:"media-source",value:i}:{type:"handle",value:a},r._mediaSource=i,r._durationUpdater=new ki(i),r._endOfStreamCanceller=null,Fr(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceOpen",null)}),r._canceller.signal),zr(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceEnded",null)}),r._canceller.signal),Br(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceClose",null)}),r._canceller.signal),r}f(n,e);var r=n.prototype;return r.addSourceBuffer=function(e,t){var n=this._mediaSource.addSourceBuffer(t),r=new Mi(e,t,n);return this.sourceBuffers.push(r),r},r.setDuration=function(e,t){this._durationUpdater.updateDuration(e,t)},r.interruptDurationSetting=function(){this._durationUpdater.stopUpdating()},r.maintainEndOfStream=function(){var e,t,n;null===this._endOfStreamCanceller&&(this._endOfStreamCanceller=new Z,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),T.debug("Init: end-of-stream order received."),e=this._mediaSource,t=this._endOfStreamCanceller.signal,(n=new Z).linkToSignal(t),Fr(e,(function(){T.debug("Init: MediaSource re-opened while end-of-stream is active"),n.cancel(),(n=new Z).linkToSignal(t),ui(e,n.signal)}),t),ui(e,n.signal))},r.stopEndOfStream=function(){null!==this._endOfStreamCanceller&&(T.debug("Init: resume-stream order received."),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)},r.dispose=function(){this.sourceBuffers.forEach((function(e){return e.dispose()})),this._canceller.cancel(),function(e){if("closed"!==e.readyState){for(var t=e.readyState,n=e.sourceBuffers,r=n.length-1;r>=0;r--){var i=n[r];try{if("open"===t){T.info("Init: Aborting SourceBuffer before removing");try{i.abort()}catch(e){}}T.info("Init: Removing SourceBuffer from mediaSource"),e.removeSourceBuffer(i)}catch(e){}}n.length>0&&T.info("Init: Not all SourceBuffers could have been removed.")}}(this._mediaSource)},n}(i),Mi=function(){function e(e,t,n){var r=this;this.type=e,this.codec=t,this._canceller=new Z,this._sourceBuffer=n,this._operationQueue=[],this._currentOperations=[];var i=function(e){var t;t=e instanceof Error?e:e.error instanceof Error?e.error:new Error("Unknown SourceBuffer Error");var n=r._currentOperations;if(r._currentOperations=[],0===n.length)T.error("SBI: error for an unknown operation",t);else for(var i,a=new Kn(t.name,t.message,"QuotaExceededError"===t.name),o=Ri(n);!(i=o()).done;){i.value.reject(a)}},a=function(){var e=r._currentOperations;r._currentOperations=[];try{for(var t,n=Ri(e);!(t=n()).done;){t.value.resolve(M(r._sourceBuffer.buffered))}}catch(t){for(var i,a=Ri(e);!(i=a()).done;){var o=i.value;t instanceof Error&&"InvalidStateError"===t.name?o.resolve([]):o.reject(t)}}r._performNextOperation()};n.addEventListener("error",i),n.addEventListener("updateend",a),this._canceller.signal.register((function(){n.removeEventListener("error",i),n.removeEventListener("updateend",a)}))}var t=e.prototype;return t.appendBuffer=function(){T.debug("SBI: receiving order to push data to the SourceBuffer",this.type);for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._addToQueue({operationName:0,params:t})},t.remove=function(e,t){return T.debug("SBI: receiving order to remove data from the SourceBuffer",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})},t.getBuffered=function(){try{return M(this._sourceBuffer.buffered)}catch(e){return T.error("Failed to get buffered time range of SourceBuffer",this.type,e instanceof Error?e:null),[]}},t.abort=function(){try{this._sourceBuffer.abort()}catch(e){T.debug("Init: Failed to abort SourceBuffer:",e instanceof Error?e:null)}this._emptyCurrentQueue()},t.dispose=function(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()},t._emptyCurrentQueue=function(){var e=new ee;this._currentOperations.length>0&&(this._currentOperations.forEach((function(t){t.reject(e)})),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach((function(t){t.reject(e)})),this._operationQueue=[])},t._addToQueue=function(e){var t=this;return new Promise((function(n,r){var i=0===t._operationQueue.length&&0===t._currentOperations.length,a=m({resolve:n,reject:r},e);t._operationQueue.push(a),i&&t._performNextOperation()}))},t._performNextOperation=function(){var e,t,n,r,i;if(0===this._currentOperations.length&&!this._sourceBuffer.updating){var a=this._operationQueue.shift();if(void 0!==a)if(0===a.operationName){this._currentOperations=[{operationName:0,resolve:a.resolve,reject:a.reject}];var o=a.params[0],s=a.params[1],u=o;if(this._operationQueue.length>0&&0===this._operationQueue[0].operationName){for(var l=[o instanceof ArrayBuffer?new Uint8Array(o):o instanceof Uint8Array?o:new Uint8Array(o.buffer)];0===(null===(e=this._operationQueue[0])||void 0===e?void 0:e.operationName);){var d=this._operationQueue[0],c=null!==(t=s.appendWindow)&&void 0!==t?t:[void 0,void 0],f=null!==(n=d.params[1].appendWindow)&&void 0!==n?n:[void 0,void 0],v=null!==(r=s.timestampOffset)&&void 0!==r?r:0,p=null!==(i=d.params[1].timestampOffset)&&void 0!==i?i:0;if(c[0]!==f[0]||c[1]!==f[1]||s.codec!==d.params[1].codec||v!==p)break;var h=d.params[0],m=void 0;m=h instanceof ArrayBuffer?new Uint8Array(h):h instanceof Uint8Array?h:new Uint8Array(h.buffer),l.push(m),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:d.resolve,reject:d.reject})}l.length>1&&(T.info("MMSI: Merging "+l.length+" segments together for perf",this.type),u=Xr.apply(void 0,l))}try{this._appendBufferNow(u,s)}catch(e){var g=e instanceof Error?new Kn(e.name,e.message,"QuotaExceededError"===e.name):new Kn("Error","Unknown SourceBuffer Error during appendBuffer",!1);this._currentOperations.forEach((function(e){e.reject(g)})),this._currentOperations=[]}}else{this._currentOperations=[a];var y=a.params,_=y[0],b=y[1];T.debug("SBI: removing data from SourceBuffer",this.type,_,b);try{this._sourceBuffer.remove(_,b)}catch(e){var S=e instanceof Error?new Kn(e.name,e.message,!1):new Kn("Error","Unknown SourceBuffer Error during remove",!1);a.reject(S),this._currentOperations=[]}}}},t._appendBufferNow=function(e,t){var n=this._sourceBuffer,r=t.codec,i=t.timestampOffset,a=t.appendWindow,o=void 0===a?[]:a;if(void 0!==r&&r!==this.codec){T.debug("SBI: updating codec",r);var s=function(e,t){if("function"==typeof e.changeType){try{e.changeType(t)}catch(e){return T.warn("Could not call 'changeType' on the given SourceBuffer:",e instanceof Error?e:""),!1}return!0}return!1}(n,r);s?this.codec=r:T.debug("SBI: could not update codec",r,this.codec)}if(void 0!==i&&n.timestampOffset!==i){var u=i;T.debug("SBI: updating timestampOffset",r,n.timestampOffset,u),n.timestampOffset=u}if(void 0===o[0])n.appendWindowStart>0&&(T.debug("SBI: re-setting `appendWindowStart` to `0`"),n.appendWindowStart=0);else if(o[0]!==n.appendWindowStart){if(o[0]>=n.appendWindowEnd){var l=o[0]+1;T.debug("SBI: pre-updating `appendWindowEnd`",l),n.appendWindowEnd=l}T.debug("SBI: setting `appendWindowStart`",o[0]),n.appendWindowStart=o[0]}void 0===o[1]?n.appendWindowEnd!==1/0&&(T.debug("SBI: re-setting `appendWindowEnd` to `Infinity`"),n.appendWindowEnd=1/0):o[1]!==n.appendWindowEnd&&(T.debug("SBI: setting `appendWindowEnd`",o[1]),n.appendWindowEnd=o[1]),T.debug("SBI: pushing segment",this.type),n.appendBuffer(e)},e}();var Pi,Di=Le();function Oi(e,t){if(null!==t&&e.src===t&&(T.info("Init: Clearing HTMLMediaElement's src"),xr(e)),null!==t)try{T.debug("Init: Revoking previous URL"),URL.revokeObjectURL(t)}catch(e){T.warn("Init: Error while revoking the media source URL",e instanceof Error?e:"")}}function Ni(e,t){return Ct(t,(function(n){var r=function(e,t){Oi(e,et(e.src)?e.src:null);var n=new Ci(Di());return t.register((function(){n.dispose()})),n}(e,t);if(r.addEventListener("mediaSourceOpen",(function(){T.info("Init: MediaSource opened"),n(r)}),t),T.info("MTCI: Attaching MediaSource URL to the media element"),"handle"===r.handle.type)e.srcObject=r.handle.value,t.register((function(){Oi(e,null)}));else{var i=URL.createObjectURL(r.handle.value);e.src=i,t.register((function(){Oi(e,i)}))}}))}function Li(e,n,r){var i;if(!t(r)){var a=Ve(e),o=We(e);if(!t(r.position))return T.debug("Init: using startAt.minimumPosition"),Math.max(Math.min(r.position,o),a);if(!t(r.wallClockTime)){T.debug("Init: using startAt.wallClockTime");var s=void 0===e.availabilityStartTime?0:e.availabilityStartTime,u=r.wallClockTime-s;return Math.max(Math.min(u,o),a)}if(!t(r.fromFirstPosition)){T.debug("Init: using startAt.fromFirstPosition");var l=r.fromFirstPosition;return l<=0?a:Math.min(o,a+l)}if(!t(r.fromLastPosition)){T.debug("Init: using startAt.fromLastPosition");var d=r.fromLastPosition;return d>=0?o:Math.max(a,o+d)}if(!t(r.fromLivePosition)){T.debug("Init: using startAt.fromLivePosition");var c=null!==(i=Ke(e))&&void 0!==i?i:o,f=r.fromLivePosition;return f>=0?c:Math.max(a,c+f)}if(!t(r.percentage)){T.debug("Init: using startAt.percentage");var v=r.percentage;return v>100?o:v<0?a:a+(o-a)*(+v/100)}}var p=Ve(e);if(e.isLive){var h,m=e.suggestedPresentationDelay,g=e.clockOffset,y=We(e),_=b.getCurrent().DEFAULT_LIVE_GAP;if(void 0===g)T.info("Init: no clock offset found for a live content, starting close to maximum available position"),h=y;else{T.info("Init: clock offset found for a live content, checking if we can start close to it");var S=void 0===e.availabilityStartTime?0:e.availabilityStartTime,E=(ne()+g)/1e3-S;h=Math.min(y,E)}var k=null!=m?m:n?_.LOW_LATENCY:_.DEFAULT;return T.debug("Init: "+h+" defined as the live time, applying a live gap of "+k),Math.max(h-k,p)}return T.info("Init: starting at the minimum available position:",p),p}function Ui(){return yi}function Fi(e,t,n,r){var i=new Z;i.linkToSignal(r);var a=new G(!1,i.signal);return e.listen((function(e){if(null===e.rebuffering&&null===e.freezing&&0!==e.readyState){if(!function(e,t){return!e||!gi||t}(n,t.hasAttribute("playsinline"))&&t.duration>0)return a.setValue(!0),void i.cancel();var r=Ei?4:3;return e.readyState>=r&&(null!==e.currentRange||e.ended)&&(!Ui()||t.duration>0)?(a.setValue(!0),void i.cancel()):void 0}}),{includeLastObservation:!0,clearSignal:i.signal}),a}function Bi(e,t){var n=e.mediaElement,r=e.playbackObserver,i=e.startTime,a=e.mustAutoPlay,o=e.isDirectfile,s=e.onWarning,u=new G(!1,t),l=new Promise((function(e,l){var d=t.register((function(e){l(e)}));if(!t.isCancelled()){var c=!1,f=function(e){r.setCurrentTime(e),c=!0};if(o&&"number"!=typeof i)r.listen((function(e,t){if(e.readyState>=1){t();var n="number"==typeof i?i:i();0!==n&&(gi?setTimeout((function(){f(n)}),0):f(n)),p()}}),{includeLastObservation:!0,clearSignal:t});else{var v="number"==typeof i?i:i();0!==v&&f(v),p()}}function p(){var i=!1;r.listen((function(o,f){if(i||0===o.seeking||(i=!0),(!c||i)&&0!==o.readyState){if(f(),Ui()&&0===n.duration){var v=new Me("MEDIA_ERR_NOT_LOADED_METADATA","Cannot load automatically: your browser falsely announced having loaded the content.");s(v)}t.isCancelled()||r.listen((function(r,i){0===r.seeking&&null===r.rebuffering&&r.readyState>=1&&(i(),function(){var r,i;if(T.info("Init: Can begin to play content"),!a)return n.autoplay&&T.warn("Init: autoplay is enabled on HTML media element. Media will play as soon as possible."),u.setValue(!0),u.finish(),d(),e({type:"skipped"});if(n.ended)return T.warn("Init: autoplay is enabled but the video is ended. Skipping autoplay to prevent video to start again"),u.setValue(!0),u.finish(),d(),e({type:"skipped"});try{i=null!==(r=n.play())&&void 0!==r?r:Promise.resolve()}catch(e){return d(),l(e)}i.then((function(){if(!t.isCancelled())return u.setValue(!0),u.finish(),d(),e({type:"autoplay"})})).catch((function(n){if(d(),!t.isCancelled()){if(n instanceof Error&&"NotAllowedError"===n.name){T.warn("Init: Media element can't play. It may be due to browser auto-play policies.");var r=new Me("MEDIA_ERR_BLOCKED_AUTOPLAY","Cannot trigger auto-play automatically: your browser does not allow it.");if(s(r),t.isCancelled())return;return e({type:"autoplay-blocked"})}l(n)}}))}())}),{includeLastObservation:!0,clearSignal:t})}}),{includeLastObservation:!0,clearSignal:t})}}));return{autoPlayResult:l,initialPlayPerformed:u}}function zi(e,t,n,r,i){if(0===t.length)return l("No `keySystems` option given.");if(null===ot.decrypt)return l("EME feature not activated.");var a=new Z;a.linkToSignal(i);var o=new G({initializationState:{type:"uninitialized",value:null},drmSystemId:void 0},i),s=ot.decrypt;if(!s.hasEmeApis())return l("EME API not available on the current page.");T.debug("Init: Creating ContentDecryptor");var u=new s(e,t);return u.addEventListener("stateChange",(function(e){if(e===Pi.WaitingForAttachment){var t=new G(!1);t.onUpdate((function(t,n){t&&(n(),e===Pi.WaitingForAttachment&&u.attach())}),{clearSignal:a.signal}),o.setValue({initializationState:{type:"awaiting-media-link",value:{isMediaLinked:t}},drmSystemId:u.systemId})}else e===Pi.ReadyForContent&&(o.setValue({initializationState:{type:"initialized",value:null},drmSystemId:u.systemId}),u.removeEventListener("stateChange"))})),u.addEventListener("error",(function(e){a.cancel(),r.onError(e)})),u.addEventListener("warning",(function(e){r.onWarning(e)})),u.addEventListener("blackListProtectionData",(function(e){r.onBlackListProtectionData(e)})),u.addEventListener("keyIdsCompatibilityUpdate",(function(e){r.onKeyIdsCompatibilityUpdate(e)})),n.onUpdate((function(e){null!==e&&u.onInitializationData(e)}),{clearSignal:a.signal}),a.signal.register((function(){u.dispose()})),o;function l(e){n.onUpdate((function(t,n){if(null!==t){n();var i=new Ce("MEDIA_IS_ENCRYPTED_ERROR",e);r.onError(i)}}),{clearSignal:i});var t=new G({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return t.finish(),t}}!function(e){e[e.Initializing=0]="Initializing",e[e.WaitingForAttachment=1]="WaitingForAttachment",e[e.ReadyForContent=2]="ReadyForContent",e[e.Error=3]="Error",e[e.Disposed=4]="Disposed"}(Pi||(Pi={}));var Vi=function(){function e(e){this._displayer=e}var t=e.prototype;return t.pushTextData=function(e){try{return Promise.resolve(this._displayer.pushTextData(e))}catch(e){return Promise.reject(e)}},t.remove=function(e,t){try{return Promise.resolve(this._displayer.removeBuffer(e,t))}catch(e){return Promise.reject(e)}},t.reset=function(){this._displayer.reset()},t.stop=function(){this._displayer.stop()},e}(),Ki=1/60,Wi=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._playbackObserver=t,i._manifest=n,i._speed=r,i._discontinuitiesStore=[],i._isStarted=!1,i._canceller=new Z,i}f(t,e);var n=t.prototype;return n.start=function(){var e=this;if(!this._isStarted){this._isStarted=!0;var t=new Hi(this._playbackObserver,this._speed);this._canceller.signal.register((function(){t.dispose()}));var n=null;this._playbackObserver.listen((function(r){var i,a=e._discontinuitiesStore,o=r.buffered,s=r.position,u=r.readyState,l=r.rebuffering,d=r.freezing,c=b.getCurrent(),f=c.BUFFER_DISCONTINUITY_THRESHOLD,v=c.FREEZING_STALLED_DELAY,p=c.UNFREEZING_SEEK_DELAY,h=c.UNFREEZING_DELTA_POSITION;if(null!==d){var m=ne(),g=null===n?d.timestamp:n.attemptTimestamp;if(!s.isAwaitingFuturePosition()&&m-g>p&&(T.warn("Init: trying to seek to un-freeze player"),e._playbackObserver.setCurrentTime(e._playbackObserver.getCurrentTime()+h),n={attemptTimestamp:m}),m-d.timestamp>v)return null===l?t.stopRebuffering():t.startRebuffering(),void e.trigger("stalled","freezing")}else n=null;if(null===l)return t.stopRebuffering(),1===u?(i=0!==r.seeking?1===r.seeking?"internal-seek":"seeking":"not-ready",void e.trigger("stalled",i)):void e.trigger("unstalled",null);var y="seeking"===l.reason&&1===r.seeking?"internal-seek":l.reason;if(s.isAwaitingFuturePosition())return t.stopRebuffering(),T.debug("Init: let rebuffering happen as we're awaiting a future position"),void e.trigger("stalled",y);if(t.startRebuffering(),null!==e._manifest){var _=l.position;if(null!=_&&e._speed.getValue()>0){var S=function(e,t,n){if(0===e.length)return null;for(var r=null,i=0;i<e.length;i++){var a=e[i].period;if(a.start>n)return r;var o=void 0;if(void 0===a.end||a.end>n){var s=e[i],u=s.discontinuity,l=s.position,d=u.start,c=u.end;if(n>=(null!=d?d:l)-Ki)if(null===c){var f=je(t,a);null!==f?o=f.start+Ki:T.warn("Init: discontinuity at Period's end but no next Period")}else n<c+Ki&&(o=c+Ki);void 0!==o&&(T.info("Init: discontinuity found",n,o),r=null!==r&&r>o?r:o)}}return r}(a,e._manifest,_);if(null!==S){var E=S+.001;if(!(E<=e._playbackObserver.getCurrentTime()))return T.warn("SA: skippable discontinuity found in the stream",s.getPolled(),E),e._playbackObserver.setCurrentTime(E),void e.trigger("warning",ji(_,E));T.info("Init: position to seek already reached, no seeking",e._playbackObserver.getCurrentTime(),E)}}var k=null!=_?_:s.getPolled(),w=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e.start(r);if(t<i)return i-t}return 1/0}(o,k);if(e._speed.getValue()>0&&w<f){var A=k+w+Ki;if(e._playbackObserver.getCurrentTime()<A)return T.warn("Init: discontinuity encountered inferior to the threshold",k,A,f),e._playbackObserver.setCurrentTime(A),void e.trigger("warning",ji(k,A))}for(var I=e._manifest.periods.length-2;I>=0;I--){var R=e._manifest.periods[I];if(void 0!==R.end&&R.end<=k){if(e._manifest.periods[I+1].start>k&&e._manifest.periods[I+1].start>e._playbackObserver.getCurrentTime()){var x=e._manifest.periods[I+1];return e._playbackObserver.setCurrentTime(x.start),void e.trigger("warning",ji(k,x.start))}break}}e.trigger("stalled",y)}else e.trigger("stalled",y)}),{includeLastObservation:!0,clearSignal:this._canceller.signal})}},n.updateDiscontinuityInfo=function(e){this._isStarted||this.start();var t=this._playbackObserver.getReference().getValue();!function(e,t,n){var r=Math.min(n.position.getPolled(),n.position.getWanted());for(;e.length>0&&void 0!==e[0].period.end&&e[0].period.end+10<r;)e.shift();var i=t.period,a=t.bufferType;if("audio"!==a&&"video"!==a)return;for(var o=0;o<e.length;o++)if(e[o].period.id===i.id){if(e[o].bufferType===a)return void(Gi(t)?e[o]=t:e.splice(o,1))}else if(e[o].period.start>i.start)return void(Gi(t)&&e.splice(o,0,t));Gi(t)&&e.push(t)}(this._discontinuitiesStore,e,t)},n.onLockedStream=function(e,t){var n;this._isStarted||this.start();var r=this._playbackObserver.getReference().getValue();if(!(!r.rebuffering||r.paused||this._speed.getValue()<=0||"audio"!==e&&"video"!==e)){var i=r.position.getWanted(),a=null!==(n=r.rebuffering.position)&&void 0!==n?n:i,o=t.start;i<o&&Math.abs(a-o)<1&&(T.warn("Init: rebuffering because of a future locked stream.\nTrying to unlock by seeking to the next Period"),this._playbackObserver.setCurrentTime(o+.001))}},n.destroy=function(){this._canceller.cancel()},t}(i);function Gi(e){return null!==e.discontinuity}function ji(e,t){return new Me("DISCONTINUITY_ENCOUNTERED","A discontinuity has been encountered at position "+String(e)+", seeked at position "+String(t))}var Hi=function(){function e(e,t){this._speedUpdateCanceller=new Z,this._isRebuffering=!1,this._playbackObserver=e,this._isDisposed=!1,this._speed=t,this._updateSpeed()}var t=e.prototype;return t.startRebuffering=function(){this._isRebuffering||this._isDisposed||(this._isRebuffering=!0,this._speedUpdateCanceller.cancel(),T.info("Init: Pause playback to build buffer"),this._playbackObserver.setPlaybackRate(0))},t.stopRebuffering=function(){this._isRebuffering&&!this._isDisposed&&(this._isRebuffering=!1,this._speedUpdateCanceller=new Z,this._updateSpeed())},t.dispose=function(){this._speedUpdateCanceller.cancel(),this._isDisposed=!0},t._updateSpeed=function(){var e=this;this._speed.onUpdate((function(t){T.info("Init: Resume playback speed",t),e._playbackObserver.setPlaybackRate(t)}),{clearSignal:this._speedUpdateCanceller.signal,emitCurrentValue:!0})},e}();var qi=function(e,t){return e.id===t.id&&e.start===t.start&&e.end===t.end};var Yi=function(e,t){for(var n=[],r=t.periods,i=0;i<r.length;i++){r[i].streamEvents.forEach((function(t){for(var r,i=t.start,a=t.end,o=t.id,s=t.data,u=0;u<e.length;u++){var l=e[u];if(qi(l,{id:o,start:i,end:a}))return void n.push(l)}if(void 0!==s.value.element)r=s.value.element;else{if(void 0===s.value.xmlData)return;var d=s.value.xmlData.namespaces.reduce((function(e,t){return e+"xmlns:"+t.key+'="'+t.value+'" '}),"<toremove ");d+=">";var c=(new DOMParser).parseFromString(d+s.value.xmlData.data+"</toremove>","application/xml").documentElement;r=c.children.length>0?c.children[0]:c.childNodes[0]}var f={type:s.type,value:Object.assign(Object.assign({},s.value),{element:r})};if(void 0===a){var v={start:i,id:o,data:f,publicEvent:{start:i,data:f}};n.push(v)}else{var p={start:i,end:a,id:o,data:f,publicEvent:{start:i,end:a,data:f}};n.push(p)}}))}return n};function Qi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $i(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function $i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Xi=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._manifest=t,i._mediaElement=n,i._playbackObserver=r,i._canceller=null,i._scheduledEventsRef=new G([]),i._eventsBeingPlayed=new WeakMap,i}f(t,e);var n=t.prototype;return n.start=function(){var e=this;if(null===this._canceller){this._canceller=new Z;var t=this._canceller.signal,n=this._playbackObserver,r=this._mediaElement,i=!1,a=new Z;a.linkToSignal(t),this._scheduledEventsRef.setValue(Yi([],this._manifest)),this._scheduledEventsRef.onUpdate((function(o){if(0!==o.length){if(!i){i=!0;var s=c(),u=function(){var t=c();e._emitStreamEvents(e._scheduledEventsRef.getValue(),s,t,a.signal),s=t},l=b.getCurrent().STREAM_EVENT_EMITTER_POLL_INTERVAL,d=setInterval(u,l);n.listen(u,{includeLastObservation:!1,clearSignal:a.signal}),a.signal.register((function(){clearInterval(d)}))}}else i&&(a.cancel(),(a=new Z).linkToSignal(t),i=!1);function c(){var e=n.getReference().getValue();return{currentTime:r.currentTime,isSeeking:0!==e.seeking}}}),{emitCurrentValue:!0,clearSignal:t})}},n.onManifestUpdate=function(e){var t=this._scheduledEventsRef.getValue();this._scheduledEventsRef.setValue(Yi(t,e))},n.stop=function(){null!==this._canceller&&(this._canceller.cancel(),this._canceller=null)},n._emitStreamEvents=function(e,t,n,r){for(var i=t.currentTime,a=n.isSeeking,o=n.currentTime,s=[],u=[],l=0;l<e.length;l++){var d=e[l],c=d.start,f=Zi(d)?d.end:void 0;this._eventsBeingPlayed.has(d)?(c>o||void 0!==f&&o>=f)&&(Zi(d)&&u.push(d.publicEvent),this._eventsBeingPlayed.delete(d)):c<=o&&void 0!==f&&o<f?(s.push({type:"stream-event",value:d.publicEvent}),this._eventsBeingPlayed.set(d,!0)):i<c&&o>=(null!=f?f:c)&&(a?s.push({type:"stream-event-skip",value:d.publicEvent}):(s.push({type:"stream-event",value:d.publicEvent}),Zi(d)&&u.push(d.publicEvent)))}if(s.length>0)for(var v,p=Qi(s);!(v=p()).done;){var h=v.value;if("stream-event"===h.type?this.trigger("event",h.value):this.trigger("eventSkip",h.value),r.isCancelled())return}if(u.length>0)for(var m,g=Qi(u);!(m=g()).done;){var y=m.value;if("function"==typeof y.onExit&&y.onExit(),r.isCancelled())return}},t}(i);function Zi(e){return void 0!==e.end}var Ji=Xi;function ea(e,n,r){function i(){var r,i,a=e.error;switch(t(a)||(r=a.code,i=a.message),r){case 1:return n(new Me("MEDIA_ERR_ABORTED",i=null!=i?i:"The fetching of the associated resource was aborted by the user's request."));case 2:return n(new Me("MEDIA_ERR_NETWORK",i=null!=i?i:"A network error occurred which prevented the media from being successfully fetched"));case 3:return n(new Me("MEDIA_ERR_DECODE",i=null!=i?i:"An error occurred while trying to decode the media resource"));case 4:return n(new Me("MEDIA_ERR_SRC_NOT_SUPPORTED",i=null!=i?i:"The media resource has been found to be unsuitable."));default:return n(new Me("MEDIA_ERR_UNKNOWN",i=null!=i?i:"The HTMLMediaElement errored due to an unknown reason."))}}r.isCancelled()||(e.addEventListener("error",i),r.register((function(){e.removeEventListener("error",i)})))}function ta(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return na(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return na(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function na(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ra=function(e){function t(t){var n;(n=e.call(this)||this)._settings=t,n._initCanceller=new Z,n._manifest=null;var r=void 0===t.url?void 0:[t.url];return n._manifestFetcher=new zt(r,t.transport,t.manifestRequestSettings),n}f(t,e);var n=t.prototype;return n.prepare=function(){var e=this;null===this._manifest&&(this._manifest=Sr.createAsync(Ct(this._initCanceller.signal,(function(t,n){e._manifestFetcher.addEventListener("warning",(function(t){return e.trigger("warning",t)})),e._manifestFetcher.addEventListener("error",(function(t){e.trigger("error",t),n(t)})),e._manifestFetcher.addEventListener("manifestReady",(function(e){t(e)}))}))),this._manifestFetcher.start(),this._initCanceller.signal.register((function(){e._manifestFetcher.dispose()})))},n.start=function(e,t){var n=this;this.prepare(),ea(e,(function(e){return n._onFatalError(e)}),this._initCanceller.signal);var r=new G(null,this._initCanceller.signal);this._initializeMediaSourceAndDecryption(e,r).then((function(i){return n._onInitialMediaSourceReady(e,i.mediaSource,t,i.drmSystemId,r,i.unlinkMediaSource)})).catch((function(e){n._onFatalError(e)}))},n.updateContentUrls=function(e,t){this._manifestFetcher.updateContentUrls(e,t)},n.dispose=function(){this._initCanceller.cancel()},n._onFatalError=function(e){this._initCanceller.isUsed()||(this._initCanceller.cancel(),this.trigger("error",e))},n._initializeMediaSourceAndDecryption=function(e,t){var n=this,r=this._initCanceller;return Ct(r.signal,(function(i){var a=n._settings.keySystems,o=zi(e,a,t,{onWarning:function(e){return n.trigger("warning",e)},onError:function(e){return n._onFatalError(e)},onBlackListProtectionData:function(e){d(p().mark((function t(){var r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==n._manifest){t.next=2;break}return t.abrupt("return");case 2:if(null===(r=n._manifest.syncValue)||void 0===r){t.next=6;break}t.t0=r,t.next=9;break;case 6:return t.next=8,n._manifest.getValueAsAsync();case 8:t.t0=t.sent;case 9:aa(t.t0,e);case 11:case"end":return t.stop()}}),t)})))().catch(S)},onKeyIdsCompatibilityUpdate:function(e){d(p().mark((function t(){var r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==n._manifest){t.next=2;break}return t.abrupt("return");case 2:if(null===(r=n._manifest.syncValue)||void 0===r){t.next=6;break}t.t0=r,t.next=9;break;case 6:return t.next=8,n._manifest.getValueAsAsync();case 8:t.t0=t.sent;case 9:ia(t.t0,e.whitelistedKeyIds,e.blacklistedKeyIds,e.delistedKeyIds);case 11:case"end":return t.stop()}}),t)})))().catch(S)}},r.signal);o.onUpdate((function(t,a){if("uninitialized"!==t.initializationState.type){a();var s=new Z;s.linkToSignal(r.signal),Ni(e,s.signal).then((function(e){var n=o.getValue();if("awaiting-media-link"===n.initializationState.type)n.initializationState.value.isMediaLinked.setValue(!0),o.onUpdate((function(t,n){if("initialized"===t.initializationState.type)return n(),void i({mediaSource:e,drmSystemId:t.drmSystemId,unlinkMediaSource:s})}),{emitCurrentValue:!0,clearSignal:r.signal});else if("initialized"===t.initializationState.type)return void i({mediaSource:e,drmSystemId:t.drmSystemId,unlinkMediaSource:s})})).catch((function(e){s.isUsed()||n._onFatalError(e)}))}}),{emitCurrentValue:!0,clearSignal:r.signal})}))},n._onInitialMediaSourceReady=function(){var e=d(p().mark((function e(t,n,r,i,a,o){var s,u,l,d,c,f,v,h,g,y,_,b,S,E,k,w,A,I,R,x,C,M=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(C=function(e,n,i,o){I({mediaElement:t,playbackObserver:r,mediaSource:e,initialTime:n,autoPlay:i,manifest:S,representationEstimator:k,segmentFetcherCreator:A,speed:h,protectionRef:a,bufferOptions:w},(function(e){if(o.cancel(),b.isUsed())return;if(R("reloadingMediaSource",e),b.isUsed())return;var n=new Z;n.linkToSignal(b.signal),Ni(t,n.signal).then((function(t){C(t,e.position,e.autoPlay,n)})).catch((function(e){n.isUsed()||x(e)}))}),o.signal)},u=this._settings,l=u.adaptiveOptions,d=u.autoPlay,c=u.bufferOptions,f=u.lowLatencyMode,v=u.segmentRequestOptions,h=u.speed,g=u.startAt,y=u.textTrackOptions,_=u.transport,b=this._initCanceller,$(this._manifest),e.prev=4,null===(s=this._manifest.syncValue)||void 0===s){e.next=9;break}e.t0=s,e.next=12;break;case 9:return e.next=11,this._manifest.getValueAsAsync();case 11:e.t0=e.sent;case 12:S=e.t0,e.next=18;break;case 15:return e.prev=15,e.t1=e.catch(4),e.abrupt("return");case 18:if(S.addEventListener("manifestUpdate",(function(e){M.trigger("manifestUpdate",e)}),b.signal),S.addEventListener("decipherabilityUpdate",(function(e){M.trigger("decipherabilityUpdate",e)}),b.signal),T.debug("Init: Calculating initial time"),E=Li(S,f,g),T.debug("Init: Initial time calculated:",E),k=Te(l),w=m({textTrackOptions:y,drmSystemId:i},c),A=new Zt(_,v,b.signal),this.trigger("manifestReady",S),!b.isUsed()){e.next=29;break}return e.abrupt("return");case 29:I=this._startBufferingOnMediaSource.bind(this),R=this.trigger.bind(this),x=this._onFatalError.bind(this),C(n,E,d,o);case 33:case"end":return e.stop()}}),e,this,[[4,15]])})));return function(t,n,r,i,a,o){return e.apply(this,arguments)}}(),n._startBufferingOnMediaSource=function(e,t,n){var r,i=this,a=e.autoPlay,o=e.bufferOptions,s=e.initialTime,u=e.manifest,l=e.mediaElement,d=e.mediaSource,c=e.playbackObserver,f=e.protectionRef,v=e.representationEstimator,p=e.segmentFetcherCreator,h=e.speed,m=null!==(r=u.getPeriodForTime(s))&&void 0!==r?r:u.getNextPeriod(s);if(void 0===m){var g=new Me("MEDIA_STARTING_TIME_NOT_FOUND","Wanted starting time not found in the Manifest.");return this._onFatalError(g)}var y=null,_=null;if("html"===this._settings.textTrackOptions.textTrackMode&&null!==ot.htmlTextDisplayer?_=new ot.htmlTextDisplayer(l,this._settings.textTrackOptions.textTrackElement):null!==ot.nativeTextDisplayer&&(_=new ot.nativeTextDisplayer(l)),null!==_){var S=new Vi(_);y=S,n.register((function(){S.stop(),null==_||_.stop()}))}var E=new Mn(d,"VIDEO"===l.nodeName,y);n.register((function(){E.disposeAll()}));var k=Bi({mediaElement:l,playbackObserver:c,startTime:s,mustAutoPlay:a,onWarning:function(e){i.trigger("warning",e)},isDirectfile:!1},n),w=k.autoPlayResult,A=k.initialPlayPerformed;if(!n.isCancelled()){A.onUpdate((function(e,t){if(e){t();var r=new Ji(u,l,c);u.addEventListener("manifestUpdate",(function(){r.onManifestUpdate(u)}),n),r.addEventListener("event",(function(e){i.trigger("streamEvent",e)}),n),r.addEventListener("eventSkip",(function(e){i.trigger("streamEventSkip",e)}),n),r.start(),n.register((function(){r.stop()}))}}),{clearSignal:n,emitCurrentValue:!0});var I=Ir(c,{autoPlay:a,manifest:u,mediaSource:d,textDisplayer:_,initialPlayPerformed:A,speed:h},n),R=this._createRebufferingController(c,u,h,n),x=new ln(E);c.listen((function(e){if(x.needToReload(e)){var n,r=c.getReference().getValue();n=r.position.isAwaitingFuturePosition()?r.position.getWanted():c.getCurrentTime();var i=A.getValue()?!c.getIsPaused():a;t({position:n,autoPlay:i})}}),{clearSignal:n}),I.listen((function(e){["video","audio","text"].forEach((function(t){var n,r=E.getStatus(t);"initialized"===r.type&&r.value.synchronizeInventory(null!==(n=e.buffered[t])&&void 0!==n?n:[])}))}),{clearSignal:n});var C=function(e,t,n,r,i,a){a.register((function(){t.interruptDurationSetting()}));var o=new nn(e,n,r.getBufferTypes());a.register((function(){o.dispose()})),o.addEventListener("warning",(function(e){return i.onWarning(e)})),o.addEventListener("periodChange",(function(e){return i.onPeriodChanged(e)})),o.addEventListener("endingPositionChange",(function(e){t.setDuration(e.endingPosition,e.isEnd)})),o.addEventListener("endOfStream",(function(){T.debug("Init: end-of-stream order received."),t.maintainEndOfStream()})),o.addEventListener("resumeStream",(function(){t.stopEndOfStream()}));var s=o.getCurrentEndingTime();return t.setDuration(s.endingPosition,s.isEnd),o}(u,d,I,E,{onWarning:function(e){return i.trigger("warning",e)},onPeriodChanged:function(e){return i.trigger("activePeriodChanged",{period:e})}},n);w.then((function(){Fi(c,l,!1,n).onUpdate((function(e,t){e&&(t(),i.trigger("loaded",{segmentSinksStore:E}))}),{emitCurrentValue:!0,clearSignal:n})})).catch((function(e){n.isCancelled()||i._onFatalError(e)}));var M=this;br({manifest:u,initialPeriod:m},I,v,E,p,o,{needsBufferFlush:function(e){var t,r,i=c.getCurrentTime(),a=null!==(t=null==e?void 0:e.relativeResumingPosition)&&void 0!==t?t:0,o=Boolean(null==e?void 0:e.relativePosHasBeenDefaulted);r=0===a&&o?i+.001:i+a,c.setCurrentTime(r),c.listen((function(e,t){(null!==e.currentRange||e.position.getPolled()>r+.1)&&(t(),c.setCurrentTime(e.position.getWanted()+.001))}),{includeLastObservation:!1,clearSignal:n})},streamStatusUpdate:function(e){var t=e.period,r=e.bufferType,i=e.imminentDiscontinuity,a=e.position;R.updateDiscontinuityInfo({period:t,bufferType:r,discontinuity:i,position:a}),n.isCancelled()||u.isLastPeriodKnown&&e.period.id===u.periods[u.periods.length-1].id&&(e.hasFinishedLoading||e.isEmptyStream?C.onLastSegmentFinishedLoading(e.bufferType):C.onLastSegmentLoadingResume(e.bufferType))},needsManifestRefresh:function(){return M._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync:function(){var e=b.getCurrent().OUT_OF_SYNC_MANIFEST_REFRESH_DELAY;M._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:e})},lockedStream:function(e){return R.onLockedStream(e.bufferType,e.period)},adaptationChange:function(e){M.trigger("adaptationChange",e),n.isCancelled()||C.onAdaptationChange(e.type,e.period,e.adaptation)},representationChange:function(e){M.trigger("representationChange",e),n.isCancelled()||C.onRepresentationChange(e.type,e.period)},inbandEvent:function(e){return M.trigger("inbandEvents",e)},warning:function(e){return M.trigger("warning",e)},periodStreamReady:function(e){return M.trigger("periodStreamReady",e)},periodStreamCleared:function(e){C.onPeriodCleared(e.type,e.period),n.isCancelled()||M.trigger("periodStreamCleared",e)},bitrateEstimateChange:function(e){return M.trigger("bitrateEstimateChange",e)},needsMediaSourceReload:function(e){var n,r,i,a=I.getReference().getValue(),o=a.position.isAwaitingFuturePosition()?a.position.getWanted():null!==(n=I.getCurrentTime())&&void 0!==n?n:a.position.getPolled(),s=null!==(i=null!==(r=a.paused.pending)&&void 0!==r?r:I.getIsPaused())&&void 0!==i?i:a.paused.last,u=o+e.timeOffset;void 0!==e.minimumPosition&&(u=Math.max(e.minimumPosition,u)),void 0!==e.maximumPosition&&(u=Math.min(e.maximumPosition,u)),t({position:u,autoPlay:!s})},needsDecipherabilityFlush:function(){var e,n,r,i,a,o=kr(l);if(void 0===(a=null==o?void 0:o[0])||a.indexOf("widevine")<0){var s=I.getReference().getValue(),u=s.position.isAwaitingFuturePosition()?s.position.getWanted():null!==(e=I.getCurrentTime())&&void 0!==e?e:s.position.getPolled(),d=null!==(r=null!==(n=s.paused.pending)&&void 0!==n?n:I.getIsPaused())&&void 0!==r?r:s.paused.last;t({position:u,autoPlay:!d})}else{var f=I.getReference().getValue(),v=f.position.isAwaitingFuturePosition()?f.position.getWanted():null!==(i=I.getCurrentTime())&&void 0!==i?i:f.position.getPolled();v+.001<f.duration?c.setCurrentTime(l.currentTime+.001):c.setCurrentTime(v)}},encryptionDataEncountered:function(e){for(var t,r=ta(e);!(t=r()).done;){var i=t.value;if(f.setValue(i),n.isCancelled())return}},error:function(e){return M._onFatalError(e)}},n)}},n._createRebufferingController=function(e,t,n,r){var i=this,a=new Wi(e,t,n);return a.addEventListener("stalled",(function(e){return i.trigger("stalled",e)})),a.addEventListener("unstalled",(function(){return i.trigger("unstalled",null)})),a.addEventListener("warning",(function(e){return i.trigger("warning",e)})),r.register((function(){return a.destroy()})),a.start(),a},t}(wr);function ia(e,t,n,r){e.updateRepresentationsDeciperability((function(e){var i=e.representation;if(void 0===i.contentProtections)return i.decipherable;var a=i.contentProtections.keyIds;if(void 0!==a)for(var o,s=ta(a);!(o=s()).done;){for(var u,l=o.value,d=ta(n);!(u=d()).done;){if(st(u.value,l.keyId))return!1}for(var c,f=ta(t);!(c=f()).done;){if(st(c.value,l.keyId))return!0}for(var v,p=ta(r);!(v=p()).done;){if(st(v.value,l.keyId))return}}return i.decipherable}))}function aa(e,t){e.updateRepresentationsDeciperability((function(e){var n,r,i=e.representation;if(!1===i.decipherable)return!1;for(var a,o,s=function(){var e=o.value;if((void 0===t.type||e.type===t.type)&&t.values.getFormattedValues().every((function(t){return e.values.some((function(e){return(void 0===t.systemId||e.systemId===t.systemId)&&st(e.data,t.data)}))})))return{v:!1}},u=ta(null!==(r=null===(n=i.contentProtections)||void 0===n?void 0:n.initData)&&void 0!==r?r:[]);!(o=u()).done;)if(a=s())return a.v;return i.decipherable}))}var oa=new Map;var sa=new(function(){function e(){this._cachedCodecSupport=new Map}return e.prototype.isSupported=function(e,n){var r=(null!=e?e:"")+';codecs="'+(null!=n?n:"")+'"',i=this._cachedCodecSupport.get(r);if(void 0!==i)return i;this._cachedCodecSupport.size>=50&&this._cachedCodecSupport.clear();var o=function(e){if(t(Mr))return a&&T.error("Compat: Cannot request codec support in a worker without MSE."),!1;if("function"==typeof Mr.isTypeSupported){var n=oa.get(e);if(void 0!==n)return n;var r=Mr.isTypeSupported(e);return oa.size>=200&&oa.clear(),oa.set(e,r),r}return!0}(r);return this._cachedCodecSupport.set(r,o),o},e}());function ua(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return la(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return la(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function la(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function da(e,t){for(var n,r=e,i=ua(t);!(n=i()).done;){var a=ca(r,n.value);if(null===a)return null;r=a}return r}function ca(e,t){var n=fa(e,t);return null!==n?e.subarray(n[1],n[2]):null}function fa(e,t){for(var n,r,i=e.length,a=0,o=0;a+8<=i;){if(o=ei(e,r=a),n=ei(e,r+=4),r+=4,0===o)o=i-a;else if(1===o){if(r+8>i)return null;o=ti(e,r),r+=8}if(o<0)throw new Error("ISOBMFF: Size out of range");if(n===t)return 1970628964===t&&(r+=16),[a,r,a+o];a+=o}return null}function va(e,t,n,r,i){for(var a,o=e.length,s=0;s<o;s+=a){var u=s;a=ei(e,u);var l=ei(e,u+=4);if(u+=4,0===a)a=o-s;else if(1===a){if(u+8>o)return;a=ti(e,u),u+=8}if(1970628964===l&&u+16<=o&&ei(e,u)===t&&ei(e,u+4)===n&&ei(e,u+8)===r&&ei(e,u+12)===i)return u+=16,e.subarray(u,s+a)}}function pa(e){var t=e.length;if(t<8)return T.warn("ISOBMFF: box inferior to 8 bytes, cannot find offsets"),null;var n=0,r=ei(e,n),i=ei(e,n+=4);if(n+=4,0===r)r=t;else if(1===r){if(n+8>t)return T.warn("ISOBMFF: box too short, cannot find offsets"),null;r=ti(e,n),n+=8}if(r<0)throw new Error("ISOBMFF: Size out of range");return 1970628964===i&&(n+=16),[0,n,r]}function ha(e){var t=ca(e,1836019558);return null===t?null:ca(t,1953653094)}function ma(e){var t=function(e,t){for(var n=[],r=e;;){var i=fa(r,t);if(null===i)return n;$(0!==i[2]&&r.length),n.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}(e,1836019558);return t.reduce((function(e,t){var n=ca(t,1953653094);return null!==n&&e.push(n),e}),[])}function ga(e){return ca(e,1835295092)}function ya(e,t){return void 0===t&&(t=0),ca(e.subarray(t),1701671783)}var _a=/^(?:[a-z]+:)?\/\//i,ba=/\/\.{1,2}\//;function Sa(){var e=arguments.length;if(0===e)return"";for(var t="",n=0;n<e;n++){var r=n<0||arguments.length<=n?void 0:arguments[n];"string"==typeof r&&""!==r&&(_a.test(r)?t=r:("/"===r[0]&&(r=r.substring(1)),"/"===t[t.length-1]&&(t=t.substring(0,t.length-1)),t=t+"/"+r))}return function(e){if(!ba.test(e))return e;for(var t=[],n=e.split("/"),r=0,i=n.length;r<i;r++)if(".."===n[r])t.pop();else{if("."===n[r])continue;t.push(n[r])}return t.join("/")}(t)}function Ea(e){var t=e.lastIndexOf("/");if(t<0)return e.length;if(_a.test(e)){var n=e.indexOf("/");if(n>=0&&t===n+1)return e.length}var r=e.indexOf("?");return r>=0&&r<t?Ea(e.substring(0,r)):t+1}var Ta="object"==typeof s&&"function"==typeof s.TextDecoder,ka="object"==typeof s&&"function"==typeof s.TextEncoder;function wa(e){if(Ta)try{return new TextDecoder("utf-16le").decode(e)}catch(e){var t=e instanceof Error?e:"";T.warn("Utils: could not use TextDecoder to parse UTF-16LE, fallbacking to another implementation",t)}for(var n="",r=0;r<e.length;r+=2)n+=String.fromCharCode((e[r+1]<<8)+e[r]);return n}function Aa(e){if(ka)try{return(new TextEncoder).encode(e)}catch(e){var t=e instanceof Error?e:"";T.warn("Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation",t)}var n,r=encodeURIComponent(e);if("function"==typeof unescape)n=unescape(r);else{var i=/[0-9a-fA-F]/,a=r.length;n="";for(var o=0;o<r.length;o++){var s=!1;if("%"===r[o])if(o<=a-6&&"u"===r[o+1]&&i.test(r[o+2])&&i.test(r[o+3])&&i.test(r[o+4])&&i.test(r[o+5])){var u=parseInt(r.substring(o+1,o+6),16);n+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(r[o+1])&&i.test(r[o+2])){var l=parseInt(r.substring(o+1,o+3),16);n+=String.fromCharCode(l),s=!0,o+=2}s||(n+=r[o])}}for(var d=new Uint8Array(n.length),c=0;c<n.length;c++)d[c]=255&n.charCodeAt(c);return d}function Ia(e,t){var n=e.toString(16);return n.length>=t?n:new Array(t-n.length+1).join("0")+n}function Ra(e){if(Ta)try{return(new TextDecoder).decode(e)}catch(e){var t=e instanceof Error?e:"";T.warn("Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation",t)}var n=e;239===n[0]&&187===n[1]&&191===n[2]&&(n=n.subarray(3));var r,i=function(e){for(var t="",n=0;n<e.length;n+=16e3){var r=e.subarray(n,n+16e3);t+=String.fromCharCode.apply(null,r)}return t}(n);if("function"==typeof escape)r=escape(i);else{var a=/[A-Za-z0-9*_\+-\.\/]/;r="";for(var o=0;o<i.length;o++)if(a.test(i[o]))r+=i[o];else{var s=i.charCodeAt(o);r+=s>=256?"%u"+Ia(s,4):"%"+Ia(s,2)}}return decodeURIComponent(r)}function xa(e){for(var t=e.length,n=new Uint8Array(t/2),r=0,i=0;r<t;r+=2,i++)n[i]=255&parseInt(e.substring(r,r+2),16);return n}function Ca(e,t){void 0===t&&(t="");for(var n="",r=0;r<e.byteLength;r++)n+=(e[r]>>>4).toString(16),n+=(15&e[r]).toString(16),t.length>0&&r<e.byteLength-1&&(n+=t);return n}function Ma(e){$(e.length);var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=new Uint8Array(16);return l[0]=i,l[1]=r,l[2]=n,l[3]=t,l[4]=o,l[5]=a,l[6]=u,l[7]=s,l.set(e.subarray(8,16),8),l}function Pa(e,t){for(var n=t;n<e.length;){if(0===e[n])break;n+=1}return{end:n+1,string:Ra(e.subarray(t,n))}}var Da=Math.pow(2,32)-1,Oa={};function Na(e){if(void 0!==Oa[e])return Oa[e];var t=Aa(e);return Oa[e]=t,t}function La(e,t){var n=t.length+8;return n<=Da?Xr(ri(n),Na(e),t):Xr(ri(1),Na(e),ii(n+8),t)}function Ua(e,t){return La(e,Xr.apply(void 0,t))}function Fa(e){var t=[];e.periods.forEach((function(n){var r=n.id;if(Ue(t,r)){T.warn("Two periods with the same ID found. Updating.");var i=r+"-dup";n.id=i,Fa(e),t.push(i)}else t.push(r);var a=n.adaptations,o=[];Object.keys(a).forEach((function(t){var n=a[t];void 0!==n&&n.forEach((function(t){var n=t.id;if(Ue(o,n)){T.warn("Two adaptations with the same ID found. Updating.",n);var r=n+"-dup";t.id=r,Fa(e),o.push(r)}else o.push(n);var i=[];t.representations.forEach((function(t){var n=t.id;if(Ue(i,n)){T.warn("Two representations with the same ID found. Updating.",n);var r=n+"-dup";t.id=r,Fa(e),i.push(r)}else i.push(n)}))}))}))}))}var Ba=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],za=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function Va(e){if(e>=za.length)throw new Error("Unable to parse base64 string.");var t=za[e];if(255===t)throw new Error("Unable to parse base64 string.");return t}function Ka(e){var t,n="",r=e.length;for(t=2;t<r;t+=3)n+=Ba[e[t-2]>>2],n+=Ba[(3&e[t-2])<<4|e[t-1]>>4],n+=Ba[(15&e[t-1])<<2|e[t]>>6],n+=Ba[63&e[t]];return t===r+1&&(n+=Ba[e[t-2]>>2],n+=Ba[(3&e[t-2])<<4],n+="=="),t===r&&(n+=Ba[e[t-2]>>2],n+=Ba[(3&e[t-2])<<4|e[t-1]>>4],n+=Ba[(15&e[t-1])<<2],n+="="),n}function Wa(e){var t=e.length%4,n=e;0!==t&&(T.warn("base64ToBytes: base64 given miss padding"),n+=3===t?"=":2===t?"==":"===");var r=n.indexOf("=");if(-1!==r&&r<n.length-2)throw new Error("Unable to parse base64 string.");for(var i,a=n.endsWith("==")?2:n.endsWith("=")?1:0,o=n.length,s=new Uint8Array(o/4*3),u=0,l=0;u<o;u+=4,l+=3)i=Va(n.charCodeAt(u))<<18|Va(n.charCodeAt(u+1))<<12|Va(n.charCodeAt(u+2))<<6|Va(n.charCodeAt(u+3)),s[l]=i>>16,s[l+1]=i>>8&255,s[l+2]=255&i;return s.subarray(0,s.length-a)}function Ga(e){return[{systemId:"edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",privateData:Xr([8,1,18,16],e)}]}function ja(e,t){if(void 0===t&&(t=Ga),null===e.firstElementChild||"ProtectionHeader"!==e.firstElementChild.nodeName)throw new Error("Protection should have ProtectionHeader child");var n=e.firstElementChild,r=Wa(null===n.textContent?"":n.textContent),i=xa(function(e){var t,n,r=((t=e)[0+(n=8)]<<0)+(t[n+1]<<8),i=wa(e.subarray(10,r+10)),a=(new DOMParser).parseFromString(i,"application/xml").querySelector("KID");if(null===a)throw new Error("Cannot parse PlayReady private data: invalid XML");return Ca(Ma(Wa(null===a.textContent?"":a.textContent))).toLowerCase()}(r)),a=n.getAttribute("SystemID");return{keyId:i,keySystems:[{systemId:(null!==a?a:"").toLowerCase().replace(/\{|\}/g,""),privateData:r}].concat(t(i))}}function Ha(e,n,r){var i,a=e.repeatCount;return a>=0?a:(i=t(n)?void 0!==r?r:Number.MAX_VALUE:n.start,Math.ceil((i-e.start)/e.duration)-1)}function qa(e,t,n){var r=e.start,i=e.duration;return i<=0?r:r+(Ha(e,t,n)+1)*i}function Ya(e,t){var n;return e*t.timescale+(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0)}function Qa(e,t){var n;return(e-(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0))/t.timescale}function $a(e,t,n){var r=e.timeline,i=Ya(t,e);if(i<0)return null;var a=function(e,t){for(var n=0,r=e.length;n<r;){var i=n+r>>>1;e[i].start<=t?n=i+1:r=i}return n-1}(r,i);if(a<0||a>=r.length-1)return null;var o=r[a];if(o.duration<=0)return null;var s=r[a+1];if(void 0===s)return null;var u=s.start;return i>=qa(o,s,n)&&i<u?Qa(u,e):null}function Xa(e,t){return e.replace(/\{start time\}/g,String(t))}function Za(e,t,n){var r=t-e;return r>0?Math.floor(r/n):0}function Ja(e,t){var n=e.repeatCount;if(void 0!==e.duration&&n<0){var r=void 0!==t?t.start:1/0;n=Math.ceil((r-e.start)/e.duration)-1}return n}var eo=function(){function e(e){var t=e.isLive,n=e.segmentPrivateInfos,r=e.media,i=e.sharedSmoothTimeline;if(this._sharedSmoothTimeline=i,this._initSegmentInfos={bitsPerSample:n.bitsPerSample,channels:n.channels,codecPrivateData:n.codecPrivateData,packetSize:n.packetSize,samplingRate:n.samplingRate,timescale:i.timescale,height:n.height,width:n.width,protection:n.protection},this._isLive=t,this._media=r,0!==i.timeline.length&&t){var a=i.timeline,o=i.validityTime,s=qa(a[a.length-1],null),u=o/1e3*i.timescale;this._scaledLiveGap=u-s}}var t=e.prototype;return t.getInitSegment=function(){return{id:"init",isInit:!0,privateInfos:{smoothInitSegment:this._initSegmentInfos},url:null,time:0,end:0,duration:0,timescale:1,complete:!0}},t.getSegments=function(e,t){this._refreshTimeline();for(var n,r=this._sharedSmoothTimeline,i=r.timescale,a=r.timeline,o=function(e,t,n){var r=void 0===e||0===e?1:e;return{up:t*r,to:(t+n)*r}}(i,e,t),s=o.up,u=o.to,l=this._media,d=[],c=a.length,f=void 0===this._scaledLiveGap?void 0:ne()/1e3*i-this._scaledLiveGap,v=0;v<c;v++){for(var p=a[v],h=p.duration,m=p.start,g=Ja(p,a[v+1]),y=Za(m,s,h),_=m+y*h,b=h;_<u&&y<=g&&(void 0===f||_+b<=f);){var S=_,E=void 0!==n?n+y:void 0,T={id:String(_),isInit:!1,time:S/i,end:(S+h)/i,duration:h/i,timescale:1,number:E,url:Xa(l,S),complete:!0,privateInfos:{smoothMediaSegment:{time:S,duration:h}}};d.push(T),_=m+ ++y*h}if(_>=u)return d;void 0!==n&&(n+=g+1)}return d},t.shouldRefresh=function(e,t){if(this._refreshTimeline(),!this._isLive)return!1;var n=this._sharedSmoothTimeline,r=n.timeline,i=n.timescale,a=r[r.length-1];if(void 0===a)return!1;var o=a.repeatCount,s=a.start+(o+1)*a.duration;return!(t*i<s)&&(e*i>=s||e*i>a.start+o*a.duration)},t.getFirstAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;return 0===t.length?null:t[0].start/n},t.getLastAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;if(void 0===this._scaledLiveGap)return qa(t[t.length-1],null)/n;for(var r=t.length-1;r>=0;r--)for(var i=t[r],a=ne()/1e3*n,o=i.start,s=i.duration,u=i.repeatCount;u>=0;u--){var l=o+s*(u+1);if(l<=a-this._scaledLiveGap)return l/n}},t.getEnd=function(){if(!this._isLive)return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(e,t){var n;if($(),this.isStillAwaitingFutureSegments())return!1;var r=this.getLastAvailablePosition();return!(void 0!==r&&t<r)&&(t>(null!==(n=this.getFirstAvailablePosition())&&void 0!==n?n:0)&&void 0)},t.checkDiscontinuity=function(e){return this._refreshTimeline(),$a(this._sharedSmoothTimeline,e,void 0)},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline();for(var t=this._sharedSmoothTimeline,n=t.timeline,r=t.timescale,i=0;i<n.length;i++){var a=n[i],o=a.start/r;if(o>e.time)return!1;if(o===e.time)return!0;if(a.repeatCount>=0&&void 0!==a.duration){var s=(o-a.start)/a.duration-1;return s%1==0&&s<=a.repeatCount}}return!1},t.canBeOutOfSyncError=function(e){return!!this._isLive&&(e instanceof Pe&&(e.isHttpError(404)||e.isHttpError(412)))},t._replace=function(e){this._initialScaledLastPosition=e._initialScaledLastPosition,this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.replace(e._sharedSmoothTimeline)},t._update=function(e){this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.update(e._sharedSmoothTimeline)},t.isStillAwaitingFutureSegments=function(){return this._isLive},t.isInitialized=function(){return!0},t.initialize=function(){T.error("A `SmoothRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(e,t){this._sharedSmoothTimeline.addPredictedSegments(e,t)},t._refreshTimeline=function(){this._sharedSmoothTimeline.refresh()},e}();function to(e,t){for(var n=0;e.length>0;){var r=e[0];if(r.start>=t)return n;if(-1===r.repeatCount)return n;if(0===r.repeatCount)e.shift(),n+=1;else{var i=e[1];if(void 0!==i&&i.start<=t)e.shift(),n+=1;else{if(r.duration<=0)return n;for(var a=r.start+r.duration,o=1;a<t&&o<=r.repeatCount;)a+=r.duration,o++;if(!(o>r.repeatCount)){var s=r.repeatCount-o;return r.start=a,r.repeatCount=s,n+=o}e.shift(),n=r.repeatCount+1}}}return n}function no(e,t){if(0===e.length)return e.push.apply(e,t),!0;if(0===t.length)return!1;var n=e.length,r=t[0].start;if(qa(e[n-1],t[0])<r)throw new Me("MANIFEST_UPDATE_ERROR","Cannot perform partial update: not enough data");for(var i=n-1;i>=0;i--){var a=e[i].start;if(a===r){var o=n-i;return e.splice.apply(e,[i,o].concat(t)),!1}if(a<r){var s=e[i];if(s.start+s.duration>r)return T.warn("RepresentationIndex: Manifest update removed all previous segments"),e.splice.apply(e,[0,n].concat(t)),!0;if(void 0===s.repeatCount||s.repeatCount<=0)return s.repeatCount<0&&(s.repeatCount=Math.floor((r-s.start)/s.duration)-1),e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1;if(s.start+s.duration*(s.repeatCount+1)<=r)return e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1;var u=(r-s.start)/s.duration-1;if(u%1==0&&s.duration===t[0].duration){var l=t[0].repeatCount<0?-1:t[0].repeatCount+u+1;return e.splice.apply(e,[i,n-i].concat(t)),e[i].start=s.start,e[i].repeatCount=l,!1}return T.warn("RepresentationIndex: Manifest update removed previous segments"),e[i].repeatCount=Math.floor(u),e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1}}var d=e[e.length-1],c=t[t.length-1];return void 0!==d.repeatCount&&d.repeatCount<0?d.start>c.start?(T.warn("RepresentationIndex: The new index is older than the previous one"),!1):(T.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0):d.start+d.duration*(d.repeatCount+1)>=c.start+c.duration*(c.repeatCount+1)?(T.warn("RepresentationIndex: The new index is older than the previous one"),!1):(T.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0)}function ro(e,t,n,r){var i=e[e.length-1],a=n.timescale===t?{time:n.time,duration:n.duration}:{time:n.time/n.timescale*t,duration:n.duration/n.timescale*t};return!(r.time===a.time)&&(a.time>=qa(i,null)&&(i.duration===a.duration?i.repeatCount++:e.push({duration:a.duration,start:a.time,repeatCount:0}),!0))}var io=function(){function e(e){var t=e.timeline,n=e.timescale,r=e.timeShiftBufferDepth,i=e.manifestReceivedTime;this.timeline=t,this.timescale=n;var a=null!=i?i:ne();if(this.validityTime=a,this._timeShiftBufferDepth=r,0!==t.length){var o=qa(t[t.length-1],null);this._initialScaledLastPosition=o}}var t=e.prototype;return t.refresh=function(){if(void 0!==this._initialScaledLastPosition){var e=this._timeShiftBufferDepth,t=(ne()-this.validityTime)/1e3+this._initialScaledLastPosition/this.timescale;if(void 0!==e){var n=(t-e)*this.timescale;to(this.timeline,n)}}},t.replace=function(e){var t=this.timeline,n=e.timeline,r=this.timescale,i=e.timescale;if(this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime,0!==t.length&&0!==n.length&&r===i){var a=t[t.length-1],o=n[n.length-1],s=qa(o,null);if(!(qa(a,null)<=s))for(var u=0;u<t.length;u++){var l=t[u],d=qa(l,null);if(d===s)return void(this.timeline=this.timeline.concat(t.slice(u+1)));if(d>s){if(l.duration!==o.duration)return;var c=s-l.start;if(0===c)return T.warn("Smooth Parser: a discontinuity detected in the previous manifest has been resolved."),void(this.timeline=this.timeline.concat(t.slice(u)));if(c<0||c%l.duration!=0)return;var f=c/l.duration-1,v=l.repeatCount-f;if(v<0)return;o.repeatCount+=v;var p=t.slice(u+1);return void(this.timeline=this.timeline.concat(p))}}}},t.update=function(e){no(this.timeline,e.timeline),this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime},t.addPredictedSegments=function(e,t){var n;if(void 0!==(null===(n=t.privateInfos)||void 0===n?void 0:n.smoothMediaSegment)){this.refresh();for(var r=0;r<e.length;r++)ro(this.timeline,this.timescale,e[r],t.privateInfos.smoothMediaSegment)}else T.warn("Smooth Parser: should only encounter SmoothRepresentationIndex")},e}();function ao(e,t,n){for(var r=e.firstElementChild,i=n;null!==r;)i=t(i,r.nodeName,r),r=r.nextElementSibling;return i}var oo={audio:"audio/mp4",video:"video/mp4",text:"application/ttml+xml"},so={AACL:"audio/mp4",AVC1:"video/mp4",H264:"video/mp4",TTML:"application/ttml+xml+mp4",DFXP:"application/ttml+xml+mp4"};var uo=function(e){void 0===e&&(e={});var n=void 0===e.referenceDateTime?Date.UTC(1970,0,1,0,0,0,0)/1e3:e.referenceDateTime,r=void 0===e.minRepresentationBitrate?0:e.minRepresentationBitrate,i=e.serverSyncInfos,a=void 0!==i?i.serverTimestamp-i.clientTime:void 0;function o(e,t){var n=ao(e,(function(e,t,n){return"CustomAttributes"===t&&e.push.apply(e,ao(n,(function(e,t,n){if("Attribute"===t){var r=n.getAttribute("Name"),i=n.getAttribute("Value");null!==r&&null!==i&&e.push(r+"="+i)}return e}),[])),e}),[]);function r(t){var n=e.getAttribute(t);return null===n?void 0:n}switch(t){case"audio":var i=r("AudioTag"),a=r("BitsPerSample"),o=r("Channels"),s=r("CodecPrivateData"),u=r("FourCC"),l=r("PacketSize"),d=r("SamplingRate"),c=r("Bitrate"),f=void 0===c?0:parseInt(c,10);if(f=isNaN(f)?0:f,void 0!==u&&void 0===so[u]||void 0===s)return T.warn("Smooth parser: Unsupported audio codec. Ignoring quality level."),null;var v=function(e,t){var n;return 0==(n="AACH"===t?5:et(e)?(248&parseInt(e.substring(0,2),16))>>3:2)?"mp4a.40.2":"mp4a.40."+n}(s,u);return{audiotag:void 0!==i?parseInt(i,10):i,bitrate:f,bitsPerSample:void 0!==a?parseInt(a,10):a,channels:void 0!==o?parseInt(o,10):o,codecPrivateData:s,codecs:v,customAttributes:n,mimeType:void 0!==u?so[u]:u,packetSize:void 0!==l?parseInt(l,10):l,samplingRate:void 0!==d?parseInt(d,10):d};case"video":var p=r("CodecPrivateData"),h=r("FourCC"),m=r("MaxWidth"),g=r("MaxHeight"),y=r("Bitrate"),_=void 0===y?0:parseInt(y,10);if(_=isNaN(_)?0:_,void 0!==h&&void 0===so[h]||void 0===p)return T.warn("Smooth parser: Unsupported video codec. Ignoring quality level."),null;var b=function(e){var t=/00000001\d7([0-9a-fA-F]{6})/.exec(e);return null!==t&&et(t[1])?"avc1."+t[1]:"avc1.4D401E"}(p);return{bitrate:_,customAttributes:n,mimeType:void 0!==h?so[h]:h,codecPrivateData:p,codecs:b,width:void 0!==m?parseInt(m,10):void 0,height:void 0!==g?parseInt(g,10):void 0};case"text":var S=r("CodecPrivateData"),E=r("FourCC"),k=r("Bitrate"),w=void 0===k?0:parseInt(k,10);return{bitrate:w=isNaN(w)?0:w,customAttributes:n,mimeType:void 0!==E?so[E]:E,codecPrivateData:null!=S?S:""};default:return T.error("Smooth Parser: Unrecognized StreamIndex type: "+t),null}}function s(e){var n=e.root,i=e.timescale,a=e.baseUrl,s=e.protections,u=e.timeShiftBufferDepth,l=e.manifestReceivedTime,d=e.isLive,c=n.getAttribute("Timescale"),f=null===c?i:+c;isNaN(f)&&(f=i);var v=n.getAttribute("Type");if(null===v)throw new Error("StreamIndex without type.");Ue(ze,v)||T.warn("Smooth Parser: Unrecognized adaptation type:",v);var p=v,h=n.getAttribute("Subtype"),g=n.getAttribute("Language"),y=n.getAttribute("Url"),_=null===y?"":y;var b,S=ao(n,(function(e,t,n){switch(t){case"QualityLevel":var i=o(n,p);if(null===i)return e;("video"!==p||i.bitrate>r)&&e.qualityLevels.push(i);break;case"c":e.cNodes.push(n)}return e}),{qualityLevels:[],cNodes:[]}),E=S.qualityLevels,k=S.cNodes,w=new io({timeline:(b=k,b.reduce((function(e,t,n){var r=t.getAttribute("d"),i=t.getAttribute("t"),a=t.getAttribute("r"),o=null!==a?+a-1:0,s=null!==i?+i:void 0,u=null!==r?+r:void 0;if(0===n)s=void 0===s||isNaN(s)?0:s;else{var l=e[n-1];if(void 0===s||isNaN(s)){if(void 0===l.duration||isNaN(l.duration))throw new Error("Smooth: Invalid CNodes. Missing timestamp.");s=l.start+l.duration*(l.repeatCount+1)}}if(void 0===u||isNaN(u)){var d=b[n+1];if(void 0===d)return e;var c=d.getAttribute("t"),f=et(c)?+c:null;if(null===f)throw new Error("Can't build index timeline from Smooth Manifest.");u=f-s}return e.push({duration:u,start:s,repeatCount:o}),e}),[])),timescale:f,timeShiftBufferDepth:u,manifestReceivedTime:l});$(E.length);var A=p+(et(g)?"_"+g:""),I=E.map((function(e){var n,r,i,o,u=(n=_,r=e.bitrate,i=e.customAttributes,n.replace(/\{bitrate\}/g,String(r)).replace(/{CustomAttributes}/g,i.length>0?i[0]:"")),l=et(e.mimeType)?e.mimeType:oo[p],c=e.codecs,f=A+"_"+(t(p)?"":p+"-")+(t(l)?"":l+"-")+(t(c)?"":c+"-")+String(e.bitrate),v=[];s.length>0&&(o=s[0],s.forEach((function(e){var t=e.keyId;e.keySystems.forEach((function(e){v.push({keyId:t,systemId:e.systemId})}))})));var h={bitsPerSample:e.bitsPerSample,channels:e.channels,codecPrivateData:e.codecPrivateData,packetSize:e.packetSize,samplingRate:e.samplingRate,height:e.height,width:e.width,protection:t(o)?void 0:{keyId:o.keyId}},g=new eo({isLive:d,sharedSmoothTimeline:w,media:u,segmentPrivateInfos:h}),y=m({},e,{index:g,cdnMetadata:[{baseUrl:a}],mimeType:l,codecs:c,id:f});if(v.length>0||void 0!==o){var b=void 0===o?[]:o.keySystems.map((function(e){var t=e.systemId,n=e.privateData,r=t.replace(/-/g,""),i=function(e,t){if(32!==e.length)throw new Error("HSS: wrong system id length");return La("pssh",Xr([0,0,0,0],xa(e),ri(t.length),t))}(r,n);return{systemId:r,data:i}}));if(b.length>0){var S=[{type:"cenc",values:b}];y.contentProtections={keyIds:v,initData:S}}else y.contentProtections={keyIds:v,initData:[]}}return y}));if("ADVT"===h)return null;var R={id:A,type:p,representations:I,language:null===g?void 0:g};return"text"===p&&"DESC"===h&&(R.closedCaption=!0),R}return function(r,i,o){var u="";if(void 0!==i){var l=Ea(i);u=i.substring(0,l)}var d=r.documentElement;if(t(d)||"SmoothStreamingMedia"!==d.nodeName)throw new Error("document root should be SmoothStreamingMedia");var c=d.getAttribute("MajorVersion"),f=d.getAttribute("MinorVersion");if(null===c||null===f||!/^[2]-[0-2]$/.test(c+"-"+f))throw new Error("Version should be 2.0, 2.1 or 2.2");var v=d.getAttribute("Timescale"),p=et(v)?+v:1e7;isNaN(p)&&(p=1e7);var h,m,g=ao(d,(function(t,n,r){switch(n){case"Protection":t.protections.push(ja(r,e.keySystems));break;case"StreamIndex":t.adaptationNodes.push(r)}return t}),{adaptationNodes:[],protections:[]}),y=g.protections,_=g.adaptationNodes,b="boolean"==typeof(h=d.getAttribute("IsLive"))?h:"string"==typeof h&&"TRUE"===h.toUpperCase();if(b){var S=d.getAttribute("DVRWindowLength");null===S||isNaN(+S)||0==+S||(m=+S/p)}var E,T,k,w,A,I,R,x=_.reduce((function(e,t){var n=s({root:t,baseUrl:u,timescale:p,protections:y,isLive:b,timeShiftBufferDepth:m,manifestReceivedTime:o});if(null===n)return e;var r=n.type,i=e[r];return void 0===i?e[r]=[n]:i.push(n),e}),{}),C=null,M=void 0!==x.video?x.video[0]:void 0,P=void 0!==x.audio?x.audio[0]:void 0;if(void 0!==M||void 0!==P){var D=[],O=[];if(void 0!==M){var N=M.representations[0];if(void 0!==N){var L=N.index.getFirstAvailablePosition(),U=N.index.getLastAvailablePosition();t(L)||D.push(L),t(U)||O.push(U)}}if(void 0!==P){var F=P.representations[0];if(void 0!==F){var B=F.index.getFirstAvailablePosition(),z=F.index.getLastAvailablePosition();t(B)||D.push(B),t(z)||O.push(z)}}D.length>0&&(A=Math.max.apply(Math,D)),O.length>0&&(I=Math.min.apply(Math,O),R=Math.max.apply(Math,O))}var V=d.getAttribute("Duration"),K=null!==V&&0!=+V?+V/p:void 0;if(b){E=e.suggestedPresentationDelay,T=n,k=null!=A?A:T;var W=R;void 0===W&&(W=Date.now()/1e3-T);var G=I;void 0===G&&(G=W),w={isLinear:!0,maximumSafePosition:G,livePosition:W,time:ne()},C=null!=m?m:null}else{k=null!=A?A:0;var j=I;void 0===j&&(j=void 0!==K?k+K:1/0),w={isLinear:!1,maximumSafePosition:j,livePosition:void 0,time:ne()}}var H=b?0:k,q=b?void 0:w.maximumSafePosition,Y={availabilityStartTime:void 0===T?0:T,clockOffset:a,isLive:b,isDynamic:b,isLastPeriodKnown:!0,timeBounds:{minimumSafePosition:k,timeshiftDepth:C,maximumTimeData:w},periods:[{adaptations:x,duration:void 0!==q?q-H:K,end:q,id:"gen-smooth-period-0",start:H}],suggestedPresentationDelay:E,transportType:"smooth",uris:t(i)?[]:[i]};return Fa(Y),Y}},lo=uo;var co=function(e){var n={url:e.url,headers:e.headers,responseType:t(e.responseType)?"json":e.responseType,timeout:e.timeout,connectionTimeout:e.connectionTimeout};return new Promise((function(r,i){var a,o,s=e.onProgress,u=e.cancelSignal,l=n.url,d=n.headers,c=n.responseType,f=n.timeout,v=n.connectionTimeout,p=new XMLHttpRequest;if(p.open("GET",l,!0),void 0!==f&&(p.timeout=f,a=setTimeout((function(){_(),i(new ke(l,p.status,we.TIMEOUT))}),f+3e3)),void 0!==v&&(o=setTimeout((function(){_(),p.readyState!==XMLHttpRequest.DONE&&p.abort(),i(new ke(l,p.status,we.TIMEOUT))}),v)),p.responseType=c,"document"===p.responseType&&p.overrideMimeType("text/xml"),!t(d)){var h=d;for(var m in h)h.hasOwnProperty(m)&&p.setRequestHeader(m,h[m])}var g=ne(),y=null;function _(){void 0!==a&&clearTimeout(a),void 0!==o&&clearTimeout(o),null!==y&&y()}void 0!==u&&(y=u.register((function(e){_(),p.readyState!==XMLHttpRequest.DONE&&p.abort(),i(e)})),u.isCancelled())||(p.onerror=function(){_(),i(new ke(l,p.status,we.ERROR_EVENT))},p.ontimeout=function(){_(),i(new ke(l,p.status,we.TIMEOUT))},void 0!==v&&(p.onreadystatechange=function(){p.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(o)}),void 0!==s&&(p.onprogress=function(e){var t=ne();s({url:l,duration:t-g,sendingTime:g,currentTime:t,size:e.loaded,totalSize:e.total})}),p.onload=function(e){if(p.readyState===XMLHttpRequest.DONE)if(_(),p.status>=200&&p.status<300){var n,a=ne(),o=p.response instanceof ArrayBuffer?p.response.byteLength:e.total,s=p.status,u=p.responseType,d=et(p.responseURL)?p.responseURL:l;if(t(n="json"===u?"object"==typeof p.response?p.response:function(e){try{return JSON.parse(e)}catch(e){return null}}(p.responseText):p.response))return void i(new ke(l,p.status,we.PARSE_ERROR));r({status:s,url:d,responseType:u,sendingTime:g,receivedTime:a,requestDuration:a-g,size:o,responseData:n})}else i(new ke(l,p.status,we.ERROR_HTTP_CODE))},p.send())}))};function fo(e,t){for(var n=e.length,r=0;r+8<=n;){var i=ei(e,r);if(0===i)i=n-r;else if(1===i){if(r+16>n)return-1;i=ti(e,r+8)}if(isNaN(i)||i<=0)return-1;if(ei(e,r+4)===t)return r+i<=n?r:-1;r+=i}return-1}function vo(e,t){if(t){if(fo(e,1718909296)<0)throw new De("INTEGRITY_ERROR","Incomplete `ftyp` box");if(fo(e,1836019574)<0)throw new De("INTEGRITY_ERROR","Incomplete `moov` box")}else{if(fo(e,1836019558)<0)throw new De("INTEGRITY_ERROR","Incomplete `moof` box");if(fo(e,1835295092)<0)throw new De("INTEGRITY_ERROR","Incomplete `mdat` box")}}function po(e,t){var n=e.customManifestLoader,r=function(e){return function(t,n,r){if(void 0===t)throw new Error("Cannot perform HTTP(s) request. URL not known");switch(e){case"arraybuffer":return co({url:t,responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});case"text":return co({url:t,responseType:"text",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});case"document":return co({url:t,responseType:"document",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});default:X()}}}(t);return"function"!=typeof n?r:function(e,t){return function(n,r,i){return new Promise((function(a,o){var s=Date.now()-ne(),u=!1,l={reject:function(e){var t,n;if(!u&&!i.isCancelled()){u=!0,i.deregister(c);var r=e,a=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching the Manifest through a custom manifestLoader.",s=new xt(a,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);o(s)}},resolve:function(e){if(!u&&!i.isCancelled()){u=!0,i.deregister(c);var t=void 0!==e.receivingTime?e.receivingTime-s:void 0,n=void 0!==e.sendingTime?e.sendingTime-s:void 0;a({responseData:e.data,size:e.size,requestDuration:e.duration,url:e.url,receivedTime:t,sendingTime:n})}},fallback:function(){u||i.isCancelled()||(u=!0,i.deregister(c),t(n,r,i).then(a,o))}},d=e({url:n,timeout:r.timeout},l);function c(e){u||(u=!0,"function"==typeof d&&d(),o(e))}i.register(c)}))}}(n,r)}function ho(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mo(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mo(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function mo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function go(e,t){var n=fa(e,1936286840);if(null===n)return null;var r,i=t,a=n[2]-n[0],o=n[1],s=e[o],u=ei(e,o+=8);if(o+=4,0===s)r=ei(e,o),i+=ei(e,o+=4)+a,o+=4;else{if(1!==s)return null;r=ti(e,o),i+=ti(e,o+=8)+a,o+=8}var l=[],d=Zr(e,o+=2);for(o+=2;--d>=0;){var c=ei(e,o);o+=4;var f=2147483647&c;if(1===(2147483648&c)>>>31)throw new Error("sidx with reference_type `1` not yet implemented");var v=ei(e,o);o+=4,o+=4,l.push({time:r,duration:v,timescale:u,range:[i,i+f-1]}),r+=v,i+=f}return l}function yo(e){var t=ca(e,1952868452);if(null!==t){var n=1,r=Jr(t,n);if(n+=3,(8&r)>0)return n+=4,(1&r)>0&&(n+=8),(2&r)>0&&(n+=4),ei(t,n)}}function _o(e){var t=ma(e);if(0!==t.length){for(var n,r=0,i=ho(t);!(n=i()).done;){var a=n.value,o=ca(a,1953658222);if(null===o)return;var s=0;if(o[s]>1)return;var u=Jr(o,s+=1);s+=3;var l=(256&u)>0,d=0;if(!l&&void 0===(d=yo(a)))return;var c=(1&u)>0,f=(4&u)>0,v=(512&u)>0,p=(1024&u)>0,h=(2048&u)>0,m=ei(o,s);s+=4,c&&(s+=4),f&&(s+=4);for(var g=m,y=0;g-- >0;)l?(y+=ei(o,s),s+=4):y+=d,v&&(s+=4),p&&(s+=4),h&&(s+=4);r+=y}return r}}function bo(e){var t=function(e){var t=ca(e,1836019574);if(null===t)return null;var n=ca(t,1953653099);return null===n?null:ca(n,1835297121)}(e);if(null!==t){var n=ca(t,1835296868);if(null!==n){var r=0,i=n[r];return r+=4,1===i?ei(n,r+16):0===i?ei(n,r+8):void 0}}}function So(e){var t=e.length;if(t<4)throw new Error("Cannot update box length: box too short");var n=ei(e,0);if(0===n){if(t>Da){var r=new Uint8Array(t+8);return r.set(ri(1),0),r.set(e.subarray(4,8),4),r.set(ii(t+8),8),r.set(e.subarray(8,t),16),r}return e.set(ri(t),0),e}if(1===n){if(t<16)throw new Error("Cannot update box length: box too short");return e.set(ii(t),8),e}if(t<=Da)return e.set(ri(t),0),e;var i=new Uint8Array(t+8);return i.set(ri(1),0),i.set(e.subarray(4,8),4),i.set(ii(t+8),8),i.set(e.subarray(8,t),16),i}function Eo(e,t,n,r,i){var a,o,s,u=[];if(i){var l=ha(e);null!==l?(s=function(e){var t=va(e,3565190898,3392751253,2387879627,2655430559);if(void 0===t)return[];for(var n=[],r=t[0],i=t[4],a=0;a<i;a++){var o=void 0,s=void 0;1===r?(s=ti(t,16*a+5),o=ti(t,16*a+5+8)):(s=ei(t,8*a+5),o=ei(t,8*a+5+4)),n.push({time:s,duration:o})}return n}(l),o=function(e){var t=va(e,1830656773,1121273062,2162299933,2952222642);if(void 0!==t)return{duration:ti(t,12),time:ti(t,4)}}(l)):T.warn("smooth: could not find traf atom")}if(void 0!==s)for(var d=0;d<s.length;d++)u.push({time:s[d].time,duration:s[d].duration,timescale:n});if(void 0!==o)return{nextSegments:u,chunkInfos:{time:o.time/n,duration:o.duration/n},scaledSegmentTime:o.time};if(t||!r.complete)return{nextSegments:u,chunkInfos:null,scaledSegmentTime:void 0};var c=r.duration*n,f=Math.min(.9*n,c/4),v=_o(e),p=void 0!==(null===(a=r.privateInfos)||void 0===a?void 0:a.smoothMediaSegment)?r.privateInfos.smoothMediaSegment.time:Math.round(r.time*n);return{nextSegments:u,chunkInfos:void 0!==v&&Math.abs(v-c)<=f?{time:r.time,duration:v/n}:{time:r.time,duration:r.duration},scaledSegmentTime:p}}function To(e){return"string"==typeof e&&e.indexOf("mp4")>=0}function ko(e,t){return La("schm",Xr(4,Aa(e),ri(t)))}function wo(e){return La("frma",Aa(e))}function Ao(e){var t=[7,[e.length]];return La("stsd",Xr.apply(void 0,t.concat(e)))}function Io(e,t,n){return La("tenc",Xr(6,[e,t],n))}function Ro(e,t,n,r,i){var a=[e,t,n];return void 0!==i&&a.push(La("senc",i),function(e){if(0===e.length)return La("saiz",new Uint8Array(0));var t=ei(e,0),n=ei(e,4),r=new Uint8Array(n+9);r.set(ri(n),5);for(var i,a,o=9,s=8;s<e.length;)s+=8,2==(2&t)?(a=2,s+=6*(i=Zr(e,s))+2):(i=0,a=0),r[o]=6*i+8+a,o++;return La("saiz",r)}(i),function(e,t,n,r){return La("saio",Xr(4,[0,0,0,1],ri(e.length+t.length+n.length+r.length+8+8+8+8)))}(r,e,t,n)),Ua("traf",a)}function xo(e,t){var n=fa(e,1836019558);if(null===n)throw new Error("Smooth: Invalid ISOBMFF given");var r=e.subarray(n[1],n[2]),i=function(e,t){var n=fa(e,t);return null!==n?e.subarray(n[0],n[2]):null}(r,1835427940),a=ca(r,1953653094);if(null===a||null===i)throw new Error("Smooth: Invalid ISOBMFF given");var o=fa(a,1952868452),s=fa(a,1953658222);if(null===o||null===s)throw new Error("Smooth: Invalid ISOBMFF given");var u=a.subarray(o[0],o[2]),l=a.subarray(s[0],s[2]);u.set([0,0,0,1],o[1]-o[0]+4);var d=function(e){return La("tfdt",Xr([1,0,0,0],ii(e)))}(t),c=function(e,t){var n=(1&e[t+3])>0;if(n)return e;var r=new Uint8Array(e.length+4);return r.set(e.subarray(0,t+8),0),r[t+3]=1|r[t+3],r.set([0,0,0,0],t+8),r.set(e.subarray(t+8,e.length),t+12),So(r)}(l,s[1]-s[0]),f=Ro(u,d,c,i,va(a,2721664850,1520127764,2722393154,2086964724)),v=Ua("moof",[i,f]),p=fa(v,1836019558),h=fa(f,1953653094),m=fa(c,1953658222);if(null===p||null===h||null===m)throw new Error("Smooth: Invalid moof, trun or traf generation");var g=p[1]-p[0]+i.length+(h[1]-h[0])+u.length+d.length+(m[1]-m[0])+8,y=n[2]-n[0],_=v.length-y,b=fa(e,1835295092);if(null===b)throw new Error("Smooth: Invalid ISOBMFF given");if(!pi&&(0===_||_<=-8)){var S=b[1];return v.set(ri(S),g),e.set(v,n[0]),_<=-8&&e.set(La("free",new Uint8Array(-_-8)),v.length),e}var E=b[1]+_;v.set(ri(E),g);var T=new Uint8Array(e.length+_),k=e.subarray(0,n[0]),w=e.subarray(n[2],e.length);return T.set(k,0),T.set(v,k.length),T.set(w,k.length+v.length),T}function Co(e){var t=e[0],n=e[1];return n===1/0?"bytes="+t+"-":"bytes="+t+"-"+n}function Mo(e,t,n,r,i,a){var o,s,u=Ua("stbl",[n,La("stts",new Uint8Array(8)),La("stsc",new Uint8Array(8)),La("stsz",new Uint8Array(12)),La("stco",new Uint8Array(8))]),l=function(e){return La("dref",Xr(7,[1],e))}(La("url ",new Uint8Array([0,0,0,1]))),d=Ua("dinf",[l]),c=Ua("minf",[r,d,u]),f=function(e){var t,n;switch(e){case"video":t="vide",n="VideoHandler";break;case"audio":t="soun",n="SoundHandler";break;default:t="hint",n=""}return La("hdlr",Xr(8,Aa(t),12,Aa(n),1))}(t),v=function(e){return La("mdhd",Xr(12,ri(e),8))}(e),p=Ua("mdia",[v,f,c]),h=function(e,t,n){return La("tkhd",Xr(ri(7),8,ri(n),20,[1,0,0,0],[0,1,0,0],12,[0,1,0,0],12,[64,0,0,0],ni(e),2,ni(t),2))}(i,a,1),m=Ua("trak",[h,p]),g=Ua("mvex",[La("trex",Xr(4,ri(1),[0,0,0,1],12))]),y=function(e,t){return La("mvhd",Xr(12,ri(e),4,[0,1],2,[1,0],10,[0,1],14,[0,1],14,[64,0,0,0],26,ni(t+1)))}(e,1),_=function(e,t,n){return Ua("moov",[e,t,n])}(y,g,m),b=(o="isom",s=["isom","iso2","iso6","avc1","dash"],La("ftyp",Xr.apply(void 0,[Aa(o),[0,0,0,1]].concat(s.map(Aa)))));return Xr(b,_)}function Po(e,t,n,r,i,a,o,s){var u=o.split("00000001"),l=u[1],d=u[2];if(void 0===l||void 0===d)throw new Error("Smooth: unsupported codec private data.");var c,f,v=function(e,t,n){var r;return r=2===n?1:4===n?3:0,La("avcC",Xr([1,e[1],e[2],e[3],252|r,225],ni(e.length),e,[1],ni(t.length),t))}(xa(l),xa(d),a);if(void 0===s){var p=function(e,t,n,r,i,a,o){return La("avc1",Xr(6,ni(1),16,ni(e),ni(t),ni(n),2,ni(r),6,[0,1,i.length],Aa(i),31-i.length,ni(a),[255,255],o))}(t,n,r,i,"AVC Coding",24,v);c=Ao([p])}else{var h=Ua("schi",[Io(1,8,s)]),m=ko("cenc",65536),g=function(e,t,n,r,i,a,o,s){return La("encv",Xr(6,ni(1),16,ni(e),ni(t),ni(n),2,ni(r),6,[0,1,i.length],Aa(i),31-i.length,ni(a),[255,255],o,s))}(t,n,r,i,"AVC Coding",24,v,Ua("sinf",[wo("avc1"),m,h]));c=Ao([g])}return Mo(e,"video",c,((f=new Uint8Array(12))[3]=1,La("vmhd",f)),t,n)}var Do=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function Oo(e,t,n,r,i,a,o){var s,u,l=function(e,t){return La("esds",Xr(4,[3,25],ni(e),[0,4,17,64,21],11,[5,2],xa(t),[6,1,2]))}(1,0===a.length?(s=i,u=t,Ca(ni((((63&2)<<4|31&Do.indexOf(s))<<4|31&u)<<3))):a),d=function(){if(void 0===o){var e=function(e,t,n,r,i,a){return La("mp4a",Xr(6,ni(e),8,ni(t),ni(n),2,ni(r),ni(i),2,a))}(1,t,n,r,i,l);return Ao([e])}var a=Ua("schi",[Io(1,8,o)]),s=ko("cenc",65536),u=Ua("sinf",[wo("mp4a"),s,a]),d=function(e,t,n,r,i,a,o){return La("enca",Xr(6,ni(e),8,ni(t),ni(n),2,ni(r),ni(i),2,a,o))}(1,t,n,r,i,l,u);return Ao([d])}();return Mo(e,"audio",d,La("smhd",new Uint8Array(8)),0,0)}function No(e,t,n,r,i,a){var o,s=t.segment.range;return Array.isArray(s)&&(o={Range:Co(s)}),co({url:e,responseType:"arraybuffer",headers:o,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:n.onProgress}).then((function(e){if(!To(t.mimeType)||!0!==a)return{resultType:"segment-loaded",resultData:e};var n=new Uint8Array(e.responseData);return vo(n,t.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},e),{responseData:n})}}))}var Lo=function(e){var t=e.checkMediaSegmentIntegrity,n=e.segmentLoader;return function(e,r,i,a,o){var s=r.segment;if(s.isInit){if(void 0===s.privateInfos||void 0===s.privateInfos.smoothInitSegment)throw new Error("Smooth: Invalid segment format");var u,l=s.privateInfos.smoothInitSegment,d=l.codecPrivateData,c=l.timescale,f=l.height,v=l.width,p=l.protection,h=void 0===p?{keyId:void 0,keySystems:void 0}:p;if(void 0===d)throw new Error("Smooth: no codec private data.");switch(r.type){case"video":u=Po(c,null!=v?v:0,null!=f?f:0,72,72,4,d,h.keyId);break;case"audio":var m=l.channels,g=void 0===m?0:m,y=l.bitsPerSample,_=void 0===y?0:y,b=l.packetSize,S=void 0===b?0:b,E=l.samplingRate;u=Oo(c,g,_,S,void 0===E?0:E,d,h.keyId);break;default:0,u=new Uint8Array(0)}return Promise.resolve({resultType:"segment-created",resultData:u})}return null===e?Promise.resolve({resultType:"segment-created",resultData:null}):"function"!=typeof n?No(e,r,o,i,a,t):new Promise((function(s,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a Smooth segment through a custom segmentLoader.",o=new xt(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(e){if(!d&&!a.isCancelled()){d=!0,a.deregister(p),To(r.mimeType)&&!0===t||s({resultType:"segment-loaded",resultData:{responseData:e.data,size:e.size,requestDuration:e.duration}});var n=e.data instanceof Uint8Array?e.data:new Uint8Array(e.data);vo(n,r.segment.isInit),s({resultType:"segment-loaded",resultData:{responseData:n,size:e.size,requestDuration:e.duration}})}},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),No(e,r,o,i,a,t).then(s,u))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:e},v=n(f,c);function p(e){d||((d=!0)||"function"!=typeof v||v(),u(e))}a.register(p)}))}};function Uo(e,t){return null===e?null:null===t.url?e.baseUrl:Sa(e.baseUrl,t.url)}var Fo=function(e){var t=lo(e),n=Lo(e),r={loadManifest:po({customManifestLoader:e.manifestLoader},"text"),parseManifest:function(n,r){var i,a=null!==(i=n.url)&&void 0!==i?i:r.originalUrl,o=n.receivedTime,s=n.responseData,u="string"==typeof s?(new DOMParser).parseFromString(s,"text/xml"):s,l=t(u,a,o),d=[];return{manifest:new It(l,{representationFilter:e.representationFilter},d),url:a,warnings:d}}},i={loadSegment:function(e,t,r,i,a){var o=Uo(e,t.segment);return n(o,t,r,i,a)},parseSegment:function(e,t,n){var r,i,a=t.segment,o=e.data,s=e.isChunked;if(null===o)return a.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var u=o instanceof Uint8Array?o:new Uint8Array(o);if(a.isInit){var l=null===(i=null===(r=a.privateInfos)||void 0===r?void 0:r.smoothInitSegment)||void 0===i?void 0:i.timescale;return{segmentType:"init",initializationData:o,initializationDataSize:o.byteLength,initTimescale:l,protectionData:[]}}var d=void 0!==n?Eo(u,s,n,a,t.isLive):null;if(null===d||null===d.chunkInfos||void 0===d.scaledSegmentTime)throw new Error("Smooth Segment without time information");var c=d.nextSegments,f=d.chunkInfos,v=xo(u,d.scaledSegmentTime),p=c.length>0?c:void 0;return{segmentType:"media",chunkData:v,chunkInfos:f,chunkOffset:0,chunkSize:v.length,protectionData:[],predictedSegments:p,appendWindow:[void 0,void 0]}}},a={loadSegment:function(t,n,r,i,a){var o=n.segment,s=Uo(t,o);return o.isInit||null===s?Promise.resolve({resultType:"segment-created",resultData:null}):To(n.mimeType)?co({url:s,responseType:"arraybuffer",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:a.onProgress}).then((function(t){if(!0!==e.checkMediaSegmentIntegrity)return{resultType:"segment-loaded",resultData:t};var r=new Uint8Array(t.responseData);return vo(r,n.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},t),{responseData:r})}})):co({url:s,responseType:"text",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:a.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))},parseSegment:function(e,t,n){var r,i,a,o=t.segment,s=t.language,u=t.mimeType,l=void 0===u?"":u,d=t.codecs,c=void 0===d?"":d,f=To(t.mimeType),v=e.data,p=e.isChunked;if(o.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if(null===v)return{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var h,m,g,y,_=null;if(f){var b;i=(b="string"==typeof v?Aa(v):v instanceof Uint8Array?v:new Uint8Array(v)).length;var S=void 0!==n?Eo(b,p,n,o,t.isLive):null;a=null==S?void 0:S.nextSegments,null===(_=null!==(r=null==S?void 0:S.chunkInfos)&&void 0!==r?r:null)?p?T.warn("Smooth: Unavailable time data for current text track."):(h=o.time,m=o.end):(h=_.time,m=void 0!==_.duration?_.time+_.duration:o.end);var E=c.toLowerCase();if("application/ttml+xml+mp4"===l||"stpp"===E||"stpp.ttml.im1t"===E)y="ttml";else{if("wvtt"!==E)throw new Error("could not find a text-track parser for the type "+l);y="vtt"}var k=ga(b);g=null===k?"":Ra(k)}else{var w;if(h=o.time,m=o.end,"string"!=typeof v){var A=v instanceof Uint8Array?v:new Uint8Array(v);i=A.length,w=Ra(A)}else w=v;switch(l){case"application/x-sami":case"application/smil":y="sami";break;case"application/ttml+xml":y="ttml";break;case"text/vtt":y="vtt"}if(void 0===y){if("srt"!==c.toLowerCase())throw new Error("could not find a text-track parser for the type "+l);y="srt"}g=w}return{segmentType:"media",chunkData:{type:y,data:g,start:h,end:m,language:s},chunkSize:i,chunkInfos:_,chunkOffset:null!=h?h:0,protectionData:[],predictedSegments:Array.isArray(a)&&a.length>0?a:void 0,appendWindow:[void 0,void 0]}}};return{manifest:r,audio:i,video:i,text:a}};function Bo(e){void 0===e.transports.smooth&&(e.transports.smooth=Fo),e.mainThreadMediaSourceInit=ra,e.codecSupportProber=sa}function zo(e){var t=Date.parse(e)-ne();if(!isNaN(t))return t;T.warn("DASH Parser: Invalid clock received: ",e)}function Vo(e){for(var t=e.representations,n=null,r=0;r<t.length;r++){var i=t[r].index.getLastAvailablePosition();if(void 0===i)return;null!==i&&(n=null===n?i:Math.min(n,i))}return null===n?null:n}function Ko(e){for(var t=e.representations,n=null,r=0;r<t.length;r++){var i=t[r].index.getFirstAvailablePosition();if(void 0===i)return;null!==i&&(n=null===n?i:Math.max(n,i))}return null===n?null:n}function Wo(e){if(0===e.length)throw new Error("DASH Parser: no period available for a dynamic content");var t=function(e){for(var t=0;t<=e.length-1;t++){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,o=null;if(void 0!==r){var s=Ko(r);if(void 0===s)return;a=s}if(void 0!==i){var u=Ko(i);if(void 0===u)return;o=u}if(void 0!==r&&null===a||void 0!==i&&null===o)return void T.info("Parser utils: found Period with no segment. ","Going to next one to calculate first position");if(null!==o)return null!==a?Math.max(a,o):o;if(null!==a)return a}}}(e),n=function(e){for(var t=e.length-1;t>=0;t--){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,o=null;if(void 0!==r){var s=Vo(r);if(void 0===s)return{safe:void 0,unsafe:void 0};a=s}if(void 0!==i){var u=Vo(i);if(void 0===u)return{safe:void 0,unsafe:void 0};o=u}if(void 0!==r&&null===a||void 0!==i&&null===o)return T.info("Parser utils: found Period with no segment. ","Going to previous one to calculate last position"),{safe:void 0,unsafe:void 0};if(null!==o)return null!==a?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(null!==a)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}(e);return{minimumSafePosition:t,maximumSafePosition:n.safe,maximumUnsafePosition:n.unsafe}}var Go=function(){function e(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=e.isDynamic&&void 0!==e.timeShiftBufferDepth?e.timeShiftBufferDepth:null,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}var t=e.prototype;return t.setLastPosition=function(e,t){this._lastPosition=e,this._positionTime=t},t.lastPositionIsKnown=function(){return this._isDynamic?void 0!==this._positionTime&&void 0!==this._lastPosition:void 0!==this._lastPosition},t.getEstimatedMinimumSegmentTime=function(){var e;if(!this._isDynamic||null===this._timeShiftBufferDepth)return 0;var t=null!==(e=this.getEstimatedLiveEdge())&&void 0!==e?e:this.getEstimatedMaximumPosition(0);return void 0!==t?t-this._timeShiftBufferDepth:void 0},t.getEstimatedLiveEdge=function(){if(this._isDynamic&&void 0!==this._serverTimestampOffset)return(ne()+this._serverTimestampOffset)/1e3-this._availabilityStartTime},t.getEstimatedMaximumPosition=function(e){if(!this._isDynamic)return this._lastPosition;var t=this.getEstimatedLiveEdge();return void 0!==t&&e!==1/0?t+e:void 0!==this._positionTime&&void 0!==this._lastPosition?Math.max(this._lastPosition-this._positionTime+ne()/1e3,0):this._lastPosition},e}();function jo(e,t){return"function"==typeof Array.prototype.flatMap?e.flatMap(t):e.reduce((function(e,n){var r=t(n);return Array.isArray(r)?(e.push.apply(e,r),e):(e.push(r),e)}),[])}function Ho(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return qo(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qo(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function qo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Yo=function(e,t){for(var n,r=Ho(t);!(n=r()).done;)for(var i,a=n.value,o=a.adaptation,s=Ho(a.trickModeAttachedAdaptationIds);!(i=s()).done;)for(var u,l=i.value,d=Ho(ze);!(u=d()).done;){var c=e[u.value];if(void 0!==c)for(var f,v=Ho(c);!(f=v()).done;){var p=f.value;p.id===l&&(void 0===p.trickModeTracks&&(p.trickModeTracks=[]),p.trickModeTracks.push(o))}}},Qo=["subtitle","caption"];function $o(e,t,n,r){function i(e,t){var n=e.split("/")[0];return Ue(ze,n)?n:"application/ttml+xml"===e||"application/mp4"===e&&null!==t&&void 0!==ae(t,(function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri&&Ue(Qo,e.value)}))?"text":void 0}function a(e){switch(e.substring(0,3)){case"avc":case"hev":case"hvc":case"vp8":case"vp9":case"av1":return"video";case"vtt":return"text"}switch(e.substring(0,4)){case"mp4a":return"audio";case"wvtt":case"stpp":return"text"}}if(null!==t){var o=i(t,r);if(void 0!==o)return o}if(null!==n){var s=a(n);if(void 0!==s)return s}for(var u=0;u<e.length;u++){var l=e[u].attributes,d=l.mimeType,c=l.codecs;if(void 0!==d){var f=i(d,r);if(void 0!==f)return f}if(void 0!==c){var v=a(c);if(void 0!==v)return v}}}var Xo=/[, ]+/g;function Zo(e,n){var r,i=e.initialization,a={};return void 0!==n&&(a.isEMSGWhitelisted=n),{id:"init",isInit:!0,time:0,end:0,duration:0,timescale:1,range:t(i)?void 0:i.range,indexRange:e.indexRange,url:null!==(r=null==i?void 0:i.url)&&void 0!==r?r:null,complete:!0,privateInfos:a,timestampOffset:-e.indexTimeOffset/e.timescale}}function Jo(e){return function(t,n,r){var i,a,o,s=et(r)?parseInt(r,10):1;return i=String(e),a=s,(o=i.toString()).length>=a?o:(new Array(a+1).join("0")+o).slice(-a)}}function es(e,t,n){return function(e,t,n){return-1===e.indexOf("$")?e:e.replace(/\$\$/g,"$").replace(/\$RepresentationID\$/g,String(t)).replace(/\$Bandwidth(\%0(\d+)d)?\$/g,Jo(void 0===n?0:n))}(e,t,n)}function ts(e,t){return function(n){return-1===n.indexOf("$")?n:n.replace(/\$\$/g,"$").replace(/\$Number(\%0(\d+)d)?\$/g,(function(e,n,r){if(void 0===t)throw new Error("Segment number not defined in a $Number$ scheme");return Jo(t)(e,n,r)})).replace(/\$Time(\%0(\d+)d)?\$/g,(function(t,n,r){if(void 0===e)throw new Error("Segment time not defined in a $Time$ scheme");return Jo(e)(t,n,r)}))}}function ns(e,t,n,r,i,a){for(var o,s,u,l=r.getEstimatedMaximumPosition(null!==(o=e.availabilityTimeOffset)&&void 0!==o?o:0),d=Math.min(t+n,null!=l?l:1/0),c=Ya(t,e),f=Ya(d,e),v=e.timeline,p=e.timescale,h=e.segmentUrlTemplate,m=e.startNumber,g=e.endNumber,y=null!=m?m:1,_=[],b=v.length,S=0;S<b;S++){var E=v[S],T=E.duration,k=E.start,w=E.range,A=void 0;A=void 0===l?i:Math.min(l*p,null!=i?i:1/0);for(var I=Ha(E,v[S+1],A),R=!1!==e.availabilityTimeComplete||S!==b-1&&0!==I,x=(s=T,u=void 0,(u=c-k)>0?Math.floor(u/s):0),C=k+x*T;C<f&&x<=I;){var M=y+x;if(void 0!==g&&M>g)break;var P=null===h?null:ts(C,M)(h),D=C-e.indexTimeOffset,O=T;D<0&&(O=T+D,D=0);var N={id:String(C),time:D/p,end:(D+O)/p,duration:O/p,isInit:!1,range:w,timescale:1,url:P,number:M,timestampOffset:-e.indexTimeOffset/p,complete:R,privateInfos:{isEMSGWhitelisted:a}};_.push(N),C=k+ ++x*T}if(C>=f)return _;if(y+=I+1,void 0!==g&&y>g)return _}return _}function rs(e,t){if(t.timescale!==e.timescale){var n=e.timescale;e.timeline.push({start:t.time/t.timescale*n,duration:t.duration/t.timescale*n,repeatCount:void 0===t.count?0:t.count,range:t.range})}else e.timeline.push({start:t.time,duration:t.duration,repeatCount:void 0===t.count?0:t.count,range:t.range});return!0}var is=function(){function e(e,n){var r,i,a,o,s,u=n.periodStart,l=n.periodEnd,d=n.representationId,c=n.representationBitrate,f=n.isEMSGWhitelisted,v=null!==(r=e.timescale)&&void 0!==r?r:1,p=(null!==(i=e.presentationTimeOffset)&&void 0!==i?i:0)-u*v,h=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:es(e.initialization.media,d,c),m=void 0===e.media?null:es(e.media,d,c);void 0!==e.initialization?s=e.initialization.range:void 0!==e.indexRange&&(s=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:p,initialization:{url:h,range:s},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:null!==(o=e.timeline)&&void 0!==o?o:[],timescale:v},this._manifestBoundsCalculator=n.manifestBoundsCalculator,this._scaledPeriodStart=Ya(u,this._index),this._scaledPeriodEnd=t(l)?void 0:Ya(l,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=f}var n=e.prototype;return n.getInitSegment=function(){return Zo(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,t){return ns(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)},n.shouldRefresh=function(){return!1},n.getFirstAvailablePosition=function(){var e=this._index;return 0===e.timeline.length?null:Qa(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)},n.getLastAvailablePosition=function(){var e,t=this._index.timeline;if(0===t.length)return null;var n=t[t.length-1];return Qa(Math.min(qa(n,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)},n.getEnd=function(){return this.getLastAvailablePosition()},n.awaitSegmentBetween=function(){return!1},n.isSegmentStillAvailable=function(){return!0},n.checkDiscontinuity=function(){return null},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){return!1},n.isInitialized=function(){return this._isInitialized},n.initialize=function(e){if(!this._isInitialized){for(var t=0;t<e.length;t++)rs(this._index,e[t]);this._isInitialized=!0}},n.addPredictedSegments=function(){T.warn("Cannot add predicted segments to a `BaseRepresentationIndex`")},n._replace=function(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted},n._update=function(){T.error("Base RepresentationIndex: Cannot update a SegmentList")},e}(),as=function(){function e(e,n){var r,i,a;if(void 0===e.duration)throw new Error("Invalid SegmentList: no duration");var o=n.periodStart,s=n.periodEnd,u=n.representationId,l=n.representationBitrate,d=n.isEMSGWhitelisted;this._isEMSGWhitelisted=d,this._periodStart=o,this._periodEnd=s;var c=null!==(r=e.presentationTimeOffset)&&void 0!==r?r:0,f=null!==(i=e.timescale)&&void 0!==i?i:1,v=c-o*f,p=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:es(e.initialization.media,u,l),h=e.list.map((function(e){return{url:void 0===e.media?null:es(e.media,u,l),mediaRange:e.mediaRange}}));this._index={list:h,timescale:f,duration:e.duration,indexTimeOffset:v,indexRange:e.indexRange,initialization:t(e.initialization)?void 0:{url:p,range:e.initialization.range}}}var n=e.prototype;return n.getInitSegment=function(){var e=Zo(this._index);return void 0===e.privateInfos&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e},n.getSegments=function(e,t){for(var n=this._index,r=n.duration,i=n.list,a=n.timescale,o=r/a,s=function(e,t,n){return[e*n,(e+t)*n]}(e-this._periodStart,t,a),u=s[0],l=s[1],d=Math.min(i.length-1,Math.floor(l/r)),c=[],f=Math.floor(u/r);f<=d;){var v=i[f].mediaRange,p=i[f].url,h=f*o+this._periodStart,m={id:String(f),time:h,isInit:!1,range:v,duration:o,timescale:1,end:h+o,url:p,timestampOffset:-n.indexTimeOffset/a,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};c.push(m),f++}return c},n.shouldRefresh=function(e,t){return!1},n.getFirstAvailablePosition=function(){return this._periodStart},n.getLastAvailablePosition=function(){var e,t=this._index,n=t.duration,r=t.list;return Math.min(r.length*n/t.timescale+this._periodStart,null!==(e=this._periodEnd)&&void 0!==e?e:1/0)},n.getEnd=function(){return this.getLastAvailablePosition()},n.awaitSegmentBetween=function(){return!1},n.isSegmentStillAvailable=function(){return!0},n.checkDiscontinuity=function(){return null},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){return!1},n.isInitialized=function(){return!0},n.initialize=function(){T.error("A `ListRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){T.warn("Cannot add predicted segments to a `ListRepresentationIndex`")},n._replace=function(e){this._index=e._index},n._update=function(){T.error("A `ListRepresentationIndex` cannot be updated")},e}();function os(e){return b.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*e}function ss(e,n,r){var i=e.start,a=e.duration,o=e.repeatCount;return void 0===i&&(null===n?i=0:t(n.duration)||(i=n.start+n.duration*(n.repeatCount+1))),void 0!==a&&!isNaN(a)||null===r||void 0===r.start||isNaN(r.start)||void 0===i||isNaN(i)||(a=r.start-i),void 0===i||isNaN(i)||void 0===a||isNaN(a)||void 0!==o&&isNaN(o)?(T.warn('DASH: A "S" Element could not have been parsed.'),null):{start:i,duration:a,repeatCount:void 0===o?0:o}}function us(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"t":var i=parseInt(r.value,10);isNaN(i)?T.warn('DASH: invalid t ("'+r.value+'")'):t.start=i;break;case"d":var a=parseInt(r.value,10);isNaN(a)?T.warn('DASH: invalid d ("'+r.value+'")'):t.duration=a;break;case"r":var o=parseInt(r.value,10);isNaN(o)?T.warn('DASH: invalid r ("'+r.value+'")'):t.repeatCount=o}}return t}function ls(e){for(var t=[],n=0;n<e.length;n++)t.push(us(e[n]));for(var r=[],i=0;i<t.length;i++){var a=ss(t[i],void 0===r[r.length-1]?null:r[r.length-1],void 0===t[i+1]?null:t[i+1]);null!==a&&r.push(a)}return r}function ds(e,t){var n,r=function(e,t){if(0===e.length||0===t.length)return null;var n=e[0].start,r=t[0].getAttribute("t"),i=null===r?null:parseInt(r,10);if(null===i||Number.isNaN(i))return null;if(n===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(n<i)for(var a=e[0],o=0;;){if(a.repeatCount>0){var s=i-a.start;if(s%a.duration==0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(++o>=e.length)return null;if((a=e[o]).start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}else for(var u=0,l=t[0],d=i;;){var c=l.getAttribute("d"),f=null===c?null:parseInt(c,10);if(null===f||Number.isNaN(f))return null;var v=l.getAttribute("r"),p=null===v?null:parseInt(v,10);if(null!==p){if(Number.isNaN(p)||p<0)return null;if(p>0){var h=n-d;if(h%f==0&&h/f<=p)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/f,prevSegmentsIdx:0,newElementsIdx:u}}d+=f*(p+1)}else d+=f;if(++u>=t.length)return null;var m=(l=t[u]).getAttribute("t"),g=null===m?null:parseInt(m,10);if(null!==g){if(Number.isNaN(g))return null;d=g}if(d===n)return{newElementsIdx:u,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(d>i)return null}}(t,e);if(null===r)return T.warn('DASH: Cannot perform "based" update. Common segment not found.'),ls(e);var i=r.prevSegmentsIdx,a=r.newElementsIdx,o=r.repeatNumberInPrevSegments,s=r.repeatNumberInNewElements,u=t.length-i+a-1;if(u>=e.length)return T.info('DASH: Cannot perform "based" update. New timeline too short'),ls(e);var l=t.slice(i);if(o>0){var d=l[0];d.start+=d.duration*o,l[0].repeatCount-=o}if(s>0&&0!==a)return T.info('DASH: Cannot perform "based" update. The new timeline has a different form.'),ls(e);var c=l[l.length-1],f=us(e[u]),v=(null!==(n=f.repeatCount)&&void 0!==n?n:0)-s;if(f.duration!==c.duration||c.repeatCount>v)return T.info('DASH: Cannot perform "based" update. The new timeline has a different form at the beginning.'),ls(e);void 0!==f.repeatCount&&f.repeatCount>c.repeatCount&&(c.repeatCount=f.repeatCount);for(var p=[],h=[],m=u+1;m<e.length;m++)h.push(us(e[m]));for(var g=0;g<h.length;g++){var y=ss(h[g],void 0===p[p.length-1]?c:p[p.length-1],void 0===h[g+1]?null:h[g+1]);null!==y&&p.push(y)}return l.concat(p)}var cs=function(){function e(n,r){var i,a,o,s,u;if(!e.isTimelineIndexArgument(n))throw new Error("The given index is not compatible with a TimelineRepresentationIndex.");var l=r.availabilityTimeComplete,d=r.availabilityTimeOffset,c=r.manifestBoundsCalculator,f=r.isDynamic,v=r.isLastPeriod,p=r.representationId,h=r.representationBitrate,m=r.periodStart,g=r.periodEnd,y=r.isEMSGWhitelisted,_=null!==(i=n.timescale)&&void 0!==i?i:1,b=(null!==(a=n.presentationTimeOffset)&&void 0!==a?a:0)-m*_;this._manifestBoundsCalculator=c,this._isEMSGWhitelisted=y,this._isLastPeriod=v,this._lastUpdate=null!==(o=r.receivedTime)&&void 0!==o?o:ne(),this._unsafelyBaseOnPreviousIndex=null,null!==r.unsafelyBaseOnPreviousRepresentation&&r.unsafelyBaseOnPreviousRepresentation.index instanceof e&&(r.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=r.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=f,this._parseTimeline=null!==(s=n.timelineParser)&&void 0!==s?s:null;var S,E=void 0===(null===(u=n.initialization)||void 0===u?void 0:u.media)?null:es(n.initialization.media,p,h),T=void 0===n.media?null:es(n.media,p,h);S=void 0===d&&void 0===l?1/0:null!=d?d:0,this._index={availabilityTimeComplete:null==l||l,availabilityTimeOffset:S,indexRange:n.indexRange,indexTimeOffset:b,initialization:t(n.initialization)?void 0:{url:E,range:n.initialization.range},segmentUrlTemplate:T,startNumber:n.startNumber,endNumber:n.endNumber,timeline:void 0===n.timeline?null:fs(n.timeline,n.startNumber,n.endNumber),timescale:_},this._scaledPeriodStart=Ya(m,this._index),this._scaledPeriodEnd=void 0===g?void 0:Ya(g,this._index)}var n=e.prototype;return n.getInitSegment=function(){return Zo(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,t){this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var n=this._index;return ns({segmentUrlTemplate:n.segmentUrlTemplate,startNumber:n.startNumber,endNumber:n.endNumber,timeline:n.timeline,timescale:n.timescale,indexTimeOffset:n.indexTimeOffset},e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)},n.shouldRefresh=function(){return!1},n.getFirstAvailablePosition=function(){this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var e=this._index.timeline;return 0===e.length?null:Qa(Math.max(this._scaledPeriodStart,e[0].start),this._index)},n.getLastAvailablePosition=function(){var e;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=vs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);return null===t?null:Qa(Math.min(t.end,null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)},n.getEnd=function(){var e;if(!this._isDynamic||this._isLastPeriod){if(this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;var t=this._index.timeline[this._index.timeline.length-1];return Qa(Math.min(qa(t,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)}},n.awaitSegmentBetween=function(e,t){var n,r;if($(),!this._isDynamic)return!1;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var i=this._index,a=i.timescale,o=i.timeline,s=os(a),u=Ya(t,this._index),l=vs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(null!==l&&Math.min(l.end,null!==(n=this._scaledPeriodEnd)&&void 0!==n?n:1/0)+s>=Math.min(u,null!==(r=this._scaledPeriodEnd)&&void 0!==r?r:1/0))return!1;var d=Ya(e,this._index);if(o.length>0&&null!==l&&!l.isLastOfTimeline&&d<qa(o[o.length-1],null,this._scaledPeriodEnd)+s+s)return!0;return!!this._isLastPeriod&&(void 0===this._scaledPeriodEnd?u+s>this._scaledPeriodStart&&void 0:d-s<this._scaledPeriodEnd&&u+s>this._scaledPeriodStart)},n.isSegmentStillAvailable=function(e){return!!e.isInit||(this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline()),function(e,n,r,i){var a=vs(n,r,i);if(null===a)return!1;for(var o=0;o<n.timeline.length;o++){if(a.timelineIdx<o)return!1;var s=n.timeline[o],u=(s.start-n.indexTimeOffset)/n.timescale;if(u>e.time)return!1;if(u===e.time)return void 0===s.range?void 0===e.range:!t(e.range)&&s.range[0]===e.range[0]&&s.range[1]===e.range[1];if(s.repeatCount>=0&&void 0!==s.duration){var l=(u-s.start)/s.duration-1;return l%1==0&&l<=a.newRepeatCount}}return!1}(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))},n.checkDiscontinuity=function(e){this._refreshTimeline();var t=this._index.timeline;return null===t&&(t=this._getTimeline(),this._index.timeline=t),$a({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)},n.canBeOutOfSyncError=function(e){return!!this._isDynamic&&(e instanceof Pe&&e.isHttpError(404))},n._replace=function(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod},n._update=function(e){null===this._index.timeline&&(this._index.timeline=this._getTimeline()),null===e._index.timeline&&(e._index.timeline=e._getTimeline()),no(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.availabilityTimeOffset=e._index.availabilityTimeOffset,this._index.availabilityTimeComplete=e._index.availabilityTimeComplete,this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod},n.isStillAwaitingFutureSegments=function(){var e;if(!this._isDynamic)return!1;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=this._index.timeline;if(0===t.length){if(void 0!==this._scaledPeriodEnd){var n=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(void 0!==n&&Ya(n,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}var r=os(this._index.timescale),i=vs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(null!==i&&!i.isLastOfTimeline){var a=Math.min(i.end,null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0);return!(void 0!==this._scaledPeriodEnd&&a+r>=this._scaledPeriodEnd)}return!!this._isLastPeriod&&(void 0===this._scaledPeriodEnd||qa(t[t.length-1],null,this._scaledPeriodEnd)+r<this._scaledPeriodEnd)},n.isInitialized=function(){return!0},n.initialize=function(){T.error("A `TimelineRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){T.warn("Cannot add predicted segments to a `TimelineRepresentationIndex`")},e.isTimelineIndexArgument=function(e){return"function"==typeof e.timelineParser||Array.isArray(e.timeline)},n._refreshTimeline=function(){if(null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._isDynamic){var e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(!t(e)){var n=Ya(e,this._index),r=to(this._index.timeline,n);void 0!==this._index.startNumber?this._index.startNumber+=r:void 0!==this._index.endNumber&&(this._index.startNumber=r+1)}}},n._getTimeline=function(){if(null===this._parseTimeline)return null!==this._index.timeline?this._index.timeline:(T.error("DASH: Timeline already lazily parsed."),[]);var e=this._parseTimeline();this._parseTimeline=null;var t,n=b.getCurrent().MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY;return null===this._unsafelyBaseOnPreviousIndex||e.length<n?fs(ls(e),this._index.startNumber,this._index.endNumber):(null===this._unsafelyBaseOnPreviousIndex._index.timeline?(t=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=t):t=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,fs(ds(e,t),this._index.startNumber,this._index.endNumber))},e}();function fs(e,t,n){if(void 0===n)return e;for(var r=null!=t?t:1,i=0;i<e.length;i++){var a=e[i];if((r+=a.repeatCount+1)>n){if(r===n+1)return e.slice(0,i+1);var o=e.slice(0,i),s=Object.assign({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,n-u),o.push(s),o}}return e}function vs(e,t,n){if(e.timeline.length<=0)return null;if(e.availabilityTimeOffset===1/0){var r=e.timeline.length-1,i=e.timeline[r];return{isLastOfTimeline:!0,timelineIdx:r,newRepeatCount:i.repeatCount,end:qa(i,null,n)}}var a=t.getEstimatedMaximumPosition(e.availabilityTimeOffset);if(void 0===a){var o=e.timeline.length-1,s=e.timeline[o];return{isLastOfTimeline:!0,timelineIdx:o,newRepeatCount:s.repeatCount,end:qa(s,null,n)}}for(var u=e.timeline.length-1;u>=e.timeline.length;u--){var l=e.timeline[u],d=l.start+l.duration;if(Qa(d,e)<=a){if(Qa(qa(l,e.timeline[u+1],n),e)<=a)return{isLastOfTimeline:u===e.timeline.length-1,timelineIdx:u,newRepeatCount:l.repeatCount,end:d};var c=Ya(a,e)-l.start,f=Math.floor(c/l.duration);return $(),{isLastOfTimeline:!1,timelineIdx:u,newRepeatCount:f-1,end:l.start+f*l.duration}}}return null}var ps=cs,hs=function(){function e(e,n){var r,i,a,o=n.availabilityTimeOffset,s=n.manifestBoundsCalculator,u=n.isDynamic,l=n.periodEnd,d=n.periodStart,c=n.representationId,f=n.representationBitrate,v=n.isEMSGWhitelisted,p=null!==(r=e.timescale)&&void 0!==r?r:1;this._availabilityTimeOffset=o,this._manifestBoundsCalculator=s;var h=null!==(i=e.presentationTimeOffset)&&void 0!==i?i:0,m=h-d*p;if(void 0===e.duration)throw new Error("Invalid SegmentTemplate: no duration");var g=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:es(e.initialization.media,c,f),y=void 0===e.media?null:es(e.media,c,f);this._index={duration:e.duration,timescale:p,indexRange:e.indexRange,indexTimeOffset:m,initialization:t(e.initialization)?void 0:{url:g,range:e.initialization.range},url:y,presentationTimeOffset:h,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=u,this._periodStart=d,this._scaledRelativePeriodEnd=void 0===l?void 0:(l-d)*p,this._isEMSGWhitelisted=v}var n=e.prototype;return n.getInitSegment=function(){return Zo(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,n){var r=this._index,i=r.duration,a=r.startNumber,o=r.endNumber,s=r.timescale,u=r.url,l=this._periodStart*s,d=this._scaledRelativePeriodEnd,c=e*s-l,f=(e+n)*s-l,v=this._getFirstSegmentStart(),p=this._getLastSegmentStart();if(t(v)||t(p))return[];var h=Math.max(v,c),m=Math.min(p,f);if(m+i<=h)return[];for(var g=[],y=null!=a?a:1,_=Math.floor(h/i),b=_*i;b<=m;b+=i){var S=_+y;if(void 0!==o&&S>o)return g;var E=!t(d)&&b+i>d?d-b:i,T=b+l,k=b+this._index.presentationTimeOffset,w=null===u?null:ts(k,S)(u),A={id:String(S),number:S,time:T/s,end:(T+E)/s,duration:E/s,timescale:1,isInit:!1,scaledDuration:E/s,url:w,timestampOffset:-r.indexTimeOffset/s,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};g.push(A),_++}return g},n.getFirstAvailablePosition=function(){var e=this._getFirstSegmentStart();return t(e)?e:e/this._index.timescale+this._periodStart},n.getLastAvailablePosition=function(){var e=this._getLastSegmentStart();if(t(e))return e;var n=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,null!=n?n:1/0)/this._index.timescale+this._periodStart},n.getEnd=function(){if(!this._isDynamic)return this.getLastAvailablePosition();var e=this._estimateRelativeScaledEnd();if(void 0!==e){var t=this._index.timescale;return(e+this._periodStart*t)/t}},n.awaitSegmentBetween=function(e,n){if($(),!this._isDynamic)return!1;var r=this._index.timescale,i=os(r),a=this._periodStart*r,o=e*r-a,s=n*r-a,u=this._getLastSegmentStart();if(t(u)){var l=this._estimateRelativeScaledEnd();return void 0===l?s+i>=0:s+i>=0&&o<l-i}var d=u+this._index.duration,c=this._estimateRelativeScaledEnd();return void 0===c?s>d-i:s>d-i&&o<c-i},n.shouldRefresh=function(){return!1},n.checkDiscontinuity=function(){return null},n.isSegmentStillAvailable=function(e){if(e.isInit)return!0;var t=this.getSegments(e.time,.1);return 0!==t.length&&(t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number)},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){if(!this._isDynamic)return!1;var e=this._estimateRelativeScaledEnd();if(void 0===e)return!0;var n=this._index.timescale,r=this._getLastSegmentStart();return!!t(r)||r+this._index.duration+os(n)<e},n.isInitialized=function(){return!0},n.initialize=function(){T.error("A `TemplateRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){T.warn("Cannot add predicted segments to a `TemplateRepresentationIndex`")},n._replace=function(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator},n._update=function(e){this._replace(e)},n._getFirstSegmentStart=function(){var e;if(!this._isDynamic)return 0;if(0===this._scaledRelativePeriodEnd||void 0===this._scaledRelativePeriodEnd){var t=this._manifestBoundsCalculator.getEstimatedMaximumPosition(null!==(e=this._availabilityTimeOffset)&&void 0!==e?e:0);if(void 0!==t&&t<this._periodStart)return null}var n=this._index,r=n.duration,i=n.timescale,a=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(void 0!==a){var o=a>this._periodStart?(a-this._periodStart)*i:0;return Math.floor(o/r)*r}},n._getLastSegmentStart=function(){var e,t,n=this._index,r=n.duration,i=n.timescale,a=n.endNumber,o=n.startNumber,s=void 0===o?1:o;if(this._isDynamic){var u=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(void 0!==u&&void 0!==this._scaledRelativePeriodEnd&&this._scaledRelativePeriodEnd<u-this._periodStart*this._index.timescale){var l=Math.ceil(this._scaledRelativePeriodEnd/r);return void 0!==a&&a-s+1<l&&(l=a-s+1),(l-1)*r}var d=this._manifestBoundsCalculator.getEstimatedMaximumPosition(null!==(e=this._availabilityTimeOffset)&&void 0!==e?e:0);if(void 0===d)return;var c=(d-this._periodStart)*i;if(c<0)return null;var f=Math.floor(c/r);return void 0!==a&&a-s+1<f&&(f=a-s+1),f<=0?null:(f-1)*r}var v=null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:0,p=Math.ceil(v/r);void 0!==a&&a-s+1<p&&(p=a-s+1);var h=(p-1)*r,m=b.getCurrent().MINIMUM_SEGMENT_SIZE*i;return void 0!==a||v-h>m||p<2?h:(p-2)*r},n._estimateRelativeScaledEnd=function(){var e,t;if(void 0!==this._index.endNumber){var n=this._index.endNumber-(null!==(e=this._index.startNumber)&&void 0!==e?e:1)+1;return Math.max(Math.min(n*this._index.duration,null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:1/0),0)}if(void 0!==this._scaledRelativePeriodEnd)return Math.max(this._scaledRelativePeriodEnd,0)},e}();function ms(e,t){var n;if(0===t.length)return e;var r=t.map((function(e){return{url:e.value}}));if(0===e.length)return r;for(var i=[],a=0;a<e.length;a++)for(var o=e[a],s=0;s<r.length;s++){var u=r[s],l=Sa(o.url,u.url);i.push({url:l,serviceLocation:null!==(n=u.serviceLocation)&&void 0!==n?n:o.serviceLocation})}return i}function gs(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ys(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ys(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ys(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _s(e){var t=e.adaptationProfiles,n=e.essentialProperties,r=e.supplementalProperties,i=e.manifestProfiles,a=e.codecs;if(-1!==((null!=t?t:"")+(null!=i?i:"")).indexOf("http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10")&&("hvc1.2.4.L153.B0"===a||"hev1.2.4.L153.B0"===a))return{colorDepth:10,eotf:"pq",colorSpace:"rec2020"};var o=ae([].concat(null!=n?n:[],null!=r?r:[]),(function(e){return"urn:mpeg:mpegB:cicp:TransferCharacteristics"===e.schemeIdUri}));if(void 0!==o)switch(o.value){case"15":return;case"16":return{eotf:"pq"};case"18":return{eotf:"hlg"}}return void 0!==a&&/^vp(08|09|10)/.exec(a)?function(e){var t,n,r,i=e.split("."),a=i[0],o=(i[1],i[2],i[3]),s=(i[4],i[5]),u=i[6],l=i[7];if(("vp08"===a||"vp09"===a||"vp10"===a)&&((void 0!==o&&"10"===o||"12"===o)&&(t=parseInt(o,10)),void 0!==u&&("16"===u?n="pq":"18"===u&&(n="hlg")),void 0!==s&&void 0!==l&&"09"===s&&"09"===l&&(r="rec2020"),void 0!==t&&void 0!==n))return{colorDepth:t,eotf:n,colorSpace:r}}(a):void 0}function bs(e,t,n){for(var r,i,a,o,s,u,l=[],d=function(){for(var e=u.value,d=void 0!==e.attributes.id?e.attributes.id:String(e.attributes.bitrate)+(void 0!==e.attributes.height?"-"+e.attributes.height:"")+(void 0!==e.attributes.width?"-"+e.attributes.width:"")+(void 0!==e.attributes.mimeType?"-"+e.attributes.mimeType:"")+(void 0!==e.attributes.codecs?"-"+e.attributes.codecs:"");l.some((function(e){return e.id===d}));)d+="-dup";var c,f=null!==(i=null===(r=n.unsafelyBaseOnPreviousAdaptation)||void 0===r?void 0:r.getRepresentation(d))&&void 0!==i?i:null,v=function(e,t){var n=[];if(void 0!==e.children.inbandEventStreams&&n.push.apply(n,e.children.inbandEventStreams),void 0!==t.children.inbandEventStreams&&n.push.apply(n,t.children.inbandEventStreams),0!==n.length)return n}(e,t),p=null!==(a=e.attributes.availabilityTimeComplete)&&void 0!==a?a:n.availabilityTimeComplete;void 0===e.attributes.availabilityTimeOffset&&void 0===n.availabilityTimeOffset||(c=(null!==(o=e.attributes.availabilityTimeOffset)&&void 0!==o?o:0)+(null!==(s=n.availabilityTimeOffset)&&void 0!==s?s:0));var h,g=function(e,t){var n,r,i,a=t.availabilityTimeOffset,o=t.manifestBoundsCalculator,s=t.isDynamic,u=t.end,l=t.start,d=t.receivedTime,c=t.unsafelyBaseOnPreviousRepresentation,f=t.inbandEventStreams,v={availabilityTimeComplete:void 0,availabilityTimeOffset:a,unsafelyBaseOnPreviousRepresentation:c,isEMSGWhitelisted:function(e){return void 0!==f&&f.some((function(t){return t.schemeIdUri===e.schemeIdUri}))},isLastPeriod:t.isLastPeriod,manifestBoundsCalculator:o,isDynamic:s,periodEnd:u,periodStart:l,receivedTime:d,representationBitrate:e.attributes.bitrate,representationId:e.attributes.id};if(void 0!==e.children.segmentBase){var p=e.children.segmentBase;i=new is(p,v)}else if(void 0!==e.children.segmentList){var h=e.children.segmentList;i=new as(h,v)}else if(void 0!==e.children.segmentTemplate||t.parentSegmentTemplates.length>0){var g=t.parentSegmentTemplates.slice(),y=e.children.segmentTemplate;void 0!==y&&g.push(y);var _=m.apply(void 0,[{}].concat(g));void 0===_.availabilityTimeOffset&&void 0===t.availabilityTimeOffset||(v.availabilityTimeOffset=(null!==(n=_.availabilityTimeOffset)&&void 0!==n?n:0)+(null!==(r=t.availabilityTimeOffset)&&void 0!==r?r:0)),i=ps.isTimelineIndexArgument(_)?new ps(_,v):new hs(_,v)}else{var b=t.adaptation.children;if(void 0!==b.segmentBase){var S=b.segmentBase;i=new is(S,v)}else if(void 0!==b.segmentList){var E=b.segmentList;i=new as(E,v)}else i=new hs({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:""},v)}return i}(e,m({},n,{availabilityTimeOffset:c,availabilityTimeComplete:p,unsafelyBaseOnPreviousRepresentation:f,adaptation:t,inbandEventStreams:v}));void 0===e.attributes.bitrate?(T.warn("DASH: No usable bitrate found in the Representation."),h=0):h=e.attributes.bitrate;var y,_,b,S=ms(n.baseURLs,e.children.baseURLs),E={bitrate:h,cdnMetadata:0===S.length?[{baseUrl:"",id:void 0}]:S.map((function(e){return{baseUrl:e.url,id:e.serviceLocation}})),index:g,id:d};void 0!==e.children.supplementalProperties&&ae(e.children.supplementalProperties,(function(e){return"tag:dolby.com,2018:dash:EC3_ExtensionType:2018"===e.schemeIdUri&&"JOC"===e.value}))&&(E.isSpatialAudio=!0),void 0!==e.attributes.codecs?y=e.attributes.codecs:void 0!==t.attributes.codecs&&(y=t.attributes.codecs),void 0!==y&&(y="mp4a.40.02"===y?"mp4a.40.2":y,E.codecs=y),void 0!==e.attributes.supplementalCodecs?_=e.attributes.supplementalCodecs:void 0!==t.attributes.supplementalCodecs&&(_=t.attributes.supplementalCodecs),void 0!==_&&(E.supplementalCodecs=et(b=_)?b.trim().replace(Xo,", "):""),void 0!==e.attributes.frameRate?E.frameRate=e.attributes.frameRate:void 0!==t.attributes.frameRate&&(E.frameRate=t.attributes.frameRate),void 0!==e.attributes.height?E.height=e.attributes.height:void 0!==t.attributes.height&&(E.height=t.attributes.height),void 0!==e.attributes.mimeType?E.mimeType=e.attributes.mimeType:void 0!==t.attributes.mimeType&&(E.mimeType=t.attributes.mimeType),void 0!==e.attributes.width?E.width=e.attributes.width:void 0!==t.attributes.width&&(E.width=t.attributes.width);var k=void 0!==t.children.contentProtections?t.children.contentProtections:[];if(void 0!==e.children.contentProtections&&k.push.apply(k,e.children.contentProtections),k.length>0){var w=k.reduce((function(e,t){var n;if(void 0!==t.attributes.schemeIdUri&&"urn:uuid:"===t.attributes.schemeIdUri.substring(0,9)&&(n=t.attributes.schemeIdUri.substring(9).replace(/-/g,"").toLowerCase()),void 0!==t.attributes.keyId&&t.attributes.keyId.length>0){var r={keyId:t.attributes.keyId,systemId:n};void 0===e.keyIds?e.keyIds=[r]:e.keyIds.push(r)}if(void 0!==n){for(var i,a=[],o=gs(t.children.cencPssh);!(i=o()).done;){var s=i.value;a.push({systemId:n,data:s})}if(a.length>0){var u,l=ae(e.initData,(function(e){return"cenc"===e.type}));if(void 0===l)e.initData.push({type:"cenc",values:a});else(u=l.values).push.apply(u,a)}}return e}),{keyIds:void 0,initData:[]});(Object.keys(w.initData).length>0||void 0!==w.keyIds&&w.keyIds.length>0)&&(E.contentProtections=w)}E.hdrInfo=_s({adaptationProfiles:t.attributes.profiles,supplementalProperties:t.children.supplementalProperties,essentialProperties:t.children.essentialProperties,manifestProfiles:n.manifestProfiles,codecs:y}),l.push(E)},c=gs(e);!(u=c()).done;)d();return l}function Ss(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Es(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Es(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Es(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ts(e){if(void 0===e)return!1;var t="urn:tva:metadata:cs:AudioPurposeCS:2007"===e.schemeIdUri&&"1"===e.value,n="urn:mpeg:dash:role:2011"===e.schemeIdUri&&"description"===e.value;return t||n}function ks(e,t){if(void 0!==e&&e.some((function(e){return"urn:tva:metadata:cs:AudioPurposeCS:2007"===e.schemeIdUri&&"2"===e.value})))return!0;if(void 0!==t&&t.some((function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri&&"caption"===e.value})))return!0;return!1}function ws(e){return void 0!==e&&("urn:mpeg:dash:role:2011"===e.schemeIdUri&&"sign"===e.value)}function As(e,t){if(et(e.attributes.id))return e.attributes.id;var n=t.isClosedCaption,r=t.isForcedSubtitle,i=t.isAudioDescription,a=t.isSignInterpreted,o=t.isTrickModeTrack,s=t.type;return et(e.attributes.language)&&(s+="-"+e.attributes.language),!0===n&&(s+="-cc"),!0===r&&(s+="-cc"),!0===i&&(s+="-ad"),!0===a&&(s+="-si"),o&&(s+="-trickMode"),et(e.attributes.contentType)&&(s+="-"+e.attributes.contentType),et(e.attributes.codecs)&&(s+="-"+e.attributes.codecs),et(e.attributes.mimeType)&&(s+="-"+e.attributes.mimeType),void 0!==e.attributes.frameRate&&(s+="-"+String(e.attributes.frameRate)),s}function Is(e){if(!t(e.children.supplementalProperties))for(var n,r=Ss(e.children.supplementalProperties);!(n=r()).done;){var i=n.value;if("urn:mpeg:dash:adaptation-set-switching:2016"===i.schemeIdUri&&!t(i.value))return i.value.split(",").map((function(e){return e.trim()})).filter((function(e){return e}))}return[]}function Rs(e,t){var n=t[1].priority-e[1].priority;return 0!==n?n:e[1].isMainAdaptation!==t[1].isMainAdaptation?e[1].isMainAdaptation?-1:1:e[1].indexInMpd-t[1].indexInMpd}function xs(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Cs(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cs(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Cs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ms=Le();function Ps(e,n){var r,i,o,s,u=[],l=function(e,n){var r=[];return e.forEach((function(i,a){var o,s;if(t(i.attributes.start))if(0===a)o=!n.isDynamic||t(n.availabilityStartTime)?0:n.availabilityStartTime;else{var u=r[r.length-1];if(t(u)||t(u.periodEnd))throw new Error("Missing start time when parsing periods.");o=u.periodEnd}else o=i.attributes.start;var l=e[a+1];t(i.attributes.duration)?a===e.length-1?s=n.duration:t(l.attributes.start)||(s=l.attributes.start-o):s=i.attributes.duration;var d=t(s)?void 0:o+s;r.push({periodStart:o,periodDuration:s,periodEnd:d})})),r}(e,n);if(l.length!==e.length)throw new Error("MPD parsing error: the time information are incoherent.");var d=n.isDynamic,c=n.manifestBoundsCalculator;d||t(n.duration)||c.setLastPosition(n.duration);for(var f=function(){var f,p=v===e.length-1,h=e[v],m=n.xlinkInfos.get(h),g=ms(n.baseURLs,h.children.baseURLs),y=l[v],_=y.periodStart,b=y.periodDuration,S=y.periodEnd;for(t(h.attributes.id)?(T.warn("DASH: No usable id found in the Period. Generating one."),f="gen-dash-period-"+Ms()):f=h.attributes.id;u.some((function(e){return e.id===f}));)f+="-dup";var E=void 0!==m?m.receivedTime:n.receivedTime,k=null!==(i=null===(r=n.unsafelyBaseOnPreviousManifest)||void 0===r?void 0:r.getPeriod(f))&&void 0!==i?i:null,w=h.attributes.availabilityTimeComplete,A=h.attributes.availabilityTimeOffset,I=n.manifestProfiles,R=h.children.segmentTemplate,x={availabilityTimeComplete:w,availabilityTimeOffset:A,baseURLs:g,manifestBoundsCalculator:c,end:S,isDynamic:d,isLastPeriod:p,manifestProfiles:I,receivedTime:E,segmentTemplate:R,start:_,unsafelyBaseOnPreviousPeriod:k},C=function(e,n){for(var r,i,a,o,s,u,l,d={video:[],audio:[],text:[]},c=[],f={},v=[],p=0;p<e.length;p++){var h=e[p],m=h.children,g=m.essentialProperties,y=m.roles,_=m.label,b=Array.isArray(y)&&y.some((function(e){return"main"===e.value}))&&y.some((function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri})),S=h.children.representations,E=null!==(r=h.attributes.availabilityTimeComplete)&&void 0!==r?r:n.availabilityTimeComplete,k=void 0;void 0===h.attributes.availabilityTimeOffset&&void 0===n.availabilityTimeOffset||(k=(null!==(i=h.attributes.availabilityTimeOffset)&&void 0!==i?i:0)+(null!==(a=n.availabilityTimeOffset)&&void 0!==a?a:0));var w=h.attributes.mimeType,A=h.attributes.codecs,I=$o(S,et(w)?w:null,et(A)?A:null,t(m.roles)?null:m.roles);if(void 0!==I){var R=null!==(o=h.attributes.selectionPriority)&&void 0!==o?o:1,x=h.attributes.id,C=Is(h),M=[];void 0!==n.segmentTemplate&&M.push(n.segmentTemplate),void 0!==h.children.segmentTemplate&&M.push(h.children.segmentTemplate);var P={availabilityTimeComplete:E,availabilityTimeOffset:k,baseURLs:ms(n.baseURLs,m.baseURLs),manifestBoundsCalculator:n.manifestBoundsCalculator,end:n.end,isDynamic:n.isDynamic,isLastPeriod:n.isLastPeriod,manifestProfiles:n.manifestProfiles,parentSegmentTemplates:M,receivedTime:n.receivedTime,start:n.start,unsafelyBaseOnPreviousAdaptation:null},D=Array.isArray(g)?ae(g,(function(e){return"http://dashif.org/guidelines/trickmode"===e.schemeIdUri})):void 0,O=null===(s=null==D?void 0:D.value)||void 0===s?void 0:s.split(" "),N=void 0!==O,L=m.accessibilities,U=void 0;void 0!==y&&y.some((function(e){return"dub"===e.value}))&&(U=!0);var F=void 0;F="text"===I&&ks(L,y);var z=void 0;"text"===I&&void 0!==y&&y.some((function(e){return"forced-subtitle"===e.value||"forced_subtitle"===e.value}))&&(z=!0);var V=void 0;"audio"!==I?V=!1:void 0!==L&&(V=L.some(Ts));var K=void 0;"video"!==I?K=!1:void 0!==L&&(K=L.some(ws));for(var W=As(h,{isAudioDescription:V,isForcedSubtitle:z,isClosedCaption:F,isSignInterpreted:K,isTrickModeTrack:N,type:I});Ue(v,W);)W+="-dup";var G=W;v.push(W),P.unsafelyBaseOnPreviousAdaptation=null!==(l=null===(u=n.unsafelyBaseOnPreviousPeriod)||void 0===u?void 0:u.getAdaptation(W))&&void 0!==l?l:null;var j={id:W,representations:bs(S,h,P),type:I,isTrickModeTrack:N};if(t(h.attributes.language)||(j.language=h.attributes.language),t(F)||(j.closedCaption=F),t(V)||(j.audioDescription=V),!0===U&&(j.isDub=!0),void 0!==z&&(j.forcedSubtitles=z),!0===K&&(j.isSignInterpreted=!0),void 0!==_&&(j.label=_),void 0!==O)c.push({adaptation:j,trickModeAttachedAdaptationIds:O});else{for(var H,q=-1,Y=function(){var e=H.value,t=f[e];if(void 0!==t&&t.newID!==G&&Ue(t.adaptationSetSwitchingIDs,x)){q=B(d[I],(function(t){return t[0].id===e}));var n,r=d[I][q];if(void 0!==r&&r[0].audioDescription===j.audioDescription&&r[0].closedCaption===j.closedCaption&&r[0].language===j.language)return T.info('DASH Parser: merging "switchable" AdaptationSets',x,e),(n=r[0].representations).push.apply(n,j.representations),r[1]={priority:Math.max(R,r[1].priority),isMainAdaptation:b||r[1].isMainAdaptation,indexInMpd:Math.min(p,r[1].indexInMpd)},1}},Q=Ss(C);!(H=Q()).done&&!Y(););q<0&&d[I].push([j,{priority:R,isMainAdaptation:b,indexInMpd:p}])}!t(x)&&t(f[x])&&(f[x]={newID:G,adaptationSetSwitchingIDs:C})}}var $=ze.reduce((function(e,t){var n=d[t];return n.length>0&&(n.sort(Rs),e[t]=n.map((function(e){return e[0]}))),e}),{});return d.video.sort(Rs),Yo($,c),$}(h.children.adaptations,x),M=(null!==(o=n.xmlNamespaces)&&void 0!==o?o:[]).concat(null!==(s=h.attributes.namespaces)&&void 0!==s?s:[]),P=function(e,t,n){for(var r,i,o,s=[],u=xs(e);!(o=u()).done;)for(var l,d=o.value,c=d.attributes,f=c.schemeIdUri,v=void 0===f?"":f,p=c.timescale,h=void 0===p?1:p,m=n.concat(null!==(r=d.attributes.namespaces)&&void 0!==r?r:[]),g=xs(d.children.events);!(l=g()).done;){var y=l.value;if(void 0!==y.eventStreamData){var _=(null!==(i=y.presentationTime)&&void 0!==i?i:0)/h+t,b=void 0===y.duration?void 0:_+y.duration/h,S=void 0,E=void 0;if(!a&&y.eventStreamData instanceof Element)S=y.eventStreamData;else try{E={namespaces:m,data:Ra(new Uint8Array(y.eventStreamData))}}catch(e){T.error("DASH: Error while parsing event-stream:",e instanceof Error?e.message:"Unknown error")}s.push({start:_,end:b,id:y.id,data:{type:"dash-event-stream",value:{schemeIdUri:v,timescale:h,element:S,xmlData:E}}})}}return s}(h.children.eventStreams,_,M),D={id:f,start:_,end:S,duration:b,adaptations:C,streamEvents:P};if(u.unshift(D),!c.lastPositionIsKnown()){var O=function(e){for(var n,r=null,i=!0,a=xs(jo(ge(e).filter((function(e){return!t(e)})),(function(e){return e})));!(n=a()).done;)for(var o,s=xs(n.value.representations);!(o=s()).done;){var u=o.value.index.getLastAvailablePosition();null!==u&&(i=!1,"number"==typeof u&&(r=t(r)?u:Math.max(r,u)))}if(!t(r))return r;if(i)return null;return}(C);if(d)if("number"==typeof O){var N=ne()/1e3;c.setLastPosition(O,N)}else{var L=Ds(n,_);if(void 0!==L){var U=L[0],F=L[1];c.setLastPosition(U,F)}}else"number"==typeof O&&c.setLastPosition(O)}},v=e.length-1;v>=0;v--)f();if(n.isDynamic&&!c.lastPositionIsKnown()){var p=Ds(n,0);if(void 0!==p){var h=p[0],m=p[1];c.setLastPosition(h,m)}}return function(e){if(0===e.length)return[];for(var t=[e[0]],n=1;n<e.length;n++){for(var r=e[n],i=t[t.length-1];(void 0===i.duration||i.start+i.duration>r.start)&&(T.warn("DASH: Updating overlapping Periods.",null==i?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0))&&(t.pop(),0!==t.length);)i=t[t.length-1];t.push(r)}return t}(u)}function Ds(e,n){if(t(e.clockOffset)){var r=Date.now()/1e3;if(r>=n)return T.warn("DASH Parser: no clock synchronization mechanism found. Using the system clock instead."),[r-e.availabilityStartTime,ne()/1e3]}else{var i=e.clockOffset/1e3-e.availabilityStartTime,a=ne()/1e3,o=a+i;if(o>=n)return[o,a]}}function Os(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ns(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ns(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ns(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ls=function e(n,r,i,a,o){void 0===o&&(o=new WeakMap);var s=n.children,u=n.attributes;if(t(r.externalClockOffset)){var l="dynamic"===u.type,d=ae(s.utcTimings,(function(e){return"urn:mpeg:dash:utc:direct:2014"===e.schemeIdUri&&!t(e.value)})),c=t(d)||t(d.value)?void 0:zo(d.value),f=t(c)||isNaN(c)?void 0:c;if(t(f)||!0===a){if(l&&!0!==a){var v=function(e){var t=e.children.utcTimings.filter((function(e){return("urn:mpeg:dash:utc:http-iso:2014"===e.schemeIdUri||"urn:mpeg:dash:utc:http-xsdate:2014"===e.schemeIdUri)&&void 0!==e.value}));return t.length>0?t[0].value:void 0}(n);if(!t(v)&&v.length>0)return{type:"needs-clock",value:{url:v,continue:function(t){return t.success?(r.externalClockOffset=zo(t.data),e(n,r,i,!0)):(i.push(t.error),T.warn("DASH Parser: Error on fetching the clock ressource",t.error),e(n,r,i,!0))}}}}}else r.externalClockOffset=f}for(var p=[],h=0;h<s.periods.length;h++){var m=s.periods[h].attributes,g=m.xlinkHref,y=m.xlinkActuate;t(g)||"onLoad"!==y||p.push({index:h,ressource:g})}return 0===p.length?function(e,n,r,i){var a,o,s,u,l,d,c,f=e.children,v=e.attributes,p="dynamic"===v.type,h=void 0!==n.url?[{url:n.url.substring(0,Ea(n.url))}]:[],m=ms(h,f.baseURLs),g=function(e,n){return"dynamic"!==e.type?0:t(e.availabilityStartTime)?null!=n?n:0:e.availabilityStartTime}(v,n.referenceDateTime),y=v.timeShiftBufferDepth,_=n.externalClockOffset,S=n.unsafelyBaseOnPreviousManifest,E=n.externalClockOffset,k=new Go({availabilityStartTime:g,isDynamic:p,timeShiftBufferDepth:y,serverTimestampOffset:E}),w={availabilityStartTime:g,baseURLs:m,clockOffset:_,duration:v.duration,isDynamic:p,manifestBoundsCalculator:k,manifestProfiles:e.attributes.profiles,receivedTime:n.manifestReceivedTime,timeShiftBufferDepth:y,unsafelyBaseOnPreviousManifest:S,xlinkInfos:i,xmlNamespaces:e.attributes.namespaces},A=Ps(f.periods,w),I=v.duration,R=null;void 0!==v.minimumUpdatePeriod&&v.minimumUpdatePeriod>=0&&(l=0===v.minimumUpdatePeriod?b.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:v.minimumUpdatePeriod);var x=Wo(A),C=x.minimumSafePosition,M=x.maximumSafePosition,P=x.maximumUnsafePosition,D=ne();if(p){var O;if(void 0!==M)O=M;else if(void 0===E)T.warn("DASH Parser: use system clock to define maximum position"),O=Date.now()/1e3-g;else O=(ne()+E)/1e3-g;var N=k.getEstimatedLiveEdge();void 0===N&&(N=void 0!==P?P:O),c={isLinear:!0,maximumSafePosition:O,livePosition:N,time:D},d=C,null!==(R=null!=y?y:null)&&void 0!==d&&N-d>R&&(R=N-d)}else{void 0===(d=C)&&(d=null!==(o=null===(a=A[0])||void 0===a?void 0:a.start)&&void 0!==o?o:0);var L=null!=I?I:1/0;if(void 0!==A[A.length-1]){var U=A[A.length-1],F=null!==(s=U.end)&&void 0!==s?s:void 0!==U.duration?U.start+U.duration:void 0;void 0!==F&&F<L&&(L=F)}void 0!==M&&M<L&&(L=M),c={isLinear:!1,maximumSafePosition:L,livePosition:void 0,time:D}}var B=!p||void 0===e.attributes.minimumUpdatePeriod&&(void 0!==(null===(u=A[A.length-1])||void 0===u?void 0:u.end)||void 0!==e.attributes.duration),z={availabilityStartTime:g,clockOffset:n.externalClockOffset,isDynamic:p,isLive:p,isLastPeriodKnown:B,periods:A,publishTime:v.publishTime,suggestedPresentationDelay:v.suggestedPresentationDelay,transportType:"dash",timeBounds:{minimumSafePosition:d,timeshiftDepth:R,maximumTimeData:c},lifetime:l,uris:t(n.url)?f.locations:[n.url].concat(f.locations)};return{type:"done",value:{parsed:z,warnings:r}}}(n,r,i,o):{type:"needs-xlinks",value:{xlinksUrls:p.map((function(e){return e.ressource})),continue:function(t){if(t.length!==p.length)throw new Error("DASH parser: wrong number of loaded ressources.");for(var u=t.length-1;u>=0;u--){var l,d=p[u].index,c=t[u],f=c.parsed,v=c.warnings,h=c.receivedTime,m=c.sendingTime,g=c.url;v.length>0&&i.push.apply(i,v);for(var y,_=Os(f);!(y=_()).done;){var b=y.value;o.set(b,{receivedTime:h,sendingTime:m,url:g})}(l=s.periods).splice.apply(l,[d,1].concat(f))}return e(n,r,i,a,o)}}}};function Us(e){var t=e.textContent,n=[];return null===t||0===t.length?[void 0,n]:[{value:t},n]}function Fs(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"id":t.id=r.value;break;case"lang":t.language=r.value;break;case"contentType":t.contentType=r.value;break;case"par":t.par=r.value}}return t}var Bs=/^P(([\d.]*)Y)?(([\d.]*)M)?(([\d.]*)D)?T?(([\d.]*)H)?(([\d.]*)M)?(([\d.]*)S)?/,zs=/([0-9]+)-([0-9]+)/;function Vs(e,t){return"true"===e?[!0,null]:"false"===e?[!1,null]:[!1,new Zs("`"+t+'` property is not a boolean value but "'+e+'"')]}function Ks(e,t){var n=parseInt(e,10);return isNaN(n)?[null,new Zs("`"+t+'` property is not an integer value but "'+e+'"')]:[n,null]}function Ws(e,t){if("INF"===e)return[1/0,null];var n=parseFloat(e);return isNaN(n)?[null,new Zs("`"+t+'` property is invalid: "'+e+'"')]:[n,null]}function Gs(e,t){if("true"===e)return[!0,null];if("false"===e)return[!1,null];var n=parseInt(e,10);return isNaN(n)?[null,new Zs("`"+t+'` property is not a boolean nor an integer but "'+e+'"')]:[n,null]}function js(e,t){var n=Date.parse(e);return isNaN(n)?[null,new Zs("`"+t+'` is in an invalid date format: "'+e+'"')]:[new Date(Date.parse(e)).getTime()/1e3,null]}function Hs(e,t){if(!et(e))return[0,new Zs("`"+t+"` property is empty")];var n=Bs.exec(e);return null===n?[null,new Zs("`"+t+'` property has an unrecognized format "'+e+'"')]:[365*parseFloat(et(n[2])?n[2]:"0")*24*60*60+30*parseFloat(et(n[4])?n[4]:"0")*24*60*60+24*parseFloat(et(n[6])?n[6]:"0")*60*60+60*parseFloat(et(n[8])?n[8]:"0")*60+60*parseFloat(et(n[10])?n[10]:"0")+parseFloat(et(n[12])?n[12]:"0"),null]}function qs(e,t){var n=zs.exec(e);return null===n?[null,new Zs("`"+t+'` property has an unrecognized format "'+e+'"')]:[[+n[1],+n[2]],null]}function Ys(e,t){try{return[Wa(e),null]}catch(n){return[null,new Zs("`"+t+'` is not a valid base64 string: "'+e+'"')]}}function Qs(e,t){var n=/^(\d+)\/(\d+)$/.exec(e);return null!==n?[+n[1]/+n[2],null]:Ws(e,t)}function $s(e){for(var t,n,r=0;r<e.attributes.length;r++){var i=e.attributes[r];switch(i.name){case"schemeIdUri":t=i.value;break;case"value":n=i.value}}return{schemeIdUri:t,value:n}}function Xs(e,t){return function(n,r){var i=r.asKey,a=(0,r.parser)(n,r.dashName),o=a[0],s=a[1];null!==s&&(T.warn(s.message),t.push(s)),null!==o&&(e[i]=o)}}var Zs=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(j(r),t.prototype),r.name="MPDError",r.message=n,r}return f(t,e),t}(Y(Error));function Js(e){var t=function(e){for(var t=[],n=[],r=0;r<e.length;r++)if(e[r].nodeType===Node.ELEMENT_NODE){var i=e[r];if("cenc:pssh"===i.nodeName){var a=i.textContent;if(null!==a&&a.length>0){var o=Ys(a,"cenc:pssh"),s=o[0],u=o[1];null!==u&&(T.warn(u.message),t.push(u)),null!==s&&n.push(s)}}}return[{cencPssh:n},t]}(e.childNodes),n=t[0],r=t[1];return[{children:n,attributes:function(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"schemeIdUri":t.schemeIdUri=r.value;break;case"value":t.value=r.value;break;case"cenc:default_KID":t.keyId=xa(r.value.replace(/-/g,""))}}return t}(e)},r]}function eu(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"range":r(a.value,{asKey:"range",parser:qs,dashName:"range"});break;case"sourceURL":t.media=a.value}}return[t,n]}function tu(e){for(var t={},n=[],r=Xs(t,n),i=e.childNodes,a=0;a<i.length;a++)if(i[a].nodeType===Node.ELEMENT_NODE){var o=i[a];if("Initialization"===o.nodeName){var s=eu(o),u=s[0],l=s[1];t.initialization=u,n=n.concat(l)}}for(var d=0;d<e.attributes.length;d++){var c=e.attributes[d];switch(c.name){case"timescale":r(c.value,{asKey:"timescale",parser:Ks,dashName:"timescale"});break;case"presentationTimeOffset":r(c.value,{asKey:"presentationTimeOffset",parser:Ws,dashName:"presentationTimeOffset"});break;case"indexRange":r(c.value,{asKey:"indexRange",parser:qs,dashName:"indexRange"});break;case"indexRangeExact":r(c.value,{asKey:"indexRangeExact",parser:Vs,dashName:"indexRangeExact"});break;case"availabilityTimeOffset":r(c.value,{asKey:"availabilityTimeOffset",parser:Ws,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(c.value,{asKey:"availabilityTimeComplete",parser:Vs,dashName:"availabilityTimeComplete"});break;case"duration":r(c.value,{asKey:"duration",parser:Ks,dashName:"duration"});break;case"startNumber":r(c.value,{asKey:"startNumber",parser:Ks,dashName:"startNumber"});break;case"endNumber":r(c.value,{asKey:"endNumber",parser:Ks,dashName:"endNumber"})}}return[t,n]}function nu(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"media":t.media=a.value;break;case"indexRange":r(a.value,{asKey:"indexRange",parser:qs,dashName:"indexRange"});break;case"index":t.index=a.value;break;case"mediaRange":r(a.value,{asKey:"mediaRange",parser:qs,dashName:"mediaRange"})}}return[t,n]}function ru(e){for(var t=tu(e),n=t[0],r=t[1],i=[],a=e.childNodes,o=0;o<a.length;o++)if(a[o].nodeType===Node.ELEMENT_NODE){var s=a[o];if("SegmentURL"===s.nodeName){var u=nu(s),l=u[0],d=u[1];i.push(l),r=r.concat(d)}}return[m(n,{list:i}),r]}function iu(e){var t=null;return function(){if(null===t){var n=e.getElementsByTagName("S");return t=n,n}return t}}function au(e){for(var n,r=tu(e),i=r[0],a=r[1],o=0;o<e.childNodes.length;o++)if(e.childNodes[o].nodeType===Node.ELEMENT_NODE){var s=e.childNodes[o];"SegmentTimeline"===s.nodeName&&(n=iu(s))}for(var u=m({},i,{duration:i.duration,timelineParser:n}),l=Xs(u,a),d=0;d<e.attributes.length;d++){var c=e.attributes[d];switch(c.nodeName){case"initialization":t(u.initialization)&&(u.initialization={media:c.value});break;case"index":u.index=c.value;break;case"availabilityTimeOffset":l(c.value,{asKey:"availabilityTimeOffset",parser:Ws,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":l(c.value,{asKey:"availabilityTimeComplete",parser:Vs,dashName:"availabilityTimeComplete"});break;case"media":u.media=c.value;break;case"bitstreamSwitching":l(c.value,{asKey:"bitstreamSwitching",parser:Vs,dashName:"bitstreamSwitching"})}}return[u,a]}function ou(e){var n=function(e){for(var n={baseURLs:[]},r=[],i=[],a=0;a<e.length;a++)if(e[a].nodeType===Node.ELEMENT_NODE){var o=e[a];switch(o.nodeName){case"BaseURL":var s=Us(o),u=s[0],l=s[1];void 0!==u&&n.baseURLs.push(u),i=i.concat(l);break;case"InbandEventStream":void 0===n.inbandEventStreams&&(n.inbandEventStreams=[]),n.inbandEventStreams.push($s(o));break;case"SegmentBase":var d=tu(o),c=d[0],f=d[1];n.segmentBase=c,f.length>0&&(i=i.concat(f));break;case"SegmentList":var v=ru(o),p=v[0],h=v[1];i=i.concat(h),n.segmentList=p;break;case"SegmentTemplate":var m=au(o),g=m[0],y=m[1];i=i.concat(y),n.segmentTemplate=g;break;case"ContentProtection":var _=Js(o),b=_[0],S=_[1];S.length>0&&(i=i.concat(S)),void 0!==b&&r.push(b);break;case"SupplementalProperty":t(n.supplementalProperties)?n.supplementalProperties=[$s(o)]:n.supplementalProperties.push($s(o))}}return r.length>0&&(n.contentProtections=r),[n,i]}(e.childNodes),r=n[0],i=n[1],a=function(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"audioSamplingRate":t.audioSamplingRate=a.value;break;case"bandwidth":r(a.value,{asKey:"bitrate",parser:Ks,dashName:"bandwidth"});break;case"codecs":t.codecs=a.value;break;case"codingDependency":r(a.value,{asKey:"codingDependency",parser:Vs,dashName:"codingDependency"});break;case"frameRate":r(a.value,{asKey:"frameRate",parser:Qs,dashName:"frameRate"});break;case"height":r(a.value,{asKey:"height",parser:Ks,dashName:"height"});break;case"id":t.id=a.value;break;case"maxPlayoutRate":r(a.value,{asKey:"maxPlayoutRate",parser:Ws,dashName:"maxPlayoutRate"});break;case"maximumSAPPeriod":r(a.value,{asKey:"maximumSAPPeriod",parser:Ws,dashName:"maximumSAPPeriod"});break;case"mimeType":t.mimeType=a.value;break;case"profiles":t.profiles=a.value;break;case"qualityRanking":r(a.value,{asKey:"qualityRanking",parser:Ks,dashName:"qualityRanking"});break;case"scte214:supplementalCodecs":t.supplementalCodecs=a.value;break;case"segmentProfiles":t.segmentProfiles=a.value;break;case"width":r(a.value,{asKey:"width",parser:Ks,dashName:"width"});break;case"availabilityTimeOffset":r(a.value,{asKey:"availabilityTimeOffset",parser:Ws,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(a.value,{asKey:"availabilityTimeComplete",parser:Vs,dashName:"availabilityTimeComplete"})}}return void 0===t.bitrate&&n.push(new Zs("No bitrate found on a Representation")),[t,n]}(e),o=a[0],s=a[1];return[{children:r,attributes:o},i.concat(s)]}function su(e){var n=function(e){for(var n={baseURLs:[],representations:[]},r=[],i=[],a=0;a<e.length;a++)if(e[a].nodeType===Node.ELEMENT_NODE){var o=e[a];switch(o.nodeName){case"Accessibility":void 0===n.accessibilities?n.accessibilities=[$s(o)]:n.accessibilities.push($s(o));break;case"BaseURL":var s=Us(o),u=s[0],l=s[1];void 0!==u&&n.baseURLs.push(u),l.length>0&&(i=i.concat(l));break;case"ContentComponent":n.contentComponent=Fs(o);break;case"EssentialProperty":t(n.essentialProperties)?n.essentialProperties=[$s(o)]:n.essentialProperties.push($s(o));break;case"InbandEventStream":void 0===n.inbandEventStreams&&(n.inbandEventStreams=[]),n.inbandEventStreams.push($s(o));break;case"Label":var d=o.textContent;null!=d&&(n.label=d);break;case"Representation":var c=ou(o),f=c[0],v=c[1];n.representations.push(f),v.length>0&&(i=i.concat(v));break;case"Role":t(n.roles)?n.roles=[$s(o)]:n.roles.push($s(o));break;case"SupplementalProperty":t(n.supplementalProperties)?n.supplementalProperties=[$s(o)]:n.supplementalProperties.push($s(o));break;case"SegmentBase":var p=tu(o),h=p[0],m=p[1];n.segmentBase=h,m.length>0&&(i=i.concat(m));break;case"SegmentList":var g=ru(o),y=g[0],_=g[1];n.segmentList=y,_.length>0&&(i=i.concat(_));break;case"SegmentTemplate":var b=au(o),S=b[0],E=b[1];n.segmentTemplate=S,E.length>0&&(i=i.concat(E));break;case"ContentProtection":var T=Js(o),k=T[0],w=T[1];w.length>0&&(i=i.concat(w)),void 0!==k&&r.push(k)}}return r.length>0&&(n.contentProtections=r),[n,i]}(e.childNodes),r=n[0],i=n[1],a=function(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"group":r(a.value,{asKey:"group",parser:Ks,dashName:"group"});break;case"lang":t.language=a.value;break;case"contentType":t.contentType=a.value;break;case"par":t.par=a.value;break;case"minBandwidth":r(a.value,{asKey:"minBitrate",parser:Ks,dashName:"minBandwidth"});break;case"maxBandwidth":r(a.value,{asKey:"maxBitrate",parser:Ks,dashName:"maxBandwidth"});break;case"minWidth":r(a.value,{asKey:"minWidth",parser:Ks,dashName:"minWidth"});break;case"maxWidth":r(a.value,{asKey:"maxWidth",parser:Ks,dashName:"maxWidth"});break;case"minHeight":r(a.value,{asKey:"minHeight",parser:Ks,dashName:"minHeight"});break;case"maxHeight":r(a.value,{asKey:"maxHeight",parser:Ks,dashName:"maxHeight"});break;case"minFrameRate":r(a.value,{asKey:"minFrameRate",parser:Qs,dashName:"minFrameRate"});break;case"maxFrameRate":r(a.value,{asKey:"maxFrameRate",parser:Qs,dashName:"maxFrameRate"});break;case"selectionPriority":r(a.value,{asKey:"selectionPriority",parser:Ks,dashName:"selectionPriority"});break;case"segmentAlignment":r(a.value,{asKey:"segmentAlignment",parser:Gs,dashName:"segmentAlignment"});break;case"subsegmentAlignment":r(a.value,{asKey:"subsegmentAlignment",parser:Gs,dashName:"subsegmentAlignment"});break;case"bitstreamSwitching":r(a.value,{asKey:"bitstreamSwitching",parser:Vs,dashName:"bitstreamSwitching"});break;case"audioSamplingRate":t.audioSamplingRate=a.value;break;case"codecs":t.codecs=a.value;break;case"scte214:supplementalCodecs":t.supplementalCodecs=a.value;break;case"codingDependency":r(a.value,{asKey:"codingDependency",parser:Vs,dashName:"codingDependency"});break;case"frameRate":r(a.value,{asKey:"frameRate",parser:Qs,dashName:"frameRate"});break;case"height":r(a.value,{asKey:"height",parser:Ks,dashName:"height"});break;case"maxPlayoutRate":r(a.value,{asKey:"maxPlayoutRate",parser:Ws,dashName:"maxPlayoutRate"});break;case"maximumSAPPeriod":r(a.value,{asKey:"maximumSAPPeriod",parser:Ws,dashName:"maximumSAPPeriod"});break;case"mimeType":t.mimeType=a.value;break;case"profiles":t.profiles=a.value;break;case"segmentProfiles":t.segmentProfiles=a.value;break;case"width":r(a.value,{asKey:"width",parser:Ks,dashName:"width"});break;case"availabilityTimeOffset":r(a.value,{asKey:"availabilityTimeOffset",parser:Ws,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(a.value,{asKey:"availabilityTimeComplete",parser:Vs,dashName:"availabilityTimeComplete"})}}return[t,n]}(e),o=a[0],s=a[1];return[{children:r,attributes:o},i.concat(s)]}function uu(e){for(var t={children:{events:[]},attributes:{}},n=[],r=Xs(t.attributes,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"schemeIdUri":t.attributes.schemeIdUri=a.value;break;case"timescale":r(a.value,{asKey:"timescale",parser:Ks,dashName:"timescale"});break;case"value":t.attributes.value=a.value}}for(var o=0;o<e.childNodes.length;o++)if(e.childNodes[o].nodeType===Node.ELEMENT_NODE){var s=e.childNodes[o];if("Event"===s.nodeName){var u=lu(s),l=u[0],d=u[1];t.children.events.push(l),d.length>0&&(n=n.concat(d))}}return[t,n]}function lu(e){for(var t={eventStreamData:e},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"presentationTime":r(a.value,{asKey:"presentationTime",parser:Ks,dashName:"presentationTime"});break;case"duration":r(a.value,{asKey:"duration",parser:Ks,dashName:"duration"});break;case"id":t.id=a.value}}return[t,n]}function du(e){var t=function(e){for(var t,n=[],r=[],i=[],a=[],o=0;o<e.length;o++)if(e[o].nodeType===Node.ELEMENT_NODE){var s=e[o];switch(s.nodeName){case"BaseURL":var u=Us(s),l=u[0],d=u[1];void 0!==l&&n.push(l),i=i.concat(d);break;case"AdaptationSet":var c=su(s),f=c[0],v=c[1];r.push(f),i=i.concat(v);break;case"EventStream":var p=uu(s),h=p[0],m=p[1];a.push(h),i=i.concat(m);break;case"SegmentTemplate":var g=au(s),y=g[0],_=g[1];t=y,_.length>0&&(i=i.concat(_))}}return[{baseURLs:n,adaptations:r,eventStreams:a,segmentTemplate:t},i]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"start":r(a.value,{asKey:"start",parser:Hs,dashName:"start"});break;case"duration":r(a.value,{asKey:"duration",parser:Hs,dashName:"duration"});break;case"bitstreamSwitching":r(a.value,{asKey:"bitstreamSwitching",parser:Vs,dashName:"bitstreamSwitching"});break;case"xlink:href":t.xlinkHref=a.value;break;case"xlink:actuate":t.xlinkActuate=a.value}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}function cu(e){var t=function(e){for(var t=[],n=[],r=[],i=[],a=[],o=0;o<e.length;o++)if(e[o].nodeType===Node.ELEMENT_NODE){var s=e[o];switch(s.nodeName){case"BaseURL":var u=Us(s),l=u[0],d=u[1];void 0!==l&&t.push(l),a=a.concat(d);break;case"Location":n.push(null===s.textContent?"":s.textContent);break;case"Period":var c=du(s),f=c[0],v=c[1];r.push(f),a=a.concat(v);break;case"UTCTiming":var p=$s(s);i.push(p)}}return[{baseURLs:t,locations:n,periods:r,utcTimings:i},a]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"profiles":t.profiles=a.value;break;case"type":t.type=a.value;break;case"availabilityStartTime":r(a.value,{asKey:"availabilityStartTime",parser:js,dashName:"availabilityStartTime"});break;case"availabilityEndTime":r(a.value,{asKey:"availabilityEndTime",parser:js,dashName:"availabilityEndTime"});break;case"publishTime":r(a.value,{asKey:"publishTime",parser:js,dashName:"publishTime"});break;case"mediaPresentationDuration":r(a.value,{asKey:"duration",parser:Hs,dashName:"mediaPresentationDuration"});break;case"minimumUpdatePeriod":r(a.value,{asKey:"minimumUpdatePeriod",parser:Hs,dashName:"minimumUpdatePeriod"});break;case"minBufferTime":r(a.value,{asKey:"minBufferTime",parser:Hs,dashName:"minBufferTime"});break;case"timeShiftBufferDepth":r(a.value,{asKey:"timeShiftBufferDepth",parser:Hs,dashName:"timeShiftBufferDepth"});break;case"suggestedPresentationDelay":r(a.value,{asKey:"suggestedPresentationDelay",parser:Hs,dashName:"suggestedPresentationDelay"});break;case"maxSegmentDuration":r(a.value,{asKey:"maxSegmentDuration",parser:Hs,dashName:"maxSegmentDuration"});break;case"maxSubsegmentDuration":r(a.value,{asKey:"maxSubsegmentDuration",parser:Hs,dashName:"maxSubsegmentDuration"})}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}var fu=function(e,n){var r=e.documentElement;if(t(r)||"MPD"!==r.nodeName)throw new Error("DASH Parser: document root should be MPD");var i=cu(r),a=i[0],o=i[1];return function e(n){if("done"===n.type)return n;if("needs-clock"===n.type)return{type:"needs-resources",value:{urls:[n.value.url],format:"string",continue:function(t){if(1!==t.length)throw new Error("DASH parser: wrong number of loaded ressources.");var r=n.value.continue(t[0].responseData);return e(r)}}};if("needs-xlinks"===n.type)return{type:"needs-resources",value:{urls:n.value.xlinksUrls,format:"string",continue:function(r){for(var i=[],a=0;a<r.length;a++){var o=r[a],s=o.responseData,u=o.receivedTime,l=o.sendingTime,d=o.url;if(!s.success)throw s.error;var c="<root>"+s.data+"</root>",f=(new DOMParser).parseFromString(c,"text/xml");if(t(f)||0===f.children.length)throw new Error("DASH parser: Invalid external ressources");for(var v=f.children[0].children,p=[],h=[],m=0;m<v.length;m++)if(v[m].nodeType===Node.ELEMENT_NODE){var g=du(v[m]),y=g[0],_=g[1];h.push.apply(h,_),p.push(y)}i.push({url:d,receivedTime:u,sendingTime:l,parsed:p,warnings:h})}var b=n.value.continue(i);return e(b)}}};X()}(Ls(a,n,o))};function vu(e){var t=e.referenceDateTime,n=void 0!==e.serverSyncInfos?e.serverSyncInfos.serverTimestamp-e.serverSyncInfos.clientTime:void 0;return function(r,i,a,o,s){var u,l=r.responseData,d=i.externalClockOffset,c=null!==(u=r.url)&&void 0!==u?u:i.originalUrl,f=null!=n?n:d,v={unsafelyBaseOnPreviousManifest:i.unsafeMode?i.previousManifest:null,url:c,referenceDateTime:t,externalClockOffset:f},p=ot.dashParsers;if(null===p.wasm||"uninitialized"===p.wasm.status||"failure"===p.wasm.status)return T.debug("DASH: WASM MPD Parser not initialized. Running JS one."),g();var h=function(e){if(e instanceof ArrayBuffer)return e;if("string"==typeof e)return Aa(e).buffer;if(e instanceof Document)return Aa(e.documentElement.innerHTML).buffer;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return function(e){var t=new DataView(e);if(61371===t.getUint16(0)&&191===t.getUint8(2))return!0;if(65279===t.getUint16(0)||65534===t.getUint16(0))return!1;return!0}(h)?"initialized"===p.wasm.status?(T.debug("DASH: Running WASM MPD Parser."),y(p.wasm.runWasmParser(h,v))):(T.debug("DASH: Awaiting WASM initialization before parsing the MPD."),p.wasm.waitForInitialization().catch((function(){})).then((function(){return null===p.wasm||"initialized"!==p.wasm.status?(T.warn("DASH: WASM MPD parser initialization failed. Running JS parser instead"),g()):(T.debug("DASH: Running WASM MPD Parser."),y(p.wasm.runWasmParser(h,v)))}))):(T.info("DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one."),g());function g(){if(null===p.js)throw new Error("No MPD parser is imported");var e=function(e){if(e instanceof ArrayBuffer)return(new DOMParser).parseFromString(Ra(new Uint8Array(e)),"text/xml");if("string"==typeof e)return(new DOMParser).parseFromString(e,"text/xml");if(e instanceof Document)return e;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return y(p.js(e,v))}function y(t){if("done"===t.type){if(t.value.warnings.length>0&&a(t.value.warnings),o.isCancelled())return Promise.reject(o.cancellationError);var n=[];return{manifest:new It(t.value.parsed,e,n),url:c,warnings:n}}var r=t.value,i=r.urls.map((function(e){return s((function(){var t=b.getCurrent().DEFAULT_REQUEST_TIMEOUT,n=b.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return"string"===r.format?co({url:e,responseType:"text",timeout:t,connectionTimeout:n,cancelSignal:o}):co({url:e,responseType:"arraybuffer",timeout:t,connectionTimeout:n,cancelSignal:o})})).then((function(e){if("string"===r.format){if("string"!=typeof e.responseData)throw new Error("External DASH resources should have been a string");return m(e,{responseData:{success:!0,data:e.responseData}})}if(!(e.responseData instanceof ArrayBuffer))throw new Error("External DASH resources should have been ArrayBuffers");return m(e,{responseData:{success:!0,data:e.responseData}})}),(function(e){var t=Ne(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"An unknown error occured when parsing ressources."});return m({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:t}})}))}));return Promise.all(i).then((function(e){return r.format,y(r.continue(e))}))}}}var pu="function"==typeof Headers?Headers:null,hu="function"==typeof AbortController?AbortController:null;function mu(){return"function"==typeof s.fetch&&!t(hu)&&!t(pu)}function gu(e,t){return"audio"===e||"video"===e?"video/mp4"===t||"audio/mp4"===t?"mp4":"video/webm"===t||"audio/webm"===t?"webm":void 0:"text"===e&&"application/mp4"===t?"mp4":void 0}function yu(e){return function(t,n,r,i,a){return new Promise((function(s,u){var l=new Z,d=l.linkToSignal(i);function c(){l.signal.deregister(u),d()}l.signal.register(u),e(t,n,r,l.signal,Object.assign(Object.assign({},a),{onNewChunk:function(e){try{o(e),a.onNewChunk(e)}catch(e){c(),l.cancel(),u(e)}}})).then((function(e){if(c(),!l.isUsed()){if("segment-loaded"===e.resultType)try{o(e.resultData.responseData)}catch(e){return void u(e)}s(e)}}),(function(e){c(),u(e)}))}));function o(e){(e instanceof ArrayBuffer||e instanceof Uint8Array)&&"mp4"===gu(n.type,n.mimeType)&&vo(new Uint8Array(e),n.segment.isInit)}}}function _u(e,t){return null===e?null:null===t.url?e.baseUrl:Sa(e.baseUrl,t.url)}function bu(e,t,n,r,i){if(void 0===t.range)return co({url:e,responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(void 0===t.indexRange)return co({url:e,headers:{Range:Co(t.range)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(t.range[1]+1===t.indexRange[0])return co({url:e,headers:{Range:Co([t.range[0],t.indexRange[1]])},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));var a=co({url:e,headers:{Range:Co(t.range)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),o=co({url:e,headers:{Range:Co(t.indexRange)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then((function(t){var n=t[0],r=t[1],i=Xr(new Uint8Array(n.responseData),new Uint8Array(r.responseData)),a=Math.min(n.sendingTime,r.sendingTime),o=Math.max(n.receivedTime,r.receivedTime);return{resultType:"segment-loaded",resultData:{url:e,responseData:i,size:n.size+r.size,requestDuration:o-a,sendingTime:a,receivedTime:o}}}))}function Su(e,n,r,i,a){var o=n.segment,s=void 0!==o.range?{Range:Co(o.range)}:void 0,u=null;return function(e){var n;if(!t(e.headers))if(t(pu))n=e.headers;else{n=new pu;for(var r=Object.keys(e.headers),i=0;i<r.length;i++){var a=r[i];n.append(a,e.headers[a])}}T.debug("Fetch: Called with URL",e.url);var o,s,u=null,l=!1,c=!1,f=ne(),v=t(hu)?null:new hu;function h(){t(v)?T.warn("Fetch: AbortController API not available."):v.abort()}void 0!==e.timeout&&(o=setTimeout((function(){l=!0,void 0!==s&&clearTimeout(s),h()}),e.timeout)),void 0!==e.connectionTimeout&&(s=setTimeout((function(){c=!0,void 0!==o&&clearTimeout(o),h()}),e.connectionTimeout));var m=e.cancelSignal.register((function(e){u=e,h()})),g={method:"GET"};return void 0!==n&&(g.headers=n),g.signal=t(v)?null:v.signal,fetch(e.url,g).then((function(n){if(void 0!==s&&clearTimeout(s),n.status>=300)throw T.warn("Fetch: Request HTTP Error",n.status,n.url),new ke(n.url,n.status,we.ERROR_HTTP_CODE);if(t(n.body))throw new ke(n.url,n.status,we.PARSE_ERROR);var r=n.headers.get("Content-Length"),i=t(r)||isNaN(+r)?void 0:+r,a=n.body.getReader(),u=0;return l();function l(){return c.apply(this,arguments)}function c(){return(c=d(p().mark((function r(){var s,d,c,v,h;return p().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,a.read();case 2:if((s=r.sent).done||t(s.value)){r.next=11;break}return u+=s.value.byteLength,d=ne(),c={url:n.url,currentTime:d,duration:d-f,sendingTime:f,chunkSize:s.value.byteLength,chunk:s.value.buffer,size:u,totalSize:i},e.onData(c),r.abrupt("return",l());case 11:if(!s.done){r.next=17;break}return void 0!==o&&clearTimeout(o),m(),v=ne(),h=v-f,r.abrupt("return",{requestDuration:h,receivedTime:v,sendingTime:f,size:u,status:n.status,url:n.url});case 17:return r.abrupt("return",l());case 18:case"end":return r.stop()}}),r)})))).apply(this,arguments)}})).catch((function(t){if(null!==u)throw u;if(m(),l)throw T.warn("Fetch: Request timed out."),new ke(e.url,0,we.TIMEOUT);if(c)throw T.warn("Fetch: Request connection timed out."),new ke(e.url,0,we.TIMEOUT);if(t instanceof ke)throw t;throw T.warn("Fetch: Request Error",t instanceof Error?t.toString():""),new ke(e.url,0,we.ERROR_EVENT)}))}({url:e,headers:s,onData:function(e){var t=new Uint8Array(e.chunk),n=function(e){for(var t=0,n=[],r=null;t<e.length;){var i=fo(r=e.subarray(t,1/0),1836019558);if(i<0)break;var a=t+i+ei(e,i+t);if(a>e.length)break;var o=fo(r,1835295092);if(o<0)break;var s=t+o+ei(e,o+t);if(s>e.length)break;var u=Math.max(a,s),l=e.subarray(t,u);n.push(l),t=u}return 0===n.length?[null,r]:[Xr.apply(void 0,n),r]}(null!==u?Xr(u,t):t),r=n[0];u=n[1],null!==r&&(i.onNewChunk(r),a.isCancelled())||(i.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize}),a.isCancelled())},timeout:r.timeout,cancelSignal:a}).then((function(e){return{resultType:"chunk-complete",resultData:e}}))}function Eu(e,t,n,r,i,a){if(t.segment.isInit)return bu(e,t.segment,r,a,i);var o=gu(t.type,t.mimeType);if(n&&("mp4"===o||void 0===o)){if(mu())return Su(e,t,r,i,a);Be("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}var s=t.segment;return co({url:e,responseType:"arraybuffer",headers:void 0!==s.range?{Range:Co(s.range)}:void 0,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}var Tu="function"==typeof Uint8Array.prototype.slice?function(e,t,n){return e.slice(t,n)}:function(e,t,n){return new Uint8Array(Array.prototype.slice.call(e,t,n))};function ku(e,t){if(e[t]>1)T.warn("ISOBMFF: un-handled PSSH version");else{var n=t+4;if(!(n+16>e.length))return Ca(Tu(e,n,n+16))}}var wu=408125543,Au=357149030,Iu=2807729,Ru=17545,xu=475249515,Cu=187,Mu=179,Pu=183,Du=241;function Ou(e,t,n,r){for(var i=r[0],a=r[1],o=i;o<a;){var s=Fu(n,o);if(null===s)return null;var u=s.value,l=o+s.length,d=Bu(n,l);if(null===d)return null;var c=l+d.length,f=c+d.value;if(u===e)return[c,f];if(t.length>0)for(var v=0;v<t.length;v++){if(u===t[v])return Ou(e,t.slice(v+1,t.length),n,[c,f])}o=f}return null}function Nu(e,t){var n=Ou(Iu,[wu,Au],e,[t,e.length]);if(null===n)return null;var r=n[1]-n[0];return 1e9/zu(e,n[0],r)}function Lu(e,t){var n=Ou(Ru,[wu,Au],e,[t,e.length]);if(null===n)return null;var r=n[1]-n[0];return 4===r?function(e,t){return new DataView(e.buffer).getFloat32(t)}(e,n[0]):8===r?function(e,t){return new DataView(e.buffer).getFloat64(t)}(e,n[0]):null}function Uu(e,t){for(var n=1;n<=8;n++)if(e[t]>=Math.pow(2,8-n))return n}function Fu(e,t){var n=Uu(e,t);if(void 0===n)return T.warn("webm: unrepresentable length"),null;if(t+n>e.length)return T.warn("webm: impossible length"),null;for(var r=0,i=0;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return{length:n,value:r}}function Bu(e,t){var n=Uu(e,t);if(void 0===n)return T.warn("webm: unrepresentable length"),null;if(t+n>e.length)return T.warn("webm: impossible length"),null;for(var r=(e[t]&(1<<8-n)-1)*Math.pow(2,8*(n-1)),i=1;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return{length:n,value:r}}function zu(e,t,n){for(var r=0,i=0;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return r}function Vu(e,t,n,r){var i=function(e){var t=ha(e);if(null!==t){var n=ca(t,1952867444);if(null!==n){var r=n[0];return 1===r?ti(n,4):0===r?ei(n,4):void 0}}}(e);if(void 0===i||void 0===r)return null;var a,o=void 0!==n.timestampOffset?i+n.timestampOffset*r:i,s=_o(e);if(o<0&&(void 0!==s&&(s+=o),o=0),t||!n.complete)return void 0===s&&T.warn("DASH: Chunked segments should indicate a duration through their trun boxes"),{time:o/r,duration:void 0!==s?s/r:void 0};var u=n.duration*r,l=Math.min(.9*r,u/4);return void 0!==s&&Math.abs(s-u)<=l&&(a=s),{time:o/r,duration:void 0!==a?a/r:a}}function Ku(e,t){if(0!==e.length){var n=e.reduce((function(e,t){return"urn:mpeg:dash:event:2012"===t.schemeIdUri&&"1"===t.value?(void 0===e.manifestRefreshEventsFromEMSGs&&(e.manifestRefreshEventsFromEMSGs=[]),e.manifestRefreshEventsFromEMSGs.push(t)):(void 0===e.EMSGs&&(e.EMSGs=[]),e.EMSGs.push(t)),e}),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),r=n.manifestRefreshEventsFromEMSGs,i=n.EMSGs,a=null==i?void 0:i.map((function(e){return{type:"emsg",value:e}})),o=void 0!==t&&void 0!==r&&function(e,t){if(e.length<=0)return!1;for(var n=e.length,r=0;r<n;r++){var i=t,a=Ra(e[r].messageData),o=Date.parse(a);if(void 0===i||void 0===o||isNaN(o)||o>=i)return!0}return!1}(r,t);return{inbandEvents:a,needsManifestRefresh:o}}}function Wu(e){var n=e.__priv_patchLastSegmentInSidx;return function(e,r,i){var a,o,s=r.segment,u=r.periodStart,l=r.periodEnd,d=e.data,c=e.isChunked,f=[u,l];if(null===d)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:f};var v=d instanceof Uint8Array?d:new Uint8Array(d),p=gu(r.type,r.mimeType),h="mp4"===p||void 0===p,m=[];if(h){var g,y=function(e){var t=0,n=ca(e,1836019574);if(null===n)return[];for(var r=[];t<n.length;){var i=void 0;try{i=fa(n,1886614376)}catch(e){var a=e instanceof Error?e:"";return T.warn("Error while removing PSSH from ISOBMFF",a),r}if(null===i)return r;var o=Tu(n,i[0],i[2]),s=ku(o,i[1]-i[0]);void 0!==s&&r.push({systemId:s,data:o}),n[i[0]+4]=102,n[i[0]+5]=114,n[i[0]+6]=101,n[i[0]+7]=101,t=i[2]}return r}(v);s.isInit&&(g=null!==(a=function(e){var t=da(e,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(null===t)return null;var n=t.subarray(8),r=ca(n,1701733238),i=0;if(null===r?(i=28,r=ca(n,1701733217)):i=78,null===r)return null;var a=da(r.subarray(i),[1936289382,1935894633,1952804451]);return null===a||a.byteLength<24?null:a.subarray(8,24)}(v))&&void 0!==a?a:void 0),(y.length>0||void 0!==g)&&m.push({initDataType:"cenc",keyId:g,initData:y})}if(!s.isInit){var _=h?Vu(v,c,s,i):null,b=null!==(o=s.timestampOffset)&&void 0!==o?o:0;if(h){var S=function(e){for(var t=[],n=0;n<e.length;){var r=ya(e,n);if(null===r)break;var i=r.length;n+=i;var a=r[0];if(0!==a)T.warn("ISOBMFF: EMSG version "+a.toString()+" not supported.");else{var o=4,s=Pa(r,o),u=s.end,l=s.string,d=Pa(r,o=u),c=d.end,f=d.string,v=ei(r,o=c),p=ei(r,o+=4),h=ei(r,o+=4),m=ei(r,o+=4);o+=4;var g={schemeIdUri:l,value:f,timescale:v,presentationTimeDelta:p,eventDuration:h,id:m,messageData:r.subarray(o,i)};t.push(g)}}if(0!==t.length)return t}(v);if(void 0!==S){var E=Ku(S.filter((function(e){return void 0!==s.privateInfos&&void 0!==s.privateInfos.isEMSGWhitelisted&&s.privateInfos.isEMSGWhitelisted(e)})),r.manifestPublishTime);if(void 0!==E){var k=E.needsManifestRefresh,w=E.inbandEvents;return{segmentType:"media",chunkData:v,chunkSize:v.length,chunkInfos:_,chunkOffset:b,appendWindow:f,inbandEvents:w,protectionData:m,needsManifestRefresh:k}}}}return{segmentType:"media",chunkData:v,chunkSize:v.length,chunkInfos:_,chunkOffset:b,protectionData:m,appendWindow:f}}var A,I,R=s.indexRange;if("webm"===p)A=function(e,t){var n=Ou(wu,[],e,[t,e.length]);if(null===n)return null;var r=n[0],i=n[1],a=Nu(e,r);if(null===a)return null;var o=Lu(e,r);if(null===o)return null;var s=Ou(xu,[],e,[r,i]);if(null===s)return null;for(var u=[],l=s[0];l<s[1];){var d=Ou(Cu,[],e,[l,s[1]]);if(null===d)break;var c=Ou(Mu,[],e,[d[0],d[1]]);if(null===c)return null;var f=zu(e,c[0],c[1]-c[0]),v=Ou(Du,[Pu],e,[d[0],d[1]]);if(null===v)return null;var p=zu(e,v[0],v[1]-v[0])+r;u.push({time:f,rangeStart:p}),l=d[1]}for(var h=[],m=0;m<u.length;m++){var g=u[m];m===u.length-1?h.push({time:g.time,timescale:a,duration:0===m?o:o-g.time,range:[g.rangeStart,1/0]}):h.push({time:g.time,timescale:a,duration:u[m+1].time-g.time,range:[g.rangeStart,u[m+1].rangeStart-1]})}return h}(v,0);else if(h&&(A=go(v,Array.isArray(R)?R[0]:0),!0===n&&null!==A&&A.length>0)){var x=A[A.length-1];Array.isArray(x.range)&&(x.range[1]=1/0)}h?I=bo(v):"webm"===p&&(I=Nu(v,0));var C=t(I)?void 0:I;return{segmentType:"init",initializationData:v,initializationDataSize:v.length,protectionData:m,initTimescale:C,segmentList:null!=A?A:void 0}}}function Gu(e,t,n,r){var i,a,o=e.segment,s=e.language,u=e.codecs;if(o.isInit)return null;null===n?r?(i=o.time,a=o.end):T.warn("Transport: Unavailable time data for current text track."):(i=n.time,void 0!==n.duration?a=i+n.duration:!r&&o.complete&&(a=i+o.duration));var l=function(e){if(void 0===e)throw new Error("Cannot parse subtitles: unknown format");switch(e.toLowerCase()){case"stpp":case"stpp.ttml.im1t":return"ttml";case"wvtt":return"vtt"}throw new Error('The codec used for the subtitles "'+e+'" is not managed yet.')}(u),d=function(e){var t=ga(e);return null===t?"":Ra(t)}(t);return{data:d,type:l,language:s,start:i,end:a}}function ju(e,t,n){var r,i,a=e.segment;return a.isInit?null:(n?T.warn("Transport: Unavailable time data for current text track."):(r=a.time,a.complete&&(i=a.time+a.duration)),{data:t,type:function(e,t){switch(t){case"application/ttml+xml":return"ttml";case"application/x-sami":case"application/smil":return"sami";case"text/vtt":return"vtt"}if(void 0!==e&&"srt"===e.toLowerCase())return"srt";throw new Error("could not find a text-track parser for the type "+(null!=t?t:""))}(e.codecs,e.mimeType),language:e.language,start:r,end:i})}function Hu(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=e.data,l=e.isChunked;if(null===u)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:null!==(i=s.timestampOffset)&&void 0!==i?i:0,protectionData:[],appendWindow:[a,o]};var d=gu(n.type,n.mimeType);if("webm"===d)throw new Error("Text tracks with a WEBM container are not yet handled.");return"mp4"===d?function(e,t,n,r,i){var a,o,s=n.segment,u=s.isInit,l=s.indexRange;if(o="string"==typeof e?Aa(e):e instanceof Uint8Array?e:new Uint8Array(e),u){var d=go(o,Array.isArray(l)?l[0]:0);if(!0===i&&null!==d&&d.length>0){var c=d[d.length-1];Array.isArray(c.range)&&(c.range[1]=1/0)}return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:bo(o),segmentList:null!=d?d:void 0}}var f=Vu(o,t,s,r),v=Gu(n,o,f,t),p=null!==(a=s.timestampOffset)&&void 0!==a?a:0;return{segmentType:"media",chunkData:v,chunkSize:o.length,chunkInfos:f,chunkOffset:p,protectionData:[],appendWindow:[n.periodStart,n.periodEnd]}}(u,l,n,r,t):function(e,t,n){var r,i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=s.timestampOffset,l=void 0===u?0:u;if(s.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if("string"!=typeof e){var d=e instanceof Uint8Array?e:new Uint8Array(e);r=Ra(d),i=d.length}else r=e;return{segmentType:"media",chunkData:ju(n,r,t),chunkSize:i,chunkInfos:null,chunkOffset:l,protectionData:[],appendWindow:[a,o]}}(u,l,n)}}var qu=function(e){var t=po({customManifestLoader:e.manifestLoader},null===ot.dashParsers.wasm||"initialized"!==ot.dashParsers.wasm.status&&"initializing"!==ot.dashParsers.wasm.status?"arraybuffer":"text"),n=vu(e),r=function(e){var t=e.lowLatencyMode,n=e.segmentLoader;return!0!==e.checkMediaSegmentIntegrity?r:yu(r);function r(e,r,i,a,o){var s=_u(e,r.segment);return null===s?Promise.resolve({resultType:"segment-created",resultData:null}):t||void 0===n?Eu(s,r,t,i,o,a):new Promise((function(e,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a DASH segment through a custom segmentLoader.",o=new xt(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(t){d||a.isCancelled()||(d=!0,a.deregister(p),e({resultType:"segment-loaded",resultData:{responseData:t.data,size:t.size,requestDuration:t.duration}}))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),Eu(s,r,t,i,o,a).then(e,u))}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:s},v=n(f,c);function p(e){d||(d=!0,"function"==typeof v&&v(),u(e))}a.register(p)}))}}(e),i=Wu(e),a=function(e){var t=e.lowLatencyMode;return!0!==e.checkMediaSegmentIntegrity?n:yu(n);function n(e,n,r,i,a){var o=n.segment,s=o.range,u=_u(e,o);if(null===u)return Promise.resolve({resultType:"segment-created",resultData:null});if(o.isInit)return bu(u,o,r,i,a);var l=gu(n.type,n.mimeType),d="mp4"===l||void 0===l;if(t&&d){if(mu())return Su(u,n,r,a,i);Be("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}return d?co({url:u,responseType:"arraybuffer",headers:Array.isArray(s)?{Range:Co(s)}:null,timeout:r.timeout,connectionTimeout:r.connectionTimeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}})):co({url:u,responseType:"text",headers:Array.isArray(s)?{Range:Co(s)}:null,timeout:r.timeout,connectionTimeout:r.connectionTimeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}}(e);return{manifest:{loadManifest:t,parseManifest:n},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:Hu(e)}}};function Yu(e){void 0===e.transports.dash&&(e.transports.dash=qu),e.dashParsers.js=fu,e.mainThreadMediaSourceInit=ra,e.codecSupportProber=sa}var Qu=function(e){function n(t){var n;return(n=e.call(this)||this)._settings=t,n._initCanceller=new Z,n}f(n,e);var r=n.prototype;return r.prepare=function(){},r.start=function(e,t){var n=this,r=this._initCanceller.signal,i=this._settings,a=i.keySystems,o=i.speed,s=i.url;xr(e);var u=new G(null);u.finish();var l=zi(e,a,u,{onError:function(e){return n._onFatalError(e)},onWarning:function(e){return n.trigger("warning",e)},onBlackListProtectionData:S,onKeyIdsCompatibilityUpdate:S},r);ea(e,(function(e){return n._onFatalError(e)}),r);var d=new Wi(t,null,o);d.addEventListener("stalled",(function(e){return n.trigger("stalled",e)})),d.addEventListener("unstalled",(function(){return n.trigger("unstalled",null)})),d.addEventListener("warning",(function(e){return n.trigger("warning",e)})),r.register((function(){d.destroy()})),d.start(),l.onUpdate((function(i,a){"uninitialized"!==i.initializationState.type&&(a(),T.info("Setting URL to HTMLMediaElement",s),e.src=s,r.register((function(){T.info("Init: Removing directfile src from media element",e.src),xr(e)})),"awaiting-media-link"===i.initializationState.type?(i.initializationState.value.isMediaLinked.setValue(!0),l.onUpdate((function(r,i){"initialized"===r.initializationState.type&&(i(),n._seekAndPlay(e,t))}),{emitCurrentValue:!0,clearSignal:r})):($(i.initializationState.type),n._seekAndPlay(e,t)))}),{emitCurrentValue:!0,clearSignal:r})},r.updateContentUrls=function(e,t){throw new Error("Cannot update content URL of directfile contents")},r.dispose=function(){this._initCanceller.cancel()},r._onFatalError=function(e){this._initCanceller.cancel(),this.trigger("error",e)},r._seekAndPlay=function(e,n){var r=this,i=this._initCanceller.signal,a=this._settings,o=a.autoPlay,s=a.startAt;Bi({mediaElement:e,playbackObserver:n,startTime:function(){T.debug("Init: Calculating initial time");var n=function(e,n){if(t(n))return 0;if(!t(n.position))return n.position;if(!t(n.wallClockTime))return n.wallClockTime;if(!t(n.fromFirstPosition))return n.fromFirstPosition;var r=e.duration;if("number"==typeof n.fromLastPosition)return t(r)||!isFinite(r)?(T.warn("startAt.fromLastPosition set but no known duration, beginning at 0."),0):Math.max(0,r+n.fromLastPosition);if("number"==typeof n.fromLivePosition){var i=e.seekable.length>0?e.seekable.end(0):r;return t(i)?(T.warn("startAt.fromLivePosition set but no known live position, beginning at 0."),0):Math.max(0,i+n.fromLivePosition)}if(!t(n.percentage)){if(t(r)||!isFinite(r))return T.warn("startAt.percentage set but no known duration, beginning at 0."),0;var a=n.percentage;return a>=100?r:a<=0?0:r*(+a/100)}return 0}(e,s);return T.debug("Init: Initial time calculated:",n),n},mustAutoPlay:o,onWarning:function(e){return r.trigger("warning",e)},isDirectfile:!0},i).autoPlayResult.then((function(){return Fi(n,e,!0,i).onUpdate((function(e,t){e&&(t(),r.trigger("loaded",{segmentSinksStore:null}))}),{emitCurrentValue:!0,clearSignal:i})})).catch((function(e){i.isCancelled()||r._onFatalError(e)}))},n}(wr);function $u(e,t){var n;if(t.length!==e.length)return!0;for(var r=0;r<t.length;r++)if(t[r].nativeTrack!==(null===(n=e[r])||void 0===n?void 0:n.nativeTrack))return!0;return!1}function Xu(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_audio_"+o+"_"+s.toString();r[o]=s+1;var l={language:a.language,id:u,normalized:it(a.language),audioDescription:"descriptions"===a.kind||"description"===a.kind,representations:[]};n.push({track:l,nativeTrack:a})}return n}function Zu(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_text_"+o+"_"+s.toString();r[o]=s+1;var l="forced"===a.kind||void 0,d={language:a.language,forced:l,label:a.label,id:u,normalized:it(a.language),closedCaption:"captions"===a.kind};n.push({track:d,nativeTrack:a})}return n}function Ju(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_video_"+o+"_"+s.toString();r[o]=s+1,n.push({track:{id:u,representations:[]},nativeTrack:a})}return n}var el=function(e){function n(t){var n,r,i,a;return(n=e.call(this)||this)._nativeAudioTracks=t.audioTracks,n._nativeVideoTracks=t.videoTracks,n._nativeTextTracks=t.textTracks,n._audioTracks=void 0!==n._nativeAudioTracks?Xu(n._nativeAudioTracks):[],n._videoTracks=void 0!==n._nativeVideoTracks?Ju(n._nativeVideoTracks):[],n._textTracks=void 0!==n._nativeTextTracks?Zu(n._nativeTextTracks):[],n._lastEmittedNativeAudioTrack=null===(r=n._getCurrentAudioTrack())||void 0===r?void 0:r.nativeTrack,n._lastEmittedNativeVideoTrack=null===(i=n._getCurrentVideoTrack())||void 0===i?void 0:i.nativeTrack,n._lastEmittedNativeTextTrack=null===(a=n._getCurrentTextTrack())||void 0===a?void 0:a.nativeTrack,n._handleNativeTracksCallbacks(),n}f(n,e);var r=n.prototype;return r.setAudioTrackById=function(e){for(var t=0;t<this._audioTracks.length;t++){var n=this._audioTracks[t],r=n.track,i=n.nativeTrack;if(r.id===e)return this._enableAudioTrackFromIndex(t),void(this._audioTrackLockedOn=i)}throw new Error("Audio track not found.")},r.disableTextTrack=function(){tl(this._textTracks),this._textTrackLockedOn=null},r.setTextTrackById=function(e){for(var t=!1,n=0;n<this._textTracks.length;n++){var r=this._textTracks[n],i=r.track,a=r.nativeTrack;i.id===e?(a.mode="showing",t=!0,this._textTrackLockedOn=a):"showing"!==a.mode&&"hidden"!==a.mode||(a.mode="disabled")}if(!t)throw new Error("Text track not found.")},r.disableVideoTrack=function(){rl(this._videoTracks),this._videoTrackLockedOn=null},r.setVideoTrackById=function(e){for(var t=0;t<this._videoTracks.length;t++){var n=this._videoTracks[t],r=n.track,i=n.nativeTrack;if(r.id===e)return i.selected=!0,void(this._videoTrackLockedOn=i)}throw new Error("Video track not found.")},r.getChosenAudioTrack=function(){var e=this._getCurrentAudioTrack();return t(e)?e:e.track},r.getChosenTextTrack=function(){var e=this._getCurrentTextTrack();return t(e)?e:e.track},r.getChosenVideoTrack=function(){var e=this._getCurrentVideoTrack();return t(e)?e:e.track},r.getAvailableAudioTracks=function(){return this._audioTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,language:t.language,normalized:t.normalized,audioDescription:t.audioDescription,active:n.enabled,representations:t.representations}}))},r.getAvailableTextTracks=function(){return this._textTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,label:t.label,forced:t.forced,language:t.language,normalized:t.normalized,closedCaption:t.closedCaption,active:"showing"===n.mode}}))},r.getAvailableVideoTracks=function(){return this._videoTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,representations:t.representations,active:n.selected}}))},r.dispose=function(){void 0!==this._nativeVideoTracks&&(this._nativeVideoTracks.onchange=null,this._nativeVideoTracks.onaddtrack=null,this._nativeVideoTracks.onremovetrack=null),void 0!==this._nativeAudioTracks&&(this._nativeAudioTracks.onchange=null,this._nativeAudioTracks.onaddtrack=null,this._nativeAudioTracks.onremovetrack=null),void 0!==this._nativeTextTracks&&(this._nativeTextTracks.onchange=null,this._nativeTextTracks.onaddtrack=null,this._nativeTextTracks.onremovetrack=null),this.removeEventListener()},r._getCurrentAudioTrack=function(){if(void 0!==this._nativeAudioTracks){for(var e=0;e<this._audioTracks.length;e++){var t=this._audioTracks[e];if(t.nativeTrack.enabled)return t}return null}},r._getCurrentVideoTrack=function(){if(void 0!==this._nativeVideoTracks){for(var e=0;e<this._videoTracks.length;e++){var t=this._videoTracks[e];if(t.nativeTrack.selected)return t}return null}},r._getCurrentTextTrack=function(){if(void 0!==this._nativeTextTracks){for(var e=0;e<this._textTracks.length;e++){var t=this._textTracks[e];if("showing"===t.nativeTrack.mode)return t}return null}},r._setPreviouslyLockedAudioTrack=function(){if(void 0!==this._audioTrackLockedOn)if(null===this._audioTrackLockedOn)for(var e=0;e<this._audioTracks.length;e++){this._audioTracks[e].nativeTrack.enabled=!1}else for(var t=0;t<this._audioTracks.length;t++){if(this._audioTracks[t].nativeTrack===this._audioTrackLockedOn)return void this._enableAudioTrackFromIndex(t)}},r._setPreviouslyLockedTextTrack=function(){if(void 0!==this._textTrackLockedOn)if(null!==this._textTrackLockedOn)for(var e=0;e<this._textTracks.length;e++){var t=this._textTracks[e].nativeTrack;if(t===this._textTrackLockedOn)return nl(this._textTracks,t),void("showing"!==t.mode&&(t.mode="showing"))}else tl(this._textTracks)},r._setPreviouslyLockedVideoTrack=function(){if(void 0!==this._videoTrackLockedOn)if(null!==this._videoTrackLockedOn)for(var e=0;e<this._videoTracks.length;e++){var t=this._videoTracks[e].nativeTrack;if(t===this._videoTrackLockedOn)return void(t.selected=!0)}else rl(this._videoTracks)},r._handleNativeTracksCallbacks=function(){var e=this;void 0!==this._nativeAudioTracks&&(this._nativeAudioTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeAudioTracks){var r=Xu(e._nativeAudioTracks);if($u(e._audioTracks,r)){e._audioTracks=r,e._setPreviouslyLockedAudioTrack(),e.trigger("availableAudioTracksChange",e.getAvailableAudioTracks());var i=e._getCurrentAudioTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeAudioTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeAudioTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeAudioTracks){var r=Xu(e._nativeAudioTracks);if($u(e._audioTracks,r)){e._audioTracks=r,e.trigger("availableAudioTracksChange",e.getAvailableAudioTracks());var i=e._getCurrentAudioTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeAudioTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeAudioTracks.onchange=function(){if(void 0!==e._audioTracks)for(var t=0;t<e._audioTracks.length;t++){var n=e._audioTracks[t],r=n.track,i=n.nativeTrack;if(i.enabled)return void(i!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",r),e._lastEmittedNativeAudioTrack=i))}null!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null),e._lastEmittedNativeAudioTrack=null)}),void 0!==this._nativeTextTracks&&(this._nativeTextTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeTextTracks){var r=Zu(e._nativeTextTracks);if($u(e._textTracks,r)){e._textTracks=r,e._setPreviouslyLockedTextTrack(),e.trigger("availableTextTracksChange",e.getAvailableTextTracks());var i=e._getCurrentTextTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeTextTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeTextTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeTextTracks){var r=Zu(e._nativeTextTracks);if($u(e._textTracks,r)){e._textTracks=r,e._setPreviouslyLockedTextTrack(),e.trigger("availableTextTracksChange",e.getAvailableTextTracks());var i=e._getCurrentTextTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeTextTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeTextTracks.onchange=function(){if(void 0!==e._textTracks)for(var t=0;t<e._textTracks.length;t++){var n=e._textTracks[t],r=n.track,i=n.nativeTrack;if("showing"===i.mode)return void(i!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",r),e._lastEmittedNativeTextTrack=i))}null!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null),e._lastEmittedNativeTextTrack=null)}),void 0!==this._nativeVideoTracks&&(this._nativeVideoTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeVideoTracks){var r=Ju(e._nativeVideoTracks);if($u(e._videoTracks,r)){e._videoTracks=r,e._setPreviouslyLockedVideoTrack(),e.trigger("availableVideoTracksChange",e.getAvailableVideoTracks());var i=e._getCurrentVideoTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeVideoTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeVideoTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeVideoTracks){var r=Ju(e._nativeVideoTracks);if($u(e._videoTracks,r)){e._videoTracks=r,e._setPreviouslyLockedVideoTrack(),e.trigger("availableVideoTracksChange",e.getAvailableVideoTracks());var i=e._getCurrentVideoTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeVideoTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeVideoTracks.onchange=function(){if(void 0!==e._videoTracks)for(var t=0;t<e._videoTracks.length;t++){var n=e._videoTracks[t],r=n.track,i=n.nativeTrack;if(i.selected)return void(i!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",r),e._lastEmittedNativeVideoTrack=i))}null!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null),e._lastEmittedNativeVideoTrack=null)})},r._enableAudioTrackFromIndex=function(e){!function(e,t){for(var n=0;n<e.length;n++)_i&&n===t||(e[n].enabled=!1);t<0||t>=e.length||(e[t].enabled=!0)}(this._audioTracks.map((function(e){return e.nativeTrack})),e)},n}(i);function tl(e){for(var t=0;t<e.length;t++){e[t].nativeTrack.mode="disabled"}}function nl(e,t){for(var n=0;n<e.length;n++){var r=e[n].nativeTrack;r===t||"showing"!==r.mode&&"hidden"!==r.mode||(r.mode="disabled")}}function rl(e){for(var t=0;t<e.length;t++){e[t].nativeTrack.selected=!1}}function il(e){e.directfile={initDirectFile:Qu,mediaElementTracksStore:el}}var al,ol=s.WebKitMediaKeys;function sl(e){return sl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},sl(e)}function ul(e){var t=function(e,t){if("object"!=sl(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=sl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==sl(t)?t:String(t)}function ll(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ul(r.key),r)}}function dl(e,t,n){return t&&ll(e.prototype,t),n&&ll(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}void 0!==ol&&"function"==typeof ol.isTypeSupported&&"function"==typeof ol.prototype.createSession&&"function"==typeof HTMLMediaElement.prototype.webkitSetMediaKeys&&(al=ol);var cl,fl=function(){function e(e,t,n){this._keyType=e,this._mediaKeys=t,this._configuration=n}var t=e.prototype;return t.createMediaKeys=function(){var e=this;return new Promise((function(t){return t(e._mediaKeys)}))},t.getConfiguration=function(){return this._configuration},dl(e,[{key:"keySystem",get:function(){return this._keyType}}]),e}(),vl=s.MSMediaKeys;function pl(e){try{var t=e();return"object"==typeof t&&null!==t&&"function"==typeof t.then?t:Promise.resolve(t)}catch(e){return Promise.reject(e)}}void 0!==vl&&void 0!==vl.prototype&&"function"==typeof vl.isTypeSupported&&"function"==typeof vl.prototype.createSession&&(cl=vl);var hl,ml=function(e){function n(t){var n;return(n=e.call(this)||this).expiration=NaN,n.keyStatuses=new Map,n._mk=t,n._sessionClosingCanceller=new Z,n.closed=new Promise((function(e){n._sessionClosingCanceller.signal.register((function(){return e()}))})),n.update=function(e){return new Promise((function(t,r){if(void 0===n._ss)return r("MediaKeySession not set.");try{t(n._ss.update(e,""))}catch(e){r(e)}}))},n}f(n,e);var r=n.prototype;return r.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r;r=t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer),n._ss=n._mk.createSession("video/mp4",r),Wr(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"message",e)}),n._sessionClosingCanceller.signal),Gr(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyadded",e)}),n._sessionClosingCanceller.signal),jr(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyerror",e)}),n._sessionClosingCanceller.signal),e()}))},r.close=function(){var e=this;return new Promise((function(n){t(e._ss)||(e._ss.close(),e._ss=void 0),e._sessionClosingCanceller.cancel(),n()}))},r.load=function(){return Promise.resolve(!1)},r.remove=function(){return Promise.resolve()},dl(n,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._ss)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),n}(i),gl=function(){function e(e){if(void 0===cl)throw new Error("No MSMediaKeys API.");this._mediaKeys=new cl(e)}var t=e.prototype;return t._setVideo=function(e){var t=this;return pl((function(){t._videoElement=e,void 0!==t._videoElement.msSetMediaKeys&&t._videoElement.msSetMediaKeys(t._mediaKeys)}))},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new ml(this._mediaKeys)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();var yl=s.MozMediaKeys;function _l(e){return"function"==typeof(null==e?void 0:e.webkitGenerateKeyRequest)}void 0!==yl&&void 0!==yl.prototype&&"function"==typeof yl.isTypeSupported&&"function"==typeof yl.prototype.createSession&&(hl=yl);var bl=function(e){function t(t,n){var r;(r=e.call(this)||this)._vid=t,r._key=n,r.sessionId="",r._closeSession=S,r.keyStatuses=new Map,r.expiration=NaN;var i=function(e){r.trigger(e.type,e)};return r.closed=new Promise((function(e){r._closeSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.removeEventListener(e,i),t.removeEventListener("webkit"+e,i)})),e()}})),["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.addEventListener(e,i),t.addEventListener("webkit"+e,i)})),r}f(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){try{if(t._key.indexOf("clearkey")>=0){var i=e instanceof ArrayBuffer?new Uint8Array(e):e,a=JSON.parse(Ra(i)),o=Wa(a.keys[0].k),s=Wa(a.keys[0].kid);n(t._vid.webkitAddKey(t._key,o,s,""))}else n(t._vid.webkitAddKey(t._key,e,null,""))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){n._vid.webkitGenerateKeyRequest(n._key,t),e()}))},n.close=function(){var e=this;return new Promise((function(t){e._closeSession(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},t}(i),Sl=function(){function e(e){this._keySystem=e}var n=e.prototype;return n._setVideo=function(e){var t=this;return pl((function(){if(!_l(e))throw new Error("Video not attached to the MediaKeys");t._videoElement=e}))},n.createSession=function(){if(t(this._videoElement))throw new Error("Video not attached to the MediaKeys");return new bl(this._videoElement,this._keySystem)},n.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();function El(e,t){var n=e instanceof Uint8Array?e:new Uint8Array(e),r=t instanceof Uint8Array?t:new Uint8Array(t),i=function(e,t){return e[t+0]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]}(n,0);if(i+4!==n.length)throw new Error("Unsupported WebKit initData.");var a=wa(n),o=a.indexOf("skd://"),s=function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint8Array(t),r=0;r<n.length;r+=2){var i=e.charCodeAt(r/2);n[r]=255&i,n[r+1]=i>>8&255}return n}(o>-1?a.substring(o+6):a),u=0,l=new Uint8Array(n.byteLength+4+s.byteLength+4+r.byteLength);return l.set(n),u+=n.length,l.set(ai(s.byteLength),u),u+=4,l.set(s,u),u+=s.byteLength,l.set(ai(r.byteLength),u),u+=4,l.set(r,u),l}function Tl(e,t){var n=e;return pl((function(){if(void 0===n.webkitSetMediaKeys)throw new Error("No webKitMediaKeys API.");n.webkitSetMediaKeys(t)}))}var kl=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._serverCertificate=r,i._videoElement=t,i._keyType=n,i._unbindSession=S,i._closeSession=S,i.closed=new Promise((function(e){i._closeSession=e})),i.keyStatuses=new Map,i.expiration=NaN,i}f(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){if(void 0===t._nativeSession||void 0===t._nativeSession.update||"function"!=typeof t._nativeSession.update)return r("Unavailable WebKit key session.");try{var i;i=e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e.buffer),n(t._nativeSession.update(i))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r,i,a=n._videoElement;if(void 0===(null===(r=a.webkitKeys)||void 0===r?void 0:r.createSession))throw new Error("No WebKitMediaKeys API.");if(ar(n._keyType,"com.apple.fps")){if(void 0===n._serverCertificate)throw new Error("A server certificate is needed for creating fairplay session.");i=El(t,n._serverCertificate)}else i=t;var o=a.webkitKeys.createSession("video/mp4",i);if(null==o)throw new Error("Impossible to get the key sessions");n._listenEvent(o),n._nativeSession=o,e()}))},n.close=function(){var e=this;return new Promise((function(t,n){e._unbindSession(),e._closeSession(),void 0!==e._nativeSession?(e._nativeSession.close(),t()):n("No session to close.")}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},n._listenEvent=function(e){var t=this;this._unbindSession();var n=function(e){t.trigger(e.type,e)};["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.addEventListener(t,n),e.addEventListener("webkit"+t,n)})),this._unbindSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.removeEventListener(t,n),e.removeEventListener("webkit"+t,n)}))}},dl(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._nativeSession)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(i),wl=function(){function e(e){if(void 0===al)throw new Error("No WebKitMediaKeys API.");this._keyType=e,this._mediaKeys=new al(e)}var t=e.prototype;return t._setVideo=function(e){if(this._videoElement=e,void 0===this._videoElement)throw new Error("Video not attached to the MediaKeys");return Tl(this._videoElement,this._mediaKeys)},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new kl(this._videoElement,this._keyType,this._serverCertificate)},t.setServerCertificate=function(e){return this._serverCertificate=e,Promise.resolve()},e}();function Al(){if(void 0===al)throw new Error("No WebKitMediaKeys API.");return{isTypeSupported:al.isTypeSupported,createCustomMediaKeys:function(e){return new wl(e)},setMediaKeys:function(e,t){if(null===t)return Tl(e,t);if(!(t instanceof wl))throw new Error("Custom setMediaKeys is supposed to be called with webkit custom MediaKeys.");return t._setVideo(e)}}}var Il=function(e){var n,r,i,a,u=Rl;if("standard"!==e&&("auto"!==e||(mi||gi)&&void 0!==al)||!o&&t(navigator.requestMediaKeySystemAccess)){var l,d;if("webkit"===e&&void 0!==al){i=Or(["needkey"]);var c=Al();l=c.isTypeSupported,d=c.createCustomMediaKeys,u=c.setMediaKeys,a="webkit"}else if(_l(null===(n=s.HTMLVideoElement)||void 0===n?void 0:n.prototype)){i=Or(["needkey"]);var f={isTypeSupported:function(e){var n=document.querySelector("video");return t(n)&&(n=document.createElement("video")),!t(n)&&"function"==typeof n.canPlayType&&!!n.canPlayType("video/mp4",e)},createCustomMediaKeys:function(e){return new Sl(e)},setMediaKeys:function(e,t){if(null===t)return Promise.resolve(void 0);if(!(t instanceof Sl))throw new Error("Custom setMediaKeys is supposed to be called with old webkit custom MediaKeys.");return t._setVideo(e)}};l=f.isTypeSupported,d=f.createCustomMediaKeys,u=f.setMediaKeys,a="older-webkit"}else if(void 0!==al){i=Or(["needkey"]);var v=Al();l=v.isTypeSupported,d=v.createCustomMediaKeys,u=v.setMediaKeys,a="webkit"}else if(vi&&void 0!==cl){i=Or(["encrypted","needkey"]);var p={isTypeSupported:function(e,t){if(void 0===cl)throw new Error("No MSMediaKeys API.");return void 0!==t?cl.isTypeSupported(e,t):cl.isTypeSupported(e)},createCustomMediaKeys:function(e){return new gl(e)},setMediaKeys:function(e,t){if(null===t)return Promise.resolve(void 0);if(!(t instanceof gl))throw new Error("Custom setMediaKeys is supposed to be called with IE11 custom MediaKeys.");return t._setVideo(e)}};l=p.isTypeSupported,d=p.createCustomMediaKeys,u=p.setMediaKeys,a="ms"}else if(void 0!==hl){i=Or(["encrypted","needkey"]);var h={isTypeSupported:function(e,t){if(void 0===hl)throw new Error("No MozMediaKeys API.");return void 0!==t?hl.isTypeSupported(e,t):hl.isTypeSupported(e)},createCustomMediaKeys:function(e){if(void 0===hl)throw new Error("No MozMediaKeys API.");return new hl(e)},setMediaKeys:function(e,t){return pl((function(){var n=e;if(void 0===n.mozSetMediaKeys||"function"!=typeof n.mozSetMediaKeys)throw new Error("Can't set video on MozMediaKeys.");return n.mozSetMediaKeys(t)}))}};l=h.isTypeSupported,d=h.createCustomMediaKeys,u=h.setMediaKeys,a="moz"}else{i=Or(["encrypted","needkey"]);var m=s.MediaKeys,g=function(){if(void 0===m)throw new Me("MEDIA_KEYS_NOT_SUPPORTED","No `MediaKeys` implementation found in the current browser.");if(void 0===m.isTypeSupported){throw new Error("This browser seems to be unable to play encrypted contents currently.Note: Some browsers do not allow decryption in some situations, like when not using HTTPS.")}};l=function(e){return g(),$(m.isTypeSupported),m.isTypeSupported(e)},d=function(e){return g(),new m(e)},a="unknown"}r=function(e,n){if(!l(e))return Promise.reject(new Error("Unsupported key type"));for(var r=0;r<n.length;r++){var i=n[r],a=i.videoCapabilities,o=i.audioCapabilities,s=i.initDataTypes,u=i.distinctiveIdentifier,c=!0;if(c=(c=c&&(t(s)||s.some((function(e){return"cenc"===e}))))&&"required"!==u){var f={initDataTypes:["cenc"],distinctiveIdentifier:"not-allowed",persistentState:"required",sessionTypes:["temporary","persistent-license"]};void 0!==a&&(f.videoCapabilities=a),void 0!==o&&(f.audioCapabilities=o);var v=d(e);return Promise.resolve(new fl(e,v,f))}}return Promise.reject(new Error("Unsupported configuration"))}}else r=function(){var e;return(e=navigator).requestMediaKeySystemAccess.apply(e,arguments)},i=Or(["encrypted"]),a="standard";return{requestMediaKeySystemAccess:r,onEncrypted:i,setMediaKeys:u,implementation:a}}("auto");function Rl(e,t){try{var n,r=e;return"function"==typeof r.setMediaKeys?n=r.setMediaKeys(t):"function"==typeof r.webkitSetMediaKeys?n=r.webkitSetMediaKeys(t):"function"==typeof r.mozSetMediaKeys?n=r.mozSetMediaKeys(t):"function"==typeof r.msSetMediaKeys&&null!==t&&(n=r.msSetMediaKeys(t)),"object"==typeof n&&null!==n&&"function"==typeof n.then?n:Promise.resolve(n)}catch(e){return Promise.reject(e)}}var xl=Il,Cl=ei(Aa("pssh"),0);function Ml(e,t){for(var n=0;n<e.length;n++){var r=e[n];if((void 0===t.systemId||void 0===r.systemId||t.systemId===r.systemId)&&st(t.data,r.data))return!0}return!1}function Pl(e){var n=e.initData,r=e.initDataType;if(t(n))return T.warn("Compat: No init data found on media encrypted event."),null;var i=function(e){for(var t=[],n=0;n<e.length;){if(e.length<n+8||ei(e,n+4)!==Cl)return T.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var r=ei(new Uint8Array(e),n);if(n+r>e.length)return T.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var i=e.subarray(n,n+r),a={systemId:ku(i,8),data:i};Ml(t,a)?T.warn("Compat: Duplicated PSSH found in initialization data, removing it."):t.push(a),n+=r}return n!==e.length?(T.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}]):t}(new Uint8Array(n));return{type:r,values:i}}function Dl(e){return Tr.setState(e,null),xl.setMediaKeys(e,null).then((function(){T.info("DRM: MediaKeys disabled with success")})).catch((function(e){T.error("DRM: Could not disable MediaKeys",e instanceof Error?e:"Unknown Error")}))}function Ol(){return(Ol=d(p().mark((function e(t,n,r){var i,a,o,s,u,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.emeImplementation,a=n.keySystemOptions,o=n.loadedSessionsStore,s=n.mediaKeySystemAccess,u=n.mediaKeys,l=Tr.getState(t),d=null!==l&&l.loadedSessionsStore!==o?l.loadedSessionsStore.closeAllSessions():Promise.resolve(),e.next=5,d;case 5:if(!r.isCancelled()){e.next=7;break}throw r.cancellationError;case 7:if(Tr.setState(t,{emeImplementation:i,keySystemOptions:a,mediaKeySystemAccess:s,mediaKeys:u,loadedSessionsStore:o}),t.mediaKeys!==u){e.next=10;break}return e.abrupt("return");case 10:T.info("DRM: Attaching MediaKeys to the media element"),i.setMediaKeys(t,u).then((function(){T.info("DRM: MediaKeys attached with success")})).catch((function(e){T.error("DRM: Could not set MediaKeys",e instanceof Error?e:"Unknown Error")}));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Nl(e){if(""===e.sessionId)return!1;var t=e.keyStatuses,n=[];return t.forEach((function(e){n.push(e)})),n.length<=0?(T.debug("DRM: isSessionUsable: MediaKeySession given has an empty keyStatuses",e.sessionId),!1):Ue(n,"expired")?(T.debug("DRM: isSessionUsable: MediaKeySession given has an expired key",e.sessionId),!1):Ue(n,"internal-error")?(T.debug("DRM: isSessionUsable: MediaKeySession given has a key with an internal-error",e.sessionId),!1):(T.debug("DRM: isSessionUsable: MediaKeySession is usable",e.sessionId),!0)}function Ll(e,t,n,r){var i=e.loadedSessionsStore,a=e.persistentSessionsStore;return"temporary"===n?Ul(i,t):null===a?(T.warn("DRM: Cannot create persistent MediaKeySession, PersistentSessionsStore not created."),Ul(i,t)):function(e,t,n,r){return Fl.apply(this,arguments)}(i,a,t,r)}function Ul(e,t){T.info("DRM: Creating a new temporary session");var n=e.createSession(t,"temporary");return Promise.resolve({type:"created-session",value:n})}function Fl(){return Fl=d(p().mark((function e(t,n,r,i){var a,o,s,u,l,c;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=function(){return c=d(p().mark((function e(){var o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===i.cancellationError){e.next=2;break}throw i.cancellationError;case 2:return T.info("DRM: Removing previous persistent session."),null!==(o=n.get(r))&&n.delete(o.sessionId),e.prev=5,e.next=8,t.closeSession(a.mediaKeySession);case 8:e.next=15;break;case 10:if(e.prev=10,e.t0=e.catch(5),""===a.mediaKeySession.sessionId){e.next=14;break}throw e.t0;case 14:t.removeSessionWithoutClosingIt(a.mediaKeySession);case 15:if(null===i.cancellationError){e.next=17;break}throw i.cancellationError;case 17:return s=t.createSession(r,"persistent-license"),e.abrupt("return",{type:"created-session",value:s});case 19:case"end":return e.stop()}}),e,null,[[5,10]])}))),c.apply(this,arguments)},l=function(){return c.apply(this,arguments)},null===i.cancellationError){e.next=4;break}throw i.cancellationError;case 4:if(T.info("DRM: Creating persistent MediaKeySession"),a=t.createSession(r,"persistent-license"),null!==(o=n.getAndReuse(r))){e.next=9;break}return e.abrupt("return",{type:"created-session",value:a});case 9:return e.prev=9,e.next=12,t.loadPersistentSession(a.mediaKeySession,o.sessionId);case 12:if(s=e.sent){e.next=19;break}return T.warn("DRM: No data stored for the loaded session"),n.delete(o.sessionId),t.removeSessionWithoutClosingIt(a.mediaKeySession),u=t.createSession(r,"persistent-license"),e.abrupt("return",{type:"created-session",value:u});case 19:if(!s||!Nl(a.mediaKeySession)){e.next=23;break}return n.add(r,r.keyIds,a.mediaKeySession),T.info("DRM: Succeeded to load persistent session."),e.abrupt("return",{type:"loaded-persistent-session",value:a});case 23:return T.warn("DRM: Previous persistent session not usable anymore."),e.abrupt("return",l());case 27:return e.prev=27,e.t0=e.catch(9),T.warn("DRM: Unable to load persistent session: "+(e.t0 instanceof Error?e.t0.toString():"Unknown Error")),e.abrupt("return",l());case 31:case"end":return e.stop()}}),e,null,[[9,27]])}))),Fl.apply(this,arguments)}function Bl(e,t){return zl.apply(this,arguments)}function zl(){return(zl=d(p().mark((function e(t,n){var r,i,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n<0||n>=t.getLength())){e.next=2;break}return e.abrupt("return");case 2:for(T.info("DRM: LSS cache limit exceeded",n,t.getLength()),r=[],i=t.getAll().slice(),a=i.length-n,o=0;o<a;o++)s=i[o],r.push(t.closeSession(s.mediaKeySession));return e.next=9,Promise.all(r);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Vl(e,t,n,r,i){return Kl.apply(this,arguments)}function Kl(){return(Kl=d(p().mark((function e(t,n,r,i,a){var o,s,u,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null,s=n.loadedSessionsStore,u=n.persistentSessionsStore,null===(l=s.reuse(t))){e.next=11;break}if(!Nl(o=l.mediaKeySession)){e.next=10;break}return T.info("DRM: Reuse loaded session",o.sessionId),e.abrupt("return",{type:"loaded-open-session",value:{mediaKeySession:o,sessionType:l.sessionType,keySessionRecord:l.keySessionRecord}});case 10:null!==u&&""!==l.mediaKeySession.sessionId&&u.delete(l.mediaKeySession.sessionId);case 11:if(null===o){e.next=16;break}return e.next=14,s.closeSession(o);case 14:if(null===a.cancellationError){e.next=16;break}throw a.cancellationError;case 16:return e.next=18,Bl(s,i);case 18:if(null===a.cancellationError){e.next=20;break}throw a.cancellationError;case 20:return e.next=22,Ll(n,t,r,a);case 22:return d=e.sent,e.abrupt("return",{type:d.type,value:{mediaKeySession:d.value.mediaKeySession,sessionType:d.value.sessionType,keySessionRecord:d.value.keySessionRecord}});case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Wl(e,n,r){var i=n.getConfiguration();if(vi||t(i))return null;var a=e.filter((function(e){return e.type===r.type&&(!!(t(e.persistentLicenseConfig)&&"required"!==e.persistentState||"required"===i.persistentState)&&("required"!==e.distinctiveIdentifier||"required"===i.distinctiveIdentifier))}))[0];return void 0!==a?{keySystemOptions:a,keySystemAccess:n}:null}function Gl(e){var n=e.keyName,r=e.keyType,i=e.keySystemOptions,a=["temporary"],o="optional",s="optional";t(i.persistentLicenseConfig)||(o="required",a.push("persistent-license")),t(i.persistentState)||(o=i.persistentState),t(i.distinctiveIdentifier)||(s=i.distinctiveIdentifier);var u,l,d=b.getCurrent(),c=d.EME_DEFAULT_AUDIO_CODECS,f=d.EME_DEFAULT_VIDEO_CODECS,v=d.EME_DEFAULT_WIDEVINE_ROBUSTNESSES,p=d.EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES,h=i.audioCapabilitiesConfig,m=i.videoCapabilitiesConfig;if("full"===(null==h?void 0:h.type))u=h.value;else{var g;0===(g="robustness"===(null==h?void 0:h.type)?h.value:"widevine"===n?v:"com.microsoft.playready.recommendation"===r?p:[]).length&&g.push(void 0);var y="contentType"===(null==h?void 0:h.type)?h.value:c;u=jo(g,(function(e){return y.map((function(t){return void 0!==e?{contentType:t,robustness:e}:{contentType:t}}))}))}if("full"===(null==m?void 0:m.type))l=m.value;else{var _;0===(_="robustness"===(null==m?void 0:m.type)?m.value:"widevine"===n?v:"com.microsoft.playready.recommendation"===r?p:[]).length&&_.push(void 0);var S="contentType"===(null==m?void 0:m.type)?m.value:f;l=jo(_,(function(e){return S.map((function(t){return void 0!==e?{contentType:t,robustness:e}:{contentType:t}}))}))}var E={initDataTypes:["cenc"],videoCapabilities:l,audioCapabilities:u,distinctiveIdentifier:s,persistentState:o,sessionTypes:a};return[E,Object.assign(Object.assign({},E),{audioCapabilities:void 0,videoCapabilities:void 0})]}function jl(e,n,r){T.info("DRM: Searching for compatible MediaKeySystemAccess");var i=Tr.getState(e);if(null!==i&&xl.implementation===i.emeImplementation.implementation){var a=Wl(n,i.mediaKeySystemAccess,i.keySystemOptions);if(null!==a)return T.info("DRM: Found cached compatible keySystem"),Promise.resolve({type:"reuse-media-key-system-access",value:{mediaKeySystemAccess:a.keySystemAccess,options:a.keySystemOptions}})}var o=n.reduce((function(e,n){var r,i=b.getCurrent().EME_KEY_SYSTEMS[n.type];if(t(i)){var a=function(e){for(var t=b.getCurrent().EME_KEY_SYSTEMS,n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];if(Ue(t[i],e))return i}}(n.type);r=[{keyName:a,keyType:n.type,keySystemOptions:n}]}else r=i.map((function(e){return{keyName:n.type,keyType:e,keySystemOptions:n}}));return e.concat(r)}),[]);return s(0);function s(e){return u.apply(this,arguments)}function u(){return(u=d(p().mark((function e(n){var i,a,u,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n>=o.length)){e.next=2;break}throw new Ce("INCOMPATIBLE_KEYSYSTEMS","No key system compatible with your wanted configuration has been found in the current browser.");case 2:if(!t(xl.requestMediaKeySystemAccess)){e.next=4;break}throw new Error("requestMediaKeySystemAccess is not implemented in your browser.");case 4:return i=o[n],a=i.keyType,u=i.keySystemOptions,l=Gl(i),T.debug("DRM: Request keysystem access "+a+","+(n+1)+" of "+o.length),e.prev=8,e.next=11,xl.requestMediaKeySystemAccess(a,l);case 11:return d=e.sent,T.info("DRM: Found compatible keysystem",a,n+1),e.abrupt("return",{type:"create-media-key-system-access",value:{options:u,mediaKeySystemAccess:d}});case 16:if(e.prev=16,e.t0=e.catch(8),T.debug("DRM: Rejected access to keysystem",a,n+1),null===r.cancellationError){e.next=21;break}throw r.cancellationError;case 21:return e.abrupt("return",s(n+1));case 22:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}}function Hl(e,t,n){var r;T.debug("Compat: Calling generateRequest on the MediaKeySession");try{r=function(e){T.info("Compat: Trying to move CENC PSSH from init data at the end of it.");for(var t=!1,n=new Uint8Array,r=new Uint8Array,i=0;i<e.length;){if(e.length<i+8||ei(e,i+4)!==Cl)throw T.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var a=ei(new Uint8Array(e),i);if(i+a>e.length)throw T.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var o=e.subarray(i,i+a);if(16===e[i+12]&&119===e[i+13]&&239===e[i+14]&&236===e[i+15]&&192===e[i+16]&&178===e[i+17]&&77===e[i+18]&&2===e[i+19]&&172===e[i+20]&&227===e[i+21]&&60===e[i+22]&&30===e[i+23]&&82===e[i+24]&&226===e[i+25]&&251===e[i+26]&&75===e[i+27]){var s=pa(o),u=null===s?void 0:o[s[1]];T.info("Compat: CENC PSSH found with version",u),void 0===u?T.warn("Compat: could not read version of CENC PSSH"):t===(1===u)?n=Xr(n,o):1===u?(T.warn("Compat: cenc version 1 encountered, removing every other cenc pssh box."),n=o,t=!0):T.warn("Compat: filtering out cenc pssh box with wrong version",u)}else r=Xr(r,o);i+=a}if(i!==e.length)throw T.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");return Xr(r,n)}(n)}catch(e){r=n}var i=null!=t?t:"";return e.generateRequest(i,r).catch((function(t){if(""!==i||!(t instanceof TypeError))throw t;return T.warn('Compat: error while calling `generateRequest` with an empty initialization data type. Retrying with a default "cenc" value.',t),e.generateRequest("cenc",r)}))}var ql=100;function Yl(e,t){return Ql.apply(this,arguments)}function Ql(){return(Ql=d(p().mark((function e(t,n){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.info("DRM: Load persisted session",n),e.next=3,t.load(n);case 3:if((r=e.sent)&&!(t.keyStatuses.size>0)){e.next=6;break}return e.abrupt("return",r);case 6:return e.abrupt("return",new Promise((function(e){t.addEventListener("keystatuseschange",i);var n=setTimeout(i,ql);function i(){clearTimeout(n),t.removeEventListener("keystatuseschange",i),e(r)}})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $l(e){var t=new Z;return Promise.race([e.close().then((function(){t.cancel()})),e.closed.then((function(){t.cancel()})),function(){return n.apply(this,arguments)}()]);function n(){return(n=d(p().mark((function e(){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Mt(1e3,t.signal);case 3:return e.next=5,r();case 5:e.next=13;break;case 7:if(e.prev=7,e.t0=e.catch(0),!(e.t0 instanceof ee)){e.next=11;break}return e.abrupt("return");case 11:n=e.t0 instanceof Error?e.t0.message:"Unknown error made it impossible to close the session",T.error("DRM: "+n);case 13:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function r(){return i.apply(this,arguments)}function i(){return(i=d(p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.update(new Uint8Array(1));case 3:n.next=13;break;case 5:if(n.prev=5,n.t0=n.catch(0),!t.isUsed()){n.next=9;break}return n.abrupt("return");case 9:if(!(n.t0 instanceof Error&&"The session is already closed."===n.t0.message)){n.next=11;break}return n.abrupt("return");case 11:return n.next=13,Mt(1e3,t.signal);case 13:if(!t.isUsed()){n.next=15;break}return n.abrupt("return");case 15:throw new Error("Compat: Couldn't know if session is closed");case 16:case"end":return n.stop()}}),n,null,[[0,5]])})))).apply(this,arguments)}}function Xl(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Zl(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Zl(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Zl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Jl(e,t){for(var n,r,i=function(){var e=r.value;if(!t.some((function(t){return st(t,e)})))return{v:!1}},a=Xl(e);!(r=a()).done;)if(n=i())return n.v;return!0}function ed(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return td(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return td(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function td(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var nd=function(){function e(e){this._initializationData=e,this._keyIds=null}var t=e.prototype;return t.associateKeyIds=function(e){null===this._keyIds&&(this._keyIds=[]);for(var t=0,n=Array.from(e);t<n.length;t++){var r=n[t];this.isAssociatedWithKeyId(r)||this._keyIds.push(r)}},t.isAssociatedWithKeyId=function(e){if(null===this._keyIds)return!1;for(var t,n=ed(this._keyIds);!(t=n()).done;){if(st(t.value,e))return!0}return!1},t.getAssociatedKeyIds=function(){return null===this._keyIds?[]:this._keyIds},t.isCompatibleWith=function(e){var t=e.keyIds;if(void 0!==t&&t.length>0){if(null!==this._keyIds&&Jl(t,this._keyIds))return!0;if(void 0!==this._initializationData.keyIds)return Jl(t,this._initializationData.keyIds)}return this._checkInitializationDataCompatibility(e)},t._checkInitializationDataCompatibility=function(e){return void 0!==e.keyIds&&e.keyIds.length>0&&void 0!==this._initializationData.keyIds?Jl(e.keyIds,this._initializationData.keyIds):this._initializationData.type===e.type&&this._initializationData.values.isCompatibleWith(e.values)},e}();function rd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return id(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return id(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function id(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ad=function(){function e(e){this._mediaKeys=e,this._storage=[]}var n=e.prototype;return n.createSession=function(e,n){var r=this,i=new nd(e);T.debug("DRM-LSS: calling `createSession`",n);var a=this._mediaKeys.createSession(n),o={mediaKeySession:a,sessionType:n,keySessionRecord:i,isGeneratingRequest:!1,isLoadingPersistentSession:!1,closingStatus:{type:"none"}};return t(a.closed)||a.closed.then((function(){T.info("DRM-LSS: session was closed, removing it.",a.sessionId);var e=r.getIndex(i);e>=0&&r._storage[e].mediaKeySession===a&&r._storage.splice(e,1)})).catch((function(e){T.warn("DRM-LSS: MediaKeySession.closed rejected: "+e)})),this._storage.push(Object.assign({},o)),T.debug("DRM-LSS: MediaKeySession added",o.sessionType,this._storage.length),o},n.reuse=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.keySessionRecord.isCompatibleWith(e))return this._storage.splice(t,1),this._storage.push(n),T.debug("DRM-LSS: Reusing session:",n.mediaKeySession.sessionId,n.sessionType),Object.assign({},n)}return null},n.getEntryForSession=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.mediaKeySession===e)return Object.assign({},n)}return null},n.generateLicenseRequest=function(){var e=d(p().mark((function e(t,n,r){var i,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=rd(this._storage);case 1:if((o=a()).done){e.next=8;break}if((s=o.value).mediaKeySession!==t){e.next=6;break}return i=s,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==i){e.next=11;break}return T.error("DRM-LSS: generateRequest error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Hl(t,n,r));case 11:if(i.isGeneratingRequest=!0,"none"===i.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,Hl(t,n,r);case 17:e.next=26;break;case 19:if(e.prev=19,e.t0=e.catch(14),void 0!==i){e.next=23;break}throw e.t0;case 23:throw i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start(),e.t0;case 26:if(void 0!==i){e.next=28;break}return e.abrupt("return",void 0);case 28:i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start();case 30:case"end":return e.stop()}}),e,this,[[14,19]])})));return function(t,n,r){return e.apply(this,arguments)}}(),n.loadPersistentSession=function(){var e=d(p().mark((function e(t,n){var r,i,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=rd(this._storage);case 1:if((a=i()).done){e.next=8;break}if((o=a.value).mediaKeySession!==t){e.next=6;break}return r=o,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==r){e.next=11;break}return T.error("DRM-LSS: loadPersistentSession error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Yl(t,n));case 11:if(r.isLoadingPersistentSession=!0,"none"===r.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,Yl(t,n);case 17:s=e.sent,e.next=27;break;case 20:if(e.prev=20,e.t0=e.catch(14),void 0!==r){e.next=24;break}throw e.t0;case 24:throw r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.t0;case 27:if(void 0!==r){e.next=29;break}return e.abrupt("return",s);case 29:return r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.abrupt("return",s);case 32:case"end":return e.stop()}}),e,this,[[14,20]])})));return function(t,n){return e.apply(this,arguments)}}(),n.closeSession=function(){var e=d(p().mark((function e(t){var n,r,i,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=rd(this._storage);case 1:if((i=r()).done){e.next=8;break}if((a=i.value).mediaKeySession!==t){e.next=6;break}return n=a,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==n){e.next=11;break}return T.warn("DRM-LSS: No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Promise.resolve(!1));case 11:return e.abrupt("return",this._closeEntry(n));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getLength=function(){return this._storage.length},n.getAll=function(){return this._storage},n.closeAllSessions=function(){var e=d(p().mark((function e(){var t,n,r=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._storage,T.debug("DRM-LSS: Closing all current MediaKeySessions",t.length),this._storage=[],n=t.map((function(e){return r._closeEntry(e)})),e.next=6,Promise.all(n);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.removeSessionWithoutClosingIt=function(e){$(e.sessionId);for(var t=this._storage.length-1;t>=0;t--){if(this._storage[t].mediaKeySession===e)return T.debug("DRM-LSS: Removing session without closing it",e.sessionId),this._storage.splice(t,1),!0}return!1},n.getIndex=function(e){for(var t=0;t<this._storage.length;t++){if(this._storage[t].keySessionRecord===e)return t}return-1},n._closeEntry=function(){var e=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.mediaKeySession,e.abrupt("return",new Promise((function(e,r){function i(){void 0!==t&&(t.closingStatus={type:"pending"}),od(n).then((function(){void 0!==t&&(t.closingStatus={type:"done"}),e(!0)})).catch((function(e){void 0!==t&&(t.closingStatus={type:"failed"}),r(e)}))}void 0!==t&&(t.isLoadingPersistentSession||t.isGeneratingRequest)?t.closingStatus={type:"awaiting",start:i}:i()})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e}();function od(e){return sd.apply(this,arguments)}function sd(){return(sd=d(p().mark((function e(t){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.debug("DRM: Trying to close a MediaKeySession",t.sessionId),e.prev=1,e.next=4,$l(t);case 4:return T.debug("DRM: Succeeded to close MediaKeySession"),e.abrupt("return");case 8:return e.prev=8,e.t0=e.catch(1),T.error("DRM: Could not close MediaKeySession: "+(e.t0 instanceof Error?e.t0.toString():"Unknown error")),e.abrupt("return");case 12:case"end":return e.stop()}}),e,null,[[1,8]])})))).apply(this,arguments)}function ud(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e[n],t&=t;return t}var ld=function(){function e(e){this.initData=e}return e.prototype.toJSON=function(){return Ka(this.initData)},e.decode=function(e){return Wa(e)},e}();function dd(e,t){var n,r;return null!==(r=null!==(n=cd(e,t))&&void 0!==n?n:cd(t,e))&&void 0!==r&&r}function cd(e,t){if(0===e.length)return!1;if(t.length<e.length)return null;for(var n=e[0],r=0,i=0;i<t.length;i++){var a=t[i];if(a.systemId===n.systemId){if(a.hash!==n.hash)return!1;if(!st(n.data instanceof Uint8Array?n.data:"string"==typeof n.data?ld.decode(n.data):n.data.initData,a.data instanceof Uint8Array?a.data:"string"==typeof a.data?ld.decode(a.data):a.data.initData))return!1;if(t.length-i<e.length)return null;for(r=1;r<e.length;r++){var o=e[r];for(i+=1;i<t.length;i++){var s=t[i];if(o.systemId===s.systemId){if(o.hash!==s.hash)return!1;if(!st(o.data instanceof Uint8Array?o.data:"string"==typeof o.data?ld.decode(o.data):o.data.initData,s.data instanceof Uint8Array?s.data:"string"==typeof s.data?ld.decode(s.data):s.data.initData))return!1;break}}if(r===t.length)return null}return!0}}return null}function fd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function vd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function pd(e){!function(e,n,r){for(var i in void 0===r&&(r="object"),$(t(e)),n)n.hasOwnProperty(i)&&$((e[i],n[i]),n[i])}(e,{save:"function",load:"function"},"persistentLicenseConfig")}var hd=function(){function e(e){pd(e),this._entries=[],this._storage=e;try{var t=this._storage.load();Array.isArray(t)||(t=[]),this._entries=t}catch(e){T.warn("DRM-PSS: Could not get entries from license storage",e instanceof Error?e:""),this.dispose()}}var n=e.prototype;return n.getLength=function(){return this._entries.length},n.getAll=function(){return this._entries},n.get=function(e){var t=this._getIndex(e);return-1===t?null:this._entries[t]},n.getAndReuse=function(e){var t=this._getIndex(e);if(-1===t)return null;var n=this._entries.splice(t,1)[0];return this._entries.push(n),n},n.add=function(e,n,r){var i;if(!t(r)&&et(r.sessionId)){var a=r.sessionId,o=this._getIndex(e);if(o>=0){var s=void 0===n?3:4,u=this._entries[o];if((null!==(i=u.version)&&void 0!==i?i:-1)>=s&&a===u.sessionId)return;T.info("DRM-PSS: Updating session info.",a),this._entries.splice(o,1)}else T.info("DRM-PSS: Add new session",a);var l=e.values.getFormattedValues().map((function(e){var t=e.systemId,n=e.data;return{systemId:t,hash:e.hash,data:new ld(n)}}));void 0===n?this._entries.push({version:3,sessionId:a,values:l,initDataType:e.type}):this._entries.push({version:4,sessionId:a,keyIds:n.map((function(e){return new ld(e)})),values:l,initDataType:e.type}),this._save()}else T.warn("DRM-PSS: Invalid Persisten Session given.")},n.delete=function(e){for(var t=-1,n=0;n<this._entries.length;n++){if(this._entries[n].sessionId===e){t=n;break}}if(-1!==t){var r=this._entries[t];T.warn("DRM-PSS: Delete session from store",r.sessionId),this._entries.splice(t,1),this._save()}else T.warn("DRM-PSS: initData to delete not found.")},n.deleteOldSessions=function(e){T.info("DRM-PSS: Deleting last "+e+" sessions."),e<=0||(e<=this._entries.length?this._entries.splice(0,e):(T.warn("DRM-PSS: Asked to remove more information that it contains",e,this._entries.length),this._entries=[]),this._save())},n.dispose=function(){this._entries=[],this._save()},n._getIndex=function(e){var t=this,n=null;function r(){if(null===n){var t=e.values.constructRequestData();n={initData:t,initDataHash:ud(t)}}return n}for(var i,a=function(){var n=t._entries[o];if(n.initDataType===e.type)switch(n.version){case 4:if(void 0!==e.keyIds){if(e.keyIds.every((function(e){for(var t,r=Ka(e),i=fd(n.keyIds);!(t=i()).done;){var a=t.value;if("string"==typeof a){if(r===a)return!0}else if(st(a.initData,e))return!0}return!1})))return{v:o}}else if(dd(e.values.getFormattedValues(),n.values))return{v:o};break;case 3:if(dd(e.values.getFormattedValues(),n.values))return{v:o};break;case 2:var i=r(),a=i.initData,s=i.initDataHash;if(n.initDataHash===s)try{if(st("string"==typeof n.initData?ld.decode(n.initData):n.initData.initData,a))return{v:o}}catch(e){T.warn("DRM-PSS: Could not decode initialization data.",e instanceof Error?e:"")}break;case 1:var u=r(),l=u.initData,d=u.initDataHash;if(n.initDataHash===d){if(void 0===n.initData.length)return{v:o};if(st(n.initData,l))return{v:o}}break;default:var c=r().initDataHash;if(n.initData===c)return{v:o}}},o=0;o<this._entries.length;o++)if(i=a())return i.v;return-1},n._save=function(){try{this._storage.save(this._entries)}catch(t){var e=t instanceof Error?t:void 0;T.warn("DRM-PSS: Could not save MediaKeySession information",e)}},e}();var md=new WeakMap,gd={prepare:function(e){md.set(e,null)},set:function(e,t){var n=t instanceof Uint8Array?t:new Uint8Array(t instanceof ArrayBuffer?t:t.buffer),r=ud(n);md.set(e,{hash:r,serverCertificate:n})},hasOne:function(e){var t=md.get(e);return void 0!==t&&(null!==t||void 0)},has:function(e,t){var n=md.get(e);if(null==n)return!1;var r=n.hash,i=n.serverCertificate,a=t instanceof Uint8Array?t:new Uint8Array(t instanceof ArrayBuffer?t:t.buffer);if(ud(a)!==r||i.length!==a.length)return!1;for(var o=0;o<i.length;o++)if(i[o]!==a[o])return!1;return!0}};function yd(e,t,n){return _d.apply(this,arguments)}function _d(){return(_d=d(p().mark((function e(n,r,i){var a,o,s,u,l,d,c,f,v,h;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,jl(n,r,i);case 2:if(a=e.sent,null===i.cancellationError){e.next=5;break}throw i.cancellationError;case 5:if(o=a.value,s=o.options,u=o.mediaKeySystemAccess,l=Tr.getState(n),p=void 0,p=s.persistentLicenseConfig,d=t(p)?null:(T.debug("DRM: Set the given license storage"),new hd(p)),bi||Si||null===l||"reuse-media-key-system-access"!==a.type){e.next=12;break}if(c=l.mediaKeys,f=l.loadedSessionsStore,!1!==gd.hasOne(c)&&(t(s.serverCertificate)||!gd.has(c,s.serverCertificate))){e.next=12;break}return e.abrupt("return",{mediaKeys:c,mediaKeySystemAccess:u,stores:{loadedSessionsStore:f,persistentSessionsStore:d},options:s});case 12:return e.next=14,bd(u);case 14:return v=e.sent,T.info("DRM: MediaKeys created with success"),h=new ad(v),e.abrupt("return",{mediaKeys:v,mediaKeySystemAccess:u,stores:{loadedSessionsStore:h,persistentSessionsStore:d},options:s});case 18:case"end":return e.stop()}var p}),e)})))).apply(this,arguments)}function bd(e){return Sd.apply(this,arguments)}function Sd(){return(Sd=d(p().mark((function e(t){var n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.info("DRM: Calling createMediaKeys on the MediaKeySystemAccess"),e.prev=1,e.next=4,t.createMediaKeys();case 4:return n=e.sent,e.abrupt("return",n);case 8:throw e.prev=8,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.message:"Unknown error when creating MediaKeys.",new Ce("CREATE_MEDIA_KEYS_ERROR",r);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})))).apply(this,arguments)}function Ed(){return(Ed=d(p().mark((function e(t,n,r){var i,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,yd(t,n,r);case 2:if(i=e.sent,a=i.mediaKeys,!(null!==t.mediaKeys&&void 0!==t.mediaKeys&&a!==t.mediaKeys)){e.next=13;break}if(T.debug("DRM: Disabling old MediaKeys"),!bi){e.next=12;break}return e.next=10,Dl(t);case 10:e.next=13;break;case 12:Dl(t).catch(S);case 13:return e.abrupt("return",i);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Td(e,t,n){var r=Dt(e*Math.pow(2,t-1));return Math.min(r,n)}var kd=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(j(r),t.prototype),r.reason=n,r}return f(t,e),t}(Y(Error)),wd={EXPIRED:"expired",INTERNAL_ERROR:"internal-error",OUTPUT_RESTRICTED:"output-restricted"};function Ad(e,t,n){var r,i=t.onKeyInternalError,a=t.onKeyOutputRestricted,o=t.onKeyExpiration,s=[],u=[],l=[];return e.keyStatuses.forEach((function(e,t){var r="string"==typeof e?[e,t]:[t,e],d=r[0],c=function(e,t){return-1!==e.indexOf("playready")&&(pi||fi)?Ma(t):t}(n,new Uint8Array(r[1])),f={keyId:c.buffer,keyStatus:d};switch(T.hasLevel("DEBUG")&&T.debug("DRM: key status update ("+Ca(c)+"): "+d),d){case wd.EXPIRED:var v=new Ce("KEY_STATUS_CHANGE_ERROR","A decryption key expired ("+Ca(c)+")",{keyStatuses:[f].concat(l)});if("error"===o||void 0===o)throw v;switch(o){case"close-session":throw new kd(v);case"fallback":s.push(c);break;default:"continue"===o||void 0===o?u.push(c):X()}l.push(f);break;case wd.INTERNAL_ERROR:var p=new Ce("KEY_STATUS_CHANGE_ERROR",'A "'+d+'" status has been encountered ('+Ca(c)+")",{keyStatuses:[f].concat(l)});switch(i){case void 0:case"error":throw p;case"close-session":throw new kd(p);case"fallback":s.push(c);break;case"continue":u.push(c);break;default:if(void 0===i)throw p;X()}l.push(f);break;case wd.OUTPUT_RESTRICTED:var h=new Ce("KEY_STATUS_CHANGE_ERROR",'A "'+d+'" status has been encountered ('+Ca(c)+")",{keyStatuses:[f].concat(l)});switch(a){case void 0:case"error":throw h;case"fallback":s.push(c);break;case"continue":u.push(c);break;default:if(void 0===a)throw h;X()}l.push(f);break;default:u.push(c)}})),l.length>0&&(r=new Ce("KEY_STATUS_CHANGE_ERROR","One or several problematic key statuses have been encountered",{keyStatuses:l})),{warning:r,blacklistedKeyIds:s,whitelistedKeyIds:u}}function Id(e,n,r,i,a){T.info("DRM: Binding session events",e.sessionId);var o=n.getLicenseConfig,s=void 0===o?{}:o,u=new Z;return u.linkToSignal(a),t(e.closed)||e.closed.then((function(){return u.cancel()})).catch((function(e){a.isCancelled()||(u.cancel(),i.onError(e))})),jr(e,(function(e){u.cancel(),i.onError(new Ce("KEY_ERROR",e.type))}),u.signal),Hr(e,(function(){try{l()}catch(e){if(a.isCancelled()||u.isUsed()&&e instanceof J)return;u.cancel(),i.onError(e)}}),u.signal),Wr(e,(function(r){var a,o=r,l=new Uint8Array(o.message),c=et(o.messageType)?o.messageType:"license-request";T.info("DRM: Received message event, type "+c,e.sessionId),function(e,n,r){var i=n.baseDelay,a=n.maxDelay,o=n.totalRetry,s=n.shouldRetry,u=n.onRetry,l=0;return c();function c(){return f.apply(this,arguments)}function f(){return(f=d(p().mark((function n(){var d,f,v;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===r.cancellationError){n.next=2;break}throw r.cancellationError;case 2:return n.prev=2,n.next=5,e();case 5:return d=n.sent,n.abrupt("return",d);case 9:if(n.prev=9,n.t0=n.catch(2),null===r.cancellationError){n.next=13;break}throw r.cancellationError;case 13:if(!(!t(s)&&!s(n.t0)||l++>=o)){n.next=15;break}throw n.t0;case 15:return"function"==typeof u&&u(n.t0,l),f=Td(i,l,a),n.next=19,Wn(f);case 19:return v=c(),n.abrupt("return",v);case 21:case"end":return n.stop()}}),n,null,[[2,9]])})))).apply(this,arguments)}}((function(){return function(e,r){var i;return new Promise((function(a,o){try{T.debug("DRM: Calling `getLicense`",r);var u=n.getLicense(e,r),l=t(s.timeout)?1e4:s.timeout;l>=0&&(i=setTimeout((function(){o(new Md('"getLicense" timeout exceeded ('+l+" ms)"))}),l)),Promise.resolve(u).then(d,c)}catch(e){c(e)}function d(e){void 0!==i&&clearTimeout(i),a(e)}function c(e){void 0!==i&&clearTimeout(i),o(e)}}))}(l,c)}),{totalRetry:null!=(a=s.retry)?a:2,baseDelay:200,maxDelay:3e3,shouldRetry:function(e){return e instanceof Md||t(e)||!0!==e.noRetry},onRetry:function(e){return i.onWarning(Rd(e))}},u.signal).then((function(n){if(u.isUsed())return Promise.resolve();if(t(n))T.info("DRM: No license given, skipping session.update");else try{return function(e,t){return xd.apply(this,arguments)}(e,n)}catch(e){u.cancel(),i.onError(e)}})).catch((function(e){if(!u.isUsed()){u.cancel();var n=Rd(e);if(!t(e))if(!0===e.fallbackOnLastTry)return T.warn("DRM: Last `getLicense` attempt failed. Blacklisting the current session."),void i.onError(new Cd(n));i.onError(n)}}))}),u.signal),void l();function l(){if(T.info("DRM: keystatuseschange event received",e.sessionId),!u.isUsed()&&0!==e.keyStatuses.size){var t=Ad(e,n,r),a=t.warning,o=t.blacklistedKeyIds,s=t.whitelistedKeyIds;void 0!==a&&(i.onWarning(a),u.isUsed())||i.onKeyUpdate({whitelistedKeyIds:s,blacklistedKeyIds:o})}}}function Rd(e){if(e instanceof Md)return new Ce("KEY_LOAD_TIMEOUT","The license server took too much time to respond.");var n=new Ce("KEY_LOAD_ERROR","An error occured when calling `getLicense`.");return!t(e)&&et(e.message)&&(n.message=e.message),n}function xd(){return(xd=d(p().mark((function e(t,n){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.info("DRM: Updating MediaKeySession with message"),e.prev=1,e.next=4,t.update(n);case 4:e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.toString():"`session.update` failed",new Ce("KEY_UPDATE_ERROR",r);case 10:T.info("DRM: MediaKeySession update succeeded.");case 11:case"end":return e.stop()}}),e,null,[[1,6]])})))).apply(this,arguments)}var Cd=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(j(r),t.prototype),r.sessionError=n,r}return f(t,e),t}(Y(Error)),Md=function(e){function t(t){var n;return n=e.call(this)||this,Object.setPrototypeOf(j(n),Cd.prototype),n.message=t,n}return f(t,e),t}(Y(Error));function Pd(e,t){return Dd.apply(this,arguments)}function Dd(){return(Dd=d(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.setServerCertificate(n);case 3:return r=e.sent,e.abrupt("return",r);case 7:throw e.prev=7,e.t0=e.catch(0),T.warn("DRM: mediaKeys.setServerCertificate returned an error",e.t0 instanceof Error?e.t0:""),i=e.t0 instanceof Error?e.t0.toString():"`setServerCertificate` error",new Ce("LICENSE_SERVER_CERTIFICATE_ERROR",i);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function Od(e,t){return Nd.apply(this,arguments)}function Nd(){return(Nd=d(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!0!==gd.hasOne(t)){e.next=3;break}return T.info("DRM: The MediaKeys already has a server certificate, skipping..."),e.abrupt("return",{type:"already-has-one"});case 3:if("function"==typeof t.setServerCertificate){e.next=6;break}return T.warn("DRM: Could not set the server certificate. mediaKeys.setServerCertificate is not a function"),e.abrupt("return",{type:"method-not-implemented"});case 6:return T.info("DRM: Setting server certificate on the MediaKeys"),gd.prepare(t),e.prev=8,e.next=11,Pd(t,n);case 11:return r=e.sent,gd.set(t,n),e.abrupt("return",{type:"success",value:r});case 16:return e.prev=16,e.t0=e.catch(8),i=Oe(e.t0)?e.t0:new Ce("LICENSE_SERVER_CERTIFICATE_ERROR","Unknown error when setting the server certificate."),e.abrupt("return",{type:"error",value:i});case 20:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}function Ld(e,t){if(!(isNaN(t)||t<0||t>=e.getLength())){var n=e.getLength(),r=n-t;T.info("DRM: Too many stored persistent sessions, removing some.",n,r),e.deleteOldSessions(r)}}var Ud=function(){function e(e){this._innerValues=e,this._lazyFormattedValues=null}var t=e.prototype;return t.constructRequestData=function(){return Xr.apply(void 0,this._innerValues.map((function(e){return e.data})))},t.isCompatibleWith=function(t){var n=t instanceof e?t.getFormattedValues():t;return dd(this.getFormattedValues(),n)},t.getFormattedValues=function(){return null===this._lazyFormattedValues&&(this._lazyFormattedValues=this._innerValues.slice().sort((function(e,t){return e.systemId===t.systemId?0:void 0===e.systemId?1:void 0===t.systemId||e.systemId<t.systemId?-1:1})).map((function(e){var t=e.systemId,n=e.data;return{systemId:t,data:n,hash:ud(n)}}))),this._lazyFormattedValues},e}();function Fd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Bd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Bd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Bd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var zd=function(e){function n(n,r){var i;i=e.call(this)||this,T.debug("DRM: Starting ContentDecryptor logic.");var a=new Z;return i._currentSessions=[],i._canceller=a,i._initDataQueue=[],i._stateData={state:Pi.Initializing,isMediaKeysAttached:0,isInitDataQueueLocked:!0,data:null},i.error=null,xl.onEncrypted(n,(function(e){T.debug("DRM: Encrypted event received from media element.");var t=Pl(e);null!==t&&i.onInitializationData(t)}),a.signal),function(e,t,n){return Ed.apply(this,arguments)}(n,r,a.signal).then((function(e){var r,a,o=e.options,s=e.mediaKeySystemAccess;(t(o.persistentLicenseConfig)||!0===o.persistentLicenseConfig.disableRetroCompatibility)&&(r=ar(a=s.keySystem,"com.microsoft.playready")||"com.chromecast.playready"===a||"com.youtube.playready"===a?"9a04f07998404286ab92e65be0885f95":"com.widevine.alpha"===a?"edef8ba979d64acea3c827dcd51d21ed":ar(a,"com.apple.fps")?"94ce86fb07ff4f43adb893d2fa968ca2":ar(a,"com.nagra.")?"adb41c242dbf4a6d958b4457c0d27b95":void 0),i.systemId=r,i._stateData.state===Pi.Initializing&&(i._stateData={state:Pi.WaitingForAttachment,isInitDataQueueLocked:!0,isMediaKeysAttached:0,data:{mediaKeysInfo:e,mediaElement:n}},i.trigger("stateChange",i._stateData.state))})).catch((function(e){i._onFatalError(e)})),i}f(n,e),n.hasEmeApis=function(){return!t(xl.requestMediaKeySystemAccess)};var r=n.prototype;return r.getState=function(){return this._stateData.state},r.attach=function(){var e=this;if(this._stateData.state!==Pi.WaitingForAttachment)throw new Error("`attach` should only be called when in the WaitingForAttachment state");if(0===this._stateData.isMediaKeysAttached){var n=this._stateData.data,r=n.mediaElement,i=n.mediaKeysInfo,a=i.options,o=i.mediaKeys,s=i.mediaKeySystemAccess,u=i.stores;if(!(!0===a.disableMediaKeysAttachmentLock)||(this._stateData={state:Pi.ReadyForContent,isInitDataQueueLocked:!0,isMediaKeysAttached:1,data:{mediaKeysInfo:i,mediaElement:r}},this.trigger("stateChange",this._stateData.state),!this._isStopped())){this._stateData.isMediaKeysAttached=1;var l={emeImplementation:xl,loadedSessionsStore:u.loadedSessionsStore,mediaKeySystemAccess:s,mediaKeys:o,keySystemOptions:a};T.debug("DRM: Attaching current MediaKeys"),function(e,t,n){return Ol.apply(this,arguments)}(r,l,this._canceller.signal).then(d(p().mark((function n(){var r,s,u;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e._stateData.isMediaKeysAttached=2,t(r=a.serverCertificate)){n.next=7;break}return n.next=5,Od(o,r);case 5:"error"===(s=n.sent).type&&e.trigger("warning",s.value);case 7:if(!e._isStopped()){n.next=9;break}return n.abrupt("return");case 9:u=e._stateData.state,e._stateData={state:Pi.ReadyForContent,isMediaKeysAttached:2,isInitDataQueueLocked:!1,data:{mediaKeysData:i}},u!==Pi.ReadyForContent&&e.trigger("stateChange",Pi.ReadyForContent),e._isStopped()||e._processCurrentInitDataQueue();case 13:case"end":return n.stop()}}),n)})))).catch((function(t){e._onFatalError(t)}))}}else T.warn("DRM: ContentDecryptor's `attach` method called more than once.")},r.dispose=function(){this.removeEventListener(),this._stateData={state:Pi.Disposed,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("stateChange",this._stateData.state)},r.onInitializationData=function(e){var t=this;if(!1===this._stateData.isInitDataQueueLocked){var n=this._stateData.data.mediaKeysData,r=Object.assign(Object.assign({},e),{values:new Ud(e.values)});this._processInitializationData(r,n).catch((function(e){t._onFatalError(e)}))}else{if(this._isStopped())throw new Error("ContentDecryptor either disposed or stopped.");this._initDataQueue.push(e)}},r._processInitializationData=function(){var e=d(p().mark((function e(n,r){var i,a,o,s,u,l,d,c,f,v,h,m,g,y,_,S,E,k,w,A,I,R,x,C,M,P,D,O,N,L,U,F,B,z=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.mediaKeySystemAccess,a=r.stores,o=r.options,!this._tryToUseAlreadyCreatedSession(n,r)&&!this._isStopped()){e.next=3;break}return e.abrupt("return");case 3:if("content"!==o.singleLicensePer){e.next=15;break}if(void 0===(s=ae(this._currentSessions,(function(e){return"created-session"===e.source})))){e.next=13;break}if(void 0!==(u=n.keyIds)){e.next=10;break}return void 0===n.content?T.warn("DRM: Unable to fallback from a non-decipherable quality."):this.trigger("blackListProtectionData",n),e.abrupt("return");case 10:return s.record.associateKeyIds(u),void 0!==n.content&&(T.hasLevel("DEBUG")&&(l=u.reduce((function(e,t){return e+", "+Ca(t)}),""),T.debug("DRM: Blacklisting new key ids",l)),this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:u,delistedKeyIds:[]})),e.abrupt("return");case 13:e.next=42;break;case 15:if("periods"!==o.singleLicensePer||void 0===n.content){e.next=42;break}d=n.content.period,c=this._currentSessions.filter((function(e){return"created-session"===e.source})),Gd(f=new Set,d),v=Fd(c);case 21:if((h=v()).done){e.next=42;break}m=h.value,g=Array.from(f),y=0,_=g;case 25:if(!(y<_.length)){e.next=40;break}if(S=_[y],!m.record.isAssociatedWithKeyId(S)){e.next=37;break}m.record.associateKeyIds(f.values()),E=p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=w.value,m.keyStatuses.whitelisted.some((function(e){return st(e,t)}))||m.keyStatuses.blacklisted.some((function(e){return st(e,t)}))||m.keyStatuses.blacklisted.push(t);case 2:case"end":return e.stop()}}),e)})),k=Fd(g);case 31:if((w=k()).done){e.next=35;break}return e.delegateYield(E(),"t0",33);case 33:e.next=31;break;case 35:return this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:m.keyStatuses.whitelisted,blacklistedKeyIds:m.keyStatuses.blacklisted,delistedKeyIds:[]}),e.abrupt("return");case 37:y++,e.next=25;break;case 40:e.next=21;break;case 42:return this._lockInitDataQueue(),t(o.persistentLicenseConfig)?A="temporary":Vd(i)?A="persistent-license":(T.warn('DRM: Cannot create "persistent-license" session: not supported'),A="temporary"),I=b.getCurrent(),R=I.EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS,x=I.EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION,C="number"==typeof o.maxSessionCacheSize?o.maxSessionCacheSize:R,e.next=48,Vl(n,a,A,C,this._canceller.signal);case 48:if(M=e.sent,!this._isStopped()){e.next=51;break}return e.abrupt("return");case 51:if(P={record:M.value.keySessionRecord,source:M.type,keyStatuses:{whitelisted:[],blacklisted:[]},blacklistedSessionError:null},this._currentSessions.push(P),D=M.value,O=D.mediaKeySession,N=D.sessionType,L=!1,Id(O,o,i.keySystem,{onKeyUpdate:function(e){var t=Kd(n,P.record,o.singleLicensePer,"created-session"===P.source,e.whitelistedKeyIds,e.blacklistedKeyIds);if(P.record.associateKeyIds(t.whitelisted),P.record.associateKeyIds(t.blacklisted),P.keyStatuses={whitelisted:t.whitelisted,blacklisted:t.blacklisted},0!==P.record.getAssociatedKeyIds().length&&"persistent-license"===N&&null!==a.persistentSessionsStore&&!L){var r=a.persistentSessionsStore;Ld(r,x-1),r.add(n,P.record.getAssociatedKeyIds(),O),L=!0}void 0!==n.content&&z.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:t.whitelisted,blacklistedKeyIds:t.blacklisted,delistedKeyIds:[]}),z._unlockInitDataQueue()},onWarning:function(e){z.trigger("warning",e)},onError:function(e){var t;if(e instanceof kd){T.warn("DRM: A session's closing condition has been triggered"),z._lockInitDataQueue();var r=z._currentSessions.indexOf(P);return r>=0&&z._currentSessions.splice(r),void 0!==n.content&&z.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:[],delistedKeyIds:P.record.getAssociatedKeyIds()}),null===(t=a.persistentSessionsStore)||void 0===t||t.delete(O.sessionId),a.loadedSessionsStore.closeSession(O).catch((function(e){var t=e instanceof Error?e:"unknown error";T.warn("DRM: failed to close expired session",t)})).then((function(){return z._unlockInitDataQueue()})).catch((function(e){return z._onFatalError(e)})),void(z._isStopped()||z.trigger("warning",e.reason))}e instanceof Cd?(P.blacklistedSessionError=e,void 0!==n.content&&(T.info("DRM: blacklisting Representations based on protection data."),z.trigger("blackListProtectionData",n)),z._unlockInitDataQueue()):z._onFatalError(e)}},this._canceller.signal),void 0!==o.singleLicensePer&&"init-data"!==o.singleLicensePer||this._unlockInitDataQueue(),"created-session"!==M.type){e.next=72;break}return U=n.values.constructRequestData(),e.prev=59,e.next=62,a.loadedSessionsStore.generateLicenseRequest(O,n.type,U);case 62:e.next=72;break;case 64:if(e.prev=64,e.t1=e.catch(59),null!==(F=a.loadedSessionsStore.getEntryForSession(O))&&"none"===F.closingStatus.type){e.next=71;break}return(B=this._currentSessions.indexOf(P))>=0&&this._currentSessions.splice(B,1),e.abrupt("return",Promise.resolve());case 71:throw new Ce("KEY_GENERATE_REQUEST_ERROR",e.t1 instanceof Error?e.t1.toString():"Unknown error");case 72:return e.abrupt("return",Promise.resolve());case 73:case"end":return e.stop()}}),e,this,[[59,64]])})));return function(t,n){return e.apply(this,arguments)}}(),r._tryToUseAlreadyCreatedSession=function(e,n){var r=n.stores,i=n.options,a=ae(this._currentSessions,(function(t){return t.record.isCompatibleWith(e)}));if(void 0===a)return!1;if(!t(a.blacklistedSessionError))return void 0===e.type||void 0===e.content?(T.error("DRM: This initialization data has already been blacklisted but the current content is not known."),!0):(T.info("DRM: This initialization data has already been blacklisted. Blacklisting the related content."),this.trigger("blackListProtectionData",e),!0);if(void 0!==e.keyIds){var o;if(void 0===i.singleLicensePer||"init-data"===i.singleLicensePer){var s=a.keyStatuses.blacklisted;o=function(e,t){for(var n,r,i=function(){var e=r.value;if(t.some((function(t){return st(t,e)})))return{v:!0}},a=Xl(e);!(r=a()).done;)if(n=i())return n.v;return!1}(e.keyIds,s)}else{var u=a.keyStatuses.whitelisted;o=!Jl(e.keyIds,u)}if(o)return void 0===e.content?(T.error("DRM: Cannot forbid key id, the content is unknown."),!0):(T.info("DRM: Current initialization data is linked to blacklisted keys. Marking Representations as not decipherable"),this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:e.keyIds,delistedKeyIds:[]}),!0)}if(null!==r.loadedSessionsStore.reuse(e))return T.debug("DRM: Init data already processed. Skipping it."),!0;var l=this._currentSessions.indexOf(a);return-1===l?T.error("DRM: Unable to remove processed init data: not found."):(T.debug("DRM: A session from a processed init data is not available anymore. Re-processing it."),this._currentSessions.splice(l,1)),!1},r._onFatalError=function(e){if(!this._canceller.isUsed()){var t=e instanceof Error?e:new De("NONE","Unknown decryption error");this.error=t,this._initDataQueue.length=0,this._stateData={state:Pi.Error,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("error",t),this._stateData.state===Pi.Error&&this.trigger("stateChange",this._stateData.state)}},r._isStopped=function(){return this._stateData.state===Pi.Disposed||this._stateData.state===Pi.Error},r._processCurrentInitDataQueue=function(){for(;!1===this._stateData.isInitDataQueueLocked;){var e=this._initDataQueue.shift();if(void 0===e)return;this.onInitializationData(e)}},r._lockInitDataQueue=function(){!1===this._stateData.isInitDataQueueLocked&&(this._stateData.isInitDataQueueLocked=!0)},r._unlockInitDataQueue=function(){2===this._stateData.isMediaKeysAttached?(this._stateData.isInitDataQueueLocked=!1,this._processCurrentInitDataQueue()):T.error("DRM: Trying to unlock in the wrong state")},n}(i);function Vd(e){var t=e.getConfiguration().sessionTypes;return void 0!==t&&Ue(t,"persistent-license")}function Kd(e,t,n,r,i,a){for(var o,s,u=[].concat(i,a),l=function(){var e=s.value;u.some((function(t){return st(t,e)}))||(T.hasLevel("DEBUG")&&T.debug("DRM: KeySessionRecord's key missing in the license, blacklisting it",Ca(e)),u.push(e))},d=Fd(t.getAssociatedKeyIds());!(s=d()).done;)l();if(void 0!==n&&"init-data"!==n){var c=e.keyIds,f=e.content;if(void 0!==c){var v=c.filter((function(e){return!u.some((function(t){return st(t,e)}))}));v.length>0&&(T.hasLevel("DEBUG")&&T.debug("DRM: init data keys missing in the license, blacklisting them",v.map((function(e){return Ca(e)})).join(", ")),u.push.apply(u,v))}if(r&&void 0!==f)if("content"===n){for(var p,h=new Set,m=Fd(f.manifest.periods);!(p=m()).done;){Gd(h,p.value)}Wd(h,u)}else if("periods"===n)for(var g,y=Fd(f.manifest.periods);!(g=y()).done;){var _=g.value,b=new Set;if(Gd(b,_),(null===(o=e.content)||void 0===o?void 0:o.period.id)===_.id)Wd(b,u);else for(var S=Array.from(b),E=function(){var e=w[k];if(u.some((function(t){return st(t,e)})))return Wd(b,u),1},k=0,w=S;k<w.length&&!E();k++);}}return{whitelisted:i,blacklisted:u.slice(i.length)}}function Wd(e,t){for(var n=Array.from(e.values()),r=function(){var e=a[i];t.some((function(t){return st(t,e)}))||t.push(e)},i=0,a=n;i<a.length;i++)r()}function Gd(e,n){for(var r,i=Fd(me(n.adaptations).reduce((function(e,n){return t(n)?e:e.concat(n)}),[]));!(r=i()).done;)for(var a,o=Fd(r.value.representations);!(a=o()).done;){var s=a.value;if(void 0!==s.contentProtections&&void 0!==s.contentProtections.keyIds)for(var u,l=Fd(s.contentProtections.keyIds);!(u=l()).done;){var d=u.value;e.add(d.keyId)}}}var jd=zd;function Hd(e){e.decrypt=jd}function qd(e,t){if(hi&&function(e,t){var n=e.activeCues;if(null===n)return!1;for(var r=0;r<n.length;r++)if(n[r]===t)return!0;return!1}(e,t)){var n=e.mode;e.mode="hidden";try{e.removeCue(t)}catch(e){T.warn("Compat: Could not remove cue from text track.")}e.mode=n}else try{e.removeCue(t)}catch(e){T.warn("Compat: Could not remove cue from text track.")}}var Yd=function(){function e(){this._ranges=[],this.length=0}var t=e.prototype;return t.insert=function(e,t){L(this._ranges,{start:e,end:t}),this.length=this._ranges.length},t.remove=function(e,t){var n=[];e>0&&n.push({start:0,end:e}),t<1/0&&n.push({start:t,end:1/0}),this._ranges=function(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=U(i,t);if(a.length>0)for(var o=0;o<a.length;o++){var s=a[o];n.push({start:Math.max(i.start,s.start),end:Math.min(i.end,s.end)})}}return n}(this._ranges,n),this.length=this._ranges.length},t.start=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].start},t.end=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].end},e}();var Qd=function(){function e(e){T.debug("NTD: Creating NativeTextDisplayer");var t=function(e){var t,n,r,i="subtitles";if(pi){var a=e.textTracks.length;(n=a>0?e.textTracks[a-1]:e.addTextTrack(i)).mode=null!==(t=n.SHOWING)&&void 0!==t?t:"showing"}else r=document.createElement("track"),e.appendChild(r),n=r.track,r.kind=i,n.mode="showing";return{track:n,trackElement:r}}(e),n=t.track,r=t.trackElement;this._buffered=new Yd,this._videoElement=e,this._track=n,this._trackElement=r}var t=e.prototype;return t.pushTextData=function(e){var t,n;if(T.debug("NTD: Appending new native text tracks"),null===e.chunk)return M(this._buffered);var r,i,a=e.timestampOffset,o=e.appendWindow,s=e.chunk,u=s.start,l=s.end,d=s.data,c=s.type,f=s.language,v=null!==(t=o[0])&&void 0!==t?t:0,p=null!==(n=o[1])&&void 0!==n?n:1/0,h=function(e,t,n,r){T.debug("NTSB: Finding parser for native text tracks:",e);var i=ot.nativeTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");T.debug("NTSB: Parser found, parsing...");var a=i(t,n,r);return T.debug("NTSB: Parsed successfully!",a.length),a}(c,d,a,f);if(0!==v&&p!==1/0){for(var m=0;m<h.length&&h[m].endTime<=v;)m++;for(h.splice(0,m),m=0;m<h.length&&h[m].startTime<v;)h[m].startTime=v,m++;for(m=h.length-1;m>=0&&h[m].startTime>=p;)m--;for(h.splice(m,h.length),m=h.length-1;m>=0&&h[m].endTime>p;)h[m].endTime=p,m--}if(void 0!==u)r=Math.max(v,u);else{if(h.length<=0)return T.warn("NTD: Current text tracks have no cues nor start time. Aborting"),M(this._buffered);T.warn("NTD: No start time given. Guessing from cues."),r=h[0].startTime}if(void 0!==l)i=Math.min(p,l);else{if(h.length<=0)return T.warn("NTD: Current text tracks have no cues nor end time. Aborting"),M(this._buffered);T.warn("NTD: No end time given. Guessing from cues."),i=h[h.length-1].endTime}if(i<=r)return T.warn("NTD: Invalid text track appended: ","the start time is inferior or equal to the end time."),M(this._buffered);if(h.length>0){var g=h[0],y=this._track.cues;null!==y&&y.length>0&&g.startTime<y[y.length-1].startTime&&this._removeData(g.startTime,1/0);for(var _=0;_<h.length;_++)this._track.addCue(h[_])}return this._buffered.insert(r,i),M(this._buffered)},t.removeBuffer=function(e,t){return this._removeData(e,t),M(this._buffered)},t.getBufferedRanges=function(){return M(this._buffered)},t.reset=function(){T.debug("NTD: Aborting NativeTextDisplayer"),this._removeData(0,1/0);var e=this._trackElement,t=this._videoElement;if(void 0!==e&&t.hasChildNodes())try{t.removeChild(e)}catch(e){T.warn("NTD: Can't remove track element from the video")}var n=this._track.mode;this._track.mode="disabled",this._track.mode=n,void 0!==this._trackElement&&(this._trackElement.innerHTML="")},t.stop=function(){T.debug("NTD: Aborting NativeTextDisplayer"),this._removeData(0,1/0);var e=this._trackElement,t=this._videoElement;if(void 0!==e&&t.hasChildNodes())try{t.removeChild(e)}catch(e){T.warn("NTD: Can't remove track element from the video")}this._track.mode="disabled",void 0!==this._trackElement&&(this._trackElement.innerHTML="")},t._removeData=function(e,t){T.debug("NTD: Removing native text track data",e,t);var n=this._track,r=n.cues;if(null!==r)for(var i=r.length-1;i>=0;i--){var a=r[i],o=a.startTime,s=a.endTime;o>=e&&o<=t&&s<=t&&qd(n,a)}this._buffered.remove(e,t)},e}(),$d=Qd,Xd=/(\d+) (\d+)/;function Zd(e,t,n,r){for(var i,a={},o=e.slice(),s=function(){var e=t[u];if(void 0!==e){var i,s;if(e.nodeType===Node.ELEMENT_NODE)for(var l=e,d=0;d<=l.attributes.length-1;d++){var c=l.attributes[d],f=c.name;if("style"===f)i=c.value;else if("region"===f)s=c.value;else{var v=f.substring(4);if(Ue(o,v)&&(a[v]=c.value,o.splice(d,1),0===o.length))return{v:a}}}if(et(i)){var p=ae(n,(function(e){return e.id===i}));if(void 0!==p)for(var h=0;h<=o.length-1;h++){var m=o[h];if(!et(a[m])&&et(p.style[m])){if(a[m]=p.style[m],o.splice(h,1),0===o.length)return{v:a};h--}}}if(et(s)){var g=ae(r,(function(e){return e.id===s}));if(void 0!==g)for(var y=0;y<=o.length-1;y++){var _=o[y];if(!et(a[_])&&et(g.style[_])){if(a[_]=g.style[_],o.splice(y,1),0===o.length)return{v:a};y--}}}}},u=0;u<=t.length-1;u++)if(i=s())return i.v;return a}function Jd(e){if(e.nodeType!==Node.ELEMENT_NODE)return{};for(var t=e,n={},r=0;r<=t.attributes.length-1;r++){var i=t.attributes[r];if(ar(i.name,"tts"))n[i.name.substring(4)]=i.value}return n}function ec(e,t){if(!(e.parentNode instanceof Element))return[];return function e(n){var r=[];n.tagName.toLowerCase()===t.toLowerCase()&&r.push(n);var i=n.parentNode;return i instanceof Element&&r.push.apply(r,e(i)),r}(e.parentNode)}function tc(e){var t=ec(e,"div");if(0===t.length){var n=ec(e,"tt:div");n.length>0&&(t=n)}return t}function nc(e){return"br"===e.nodeName||"tt:br"===e.nodeName}function rc(e){return"span"===e.nodeName||"tt:span"===e.nodeName}var ic=["align","backgroundColor","color","direction","display","displayAlign","extent","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","opacity","origin","overflow","padding","textAlign","textDecoration","textOutline","unicodeBidi","visibility","wrapOption","writingMode"];function ac(e,t){var n=[],r=(new DOMParser).parseFromString(e,"text/xml");if(null!=r){var i=r.getElementsByTagName("tt")[0];if(void 0===i)if(void 0===(i=r.getElementsByTagNameNS("*","tt")[0]))throw new Error("invalid XML");for(var a=function(e){var t=e.getElementsByTagName("body");if(t.length>0)return t[0];var n=e.getElementsByTagName("tt:body");return n.length>0?n[0]:null}(i),o=function(e){var t=e.getElementsByTagName("style");if(t.length>0)return t;var n=e.getElementsByTagName("tt:style");return n.length>0?n:t}(i),s=function(e){var t=e.getElementsByTagName("region");if(t.length>0)return t;var n=e.getElementsByTagName("tt:region");return n.length>0?n:t}(i),u=function(e){var t=e.getElementsByTagName("p");if(t.length>0)return t;var n=e.getElementsByTagName("tt:p");return n.length>0?n:t}(i),l=function(e){var t=e.getAttribute("ttp:frameRate"),n=e.getAttribute("ttp:subFramRate"),r=e.getAttribute("ttp:tickRate"),i=e.getAttribute("ttp:frameRateMultiplier"),a=e.getAttribute("xml:space"),o=e.getAttribute("ttp:cellResolution"),s={columns:32,rows:15};if(null!==o){var u=Xd.exec(o);if(null===u||u.length<3)T.warn("TTML Parser: Invalid cellResolution");else{var l=parseInt(u[1],10),d=parseInt(u[2],10);isNaN(l)||isNaN(d)?T.warn("TTML Parser: Invalid cellResolution"):s={columns:l,rows:d}}}if(et(a)&&"default"!==a&&"preserve"!==a)throw new Error("Invalid spacing style");var c=Number(t);(isNaN(c)||c<=0)&&(c=30);var f=Number(n);(isNaN(f)||f<=0)&&(f=1);var v=Number(r);(isNaN(v)||v<=0)&&(v=void 0);var p=c,h=null!=f?f:1,m=null!=a?a:"default",g=null!=v?v:c*f;if(null!==i){var y=/^(\d+) (\d+)$/g.exec(i);null!==y&&(p=c*(Number(y[1])/Number(y[2])))}return{cellResolution:s,tickRate:g,frameRate:p,subFrameRate:h,spaceStyle:m}}(i),d=[],c=0;c<=o.length-1;c++){var f=o[c];if(f instanceof Element){var v=f.getAttribute("xml:id");if(null!==v){var p=f.getAttribute("style"),h=null===p?[]:p.split(" ");d.push({id:v,style:Jd(f),extendsStyles:h})}}}!function(e){var t=[];function n(r,i){t.push(i);for(var a=function(){var i=r.extendsStyles[o],a=B(e,(function(e){return e.id===i}));if(a<0)T.warn("TTML Parser: unknown style inheritance: "+i);else{var s=e[a];Ue(t,a)?T.warn("TTML Parser: infinite style inheritance loop avoided"):n(s,a),r.style=m({},s.style,r.style)}},o=0;o<r.extendsStyles.length;o++)a();r.extendsStyles.length=0}for(var r=0;r<e.length;r++)n(e[r],r),t.length=0}(d);for(var g=[],y=function(){var e=s[_];if(e instanceof Element){var t=e.getAttribute("xml:id");if(null!==t){var n=Jd(e),r=e.getAttribute("style");if(et(r)){var i=ae(d,(function(e){return e.id===r}));void 0!==i&&(n=m({},i.style,n))}g.push({id:t,style:n,extendsStyles:[]})}}},_=0;_<=s.length-1;_++)y();for(var b=Zd(ic,null!==a?[a]:[],d,g),S="default"===(null!==a?a.getAttribute("xml:space"):void 0)||"default"===l.spaceStyle,E=0;E<u.length;E++){var k=u[E];if(k instanceof Element){var w=tc(k),A=m({},b,Zd(ic,[k].concat(w),d,g)),I=k.getAttribute("xml:space"),R=et(I)?"default"===I:S,x={paragraph:k,timeOffset:t,idStyles:d,regionStyles:g,body:a,paragraphStyle:A,ttParams:l,shouldTrimWhiteSpace:R};null!==x&&n.push(x)}}}return n}function oc(e){return"function"==typeof s.VTTCue&&e instanceof s.VTTCue}function sc(e,n,r){if(e>=n)return T.warn("Compat: Invalid cue times: "+e+" - "+n),null;if(t(s.VTTCue)){if(t(s.TextTrackCue))throw new Error("VTT cues not supported in your target");return new TextTrackCue(e,n,r)}return new VTTCue(e,n,r)}var uc=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,lc=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,dc=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d{2,})$/,cc=/^(\d*\.?\d*)f$/,fc=/^(\d*\.?\d*)t$/,vc=/^(?:(\d*\.?\d*)h)?(?:(\d*\.?\d*)m)?(?:(\d*\.?\d*)s)?(?:(\d*\.?\d*)ms)?$/,pc=/^(\d{1,2}|100)% (\d{1,2}|100)%$/,hc=/^((?:\+|\-)?\d*(?:\.\d+)?)(px|em|c|%|rh|rw)$/,mc=/^#([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})$/,gc=/^#([0-9A-f])([0-9A-f])([0-9A-f])([0-9A-f])$/,yc=/^rgb\( *(\d+) *, *(\d+) *, *(\d+) *\)/,_c=/^rgba\( *(\d+) *, *(\d+) *, *(\d+) *, *(\d+) *\)/;function bc(e,t){var n=e.exec(t);if(null===n||""===n[0])return null;var r=Number(n[1]);isNaN(r)&&(r=0);var i=Number(n[2]);isNaN(i)&&(i=0);var a=Number(n[3]);isNaN(a)&&(a=0);var o=Number(n[4]);return isNaN(o)&&(o=0),o/1e3+a+60*i+3600*r}var Sc=function(e,t){return uc.test(e)?function(e,t){var n=uc.exec(t),r=Number(n[1]),i=Number(n[2]),a=Number(n[3]),o=Number(n[4]),s=Number(n[5]);isNaN(s)&&(s=0);return o+=s/e.subFrameRate,a+=o/e.frameRate,a+60*i+3600*r}(t,e):lc.test(e)?bc(lc,e):dc.test(e)?bc(dc,e):cc.test(e)?function(e,t){var n=cc.exec(t);return Number(n[1])/e.frameRate}(t,e):fc.test(e)?function(e,t){var n=fc.exec(t);return Number(n[1])/e.tickRate}(t,e):vc.test(e)?bc(vc,e):void 0};function Ec(e,n){var r=e.getAttribute("begin"),i=e.getAttribute("dur"),a=e.getAttribute("end"),o=et(r)?Sc(r,n):null,s=et(i)?Sc(i,n):null,u=et(a)?Sc(a,n):null;if(t(o)||t(u)&&t(s))throw new Error("Invalid text cue");return{start:o,end:t(u)?o+s:u}}var Tc={left:"start",center:"center",right:"end",start:"start",end:"end"},kc={left:"line-left",center:"center",right:"line-right"};function wc(e){var n=e.paragraph,r=e.timeOffset,i=e.paragraphStyle,a=e.ttParams,o=e.shouldTrimWhiteSpace;if(!n.hasAttribute("begin")&&!n.hasAttribute("end")&&/^\s*$/.test(null===n.textContent?"":n.textContent))return null;var s=Ec(n,a),u=s.start,l=s.end,d=function(e,t){function n(e,t){for(var r=e.childNodes,i="",a=0;a<r.length;a++){var o=r[a];if("#text"===o.nodeName){var s=o.textContent;if(null===s&&(s=""),t){var u=s.trim();s=u=u.replace(/\s+/g," ")}i+=s.replace(/&|\u0026/g,"&").replace(/<|\u003C/g,"<").replace(/>|\u2265/g,">").replace(/\u200E/g,"‎").replace(/\u200F/g,"‏").replace(/\u00A0/g," ")}else if(nc(o))i+="\n";else if(rc(o)&&o.nodeType===Node.ELEMENT_NODE&&o.childNodes.length>0){var l=o.getAttribute("xml:space");i+=n(o,et(l)?"default"===l:t)}}return i}return n(e,t)}(n,o),c=sc(u+r,l+r,d);return null===c?null:(oc(c)&&function(e,n){var r=n.extent;if(et(r)){var i=pc.exec(r);t(i)||(e.size=Number(i[1]))}switch(n.writingMode){case"tb":case"tblr":e.vertical="lr";break;case"tbrl":e.vertical="rl"}var a=n.origin;if(et(a)){t(pc.exec(a))}var o=n.align;if(et(o)){e.align=o,"center"===o&&("center"!==e.align&&(e.align="middle"),e.position="auto");var s=kc[o];e.positionAlign=void 0===s?"":s;var u=Tc[o];e.lineAlign=void 0===u?"":u}}(c,i),c)}var Ac=function(e,t){for(var n=ac(e,t),r=[],i=0;i<n.length;i++){var a=wc(n[i]);null!==a&&r.push(a)}return r};function Ic(e){e.nativeTextTracksParsers.ttml=Ac,e.nativeTextDisplayer=$d}var Rc=/&#([0-9]+);/g,xc=/<br>/gi,Cc=/<style[^>]*>([\s\S]*?)<\/style[^>]*>/i,Mc=/\s*<p (?:class=([^>]+))?>(.*)/i,Pc=/<sync[^>]+?start="?([0-9]*)"?[^0-9]/i;function Dc(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}var Oc=function(e,n,r){var i,a,o=/<sync[ >]/gi,s=/<sync[ >]|<\/body>/gi,u=[],l=Cc.exec(e),d=null!==l?l[1]:"";s.exec(e);var c,f=function(e){for(var n=/\.(\S+)\s*{([^}]*)}/gi,r={},i=n.exec(e);Array.isArray(i);){var a=i[1],o=Dc(i[2],"lang");t(a)||t(o)||(r[o]=a),i=n.exec(e)}return r}(d);if(et(r)&&void 0===(c=f[r]))throw new Error("sami: could not find lang "+r+" in CSS");for(;i=o.exec(e),a=s.exec(e),null!==i||null!==a;){if(null===i||null===a||i.index>=a.index)throw new Error("parse error");var v=e.slice(i.index,a.index),p=Pc.exec(v);if(null===p)throw new Error("parse error (sync time attribute)");var h=+p[1];if(isNaN(h))throw new Error("parse error (sync time attribute NaN)");m(v.split("\n"),h/1e3)}return function(e){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=i.start,o=i.end,s=i.text;if(et(s)&&!t(o)){var u=sc(a,o,s);null!==u&&n.push(u)}}return n}(u);function m(e,t){for(var r,i,a=e.length;--a>=0;)if(null!==(r=Mc.exec(e[a]))){var o=r,s=o[1],l=o[2];c===s&&(" "===l?u[u.length-1].end=t:u.push({text:(i=l,i.replace(xc,"\n").replace(Rc,(function(e,t){return String.fromCharCode(Number(t))}))),start:t+n}))}}};function Nc(e){e.nativeTextTracksParsers.sami=Oc,e.nativeTextDisplayer=$d}function Lc(e){for(var t=0;t<e.length;){if(""===e[t])return t+1;t++}return t}function Uc(e,t){return"string"==typeof e[t]&&/^STYLE( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}function Fc(e,t){var n=e[t];if(void 0===n||""===n||Uc(e,t)||function(e,t){return"string"==typeof e[t]&&/^REGION( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}(e,t)||function(e,t){return"string"==typeof e[t]&&/^NOTE( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}(e,t))return!1;if(n.indexOf("--\x3e")>=0)return!0;var r=e[t+1];return void 0!==r&&r.indexOf("--\x3e")>=0}function Bc(e,t){for(var n=t+1;et(e[n]);)n++;return n}function zc(e,t){for(var n=[],r=t;r<e.length;r++)if(Fc(e,r)){var i=Bc(e,r);n.push(e.slice(r,i)),r=i}else if(et(e[r]))for(;et(e[r]);)r++;return n}function Vc(e){var t=e.split(":").reverse();if(et(t[2])||et(t[1])){var n=et(t[2])?parseInt(t[2],10):0,r=parseInt(t[1],10),i=parseFloat(t[0].replace(",","."));if(isNaN(n)||isNaN(r)||isNaN(i))return;return 60*n*60+60*r+i}}function Kc(e,t){var n,r,i,a=/-->/;if(a.test(e[0]))n=e[0],r=e.slice(1,e.length);else{if(!a.test(e[1]))return null;i=e[0],n=e[1],r=e.slice(2,e.length)}var o=function(e){var t=/^([\d:.]+)[ |\t]+-->[ |\t]+([\d:.]+)[ |\t]*(.*)$/.exec(e);if(null===t)return null;var n=Vc(t[1]),r=Vc(t[2]);return void 0===n||void 0===r?null:{start:n,end:r,settings:t[3].split(/ |\t/).reduce((function(e,t){var n=t.split(":");return 2===n.length&&(e[n[0]]=n[1]),e}),{})}}(n);return null===o?null:{start:o.start+t,end:o.end+t,settings:o.settings,payload:r,header:i}}function Wc(e,t){if(!et(e.vertical)||"rl"!==e.vertical&&"lr"!==e.vertical||(t.vertical=e.vertical),et(e.line)){var n=/^(\d+(\.\d+)?)%(,([a-z]+))?/.exec(e.line);if(Array.isArray(n))t.line=Number(n[1]),t.snapToLines=!1,Ue(["start","center","end"],n[4])&&(t.lineAlign=n[4]);else{var r=/^(-?\d+)(,([a-z]+))?/.exec(e.line);Array.isArray(r)&&(t.line=Number(r[1]),t.snapToLines=!0,Ue(["start","center","end"],r[3])&&(t.lineAlign=r[3]))}}if(et(e.position)){var i=/^([\d\.]+)%(?:,(line-left|line-right|center))?$/.exec(e.position);if(Array.isArray(i)&&i.length>=2){var a=parseInt(i[1],10);isNaN(a)||(t.position=a,void 0!==i[2]&&(t.positionAlign=i[2]))}}et(e.size)&&(t.size=e.size),"string"==typeof e.align&&Ue(["start","center","end","left"],e.align)&&(t.align=e.align)}var Gc=function(e,t){var n=e.split(/\r\n|\n|\r/);if(!/^WEBVTT($| |\t)/.test(n[0]))throw new Error("Can't parse WebVTT: Invalid file.");for(var r,i=zc(n,Lc(n)),a=[],o=0;o<i.length;o++){var s=Kc(i[o],t);if(null!==s){var u=sc((r=s).start,r.end,r.payload.join("\n"));null!==u&&(oc(u)&&Wc(s.settings,u),a.push(u))}}return a};function jc(e){e.nativeTextTracksParsers.vtt=Gc,e.nativeTextDisplayer=$d}function Hc(e,t){for(var n=t+1;et(e[n]);)n++;return n}function qc(e){for(var t=[],n=0;n<e.length;n++)if(et(e[n])){var r=Hc(e,n),i=e.slice(n,r);i.length>0&&(1===i.length?i[0].indexOf("--\x3e")>=0&&t.push(i):(i[1].indexOf("--\x3e")>=0||i[0].indexOf("--\x3e")>=0)&&t.push(i)),n=r}return t}function Yc(e){var t=e.split(":");if(et(t[2])){var n=parseInt(t[0],10),r=parseInt(t[1],10),i=parseFloat(t[2].replace(",","."));if(isNaN(n)||isNaN(r)||isNaN(i))return;return 60*n*60+60*r+i}}function Qc(e,t){if(0===e.length)return null;var n,r,i=[];if(et(e[1])&&-1!==e[1].indexOf("--\x3e")){var a=e[1].split("--\x3e").map((function(e){return e.trim()}));n=a[0],r=a[1],i=e.slice(2,e.length)}if(!et(n)||!et(r)){var o=e[0].split("--\x3e").map((function(e){return e.trim()}));n=o[0],r=o[1],i=e.slice(1,e.length)}if(!et(n)||!et(r))return null;var s=Yc(n),u=Yc(r);return void 0===s||void 0===u?null:{start:s+t,end:u+t,payload:i}}function $c(e,t){for(var n,r,i,a,o,s=qc(e.split(/\r\n|\n|\r/)),u=[],l=0;l<s.length;l++){var d=Qc(s[l],t);if(null!==d){var c=(r=void 0,i=void 0,a=void 0,o=void 0,r=(n=d).start,i=n.end,a=n.payload,o=a.join("\n"),sc(r,i,o));null!==c&&u.push(c)}}return u}function Xc(e){e.nativeTextTracksParsers.srt=$c,e.nativeTextDisplayer=$d}var Zc=s.ResizeObserver;function Jc(e,t,n){return void 0===n&&(n=.2),Math.abs(e-t)<=Math.min(n,.2)}function ef(e,t){for(var n=e.length-1;n>=0;n--){if(e[n].start<t)return e.slice(0,n+1)}return[]}function tf(e,t){for(var n=0;n<e.length;n++){if(e[n].end>t)return e.slice(n,e.length)}return[]}function nf(e,t,n){var r=Math.max(e.start,t),i=ef(e.cues,t),a={start:e.start,end:r,cues:i},o=Math.min(n,e.end),s=tf(e.cues,n);return[a,{start:o,end:e.end,cues:s}]}var rf=function(){function e(){this._cuesBuffer=[]}var t=e.prototype;return t.isEmpty=function(){return 0===this._cuesBuffer.length},t.get=function(e){for(var t=this._cuesBuffer,n=[],r=t.length-1;r>=0;r--){var i=t[r];if(e<i.end&&e>=i.start){for(var a=i.cues,o=0;o<a.length;o++)e>=a[o].start&&e<a[o].end&&n.push(a[o].element);if(0===n.length&&a.length>0)for(var s=0;s<a.length;s++)(Jc(e,a[s].start,.001)||Jc(e,a[s].end,.001))&&n.push(a[s].element);return n}}return[]},t.remove=function(e,t){for(var n=Math.max(e,t),r=this._cuesBuffer,i=0;i<r.length;i++)if(r[i].end>e){var a=r[i];if(a.start>=n)return;if(a.end>=n){if(e<=a.start)a.cues=tf(a.cues,n),a.start=n;else{var o=nf(a,e,n),s=o[0],u=o[1];this._cuesBuffer[i]=s,r.splice(i+1,0,u)}return}a.start>=e?(r.splice(i,1),i--):(a.cues=ef(a.cues,e),a.end=Math.max(e,a.start))}},t.insert=function(e,t,n){var r=this._cuesBuffer,i={start:t,end:n,cues:e},a=Math.abs(t-n)/5;function o(e){var t=r[e];void 0===t||Jc(i.end,t.end,a)?r[e]=i:(t.start>=i.end||(t.cues=tf(t.cues,i.end),t.start=i.end),r.splice(e,0,i))}for(var s=0;s<r.length;s++){var u=r[s];if(t<u.end){if(Jc(t,u.start,a)){if(Jc(n,u.end,a))return void(r[s]=i);if(n<u.end)return u.cues=tf(u.cues,n),u.start=n,void r.splice(s,0,i);do{r.splice(s,1),u=r[s]}while(void 0!==u&&n>u.end);return void o(s)}if(t<u.start){if(n<u.start)return void r.splice(s,0,i);if(Jc(n,u.start,a))return u.start=n,void r.splice(s,0,i);if(Jc(n,u.end,a))return void r.splice(s,1,i);if(n<u.end)return u.cues=tf(u.cues,n),u.start=n,void r.splice(s,0,i);do{r.splice(s,1),u=r[s]}while(void 0!==u&&n>u.end);return void o(s)}if(Jc(u.end,n,a))return u.cues=ef(u.cues,t),u.end=t,void r.splice(s+1,0,i);if(u.end>n){var l=nf(u,t,n),d=l[0],c=l[1];return this._cuesBuffer[s]=d,r.splice(s+1,0,i),void r.splice(s+2,0,c)}u.cues=ef(u.cues,t),u.end=t;var f=s+1;for(u=r[f];void 0!==u&&n>u.end;)r.splice(f,1),u=r[f];return void o(f)}}if(r.length){var v=r[r.length-1];Jc(v.end,t,a)&&(v.end=t)}r.push(i)},e}();function af(e,t,n,r){for(var i=[t/n.columns,e/n.rows],a=r.getElementsByClassName("proportional-style"),o=0;o<a.length;o++){var s=a[o];if(s instanceof HTMLElement){var u=s.getAttribute("data-proportional-font-size");null===u||isNaN(+u)||(s.style.fontSize=String(+u*i[1])+"px");var l=s.getAttribute("data-proportional-width");null===l||isNaN(+l)||(s.style.width=String(+l*i[0])+"px");var d=s.getAttribute("data-proportional-height");null===d||isNaN(+d)||(s.style.height=String(+d*i[1])+"px");var c=s.getAttribute("data-proportional-line-height");null===c||isNaN(+c)||(s.style.lineHeight=String(+c*i[1])+"px");var f=s.getAttribute("data-proportional-left");null===f||isNaN(+f)||(s.style.left=String(+f*i[0])+"px");var v=s.getAttribute("data-proportional-top");null===v||isNaN(+v)||(s.style.top=String(+v*i[1])+"px");var p=s.getAttribute("data-proportional-padding-top");null===p||isNaN(+p)||(s.style.paddingTop=String(+p*i[1])+"px");var h=s.getAttribute("data-proportional-padding-bottom");null===h||isNaN(+h)||(s.style.paddingBottom=String(+h*i[1])+"px");var m=s.getAttribute("data-proportional-padding-left");null===m||isNaN(+m)||(s.style.paddingLeft=String(+m*i[0])+"px");var g=s.getAttribute("data-proportional-padding-right");null===g||isNaN(+g)||(s.style.paddingRight=String(+g*i[0])+"px")}}return a.length>0}function of(e,t){try{e.removeChild(t)}catch(e){T.warn("HTD: Can't remove text track: not in the element.")}}function sf(e){var t=e.getAttribute("data-resolution-rows"),n=e.getAttribute("data-resolution-columns");if(null===t||null===n)return null;var r=parseInt(t,10),i=parseInt(n,10);return null===r||null===i?null:{rows:r,columns:i}}var uf,lf=function(){function e(e,t){T.debug("HTD: Creating HTMLTextDisplayer"),this._buffered=new Yd,this._videoElement=e,this._textTrackElement=t,this._sizeUpdateCanceller=new Z,this._subtitlesIntervalCanceller=new Z,this._buffer=new rf,this._currentCues=[],this._isAutoRefreshing=!1}var t=e.prototype;return t.pushTextData=function(e){var t,n;T.debug("HTD: Appending new html text tracks");var r=e.timestampOffset,i=e.appendWindow,a=e.chunk;if(null===a)return M(this._buffered);var o,s,u=a.start,l=a.end,d=a.data,c=a.type,f=a.language,v=null!==(t=i[0])&&void 0!==t?t:0,p=null!==(n=i[1])&&void 0!==n?n:1/0,h=function(e,t,n,r){T.debug("HTSB: Finding parser for html text tracks:",e);var i=ot.htmlTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");T.debug("HTSB: Parser found, parsing...");var a=i(t,n,r);return T.debug("HTTB: Parsed successfully!",a.length),a}(c,d,r,f);if(0!==v&&p!==1/0){for(var m=0;m<h.length&&h[m].end<=v;)m++;for(h.splice(0,m),m=0;m<h.length&&h[m].start<v;)h[m].start=v,m++;for(m=h.length-1;m>=0&&h[m].start>=p;)m--;for(h.splice(m,h.length),m=h.length-1;m>=0&&h[m].end>p;)h[m].end=p,m--}if(void 0!==u)o=Math.max(v,u);else{if(h.length<=0)return T.warn("HTD: Current text tracks have no cues nor start time. Aborting"),M(this._buffered);T.warn("HTD: No start time given. Guessing from cues."),o=h[0].start}if(void 0!==l)s=Math.min(p,l);else{if(h.length<=0)return T.warn("HTD: Current text tracks have no cues nor end time. Aborting"),M(this._buffered);T.warn("HTD: No end time given. Guessing from cues."),s=h[h.length-1].end}return s<=o?(T.warn("HTD: Invalid text track appended: ","the start time is inferior or equal to the end time."),M(this._buffered)):(this._buffer.insert(h,o,s),this._buffered.insert(o,s),this._isAutoRefreshing||this._buffer.isEmpty()||this.autoRefreshSubtitles(this._subtitlesIntervalCanceller.signal),M(this._buffered))},t.removeBuffer=function(e,t){return T.debug("HTD: Removing html text track data",e,t),this._buffer.remove(e,t),this._buffered.remove(e,t),this._isAutoRefreshing&&this._buffer.isEmpty()&&(this.refreshSubtitles(),this._isAutoRefreshing=!1,this._subtitlesIntervalCanceller.cancel(),this._subtitlesIntervalCanceller=new Z),M(this._buffered)},t.getBufferedRanges=function(){return M(this._buffered)},t.reset=function(){T.debug("HTD: Resetting HTMLTextDisplayer"),this.stop(),this._subtitlesIntervalCanceller=new Z},t.stop=function(){this._subtitlesIntervalCanceller.isUsed()||(T.debug("HTD: Stopping HTMLTextDisplayer"),this._disableCurrentCues(),this._buffer.remove(0,1/0),this._buffered.remove(0,1/0),this._isAutoRefreshing=!1,this._subtitlesIntervalCanceller.cancel())},t._disableCurrentCues=function(){if(this._sizeUpdateCanceller.cancel(),this._currentCues.length>0){for(var e=0;e<this._currentCues.length;e++)of(this._textTrackElement,this._currentCues[e].element);this._currentCues=[]}},t._displayCues=function(e){if(!(this._currentCues.length===e.length&&this._currentCues.every((function(t,n){return t.element===e[n]})))){this._sizeUpdateCanceller.cancel();for(var t=0;t<this._currentCues.length;t++)of(this._textTrackElement,this._currentCues[t].element);this._currentCues=[];for(var n=0;n<e.length;n++){var r=e[n],i=sf(r);this._currentCues.push({element:r,resolution:i}),this._textTrackElement.appendChild(r)}var a=this._currentCues.filter((function(e){return null!==e.resolution}));if(a.length>0){this._sizeUpdateCanceller=new Z,this._sizeUpdateCanceller.linkToSignal(this._subtitlesIntervalCanceller.signal);var o=b.getCurrent().TEXT_TRACK_SIZE_CHECKS_INTERVAL,s=function(e,t,n){var r=e.getBoundingClientRect(),i=r.height,a=r.width,o=new G({height:i,width:a},n),s=i,u=a;if(void 0!==Zc){var l=new Zc((function(e){if(0!==e.length){var t=e[0].contentRect,n=t.height,r=t.width;n===s&&r===u||(s=n,u=r,o.setValue({height:n,width:r}))}else T.error("Compat: Resized but no observed element.")}));l.observe(e),n.register((function(){l.disconnect()}))}else{var d=setInterval((function(){var t=e.getBoundingClientRect(),n=t.height,r=t.width;n===s&&r===u||(s=n,u=r,o.setValue({height:n,width:r}))}),t);n.register((function(){clearInterval(d)}))}return o}(this._textTrackElement,o,this._sizeUpdateCanceller.signal);s.onUpdate((function(e){for(var t=e.height,n=e.width,r=0;r<a.length;r++){var i=a[r];af(t,n,i.resolution,i.element)}}),{clearSignal:this._sizeUpdateCanceller.signal,emitCurrentValue:!0})}}},t.autoRefreshSubtitles=function(e){var t=this;if(!this._isAutoRefreshing&&!e.isCancelled()){var n=null,r=b.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL,i=function(){t._isAutoRefreshing=!1,null!==n&&(n.cancel(),n=null)},a=function(){i(),t._isAutoRefreshing=!0,(n=new Z).linkToSignal(e);var a=setInterval((function(){return t.refreshSubtitles()}),r);n.signal.register((function(){clearInterval(a)})),t.refreshSubtitles()};qr(this._videoElement,(function(){i(),t._disableCurrentCues()}),e),Yr(this._videoElement,a,e),Qr(this._videoElement,a,e),a()}},t.refreshSubtitles=function(){var e,t=b.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL;e=this._videoElement.paused||this._videoElement.playbackRate<=0?this._videoElement.currentTime:Math.max(this._videoElement.currentTime+t/1e3/2,0);var n=this._buffer.get(e);0===n.length?this._disableCurrentCues():this._displayCues(n)},e}(),df=lf;function cf(e){return void 0===e.extent&&void 0===e.origin&&void 0===e.displayAlign&&void 0===e.display&&void 0===e.textAlign&&void 0===e.fontSize}function ff(e){e.extent="70% 20%",e.fontSize="1c",e.origin="15% 80%",e.displayAlign="before",e.textAlign="center"}function vf(e,t){(void 0===uf&&(uf=void 0!==e.classList&&"function"==typeof e.classList.add),uf)?e.classList.add(t):(" "+e.className+" ").indexOf(" "+t+" ")<0&&(e.className+=" "+t)}function pf(e,t){var n=t;return et(t)&&t.trim().endsWith("%")&&(n=t.trim().slice(0,-1),n=(parseInt(n,10)/100).toString()+"em"),"-1px -1px "+n+" "+e+",1px -1px "+n+" "+e+",-1px 1px "+n+" "+e+",1px 1px "+n+" "+e}function hf(e){var n;return t(n=mc.exec(e))?t(n=gc.exec(e))?t(n=yc.exec(e))?t(n=_c.exec(e))?e:"rgba("+String(+n[1])+","+String(+n[2])+","+String(+n[3])+","+String(+n[4]/255)+")":"rgb("+String(+n[1])+","+String(+n[2])+","+String(+n[3])+")":"rgba("+String(parseInt(n[1]+n[1],16))+","+String(parseInt(n[2]+n[2],16))+","+String(parseInt(n[3]+n[3],16))+","+String(parseInt(n[4]+n[4],16)/255)+")":"rgba("+String(parseInt(n[1],16))+","+String(parseInt(n[2],16))+","+String(parseInt(n[3],16))+","+String(parseInt(n[4],16)/255)+")"}var mf=["color","direction","display","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","textOutline","unicodeBidi","visibility","wrapOption"];function gf(e,t,n){var r=t.color;et(r)&&(e.style.color=hf(r));var i=t.backgroundColor;et(i)&&(e.style.backgroundColor=hf(i));var a=t.textOutline;if(et(a)){var o=a.trim().replace(/\s+/g," ").split(" "),s=o.length;if(3===s){var u=hf(o[0]),l=o[1];e.style.textShadow=pf(u,l)}else if(et(r)&&1===s){var d=o[0];e.style.textShadow=pf(r,d)}else if(2===s){var c=/^[#A-Z]/i.test(o[0]);if(c!==/^[0-9]/.test(o[0]))if(c){var f=hf(o[0]),v=o[1];e.style.textShadow=pf(f,v)}else if(et(r)){var p=o[0];e.style.textShadow=pf(r,p)}}}var h=t.textDecoration;if(et(h))switch(h){case"noUnderline":case"noLineThrough":case"noOverline":e.style.textDecoration="none";break;case"lineThrough":e.style.textDecoration="line-through";break;default:e.style.textDecoration=h}var m=t.fontFamily;if(et(m))switch(m){case"proportionalSansSerif":e.style.fontFamily="Arial, Helvetica, Liberation Sans, sans-serif";break;case"monospaceSansSerif":case"sansSerif":e.style.fontFamily="sans-serif";break;case"monospaceSerif":case"default":e.style.fontFamily="Courier New, Liberation Mono, monospace";break;case"proportionalSerif":e.style.fontFamily="serif";break;default:e.style.fontFamily=m}var g=t.fontStyle;et(g)&&(e.style.fontStyle=g);var y=t.fontWeight;et(y)&&(e.style.fontWeight=y);var _=t.fontSize;et(_)?function(e,t){var n=t.trim().split(" ");if(0!==n.length){var r=hc.exec(n[0]);if(null!==r)if("px"===r[2]||"em"===r[2])e.style.fontSize=r[1]+r[2];else if("c"===r[2])e.style.position="relative",vf(e,"proportional-style"),e.setAttribute("data-proportional-font-size",r[1]);else if("%"===r[2]){var i=Number(r[1]);isNaN(i)?T.warn('TTML Parser: could not parse fontSize value "'+r[1]+'" into a number'):(e.style.position="relative",vf(e,"proportional-style"),e.setAttribute("data-proportional-font-size",String(i/100)))}else T.warn("TTML Parser: unhandled fontSize unit:",r[2])}}(e,_):(vf(e,"proportional-style"),e.setAttribute("data-proportional-font-size","1"));var b=t.direction;et(b)&&(e.style.direction=b);var S=t.unicodeBidi;if(et(S))switch(S){case"bidiOverride":e.style.unicodeBidi="bidi-override";break;case"embed":e.style.unicodeBidi="embed";break;default:e.style.unicodeBidi="normal"}var E=t.visibility;et(E)&&(e.style.visibility=E),"none"===t.display&&(e.style.display="none");var k=t.wrapOption;e.style.whiteSpace="noWrap"===k?n?"nowrap":"pre":n?"normal":"pre-wrap"}function yf(e,t){e.style.color="white",e.style.position="absolute";var n=t.extent;et(n)&&function(e,t){var n=t.trim();if("auto"!==n){var r=n.split(" ");if(2===r.length){var i=hc.exec(r[0]),a=hc.exec(r[1]);null!==i&&null!==a&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.width=i[1]+i[2]:"c"===i[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-width",i[1])):T.warn("TTML Parser: unhandled extent unit:",i[2]),"px"===a[2]||"%"===a[2]||"em"===a[2]?e.style.height=a[1]+a[2]:"c"===a[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-height",a[1])):T.warn("TTML Parser: unhandled extent unit:",a[2]))}}}(e,n),et(t.writingMode);var r=t.overflow;e.style.overflow=et(r)?r:"hidden";var i=t.padding;et(i)&&function(e,t){var n=t.trim().split(" ");if(!(n.length<1)){var r=hc.exec(n[0]);if(null!==r){if("px"===r[2]||"%"===r[2]||"em"===r[2]){var i=r[1]+r[2];1===n.length?e.style.padding=i:2===n.length?(e.style.paddingTop=i,e.style.paddingBottom=i):e.style.paddingTop=i}else"c"===r[2]?(vf(e,"proportional-style"),1===n.length?(e.setAttribute("data-proportional-padding-top",r[1]),e.setAttribute("data-proportional-padding-bottom",r[1]),e.setAttribute("data-proportional-padding-left",r[1]),e.setAttribute("data-proportional-padding-right",r[1])):2===n.length?(e.setAttribute("data-proportional-padding-top",r[1]),e.setAttribute("data-proportional-padding-bottom",r[1])):e.setAttribute("data-proportional-padding-top",r[1])):T.warn("TTML Parser: unhandled padding unit:",r[2]);if(1!==n.length){var a=hc.exec(n[1]);if(null!==a){if("px"===a[2]||"%"===a[2]||"em"===a[2]){var o=a[1]+a[2];n.length<4?(e.style.paddingLeft=o,e.style.paddingRight=o):e.style.paddingRight=o}else"c"===a[2]?(vf(e,"proportional-style"),n.length<4?(e.setAttribute("data-proportional-padding-left",a[1]),e.setAttribute("data-proportional-padding-right",a[1])):e.setAttribute("data-proportional-padding-right",a[1])):T.warn("TTML Parser: unhandled padding unit:",a[2]);if(2!==n.length){var s=hc.exec(n[2]);if(null!==s){if("px"===s[2]||"%"===s[2]||"em"===s[2]){var u=s[1]+s[2];e.style.paddingBottom=u}else"c"===s[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-padding-bottom",s[1])):T.warn("TTML Parser: unhandled padding unit:",s[2]);if(3!==n.length){var l=hc.exec(n[3]);if(null!==l)if("px"===l[2]||"%"===l[2]||"em"===l[2]){var d=l[1]+l[2];e.style.paddingLeft=d}else"c"===l[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-padding-left",l[1])):T.warn("TTML Parser: unhandled padding unit:",l[2])}}}}}}}}(e,i);var a=t.origin;et(a)&&function(e,t){var n=t.trim();if("auto"!==n){var r=n.split(" ");if(2===r.length){var i=hc.exec(r[0]),a=hc.exec(r[1]);null!==i&&null!==a&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.left=i[1]+i[2]:"c"===i[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-left",i[1])):T.warn("TTML Parser: unhandled origin unit:",i[2]),"px"===a[2]||"%"===a[2]||"em"===a[2]?e.style.top=a[1]+a[2]:"c"===a[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-top",a[1])):T.warn("TTML Parser: unhandled origin unit:",a[2]))}}}(e,a);var o=t.displayAlign;if(et(o))switch(e.style.display="flex",e.style.flexDirection="column",o){case"before":e.style.justifyContent="flex-start";break;case"center":e.style.justifyContent="center";break;case"after":e.style.justifyContent="flex-end"}var s=t.opacity;et(s)&&(e.style.opacity=s);var u=t.visibility;et(u)&&(e.style.visibility=u),"none"===t.display&&(e.style.display="none")}function _f(e,t){e.style.margin="0px",vf(e,"proportional-style"),e.setAttribute("data-proportional-font-size","1");var n=t.backgroundColor;et(n)&&(e.style.backgroundColor=hf(n));var r=t.lineHeight;et(r)&&function(e,t){var n=t.trim(),r=n.split(" ");if("auto"!==n){var i=hc.exec(r[0]);null!==i&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.lineHeight=i[1]+i[2]:"c"===i[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-line-height",i[1])):T.warn("TTML Parser: unhandled lineHeight unit:",i[2]))}}(e,r);var i=t.textAlign;if(et(i))switch(i){case"center":e.style.textAlign="center";break;case"left":case"start":e.style.textAlign="left";break;case"right":case"end":e.style.textAlign="right"}}function bf(e,t,n){var r=document.createElement("span"),i=null===e.textContent?"":e.textContent;if(n){var a=i.trim();i=a=a.replace(/\s+/g," ")}var o=document.createTextNode(i);return r.appendChild(o),r.className="rxp-texttrack-span",gf(r,t,n),r}function Sf(e,t,n,r,i,a){var o=a.cellResolution,s=a.shouldTrimWhiteSpace,u=tc(e),l=document.createElement("DIV");if(l.className="rxp-texttrack-region",l.setAttribute("data-resolution-columns",String(o.columns)),l.setAttribute("data-resolution-rows",String(o.rows)),yf(l,i),null!==t){var d=Zd(["backgroundColor"],[].concat(u,[t]),r,n).bodyBackgroundColor;et(d)&&(l.style.backgroundColor=hf(d))}var c=document.createElement("p");c.className="rxp-texttrack-p",_f(c,i);for(var f=function(e,t,n,r,i){return function e(r,i,a,o){for(var s=r.childNodes,u=[],l=0;l<s.length;l++){var d=s[l];if("#text"===d.nodeName){var c=Zd(["backgroundColor"],a,n,t).backgroundColor;et(c)?i.backgroundColor=c:delete i.backgroundColor;var f=bf(d,i,o);u.push(f)}else if(nc(d)){var v=document.createElement("BR");u.push(v)}else if(rc(d)&&d.nodeType===Node.ELEMENT_NODE&&d.childNodes.length>0){var p=d.getAttribute("xml:space"),h=et(p)?"default"===p:o,g=m({},i,Zd(mf,[d],n,t));u.push.apply(u,e(d,g,[d].concat(a),h))}}return u}(e,m({},r),[],i)}(e,n,r,i,s),v=0;v<f.length;v++)c.appendChild(f[v]);return l.appendChild(c),l}function Ef(e){var t=e.paragraph,n=e.ttParams,r=e.body,i=e.regionStyles,a=e.idStyles,o=e.paragraphStyle,s=e.timeOffset,u=e.shouldTrimWhiteSpace;if(!t.hasAttribute("begin")&&!t.hasAttribute("end")&&/^\s*$/.test(null===t.textContent?"":t.textContent))return null;var l=n.cellResolution,d=Ec(t,n);return{start:d.start+s,end:d.end+s,element:Sf(t,r,i,a,o,{cellResolution:l,shouldTrimWhiteSpace:u})}}var Tf=function(e,t){for(var n=ac(e,t),r=[],i=0;i<n.length;i++){var a=n[i].paragraphStyle;cf(a)&&ff(a);var o=Ef(n[i]);null!==o&&r.push(o)}return r};function kf(e){e.htmlTextTracksParsers.ttml=Tf,e.htmlTextDisplayer=df}var wf=/&#([0-9]+);/g,Af=/<br>/gi,If=/<style[^>]*>([\s\S]*?)<\/style[^>]*>/i,Rf=/\s*<p (?:class=([^>]+))?>(.*)/i,xf=/<sync[^>]+?start="?([0-9]*)"?[^0-9]/i;function Cf(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}var Mf=function(e,n,r){var i,a,o=/<sync[ >]/gi,s=/<sync[ >]|<\/body>/gi,u=[],l=If.exec(e),d=Array.isArray(l)?l[1]:"";s.exec(e);var c,f=function(e){for(var n=/\.(\S+)\s*{([^}]*)}/gi,r={},i=n.exec(e);null!==i;){var a=i[1],o=Cf(i[2],"lang");t(a)||t(o)||(r[o]=a),i=n.exec(e)}return r}(d),v=function(e){var t=/p\s*{([^}]*)}/gi.exec(e);return null===t?"":t[1]}(d);if(et(r)&&void 0===(c=f[r]))throw new Error("sami: could not find lang "+r+" in CSS");for(;i=o.exec(e),a=s.exec(e),null!==i||null!==a;){if(null===i||null===a||i.index>=a.index)throw new Error("parse error");var p=e.slice(i.index,a.index),h=xf.exec(p);if(!Array.isArray(h))throw new Error("parse error (sync time attribute)");var m=+h[1];if(isNaN(m))throw new Error("parse error (sync time attribute NaN)");g(p.split("\n"),m/1e3)}return u;function g(e,t){for(var r=e.length;--r>=0;){var i=Rf.exec(e[r]);if(Array.isArray(i)){var a=i[1],o=i[2];if(c===a)if(" "===o)u[u.length-1].end=t;else{var s=document.createElement("DIV");s.className="rxp-texttrack-region";var l=document.createElement("DIV");l.className="rxp-texttrack-div",l.style.position="absolute",l.style.bottom="0",l.style.width="100%",l.style.color="#fff",l.style.textShadow="-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000";var d=document.createElement("div");d.className="rxp-texttrack-p",et(v)&&(d.style.cssText=v);for(var f=o.split(Af),p=0;p<f.length;p++){0!==p&&d.appendChild(document.createElement("BR"));var h=document.createElement("SPAN");h.className="rxp-texttrack-span",h.textContent=f[p].replace(wf,(function(e,t){return String.fromCharCode(Number(t))})),d.appendChild(h)}l.appendChild(d),s.appendChild(l),u.push({element:s,start:t+n,end:-1})}}}}};function Pf(e){e.htmlTextTracksParsers.sami=Mf,e.htmlTextDisplayer=df}var Df={white:"#ffffff",lime:"#00ff00",cyan:"#00ffff",red:"#ff0000",yellow:"#ffff00",magenta:"#ff00ff",blue:"#0000ff",black:"#000000"};function Of(e){var t=Object.keys(Df).reduce((function(e,t){return e[t]="color: "+Df[t]+";",e["bg_"+t]="background-color: "+Df[t]+";",e}),{}),n="";return e.forEach((function(e){if(e.length>=2)for(var r=function(r){var a=e[r];if(Array.isArray(/::cue {/.exec(a)))for(a=e[++r];et(a)&&!Array.isArray(/}/.exec(a))&&0!==a.length;)n+=a,a=e[++r];else{for(var o=[],s=/::cue\(\.?(.*?)\)(?:,| {)/.exec(a);et(a)&&Array.isArray(s);)o.push(s[1]),a=e[++r],s=/::cue\(\.?(.*?)\)(?:,| {)/.exec(a);for(var u="";et(a)&&!Array.isArray(/}/.exec(a))&&0!==a.length;)u+=a,a=e[++r];o.forEach((function(e){void 0===t[e]?t[e]=u:t[e]+=u}))}i=r},i=1;i<e.length;i++)r(i)})),{classes:t,global:n}}function Nf(e,t){var n,r=["u","i","b"],i=e.nodeName.toLowerCase().split(".")[0];if(Ue(["u","i","b","c","#text"],i))if("#text"===i){var a=e.wholeText.split("\n");n=document.createElement("span");for(var o=0;o<a.length;o++)if(o>0&&n.appendChild(document.createElement("br")),a[o].length>0){var s=document.createTextNode(a[o]);n.appendChild(s)}}else{var u=e.nodeName.toLowerCase().split("."),l=[];if(u.forEach((function(e){et(t[e])&&l.push(t[e])})),0!==l.length){var d=document.createAttribute("style");l.forEach((function(e){d.value+=e}));var c=Ue(r,i)?i:"span";(n=document.createElement(c)).setAttributeNode(d)}else{var f=Ue(r,i)?i:"span";n=document.createElement(f)}for(var v=0;v<e.childNodes.length;v++){var p=Nf(e.childNodes[v],t);n.appendChild(p)}}else{n=document.createElement("span");for(var h=0;h<e.childNodes.length;h++){var m=Nf(e.childNodes[h],t);n.appendChild(m)}}return n}var Lf,Uf,Ff,Bf=function(e){if(!(void 0!==e&&0!==ge(e).length))return"text-align:center";var t=zf(e),n=Wf(e);return"position: absolute;margin: 0;transform: translate("+t.offset+"%,"+n.offset+"%);width: "+qf(e.size)+"%;left: "+t.position+"%;top: "+(null!==n.position?n.position+"%":"auto")+";text-align: "+Hf(e.align)+";"};!function(e){e.LINE_LEFT="line-left",e.CENTER="center",e.LINE_RIGHT="line-right"}(Lf||(Lf={})),function(e){e.LEFT="left",e.CENTER="center",e.RIGHT="right"}(Uf||(Uf={})),function(e){e.START="start",e.CENTER="center",e.END="end"}(Ff||(Ff={}));var zf=function(e){return{position:Vf(e),offset:Kf(e)}},Vf=function(e){var t,n=Qf(e.position);if(null!==n)return n;var r=Hf(e.align);return((t={})[Uf.LEFT]=0,t[Uf.CENTER]=50,t[Uf.RIGHT]=100,t)[r]},Kf=function(e){var t,n,r,i,a=((t={})[Lf.LINE_LEFT]=0,t[Lf.CENTER]=-50,t[Lf.LINE_RIGHT]=-100,t),o=void 0!==e.position?(r=e.position,i=/,(line-left|line-right|center)/.exec(r),!Array.isArray(i)||i.length<2?null:i[1]):null;return null!==o?a[o]:((n={})[Uf.LEFT]=0,n[Uf.CENTER]=-50,n[Uf.RIGHT]=-100,n)[void 0!==e.align?Hf(e.align):Uf.CENTER]},Wf=function(e){return{position:Gf(e.line),offset:jf(e.line)}},Gf=function(e){return Qf(e)},jf=function(e){var t,n=((t={})[Ff.START]=0,t[Ff.CENTER]=-50,t[Ff.END]=-100,t);if(void 0===e)return n[Ff.START];var r,i=(r=/,(start|center|end)/.exec(e),!Array.isArray(r)||r.length<2?null:r[1]);return null!==i?n[i]:n[Ff.START]},Hf=function(e){switch(e){case"left":case"start":return"left";case"right":case"end":return"right";default:return"center"}},qf=function(e){return Yf(e,100)},Yf=function(e,t){var n=Qf(e);return null!==n?n:t},Qf=function(e){if(void 0===e)return null;var t=/^([\d.]+)%/.exec(e);return!Array.isArray(t)||t.length<2?null:parseInt(t[1],10)};function $f(e,t){var n=e.start,r=e.end,i=e.settings,a=e.header,o=e.payload,s=document.createElement("div"),u=document.createAttribute("style");u.value="width:100%;height:100%;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;",s.setAttributeNode(u);var l=document.createElement("p"),d=function(e){var t=document.createAttribute("style");return t.value=Bf(e),t}(i);l.setAttributeNode(d);var c=document.createElement("span"),f=document.createAttribute("style");f.value="background-color:rgba(0,0,0,0.8);color:white;",c.setAttributeNode(f);var v=t.global,p=t.classes,h=[v,et(a)?p[a]:void 0].filter((function(e){return void 0!==e})).join("");return f.value+=h,c.setAttributeNode(f),function(e,t){for(var n=e.replace(/<[0-9]{2}:[0-9]{2}.[0-9]{3}>/,"").replace(/<([u,i,b,c])(\..*?)?(?: .*?)?>(.*?)<\/\1>/g,"<$1$2>$3</$1$2>"),r=(new DOMParser).parseFromString(n,"text/html").body.childNodes,i=[],a=0;a<r.length;a++)i.push(Nf(r[a],t));return i}(o.join("\n"),p).forEach((function(e){c.appendChild(e)})),s.appendChild(l),l.appendChild(c),{start:n,end:r,element:s}}var Xf=function(e,t){var n=e.split(/\r\n|\n|\r/g),r=[];if(null===/^WEBVTT( |\t|\n|\r|$)/.exec(n[0]))throw new Error("Can't parse WebVTT: Invalid File.");for(var i=Lc(n),a=function(e,t){for(var n=[],r=t;r<e.length;r++)if(Uc(e,r)){var i=r;for(r++;et(e[r]);)r++;var a=e.slice(i,r);n.push(a)}else if(et(e[r]))for(;et(e[r]);)r++;return n}(n,i),o=zc(n,i),s=Of(a),u=0;u<o.length;u++){var l=Kc(o[u],t);if(null!==l){var d=$f(l,s);r.push(d)}}return r};function Zf(e){e.htmlTextTracksParsers.vtt=Xf,e.htmlTextDisplayer=df}function Jf(e,t){for(var n=qc(e.split(/\r\n|\n|\r/)),r=[],i=0;i<n.length;i++){var a=Qc(n[i],t);if(null!==a){var o=ev(a);null!==o&&r.push(o)}}return r}function ev(e){var t=e.start,n=e.end,r=e.payload,i=document.createElement("div");i.className="rxp-texttrack-p",i.style.fontSize="28px",i.style.position="absolute",i.style.bottom="5%",i.style.width="100%",i.style.textAlign="center",i.style.color="#fff",i.style.textShadow="-1px -1px 2px #000,1px -1px 2px #000,-1px 1px 2px #000,1px 1px 2px #000";for(var a=0;a<r.length;a++){0!==a&&i.appendChild(document.createElement("br"));var o=tv(r[a]);i.appendChild(o)}return{start:t,end:n,element:i}}function tv(e){var t=document.createElement("div");t.innerHTML=e;return function e(t){var n=t.childNodes,r=document.createElement("span");r.className="rxp-texttrack-span";for(var i=0;i<n.length;i++){var a=n[i];if("#text"===a.nodeName){for(var o=a.wholeText.split("\n"),s=0;s<o.length;s++)if(0!==s&&r.appendChild(document.createElement("br")),o[s].length>0){var u=document.createTextNode(o[s]);r.appendChild(u)}}else if("B"===a.nodeName){var l=e(a);l.style.fontWeight="bold",r.appendChild(l)}else if("I"===a.nodeName){var d=e(a);d.style.fontStyle="italic",r.appendChild(d)}else if("U"===a.nodeName){var c=e(a);c.style.textDecoration="underline",r.appendChild(c)}else if(nv(a)&&"string"==typeof a.color){var f=e(a);f.style.color=a.color,r.appendChild(f)}else{var v=e(a);r.appendChild(v)}}return r}(t)}function nv(e){return"FONT"===e.nodeName&&"color"in e}function rv(e){e.htmlTextTracksParsers.srt=Jf,e.htmlTextDisplayer=df}function iv(){if(!hi)return!0;var e=function(){if(!hi)return T.warn("Compat: Can't access Firefox version on no firefox browser."),null;var e=navigator.userAgent,t=/Firefox\/([0-9]+)\./.exec(e);if(null===t)return-1;var n=parseInt(t[1],10);return isNaN(n)?-1:n}();if(null===e||e<67)return!0;var t=null===HTMLVideoElement||void 0===HTMLVideoElement?void 0:HTMLVideoElement.prototype;return void 0!==(null==t?void 0:t.requirePictureInPicture)}function av(e){var t=e;if("function"==typeof t.getStartDate){var n=t.getStartDate();if("object"==typeof n&&null!==n){var r=+n;if(!isNaN(r))return r/1e3}else if("number"==typeof n&&!isNaN(n))return n}}var ov="function"==typeof MediaSource&&!0===MediaSource.canConstructInDedicatedWorker,sv="object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate,uv=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(j(i),t.prototype),i.name="WorkerInitializationError",i.type="WORKER_INITIALIZATION_ERROR",i.code=n,i.message=xe(i.code,r),i}return f(t,e),t}(Y(Error));var lv=_i;function dv(e,t,n){var r=t(e.getReference(),n);return{getCurrentTime:function(){return e.getCurrentTime()},getReadyState:function(){return e.getReadyState()},getPlaybackRate:function(){return e.getPlaybackRate()},getIsPaused:function(){return e.getIsPaused()},getReference:function(){return r},listen:function(e,t){var i;n.isCancelled()||!0===(null===(i=null==t?void 0:t.clearSignal)||void 0===i?void 0:i.isCancelled())||r.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},deriveReadOnlyObserver:function(e){return dv(this,e,n)}}}var cv=function(){function e(e,t){this._last=e,this._wanted=t}var t=e.prototype;return t.serialize=function(){return[this._last,this._wanted]},t.getPolled=function(){return this._last},t.getWanted=function(){var e;return null!==(e=this._wanted)&&void 0!==e?e:this._last},t.forceWantedPosition=function(e){this._wanted=e},t.isAwaitingFuturePosition=function(){return null!==this._wanted},e}(),fv=["canplay","ended","play","pause","seeking","seeked","loadedmetadata","ratechange"],vv=function(){function e(e,t){var n=this;this._internalSeeksIncoming=[],this._mediaElement=e,this._withMediaSource=t.withMediaSource,this._lowLatencyMode=t.lowLatencyMode,this._canceller=new Z,this._observationRef=this._createSharedReference(),this._expectedSeekingPosition=null,this._pendingSeek=null;var r=function(){if(null!==n._pendingSeek){var e=n._pendingSeek;n._pendingSeek=null,n._actuallySetCurrentTime(e)}};e.addEventListener("loadedmetadata",r),this._canceller.signal.register((function(){e.removeEventListener("loadedmetadata",r)}))}var t=e.prototype;return t.stop=function(){this._canceller.cancel()},t.getCurrentTime=function(){return this._mediaElement.currentTime},t.getPlaybackRate=function(){return this._mediaElement.playbackRate},t.getIsPaused=function(){return this._mediaElement.paused},t.setCurrentTime=function(e){this._mediaElement.readyState>=1?this._actuallySetCurrentTime(e):(this._internalSeeksIncoming=[],this._pendingSeek=e,this._generateObservationForEvent("manual"))},t.setPlaybackRate=function(e){this._mediaElement.playbackRate=e},t.getReadyState=function(){return this._mediaElement.readyState},t.getReference=function(){return this._observationRef},t.listen=function(e,t){var n;if(this._canceller.isUsed()||!0===(null===(n=null==t?void 0:t.clearSignal)||void 0===n?void 0:n.isCancelled()))return S;this._observationRef.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},t.deriveReadOnlyObserver=function(e){return dv(this,e,this._canceller.signal)},t._actuallySetCurrentTime=function(e){T.info("API: Seeking internally",e),this._internalSeeksIncoming.push(e),this._mediaElement.currentTime=e},t._createSharedReference=function(){var e=this;if(void 0!==this._observationRef)return this._observationRef;var t,n=b.getCurrent(),r=n.SAMPLING_INTERVAL_MEDIASOURCE,i=n.SAMPLING_INTERVAL_LOW_LATENCY,a=n.SAMPLING_INTERVAL_NO_MEDIASOURCE,o=new G(this._getCurrentObservation("init"),this._canceller.signal);t=this._lowLatencyMode?i:this._withMediaSource?r:a;var s=function(){e._generateObservationForEvent("timeupdate")},u=setInterval(s,t),l=fv.map((function(n){var r=function(){clearInterval(u),u=setInterval(s,t),e._generateObservationForEvent(n)};return e._mediaElement.addEventListener(n,r),function(){e._mediaElement.removeEventListener(n,r)}}));return this._canceller.signal.register((function(){clearInterval(u),l.forEach((function(e){return e()})),o.finish()})),o},t._getCurrentObservation=function(e){var t,n,r=e,i=void 0===this._observationRef?function(e){var t=hv(e);return m(t,{rebuffering:null,event:"init",seeking:0,position:new cv(t.position,null),freezing:null,bufferGap:0,currentRange:null})}(this._mediaElement):this._observationRef.getValue(),a=!1,o=this._pendingSeek,s=hv(this._mediaElement),u=s.buffered,l=s.readyState,d=s.position,c=s.seeking;if("seeking"===r)if(this._internalSeeksIncoming.length>0){a=!0,r="internal-seeking";var f=this._internalSeeksIncoming.shift();this._expectedSeekingPosition=lv?Math.max(d,null!=f?f:0):d}else this._expectedSeekingPosition=d;else c?this._expectedSeekingPosition=Math.max(d,null!==(t=this._expectedSeekingPosition)&&void 0!==t?t:0):lv&&null!==this._expectedSeekingPosition&&d<this._expectedSeekingPosition?o=this._expectedSeekingPosition:this._expectedSeekingPosition=null;c&&1===i.seeking&&"seeking"!==e&&(a=!0);var v,p,h=null!==(n=this._expectedSeekingPosition)&&void 0!==n?n:d;!this._withMediaSource&&0===u.length&&l>=3?(v=void 0,p=void 0):p=null!==(v=P(u,h))?v.end-h:1/0;var g,y=function(e){var t,n,r=e.previousObservation,i=e.currentObservation,a=e.basePosition,o=e.observationEvent,s=e.withMediaSource,u=e.lowLatencyMode,l=e.bufferGap,d=e.currentRange,c=b.getCurrent().REBUFFERING_GAP,f=i.position,v=i.duration,p=i.paused,h=i.readyState,m=i.ended,g=r.rebuffering,y=r.event,_=r.position,S=function(e,t,n,r,i){var a=b.getCurrent().REBUFFERING_GAP,o=i?"LOW_LATENCY":"DEFAULT";if(void 0===t)return n&&Math.abs(r-e)<=a[o];return null!==t&&r-t.end<=a[o]}(a,d,m,v,u),E=h>=1&&"loadedmetadata"!==o&&null===g&&!(S||m),T=null,k=u?c.LOW_LATENCY:c.DEFAULT;if(s){if(E)l===1/0?(t=!0,T=a):void 0===l?h<3&&(t=!0,T=void 0):l<=k&&(t=!0,T=a+l);else if(null!==g){var w=pv(g,u);!0!==t&&null!==g&&h>1&&(S||m||void 0!==l&&isFinite(l)&&l>w)||void 0===l&&h>=3?n=!0:void 0===l?T=void 0:l===1/0?T=a:l<=w&&(T=a+l)}}else E&&(!p&&"timeupdate"===o&&"timeupdate"===y&&f===_.getPolled()||"seeking"===o&&(l===1/0||void 0===l&&h<3))?t=!0:null!==g&&("seeking"!==o&&f!==_.getPolled()||"canplay"===o||void 0===l&&h>=3||void 0!==l&&l<1/0&&(l>pv(g,u)||S||m))&&(n=!0);if(!0===n)return null;var A;if(!0===t||null!==g)return A="seeking"===o||null!==g&&"seeking"===g.reason||i.seeking?"seeking":1===h?"not-ready":"buffering",null!==g&&g.reason===A?{reason:g.reason,timestamp:g.timestamp,position:T}:{reason:A,timestamp:ne(),position:T};return null}({previousObservation:i,currentObservation:s,basePosition:h,observationEvent:r,lowLatencyMode:this._lowLatencyMode,withMediaSource:this._withMediaSource,bufferGap:p,currentRange:v}),_=function(e,t,n,r){var i=b.getCurrent().MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING;if(e.freezing)return t.ended||t.paused||0===t.readyState||0===t.playbackRate||e.position.getPolled()!==t.position?null:e.freezing;return"timeupdate"===n&&void 0!==r&&r>i&&!t.ended&&!t.paused&&t.readyState>=1&&0!==t.playbackRate&&t.position===e.position.getPolled()?{timestamp:ne()}:null}(i,s,r,p);g=a?1:c?2:0;var S=m({},s,{position:new cv(s.position,o),event:r,seeking:g,rebuffering:y,freezing:_,bufferGap:p,currentRange:v});return T.hasLevel("DEBUG")&&T.debug("API: current media element state tick","event",S.event,"position",S.position.getPolled(),"seeking",S.seeking,"internalSeek",a,"rebuffering",null!==S.rebuffering,"freezing",null!==S.freezing,"ended",S.ended,"paused",S.paused,"playbackRate",S.playbackRate,"readyState",S.readyState,"pendingPosition",o),S},t._generateObservationForEvent=function(e){var t=this._getCurrentObservation(e);T.hasLevel("DEBUG")&&T.debug("API: current playback timeline:\n"+function(e,t){for(var n="",r="",i=0;i<e.length;i++){var a=e.start(i),o=e.end(i),s=a.toFixed(2),u=o.toFixed(2),l=s+"|=="+(o-a).toFixed(2)+"==|"+u;if(n+=l,0===r.length&&o>t){var d=n.length-Math.floor(l.length/2);r=" ".repeat(d)+"^"+t}if(i<e.length-1){var c=e.start(i+1),f=" ~"+(c-o).toFixed(2)+"~ ";if(n+=f,0===r.length&&t<c){var v=n.length-Math.floor(f.length/2);r=" ".repeat(v)+"^"+t}}}0===r.length&&(r=" ".repeat(n.length)+"^"+t);return n+"\n"+r}(t.buffered,t.position.getPolled()),"\n"+e),this._observationRef.setValue(t)},e}();function pv(e,t){if(null===e)return 0;var n=t?"LOW_LATENCY":"DEFAULT",r=b.getCurrent(),i=r.RESUME_GAP_AFTER_SEEKING,a=r.RESUME_GAP_AFTER_NOT_ENOUGH_DATA,o=r.RESUME_GAP_AFTER_BUFFERING;switch(e.reason){case"seeking":return i[n];case"not-ready":return a[n];case"buffering":return o[n]}}function hv(e){return{buffered:e.buffered,position:e.currentTime,duration:e.duration,ended:e.ended,paused:e.paused,playbackRate:e.playbackRate,readyState:e.readyState,seeking:e.seeking}}function mv(e){return gv.apply(this,arguments)}function gv(){return(gv=d(p().mark((function e(t){var n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==(n=Tr.getState(t))){e.next=3;break}return e.abrupt("return",void 0);case 3:return T.info("DRM: Disposing of the current MediaKeys"),r=n.loadedSessionsStore,Tr.clearState(t),e.next=8,r.closeAllSessions();case 8:return e.abrupt("return",Promise.race([n.emeImplementation.setMediaKeys(t,null).catch((function(e){T.error("DRM: Could not reset MediaKeys",e instanceof Error?e:"Unknown Error")})),Wn(1e3)]));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yv(e){if(T.info("DRM: Clearing-up DRM session."),vi)return T.info("DRM: disposing current MediaKeys."),mv(e);var t=Tr.getState(e);return null!==t&&!0===t.keySystemOptions.closeSessionsOnStop?(T.info("DRM: closing all current sessions."),t.loadedSessionsStore.closeAllSessions()):(T.info("DRM: Nothing to clear. Returning right away. No state =",null===t),Promise.resolve())}var _v=function(e){function t(t){var n;return(n=e.call(this)||this)._canceller=new Z,n._adaptationRef=t,n._updateToken=!1,n.refresh=S,n}f(t,e);var n=t.prototype;return n.start=function(e){if(this._updateToken=!0,null===e)return this._lastEmitted=null,this._updateToken=!1,void this._adaptationRef.setValue(null);var t=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:e.adaptation,switchingMode:e.switchingMode,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:e.adaptation.id,switchingMode:e.switchingMode,representations:t,relativeResumingPosition:void 0}))},n.updateTrack=function(e){if(this._updateToken=!0,null===e){if(null===this._lastEmitted)return;return this._updateToken=!1,this._canceller.cancel(),this._canceller=new Z,this._lastEmitted=null,void this._adaptationRef.setValue(null)}var t=e.adaptation,n=e.switchingMode,r=e.relativeResumingPosition;this._canceller.cancel(),this._canceller=new Z;var i=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:t,switchingMode:n,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:t.id,switchingMode:n,representations:i,relativeResumingPosition:r}))},n._constructLockedRepresentationsReference=function(e){var t=new G({representationIds:[],switchingMode:"lazy"}),n=this;return this.refresh=r,this._canceller.signal.register((function(){n.refresh=S})),e.lockedRepresentations.onUpdate(r,{clearSignal:this._canceller.signal,emitCurrentValue:!1}),r(),t;function r(){var r,i,a=e.lockedRepresentations.getValue();if(null===a)i=e.adaptation.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})),r="lazy";else{var o=a.representationIds;if(r=a.switchingMode,0===(i=e.adaptation.representations.filter((function(e){return Ue(o,e.id)})).filter((function(e){return!0===e.isSupported&&!1!==e.decipherable}))).length)return void n.trigger("noPlayableLockedRepresentation",null)}if(i.length<=0)return e.adaptation.isSupported=!1,void n.trigger("noPlayableRepresentation",null);var s=t.getValue(),u=i.map((function(e){return e.id})).slice().sort();if(u.length===s.representationIds.length){for(var l=0;l<u.length;l++)if(s.representationIds[l]!==u[l])return void t.setValue({representationIds:u,switchingMode:r})}else t.setValue({representationIds:u,switchingMode:r})}},n.dispose=function(){this.removeEventListener(),this._canceller.cancel(),this._adaptationRef.finish()},t}(i);function bv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Sv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Sv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Sv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ev=function(e){function n(t){var n,r;return(n=e.call(this)||this)._storedPeriodInfo=[],n._isDisposed=!1,n._cachedPeriodInfo=new WeakMap,n._isTrickModeTrackEnabled=t.preferTrickModeTracks,n._defaultAudioTrackSwitchingMode=null!==(r=t.defaultAudioTrackSwitchingMode)&&void 0!==r?r:b.getCurrent().DEFAULT_AUDIO_TRACK_SWITCHING_MODE,n}f(n,e);var r=n.prototype;return r.getAvailablePeriods=function(){return this._storedPeriodInfo.reduce((function(e,t){return t.isPeriodAdvertised&&e.push(Iv(t.period)),e}),[])},r.onManifestUpdate=function(e){for(var t,n,r,i,a,o,s,u=this,l=b.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=e.periods,c=[],f=0,v=function(e){var i=u._storedPeriodInfo[e].period,a=d[f];if(void 0===a)for(var o=u._storedPeriodInfo.length-1;o>=e;o--)u._storedPeriodInfo[o].inManifest=!1,kv(u._storedPeriodInfo[o])&&u._removePeriodObject(o);else if(i===a){f++;var s=u._storedPeriodInfo[e].text.storedSettings;if(null!==s)if(!Ge(a,"text").some((function(e){return e.id===s.adaptation.id}))){T.warn("TS: Chosen text Adaptation not available anymore");var v=u._storedPeriodInfo[e];if(v.text.storedSettings=null,u.trigger("trackUpdate",{period:Iv(a),trackType:"text",reason:"missing"}),u._isDisposed)return{v:void 0};var h=Tv(u._storedPeriodInfo,v.period.id);void 0!==h&&null===h.text.storedSettings&&(null===(t=h.text.dispatcher)||void 0===t||t.updateTrack(null))}var m=u._storedPeriodInfo[e].video.storedSettings;if(null!==m){var g=Ge(a,"video");if(!g.some((function(e){return e.id===m.adaptation.id}))){T.warn("TS: Chosen video Adaptation not available anymore");var y,_=u._storedPeriodInfo[e];if(0===g.length)y=null;else{var b=g[0],S=wv(b,u._isTrickModeTrackEnabled),E=new G(null);y={adaptationBase:b,adaptation:S,switchingMode:l,lockedRepresentations:E}}if(_.video.storedSettings=y,u.trigger("trackUpdate",{period:Iv(a),trackType:"video",reason:"missing"}),u._isDisposed)return{v:void 0};var k=Tv(u._storedPeriodInfo,_.period.id);void 0!==k&&k.video.storedSettings===y&&(null===(n=k.video.dispatcher)||void 0===n||n.updateTrack(y))}}var w=u._storedPeriodInfo[e].audio.storedSettings;if(null!==w){var A=Ge(a,"audio");if(!A.some((function(e){return e.id===w.adaptation.id}))){T.warn("TS: Chosen audio Adaptation not available anymore");var I=u._storedPeriodInfo[e],R=0===A.length?null:{adaptation:A[0],switchingMode:u._defaultAudioTrackSwitchingMode,lockedRepresentations:new G(null)};if(I.audio.storedSettings=R,u.trigger("trackUpdate",{period:Iv(a),trackType:"audio",reason:"missing"}),u._isDisposed)return{v:void 0};var x=Tv(u._storedPeriodInfo,I.period.id);void 0!==x&&x.audio.storedSettings===R&&(null===(r=x.audio.dispatcher)||void 0===r||r.updateTrack(R))}}}else if(i.start<=a.start)u._storedPeriodInfo[e].inManifest=!1,kv(u._storedPeriodInfo[e])&&(u._removePeriodObject(e),e--);else{var C=Av(a,!0,u._isTrickModeTrackEnabled,u._defaultAudioTrackSwitchingMode);u._storedPeriodInfo.splice(e,0,C),c.push(C),f++}p=e},p=0;p<this._storedPeriodInfo.length;p++)if(s=v(p))return s.v;if(f<d.length){var h,m=d.slice(f).map((function(e){return Av(e,!0,u._isTrickModeTrackEnabled,u._defaultAudioTrackSwitchingMode)}));(h=this._storedPeriodInfo).push.apply(h,m),c.push.apply(c,m)}for(var g,y=bv(this._storedPeriodInfo);!(g=y()).done;){var _=g.value;null===(i=_.audio.dispatcher)||void 0===i||i.refresh(),null===(a=_.video.dispatcher)||void 0===a||a.refresh(),null===(o=_.text.dispatcher)||void 0===o||o.refresh()}},r.onDecipherabilityUpdates=function(){for(var e,t,n,r,i=bv(this._storedPeriodInfo);!(r=i()).done;){var a=r.value;null===(e=a.audio.dispatcher)||void 0===e||e.refresh(),null===(t=a.video.dispatcher)||void 0===t||t.refresh(),null===(n=a.text.dispatcher)||void 0===n||n.refresh()}},r.addTrackReference=function(e,n,r){var i=this,a=Tv(this._storedPeriodInfo,n.id);if(void 0===a){a=Av(n,!1,this._isTrickModeTrackEnabled,this._defaultAudioTrackSwitchingMode);for(var o=!1,s=0;s<this._storedPeriodInfo.length;s++)this._storedPeriodInfo[s].period.start>n.start&&(this._storedPeriodInfo.splice(s,0,a),o=!0);o||this._storedPeriodInfo.push(a)}if(a.isPeriodAdvertised||(a.isPeriodAdvertised=!0,this.trigger("newAvailablePeriods",[{id:n.id,start:n.start,end:n.end}]),!this._isDisposed))if(null===a[e].dispatcher){var u=a[e].storedSettings,l=new _v(r);a[e].dispatcher=l,l.addEventListener("noPlayableRepresentation",(function(){var r,a,o,s,u=ae(null!==(r=n.adaptations[e])&&void 0!==r?r:[],(function(e){return!1!==e.isSupported&&e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})).length>0}));if(void 0===u){var l=new Me("NO_PLAYABLE_REPRESENTATION","No "+e+" Representation can be played",{tracks:void 0});return i.trigger("error",l),void i.dispose()}var d=null===(a=Tv(i._storedPeriodInfo,n.id))||void 0===a?void 0:a[e];if(!t(d)){var c={adaptation:u,switchingMode:"audio"===e?i._defaultAudioTrackSwitchingMode:"reload",lockedRepresentations:new G(null)};d.storedSettings=c,i.trigger("trackUpdate",{period:Iv(n),trackType:e,reason:"no-playable-representation"}),i._isDisposed||t(d=null===(o=Tv(i._storedPeriodInfo,n.id))||void 0===o?void 0:o[e])||d.storedSettings!==c||null===(s=d.dispatcher)||void 0===s||s.updateTrack(c)}})),l.addEventListener("noPlayableLockedRepresentation",(function(){null==u||u.lockedRepresentations.setValue(null),i.trigger("brokenRepresentationsLock",{period:{id:n.id,start:n.start,end:n.end},trackType:e})})),l.start(u)}else T.error("TS: Subject already added for "+e+" and Period "+n.start)},r.removeTrackReference=function(e,t){var n=function(e,t){for(var n=0;n<e.length;n++){if(e[n].period.id===t.id)return n}}(this._storedPeriodInfo,t);if(void 0!==n){var r=this._storedPeriodInfo[n],i=r[e];null!==(null==i?void 0:i.dispatcher)?(i.dispatcher.dispose(),i.dispatcher=null,kv(r)&&this._removePeriodObject(n)):T.warn("TS: TrackDispatcher already removed for "+e+" and Period "+t.start)}else T.warn("TS: "+e+" not found for period",t.start)},r.getPeriodObjectFromPeriod=function(e){var t=Tv(this._storedPeriodInfo,e.id);return void 0===t&&void 0!==e?this._cachedPeriodInfo.get(e):t},r.getPeriodObjectFromId=function(e){return Tv(this._storedPeriodInfo,e)},r.disableVideoTrickModeTracks=function(){this._isTrickModeTrackEnabled&&(this._isTrickModeTrackEnabled=!1,this._resetVideoTrackChoices("trickmode-disabled"))},r.enableVideoTrickModeTracks=function(){this._isTrickModeTrackEnabled||(this._isTrickModeTrackEnabled=!0,this._resetVideoTrackChoices("trickmode-enabled"))},r.resetPeriodObjects=function(){for(var e,t,n,r=this._storedPeriodInfo.length-1;r>=0;r--){var i=this._storedPeriodInfo[r];null===(e=i.audio.dispatcher)||void 0===e||e.dispose(),i.audio.dispatcher=null,null===(t=i.video.dispatcher)||void 0===t||t.dispose(),i.video.dispatcher=null,null===(n=i.text.dispatcher)||void 0===n||n.dispose(),i.text.dispatcher=null,i.inManifest||this._removePeriodObject(r)}},r.isTrickModeEnabled=function(){return this._isTrickModeTrackEnabled},r.setAudioTrack=function(e){var t=e.periodRef,n=e.trackId,r=e.switchingMode,i=e.lockedRepresentations,a=e.relativeResumingPosition;return this._setAudioOrTextTrack({bufferType:"audio",periodRef:t,trackId:n,switchingMode:null!=r?r:this._defaultAudioTrackSwitchingMode,lockedRepresentations:i,relativeResumingPosition:a})},r.setTextTrack=function(e,t){return this._setAudioOrTextTrack({bufferType:"text",periodRef:e,trackId:t,switchingMode:"direct",lockedRepresentations:null,relativeResumingPosition:void 0})},r._setAudioOrTextTrack=function(e){var t,n,r=e.bufferType,i=e.periodRef,a=e.trackId,o=e.switchingMode,s=e.lockedRepresentations,u=e.relativeResumingPosition,l=i.period,d=ae(null!==(t=l.adaptations[r])&&void 0!==t?t:[],(function(e){var t=e.id;return!0===e.isSupported&&t===a}));if(void 0===d)throw new Error("Wanted "+r+" track not found.");var c,f=i[r];if(null===s)c=new G(null);else{var v=this._getRepresentationsToLock(d,s),p="audio"===r?this._defaultAudioTrackSwitchingMode:"direct";c=new G({representationIds:v,switchingMode:p})}var h={adaptation:d,switchingMode:o,lockedRepresentations:c,relativeResumingPosition:u};if(f.storedSettings=h,this.trigger("trackUpdate",{period:Iv(l),trackType:r,reason:"manual"}),!this._isDisposed){var m=Tv(this._storedPeriodInfo,l.id);void 0!==m&&m[r].storedSettings===h&&(null===(n=m[r].dispatcher)||void 0===n||n.updateTrack(h))}},r.setVideoTrack=function(e){var t,n,r=e.periodRef,i=e.trackId,a=e.switchingMode,o=e.lockedRepresentations,s=e.relativeResumingPosition,u=r.period,l=ae(null!==(t=u.adaptations.video)&&void 0!==t?t:[],(function(e){var t=e.id;return!0===e.isSupported&&t===i}));if(void 0===l)throw new Error("Wanted video track not found.");var d,c=b.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,f=r.video,v=wv(l,this._isTrickModeTrackEnabled);if(null===o)d=new G(null);else{var p=this._getRepresentationsToLock(l,o);d=new G({representationIds:p,switchingMode:c})}var h={adaptationBase:l,switchingMode:null!=a?a:c,adaptation:v,relativeResumingPosition:s,lockedRepresentations:d};if(f.storedSettings=h,this.trigger("trackUpdate",{period:Iv(u),trackType:"video",reason:"manual"}),!this._isDisposed){var m=Tv(this._storedPeriodInfo,u.id);void 0!==m&&m.video.storedSettings===h&&(null===(n=m.video.dispatcher)||void 0===n||n.updateTrack(h))}},r.disableTrack=function(e,t){var n,r,i=e[t];if(null!==i.storedSettings&&("text"!==t&&(null===(n=e[t].storedSettings)||void 0===n||n.lockedRepresentations.finish()),i.storedSettings=null,this.trigger("trackUpdate",{period:Iv(e.period),trackType:t,reason:"manual"}),!this._isDisposed)){var a=Tv(this._storedPeriodInfo,e.period.id);void 0!==a&&null===a[t].storedSettings&&(null===(r=a[t].dispatcher)||void 0===r||r.updateTrack(null))}},r.getChosenAudioTrack=function(e){return null===e.audio.storedSettings?null:Ye(e.audio.storedSettings.adaptation,!0)},r.getChosenTextTrack=function(e){return null===e.text.storedSettings?null:Qe(e.text.storedSettings.adaptation)},r.getChosenVideoTrack=function(e){return null===e.video.storedSettings?null:$e(e.video.storedSettings.adaptation,!0)},r.getAvailableAudioTracks=function(e){var t=e.audio.storedSettings,n=null!==t?t.adaptation.id:null;return Ge(e.period,"audio").map((function(e){var t=null!==n&&n===e.id;return m(Ye(e,!0),{active:t})}))},r.getAvailableTextTracks=function(e){var t=e.text.storedSettings,n=null!==t?t.adaptation.id:null;return Ge(e.period,"text").map((function(e){var t=null!==n&&n===e.id;return m(Qe(e),{active:t})}))},r.getAvailableVideoTracks=function(e){var t=e.video.storedSettings,n=null===t?void 0:t.adaptation.id;return Ge(e.period,"video").map((function(e){var t=null!==n&&n===e.id,r=$e(e,!0),i=void 0!==r.trickModeTracks?r.trickModeTracks.map((function(e){var t=null!==n&&n===e.id;return m(e,{active:t})})):[],a=m(r,{active:t});return void 0!==i&&(a.trickModeTracks=i),a}))},r.getLockedAudioRepresentations=function(e){var t=e.audio.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representationIds},r.getLockedVideoRepresentations=function(e){var t=e.video.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representationIds},r.lockAudioRepresentations=function(e,t){var n,r=e.audio.storedSettings;if(null!==r){var i=b.getCurrent().DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representationIds:a,switchingMode:o})}},r.lockVideoRepresentations=function(e,t){var n,r=e.video.storedSettings;if(null!==r){var i=b.getCurrent().DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representationIds:a,switchingMode:o})}},r.unlockAudioRepresentations=function(e){var t=e.audio.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.unlockVideoRepresentations=function(e){var t=e.video.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.dispose=function(){for(this._isDisposed=!0;;){var e=this._storedPeriodInfo.pop();if(void 0===e)return;e.isRemoved=!0}},r._resetVideoTrackChoices=function(e){for(var t,n=0;n<this._storedPeriodInfo.length;n++){var r=this._storedPeriodInfo[n];if(null!==r.video.storedSettings){var i=r.video.storedSettings.adaptationBase;if(null!==i){var a=wv(i,this._isTrickModeTrackEnabled);r.video.storedSettings.adaptationBase=i,r.video.storedSettings.adaptation=a}}}for(var o=this._storedPeriodInfo.slice(),s=0;s<o.length;s++){var u=o[s].period,l=o[s].video.storedSettings;if(this.trigger("trackUpdate",{period:Iv(u),trackType:"video",reason:e}),this._isDisposed)return;var d=Tv(this._storedPeriodInfo,u.id);void 0!==d&&d.video.storedSettings===l&&(null===(t=d.video.dispatcher)||void 0===t||t.updateTrack(l))}},r._removePeriodObject=function(e){var t=this._storedPeriodInfo[e];this._storedPeriodInfo[e].isRemoved=!0,this._storedPeriodInfo.splice(e,1),this._cachedPeriodInfo.set(t.period,t)},r._getRepresentationsToLock=function(e,t){var n=t.reduce((function(t,n){var r=ae(e.representations,(function(e){return e.id===n}));return void 0===r?T.warn("API: Wanted locked Representation not found."):t.push(r.id),t}),[]);if(0===n.length)throw new Error("Cannot lock Representations: None of the given Representation id are found");return n},n}(i);function Tv(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.period.id===t)return r}}function kv(e){var t,n,r;return!e.inManifest&&null===(null===(t=e.text)||void 0===t?void 0:t.dispatcher)&&null===(null===(n=e.audio)||void 0===n?void 0:n.dispatcher)&&null===(null===(r=e.video)||void 0===r?void 0:r.dispatcher)}function wv(e,t){var n;return t&&void 0!==(null===(n=e.trickModeTracks)||void 0===n?void 0:n[0])?e.trickModeTracks[0]:e}function Av(e,t,n,r){var i,a,o=Ge(e,"audio")[0],s=Ge(e,"video")[0],u=wv(s,n),l=b.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=void 0!==o?{adaptation:o,switchingMode:r,lockedRepresentations:new G(null)}:null,c=void 0!==u?{adaptation:u,adaptationBase:s,switchingMode:l,lockedRepresentations:new G(null)}:null,f=null,v=(null!==(i=e.adaptations.text)&&void 0!==i?i:[]).filter((function(e){return!0===e.isForcedSubtitles}));if(v.length>0){if(null!=o){var p=ae(v,(function(e){return e.normalizedLanguage===o.normalizedLanguage}));void 0!==p&&(f=p)}null===f&&(f=null!==(a=ae(v,(function(e){return void 0===e.normalizedLanguage})))&&void 0!==a?a:null)}var h=null;return null!==f&&(h={adaptation:f,switchingMode:"direct",lockedRepresentations:new G(null)}),{period:e,inManifest:t,isPeriodAdvertised:!1,isRemoved:!1,audio:{storedSettings:d,dispatcher:null},video:{storedSettings:c,dispatcher:null},text:{storedSettings:h,dispatcher:null}}}function Iv(e){return{start:e.start,end:e.end,id:e.id}}var Rv=Ev;function xv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Cv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Cv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Mv(e,n){var r=b.getCurrent().FORCED_ENDED_THRESHOLD;if(e.ended)return"ENDED";if(null!==n){var i=Math.abs(e.duration-e.currentTime);return!t(r)&&i<r?"ENDED":"seeking"===n?"SEEKING":"freezing"===n?"FREEZING":"BUFFERING"}return e.paused?"PAUSED":"PLAYING"}function Pv(e){return"LOADING"!==e&&"RELOADING"!==e&&"STOPPED"!==e}function Dv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ov(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ov(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ov(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Nv=Le(),Lv=["manifestLoader","segmentLoader"],Uv=function(n){function r(e){var r;void 0===e&&(e={}),r=n.call(this)||this;var i=function(e){var n,r,i,a,o,s,u=b.getCurrent(),l=u.DEFAULT_BASE_BANDWIDTH,d=u.DEFAULT_VIDEO_RESOLUTION_LIMIT,c=u.DEFAULT_MAX_BUFFER_AHEAD,f=u.DEFAULT_MAX_BUFFER_BEHIND,v=u.DEFAULT_MAX_VIDEO_BUFFER_SIZE,p=u.DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN,h=u.DEFAULT_WANTED_BUFFER_AHEAD;if(t(e.maxBufferAhead))n=c;else if(n=Number(e.maxBufferAhead),isNaN(n))throw new Error("Invalid maxBufferAhead parameter. Should be a number.");if(t(e.maxBufferBehind))r=f;else if(r=Number(e.maxBufferBehind),isNaN(r))throw new Error("Invalid maxBufferBehind parameter. Should be a number.");if(t(e.wantedBufferAhead))i=h;else if(i=Number(e.wantedBufferAhead),isNaN(i))throw new Error("Invalid wantedBufferAhead parameter. Should be a number.");if(t(e.maxVideoBufferSize))a=v;else if(a=Number(e.maxVideoBufferSize),isNaN(a))throw new Error("Invalid maxVideoBufferSize parameter. Should be a number.");var m=t(e.videoResolutionLimit)?d:e.videoResolutionLimit,g=t(e.throttleVideoBitrateWhenHidden)?p:!!e.throttleVideoBitrateWhenHidden;if(t(e.videoElement))o=document.createElement("video");else{if(!(e.videoElement instanceof HTMLMediaElement))throw new Error("Invalid videoElement parameter. Should be a HTMLMediaElement.");o=e.videoElement}if(t(e.baseBandwidth))s=l;else if(s=Number(e.baseBandwidth),isNaN(s))throw new Error("Invalid baseBandwidth parameter. Should be a number.");return{maxBufferAhead:n,maxBufferBehind:r,videoResolutionLimit:m,videoElement:o,wantedBufferAhead:i,maxVideoBufferSize:a,throttleVideoBitrateWhenHidden:g,baseBandwidth:s}}(e),a=i.baseBandwidth,o=i.videoResolutionLimit,s=i.maxBufferAhead,u=i.maxBufferBehind,l=i.throttleVideoBitrateWhenHidden,d=i.videoElement,c=i.wantedBufferAhead,f=i.maxVideoBufferSize;d.preload="auto",r.version="4.0.0-dev.202402213",r.log=T,r.state="STOPPED",r.videoElement=d;var v=new Z;r._destroyCanceller=v,r._priv_pictureInPictureRef=function(e,t){var n=e;if(!0===n.webkitSupportsPresentationMode&&"function"==typeof n.webkitSetPresentationMode){var r="picture-in-picture"===n.webkitPresentationMode,i=new G({isEnabled:r,pipWindow:null},t);return $r(n,"webkitpresentationmodechanged",(function(){var e="picture-in-picture"===n.webkitPresentationMode;i.setValue({isEnabled:e,pipWindow:null})}),t),i}var a=document.pictureInPictureElement===n,o=new G({isEnabled:a,pipWindow:null},t);return $r(n,"enterpictureinpicture",(function(e){var t;o.setValue({isEnabled:!0,pipWindow:null!==(t=e.pictureInPictureWindow)&&void 0!==t?t:null})}),t),$r(n,"leavepictureinpicture",(function(){o.setValue({isEnabled:!1,pipWindow:null})}),t),o}(d,v.signal),r._priv_speed=new G(d.playbackRate,r._destroyCanceller.signal),r._priv_preferTrickModeTracks=!1,r._priv_contentLock=new G(!1,r._destroyCanceller.signal),r._priv_bufferOptions={wantedBufferAhead:new G(c,r._destroyCanceller.signal),maxBufferAhead:new G(s,r._destroyCanceller.signal),maxBufferBehind:new G(u,r._destroyCanceller.signal),maxVideoBufferSize:new G(f,r._destroyCanceller.signal)},r._priv_bitrateInfos={lastBitrates:{audio:a,video:a}},r._priv_throttleVideoBitrateWhenHidden=l,r._priv_videoResolutionLimit=o,r._priv_currentError=null,r._priv_contentInfos=null,r._priv_contentEventsMemory={},r._priv_reloadingMetadata={},r._priv_lastAutoPlay=!1,r._priv_worker=null;var p=function(){r.trigger("volumeChange",{volume:d.volume,muted:d.muted})};return d.addEventListener("volumechange",p),v.signal.register((function(){d.removeEventListener("volumechange",p)})),r}f(r,n),r.addFeatures=function(e){!function(e){for(var n=0;n<e.length;n++){var r=e[n];if("function"==typeof r)r(at);else{if(t(r)||"function"!=typeof r._addFeature)throw new Error("Unrecognized feature");r._addFeature(at)}}}(e)};var i=r.prototype;return i.attachWorker=function(t){var n=this;return new Promise((function(r,i){var a;if("function"!=typeof Worker)return T.warn("API: Cannot rely on a WebWorker: Worker API unavailable"),i(new uv("INCOMPATIBLE_ERROR","Worker unavailable"));if(!sv)return T.warn("API: Cannot rely on a WebWorker: WebAssembly unavailable"),i(new uv("INCOMPATIBLE_ERROR","WebAssembly unavailable"));if("string"==typeof t.workerUrl)n._priv_worker=new Worker(t.workerUrl);else{var o=URL.createObjectURL(t.workerUrl);n._priv_worker=new Worker(o),URL.revokeObjectURL(o)}n._priv_worker.onerror=function(e){null!==n._priv_worker&&(n._priv_worker.terminate(),n._priv_worker=null),T.error("API: Unexpected worker error",e.error instanceof Error?e.error:void 0),i(new uv("UNKNOWN_ERROR",'Unexpected Worker "error" event'))};n._priv_worker.addEventListener("message",(function e(t){var a=t.data;"init-error"===a.type?(T.warn("API: Processing InitError worker message: detaching worker"),null!==n._priv_worker&&(n._priv_worker.removeEventListener("message",e),n._priv_worker.terminate(),n._priv_worker=null),i(new uv("SETUP_ERROR","Worker parser initialization failed: "+a.value.errorMessage))):"init-success"===a.type&&(T.info("API: InitSuccess received from worker."),null!==n._priv_worker&&n._priv_worker.removeEventListener("message",e),r())})),T.debug("---\x3e Sending To Worker:","init"),n._priv_worker.postMessage({type:"init",value:{dashWasmUrl:t.dashWasmUrl,logLevel:T.getLevel(),sendBackLogs:e(),date:Date.now(),timestamp:ne(),hasVideo:"video"===(null===(a=n.videoElement)||void 0===a?void 0:a.nodeName.toLowerCase()),hasMseInWorker:ov}}),T.addEventListener("onLogLevelChange",(function(t){null!==n._priv_worker&&(T.debug("---\x3e Sending To Worker:","log-level-update"),n._priv_worker.postMessage({type:"log-level-update",value:{logLevel:t,sendBackLogs:e()}}))}),n._destroyCanceller.signal)}))},i.getCurrentModeInformation=function(){return null===this._priv_contentInfos?null:{isDirectFile:this._priv_contentInfos.isDirectFile,useWorker:this._priv_contentInfos.useWorker}},i.addEventListener=function(e,t){return n.prototype.addEventListener.call(this,e,t)},i.stop=function(){null!==this._priv_contentInfos&&this._priv_contentInfos.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),"STOPPED"!==this.state&&this._priv_setPlayerState("STOPPED")},i.dispose=function(){this.stop(),null!==this.videoElement&&mv(this.videoElement).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";T.error("API: Could not dispose decryption resources: "+t)})),this._destroyCanceller.cancel(),this._priv_reloadingMetadata={},this.videoElement=null,null!==this._priv_worker&&(this._priv_worker.terminate(),this._priv_worker=null)},i.loadVideo=function(e){var n=function(e){var n,r,i,a,o,s,u,l,d,c,f=b.getCurrent(),v=f.DEFAULT_AUTO_PLAY,p=f.DEFAULT_CODEC_SWITCHING_BEHAVIOR,h=f.DEFAULT_ENABLE_FAST_SWITCHING,g=f.DEFAULT_TEXT_TRACK_MODE;if(t(e))throw new Error("No option set on loadVideo");if(t(e.url)){if(t(e.initialManifest)&&t(e.manifestLoader))throw new Error("Unable to load a content: no url set on loadVideo.\nPlease provide at least either an `url` argument, a `initialManifest` option or a `manifestLoader` option so the RxPlayer can load the content.")}else a=String(e.url);if(t(e.transport))throw new Error("No transport set on loadVideo");o=String(e.transport);var y=t(e.autoPlay)?v:!!e.autoPlay;if(t(e.keySystems))s=[];else for(var _,S=xv(s=Array.isArray(e.keySystems)?e.keySystems:[e.keySystems]);!(_=S()).done;){var E=_.value;if("string"!=typeof E.type||"function"!=typeof E.getLicense)throw new Error("Invalid key system given: Missing type string or getLicense callback")}var k=void 0!==e.lowLatencyMode&&!!e.lowLatencyMode,w=e.initialManifest,A=null!==(n=e.minimumManifestUpdateInterval)&&void 0!==n?n:0,I=null!==(r=e.defaultAudioTrackSwitchingMode)&&void 0!==r?r:void 0;void 0===I||Ue(["seamless","direct","reload"],I)||(T.warn("The `defaultAudioTrackSwitchingMode` loadVideo option must match one of the following strategy name:\n- `seamless`\n- `direct`\n- `reload`"),I=void 0);var R=t(e.onCodecSwitch)?p:e.onCodecSwitch;if(Ue(["continue","reload"],R)||(T.warn("The `onCodecSwitch` loadVideo option must match one of the following string:\n- `continue`\n- `reload`\nIf badly set, "+p+" will be used as default"),R=p),t(e.textTrackMode))u=g;else{if("native"!==e.textTrackMode&&"html"!==e.textTrackMode)throw new Error("Invalid textTrackMode.");u=e.textTrackMode}if("html"===u){if(t(e.textTrackElement))throw new Error('You have to provide a textTrackElement in "html" textTrackMode.');if(!(e.textTrackElement instanceof HTMLElement))throw new Error("textTrackElement should be an HTMLElement.");d=e.textTrackElement}else t(e.textTrackElement)||T.warn('API: You have set a textTrackElement without being in an "html" textTrackMode. It will be ignored.');if(t(e.mode))l="auto";else{if(!Ue(["auto","multithread","main"],e.mode))throw new Error("Invalid `mode` option.");l=e.mode}var x=t(e.enableFastSwitching)?h:e.enableFastSwitching;if(!t(e.startAt))if("wallClockTime"in e.startAt&&e.startAt.wallClockTime instanceof Date){var C=e.startAt.wallClockTime.getTime()/1e3;c=m({},e.startAt,{wallClockTime:C})}else c=e.startAt;var M=null!==(i=e.requestConfig)&&void 0!==i?i:{};return{__priv_patchLastSegmentInSidx:e.__priv_patchLastSegmentInSidx,__priv_manifestUpdateUrl:e.__priv_manifestUpdateUrl,checkMediaSegmentIntegrity:e.checkMediaSegmentIntegrity,autoPlay:y,defaultAudioTrackSwitchingMode:I,enableFastSwitching:x,initialManifest:w,keySystems:s,lowLatencyMode:k,manifestLoader:e.manifestLoader,minimumManifestUpdateInterval:A,requestConfig:M,onCodecSwitch:R,referenceDateTime:e.referenceDateTime,representationFilter:e.representationFilter,segmentLoader:e.segmentLoader,serverSyncInfos:e.serverSyncInfos,startAt:c,textTrackElement:d,textTrackMode:u,transport:o,mode:l,url:a}}(e);T.info("API: Calling loadvideo",n.url,n.transport),this._priv_reloadingMetadata={options:n},this._priv_initializeContentPlayback(n),this._priv_lastAutoPlay=n.autoPlay},i.reload=function(e){var t,n,r,i,a,o,s=this._priv_reloadingMetadata,u=s.options,l=s.manifest,d=s.reloadPosition,c=s.reloadInPause;if(void 0===u)throw new Error("API: Can't reload without having previously loaded a content.");if(function(e){var t,n,r,i;if(null===e||"object"!=typeof e&&void 0!==e)throw new Error("API: reload - Invalid options format.");if(null===(null==e?void 0:e.reloadAt)||"object"!=typeof(null==e?void 0:e.reloadAt)&&void 0!==(null==e?void 0:e.reloadAt))throw new Error("API: reload - Invalid 'reloadAt' option format.");if("number"!=typeof(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position)&&void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.position))throw new Error("API: reload - Invalid 'reloadAt.position' option format.");if("number"!=typeof(null===(r=null==e?void 0:e.reloadAt)||void 0===r?void 0:r.relative)&&void 0!==(null===(i=null==e?void 0:e.reloadAt)||void 0===i?void 0:i.relative))throw new Error("API: reload - Invalid 'reloadAt.relative' option format.");if(!Array.isArray(null==e?void 0:e.keySystems)&&void 0!==(null==e?void 0:e.keySystems))throw new Error("API: reload - Invalid 'keySystems' option format.");if(void 0!==(null==e?void 0:e.autoPlay)&&"boolean"!=typeof e.autoPlay)throw new Error("API: reload - Invalid 'autoPlay' option format.")}(e),void 0!==(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position))i={position:e.reloadAt.position};else if(void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.relative)){if(void 0===d)throw new Error("Can't reload to a relative position when previous content was not loaded.");i={position:e.reloadAt.relative+d}}else void 0!==d&&(i={position:d});void 0!==(null==e?void 0:e.autoPlay)?a=e.autoPlay:void 0!==c&&(a=!c),void 0!==(null==e?void 0:e.keySystems)?o=e.keySystems:void 0!==(null===(r=this._priv_reloadingMetadata.options)||void 0===r?void 0:r.keySystems)&&(o=this._priv_reloadingMetadata.options.keySystems);var f=Object.assign(Object.assign({},u),{initialManifest:l});void 0!==i&&(f.startAt=i),void 0!==a&&(f.autoPlay=a),void 0!==o&&(f.keySystems=o),this._priv_initializeContentPlayback(f)},i.createDebugElement=function(e){if(null===ot.createDebugElement)throw new Error("Feature `DEBUG_ELEMENT` not added to the RxPlayer");var t=new Z;return ot.createDebugElement(e,this,t.signal),{dispose:function(){t.cancel()}}},i._priv_initializeContentPlayback=function(e){var n,r,i,a,o,s,u=this,l=e.autoPlay,d=e.defaultAudioTrackSwitchingMode,c=e.enableFastSwitching,f=e.initialManifest,v=e.keySystems,p=e.lowLatencyMode,h=e.minimumManifestUpdateInterval,g=e.requestConfig,y=e.onCodecSwitch,_=e.startAt,b=e.transport,S=e.checkMediaSegmentIntegrity,E=e.manifestLoader,k=e.referenceDateTime,w=e.segmentLoader,A=e.serverSyncInfos,I=e.mode,R=e.__priv_manifestUpdateUrl,x=e.__priv_patchLastSegmentInSidx,C=e.url;if(null===this.videoElement)throw new Error("the attached video element is disposed");var M,P,D="directfile"===b,O=new Z,N=this.videoElement,L=!1,U=null;if(D){if(null===ot.directfile)throw this.stop(),this._priv_currentError=null,new Error("DirectFile feature not activated in your build.");if(t(C))throw new Error("No URL for a DirectFile content");if(T.info("API: Initializing DirectFile mode in the main thread"),U=this._priv_initializeMediaElementTracksStore(O.signal),O.isUsed())return;M=new ot.directfile.initDirectFile({autoPlay:l,keySystems:v,speed:this._priv_speed,startAt:_,url:C})}else{var F={lowLatencyMode:p,maxRetry:null===(n=g.manifest)||void 0===n?void 0:n.maxRetry,requestTimeout:null===(r=g.manifest)||void 0===r?void 0:r.timeout,connectionTimeout:null===(i=g.manifest)||void 0===i?void 0:i.connectionTimeout,minimumManifestUpdateInterval:h,initialManifest:f},B=iv(),z={throttleBitrate:{},limitResolution:{}};this._priv_throttleVideoBitrateWhenHidden&&(B?z.throttleBitrate={video:W(Nr(this._priv_pictureInPictureRef,O.signal),(function(e){return e?1/0:0}),O.signal)}:T.warn("API: Can't apply throttleVideoBitrateWhenHidden because browser can't be trusted for visibility.")),"videoElement"===this._priv_videoResolutionLimit?B?z.limitResolution={video:Ur(N,this._priv_pictureInPictureRef,O.signal)}:T.warn("API: Can't apply videoResolutionLimit because browser can't be trusted for video size."):"screen"===this._priv_videoResolutionLimit&&(z.limitResolution={video:Lr(O.signal)});var V={initialBitrates:this._priv_bitrateInfos.lastBitrates,lowLatencyMode:p,throttlers:z},K="native"===e.textTrackMode?{textTrackMode:"native"}:{textTrackMode:"html",textTrackElement:e.textTrackElement},j=m({enableFastSwitching:c,onCodecSwitch:y},this._priv_bufferOptions),H={lowLatencyMode:p,maxRetry:null===(a=g.segment)||void 0===a?void 0:a.maxRetry,requestTimeout:null===(o=g.segment)||void 0===o?void 0:o.timeout,connectionTimeout:null===(s=g.segment)||void 0===s?void 0:s.connectionTimeout},q=null!==ot.multithread&&null!==this._priv_worker&&"dash"===b&&Lv.every((function(n){return t(e[n])}))&&"function"!=typeof e.representationFilter;if("main"===I||"auto"===I&&!q){if(null===ot.mainThreadMediaSourceInit)throw new Error("Cannot load video, neither in a WebWorker nor with the `MEDIA_SOURCE_MAIN` feature");var Y=ot.transports[b];if("function"!=typeof Y)throw this.stop(),this._priv_currentError=null,new Error('transport "'+b+'" not supported');var Q="string"==typeof e.representationFilter?(P=e.representationFilter,new Function("return ("+P+"(arguments[0], arguments[1]))")):e.representationFilter;T.info("API: Initializing MediaSource mode in the main thread");var X=Y({lowLatencyMode:p,checkMediaSegmentIntegrity:S,manifestLoader:E,referenceDateTime:k,representationFilter:Q,segmentLoader:w,serverSyncInfos:A,__priv_manifestUpdateUrl:R,__priv_patchLastSegmentInSidx:x});M=new ot.mainThreadMediaSourceInit({adaptiveOptions:V,autoPlay:l,bufferOptions:j,keySystems:v,lowLatencyMode:p,transport:X,manifestRequestSettings:F,segmentRequestOptions:H,speed:this._priv_speed,startAt:_,textTrackOptions:K,url:C})}else{if(null===ot.multithread)throw new Error("Cannot load video in multithread mode: `MULTI_THREAD` feature not imported.");if(null===this._priv_worker)throw new Error("Cannot load video in multithread mode: `attachWorker` method not called.");$(e.representationFilter),L=!0,T.info("API: Initializing MediaSource mode in a WebWorker");var J={lowLatencyMode:p,checkMediaSegmentIntegrity:S,referenceDateTime:k,serverSyncInfos:A,manifestLoader:void 0,segmentLoader:void 0,representationFilter:e.representationFilter,__priv_manifestUpdateUrl:R,__priv_patchLastSegmentInSidx:x};M=new ot.multithread.init({adaptiveOptions:V,autoPlay:l,bufferOptions:j,keySystems:v,lowLatencyMode:p,transportOptions:J,manifestRequestSettings:F,segmentRequestOptions:H,speed:this._priv_speed,startAt:_,textTrackOptions:K,worker:this._priv_worker,url:C})}}var ee={contentId:Nv(),originalUrl:C,currentContentCanceller:O,defaultAudioTrackSwitchingMode:d,initializer:M,isDirectFile:D,segmentSinksStore:null,manifest:null,currentPeriod:null,activeAdaptations:null,activeRepresentations:null,tracksStore:null,mediaElementTracksStore:U,useWorker:L};M.addEventListener("error",(function(e){u._priv_onFatalError(e,ee)})),M.addEventListener("warning",(function(e){var t=Ne(e,{defaultCode:"NONE",defaultReason:"An unknown error happened."});T.warn("API: Sending warning:",t),u.trigger("warning",t)})),M.addEventListener("reloadingMediaSource",(function(e){ee.segmentSinksStore=null,null!==ee.tracksStore&&ee.tracksStore.resetPeriodObjects(),u._priv_lastAutoPlay=e.autoPlay})),M.addEventListener("inbandEvents",(function(e){return u.trigger("inbandEvents",e)})),M.addEventListener("streamEvent",(function(e){return u.trigger("streamEvent",e)})),M.addEventListener("streamEventSkip",(function(e){return u.trigger("streamEventSkip",e)})),M.addEventListener("activePeriodChanged",(function(e){return u._priv_onActivePeriodChanged(ee,e)})),M.addEventListener("periodStreamReady",(function(e){return u._priv_onPeriodStreamReady(ee,e)})),M.addEventListener("periodStreamCleared",(function(e){return u._priv_onPeriodStreamCleared(ee,e)})),M.addEventListener("representationChange",(function(e){return u._priv_onRepresentationChange(ee,e)})),M.addEventListener("adaptationChange",(function(e){return u._priv_onAdaptationChange(ee,e)})),M.addEventListener("bitrateEstimateChange",(function(e){return u._priv_onBitrateEstimateChange(e)})),M.addEventListener("manifestReady",(function(e){return u._priv_onManifestReady(ee,e)})),M.addEventListener("manifestUpdate",(function(e){return u._priv_onManifestUpdate(ee,e)})),M.addEventListener("decipherabilityUpdate",(function(e){return u._priv_onDecipherabilityUpdate(ee,e)})),M.addEventListener("loaded",(function(e){ee.segmentSinksStore=e.segmentSinksStore})),M.prepare(),this.stop();var te=new vv(N,{withMediaSource:!D,lowLatencyMode:p});O.signal.register((function(){te.stop()}));var ne=function(e,t,n,r){var i=new G("LOADING",r);e.addEventListener("loaded",(function(){if("LOADING"===i.getValue()){if(i.setValue("LOADED"),!r.isCancelled()){var e=Mv(t,null);"PAUSED"!==e&&i.setValue(e)}}else"RELOADING"===i.getValue()?i.setValue(Mv(t,null)):o(null)}),r),e.addEventListener("reloadingMediaSource",(function(){Pv(i.getValue())&&i.setValueIfChanged("RELOADING")}),r);var a=null;return e.addEventListener("stalled",(function(e){e!==a&&(o(e),a=e)}),r),e.addEventListener("unstalled",(function(){null!==a&&(o(null),a=null)}),r),n.listen((function(e){Ue(["seeking","ended","play","pause"],e.event)&&o(a)}),{clearSignal:r}),i;function o(e){if(Pv(i.getValue())){var n=Mv(t,e);"LOADED"===i.getValue()&&"PAUSED"===n||i.setValueIfChanged(n)}}}(M,N,te,O.signal);O.signal.register((function(){M.dispose()}));var re=function(e){switch(e){case"STOPPED":case"RELOADING":case"LOADING":break;case"ENDED":u._priv_reloadingMetadata.reloadInPause=!0,u._priv_reloadingMetadata.reloadPosition=te.getReference().getValue().position.getPolled();break;default:var t=te.getReference().getValue();u._priv_reloadingMetadata.reloadInPause=t.paused,u._priv_reloadingMetadata.reloadPosition=t.position.getWanted()}},ie=null,ae=function(e){null!==ie&&(ie.cancel(),ie=null),ne.onUpdate((function(t,n){var r,i,a,o;Pv(t)&&(n(),null!==ie&&ie.cancel(),(ie=new Z).linkToSignal(O.signal),e!==!N.paused&&(N.paused?u.trigger("pause",null):u.trigger("play",null)),r=N,i=function(){return u.trigger("play",null)},a=function(){return u.trigger("pause",null)},(o=O.signal).isCancelled()||null===r||(r.addEventListener("play",i),r.addEventListener("pause",a),o.register((function(){r.removeEventListener("play",i),r.removeEventListener("pause",a)}))))}),{emitCurrentValue:!1,clearSignal:O.signal})};ae(l),M.addEventListener("reloadingMediaSource",(function(e){ae(e.autoPlay)})),this._priv_currentError=null,this._priv_contentInfos=ee;var oe=null;ne.onUpdate((function(e){re(e),u._priv_setPlayerState(e),O.isUsed()||(null!==oe?Pv(u.state)||(oe.cancel(),oe=null):Pv(u.state)&&((oe=new Z).linkToSignal(O.signal),function(e,t,n,r,i){if(!i.isCancelled()&&null!==e){var a=2===t.getReference().getValue().seeking;a&&(n(),i.isCancelled())||t.listen((function(e){"seeking"===e.event?(a=!0,n()):a&&"seeked"===e.event&&(a=!1,r())}),{includeLastObservation:!0,clearSignal:i})}}(N,te,(function(){return u.trigger("seeking",null)}),(function(){return u.trigger("seeked",null)}),oe.signal)))}),{emitCurrentValue:!0,clearSignal:O.signal}),te.listen((function(e){re(u.state),u._priv_triggerPositionUpdate(ee,e)}),{clearSignal:O.signal}),O.signal.register((function(){M.removeEventListener()})),this._priv_contentLock.onUpdate((function(e,t){e||(t(),M.start(N,te))}),{emitCurrentValue:!0,clearSignal:O.signal})},i.getError=function(){return this._priv_currentError},i.getVideoElement=function(){return this.videoElement},i.getPlayerState=function(){return this.state},i.isContentLoaded=function(){return!Ue(["LOADING","RELOADING","STOPPED"],this.state)},i.isBuffering=function(){return Ue(["BUFFERING","SEEKING","LOADING","RELOADING"],this.state)},i.isPaused=function(){return!this.videoElement||(Ue(["LOADING","RELOADING"],this.state)?!this._priv_lastAutoPlay:this.videoElement.paused)},i.isLive=function(){if(null===this._priv_contentInfos)return!1;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return!t&&null!==n&&n.isLive},i.areTrickModeTracksEnabled=function(){return this._priv_preferTrickModeTracks},i.getContentUrls=function(){if(null!==this._priv_contentInfos){var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest,r=e.originalUrl;return t?void 0===r?void 0:[r]:null!==n?n.uris:void 0}},i.updateContentUrls=function(e,t){if(null===this._priv_contentInfos)throw new Error("No content loaded");var n=!0===(null==t?void 0:t.refresh);this._priv_contentInfos.initializer.updateContentUrls(e,n)},i.getMediaDuration=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration},i.getCurrentBufferGap=function(){if(null===this.videoElement)throw new Error("Disposed player");var e,t,n,r=this.videoElement,i=(e=r.buffered,t=r.currentTime,null!==(n=P(e,t))?n.end-t:1/0);return i===1/0?0:i},i.getWallClockTime=function(){if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)return this.videoElement.currentTime;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){var r=av(this.videoElement);return(null!=r?r:0)+this.videoElement.currentTime}return null!==n?this.videoElement.currentTime+(void 0!==n.availabilityStartTime?n.availabilityStartTime:0):0},i.getPosition=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.currentTime},i.getLastStoredContentPosition=function(){return this._priv_reloadingMetadata.reloadPosition},i.getPlaybackRate=function(){return this._priv_speed.getValue()},i.setPlaybackRate=function(e,n){var r;e!==this._priv_speed.getValue()&&this._priv_speed.setValue(e);var i=null==n?void 0:n.preferTrickModeTracks;if("boolean"==typeof i){this._priv_preferTrickModeTracks=i;var a=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.tracksStore;t(a)||(i&&!a.isTrickModeEnabled()?a.enableVideoTrickModeTracks():!i&&a.isTrickModeEnabled()&&a.disableVideoTrickModeTracks())}},i.getVideoRepresentation=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e)return e.video},i.getAudioRepresentation=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e)return e.audio},i.play=function(){var e=this;if(null===this.videoElement)throw new Error("Disposed player");var n=this.videoElement.play();return t(n)||"function"!=typeof n.catch?Promise.resolve():n.catch((function(t){if("NotAllowedError"===t.name){var n=new Me("MEDIA_ERR_PLAY_NOT_ALLOWED",t.toString());e.trigger("warning",n)}throw t}))},i.pause=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.pause()},i.seekTo=function(e){var n;if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)throw new Error("player: no content loaded");var r,i=this._priv_contentInfos,a=i.isDirectFile,o=i.manifest;if(!a&&null===o)throw new Error("player: the content did not load yet");if("number"==typeof e)r=e;else if("object"==typeof e){var s=e,u=this.videoElement.currentTime;if(t(s.relative))if(t(s.position)){if(t(s.wallClockTime))throw new Error('invalid time object. You must set one of the following properties: "relative", "position" or "wallClockTime"');if(null!==o)r=s.wallClockTime-(null!==(n=o.availabilityStartTime)&&void 0!==n?n:0);else if(a&&null!==this.videoElement){var l=av(this.videoElement);void 0!==l&&(r=s.wallClockTime-l)}void 0===r&&(r=s.wallClockTime)}else r=s.position;else r=u+s.relative}if(void 0===r)throw new Error("invalid time given");return T.info("API: API Seek to",r),this.videoElement.currentTime=r,r},i.getVolume=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.volume},i.setVolume=function(e){if(null===this.videoElement)throw new Error("Disposed player");var t=this.videoElement;e!==t.volume&&(t.volume=e)},i.isMute=function(){var e;return!0===(null===(e=this.videoElement)||void 0===e?void 0:e.muted)},i.mute=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.muted||(this.videoElement.muted=!0)},i.unMute=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.muted&&(this.videoElement.muted=!1)},i.setMaxBufferBehind=function(e){this._priv_bufferOptions.maxBufferBehind.setValue(e)},i.setMaxBufferAhead=function(e){this._priv_bufferOptions.maxBufferAhead.setValue(e)},i.setWantedBufferAhead=function(e){this._priv_bufferOptions.wantedBufferAhead.setValue(e)},i.setMaxVideoBufferSize=function(e){this._priv_bufferOptions.maxVideoBufferSize.setValue(e)},i.getMaxBufferBehind=function(){return this._priv_bufferOptions.maxBufferBehind.getValue()},i.getMaxBufferAhead=function(){return this._priv_bufferOptions.maxBufferAhead.getValue()},i.getWantedBufferAhead=function(){return this._priv_bufferOptions.wantedBufferAhead.getValue()},i.getMaxVideoBufferSize=function(){return this._priv_bufferOptions.maxVideoBufferSize.getValue()},i.getCurrentPeriod=function(){var e,n=null===(e=this._priv_contentInfos)||void 0===e?void 0:e.currentPeriod;return t(n)?null:{id:n.id,start:n.start,end:n.end}},i.getKeySystemConfiguration=function(){if(null===this.videoElement)throw new Error("Disposed player");var e=kr(this.videoElement);return null===e?null:{keySystem:e[0],configuration:e[1]}},i.getAvailablePeriods=function(){if(null===this._priv_contentInfos)return[];var e=this._priv_contentInfos,t=e.isDirectFile,n=e.tracksStore;return t||null===n?[]:n.getAvailablePeriods().slice()},i.getAvailableAudioTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableAudioTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableAudioTracks(t))&&void 0!==n?n:[]}))},i.getAvailableTextTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableTextTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableTextTracks(t))&&void 0!==n?n:[]}))},i.getAvailableVideoTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableVideoTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableVideoTracks(t))&&void 0!==n?n:[]}))},i.getAudioTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenAudioTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenAudioTrack(t)}))}},i.getTextTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenTextTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenTextTrack(t)}))}},i.getVideoTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenVideoTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenVideoTrack(t)}))}},i.setAudioTrack=function(e){var t;if(null===this._priv_contentInfos)throw new Error("No content loaded");var n,r,i,a=this._priv_contentInfos,o=a.isDirectFile,s=a.mediaElementTracksStore;if(o)try{var u="string"==typeof e?e:e.trackId;return void(null==s||s.setAudioTrackById(u))}catch(e){throw new Error("player: unknown audio track")}var l,d=null;return"string"==typeof e?r=e:(r=e.trackId,n=e.periodId,i=e.switchingMode,d=null!==(t=e.lockedRepresentations)&&void 0!==t?t:null,l=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,t){return e.setAudioTrack({periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:d,relativeResumingPosition:l})}))},i.setTextTrack=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r=this._priv_contentInfos,i=r.isDirectFile,a=r.mediaElementTracksStore;if(i)try{var o="string"==typeof e?e:e.trackId;return void(null==a||a.setTextTrackById(o))}catch(e){throw new Error("player: unknown text track")}return"string"==typeof e?n=e:(n=e.trackId,t=e.periodId),this._priv_callTracksStoreGetterSetter(t,void 0,(function(e,t){return e.setTextTrack(t,n)}))},i.disableTextTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(!n)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.disableTrack(t,"text")}));null==r||r.disableTextTrack()}},i.setVideoTrack=function(e){var t;if(null===this._priv_contentInfos)throw new Error("No content loaded");var n,r,i,a=this._priv_contentInfos,o=a.isDirectFile,s=a.mediaElementTracksStore;if(o)try{var u="string"==typeof e?e:e.trackId;return void(null==s||s.setVideoTrackById(u))}catch(e){throw new Error("player: unknown video track")}var l,d=null;return"string"==typeof e?r=e:(r=e.trackId,n=e.periodId,i=e.switchingMode,d=null!==(t=e.lockedRepresentations)&&void 0!==t?t:null,l=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,t){return e.setVideoTrack({periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:d,relativeResumingPosition:l})}))},i.disableVideoTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;return n&&null!==r?r.disableVideoTrack():this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.disableTrack(t,"video")}))}},i.lockVideoRepresentations=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r;if(this._priv_contentInfos.isDirectFile)throw new Error("Cannot lock video Representations in directfile mode.");return Array.isArray(e)?(t=e,n=void 0):(t=e.representations,n=e.periodId,r=e.switchingMode),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,n){return e.lockVideoRepresentations(n,{representations:t,switchingMode:r})}))},i.lockAudioRepresentations=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r;if(this._priv_contentInfos.isDirectFile)throw new Error("Cannot lock audio Representations in directfile mode.");return Array.isArray(e)?(t=e,n=void 0):(t=e.representations,n=e.periodId,r=e.switchingMode),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,n){return e.lockAudioRepresentations(n,{representations:t,switchingMode:r})}))},i.getLockedVideoRepresentations=function(e){return null===this._priv_contentInfos||this._priv_contentInfos.isDirectFile?null:this._priv_callTracksStoreGetterSetter(e,null,(function(e,t){return e.getLockedVideoRepresentations(t)}))},i.getLockedAudioRepresentations=function(e){return null===this._priv_contentInfos||this._priv_contentInfos.isDirectFile?null:this._priv_callTracksStoreGetterSetter(e,null,(function(e,t){return e.getLockedAudioRepresentations(t)}))},i.unlockVideoRepresentations=function(e){if(null!==this._priv_contentInfos&&!this._priv_contentInfos.isDirectFile)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.unlockVideoRepresentations(t)}))},i.unlockAudioRepresentations=function(e){if(null!==this._priv_contentInfos&&!this._priv_contentInfos.isDirectFile)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.unlockAudioRepresentations(t)}))},i.getMinimumPosition=function(){if(null===this._priv_contentInfos)return null;if(this._priv_contentInfos.isDirectFile)return 0;var e=this._priv_contentInfos.manifest;return null!==e?Ve(e):null},i.getLivePosition=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return t?void 0:!0!==(null==n?void 0:n.isLive)?null:Ke(n)},i.getMaximumPosition=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration}return null!==n?n.isDynamic||null===this.videoElement?We(n):this.videoElement.duration:null},i.__priv_getSegmentSinkContent=function(e){if(null===this._priv_contentInfos||null===this._priv_contentInfos.segmentSinksStore)return null;var t=this._priv_contentInfos.segmentSinksStore.getStatus(e);return"initialized"===t.type?t.value.getLastKnownInventory():null},i.__priv_getManifest=function(){return null===this._priv_contentInfos?null:this._priv_contentInfos.manifest},i.__priv_getCurrentAdaptation=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,n=e.currentPeriod,r=e.activeAdaptations;return null===n||null===r||t(r[n.id])?null:r[n.id]},i.__priv_getCurrentRepresentations=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,n=e.currentPeriod,r=e.activeRepresentations;return null===n||null===r||t(r[n.id])?null:r[n.id]},i._priv_cleanUpCurrentContentState=function(){var e,n,r,i,a=this;T.debug("Locking `contentLock` to clean-up the current content."),this._priv_contentLock.setValue(!0),null===(n=null===(e=this._priv_contentInfos)||void 0===e?void 0:e.tracksStore)||void 0===n||n.dispose(),null===(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.mediaElementTracksStore)||void 0===i||i.dispose(),this._priv_contentInfos=null,this._priv_contentEventsMemory={};var o=function(){null!==a.videoElement&&(T.debug("Unlocking `contentLock`. Next content can begin."),a._priv_contentLock.setValue(!1))};t(this.videoElement)?o():yv(this.videoElement).then((function(){T.debug("API: DRM session cleaned-up with success!"),o()}),(function(e){T.error("API: An error arised when trying to clean-up the DRM session:"+(e instanceof Error?e.toString():"Unknown Error")),o()}))},i._priv_onManifestReady=function(e,t){var n,r=this;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){e.manifest=t,0===t.manifestFormat&&(this._priv_reloadingMetadata.manifest=t);var i=new Rv({preferTrickModeTracks:this._priv_preferTrickModeTracks,defaultAudioTrackSwitchingMode:e.defaultAudioTrackSwitchingMode});e.tracksStore=i,i.addEventListener("newAvailablePeriods",(function(e){r.trigger("newAvailablePeriods",e)})),i.addEventListener("brokenRepresentationsLock",(function(e){r.trigger("brokenRepresentationsLock",e)})),i.addEventListener("trackUpdate",(function(e){var t,n;r.trigger("trackUpdate",e);var i=null!==(n=null===(t=r._priv_contentInfos)||void 0===t?void 0:t.currentPeriod)&&void 0!==n?n:void 0;"no-playable-representation"===e.reason&&e.period.id===(null==i?void 0:i.id)&&r._priv_onAvailableTracksMayHaveChanged(e.trackType)})),e.tracksStore.addEventListener("warning",(function(e){r.trigger("warning",e)})),e.tracksStore.addEventListener("error",(function(t){r._priv_onFatalError(t,e)})),e.tracksStore.onManifestUpdate(t)}},i._priv_onManifestUpdate=function(e,n){var r,i,a;if(null!==this._priv_contentInfos&&null!==this._priv_contentInfos.manifest){t(null==e?void 0:e.tracksStore)||e.tracksStore.onManifestUpdate(this._priv_contentInfos.manifest);var o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,s=null===(a=this._priv_contentInfos)||void 0===a?void 0:a.tracksStore;if(void 0!==o&&!t(s))for(var u,l=Dv(n.updatedPeriods);!(u=l()).done;){var d=u.value;if(d.period.id===o.id&&(d.result.addedAdaptations.length>0||d.result.removedAdaptations.length>0)){if(void 0===s.getPeriodObjectFromPeriod(o))return;this._priv_onAvailableTracksMayHaveChanged("audio"),this._priv_onAvailableTracksMayHaveChanged("text"),this._priv_onAvailableTracksMayHaveChanged("video")}}}},i._priv_onDecipherabilityUpdate=function(e,n){if(null!==e&&null!==e.manifest){t(null==e?void 0:e.tracksStore)||e.tracksStore.onDecipherabilityUpdates();for(var r,i=n.reduce((function(t,n){var r,i,a;if(!(void 0!==ae(t,(function(e){return e[0].id===n.period.id&&e[1]===n.adaptation.type})))){var o=e.tracksStore;if(null===o)return t;var s=!1,u=o.getPeriodObjectFromPeriod(n.period);if(void 0===u)return t;switch(n.adaptation.type){case"audio":s=(null===(r=o.getChosenAudioTrack(u))||void 0===r?void 0:r.id)===n.adaptation.id;break;case"video":s=(null===(i=o.getChosenVideoTrack(u))||void 0===i?void 0:i.id)===n.adaptation.id;break;case"text":s=(null===(a=o.getChosenTextTrack(u))||void 0===a?void 0:a.id)===n.adaptation.id}s&&t.push([n.period,n.adaptation.type])}return t}),[]),a=Dv(i);!(r=a()).done;){var o=r.value,s=o[0],u=o[1];this._priv_triggerEventIfNotStopped("representationListUpdate",{period:{start:s.start,end:s.end,id:s.id},trackType:u,reason:"decipherability-update"},e.currentContentCanceller.signal)}}},i._priv_onActivePeriodChanged=function(e,n){var r,i,a,o,s,u,l=n.period;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){e.currentPeriod=l;var d=e.currentContentCanceller.signal;this._priv_contentEventsMemory.periodChange!==l&&(this._priv_contentEventsMemory.periodChange=l,this._priv_triggerEventIfNotStopped("periodChange",{start:l.start,end:l.end,id:l.id},d)),this._priv_triggerEventIfNotStopped("availableAudioTracksChange",this.getAvailableAudioTracks(),d),this._priv_triggerEventIfNotStopped("availableTextTracksChange",this.getAvailableTextTracks(),d),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",this.getAvailableVideoTracks(),d);var c=null===(i=this._priv_contentInfos)||void 0===i?void 0:i.tracksStore;if(t(c))this._priv_triggerEventIfNotStopped("audioTrackChange",null,d),this._priv_triggerEventIfNotStopped("textTrackChange",null,d),this._priv_triggerEventIfNotStopped("videoTrackChange",null,d);else{var f=c.getPeriodObjectFromPeriod(l);if(f){var v=c.getChosenAudioTrack(f);this._priv_triggerEventIfNotStopped("audioTrackChange",v,d);var p=c.getChosenTextTrack(f);this._priv_triggerEventIfNotStopped("textTrackChange",p,d);var h=c.getChosenVideoTrack(f);this._priv_triggerEventIfNotStopped("videoTrackChange",h,d)}}var m=null!==(o=null===(a=this.__priv_getCurrentRepresentations())||void 0===a?void 0:a.audio)&&void 0!==o?o:null;this._priv_triggerEventIfNotStopped("audioRepresentationChange",m,d);var g=null!==(u=null===(s=this.__priv_getCurrentRepresentations())||void 0===s?void 0:s.video)&&void 0!==u?u:null;this._priv_triggerEventIfNotStopped("videoRepresentationChange",g,d)}},i._priv_onPeriodStreamReady=function(e,n){var r;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var i=n.type,a=n.period,o=n.adaptationRef,s=e.tracksStore;switch(i){case"video":case"audio":case"text":t(s)?(T.error("API: TracksStore not instanciated for a new "+i+" period"),o.setValue(null)):s.addTrackReference(i,a,o);break;default:X()}}},i._priv_onPeriodStreamCleared=function(e,n){var r;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var i=n.type,a=n.period,o=e.tracksStore;switch(i){case"audio":case"text":case"video":t(o)||o.removeTrackReference(i,a)}var s=e.activeAdaptations,u=e.activeRepresentations;if(!t(s)&&!t(s[a.id])){var l=s[a.id];delete l[i],0===Object.keys(l).length&&delete s[a.id]}if(!t(u)&&!t(u[a.id])){var d=u[a.id];delete d[i],0===Object.keys(d).length&&delete u[a.id]}}},i._priv_onAdaptationChange=function(e,n){var r,i=n.type,a=n.adaptation,o=n.period;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){null===e.activeAdaptations&&(e.activeAdaptations={});var s,u=e.activeAdaptations,l=e.currentPeriod,d=u[o.id];if(t(d))u[o.id]=((s={})[i]=a,s);else d[i]=a;var c=e.tracksStore,f=e.currentContentCanceller.signal;if(null!==c&&null!==l&&!t(o)&&o.id===l.id){var v=c.getPeriodObjectFromPeriod(o);if(void 0===v)return;switch(i){case"audio":var p=c.getChosenAudioTrack(v);this._priv_triggerEventIfNotStopped("audioTrackChange",p,f);break;case"text":var h=c.getChosenTextTrack(v);this._priv_triggerEventIfNotStopped("textTrackChange",h,f);break;case"video":var m=c.getChosenVideoTrack(v);this._priv_triggerEventIfNotStopped("videoTrackChange",m,f)}}}},i._priv_onRepresentationChange=function(e,n){var r,i=n.type,a=n.period,o=n.representation;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){null===e.activeRepresentations&&(e.activeRepresentations={});var s,u=e.activeRepresentations,l=e.currentPeriod,d=u[a.id];if(t(d))u[a.id]=((s={})[i]=o,s);else d[i]=o;if(!t(a)&&null!==l&&l.id===a.id){var c=this._priv_contentInfos.currentContentCanceller.signal;"video"===i?this._priv_triggerEventIfNotStopped("videoRepresentationChange",o,c):"audio"===i&&this._priv_triggerEventIfNotStopped("audioRepresentationChange",o,c)}}},i._priv_onBitrateEstimateChange=function(e){var t=e.type,n=e.bitrate;void 0!==n&&(this._priv_bitrateInfos.lastBitrates[t]=n),this.trigger("__priv_bitrateEstimateChange",{type:t,bitrate:n})},i._priv_setPlayerState=function(e){this.state!==e&&(this.state=e,T.info("API: playerStateChange event",e),this.trigger("playerStateChange",e))},i._priv_triggerPositionUpdate=function(e,n){var r,i;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var a=e.isDirectFile,o=e.manifest;if((a||null!==o)&&!t(n)){var s=null!==o?We(o):void 0,u={position:n.position.getPolled(),duration:n.duration,playbackRate:n.playbackRate,maximumPosition:s,bufferGap:void 0!==n.bufferGap&&isFinite(n.bufferGap)?n.bufferGap:0};if(null!==o&&o.isLive&&n.position.getPolled()>0){var l=null!==(i=o.availabilityStartTime)&&void 0!==i?i:0;u.wallClockTime=n.position.getPolled()+l;var d=Ke(o);void 0!==d&&(u.liveGap=d-n.position.getPolled())}else if(a&&null!==this.videoElement){var c=av(this.videoElement);void 0!==c&&(u.wallClockTime=c+n.position.getPolled())}this.trigger("positionUpdate",u)}}},i._priv_triggerEventIfNotStopped=function(e,t,n){n.isCancelled()||this.trigger(e,t)},i._priv_initializeMediaElementTracksStore=function(e){var t,n,r,i=this;$(ot.directfile),$(this.videoElement);var a=new ot.directfile.mediaElementTracksStore(this.videoElement);return this._priv_triggerEventIfNotStopped("availableAudioTracksChange",a.getAvailableAudioTracks(),e),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",a.getAvailableVideoTracks(),e),this._priv_triggerEventIfNotStopped("availableTextTracksChange",a.getAvailableTextTracks(),e),this._priv_triggerEventIfNotStopped("audioTrackChange",null!==(t=a.getChosenAudioTrack())&&void 0!==t?t:null,e),this._priv_triggerEventIfNotStopped("textTrackChange",null!==(n=a.getChosenTextTrack())&&void 0!==n?n:null,e),this._priv_triggerEventIfNotStopped("videoTrackChange",null!==(r=a.getChosenVideoTrack())&&void 0!==r?r:null,e),a.addEventListener("availableVideoTracksChange",(function(e){return i.trigger("availableVideoTracksChange",e)})),a.addEventListener("availableAudioTracksChange",(function(e){return i.trigger("availableAudioTracksChange",e)})),a.addEventListener("availableTextTracksChange",(function(e){return i.trigger("availableTextTracksChange",e)})),a.addEventListener("audioTrackChange",(function(e){return i.trigger("audioTrackChange",e)})),a.addEventListener("videoTrackChange",(function(e){return i.trigger("videoTrackChange",e)})),a.addEventListener("textTrackChange",(function(e){return i.trigger("textTrackChange",e)})),a},i._priv_callTracksStoreGetterSetter=function(e,t,n){var r,i;if(null===this._priv_contentInfos||null===this._priv_contentInfos.tracksStore)return T.warn("API: Trying to call track API too soon"),t;var a=this._priv_contentInfos.tracksStore,o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,s=null!=e?e:null==o?void 0:o.id;if(void 0===s)return t;var u=s===(null==o?void 0:o.id)?a.getPeriodObjectFromPeriod(o):a.getPeriodObjectFromId(s);return void 0===u?t:n(a,u)},i._priv_onAvailableTracksMayHaveChanged=function(e,n){var r=this._priv_contentInfos;if(null!==r){var i=r.currentPeriod,a=r.tracksStore,o=r.currentContentCanceller.signal;if(!t(i)&&null!==a){var s=null!=n?n:a.getPeriodObjectFromPeriod(i);if(void 0!==s)switch(e){case"video":var u=a.getAvailableVideoTracks(s);this._priv_triggerEventIfNotStopped("availableVideoTracksChange",null!=u?u:[],o);break;case"audio":var l=a.getAvailableAudioTracks(s);this._priv_triggerEventIfNotStopped("availableAudioTracksChange",null!=l?l:[],o);break;case"text":var d=a.getAvailableTextTracks(s);this._priv_triggerEventIfNotStopped("availableTextTracksChange",null!=d?d:[],o);break;default:X()}}}},i._priv_onFatalError=function(e,t){var n=Ne(e,{defaultCode:"NONE",defaultReason:"An unknown error stopped content playback."});n.fatal=!0,t.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this._priv_currentError=n,T.error("API: The player stopped because of an error",n),this._priv_setPlayerState("STOPPED"),this._priv_currentError===n&&this.trigger("error",n)},dl(r,null,[{key:"ErrorTypes",get:function(){return Ie}},{key:"ErrorCodes",get:function(){return Re}},{key:"LogLevel",get:function(){return T.getLevel()},set:function(e){T.setLevel(e)}}]),r}(i);Uv.version="4.0.0-dev.202402213";var Fv=Uv;!function(){if(!o&&!t(s.WebKitSourceBuffer)&&void 0===s.WebKitSourceBuffer.prototype.addEventListener){var e=s.WebKitSourceBuffer.prototype;for(var n in i.prototype)i.prototype.hasOwnProperty(n)&&(e[n]=i.prototype[n]);e._listeners=[],e._emitUpdate=function(e,t){var n=this;u((function(){n.trigger(e,t),n.updating=!1,n.trigger("updateend")}))},e.appendBuffer=function(e){if(this.updating)throw new Error("updating");this.trigger("updatestart"),this.updating=!0;try{this.append(e)}catch(e){return void this._emitUpdate("error",e)}this._emitUpdate("update")}}}(),Fv.addFeatures([Bo,Yu,il,Hd,Ic,Nc,jc,Xc,kf,Pf,Zf,rv]),e()&&T.setLevel("DEBUG");var Bv=Fv}(),r=r.default}()}));
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RxPlayer=t():e.RxPlayer=t()}(self,(function(){return function(){var e={61:function(e,t,n){var r=n(698).default;function i(){"use strict";e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},a=Object.prototype,o=a.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},l=u.iterator||"@@iterator",d=u.asyncIterator||"@@asyncIterator",c=u.toStringTag||"@@toStringTag";function f(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,n){return e[t]=n}}function v(e,t,n,r){var i=t&&t.prototype instanceof b?t:b,a=Object.create(i.prototype),o=new D(r||[]);return s(a,"_invoke",{value:x(e,n,o)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=v;var h="suspendedStart",m="suspendedYield",g="executing",y="completed",_={};function b(){}function S(){}function E(){}var T={};f(T,l,(function(){return this}));var k=Object.getPrototypeOf,w=k&&k(k(O([])));w&&w!==a&&o.call(w,l)&&(T=w);var A=E.prototype=b.prototype=Object.create(T);function I(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(i,a,s,u){var l=p(e[i],e,a);if("throw"!==l.type){var d=l.arg,c=d.value;return c&&"object"==r(c)&&o.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(c).then((function(e){d.value=e,s(d)}),(function(e){return n("throw",e,s,u)}))}u(l.arg)}var i;s(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(a,a):a()}})}function x(e,n,r){var i=h;return function(a,o){if(i===g)throw new Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=C(s,r);if(u){if(u===_)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var l=p(e,n,r);if("normal"===l.type){if(i=r.done?y:m,l.arg===_)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i=y,r.method="throw",r.arg=l.arg)}}}function C(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,C(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var a=p(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,_;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,_):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function M(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(M,this),this.reset(!0)}function O(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function n(){for(;++i<e.length;)if(o.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(r(e)+" is not iterable")}return S.prototype=E,s(A,"constructor",{value:E,configurable:!0}),s(E,"constructor",{value:S,configurable:!0}),S.displayName=f(E,c,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===S||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,f(e,c,"GeneratorFunction")),e.prototype=Object.create(A),e},n.awrap=function(e){return{__await:e}},I(R.prototype),f(R.prototype,d,(function(){return this})),n.AsyncIterator=R,n.async=function(e,t,r,i,a){void 0===a&&(a=Promise);var o=new R(v(e,t,r,i),a);return n.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(A),f(A,c,"Generator"),f(A,l,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=O,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var n in this)"t"===n.charAt(0)&&o.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),l=o.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,_):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),P(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:O(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},n}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},698:function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:function(e,t,n){var r=n(61)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var r={};return function(){"use strict";function e(){return"boolean"==typeof __RX_PLAYER_DEBUG_MODE__&&__RX_PLAYER_DEBUG_MODE__}function t(e){return null==e}n.d(r,{default:function(){return Bv}});var i=function(){function e(){this._listeners={}}var n=e.prototype;return n.addEventListener=function(e,t,n){var r=this,i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],void 0!==n&&n.register((function(){r.removeEventListener(e,t)}))},n.removeEventListener=function(e,n){if(t(e))this._listeners={};else{var r=this._listeners[e];if(Array.isArray(r))if(t(n))delete this._listeners[e];else{var i=r.indexOf(n);-1!==i&&r.splice(i,1),0===r.length&&delete this._listeners[e]}}},n.trigger=function(e,t){var n=this._listeners[e];Array.isArray(n)&&n.slice().forEach((function(e){try{e(t)}catch(e){0,console.error("RxPlayer: EventEmitter error",e instanceof Error?e:null)}}))},e}(),a="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,o="undefined"==typeof window&&!a,s=a?self:o?n.g:window,u="function"==typeof queueMicrotask?queueMicrotask:function(e){Promise.resolve().then(e,(function(){return e()}))};function l(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function d(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){l(a,r,i,o,s,"next",e)}function s(e){l(a,r,i,o,s,"throw",e)}o(void 0)}))}}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function f(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}var v=n(687),p=n.n(v);var h={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:"native",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:"continue",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MINIMUM_MAX_BUFFER_AHEAD:{text:120},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:"none",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,BITRATE_REBUFFERING_RATIO:1.5,DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:500,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,SEGMENT_SYNCHRONIZATION_DELAY:1500,MISSING_DATA_TRIGGER_SYNC_DELAY:.1,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.005,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs="avc1.4d401e"','video/mp4;codecs="avc1.42e01e"','video/webm;codecs="vp8"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs="mp4a.40.2"',"audio/webm;codecs=opus"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:["HW_SECURE_ALL","HW_SECURE_DECODE","HW_SECURE_CRYPTO","SW_SECURE_DECODE","SW_SECURE_CRYPTO"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:["3000","2000"],EME_KEY_SYSTEMS:{clearkey:["webkit-org.w3.clearkey","org.w3.clearkey"],widevine:["com.widevine.alpha"],playready:["com.microsoft.playready.recommendation","com.microsoft.playready","com.chromecast.playready","com.youtube.playready"],fairplay:["com.apple.fps.1_0"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:"reload",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:"seamless"};var m="function"==typeof Object.assign?Object.assign:function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=0;n<(arguments.length<=1?0:arguments.length-1);n++){var r=n+1<1||arguments.length<=n+1?void 0:arguments[n+1];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};function g(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}function y(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(0===n.length)return e;var i=n.shift();if(g(e)&&g(i))for(var a in i)if(g(i[a])){var o=e[a];void 0===o&&(o={},e[a]=o),y(o,i[a])}else{var s;m(e,((s={})[a]=i[a],s))}return y.apply(void 0,[e].concat(n))}var _=function(){function e(){this._config=h}var t=e.prototype;return t.update=function(e){var t=y(this._config,e);this._config=t},t.getCurrent=function(){return this._config},e}(),b=new _;function S(){}var E=function(e){function t(){var t;return(t=e.call(this)||this).error=S,t.warn=S,t.info=S,t.debug=S,t._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},t._currentLevel="NONE",t}f(t,e);var n=t.prototype;return n.setLevel=function(e,t){var n,r=this._levels[e];"number"==typeof r?(n=r,this._currentLevel=e):(n=0,this._currentLevel="NONE"),void 0===t?(this.error=n>=this._levels.ERROR?console.error.bind(console):S,this.warn=n>=this._levels.WARNING?console.warn.bind(console):S,this.info=n>=this._levels.INFO?console.info.bind(console):S,this.debug=n>=this._levels.DEBUG?console.log.bind(console):S):(this.error=n>=this._levels.ERROR?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("ERROR",n)}:S,this.warn=n>=this._levels.WARNING?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("WARNING",n)}:S,this.info=n>=this._levels.INFO?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("INFO",n)}:S,this.debug=n>=this._levels.DEBUG?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("DEBUG",n)}:S),this.trigger("onLogLevelChange",this._currentLevel)},n.getLevel=function(){return this._currentLevel},n.hasLevel=function(e){return this._levels[e]>=this._levels[this._currentLevel]},t}(i),T=new E,k=1/60;function w(e,t){return Math.abs(e-t)<k}function A(e,t){return{start:Math.min(e.start,t.start),end:Math.max(e.end,t.end)}}function I(e,t){return e.end<=t.start}function R(e,t){var n=e.start,r=e.end;return n<=t&&t<r}function x(e,t){return R(e,t.start)||e.start<t.end&&t.end<e.end||R(t,e.start)}function C(e,t){return w(t.start,e.end)||w(t.end,e.start)}function M(e){for(var t=[],n=0;n<e.length;n++)t.push({start:e.start(n),end:e.end(n)});return t}function P(e,t){for(var n=e.length-1;n>=0;n--){var r=e.start(n);if(t>=r){var i=e.end(n);if(t<i)return{start:r,end:i}}}return null}function D(e,t){for(var n=e.length-1;n>=0;n--){if(t>=e[n].start)if(t<e[n].end)return e[n]}return null}function O(e,t){for(var n=null,r=[],i=0;i<e.length;i++){var a=e[i].start,o=e[i].end;t<a||t>=o?r.push({start:a,end:o}):n={start:a,end:o}}return{outerRanges:r,innerRange:n}}function N(e,t){var n=D(e,t);return null!==n?n.end-t:1/0}function L(e,t){if(t.start===t.end)return e;for(var n=t,r=0;r<e.length;r++){var i=e[r],a=x(n,i),o=C(n,i);if(a||o)n=A(n,i),e.splice(r--,1);else if(0===r){if(I(n,e[0]))break}else if(I(e[r-1],n)&&I(n,i))break}return e.splice(r,0,n),function(e){for(var t=1;t<e.length;t++){var n=e[t-1],r=e[t];if(C(n,r)){var i=A(n,r);e.splice(--t,2,i)}}return e}(function(e){for(var t=0;t<e.length;t++){var n=e[t];n.start===n.end&&e.splice(t--,1)}return e}(e))}function U(e,t){for(var n=[],r=0;r<t.length;r++)x(e,t[r])&&n.push(t[r]);return n}function F(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=[],o=U(i,t);if(o.length>0)for(var s=0;s<o.length;s++){var u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(0===a.length)n.push(i);else{for(var l=i.start,d=0;d<a.length;d++)a[d].start>l&&n.push({start:l,end:a[d].start}),l=a[d].end;l<i.end&&n.push({start:l,end:i.end})}}return n}function B(e,t,n){if("function"==typeof Array.prototype.findIndex)return e.findIndex(t,n);for(var r=e.length>>>0,i=0;i<r;i++)if(t.call(n,e[i],i,e))return i;return-1}function z(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return V(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return V(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var K=function(){function e(e,t){var n=this;this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],void 0!==t&&(this._deregisterCancellation=t.register((function(){return n.finish()})))}var t=e.prototype;return t.getValue=function(){return this._value},t.setValue=function(e){if(!this._isFinished&&(this._value=e,0!==this._listeners.length))for(var t,n=z(this._listeners.slice());!(t=n()).done;){var r=t.value;try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(e){}}},t.setValueIfChanged=function(e){e!==this._value&&this.setValue(e)},t.onUpdate=function(e,t){var n=this,r=function e(){if(void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.deregister(e),!i.hasBeenCleared){i.hasBeenCleared=!0;var r=n._listeners.indexOf(i);r>=0&&n._listeners.splice(r,1)}},i={trigger:e,complete:r,hasBeenCleared:!1};this._listeners.push(i),!0===(null==t?void 0:t.emitCurrentValue)&&e(this._value,r),this._isFinished||i.hasBeenCleared?r():void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.register(r)},t.waitUntilDefined=function(e,t){var n=this;this.onUpdate((function(t,r){void 0!==t&&(r(),e(n._value))}),{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:!0})},t._onFinished=function(e,t){var n=this;if(t.isCancelled())return S;var r=function(){var e=B(n._onFinishCbs,(function(e){return e.trigger===i}));e>=0&&(n._onFinishCbs[e].hasBeenCleared=!0,n._onFinishCbs.splice(e,1))},i=function(){r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a},t.finish=function(){void 0!==this._deregisterCancellation&&this._deregisterCancellation(),this._isFinished=!0;for(var e,t=z(this._listeners.slice());!(e=t()).done;){var n=e.value;try{n.hasBeenCleared||(n.complete(),n.hasBeenCleared=!0)}catch(e){}}if(this._listeners.length=0,this._onFinishCbs.length>0){for(var r,i=z(this._onFinishCbs.slice());!(r=i()).done;){var a=r.value;try{a.hasBeenCleared||(a.trigger(),a.hasBeenCleared=!0)}catch(e){}}this._onFinishCbs.length=0}},e}();function W(e,t,n){var r=new K(t(e.getValue()),n);return e.onUpdate((function(e){r.setValue(t(e))}),{clearSignal:n}),e._onFinished((function(){r.finish()}),n),r}var G=K;function j(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function H(e){return H=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},H(e)}function q(e,t,n){return q=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&c(i,n.prototype),i},q.apply(null,arguments)}function Y(e){var t="function"==typeof Map?new Map:void 0;return Y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return q(e,arguments,H(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)},Y(e)}var Q=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(j(r),t.prototype),r.name="AssertionError",r.message=n,r}return f(t,e),t}(Y(Error));function $(e,t){0}function X(e){throw new Q("Unreachable path taken")}var Z=function(){function e(){var e,t=(e=S,[function(t){e(t)},function(t){e=t}]),n=t[0],r=t[1];this._isUsed=!1,this._trigger=n,this.signal=new J(r)}var t=e.prototype;return t.isUsed=function(){return this._isUsed},t.linkToSignal=function(e){var t=this,n=e.register((function(){t.cancel()}));return this.signal.register(n),n},t.cancel=function(e){if(!this._isUsed){this._isUsed=!0;var t=null!=e?e:new ee;this._trigger(t)}},e.isCancellationError=function(e){return e instanceof ee},e}(),J=function(){function e(e){var t=this;this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e((function(e){for(t.cancellationError=e,t._isCancelled=!0;t._listeners.length>0;)try{var n=t._listeners.pop();null==n||n(e)}catch(e){T.error("Error while calling clean up listener",e instanceof Error?e.toString():"Unknown error")}}))}var t=e.prototype;return t.isCancelled=function(){return this._isCancelled},t.register=function(e){var t=this;return this._isCancelled?($(this.cancellationError),e(this.cancellationError),S):(this._listeners.push(e),function(){return t.deregister(e)})},t.deregister=function(e){for(var t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)},e}(),ee=function(e){function t(){var n;return n=e.call(this)||this,Object.setPrototypeOf(j(n),t.prototype),n.name="CancellationError",n.message="This task was cancelled.",n}return f(t,e),t}(Y(Error));var te=new G(0);function ne(){return performance.now()+te.getValue()}function re(e){var t=e.map((function(t){return Math.log(t/e[0])})),n=t.map((function(e){return e-t[0]+1})),r=(n[n.length-1]-1)/(2*e.length+10),i=1/r;return e.map((function(e,t){return a(t)}));function a(t){if(0===t)return 0;var o=Math.min(Math.max(1,t),e.length-1);return e[o]===e[o-1]?a(t-1):i*(r+(e[o]*n[o-1]-e[o-1]*n[o])/(e[o]-e[o-1]))+4}}var ie=function(){function e(e){this._levelsMap=re(e).map((function(e){return e+4})),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=6e3,T.debug("ABR: Steps for buffer based chooser.",this._levelsMap.map((function(t,n){return"bufferLevel: "+t+", bitrate: "+e[n]})).join(" ,"))}var n=e.prototype;return n.onAddedSegment=function(e){var n=this._levelsMap,r=this._bitrates,i=e.bufferGap,a=e.currentBitrate,o=e.currentScore,s=e.speed;if(t(a))this._currentEstimate=r[0];else{for(var u,l=-1,d=0;d<r.length;d++){var c=r[d];if(c===a)l=d;else if(c>a)break}if(l<0||r.length!==n.length)return T.info("ABR: Current Bitrate not found in the calculated levels"),void(this._currentEstimate=r[0]);void 0!==o&&(u=0===s?o.score:o.score/s);var f=isFinite(i)?i:0,v=ne();if(f<n[l]||void 0!==u&&u<1&&1===(null==o?void 0:o.confidenceLevel)){if((void 0===this._lastUnsuitableQualityTimestamp?-1:v-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+9e3){var p=this._blockRaiseDelay+3e3;this._blockRaiseDelay=Math.min(p,15e3),T.debug("ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality",this._blockRaiseDelay)}else{var h=this._blockRaiseDelay-1e3;this._blockRaiseDelay=Math.max(6e3,h),T.debug("ABR: Lowering quality in BufferBasedChooser",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=v;for(var m=B(r,(function(e){return e===a}))-1;m>=0;m--)if(f>=n[m])return void(this._currentEstimate=r[m]);this._currentEstimate=r[0]}else if(void 0!==this._lastUnsuitableQualityTimestamp&&v-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||void 0===u||u<1.15||1!==(null==o?void 0:o.confidenceLevel))this._currentEstimate=a;else{var g=n[l],y=function(){for(var e=l+1;e<n.length;e++)if(n[e]>g)return e}();if(void 0!==y)if(i>=n[y])return T.debug("ABR: Raising quality in BufferBasedChooser",r[y]),void(this._currentEstimate=r[y]);this._currentEstimate=a}}},n.getLastEstimate=function(){return this._currentEstimate},e}();function ae(e,t,n){if("function"==typeof Array.prototype.find)return e.find(t,n);for(var r=e.length>>>0,i=0;i<r;i++){var a=e[i];if(t.call(n,a,i,e))return a}}var oe=function(){function e(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}var t=e.prototype;return t.addSample=function(e,t){var n=Math.pow(this._alpha,e),r=t*(1-n)+n*this._lastEstimate;isNaN(r)||(this._lastEstimate=r,this._totalWeight+=e)},t.getEstimate=function(){var e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e},e}();function se(e){if(!(e.progress.length<5)){for(var t=new oe(2),n=e.progress,r=1;r<n.length;r++){var i=n[r].size-n[r-1].size,a=n[r].timestamp-n[r-1].timestamp,o=8*i/(a/1e3);t.addSample(a/1e3,o)}return t.getEstimate()}}function ue(e,t){var n=8*(e.totalSize-e.size);return Math.max(n/t,0)}var le=function(){function e(e,t){var n=b.getCurrent(),r=n.ABR_STARVATION_GAP,i=n.OUT_OF_STARVATION_GAP,a=n.ABR_STARVATION_FACTOR,o=n.ABR_REGULAR_FACTOR;this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,this._config=t?{starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:{starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}var n=e.prototype;return n.getBandwidthEstimate=function(e,n,r,i,a){var o,s,u=this._config,l=e.bufferGap,d=e.position,c=e.duration,f=isFinite(l)?l:0,v=b.getCurrent().ABR_STARVATION_DURATION_DELTA;return isNaN(c)||f+d.getWanted()<c-v?!this._inStarvationMode&&f<=u.starvationGap?(T.info("ABR: enter starvation mode."),this._inStarvationMode=!0):this._inStarvationMode&&f>=u.outOfStarvationGap&&(T.info("ABR: exit starvation mode."),this._inStarvationMode=!1):this._inStarvationMode&&(T.info("ABR: exit starvation mode."),this._inStarvationMode=!1),this._inStarvationMode&&(s=function(e,n,r,i,a){if(!i){var o=n.bufferGap,s=n.speed,u=n.position,l=isFinite(o)?o:0,d=function(e,t){for(var n=-1,r=0;r<e.length;r++){var i=e[r].content.segment;if(!(i.duration<=0)){var a=i.time+i.duration;if(!i.complete&&r===e.length-1&&t-i.time>-1.2){n=r;break}if(a>t&&t-i.time>-1.2){n=r;break}}}if(n<0)return[];for(var o=e[n],s=o.content.segment.time,u=[o],l=n+1;l<e.length&&e[l].content.segment.time===s;l++)u.push(e[l]);return u}(e,u.getWanted()+l);if(1===d.length){var c=d[0],f=ne(),v=1.5*c.content.segment.duration;if(v=Math.min(v,3e3),v=Math.max(v,12e3),!(f-c.requestTimestamp<v)){var p=c.progress.length>0?c.progress[c.progress.length-1]:void 0,h=se(c);if(void 0!==p&&void 0!==h){var m=ue(p,h);if((f-p.timestamp)/1e3<=m&&m-l/s>2500)return h}if(c.content.segment.complete){var g=c.content.segment.duration,y=(f-c.requestTimestamp)/1e3,_=y<=(1.5*g+2)/s;if(!t(r)&&!_){var b=g/y,S=r.bitrate*Math.min(.7,b);return void 0===a||S<a?S:void 0}}}}}}(i,e,r,this._lowLatencyMode,a),void 0!==s&&(T.info("ABR: starvation mode emergency estimate:",s),n.reset(),o=t(r)?s:Math.min(s,r.bitrate))),t(o)&&(o=void 0!==(s=n.getEstimate())?s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):void 0!==a?a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}},n.isUrgent=function(e,t,n,r){return null===t||!(e>=t.bitrate)&&function(e,t,n){if(n)return!0;var r=isFinite(e.bufferGap)?e.bufferGap:0,i=e.position.getWanted()+r,a=ae(t,(function(e){var t=e.content;return t.segment.duration>0&&t.segment.time+t.segment.duration>i}));if(void 0===a)return!0;var o=ne(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=se(a);if(void 0===s||void 0===u)return!0;var l=ue(s,u);return(o-s.timestamp)/1e3>1.2*l||l-r/e.speed>-1.5}(r,n,this._lowLatencyMode)},e}();function de(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ce(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var fe=function(){function e(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}var t=e.prototype;return t.getGuess=function(e,t,n,r,i){var a=t.bufferGap,o=t.speed,s=this._lastAbrEstimate.representation;if(null===s)return null;if(r>s.bitrate)return 2===this._lastAbrEstimate.algorithmType&&(null!==this._lastAbrEstimate.representation&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;var u=this._scoreCalculator.getEstimate(n);if(2!==this._lastAbrEstimate.algorithmType){if(void 0===u)return null;if(this._canGuessHigher(a,o,u)){var l=ve(e,n);if(null!==l)return l}return null}if(this._isLastGuessValidated(s,r,u)&&(T.debug("ABR: Guessed Representation validated",s.bitrate),this._lastMaintanableBitrate=s.bitrate,this._consecutiveWrongGuesses=0),n.id!==s.id)return s;if(this._shouldStopGuess(n,u,a,i))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=ne()+Math.min(15e3*this._consecutiveWrongGuesses,12e4),function(e,t){var n=B(e,(function(e){return e.id===t.id}));if(n<0)return T.error("ABR: Current Representation not found."),null;for(;--n>=0;)if(e[n].bitrate<t.bitrate)return e[n];return null}(e,n);if(void 0===u)return n;if(this._canGuessHigher(a,o,u)){var d=ve(e,n);if(null!==d)return d}return n},t._canGuessHigher=function(e,t,n){var r=n.score,i=n.confidenceLevel;return isFinite(e)&&e>=2.5&&ne()>this._blockGuessesUntil&&1===i&&r/t>1.01},t._shouldStopGuess=function(e,t,n,r){if(void 0!==t&&t.score<1.01)return!0;if((void 0===t||t.score<1.2)&&n<.6)return!0;for(var i,a=r.filter((function(t){return t.content.representation.id===e.id})),o=ne(),s=de(a);!(i=s()).done;){var u=i.value,l=o-u.requestTimestamp;if(u.content.segment.isInit){if(l>1e3)return!0}else{if(l>1e3*u.content.segment.duration+200)return!0;var d=se(u);if(void 0!==d&&d<.8*e.bitrate)return!0}}return!1},t._isLastGuessValidated=function(e,t,n){return void 0!==n&&1===n.confidenceLevel&&n.score>1.5||t>=e.bitrate&&(null===this._lastMaintanableBitrate||this._lastMaintanableBitrate<e.bitrate)},e}();function ve(e,t){var n=e.length,r=B(e,(function(e){return e.id===t.id}));if(r<0)return T.error("ABR: Current Representation not found."),null;for(;++r<n;)if(e[r].bitrate>t.bitrate)return e[r];return null}var pe=function(){function e(){var e=b.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new oe(t),this._slowEWMA=new oe(n),this._bytesSampled=0}var t=e.prototype;return t.addSample=function(e,t){if(!(t<b.getCurrent().ABR_MINIMUM_CHUNK_SIZE)){var n=8e3*t/e,r=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(r,n),this._slowEWMA.addSample(r,n)}},t.getEstimate=function(){var e=b.getCurrent().ABR_MINIMUM_TOTAL_BYTES;if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())},t.reset=function(){var e=b.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new oe(t),this._slowEWMA=new oe(n),this._bytesSampled=0},e}();var he=function(){function e(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}return e.prototype.update=function(e,t,n){this.representation=e,this.bandwidth=t,this.algorithmType=n},e}();function me(e){return Object.keys(e).map((function(t){return e[t]}))}var ge="function"==typeof Object.values?Object.values:me,ye=function(){function e(){this._currentRequests={}}var n=e.prototype;return n.add=function(e){var t=e.id,n=e.requestTimestamp,r=e.content;this._currentRequests[t]={requestTimestamp:n,progress:[],content:r}},n.addProgress=function(e){var n=this._currentRequests[e.id];t(n)?T.warn("ABR: progress for a request not added"):n.progress.push(e)},n.remove=function(e){t(this._currentRequests[e])&&T.warn("ABR: can't remove unknown request"),delete this._currentRequests[e]},n.getRequests=function(){return ge(this._currentRequests).filter((function(e){return!t(e)})).sort((function(e,t){return e.content.segment.time-t.content.segment.time}))},e}(),_e=function(){function e(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}var t=e.prototype;return t.addSample=function(e,t,n){var r,i=n/t,a=this._currentRepresentationData;null!==a&&a.representation.id===e.id?(r=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=n,a.loadedSegments++):((r=new oe(5)).addSample(t,i),this._currentRepresentationData={representation:e,ewma:r,loadedDuration:n,loadedSegments:0}),r.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(T.debug("ABR: New last stable representation",e.bitrate),this._lastRepresentationWithGoodScore=e)},t.getEstimate=function(e){if(null!==this._currentRepresentationData&&this._currentRepresentationData.representation.id===e.id){var t=this._currentRepresentationData,n=t.ewma,r=t.loadedSegments,i=t.loadedDuration;return{score:n.getEstimate(),confidenceLevel:r>=5&&i>=10?1:0}}},t.getLastStableRepresentation=function(){return this._lastRepresentationWithGoodScore},e}();function be(e,t){var n=B(e,(function(e){return e.bitrate>t}));return-1===n?e[e.length-1]:0===n?e[0]:e[n-1]}var Se=new G(void 0);Se.finish();var Ee=new G(1/0);Ee.finish();var Te=function(e){var n={},r=e.initialBitrates,i=e.throttlers,a=e.lowLatencyMode;return function(e,o,s,u,l){var d,c,f,v=e.adaptation.type,p=function(e){var r=n[e];if(t(r)){T.debug("ABR: Creating new BandwidthEstimator for ",e);var i=new pe;return n[e]=i,i}return r}(v),h=null!==(d=r[v])&&void 0!==d?d:0;return function(e,t){var n=e.bandwidthEstimator,r=e.context,i=e.currentRepresentation,a=e.filters,o=e.initialBitrate,s=e.lowLatencyMode,u=e.playbackObserver,l=e.representations,d=new _e,c=new le(null!=o?o:0,s),f=new ye,v=S,p={metrics:_,requestBegin:E,requestProgress:k,requestEnd:w,addedSegment:function(e){v(e)}},h=new Z;h.linkToSignal(t);var m=g(l.getValue(),h.signal);return l.onUpdate(y,{clearSignal:t}),{estimates:m,callbacks:p};function g(e,t){if(e.length<=1)return new G({bitrate:void 0,representation:e[0],urgent:!0,knownStableBitrate:void 0});var o=!1,l=e.sort((function(e,t){return e.bitrate-t.bitrate})),p=new ie(l.map((function(e){return e.bitrate}))),h=new he,m=new fe(d,h),g=u.getReference().getValue(),y=new G(E());return u.listen((function(e){g=e,_()}),{includeLastObservation:!1,clearSignal:t}),v=function(e){if(null!==g){var t=g,n=t.position,r=t.speed,i=N(e.buffered,n.getWanted()),a=e.content.representation,o=d.getEstimate(a),s={bufferGap:i,currentBitrate:a.bitrate,currentScore:o,speed:r};p.onAddedSegment(s),_()}},t.register((function(){v=S})),a.throttleBitrate.onUpdate(_,{clearSignal:t}),a.limitResolution.onUpdate(_,{clearSignal:t}),y;function _(){y.setValue(E())}function E(){var e=g,t=e.bufferGap,u=e.position,v=e.maximumPosition,y=a.limitResolution.getValue(),_=a.throttleBitrate.getValue(),S=i.getValue(),E=function(e,t,n){var r=e;void 0!==n&&n<1/0&&(r=function(e,t){if(0===e.length)return[];e.sort((function(e,t){return e.bitrate-t.bitrate}));var n=e[0].bitrate,r=Math.max(t,n),i=B(e,(function(e){return e.bitrate>r}));return-1===i?e:e.slice(0,i)}(r,n));void 0!==t&&(r=function(e,t){if(void 0===t.width||void 0===t.height)return e;var n=t.width*t.pixelRatio,r=t.height*t.pixelRatio,i=ae(e.slice().sort((function(e,t){var n,r;return(null!==(n=e.width)&&void 0!==n?n:0)-(null!==(r=t.width)&&void 0!==r?r:0)})),(function(e){return"number"==typeof e.width&&e.width>=n&&"number"==typeof e.height&&e.height>=r}));if(void 0===i)return e;var a="number"==typeof i.width?i.width:0;return e.filter((function(e){return"number"!=typeof e.width||e.width<=a}))}(r,t));return r}(l,y,_),k=f.getRequests(),w=c.getBandwidthEstimate(g,n,S,k,h.bandwidth),A=w.bandwidthEstimate,I=w.bitrateChosen,R=d.getLastStableRepresentation(),x=null===R?void 0:R.bitrate/(g.speed>0?g.speed:1),C=b.getCurrent(),M=C.ABR_ENTER_BUFFER_BASED_ALGO,P=C.ABR_EXIT_BUFFER_BASED_ALGO;o&&t<=P?o=!1:!o&&isFinite(t)&&t>=M&&(o=!0);var D=be(E,I),O=p.getLastEstimate(),N=D.bitrate,L=null;o&&void 0!==O&&O>N&&(N=(L=be(E,O)).bitrate);var U=null;return s&&null!==S&&r.manifest.isDynamic&&v-u.getWanted()<40&&(U=m.getGuess(l,g,S,N,k)),null!==U&&U.bitrate>N?(T.debug("ABR: Choosing representation with guess-based estimation.",U.bitrate,U.id),h.update(U,A,2),{bitrate:A,representation:U,urgent:null===S||U.bitrate<S.bitrate,knownStableBitrate:x}):null!==L?(T.debug("ABR: Choosing representation with buffer-based estimation.",L.bitrate,L.id),h.update(L,A,0),{bitrate:A,representation:L,urgent:c.isUrgent(L.bitrate,S,k,g),knownStableBitrate:x}):(T.debug("ABR: Choosing representation with bandwidth estimation.",D.bitrate,D.id),h.update(D,A,1),{bitrate:A,representation:D,urgent:c.isUrgent(D.bitrate,S,k,g),knownStableBitrate:x})}}function y(){var e=l.getValue();h.cancel(),(h=new Z).linkToSignal(t),g(e,h.signal).onUpdate((function(e){m.setValue(e)}),{clearSignal:h.signal,emitCurrentValue:!0})}function _(e){var t=e.requestDuration,r=e.segmentDuration,i=e.size,a=e.content;if(n.addSample(t,i),!a.segment.isInit){var o=a.segment,s=a.representation;if(void 0===r&&!o.complete)return;var u=null!=r?r:o.duration;d.addSample(s,t/1e3,u)}}function E(e){f.add(e)}function k(e){f.addProgress(e)}function w(e){f.remove(e.id)}}({bandwidthEstimator:p,context:e,currentRepresentation:o,filters:{limitResolution:null!==(c=i.limitResolution[v])&&void 0!==c?c:Se,throttleBitrate:null!==(f=i.throttleBitrate[v])&&void 0!==f?f:Ee},initialBitrate:h,playbackObserver:u,representations:s,lowLatencyMode:a},l)}},ke=function(e){function t(n,r,i){var a;switch(a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="RequestError",a.url=n,a.status=r,a.type=i,i){case"TIMEOUT":a.message="The request timed out";break;case"ERROR_EVENT":a.message="An error prevented the request to be performed successfully";break;case"PARSE_ERROR":a.message="An error happened while formatting the response data";break;case"ERROR_HTTP_CODE":a.message="An HTTP status code indicating failure was received: "+String(a.status)}return a}return f(t,e),t.prototype.serialize=function(){return{url:this.url,status:this.status,type:this.type}},t}(Y(Error)),we={TIMEOUT:"TIMEOUT",ERROR_EVENT:"ERROR_EVENT",ERROR_HTTP_CODE:"ERROR_HTTP_CODE",PARSE_ERROR:"PARSE_ERROR"},Ae=we,Ie={NETWORK_ERROR:"NETWORK_ERROR",MEDIA_ERROR:"MEDIA_ERROR",ENCRYPTED_MEDIA_ERROR:"ENCRYPTED_MEDIA_ERROR",OTHER_ERROR:"OTHER_ERROR"},Re={PIPELINE_LOAD_ERROR:"PIPELINE_LOAD_ERROR",PIPELINE_PARSE_ERROR:"PIPELINE_PARSE_ERROR",INTEGRITY_ERROR:"INTEGRITY_ERROR",MANIFEST_PARSE_ERROR:"MANIFEST_PARSE_ERROR",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"MANIFEST_INCOMPATIBLE_CODECS_ERROR",MANIFEST_UPDATE_ERROR:"MANIFEST_UPDATE_ERROR",MANIFEST_UNSUPPORTED_ADAPTATION_TYPE:"MANIFEST_UNSUPPORTED_ADAPTATION_TYPE",MEDIA_STARTING_TIME_NOT_FOUND:"MEDIA_STARTING_TIME_NOT_FOUND",MEDIA_TIME_BEFORE_MANIFEST:"MEDIA_TIME_BEFORE_MANIFEST",MEDIA_TIME_AFTER_MANIFEST:"MEDIA_TIME_AFTER_MANIFEST",MEDIA_TIME_NOT_FOUND:"MEDIA_TIME_NOT_FOUND",NO_PLAYABLE_REPRESENTATION:"NO_PLAYABLE_REPRESENTATION",MEDIA_IS_ENCRYPTED_ERROR:"MEDIA_IS_ENCRYPTED_ERROR",CREATE_MEDIA_KEYS_ERROR:"CREATE_MEDIA_KEYS_ERROR",KEY_ERROR:"KEY_ERROR",KEY_STATUS_CHANGE_ERROR:"KEY_STATUS_CHANGE_ERROR",KEY_UPDATE_ERROR:"KEY_UPDATE_ERROR",KEY_LOAD_ERROR:"KEY_LOAD_ERROR",KEY_LOAD_TIMEOUT:"KEY_LOAD_TIMEOUT",KEY_GENERATE_REQUEST_ERROR:"KEY_GENERATE_REQUEST_ERROR",INCOMPATIBLE_KEYSYSTEMS:"INCOMPATIBLE_KEYSYSTEMS",INVALID_ENCRYPTED_EVENT:"INVALID_ENCRYPTED_EVENT",INVALID_KEY_SYSTEM:"INVALID_KEY_SYSTEM",LICENSE_SERVER_CERTIFICATE_ERROR:"LICENSE_SERVER_CERTIFICATE_ERROR",MULTIPLE_SESSIONS_SAME_INIT_DATA:"MULTIPLE_SESSIONS_SAME_INIT_DATA",BUFFER_APPEND_ERROR:"BUFFER_APPEND_ERROR",BUFFER_FULL_ERROR:"BUFFER_FULL_ERROR",BUFFER_TYPE_UNKNOWN:"BUFFER_TYPE_UNKNOWN",MEDIA_ERR_BLOCKED_AUTOPLAY:"MEDIA_ERR_BLOCKED_AUTOPLAY",MEDIA_ERR_PLAY_NOT_ALLOWED:"MEDIA_ERR_PLAY_NOT_ALLOWED",MEDIA_ERR_NOT_LOADED_METADATA:"MEDIA_ERR_NOT_LOADED_METADATA",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_UNKNOWN:"MEDIA_ERR_UNKNOWN",MEDIA_SOURCE_NOT_SUPPORTED:"MEDIA_SOURCE_NOT_SUPPORTED",MEDIA_KEYS_NOT_SUPPORTED:"MEDIA_KEYS_NOT_SUPPORTED",DISCONTINUITY_ENCOUNTERED:"DISCONTINUITY_ENCOUNTERED",NONE:"NONE"};function xe(e,t){return e+": "+t}var Ce=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="EncryptedMediaError",a.type=Ie.ENCRYPTED_MEDIA_ERROR,a.code=n,a._originalMessage=r,a.message=xe(a.code,r),a.fatal=!1,"string"==typeof(null==i?void 0:i.keyStatuses)&&(a.keyStatuses=i.keyStatuses),a}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}},t}(Y(Error)),Me=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="MediaError",a.type=Ie.MEDIA_ERROR,a._originalMessage=r,a.code=n,a.message=xe(a.code,r),a.fatal=!1,void 0!==(null==i?void 0:i.tracks)&&(null==i?void 0:i.tracks.length)>0&&(a.tracksInfo=i.tracks),a}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}},t}(Y(Error)),Pe=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(j(i),t.prototype),i.name="NetworkError",i.type=Ie.NETWORK_ERROR,i.url=r.url,i.status=r.status,i.errorType=r.type,i._baseError=r,i.code=n,i.message=xe(i.code,r.message),i.fatal=!1,i}f(t,e);var n=t.prototype;return n.isHttpError=function(e){return this.errorType===Ae.ERROR_HTTP_CODE&&this.status===e},n.serialize=function(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}},t}(Y(Error)),De=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(j(i),t.prototype),i.name="OtherError",i.type=Ie.OTHER_ERROR,i.code=n,i.message=xe(i.code,r),i.fatal=!1,i._originalMessage=r,i}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage}},t}(Y(Error));function Oe(e){return(e instanceof Ce||e instanceof Me||e instanceof De||e instanceof Pe)&&Object.keys(Ie).indexOf(e.type)>=0}function Ne(e,t){var n=t.defaultCode,r=t.defaultReason;if(Oe(e))return e;var i=e instanceof Error?e.toString():r;return new De(n,i)}function Le(){var e="",t=-1;return function(){return++t>=Number.MAX_SAFE_INTEGER&&(e+="0",t=0),e+String(t)}}function Ue(e,t,n){if("function"==typeof Array.prototype.includes)return e.includes(t,n);var r=e.length>>>0;if(0===r)return!1;for(var i,a,o=0|n,s=o>=0?Math.min(o,r-1):Math.max(r+o,0);s<r;){if((i=e[s])===(a=t)||"number"==typeof i&&"number"==typeof a&&isNaN(i)&&isNaN(a))return!0;s++}return!1}var Fe=[];function Be(e){Ue(Fe,e)||(console.warn(e),Fe.push(e))}var ze=["audio","video","text"];function Ve(e){var t,n,r=e.timeBounds;if(null===r.timeshiftDepth)return null!==(t=r.minimumSafePosition)&&void 0!==t?t:0;var i,a=r.maximumTimeData;if(r.maximumTimeData.isLinear){var o=ne()-a.time;i=a.maximumSafePosition+o/1e3}else i=a.maximumSafePosition;var s=i-r.timeshiftDepth;return Math.max(null!==(n=r.minimumSafePosition)&&void 0!==n?n:0,s)}function Ke(e){var t=e.timeBounds.maximumTimeData;if(e.isLive&&void 0!==t.livePosition){if(!t.isLinear)return t.livePosition;var n=ne()-t.time;return t.livePosition+n/1e3}}function We(e){var t=e.timeBounds.maximumTimeData;if(!t.isLinear)return t.maximumSafePosition;var n=ne()-t.time;return t.maximumSafePosition+n/1e3}function Ge(e,t){if(void 0===t)return qe(e).filter((function(e){return!0===e.isSupported}));var n=e.adaptations[t];return void 0===n?[]:n.filter((function(e){return!0===e.isSupported}))}function je(e,t){var n=t.end;if(void 0===n)return null;var r=ae(e.periods,(function(e){return void 0===e.end||n<e.end}));return void 0===r?null:r}function He(e,t,n){return t>=e.start&&(void 0===e.end||t<e.end)||t===e.end&&(null===n||n.start>e.end)}function qe(e){return me(e.adaptations).reduce((function(e,n){return t(n)?e:e.concat(n)}),[])}function Ye(e,t){var n,r,i={language:null!==(n=e.language)&&void 0!==n?n:"",normalized:null!==(r=e.normalizedLanguage)&&void 0!==r?r:"",audioDescription:!0===e.isAudioDescription,id:e.id,representations:(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(Xe),label:e.label};return!0===e.isDub&&(i.dub=!0),i}function Qe(e){var t,n;return{language:null!==(t=e.language)&&void 0!==t?t:"",normalized:null!==(n=e.normalizedLanguage)&&void 0!==n?n:"",closedCaption:!0===e.isClosedCaption,id:e.id,label:e.label,forced:e.isForcedSubtitles}}function $e(e,t){var n=void 0!==e.trickModeTracks?e.trickModeTracks.map((function(e){var n=(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(Ze),r={id:e.id,representations:n,isTrickModeTrack:!0};return!0===e.isSignInterpreted&&(r.signInterpreted=!0),r})):void 0,r={id:e.id,representations:(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(Ze),label:e.label};return!0===e.isSignInterpreted&&(r.signInterpreted=!0),!0===e.isTrickModeTrack&&(r.isTrickModeTrack=!0),void 0!==n&&(r.trickModeTracks=n),r}function Xe(e){var t=e.id,n=e.bitrate,r=e.codecs,i=e.isSpatialAudio,a=e.isSupported,o=e.decipherable;return{id:t,bitrate:n,codec:null==r?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function Ze(e){var t=e.id,n=e.bitrate,r=e.frameRate,i=e.width,a=e.height,o=e.codecs,s=e.hdrInfo,u=e.isSupported,l=e.decipherable;return{id:t,bitrate:n,frameRate:r,width:i,height:a,codec:null==o?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:l}}function Je(e){switch(e.type){case"audio":return{type:"audio",track:Ye(e,!1)};case"video":return{type:"video",track:$e(e,!1)};case"text":return{type:"text",track:Qe(e)}}}function et(e){return"string"==typeof e&&e.length>0}var tt={aa:"aar",ab:"abk",ae:"ave",af:"afr",ak:"aka",am:"amh",an:"arg",ar:"ara",as:"asm",av:"ava",ay:"aym",az:"aze",ba:"bak",be:"bel",bg:"bul",bi:"bis",bm:"bam",bn:"ben",bo:"bod",br:"bre",bs:"bos",ca:"cat",ce:"che",ch:"cha",co:"cos",cr:"cre",cs:"ces",cu:"chu",cv:"chv",cy:"cym",da:"dan",de:"deu",dv:"div",dz:"dzo",ee:"ewe",el:"ell",en:"eng",eo:"epo",es:"spa",et:"est",eu:"eus",fa:"fas",ff:"ful",fi:"fin",fj:"fij",fo:"fao",fr:"fra",fy:"fry",ga:"gle",gd:"gla",gl:"glg",gn:"grn",gu:"guj",gv:"glv",ha:"hau",he:"heb",hi:"hin",ho:"hmo",hr:"hrv",ht:"hat",hu:"hun",hy:"hye",hz:"her",ia:"ina",id:"ind",ie:"ile",ig:"ibo",ii:"iii",ik:"ipk",io:"ido",is:"isl",it:"ita",iu:"iku",ja:"jpn",jv:"jav",ka:"kat",kg:"kon",ki:"kik",kj:"kua",kk:"kaz",kl:"kal",km:"khm",kn:"kan",ko:"kor",kr:"kau",ks:"kas",ku:"kur",kv:"kom",kw:"cor",ky:"kir",la:"lat",lb:"ltz",lg:"lug",li:"lim",ln:"lin",lo:"lao",lt:"lit",lu:"lub",lv:"lav",mg:"mlg",mh:"mah",mi:"mri",mk:"mkd",ml:"mal",mn:"mon",mr:"mar",ms:"msa",mt:"mlt",my:"mya",na:"nau",nb:"nob",nd:"nde",ne:"nep",ng:"ndo",nl:"nld",nn:"nno",no:"nor",nr:"nbl",nv:"nav",ny:"nya",oc:"oci",oj:"oji",om:"orm",or:"ori",os:"oss",pa:"pan",pi:"pli",pl:"pol",ps:"pus",pt:"por",qu:"que",rm:"roh",rn:"run",ro:"ron",ru:"rus",rw:"kin",sa:"san",sc:"srd",sd:"snd",se:"sme",sg:"sag",si:"sin",sk:"slk",sl:"slv",sm:"smo",sn:"sna",so:"som",sq:"sqi",sr:"srp",ss:"ssw",st:"sot",su:"sun",sv:"swe",sw:"swa",ta:"tam",te:"tel",tg:"tgk",th:"tha",ti:"tir",tk:"tuk",tl:"tgl",tn:"tsn",to:"ton",tr:"tur",ts:"tso",tt:"tat",tw:"twi",ty:"tah",ug:"uig",uk:"ukr",ur:"urd",uz:"uzb",ve:"ven",vi:"vie",vo:"vol",wa:"wln",wo:"wol",xh:"xho",yi:"yid",yo:"yor",za:"zha",zh:"zho",zu:"zul"},nt={alb:"sqi",arm:"hye",baq:"eus",bur:"mya",chi:"zho",cze:"ces",dut:"nld",fre:"fra",geo:"kat",ger:"deu",gre:"ell",ice:"isl",mac:"mkd",mao:"mri",may:"msa",per:"fas",slo:"slk",rum:"ron",tib:"bod",wel:"cym"};function rt(e){if(t(e)||""===e)return"";var n=function(e){var t;switch(e.length){case 2:t=tt[e];break;case 3:t=nt[e]}return t}((""+e).toLowerCase().split("-")[0]);return et(n)?n:e}var it=rt,at={dashParsers:{wasm:null,js:null},codecSupportProber:null,createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},ot=at;function st(e,t){if(e.length!==t.length)return!1;if(e===t)return!0;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return!1;return!0}function ut(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return lt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function lt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var dt=Le(),ct=function(){function e(e,t){var n,r,i,a,o;if(this.id=e.id,this.uniqueId=dt(),this.bitrate=e.bitrate,this.codecs=[],void 0!==e.isSpatialAudio&&(this.isSpatialAudio=e.isSpatialAudio),void 0!==e.height&&(this.height=e.height),void 0!==e.width&&(this.width=e.width),void 0!==e.mimeType&&(this.mimeType=e.mimeType),void 0!==e.contentProtections&&(this.contentProtections=e.contentProtections),void 0!==e.frameRate&&(this.frameRate=e.frameRate),void 0!==e.hdrInfo&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index,"audio"===t||"video"===t)if(null!==ot.codecSupportProber){if(void 0!==e.supplementalCodecs){var s=ot.codecSupportProber.isSupported(null!==(n=this.mimeType)&&void 0!==n?n:"",null!==(r=e.supplementalCodecs)&&void 0!==r?r:"");!1!==s&&(this.codecs=[e.supplementalCodecs],!0===s&&(this.isSupported=!0))}!0!==this.isSupported&&(this.codecs.length>0?this.codecs.push(null!==(i=e.codecs)&&void 0!==i?i:""):(this.codecs=void 0===e.codecs?[]:[e.codecs],this.isSupported=ot.codecSupportProber.isSupported(null!==(a=this.mimeType)&&void 0!==a?a:"",null!==(o=e.codecs)&&void 0!==o?o:"")))}else void 0!==e.supplementalCodecs&&this.codecs.push(e.supplementalCodecs),void 0!==e.codecs&&this.codecs.push(e.codecs);else void 0!==e.codecs&&this.codecs.push(e.codecs),this.isSupported=!0}var t=e.prototype;return t.refreshCodecSupport=function(e){var t,n=null!==(t=this.mimeType)&&void 0!==t?t:"",r=this.codecs;0===r.length&&(r=[""]);for(var i=0;i<r.length;i++)for(var a,o=ut(e);!(a=o()).done;){var s=a.value,u=r[i];if(s.codec===u&&s.mimeType===n){if(s.result)return this.isSupported=!0,void(this.codecs=[u]);if(i===r.length)return this.isSupported=!1,void(this.codecs=[u])}}},t.getMimeTypeString=function(){var e,t,n;return(null!==(e=this.mimeType)&&void 0!==e?e:"")+';codecs="'+(null!==(n=null===(t=this.codecs)||void 0===t?void 0:t[0])&&void 0!==n?n:"")+'"'},t.getEncryptionData=function(e){for(var t,n,r=this.getAllEncryptionData(),i=[],a=0;a<r.length;a++)for(var o=!1,s=r[a],u=0;u<s.values.length;u++)if(s.values[u].systemId.toLowerCase()===e.toLowerCase())if(o)i[i.length-1].values.push(s.values[u]);else{var l=null===(n=null===(t=this.contentProtections)||void 0===t?void 0:t.keyIds)||void 0===n?void 0:n.map((function(e){return e.keyId}));i.push({type:s.type,keyIds:l,values:[s.values[u]]}),o=!0}return i},t.getAllEncryptionData=function(){var e,t;if(void 0===this.contentProtections||0===this.contentProtections.initData.length)return[];var n=null===(t=null===(e=this.contentProtections)||void 0===e?void 0:e.keyIds)||void 0===t?void 0:t.map((function(e){return e.keyId}));return this.contentProtections.initData.map((function(e){return{type:e.type,keyIds:n,values:e.values}}))},t.addProtectionData=function(e,t,n){var r=!1;if(void 0===this.contentProtections)return this.contentProtections={keyIds:void 0!==t?[{keyId:t}]:[],initData:[{type:e,values:n}]},!0;if(void 0!==t){var i=this.contentProtections.keyIds;if(void 0===i)this.contentProtections.keyIds=[{keyId:t}];else{for(var a,o=!1,s=ut(i);!(a=s()).done;){st(a.value.keyId,t)&&(o=!0)}o||(T.warn("Manifest: found unanounced key id."),i.push({keyId:t}))}}for(var u=this.contentProtections.initData,l=0;l<u.length;l++)if(u[l].type===e){for(var d=u[l].values,c=0;c<n.length;c++){var f=n[c],v=void 0;for(v=0;v<d.length;v++)if(f.systemId===d[v].systemId){if(st(f.data,d[v].data))break;T.warn("Manifest: different init data for the same system ID")}v===d.length&&(d.push(f),r=!0)}return r}return this.contentProtections.initData.push({type:e,values:n}),!0},t.getMetadataSnapshot=function(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,codecs:this.codecs,mimeType:this.mimeType,width:this.width,height:this.height,frameRate:this.frameRate,isSupported:this.isSupported,hdrInfo:this.hdrInfo,contentProtections:this.contentProtections,decipherable:this.decipherable}},e}(),ft=ct;function vt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return pt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ht=function(){function e(n,r){void 0===r&&(r={});var i=n.trickModeTracks,a=r,o=a.representationFilter,s=a.isManuallyAdded;this.id=n.id,this.type=n.type,void 0!==n.isTrickModeTrack&&(this.isTrickModeTrack=n.isTrickModeTrack),void 0!==n.language&&(this.language=n.language,this.normalizedLanguage=it(n.language)),void 0!==n.closedCaption&&(this.isClosedCaption=n.closedCaption),void 0!==n.audioDescription&&(this.isAudioDescription=n.audioDescription),void 0!==n.isDub&&(this.isDub=n.isDub),void 0!==n.forcedSubtitles&&(this.isForcedSubtitles=n.forcedSubtitles),void 0!==n.isSignInterpreted&&(this.isSignInterpreted=n.isSignInterpreted),void 0!==n.label&&(this.label=n.label),void 0!==i&&i.length>0&&(this.trickModeTracks=i.map((function(t){return new e(t)})));for(var u,l=n.representations,d=[],c=0;c<l.length;c++){var f=new ft(l[c],this.type),v=!0;if(!t(o)){var p={id:f.id,bitrate:f.bitrate,codecs:f.codecs,height:f.height,width:f.width,frameRate:f.frameRate,hdrInfo:f.hdrInfo};if(void 0!==f.contentProtections&&(p.contentProtections={},void 0!==f.contentProtections.keyIds)){var h=f.contentProtections.keyIds.map((function(e){return e.keyId}));p.contentProtections.keyIds=h}v=o(p,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}v?(d.push(f),void 0===u&&(!0===f.isSupported?u=!0:!1===f.isSupported&&(u=!1))):T.debug("Filtering Representation due to representationFilter",this.type,"Adaptation: "+this.id,"Representation: "+f.id,"("+f.bitrate+")")}d.sort((function(e,t){return e.bitrate-t.bitrate})),this.representations=d,this.isSupported=u,this.manuallyAdded=!0===s}var n=e.prototype;return n.refreshCodecSupport=function(e){for(var t,n=vt(this.representations);!(t=n()).done;){var r=t.value;void 0===r.isSupported&&(r.refreshCodecSupport(e),!0!==this.isSupported&&!0===r.isSupported?this.isSupported=!0:void 0===this.isSupported&&!1===r.isSupported&&(this.isSupported=!1))}},n.getRepresentation=function(e){return ae(this.representations,(function(t){var n=t.id;return e===n}))},n.getMetadataSnapshot=function(){for(var e,t=[],n=vt(this.representations);!(e=n()).done;){var r=e.value;t.push(r.getMetadataSnapshot())}return{id:this.id,type:this.type,isSupported:this.isSupported,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:t,label:this.label,isDub:this.isDub}},e}();function mt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return gt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function gt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var yt,_t=function(){function e(e,n,r){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((function(i,a){var o=e.adaptations[a];if(t(o))return i;var s=o.map((function(e){var t=new ht(e,{representationFilter:r});return t.representations.length>0&&!1===t.isSupported&&n.push(t),t})).filter((function(e){return e.representations.length>0}));if(s.every((function(e){return!1===e.isSupported}))&&o.length>0&&("video"===a||"audio"===a))throw new Me("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+a+" adaptations",{tracks:void 0});return s.length>0&&(i[a]=s),i}),{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new Me("MANIFEST_PARSE_ERROR","No supported audio and video tracks.");this.duration=e.duration,this.start=e.start,t(this.duration)||t(this.start)||(this.end=this.start+this.duration),this.streamEvents=void 0===e.streamEvents?[]:e.streamEvents}var n=e.prototype;return n.refreshCodecSupport=function(e,t){var n=this;Object.keys(this.adaptations).forEach((function(r){var i=n.adaptations[r];if(void 0!==i){for(var a,o=!1,s=mt(i);!(a=s()).done;){var u=a.value,l=u.isSupported;u.refreshCodecSupport(e),!1!==l&&!1===u.isSupported&&t.push(u),!1===o?o=u.isSupported:void 0===o&&!0===u.isSupported&&(o=!0)}if(("video"===r||"audio"===r)&&!1===o)throw new Me("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+r+" adaptations",{tracks:void 0})}}),{})},n.getAdaptations=function(){return qe(this)},n.getAdaptationsForType=function(e){var t=this.adaptations[e];return null!=t?t:[]},n.getAdaptation=function(e){return ae(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n.getSupportedAdaptations=function(e){return Ge(this,e)},n.containsTime=function(e,t){return He(this,e,t)},n.getMetadataSnapshot=function(){for(var e,t={},n=mt(this.getAdaptations());!(e=n()).done;){var r=e.value,i=t[r.type];void 0===i&&(i=[],t[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:t}},e}();function bt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return St(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return St(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function St(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Et(e,t,n){var r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};e.start=t.start,e.end=t.end,e.duration=t.duration,e.streamEvents=t.streamEvents;for(var i=e.getAdaptations(),a=t.getAdaptations(),o=function(e){var t=i[e],o=B(a,(function(e){return e.id===t.id}));if(-1===o){T.warn('Manifest: Adaptation "'+i[e].id+'" not found when merging.');var u=i.splice(e,1)[0];e--,r.removedAdaptations.push({id:u.id,trackType:u.type})}else{var l=a.splice(o,1)[0],d=[],c=[],f=[];r.updatedAdaptations.push({adaptation:t.id,trackType:t.type,updatedRepresentations:d,addedRepresentations:c,removedRepresentations:f});for(var v,p=t.representations,h=l.representations.slice(),m=function(e){var t=p[e],r=B(h,(function(e){return e.id===t.id}));if(-1===r){T.warn('Manifest: Representation "'+p[e].id+'" not found when merging.');var i=p.splice(e,1)[0];e--,f.push(i.id)}else{var a=h.splice(r,1)[0];d.push(t.getMetadataSnapshot()),t.cdnMetadata=a.cdnMetadata,n===yt.Full?t.index._replace(a.index):t.index._update(a.index)}g=e},g=0;g<p.length;g++)m(g);if(h.length>0)T.warn("Manifest: "+h.length+" new Representations found when merging."),(v=t.representations).push.apply(v,h),c.push.apply(c,h.map((function(e){return e.getMetadataSnapshot()})))}s=e},s=0;s<i.length;s++)o(s);if(a.length>0){T.warn("Manifest: "+a.length+" new Adaptations found when merging.");for(var u,l=bt(a);!(u=l()).done;){var d=u.value,c=e.adaptations[d.type];void 0===c?e.adaptations[d.type]=[d]:c.push(d),r.addedAdaptations.push(d.getMetadataSnapshot())}}return r}function Tt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function kt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}!function(e){e[e.Full=0]="Full",e[e.Partial=1]="Partial"}(yt||(yt={}));var wt=Le(),At=function(e){function t(t,n,r){var i,a;i=e.call(this)||this;var o=n.representationFilter,s=n.manifestUpdateUrl;i.manifestFormat=0,i.id=wt(),i.expired=null!==(a=t.expired)&&void 0!==a?a:null,i.transport=t.transportType,i.clockOffset=t.clockOffset;var u=[];if(i.periods=t.periods.map((function(e){return new _t(e,u,o)})).sort((function(e,t){return e.start-t.start})),u.length>0){var l=new Me("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{tracks:u.map(Je)});r.push(l)}return i.adaptations=void 0===i.periods[0]?{}:i.periods[0].adaptations,i.timeBounds=t.timeBounds,i.isDynamic=t.isDynamic,i.isLive=t.isLive,i.isLastPeriodKnown=t.isLastPeriodKnown,i.uris=void 0===t.uris?[]:t.uris,i.updateUrl=s,i.lifetime=t.lifetime,i.clockOffset=t.clockOffset,i.suggestedPresentationDelay=t.suggestedPresentationDelay,i.availabilityStartTime=t.availabilityStartTime,i.publishTime=t.publishTime,i}f(t,e);var n=t.prototype;return n.refreshCodecSupport=function(e){for(var t,n=[],r=Tt(this.periods);!(t=r()).done;){t.value.refreshCodecSupport(e,n)}return n.length>0?new Me("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{tracks:n.map(Je)}):null},n.getPeriod=function(e){return ae(this.periods,(function(t){return e===t.id}))},n.getPeriodForTime=function(e){return function(e,t){for(var n=null,r=e.periods.length-1;r>=0;r--){var i=e.periods[r];if(He(i,t,n))return i;n=i}}(this,e)},n.getNextPeriod=function(e){return ae(this.periods,(function(t){return t.start>e}))},n.getPeriodAfter=function(e){return je(this,e)},n.getUrls=function(){return this.uris},n.replace=function(e){this._performUpdate(e,yt.Full)},n.update=function(e){this._performUpdate(e,yt.Partial)},n.getMinimumSafePosition=function(){return Ve(this)},n.getLivePosition=function(){return Ke(this)},n.getMaximumSafePosition=function(){return We(this)},n.updateRepresentationsDeciperability=function(e){var t=function(e,t){for(var n,r=[],i=Tt(e.periods);!(n=i()).done;)for(var a,o=n.value,s=Tt(o.getAdaptations());!(a=s()).done;)for(var u,l=a.value,d=Tt(l.representations);!(u=d()).done;){var c=u.value,f={manifest:e,period:o,adaptation:l,representation:c},v=t(f);v!==c.decipherable&&(r.push(f),c.decipherable=v,T.debug('Decipherability changed for "'+c.id+'"',"("+c.bitrate+")",String(c.decipherable)))}return r}(this,e);t.length>0&&this.trigger("decipherabilityUpdate",t)},n.getAdaptations=function(){Be("manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead");var e=this.periods[0];if(void 0===e)return[];var t=e.adaptations,n=[];for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];n.push.apply(n,i)}return n},n.getAdaptationsForType=function(e){Be("manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead");var t=this.periods[0];if(void 0===t)return[];var n=t.adaptations[e];return void 0===n?[]:n},n.getAdaptation=function(e){return Be("manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead"),ae(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n.getMetadataSnapshot=function(){for(var e,t=[],n=Tt(this.periods);!(e=n()).done;){var r=e.value;t.push(r.getMetadataSnapshot())}return{manifestFormat:1,id:this.id,periods:t,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}},n._performUpdate=function(e,t){var n;if(this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime,t===yt.Full)this.timeBounds=e.timeBounds,this.uris=e.uris,n=function(e,t){for(var n={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0,i=0;i<t.length;i++){for(var a=t[i],o=r,s=e[o];void 0!==s&&s.id!==a.id;)s=e[++o];if(void 0!==s){var u,l,d=Et(s,a,yt.Full);n.updatedPeriods.push({period:{id:s.id,start:s.start,end:s.end,duration:s.duration,streamEvents:s.streamEvents},result:d});var c=t.slice(r,i),f=o-r,v=e.splice.apply(e,[r,f].concat(c));(u=n.removedPeriods).push.apply(u,v.map((function(e){return{id:e.id,start:e.start,end:e.end}}))),(l=n.addedPeriods).push.apply(l,c.map((function(e){return e.getMetadataSnapshot()}))),r=i+1}}if(r>e.length)return T.error("Manifest: error when updating Periods"),n;if(r<e.length){var p,h=e.splice(r,e.length-r);(p=n.removedPeriods).push.apply(p,h.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}var m,g=t.slice(r,t.length);return g.length>0&&(e.push.apply(e,g),(m=n.addedPeriods).push.apply(m,g.map((function(e){return e.getMetadataSnapshot()})))),n}(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],n=function(e,t){var n,r={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(0===e.length)return e.splice.apply(e,[0,0].concat(t)),(n=r.addedPeriods).push.apply(n,t.map((function(e){return e.getMetadataSnapshot()}))),r;if(0===t.length)return r;var i=e[e.length-1];if(i.start<t[0].start){var a;if(i.end!==t[0].start)throw new Me("MANIFEST_UPDATE_ERROR","Cannot perform partial update: not enough data");return e.push.apply(e,t),(a=r.addedPeriods).push.apply(a,t.map((function(e){return e.getMetadataSnapshot()}))),r}var o=B(e,(function(e){return e.id===t[0].id}));if(o<0)throw new Me("MANIFEST_UPDATE_ERROR","Cannot perform partial update: incoherent data");var s=Et(e[o],t[0],yt.Partial);r.updatedPeriods.push({period:m(e[o].getMetadataSnapshot(),{adaptations:void 0}),result:s});for(var u=o+1,l=1;l<t.length;l++){for(var d=t[l],c=-1,f=u;f<e.length;f++)if(d.id===e[f].id){c=f;break}if(c<0){for(var v,p=-1,h=u;h<e.length;h++)if(d.start<e[h].start){p=h;break}var g=p-u,y=e.splice(u,g,d);r.addedPeriods.push(d.getMetadataSnapshot()),(v=r.removedPeriods).push.apply(v,y.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}else{if(c>u){var _;T.warn("Manifest: old Periods not found in new when updating, removing");var b=e.splice(u,c-u);(_=r.removedPeriods).push.apply(_,b.map((function(e){return{id:e.id,start:e.start,end:e.end}}))),c=u}var S=Et(e[c],d,yt.Full);r.updatedPeriods.push({period:m(e[c].getMetadataSnapshot(),{adaptations:void 0}),result:S})}u++}if(u<e.length){var E;T.warn("Manifest: Ending Periods not found in new when updating, removing");var k=e.splice(u,e.length-u);(E=r.removedPeriods).push.apply(E,k.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}return r}(this.periods,e.periods);for(var r=this.getMinimumSafePosition();this.periods.length>0;){var i=this.periods[0];if(void 0===i.end||i.end>r)break;this.periods.shift()}}this.adaptations=void 0===this.periods[0]?{}:this.periods[0].adaptations,this.trigger("manifestUpdate",n)},t}(i);var It=At;function Rt(e){return e instanceof ke?new Pe("PIPELINE_LOAD_ERROR",e):Ne(e,{defaultCode:"PIPELINE_LOAD_ERROR",defaultReason:"Unknown error when fetching the Manifest"})}var xt=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="CustomLoaderError",a.message=n,a.canRetry=r,a.xhr=i,a}return f(t,e),t}(Y(Error));function Ct(e,t){var n;return new Promise((function(r,i){if(null!==e.cancellationError)return i(e.cancellationError);var a=!1;function o(e){void 0!==n&&n(),i(e)}n=t((function(t){e.deregister(o),a=!0,r(t)}),(function(t){e.deregister(o),a=!0,i(t)})),a||e.register(o)}))}function Mt(e,t){return Ct(t,(function(t){var n=setTimeout((function(){return t()}),e);return function(){return clearTimeout(n)}}))}var Pt=.3;function Dt(e){return e*((2*Math.random()-1)*Pt+1)}function Ot(e,t,n,r,i){return Nt.apply(this,arguments)}function Nt(){return Nt=d(p().mark((function e(t,n,r,i,a){var o,s,u,l,c,f,v,h,m,g,y,_,b;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(b=function(e){var t;if(0===c.size)return e[0];var n=ne();return null===(t=e.filter((function(e){var t;return!0!==(null===(t=c.get(e))||void 0===t?void 0:t.isBlacklisted)})).reduce((function(e,t){var r,i=null===(r=c.get(t))||void 0===r?void 0:r.blockedUntil;return void 0!==i&&i<=n&&(i=void 0),void 0===e?[t,i]:void 0===e[1]?e:void 0===i?[t,void 0]:i<e[1]?[t,i]:e}),void 0))||void 0===t?void 0:t[0]},_=function(e,t){var r=c.get(e);if(void 0===r||void 0===r.blockedUntil)return h(e);var i=ne(),o=r.blockedUntil-i;if(o<=0)return h(e);var s=new Z,u=s.linkToSignal(a);return new Promise((function(r,i){function l(e){u(),r(e)}function d(e){u(),i(e)}null==n||n.addEventListener("priorityChange",(function(){var n=v();if(a.isCancelled())throw a.cancellationError;if(void 0===n)return d(t);n!==e&&(s.cancel(),_(n,t).then(l,d))}),s.signal),Mt(o,s.signal).then((function(){return h(e).then(l,d)}),S)}))},y=function(){return(y=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=v(),!a.isCancelled()){e.next=3;break}throw a.cancellationError;case 3:if(void 0!==n){e.next=5;break}throw t;case 5:if(l(t),!a.isCancelled()){e.next=8;break}throw a.cancellationError;case 8:return e.abrupt("return",_(n,t));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)},g=function(e){return y.apply(this,arguments)},m=function(){return(m=d(p().mark((function e(t){var i,l,d,f,v;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r(t,a);case 3:return i=e.sent,e.abrupt("return",i);case 7:if(e.prev=7,e.t0=e.catch(0),!Z.isCancellationError(e.t0)){e.next=11;break}throw e.t0;case 11:if(null!==t&&null!==n&&n.downgradeCdn(t),void 0===(l=c.get(t))?(l={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},c.set(t,l)):l.errorCounter++,(p=e.t0)instanceof ke?p.type===Ae.ERROR_HTTP_CODE?p.status>=500||404===p.status||415===p.status||412===p.status:p.type===Ae.TIMEOUT||p.type===Ae.ERROR_EVENT:p instanceof xt?"boolean"==typeof p.canRetry?p.canRetry:void 0!==p.xhr&&(p.xhr.status>=500||404===p.xhr.status||415===p.xhr.status||412===p.xhr.status):Oe(p)&&"INTEGRITY_ERROR"===p.code){e.next=18;break}return l.blockedUntil=void 0,l.isBlacklisted=!0,e.abrupt("return",g(e.t0));case 18:return l.errorCounter>u?(l.blockedUntil=void 0,l.isBlacklisted=!0):(d=l.errorCounter,f=Math.min(o*Math.pow(2,d-1),s),v=Dt(f),l.blockedUntil=ne()+v),e.abrupt("return",g(e.t0));case 20:case"end":return e.stop()}var p}),e,null,[[0,7]])})))).apply(this,arguments)},h=function(e){return m.apply(this,arguments)},v=function(){if(null===t){var e=c.get(null);if(void 0!==e&&e.isBlacklisted)return;return null}if(null===n)return b(t);var r=n.getCdnPreferenceForResource(t);return b(r)},null===a.cancellationError){e.next=9;break}return e.abrupt("return",Promise.reject(a.cancellationError));case 9:if(o=i.baseDelay,s=i.maxDelay,u=i.maxRetry,l=i.onRetry,null!==t&&0===t.length&&T.warn("Fetchers: no CDN given to `scheduleRequestWithCdns`."),c=new Map,void 0!==(f=v())){e.next=15;break}throw new Error("No CDN to request");case 15:return e.abrupt("return",h(f));case 16:case"end":return e.stop()}}),e)}))),Nt.apply(this,arguments)}function Lt(e,t,n){return Ot(null,null,e,t,n)}function Ut(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ft(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ft(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ft(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Bt=function(e){function t(t,n,r){var i;return(i=e.call(this)||this).scheduleManualRefresh=S,i._manifestUrls=t,i._pipelines=n.manifest,i._settings=r,i._canceller=new Z,i._isStarted=!1,i._isRefreshPending=!1,i._consecutiveUnsafeMode=0,i._prioritizedContentUrl=null,i}f(t,e);var n=t.prototype;return n.dispose=function(){this._canceller.cancel(),this.removeEventListener()},n.start=function(){var e=this;if(!this._isStarted){this._isStarted=!0;var t=this._settings.initialManifest;(t instanceof It?Promise.resolve({manifest:t}):void 0!==t?this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):this._fetchManifest(void 0).then((function(e){return e.parse({previousManifest:null,unsafeMode:!1})}))).then((function(t){e.trigger("manifestReady",t.manifest),e._canceller.isUsed()||e._recursivelyRefreshManifest(t.manifest,t)})).catch((function(t){return e._onFatalError(t)}))}},n.updateContentUrls=function(e,t){var n;this._prioritizedContentUrl=null!==(n=null==e?void 0:e[0])&&void 0!==n?n:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})},n._fetchManifest=function(){var e=d(p().mark((function e(t){var n,r,i,a,o,s,u,l,d=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=function(e){var t=a.loadManifest,n=void 0===i.requestTimeout?b.getCurrent().DEFAULT_REQUEST_TIMEOUT:i.requestTimeout,o=void 0===i.connectionTimeout?b.getCurrent().DEFAULT_CONNECTION_TIMEOUT:i.connectionTimeout;n<0&&(n=void 0),o<0&&(o=void 0);return Lt((function(){return t(e,{timeout:n,connectionTimeout:o},r)}),s,r)},r=this._canceller.signal,i=this._settings,a=this._pipelines,o=null!=t?t:null===(n=this._manifestUrls)||void 0===n?void 0:n[0],s=this._getBackoffSetting((function(e){d.trigger("warning",Rt(e))})),e.prev=6,e.next=9,l(o);case 9:return u=e.sent,e.abrupt("return",{parse:function(e){return d._parseLoadedManifest(u,e,o)}});case 13:throw e.prev=13,e.t0=e.catch(6),Rt(e.t0);case 16:case"end":return e.stop()}}),e,this,[[6,13]])})));return function(t){return e.apply(this,arguments)}}(),n.parse=function(e,t,n){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,n)},n._parseLoadedManifest=function(){var e=d(p().mark((function e(t,n,r){var i,a,o,s,u,l,c,f,v,h,m,g,y,_,b,S,E,k=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(E=function(e,t){S(t);var n=ne()-a;return T.info("MF: Manifest parsed in "+n+"ms"),{manifest:e,sendingTime:u,receivedTime:l,parsingTime:n}},S=function(e){for(var t,n=Ut(e);!(t=n()).done;){var r=t.value;if(o.isCancelled())return;var i=Ne(r,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown error when parsing the Manifest"});s("warning",i)}},b=function(){return(b=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Lt(t,c,o);case 3:return n=e.sent,e.abrupt("return",n);case 7:throw e.prev=7,e.t0=e.catch(0),Rt(e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)},_=function(e){return b.apply(this,arguments)},a=ne(),o=this._canceller.signal,s=this.trigger.bind(this),u=t.sendingTime,l=t.receivedTime,c=this._getBackoffSetting((function(e){k.trigger("warning",Rt(e))})),f=null!=r?r:null===(i=this._manifestUrls)||void 0===i?void 0:i[0],v={externalClockOffset:n.externalClockOffset,unsafeMode:n.unsafeMode,previousManifest:n.previousManifest,originalUrl:f},e.prev=11,h=this._pipelines.parseManifest(t,v,S,o,_),h instanceof Promise){e.next=17;break}return e.abrupt("return",E(h.manifest,h.warnings));case 17:return e.next=19,h;case 19:return m=e.sent,g=m.manifest,y=m.warnings,e.abrupt("return",E(g,y));case 23:e.next=29;break;case 25:throw e.prev=25,e.t0=e.catch(11),Ne(e.t0,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown error when parsing the Manifest"});case 29:case"end":return e.stop()}}),e,this,[[11,25]])})));return function(t,n,r){return e.apply(this,arguments)}}(),n._getBackoffSetting=function(e){var t=b.getCurrent(),n=t.DEFAULT_MAX_MANIFEST_REQUEST_RETRY,r=t.INITIAL_BACKOFF_DELAY_BASE,i=t.MAX_BACKOFF_DELAY_BASE,a=this._settings,o=a.lowLatencyMode,s=a.maxRetry;return{onRetry:e,baseDelay:o?r.LOW_LATENCY:r.REGULAR,maxDelay:o?i.LOW_LATENCY:i.REGULAR,maxRetry:null!=s?s:n}},n._recursivelyRefreshManifest=function(e,t){var n=this,r=t.sendingTime,i=t.parsingTime,a=t.updatingTime,o=b.getCurrent(),s=o.MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE,u=o.MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE,l=void 0!==i?i+(null!=a?a:0):void 0,d=!1;this._consecutiveUnsafeMode>0?d=this._consecutiveUnsafeMode<s:void 0!==l&&(d=l>=u);var c=void 0===r?0:ne()-r,f=Math.max(this._settings.minimumManifestUpdateInterval-c,0),v=new Z;if(v.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=function(t){var i=t.enablePartialRefresh,a=t.delay,o=t.canUseUnsafeMode&&d,s=void 0===r?0:ne()-r,u=Math.max(n._settings.minimumManifestUpdateInterval-s,0),l=setTimeout((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:i,unsafeMode:o})}),Math.max((null!=a?a:0)-s,u));v.signal.register((function(){clearTimeout(l)}))},null!==e.expired){var p=setTimeout((function(){var t;null===(t=e.expired)||void 0===t||t.then((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})}),S)}),f);v.signal.register((function(){clearTimeout(p)}))}if(void 0!==e.lifetime&&e.lifetime>=0){var h,m=1e3*e.lifetime-c;void 0===l?h=m:e.lifetime<3&&l>=100?(h=Math.min(Math.max(3e3-c,Math.max(m,0)+l),6*m),T.info("MUS: Manifest update rythm is too frequent. Postponing next request.",m,h)):l>=1e3*e.lifetime/10?(h=Math.min(Math.max(m,0)+l,6*m),T.info("MUS: Manifest took too long to parse. Postponing next request",h,h)):h=m;var g=setTimeout((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})}),Math.max(h,f));v.signal.register((function(){clearTimeout(g)}))}},n._triggerNextManifestRefresh=function(e,t){var n,r,i=this,a=t.enablePartialRefresh,o=t.unsafeMode,s=e.updateUrl;null!==this._prioritizedContentUrl?(n=!0,r=this._prioritizedContentUrl,this._prioritizedContentUrl=null):r=(n=!a||void 0===s)?e.getUrls()[0]:s;var u=e.clockOffset;o?(this._consecutiveUnsafeMode+=1,T.info('Init: Refreshing the Manifest in "unsafeMode" for the '+String(this._consecutiveUnsafeMode)+" consecutive time.")):this._consecutiveUnsafeMode>0&&(T.info('Init: Not parsing the Manifest in "unsafeMode" anymore after '+String(this._consecutiveUnsafeMode)+" consecutive times."),this._consecutiveUnsafeMode=0),this._isRefreshPending||(this._isRefreshPending=!0,this._fetchManifest(r).then((function(t){return t.parse({externalClockOffset:u,previousManifest:e,unsafeMode:o})})).then((function(t){i._isRefreshPending=!1;var r=t.manifest,a=t.sendingTime,o=t.parsingTime,s=ne();if(n)e.replace(r);else try{e.update(r)}catch(t){var u=t instanceof Error?t.message:"unknown error";T.warn("MUS: Attempt to update Manifest failed: "+u,"Re-downloading the Manifest fully");var l=b.getCurrent().FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY,d=void 0===a?0:ne()-a,c=Math.max(i._settings.minimumManifestUpdateInterval-d,0),f=S,v=setTimeout((function(){f(),i._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})}),Math.max(l-d,c));return void(f=i._canceller.signal.register((function(){clearTimeout(v)})))}var p=ne()-s;i._recursivelyRefreshManifest(e,{sendingTime:a,parsingTime:o,updatingTime:p})})).catch((function(e){i._isRefreshPending=!1,i._onFatalError(e)})))},n._onFatalError=function(e){this._canceller.isUsed()||(this.trigger("error",e),this.dispose())},t}(i);var zt=Bt;function Vt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Kt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Kt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Wt=function(e){function t(t){var n;return(n=e.call(this)||this)._downgradedCdnList={metadata:[],timeouts:[]},t.register((function(){for(var e,t=Vt(n._downgradedCdnList.timeouts);!(e=t()).done;){var r=e.value;clearTimeout(r)}n._downgradedCdnList={metadata:[],timeouts:[]}})),n}f(t,e);var n=t.prototype;return n.getCdnPreferenceForResource=function(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)},n.downgradeCdn=function(e){var t=this,n=Gt(this._downgradedCdnList.metadata,e);n>=0&&this._removeIndexFromDowngradeList(n);var r=b.getCurrent().DEFAULT_CDN_DOWNGRADE_TIME;this._downgradedCdnList.metadata.push(e);var i=setTimeout((function(){var n=Gt(t._downgradedCdnList.metadata,e);n>=0&&t._removeIndexFromDowngradeList(n),t.trigger("priorityChange",null)}),r);this._downgradedCdnList.timeouts.push(i),this.trigger("priorityChange",null)},n._innerGetCdnPreferenceForResource=function(e){var t=this,n=e.reduce((function(e,n){return t._downgradedCdnList.metadata.some((function(e){return e.id===n.id&&e.baseUrl===n.baseUrl}))?e[1].push(n):e[0].push(n),e}),[[],[]]),r=n[0],i=n[1];return r.concat(i)},n._removeIndexFromDowngradeList=function(e){this._downgradedCdnList.metadata.splice(e,1);var t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])},t}(i);function Gt(e,t){return 0===e.length?-1:void 0!==t.id?B(e,(function(e){return e.id===t.id})):B(e,(function(e){return e.baseUrl===t.baseUrl}))}function jt(e,t){return e.segment.id===t.segment.id&&e.representation.uniqueId===t.representation.uniqueId}function Ht(e){if(t(e))return"";var n,r=e.period,i=e.adaptation,a=e.representation,o=e.segment;return n=o.isInit?"init":o.complete?o.time+"-"+o.duration:""+o.time,i.type+" P: "+r.id+" A: "+i.id+" R: "+a.id+" S: "+n}var qt=function(){function e(){this._cache=new WeakMap}var t=e.prototype;return t.add=function(e,t){var n=e.representation;e.segment.isInit&&this._cache.set(n,t)},t.get=function(e){var t=e.representation;if(e.segment.isInit){var n=this._cache.get(t);if(void 0!==n)return n}return null},e}(),Yt=Le();var Qt=function(){function e(e){var t=e.prioritySteps;if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=t,this._prioritySteps.high>=this._prioritySteps.low)throw new Error("TP: the max high level priority should be given a lowerpriority number than the min low priority.")}var t=e.prototype;return t.create=function(e,t,n,r){var i,a=this;return Ct(r,(function(o,s){return i={hasEnded:!1,priority:t,trigger:function(){if(!i.hasEnded){var e=function(){u(),a._endTask(i)},t=new Z,u=t.linkToSignal(r);i.interrupter=t,t.signal.register((function(){i.interrupter=null,r.isCancelled()||n.beforeInterrupted()})),a._minPendingPriority=null===a._minPendingPriority?i.priority:Math.min(a._minPendingPriority,i.priority),a._pendingTasks.push(i),i.taskFn(t.signal).then((function(t){n.beforeEnded(),e(),o(t)})).catch((function(n){!r.isCancelled()&&t.isUsed()&&n instanceof ee||function(t){e(),s(t)}(n)}))}},taskFn:e,interrupter:null},a._canBeStartedNow(i)?(i.trigger(),a._isRunningHighPriorityTasks()&&a._interruptCancellableTasks()):a._waitingQueue.push(i),function(){return a._endTask(i)}}))},t._endTask=function(e){e.hasEnded=!0;var t=$t(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{var n=$t(e.taskFn,this._pendingTasks);if(n<0)return;this._pendingTasks.splice(n,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}},t.updatePriority=function(e,t){var n=$t(e,this._waitingQueue);if(n>=0){var r=this._waitingQueue[n];if(r.priority===t)return;if(r.priority=t,!this._canBeStartedNow(r))return;return this._findAndRunWaitingQueueTask(n),void(this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks())}var i=$t(e,this._pendingTasks);if(i<0)T.warn("TP: request to update the priority of a non-existent task");else{var a=this._pendingTasks[i];if(a.priority!==t){var o=a.priority;a.priority=t,null===this._minPendingPriority||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(1===this._pendingTasks.length?this._minPendingPriority=t:this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority}))),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}}},t._loopThroughWaitingQueue=function(){var e=this._waitingQueue.reduce((function(e,t){return null===e||e>t.priority?t.priority:e}),null);if(!(null===e||null!==this._minPendingPriority&&this._minPendingPriority<e))for(var t=0;t<this._waitingQueue.length;t++){var n=null===this._minPendingPriority?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=n&&(this._findAndRunWaitingQueueTask(t),t--)}},t._interruptCancellableTasks=function(){for(var e=0;e<this._pendingTasks.length;e++){var t=this._pendingTasks[e];if(t.priority>=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}},t._findAndRunWaitingQueueTask=function(e){return e>=this._waitingQueue.length||e<0?(T.warn("TP : Tried to start a non existing task"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)},t._interruptPendingTask=function(e){var t,n=$t(e.taskFn,this._pendingTasks);n<0?T.warn("TP: Interrupting a non-existent pending task. Aborting..."):(this._pendingTasks.splice(n,1),this._waitingQueue.push(e),0===this._pendingTasks.length?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))),null===(t=e.interrupter)||void 0===t||t.cancel())},t._canBeStartedNow=function(e){return null===this._minPendingPriority||e.priority<=this._minPendingPriority},t._isRunningHighPriorityTasks=function(){return null!==this._minPendingPriority&&this._minPendingPriority<=this._prioritySteps.high},e}();function $t(e,t){return B(t,(function(t){return t.taskFn===e}))}var Xt=function(){function e(e,t,n){var r=new Wt(n),i=b.getCurrent(),a=i.MIN_CANCELABLE_PRIORITY,o=i.MAX_HIGH_PRIORITY_LEVEL;this._transport=e,this._prioritizer=new Qt({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=r,this._backoffOptions=t}return e.prototype.createSegmentFetcher=function(e,n){var r,i,a,o,s,u,l,c,f,v,h,g,y,_,S=(r=this._backoffOptions,i=r.maxRetry,a=r.lowLatencyMode,o=r.requestTimeout,s=r.connectionTimeout,u=b.getCurrent(),l=u.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,c=u.DEFAULT_REQUEST_TIMEOUT,f=u.DEFAULT_CONNECTION_TIMEOUT,v=u.INITIAL_BACKOFF_DELAY_BASE,h=u.MAX_BACKOFF_DELAY_BASE,{maxRetry:null!=i?i:l,baseDelay:a?v.LOW_LATENCY:v.REGULAR,maxDelay:a?h.LOW_LATENCY:h.REGULAR,requestTimeout:void 0===o?c:o,connectionTimeout:void 0===s?f:s}),E=function(e,n,r,i,a){var o;o=void 0===a.connectionTimeout||a.connectionTimeout<0?void 0:a.connectionTimeout;var s={timeout:a.requestTimeout<0?void 0:a.requestTimeout,connectionTimeout:o},u=Ue(["audio","video"],e)?new qt:void 0,l=n.loadSegment,c=n.parseSegment;return function(){var e=d(p().mark((function e(n,o,d){var f,v,h,g,y,_,b,S,E,k,w,A,I,R,x,C,M,P,D,O,N,L,U,F;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(F=function(){var e;R||!t(w)&&void 0!==w.size&&void 0!==w.requestDuration&&A.length>0&&A.every((function(e){return e}))&&(R=!0,null===(e=i.onMetrics)||void 0===e||e.call(i,{size:w.size,requestDuration:w.requestDuration,content:n,segmentDuration:I}))},U=function(e){o.onRetry(Rt(e))},L=function(e,t){A.push(!1);var n=A.length-1;return function(r){var i={data:e,isChunked:t};try{var a=c(i,x,r);return A[n]||(I=void 0!==I&&"media"===a.segmentType&&null!==a.chunkInfos&&void 0!==a.chunkInfos.duration?I+a.chunkInfos.duration:void 0,A[n]=!0,F()),a}catch(e){throw Ne(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown parsing error"})}}},N=function(e){return l(e,x,s,d,C)},O=function(){var e;void 0===w&&(T.debug("SF: Segment request cancelled",E),w=null,null===(e=i.onRequestEnd)||void 0===e||e.call(i,{id:k}))},g=n.segment,y=n.adaptation,_=n.representation,b=n.manifest,S=n.period,E=Ht(n),k=Yt(),A=[],I=0,R=!1,x={segment:g,type:y.type,language:y.language,isLive:b.isLive,periodStart:S.start,periodEnd:S.end,mimeType:_.mimeType,codecs:_.codecs[0],manifestPublishTime:b.publishTime},C={onProgress:function(e){var t;void 0===w&&void 0!==e.totalSize&&e.size<e.totalSize&&(null===(t=i.onProgress)||void 0===t||t.call(i,{duration:e.duration,size:e.size,totalSize:e.totalSize,timestamp:ne(),id:k}))},onNewChunk:function(e){o.onChunk(L(e,!0))}},null===(M=void 0!==u?u.get(n):null)){e.next=18;break}return T.debug("SF: Found wanted segment in cache",E),o.onChunk(L(M,!1)),e.abrupt("return",Promise.resolve());case 18:return T.debug("SF: Beginning request",E),null===(f=i.onRequestBegin)||void 0===f||f.call(i,{requestTimestamp:ne(),id:k,content:n}),d.register(O),e.prev=21,e.next=24,Ot(n.representation.cdnMetadata,r,N,m({onRetry:U},a),d);case 24:"segment-loaded"===(P=e.sent).resultType?(D=P.resultData.responseData,void 0!==u&&u.add(n,P.resultData.responseData),o.onChunk(L(D,!1))):"segment-created"===P.resultType&&o.onChunk(L(P.resultData,!1)),T.debug("SF: Segment request ended with success",E),o.onAllChunksReceived(),"segment-created"!==P.resultType?(w=P.resultData,F()):w=null,d.isCancelled()||null===(v=i.onRequestEnd)||void 0===v||v.call(i,{id:k}),d.deregister(O),e.next=43;break;case 33:if(e.prev=33,e.t0=e.catch(21),d.deregister(O),w=null,!(e.t0 instanceof ee)){e.next=40;break}throw T.debug("SF: Segment request aborted",E),e.t0;case 40:throw T.debug("SF: Segment request failed",E),null===(h=i.onRequestEnd)||void 0===h||h.call(i,{id:k}),Rt(e.t0);case 43:case"end":return e.stop()}}),e,null,[[21,33]])})));return function(t,n,r){return e.apply(this,arguments)}}()}(e,this._transport[e],this._cdnPrioritizer,n,S);return g=this._prioritizer,y=E,_=new WeakMap,{createRequest:function(e,t,n,r){var i=function(t){return y(e,n,t)},a=g.create(i,t,n,r);return _.set(a,i),a},updatePriority:function(e,t){var n=_.get(e);void 0!==n?g.updatePriority(n,t):T.warn("Fetchers: Cannot update the priority of a request: task not found.")}}},e}(),Zt=Xt,Jt=function(){function e(e){this._array=[],this._sortingFn=e}var t=e.prototype;return t.add=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.sort(this._sortingFn);for(var r=0,i=0;i<t.length;i++){for(var a=t[i],o=!1;!o&&r<this._array.length;)this._sortingFn(a,this._array[r])<0?(this._array.splice(r,0,a),o=!0):r++;o||this._array.push(a)}},t.length=function(){return this._array.length},t.get=function(e){if(e<0||e>=this._array.length)throw new Error("Invalid index.");return this._array[e]},t.toArray=function(){return this._array.slice()},t.findFirst=function(e){return ae(this._array,e)},t.has=function(e){return Ue(this._array,e)},t.removeElement=function(e){var t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t},t.head=function(){return this._array[0]},t.last=function(){return this._array[this._array.length-1]},t.shift=function(){return this._array.shift()},t.pop=function(){return this._array.pop()},e}();function en(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return tn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function tn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var nn=function(e){function t(t,n,r){var i;(i=e.call(this)||this)._canceller=new Z,i._manifest=t,i._activeStreams=new Map,i._allBufferTypes=r,i._lastCurrentPeriodId=null;var a=new rn(t);i._maximumPositionCalculator=a;var o=i._canceller.signal;return n.listen((function(e){var n=e.position.getWanted();if(n<t.getMinimumSafePosition()){var r=new Me("MEDIA_TIME_BEFORE_MANIFEST","The current position is behind the earliest time announced in the Manifest.");i.trigger("warning",r)}else if(n>a.getMaximumAvailablePosition()){var o=new Me("MEDIA_TIME_AFTER_MANIFEST","The current position is after the latest time announced in the Manifest.");i.trigger("warning",o)}}),{includeLastObservation:!0,clearSignal:o}),t.addEventListener("manifestUpdate",(function(){i.trigger("endingPositionChange",i._getManifestEndTime()),o.isCancelled()||i._checkEndOfStream()}),o),i}f(t,e);var n=t.prototype;return n.getCurrentEndingTime=function(){return this._getManifestEndTime()},n.onAdaptationChange=function(e,t,n){if(this._manifest.isLastPeriodKnown){var r=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(null==r?void 0:r.id)&&("audio"===e||"video"===e)){"audio"===e?this._maximumPositionCalculator.updateLastAudioAdaptation(n):this._maximumPositionCalculator.updateLastVideoAdaptation(n);var i=this._maximumPositionCalculator.getEndingPosition(),a=void 0!==i?{isEnd:!0,endingPosition:i}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger("endingPositionChange",a)}}this._canceller.isUsed()||null===n&&this._addActivelyLoadedPeriod(t,e)},n.onRepresentationChange=function(e,t){this._addActivelyLoadedPeriod(t,e)},n.onPeriodCleared=function(e,t){this._removeActivelyLoadedPeriod(t,e)},n.onLastSegmentFinishedLoading=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())},n.onLastSegmentLoadingResume=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())},n.dispose=function(){this.removeEventListener(),this._canceller.cancel()},n._addActivelyLoadedPeriod=function(e,t){var n=this._lazilyCreateActiveStreamInfo(t);n.activePeriods.has(e)||(n.activePeriods.add(e),this._checkCurrentPeriod())},n._removeActivelyLoadedPeriod=function(e,t){var n=this._activeStreams.get(t);void 0!==n&&n.activePeriods.has(e)&&(n.activePeriods.removeElement(e),this._checkCurrentPeriod())},n._checkCurrentPeriod=function(){var e=this;if(0!==this._allBufferTypes.length){var t=this._activeStreams.get(this._allBufferTypes[0]);if(void 0!==t)for(var n,r,i=function(){for(var t=r.value,n=!0,i=1;i<e._allBufferTypes.length;i++){var a=e._activeStreams.get(e._allBufferTypes[i]);if(void 0===a)return{v:void 0};if(!a.activePeriods.toArray().some((function(e){return e.id===t.id}))){n=!1;break}}if(n)return e._lastCurrentPeriodId!==t.id&&(e._lastCurrentPeriodId=t.id,e.trigger("periodChange",t)),{v:void 0}},a=en(t.activePeriods.toArray());!(r=a()).done;)if(n=i())return n.v}},n._getManifestEndTime=function(){var e=this._maximumPositionCalculator.getEndingPosition();return void 0!==e?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}},n._lazilyCreateActiveStreamInfo=function(e){var t=this._activeStreams.get(e);return void 0===t&&(t={activePeriods:new Jt((function(e,t){return e.start-t.start})),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t},n._checkEndOfStream=function(){var e=this;this._manifest.isLastPeriodKnown&&(this._allBufferTypes.every((function(t){var n=e._activeStreams.get(t);return void 0!==n&&n.hasFinishedLoadingLastPeriod}))?this.trigger("endOfStream",null):this.trigger("resumeStream",null))},t}(i),rn=function(){function e(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}var t=e.prototype;return t.updateLastAudioAdaptation=function(e){this._lastAudioAdaptation=e},t.updateLastVideoAdaptation=function(e){this._lastVideoAdaptation=e},t.getMaximumAvailablePosition=function(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(void 0===this._lastVideoAdaptation||void 0===this._lastAudioAdaptation)return this._manifest.getMaximumSafePosition();if(null===this._lastAudioAdaptation){if(null===this._lastVideoAdaptation)return this._manifest.getMaximumSafePosition();var e=an(this._lastVideoAdaptation);return"number"!=typeof e?this._manifest.getMaximumSafePosition():e}if(null===this._lastVideoAdaptation){var t=an(this._lastAudioAdaptation);return"number"!=typeof t?this._manifest.getMaximumSafePosition():t}var n=an(this._lastAudioAdaptation),r=an(this._lastVideoAdaptation);return"number"!=typeof n||"number"!=typeof r?this._manifest.getMaximumSafePosition():Math.min(n,r)},t.getEndingPosition=function(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(void 0!==this._lastVideoAdaptation&&void 0!==this._lastAudioAdaptation){if(null===this._lastAudioAdaptation)return null===this._lastVideoAdaptation?void 0:null!==(e=on(this._lastVideoAdaptation))&&void 0!==e?e:void 0;if(null===this._lastVideoAdaptation)return null!==(t=on(this._lastAudioAdaptation))&&void 0!==t?t:void 0;var n=on(this._lastAudioAdaptation),r=on(this._lastVideoAdaptation);return"number"!=typeof n||"number"!=typeof r?void 0:Math.min(n,r)}},e}();function an(e){for(var n,r=e.representations,i=null,a=0;a<r.length;a++)if(r[a].index!==n){n=r[a].index;var o=r[a].index.getLastAvailablePosition();if(void 0===o)return;null!==o&&(i=t(i)?o:Math.min(i,o))}return i}function on(e){for(var n,r=e.representations,i=null,a=0;a<r.length;a++)if(r[a].index!==n){n=r[a].index;var o=r[a].index.getEnd();if(void 0===o)return;null!==o&&(i=t(i)?o:Math.min(i,o))}return i}function sn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return un(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return un(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function un(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ln=function(){function e(e){this._segmentSinksStore=e,this._currentFreezeTimestamp=null}return e.prototype.needToReload=function(e){var t=e.readyState,n=e.rebuffering,r=e.freezing;if((void 0!==e.bufferGap&&isFinite(e.bufferGap)?e.bufferGap:0)<6||null===n&&null===r||t>1)return this._currentFreezeTimestamp=null,!1;var i=ne();null===this._currentFreezeTimestamp&&(this._currentFreezeTimestamp=i);var a=null!==n&&i-n.timestamp>4e3,o=null!==r&&i-r.timestamp>4e3;if((a||o)&&ne()-this._currentFreezeTimestamp>4e3){for(var s=!0,u=!0,l=0,d=[this._segmentSinksStore.getStatus("audio"),this._segmentSinksStore.getStatus("video")];l<d.length;l++){var c=d[l];if("initialized"===c.type)for(var f,v=sn(c.value.getLastKnownInventory());!(f=v()).done;){var p=f.value.infos.representation;if(!1===p.decipherable)return T.warn("Init: we have undecipherable segments left in the buffer, reloading"),this._currentFreezeTimestamp=null,!0;void 0!==p.contentProtections&&(u=!1,!0!==p.decipherable&&(s=!1))}}if(!u&&s)return T.warn("Init: we are frozen despite only having decipherable segments left in the buffer, reloading"),this._currentFreezeTimestamp=null,!0}return!1},e}();function dn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var fn=function(){function e(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}var t=e.prototype;return t.addBufferedSegment=function(e,t){var n=ne();this._history.push({date:n,buffered:t,context:e}),this._cleanHistory(n)},t.getHistoryFor=function(e){return this._history.filter((function(t){return jt(t.context,e)}))},t._cleanHistory=function(e){for(var t,n=e-this._lifetime,r=0,i=dn(this._history);!(t=i()).done;){if(!(t.value.date<n))break;r++}if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){var a=this._history.length-this._maxHistoryLength;this._history=this._history.splice(a)}},e}();function vn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return pn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var hn=function(){function e(){var e=b.getCurrent(),t=e.BUFFERED_HISTORY_RETENTION_TIME,n=e.BUFFERED_HISTORY_MAXIMUM_ENTRIES;this._inventory=[],this._bufferedHistory=new fn(t,n)}var n=e.prototype;return n.reset=function(){this._inventory.length=0},n.synchronizeBuffered=function(e){for(var n,r,i,a,o,s,u,l=this._inventory,d=0,c=l[0],f=b.getCurrent().MINIMUM_SEGMENT_SIZE,v=null==c?void 0:c.infos.adaptation.type,p=e.length,h=0;h<p;h++){if(void 0===c)return;var m=e[h].start,g=e[h].end;if(g-m<f)T.warn("SI: skipped range when synchronizing because it was too small",v,m,g);else{for(var y=d;void 0!==c&&(null!==(n=c.bufferedEnd)&&void 0!==n?n:c.end)-m<f;)c=l[++d];var _=null,S=d-y;if(S>0){var E=l[y+S-1];_={end:null!==(r=E.bufferedEnd)&&void 0!==r?r:E.end,precizeEnd:E.precizeEnd},T.debug("SI: "+S+" segments GCed.",v);for(var k,w=vn(l.splice(y,S));!(k=w()).done;){var A=k.value;void 0===A.bufferedStart&&void 0===A.bufferedEnd&&2!==A.status&&this._bufferedHistory.addBufferedSegment(A.infos,null)}d=y}if(void 0===c)return;if(g-(null!==(i=c.bufferedStart)&&void 0!==i?i:c.start)>=f){if(yn(c,m,_,v),d===l.length-1)return void _n(c,g,v);for(var I=null!==(a=(c=l[++d]).bufferedStart)&&void 0!==a?a:c.start,R=null!==(o=c.bufferedEnd)&&void 0!==o?o:c.end,x=h<p-1?e[h+1].start:void 0;void 0!==c&&g-I>=f&&(void 0===x||g-I>=R-x);){var C=l[d-1];void 0===C.bufferedEnd&&(C.bufferedEnd=c.precizeStart?c.start:C.end,T.debug("SI: calculating buffered end of contiguous segment",v,C.bufferedEnd,C.end)),c.bufferedStart=C.bufferedEnd,void 0!==(c=l[++d])&&(I=null!==(s=c.bufferedStart)&&void 0!==s?s:c.start,R=null!==(u=c.bufferedEnd)&&void 0!==u?u:c.end)}}var M=l[d-1];void 0!==M&&_n(M,g,v)}}if(!t(c)){T.debug("SI: last segments have been GCed",v,d,l.length);for(var P,D=vn(l.splice(d,l.length-d));!(P=D()).done;){var O=P.value;void 0===O.bufferedStart&&void 0===O.bufferedEnd&&2!==O.status&&this._bufferedHistory.addBufferedSegment(O.infos,null)}}void 0!==v&&T.hasLevel("DEBUG")&&T.debug("SI: current "+v+" inventory timeline:\n"+function(e){var t=1/60,n={},r=[],i=null,a=null;function o(e){var t=String.fromCharCode(r.length+65);return r.push({letter:t,periodId:e.period.id,representationId:e.representation.id,bitrate:e.representation.bitrate}),t}for(var s="",u=0;u<e.length;u++){var l=e[u];if(void 0!==l.bufferedStart&&void 0!==l.bufferedEnd){var d,c=l.infos.period.id,f=l.infos.representation.id,v=n[c],p=void 0;if(void 0===v)p=o(l.infos),n[c]=((d={})[f]=p,d);else void 0===v[f]?(p=o(l.infos),v[f]=p):p=v[f];null===i?s+=l.bufferedStart.toFixed(2)+"|"+p+"|":a===p?i.bufferedEnd+t<l.bufferedStart&&(s+=i.bufferedEnd.toFixed(2)+" ~ "+l.bufferedStart.toFixed(2)+"|"+p+"|"):s+=i.bufferedEnd.toFixed(2)+" ~ "+l.bufferedStart.toFixed(2)+"|"+p+"|",i=l,a=p}}null!==i&&(s+=String(i.end.toFixed(2)));return r.forEach((function(e){var t;s+="\n["+e.letter+"] P: "+e.periodId+" || R: "+e.representationId+"("+(null!==(t=e.bitrate)&&void 0!==t?t:"unknown bitrate")+")"})),s}(this._inventory))},n.insertChunk=function(e,t,n){var r=e.period,i=e.adaptation,a=e.representation,o=e.segment,s=e.chunkSize,u=e.start,l=e.end;if(!o.isInit){var d=i.type;if(u>=l)T.warn("SI: Invalid chunked inserted: starts before it ends",d,u,l);else{for(var c=this._inventory,f={status:t?0:2,insertionTs:n,chunkSize:s,splitted:!1,start:u,end:l,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:o,period:r,adaptation:i,representation:a}},v=c.length-1;v>=0;v--){var p=c[v];if(p.start<=u){if(p.end<=u){for(T.debug("SI: Pushing segment strictly after previous one.",d,u,p.end),this._inventory.splice(v+1,0,f),v+=2;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return T.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);T.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}if(p.start===u){if(p.end<=l){for(T.debug("SI: Segment pushed replace another one",d,u,l,p.end),this._inventory.splice(v,1,f),v+=1;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return T.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);T.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}return T.debug("SI: Segment pushed ends before another with the same start",d,u,l,p.end),c.splice(v,0,f),p.start=f.end,p.bufferedStart=void 0,void(p.precizeStart=p.precizeStart&&f.precizeEnd)}if(p.end<=f.end){for(T.debug("SI: Segment pushed updates end of previous one",d,u,l,p.start,p.end),this._inventory.splice(v+1,0,f),p.end=f.start,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&f.precizeStart,v+=2;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return T.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);T.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}T.warn("SI: Segment pushed is contained in a previous one",d,u,l,p.start,p.end);var h={status:p.status,insertionTs:p.insertionTs,chunkSize:p.chunkSize,splitted:!0,start:f.end,end:p.end,precizeStart:p.precizeStart&&p.precizeEnd&&f.precizeEnd,precizeEnd:p.precizeEnd,bufferedStart:void 0,bufferedEnd:p.end,infos:p.infos};return p.end=f.start,p.splitted=!0,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&f.precizeStart,c.splice(v+1,0,f),void c.splice(v+2,0,h)}}var m=this._inventory[0];if(void 0===m)return T.debug("SI: first segment pushed",d,u,l),void this._inventory.push(f);if(!(m.start>=l)){if(m.end<=l){for(T.debug("SI: Segment pushed starts before and completely recovers the previous first one",d,u,l,m.start,m.end),this._inventory.splice(0,1,f);c.length>1&&c[1].start<f.end;){if(c[1].end>f.end)return T.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[1].start),c[1].start=f.end,c[1].bufferedStart=void 0,void(c[1].precizeStart=f.precizeEnd);T.debug("SI: Segment pushed removes the next one",d,u,l,c[1].start,c[1].end),c.splice(1,1)}return}return T.debug("SI: Segment pushed start of the next one",d,u,l,m.start,m.end),m.start=l,m.bufferedStart=void 0,m.precizeStart=f.precizeEnd,void this._inventory.splice(0,0,f)}T.debug("SI: Segment pushed comes before all previous ones",d,u,l,m.start),this._inventory.splice(0,0,f)}}},n.completeSegment=function(e){if(!e.segment.isInit){for(var t=this._inventory,n=[],r=0;r<t.length;r++)if(jt(t[r].infos,e)){var i=!1;n.length>0&&(i=!0,1===n.length&&(T.warn("SI: Completed Segment is splitted.",e.segment.id,e.segment.time,e.segment.end),n[0].splitted=!0));var a=r,o=t[r].chunkSize;for(r+=1;r<t.length&&jt(t[r].infos,e);){var s=t[r].chunkSize;void 0!==o&&void 0!==s&&(o+=s),r++}var u=r-1,l=u-a,d=t[u].end,c=t[u].bufferedEnd;l>0&&(this._inventory.splice(a+1,l),r-=l),0===this._inventory[a].status&&(this._inventory[a].status=1),this._inventory[a].chunkSize=o,this._inventory[a].end=d,this._inventory[a].bufferedEnd=c,this._inventory[a].splitted=i,n.push(this._inventory[a])}if(0===n.length)T.warn("SI: Completed Segment not found",e.segment.id,e.segment.time);else for(var f,v=vn(n);!(f=v()).done;){var p=f.value;void 0!==p.bufferedStart&&void 0!==p.bufferedEnd?2!==p.status&&this._bufferedHistory.addBufferedSegment(p.infos,{start:p.bufferedStart,end:p.bufferedEnd}):T.debug("SI: buffered range not known after sync. Skipping history.",p.start,p.end)}}},n.getInventory=function(){return this._inventory},n.getHistoryFor=function(e){return this._bufferedHistory.getHistoryFor(e)},e}();function mn(e){if(void 0===e.bufferedStart||1!==e.status)return!1;var t=e.start,n=e.end-t,r=b.getCurrent(),i=r.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,a=r.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(t-e.bufferedStart)<=i&&(void 0===e.bufferedEnd||e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-n)<=Math.min(a,n/3))}function gn(e){if(void 0===e.bufferedEnd||1!==e.status)return!1;var t=e.start,n=e.end,r=n-t,i=b.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(n-e.bufferedEnd)<=a&&void 0!==e.bufferedStart&&e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-r)<=Math.min(o,r/3)}function yn(e,t,n,r){var i=b.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MISSING_DATA_TRIGGER_SYNC_DELAY,s=i.SEGMENT_SYNCHRONIZATION_DELAY;if(void 0!==e.bufferedStart)e.bufferedStart<t&&(T.debug("SI: Segment partially GCed at the start",r,e.bufferedStart,t),e.bufferedStart=t),!e.precizeStart&&mn(e)&&(e.start=e.bufferedStart,e.precizeStart=!0);else if(e.precizeStart)T.debug("SI: buffered start is precize start",r,e.start),e.bufferedStart=e.start;else if(null!==n&&n.end>t&&(n.precizeEnd||e.start-n.end<=a))T.debug("SI: buffered start is end of previous segment",r,t,e.start,n.end),e.bufferedStart=n.end,mn(e)&&(e.start=n.end,e.precizeStart=!0);else if(e.start-t<=a){var u=ne();if(e.start-t>=o&&u-e.insertionTs<s)return void T.debug("SI: Ignored bufferedStart synchronization",r,t,e.start,u-e.insertionTs);T.debug("SI: found true buffered start",r,t,e.start),e.bufferedStart=t,mn(e)&&(e.start=t,e.precizeStart=!0)}else if(t<e.start)T.debug("SI: range start too far from expected start",r,t,e.start),e.bufferedStart=e.start;else{var l=ne();if(e.start-t>=o&&l-e.insertionTs<s)return void T.debug("SI: Ignored bufferedStart synchronization",r,t,e.start,l-e.insertionTs);T.debug("SI: Segment appears immediately garbage collected at the start",r,t,e.start),e.bufferedStart=t}}function _n(e,t,n){var r=b.getCurrent(),i=r.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,a=r.MISSING_DATA_TRIGGER_SYNC_DELAY,o=r.SEGMENT_SYNCHRONIZATION_DELAY;if(void 0!==e.bufferedEnd)e.bufferedEnd>t&&(T.debug("SI: Segment partially GCed at the end",n,e.bufferedEnd,t),e.bufferedEnd=t),!e.precizeEnd&&t-e.end<=i&&gn(e)&&(e.precizeEnd=!0,e.end=t);else if(e.precizeEnd)T.debug("SI: buffered end is precize end",n,e.end),e.bufferedEnd=e.end;else if(t-e.end<=i){var s=ne();if(t-e.end>=a&&s-e.insertionTs<o)return void T.debug("SI: Ignored bufferedEnd synchronization",n,t,e.end,s-e.insertionTs);T.debug("SI: found true buffered end",n,t,e.end),e.bufferedEnd=t,gn(e)&&(e.end=t,e.precizeEnd=!0)}else if(t>e.end)T.debug("SI: range end too far from expected end",n,t,e.end),e.bufferedEnd=e.end;else{var u=ne();if(t-e.end>=a&&u-e.insertionTs<o)return void T.debug("SI: Ignored bufferedEnd synchronization",n,t,e.end,u-e.insertionTs);T.debug("SI: Segment appears immediately garbage collected at the end",n,e.bufferedEnd,t),e.bufferedEnd=t}}var bn,Sn=hn,En=function(){function e(){this._segmentInventory=new Sn}var t=e.prototype;return t.synchronizeInventory=function(e){this._segmentInventory.synchronizeBuffered(e)},t.getLastKnownInventory=function(){return this._segmentInventory.getInventory()},t.getSegmentHistory=function(e){return this._segmentInventory.getHistoryFor(e)},e}();!function(e){e[e.Push=0]="Push",e[e.Remove=1]="Remove",e[e.SignalSegmentComplete=2]="SignalSegmentComplete"}(bn||(bn={}));var Tn=function(e){function t(t,n,r){var i;i=e.call(this)||this,T.info("AVSB: calling `mediaSource.addSourceBuffer`",n);var a=r.addSourceBuffer(t,n);return i.bufferType=t,i._sourceBuffer=a,i._lastInitSegmentUniqueId=null,i.codec=n,i._initSegmentsMap=new Map,i._pendingOperations=[],i}f(t,e);var n=t.prototype;return n.declareInitSegment=function(e,t){kn(t),this._initSegmentsMap.set(e,t)},n.freeInitSegment=function(e){this._initSegmentsMap.delete(e)},n.pushChunk=function(){var e=d(p().mark((function e(t){var n,r,i,a,o=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return kn(t.data.chunk),T.debug("AVSB: receiving order to push data to the SourceBuffer",this.bufferType,Ht(t.inventoryInfos)),0===(n=this._getActualDataToPush(t.data)).length&&n.push(new Uint8Array),r=Promise.all(n.map((function(e){var n=t.data,r=n.codec,i=n.timestampOffset,a=n.appendWindow;return T.debug("AVSB: pushing segment",o.bufferType,Ht(t.inventoryInfos)),o._sourceBuffer.appendBuffer(e,{codec:r,timestampOffset:i,appendWindow:a})}))),this._addToOperationQueue(r,{type:bn.Push,value:t}),e.prev=6,e.next=9,r;case 9:i=e.sent,e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(6),this._segmentInventory.insertChunk(t.inventoryInfos,!1,ne()),e.t0;case 16:return null!==t.inventoryInfos&&this._segmentInventory.insertChunk(t.inventoryInfos,!0,ne()),a=i[i.length-1],this._segmentInventory.synchronizeBuffered(a),e.abrupt("return",a);case 20:case"end":return e.stop()}}),e,this,[[6,12]])})));return function(t){return e.apply(this,arguments)}}(),n.removeBuffer=function(){var e=d(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.debug("AVSB: receiving order to remove data from the SourceBuffer",this.bufferType,t,n),r=this._sourceBuffer.remove(t,n),this._addToOperationQueue(r,{type:bn.Remove,value:{start:t,end:n}}),e.next=5,r;case 5:return i=e.sent,this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.signalSegmentComplete=function(){var e=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._pendingOperations.length>0)){e.next=10;break}return n=this._pendingOperations[this._pendingOperations.length-1].promise,this._addToOperationQueue(n,{type:bn.SignalSegmentComplete,value:t}),e.prev=3,e.next=6,n;case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:this._segmentInventory.completeSegment(t);case 11:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(t){return e.apply(this,arguments)}}(),n.getPendingOperations=function(){return this._pendingOperations.map((function(e){return e.operation}))},n.dispose=function(){try{T.debug("AVSB: Calling `dispose` on the SourceBufferInterface"),this._sourceBuffer.dispose()}catch(e){T.debug("AVSB: Failed to dispose a "+this.bufferType+" SourceBufferInterface:",e instanceof Error?e:"")}},n._getActualDataToPush=function(e){var t=[];if(null!==e.initSegmentUniqueId&&!this._isLastInitSegment(e.initSegmentUniqueId)){var n=this._initSegmentsMap.get(e.initSegmentUniqueId);if(void 0===n)throw new Error("Invalid initialization segment uniqueId");var r=new ArrayBuffer(n.byteLength),i=new Uint8Array(r);i.set(n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)),n=i,t.push(n),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return null!==e.chunk&&t.push(e.chunk),t},n._isLastInitSegment=function(e){return null!==this._lastInitSegmentUniqueId&&this._lastInitSegmentUniqueId===e},n._addToOperationQueue=function(e,t){var n=this,r={operation:t,promise:e};this._pendingOperations.push(r);var i=function(){var e=n._pendingOperations.indexOf(r);e>=0&&n._pendingOperations.splice(e,1)};e.then(i,i)},t}(En);function kn(e){}var wn=Tn,An=function(e){function t(t){var n;return T.debug("HTSB: Creating TextSegmentSink"),(n=e.call(this)||this).bufferType="text",n._sender=t,n._pendingOperations=[],n._sender.reset(),n}f(t,e);var n=t.prototype;return n.declareInitSegment=function(e){T.warn("HTSB: Declaring initialization segment for Text SegmentSink",e)},n.freeInitSegment=function(e){T.warn("HTSB: Freeing initialization segment for Text SegmentSink",e)},n.pushChunk=function(){var e=d(p().mark((function e(t){var n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return In((n=t.data).chunk),r=this._sender.pushTextData(Object.assign(Object.assign({},n),{chunk:n.chunk})),this._addToOperationQueue(r,{type:bn.Push,value:t}),e.next=6,r;case 6:return i=e.sent,null!==t.inventoryInfos&&this._segmentInventory.insertChunk(t.inventoryInfos,!0,ne()),this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.removeBuffer=function(){var e=d(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._sender.remove(t,n),this._addToOperationQueue(r,{type:bn.Remove,value:{start:t,end:n}}),e.next=4,r;case 4:return i=e.sent,this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.signalSegmentComplete=function(){var e=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._pendingOperations.length>0)){e.next=10;break}return n=this._pendingOperations[this._pendingOperations.length-1].promise,this._addToOperationQueue(n,{type:bn.SignalSegmentComplete,value:t}),e.prev=3,e.next=6,n;case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:this._segmentInventory.completeSegment(t);case 11:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(t){return e.apply(this,arguments)}}(),n.getPendingOperations=function(){return this._pendingOperations.map((function(e){return e.operation}))},n.dispose=function(){T.debug("HTSB: Disposing TextSegmentSink"),this._sender.reset()},n._addToOperationQueue=function(e,t){var n=this,r={operation:t,promise:e};this._pendingOperations.push(r);var i=function(){var e=n._pendingOperations.indexOf(r);e>=0&&n._pendingOperations.splice(e,1)};e.then(i,i)},t}(En);function In(e){}var Rn=An,xn=["audio","video","text"];function Cn(e){return"audio"===e||"video"===e}var Mn=function(){function e(e,t,n){this._mediaSource=e,this._textInterface=n,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}e.isNative=function(e){return Cn(e)};var n=e.prototype;return n.getBufferTypes=function(){var e=this.getNativeBufferTypes();return null!==this._textInterface&&e.push("text"),e},n.getNativeBufferTypes=function(){return this._hasVideo?["video","audio"]:["audio"]},n.getStatus=function(e){var t=this._initializedSegmentSinks[e];return void 0===t?{type:"uninitialized"}:null===t?{type:"disabled"}:{type:"initialized",value:t}},n.waitForUsableBuffers=function(e){var t=this;return this._areNativeBuffersUsable()?Promise.resolve():Ct(e,(function(e){var n,r=function(){var e=t._onNativeBufferAddedOrDisabled.indexOf(n);e>=0&&t._onNativeBufferAddedOrDisabled.splice(e,1)};return n=function(){t._areNativeBuffersUsable()&&(r(),e())},t._onNativeBufferAddedOrDisabled.push(n),r}))},n.disableSegmentSink=function(t){var n=this._initializedSegmentSinks[t];if(null!==n){if(void 0!==n)throw new Error("Cannot disable an active SegmentSink.");this._initializedSegmentSinks[t]=null,e.isNative(t)&&this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()}))}else T.warn("SBS: The "+t+" SegmentSink was already disabled.")},n.createSegmentSink=function(e,n){var r,i=this._initializedSegmentSinks[e];if(Cn(e)){if(!t(i))return i instanceof wn&&i.codec!==n?T.warn("SB: Reusing native SegmentSink with codec",i.codec,"for codec",n):T.info("SB: Reusing native SegmentSink with codec",n),i;T.info("SB: Adding native SegmentSink with codec",n);var a=new wn("audio"===e?"audio":"video",n,this._mediaSource);return this._initializedSegmentSinks[e]=a,this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()})),a}if(!t(i))return T.info("SB: Reusing a previous custom SegmentSink for the type",e),i;if("text"===e){if(T.info("SB: Creating a new text SegmentSink"),null===this._textInterface)throw new Error("HTML Text track feature not activated");return r=new Rn(this._textInterface),this._initializedSegmentSinks.text=r,r}throw T.error("SB: Unknown buffer type:",e),new Me("BUFFER_TYPE_UNKNOWN","The player wants to create a SegmentSink of an unknown type.")},n.disposeSegmentSink=function(e){var n=this._initializedSegmentSinks[e];t(n)?T.warn("SB: Trying to dispose a SegmentSink that does not exist"):(T.info("SB: Aborting SegmentSink",e),n.dispose(),delete this._initializedSegmentSinks[e])},n.disposeAll=function(){var e=this;xn.forEach((function(t){"initialized"===e.getStatus(t).type&&e.disposeSegmentSink(t)}))},n._areNativeBuffersUsable=function(){var e=this,t=this.getNativeBufferTypes();return!t.some((function(t){return void 0===e._initializedSegmentSinks[t]}))&&!t.every((function(t){return null===e._initializedSegmentSinks[t]}))},e}(),Pn=function(){function e(e){this._weakMap=new WeakMap,this._fn=e}var t=e.prototype;return t.get=function(e){var t=this._weakMap.get(e);if(void 0===t){var n=this._fn(e);return this._weakMap.set(e,n),n}return t},t.destroy=function(e){this._weakMap.delete(e)},e}();function Dn(e,t){var n,r=e.segmentSink,i=e.playbackObserver,a=e.maxBufferBehind,o=e.maxBufferAhead,s=[];function u(){null!==s&&function(e,t,n,r,i,a){return On.apply(this,arguments)}(r,n,s,a.getValue(),o.getValue(),t).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";T.error("Could not run BufferGarbageCollector:",t)}))}i.listen((function(e){n=e.position.getWanted(),s=e.buffered[r.bufferType],u()}),{includeLastObservation:!0,clearSignal:t}),a.onUpdate(u,{clearSignal:t}),o.onUpdate(u,{clearSignal:t}),u()}function On(){return(On=d(p().mark((function e(n,r,i,a,o,s){var u,l,d,c,f,v,h,m;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(isFinite(a)||isFinite(o)){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:u=[],l=O(i,r),d=l.innerRange,c=l.outerRanges,f=function(){if(isFinite(o)){for(var e=0;e<c.length;e++){var n=c[e];r+o<=n.start?u.push(n):r<=n.start&&r+o<n.end&&r+o>n.start&&u.push({start:r+o,end:n.end})}t(d)||r+o<d.end&&u.push({start:r+o,end:d.end})}},function(){if(isFinite(a)){for(var e=0;e<c.length;e++){var n=c[e];r-a>=n.end?u.push(n):r>=n.end&&r-a>n.start&&r-a<n.end&&u.push({start:n.start,end:r-a})}t(d)||r-a>d.start&&u.push({start:d.start,end:r-a})}}(),f(),v=0,h=u;case 9:if(!(v<h.length)){e.next=20;break}if(!((m=h[v]).start<m.end)){e.next=17;break}if(T.debug("GC: cleaning range from SegmentSink",m.start,m.end),null===s.cancellationError){e.next=15;break}throw s.cancellationError;case 15:return e.next=17,n.removeBuffer(m.start,m.end);case 17:v++,e.next=9;break;case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Nn=function(e){function t(t,n,r,i){var a;return(a=e.call(this)||this)._content=t,a._currentCanceller=null,a._downloadQueue=n,a._initSegmentRequest=null,a._mediaSegmentRequest=null,a._segmentFetcher=r,a._initSegmentInfoRef=new G(void 0),a._mediaSegmentAwaitingInitMetadata=null,i||a._initSegmentInfoRef.setValue(null),a}f(t,e);var n=t.prototype;return n.getRequestedInitSegment=function(){return null===this._initSegmentRequest?null:this._initSegmentRequest.segment},n.getRequestedMediaSegment=function(){return null===this._mediaSegmentRequest?null:this._mediaSegmentRequest.segment},n.start=function(){var e=this;null===this._currentCanceller&&(this._currentCanceller=new Z,this._downloadQueue.onUpdate((function(t){var n=t.segmentQueue;if(!(n.length>0&&n[0].segment.id===e._mediaSegmentAwaitingInitMetadata)){var r=e._mediaSegmentRequest;if(0===n.length){if(null===r)return;return T.debug("Stream: no more media segment to request. Cancelling queue.",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()}if(null===r)return T.debug("Stream: Media segments now need to be requested. Starting queue.",e._content.adaptation.type,n.length),void e._restartMediaSegmentDownloadingQueue();var i=n[0];return r.segment.id!==i.segment.id?(T.debug("Stream: Next media segment changed, cancelling previous",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()):void(r.priority!==i.priority&&(T.debug("Stream: Priority of next media segment changed, updating",e._content.adaptation.type,r.priority,i.priority),e._segmentFetcher.updatePriority(r.request,i.priority)))}}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate((function(t){var n,r=e._initSegmentRequest;null===t.initSegment||null===r?(null===(n=t.initSegment)||void 0===n?void 0:n.segment.id)!==(null==r?void 0:r.segment.id)&&(null===t.initSegment&&T.debug("Stream: no more init segment to request. Cancelling queue.",e._content.adaptation.type),e._restartInitSegmentDownloadingQueue(t.initSegment)):t.initSegment.priority!==r.priority&&e._segmentFetcher.updatePriority(r.request,t.initSegment.priority)}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))},n.stop=function(){var e;null===(e=this._currentCanceller)||void 0===e||e.cancel(),this._currentCanceller=null},n._restartMediaSegmentDownloadingQueue=function(){var e=this;null!==this._mediaSegmentRequest&&this._mediaSegmentRequest.canceller.cancel();!function t(n){if(null!==e._currentCanceller&&e._currentCanceller.isUsed())e._mediaSegmentRequest=null;else{if(void 0===n)return e._mediaSegmentRequest=null,void e.trigger("emptyQueue",null);var r=new Z,i=null===e._currentCanceller?S:r.linkToSignal(e._currentCanceller.signal),a=n.segment,o=n.priority,s=m({segment:a},e._content),u=!1,l=!1;r.signal.register((function(){e._mediaSegmentRequest=null,u||(e._mediaSegmentAwaitingInitMetadata===a.id&&(e._mediaSegmentAwaitingInitMetadata=null),u=!0,l=!1)}));var d=function(t){$(t.segmentType),e.trigger("parsedMediaSegment",m({},t,{segment:a}))},c=function(){var n=e._downloadQueue.getValue().segmentQueue;if(0===n.length)return u=!0,void e.trigger("emptyQueue",null);n[0].segment.id===a.id&&n.shift(),u=!0,t(n[0])},f=e._segmentFetcher.createRequest(s,o,{onRetry:function(t){e.trigger("requestRetry",{segment:a,error:t})},beforeInterrupted:function(){T.info("Stream: segment request interrupted temporarly.",a.id,a.time)},onChunk:function(t){var n=e._initSegmentInfoRef.getValue();void 0!==n?d(t(null!=n?n:void 0)):(l=!0,e._initSegmentInfoRef.waitUntilDefined((function(e){d(t(null!=e?e:void 0))}),{clearSignal:r.signal}))},onAllChunksReceived:function(){l?(e._mediaSegmentAwaitingInitMetadata=a.id,e._initSegmentInfoRef.waitUntilDefined((function(){e._mediaSegmentAwaitingInitMetadata=null,l=!1,e.trigger("fullyLoadedSegment",a)}),{clearSignal:r.signal})):e.trigger("fullyLoadedSegment",a)},beforeEnded:function(){i(),e._mediaSegmentRequest=null,l?e._initSegmentInfoRef.waitUntilDefined(c,{clearSignal:r.signal}):c()}},r.signal);f.catch((function(t){i(),u||(u=!0,e.stop(),e.trigger("error",t))})),e._mediaSegmentRequest={segment:a,priority:o,request:f,canceller:r}}}(this._downloadQueue.getValue().segmentQueue[0])},n._restartInitSegmentDownloadingQueue=function(e){var t=this;if((null===this._currentCanceller||!this._currentCanceller.isUsed())&&(null!==this._initSegmentRequest&&this._initSegmentRequest.canceller.cancel(),null!==e)){var n=new Z,r=null===this._currentCanceller?S:n.linkToSignal(this._currentCanceller.signal),i=e.segment,a=e.priority,o=m({segment:i},this._content),s=!1,u=this._segmentFetcher.createRequest(o,a,{onRetry:function(e){t.trigger("requestRetry",{segment:i,error:e})},beforeInterrupted:function(){T.info("Stream: init segment request interrupted temporarly.",i.id)},beforeEnded:function(){r(),t._initSegmentRequest=null,s=!0},onChunk:function(e){var n,r=e(void 0);$(r.segmentType),t.trigger("parsedInitSegment",m({},r,{segment:i})),"init"===r.segmentType&&t._initSegmentInfoRef.setValue(null!==(n=r.initTimescale)&&void 0!==n?n:null)},onAllChunksReceived:function(){t.trigger("fullyLoadedSegment",i)}},n.signal);u.catch((function(e){r(),s||(s=!0,t.stop(),t.trigger("error",e))})),n.signal.register((function(){t._initSegmentRequest=null,s||(s=!0)})),this._initSegmentRequest={segment:i,priority:a,request:u,canceller:n}}},t}(i);function Ln(e,t,n,r,i){var a=e.period,o=e.adaptation,s=e.representation,u=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(void 0===r.bufferedStart||void 0===r.bufferedEnd||r.bufferedStart>=t.end)return null;if(r.bufferedEnd>t.start)return n}return null}(i,t);if(null===u){if(null===n){if(r&&void 0!==a.end&&t.end>=a.end)return{start:void 0,end:null};var l=s.index.checkDiscontinuity(t.start);if(null!==l)return{start:void 0,end:l}}return null}var d=i[u];if(void 0!==d.bufferedStart&&d.bufferedStart>t.start&&(null===n||d.infos.segment.end<=n)){var c=d.bufferedStart;return r||!1===s.index.awaitSegmentBetween(t.start,c)?(T.debug("RS: current discontinuity encountered",o.type,d.bufferedStart),{start:void 0,end:c}):null}var f=function(e,t,n){if(n<=0)return T.error("RS: Asked to check a discontinuity before the first chunk."),null;for(var r=n;r<e.length;r++){var i=e[r],a=e[r-1];if(void 0===i.bufferedStart||void 0===a.bufferedEnd||i.bufferedStart>=t.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}(i,t,u+1);if(null!==f){var v=i[f-1],p=i[f];if(null===n||p.infos.segment.end<=n){if(!r&&!1!==s.index.awaitSegmentBetween(v.infos.segment.end,p.infos.segment.time))return null;var h=v.bufferedEnd,m=p.bufferedStart;return T.debug("RS: future discontinuity encountered",o.type,h,m),{start:h,end:m}}}if(null===n){if(r&&void 0!==a.end){if(t.end<a.end)return null;var g=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(void 0===r.bufferedStart)return null;if(r.bufferedStart<t)return n}return null}(i,a.end);if(null!==g){var y=i[g];if(void 0!==y.bufferedEnd&&y.bufferedEnd<a.end)return T.debug("RS: discontinuity encountered at the end of the current period",o.type,y.bufferedEnd,a.end),{start:y.bufferedEnd,end:null}}}if(void 0!==a.end&&t.end>=a.end)return null;for(var _=i.length-1;_>=0;_--){var b=i[_];if(void 0===b.bufferedStart)break;if(b.bufferedStart<t.end){if(void 0!==b.bufferedEnd&&b.bufferedEnd<t.end){var S=s.index.checkDiscontinuity(t.end);if(null!==S)return{start:b.bufferedEnd,end:S}}return null}}}return null}function Un(e){var t=e.bufferedSegments,n=e.content,r=e.currentPlaybackTime,i=e.fastSwitchThreshold,a=e.getBufferedHistory,o=e.neededRange,s=e.segmentsBeingPushed,u=e.maxBufferSize,l=n.adaptation,d=n.representation,c=function(e,t,n){var r=8e3*n;return r-=t.reduce((function(e,t){return e+t.representation.bitrate*t.segment.duration}),0),e.reduce((function(e,t){return void 0!==t.chunkSize?e-8*t.chunkSize:e}),r)}(t,s,u),f=d.index.getSegments(o.start,o.end-o.start),v=t.filter((function(e){return!Bn(e.infos,n,r,i)})).filter((function(e,t,n){var r=0===t?null:n[t-1],i=t>=n.length-1?null:n[t+1],s=null;if(function(e,t,n){var r=b.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedStart)return!1;if(null!==t&&void 0!==t.bufferedEnd&&e.bufferedStart-t.bufferedEnd<.1)return!1;if(n<e.bufferedStart&&e.bufferedStart-e.start>r)return T.info("Stream: The start of the wanted segment has been garbage collected",e.start,e.bufferedStart),!0;return!1}(e,r,o.start)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.start;if(void 0!==t&&void 0!==a&&t-a>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.start;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(s=a(e.infos),e.bufferedStart))return!1;T.debug("Stream: skipping segment gc-ed at the start",e.start,e.bufferedStart)}if(function(e,t,n){var r=b.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedEnd)return!1;if(null!==t&&void 0!==t.bufferedStart&&t.bufferedStart-e.bufferedEnd<.1)return!1;if(n>e.bufferedEnd&&e.end-e.bufferedEnd>r)return T.info("Stream: The end of the wanted segment has been garbage collected",e.end,e.bufferedEnd),!0;return!1}(e,i,o.end)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.end;if(void 0!==t&&void 0!==a&&a-t>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.end;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(s=null!=s?s:a(e.infos),e.bufferedEnd))return!1;T.debug("Stream: skipping segment gc-ed at the end",e.end,e.bufferedEnd)}return!0})),p=b.getCurrent(),h=p.MINIMUM_SEGMENT_SIZE,g=p.MIN_BUFFER_AHEAD,y=!1,_=Math.min(1/60,h),S=!1,E=[],k=f.filter((function(e){var t=m({segment:e},n);if(s.length>0&&s.some((function(e){return jt(t,e)})))return!1;var u=e.duration,f=e.time,p=e.end;if(e.isInit)return!0;if(y)return E.push(e),!1;if(e.complete&&u<h)return!1;if(s.length>0&&s.some((function(e){if(e.period.id!==n.period.id||e.adaptation.id!==n.adaptation.id)return!1;var a=e.segment;return!(a.time-_>f)&&(!(a.end+_<p)&&!Bn(e,t,r,i))})))return!1;for(var b=0;b<v.length;b++){var k=v[b];if(k.infos.period.id===n.period.id){var w=k.infos.segment;if(f-w.time>-_&&w.end-p>-_)return!1}}var A=u*n.representation.bitrate;if(c-A<0&&(S=!0,f>o.start+g))return y=!0,E.push(e),!1;var I=a(t);if(I.length>1){var R=I[I.length-1],x=I[I.length-2];if(null===R.buffered&&null===x.buffered)return T.warn("Stream: Segment GCed multiple times in a row, ignoring it.","If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering."+l.type,d.id,e.time),!1}for(var C=0;C<v.length;C++){var M=v[C];if(M.end+_>f){var P=M.start>f+_||Fn(v,C).end<p-_;return P&&(c-=A),P}}return c-=A,!0}));return{segmentsToLoad:k,segmentsOnHold:E,isBufferFull:S}}function Fn(e,t){for(var n=t+1,r=b.getCurrent().MINIMUM_SEGMENT_SIZE,i=Math.min(1/60,r);n<e.length-1&&e[n-1].end+i>e[n].start;)n++;return e[--n]}function Bn(e,t,n,r){var i=b.getCurrent().CONTENT_REPLACEMENT_PADDING;return e.period.id===t.period.id&&(!(e.segment.time<n+i)&&(e.adaptation.id!==t.adaptation.id||function(e,t,n){var r=e.bitrate,i=b.getCurrent().BITRATE_REBUFFERING_RATIO;if(void 0===n){var a=r*i;return t.bitrate>a}return r<n&&t.bitrate>r}(e.representation,t.representation,r)))}function zn(e,t){for(var n=e-t,r=b.getCurrent().SEGMENT_PRIORITIES_STEPS,i=0;i<r.length;i++)if(n<r[i])return i;return r.length}function Vn(e,n,r,i,a,o,s){var u,l,d,c=e.representation,f=null!==(l=null!==(u=r.getIsPaused())&&void 0!==u?u:r.getReference().getValue().paused.pending)&&void 0!==l?l:r.getReference().getValue().paused.last,v=null!==(d=r.getPlaybackRate())&&void 0!==d?d:r.getReference().getValue().speed,p=n;(void 0===f||void 0===v||f||v<=0)&&(p-=.1);var h=function(e,n,r){var i,a,o=e.manifest,s=e.period,u=e.representation,l=u.index.getLastAvailablePosition(),d=u.index;a=!t(l)&&Mn.isNative(e.adaptation.type)&&n>=l&&d.isInitialized()&&!d.isStillAwaitingFutureSegments()&&function(e,t,n){var r,i=e.getPeriodAfter(t);return t.containsTime(n,i)&&e.isLastPeriodKnown&&t.id===(null===(r=e.periods[e.periods.length-1])||void 0===r?void 0:r.id)}(o,s,n)?l-1:n-.1;var c,f=a+r;c=!(!u.index.isInitialized()||u.index.isStillAwaitingFutureSegments()||void 0===s.end)&&(void 0===l?f>=s.end:null===l||f>=l);return{start:Math.max(a,s.start),end:Math.min(f,null!==(i=s.end)&&void 0!==i?i:1/0),hasReachedPeriodEnd:c}}(e,p,a),m=c.index.shouldRefresh(h.start,h.end),g=s.getPendingOperations().filter((function(e){return e.type===bn.SignalSegmentComplete})).map((function(e){return e.value})),y=function(e,t){for(var n=b.getCurrent().MINIMUM_SEGMENT_SIZE,r=Math.max(1/60,n),i=e.start+r,a=e.end-r,o=[],s=t.length-1;s>=0;s--){var u=t[s],l=u.infos.representation;if(1===u.status&&!1!==l.decipherable&&!1!==l.isSupported){var d=u.infos.segment,c=d.time/d.timescale;((d.complete?c+d.duration/d.timescale:u.end)>i&&c<a||u.end>i&&u.start<a)&&o.unshift(u)}}return o}({start:Math.max(h.start-.5,0),end:h.end+.5},s.getLastKnownInventory()),_=r.getCurrentTime();void 0===_&&(_=r.getReference().getValue().position.getWanted());var S=Un({content:e,bufferedSegments:y,currentPlaybackTime:_,fastSwitchThreshold:i,getBufferedHistory:s.getSegmentHistory.bind(s),neededRange:h,segmentsBeingPushed:g,maxBufferSize:o}),E=S.segmentsToLoad,T=S.segmentsOnHold,k=S.isBufferFull,w=E.map((function(e){return{priority:zn(e.time,p),segment:e}})),A=c.index.isInitialized()&&!c.index.isStillAwaitingFutureSegments()&&h.hasReachedPeriodEnd&&0===w.length&&0===T.length,I=null;return g.length>0&&(I=Math.min.apply(Math,g.map((function(e){return e.segment.time})))),T.length>0&&(I=null!==I?Math.min(I,T[0].time):T[0].time),w.length>0&&(I=null!==I?Math.min(I,w[0].segment.time):w[0].segment.time),{imminentDiscontinuity:Ln(e,h,I,A,y),hasFinishedLoading:A,neededSegments:w,isBufferFull:k,shouldRefreshManifest:m}}var Kn=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(j(a),t.prototype),a.name="SourceBufferError",a.errorName=n,a.message=r,a.isBufferFull=i,a}f(t,e);var n=t.prototype;return n.serialize=function(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}},n.toString=function(){return this.errorName+": "+this.message},t}(Y(Error));function Wn(e){return new Promise((function(t){setTimeout(t,e)}))}function Gn(e,t,n,r,i){return jn.apply(this,arguments)}function jn(){return(jn=d(p().mark((function e(t,n,r,i,a){var o,s,u,l,d,c,f;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,n.pushChunk(r);case 3:case 31:return e.abrupt("return",e.sent);case 6:if(e.prev=6,e.t0=e.catch(0),!(a.isCancelled()&&e.t0 instanceof ee)){e.next=12;break}throw e.t0;case 12:if(e.t0 instanceof Kn&&e.t0.isBufferFull){e.next=15;break}throw o=e.t0 instanceof Error?e.t0.toString():"An unknown error happened when pushing content",new Me("BUFFER_APPEND_ERROR",o,{tracks:[Je(r.inventoryInfos.adaptation)]});case 15:return s=t.getReference().getValue(),u=s.position,l=u.getWanted(),e.prev=17,T.warn("Stream: Running garbage collector"),d=Math.max(l-5,0),c=l+i.getValue()+12,e.next=23,n.removeBuffer(0,d);case 23:return e.next=25,n.removeBuffer(c,Number.MAX_VALUE);case 25:return e.next=27,Wn(200);case 27:if(null===a.cancellationError){e.next=29;break}throw a.cancellationError;case 29:return e.next=31,n.pushChunk(r);case 34:if(e.prev=34,e.t1=e.catch(17),!(e.t1 instanceof ee)){e.next=38;break}throw e.t1;case 38:throw f=e.t1 instanceof Error?e.t1.toString():"Could not clean the buffer",new Me("BUFFER_FULL_ERROR",f,{tracks:[Je(r.inventoryInfos.adaptation)]});case 40:case"end":return e.stop()}}),e,null,[[0,6],[17,34]])})))).apply(this,arguments)}function Hn(){return Hn=d(p().mark((function e(t,n){var r,i,a,o,s,u,l,d,c,f;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.playbackObserver,i=t.content,a=t.initSegmentUniqueId,o=t.segment,s=t.segmentSink,u=t.bufferGoal,null===n.cancellationError){e.next=3;break}throw n.cancellationError;case 3:return l=i.representation.getMimeTypeString(),d={initSegmentUniqueId:a,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:l},c=m({segment:o,chunkSize:void 0,start:0,end:0},i),e.next=8,Gn(r,s,{data:d,inventoryInfos:c},u,n);case 8:return f=e.sent,e.abrupt("return",{content:i,segment:o,buffered:f});case 10:case"end":return e.stop()}}),e)}))),Hn.apply(this,arguments)}function qn(){return qn=d(p().mark((function e(t,n){var r,i,a,o,s,u,l,d,c,f,v,h,g,y,_,S,E,T,k,w,A,I,R,x;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.playbackObserver,i=t.bufferGoal,a=t.content,o=t.initSegmentUniqueId,s=t.parsedSegment,u=t.segment,l=t.segmentSink,null!==s.chunkData){e.next=3;break}return e.abrupt("return",null);case 3:if(null===n.cancellationError){e.next=5;break}throw n.cancellationError;case 5:return f=s.chunkData,v=s.chunkInfos,h=s.chunkOffset,g=s.chunkSize,y=s.appendWindow,_=a.representation.getMimeTypeString(),S=b.getCurrent(),E=S.APPEND_WINDOW_SECURITIES,T=[void 0!==y[0]?Math.max(0,y[0]-E.START):void 0,void 0!==y[1]?y[1]+E.END:void 0],k={initSegmentUniqueId:o,chunk:f,timestampOffset:h,appendWindow:T,codec:_},w=null!==(d=null==v?void 0:v.time)&&void 0!==d?d:u.time,A=null!==(c=null==v?void 0:v.duration)&&void 0!==c?c:u.duration,I=w+A,void 0!==T[0]&&(w=Math.max(w,T[0])),void 0!==T[1]&&(I=Math.min(I,T[1])),R=m({segment:u,chunkSize:g,start:w,end:I},a),e.next=18,Gn(r,l,{data:k,inventoryInfos:R},i,n);case 18:return x=e.sent,e.abrupt("return",{content:a,segment:u,buffered:x});case 20:case"end":return e.stop()}}),e)}))),qn.apply(this,arguments)}function Yn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Qn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Qn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Qn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var $n=function(e,t,n){var r=e.content,i=e.options,a=e.playbackObserver,o=e.segmentSink,s=e.segmentFetcher,u=e.terminate,l=r.period,d=r.adaptation,c=r.representation,f=i.bufferGoal,v=i.maxBufferSize,p=i.drmSystemId,h=i.fastSwitchThreshold,g=d.type,y=new Z;y.linkToSignal(n);var _=new Z;_.linkToSignal(y.signal);var S={segment:c.index.getInitSegment(),uniqueId:null,isLoaded:!1};y.signal.register((function(){null!==S.uniqueId&&o.freeInitSegment(S.uniqueId)}));var E=new G({initSegment:null,segmentQueue:[]},_.signal),k=null!==S.segment;k||(S.isLoaded=!0);var w=!1;if(void 0!==p){var A=c.getEncryptionData(p);if(A.length>0&&A.every((function(e){return void 0!==e.keyIds}))&&(w=!0,t.encryptionDataEncountered(A.map((function(e){return m({content:r},e)}))),y.isUsed()))return}var I=new Nn(r,E,s,k);return I.addEventListener("error",(function(e){_.signal.isCancelled()||(y.cancel(),t.error(e))})),I.addEventListener("parsedInitSegment",x),I.addEventListener("parsedMediaSegment",x),I.addEventListener("emptyQueue",R),I.addEventListener("requestRetry",(function(e){if(t.warning(e.error),!_.signal.isCancelled()){var n=e.segment,r=c.index;!1===r.isSegmentStillAvailable(n)?R():r.canBeOutOfSyncError(e.error,n)&&t.manifestMightBeOufOfSync()}})),I.addEventListener("fullyLoadedSegment",(function(e){o.signalSegmentComplete(m({segment:e},r)).catch(C)})),I.start(),_.signal.register((function(){I.removeEventListener(),I.stop()})),a.listen(R,{includeLastObservation:!1,clearSignal:_.signal}),r.manifest.addEventListener("manifestUpdate",R,_.signal),f.onUpdate(R,{emitCurrentValue:!1,clearSignal:_.signal}),v.onUpdate(R,{emitCurrentValue:!1,clearSignal:_.signal}),u.onUpdate(R,{emitCurrentValue:!1,clearSignal:_.signal}),void R();function R(){if(!_.isUsed()){var e=a.getReference().getValue(),n=e.position.getWanted(),i=Vn(r,n,a,h.getValue(),f.getValue(),v.getValue(),o),s=i.neededSegments,d=null;if(c.index.isInitialized()){if(s.length>0&&!S.isLoaded&&null!==S.segment){var p=s[0].priority;d={segment:S.segment,priority:p}}}else if(null===S.segment)T.warn("Stream: Uninitialized index without an initialization segment");else if(S.isLoaded)T.warn("Stream: Uninitialized index with an already loaded initialization segment");else{var m=e.position.getWanted();d={segment:S.segment,priority:zn(l.start,m)}}var y=u.getValue();if(null===y)E.setValue({initSegment:d,segmentQueue:s});else{if(y.urgent)return T.debug("Stream: Urgent switch, terminate now.",g),E.setValue({initSegment:null,segmentQueue:[]}),E.finish(),_.cancel(),void t.terminating();var k=s[0],w=I.getRequestedInitSegment(),A=I.getRequestedMediaSegment(),R=null===A||void 0===k||A.id!==k.segment.id?[]:[k],x=null===w?null:d;if(E.setValue({initSegment:x,segmentQueue:R}),0===R.length&&null===x)return T.debug("Stream: No request left, terminate",g),E.finish(),_.cancel(),void t.terminating()}if(t.streamStatusUpdate({period:l,position:e.position.getWanted(),bufferType:g,imminentDiscontinuity:i.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:i.hasFinishedLoading,neededSegments:i.neededSegments}),!_.signal.isCancelled()){var M=b.getCurrent().UPTO_CURRENT_POSITION_CLEANUP;if(i.isBufferFull){var P=Math.max(0,n-M);P>0&&o.removeBuffer(0,P).catch(C)}i.shouldRefreshManifest&&t.needsManifestRefresh()}}}function x(e){if(!y.isUsed()){for(var n,i=Yn(e.protectionData);!(n=i()).done;){var s=n.value;c.addProtectionData(s.initDataType,s.keyId,s.initData)}if(!w){var u=c.getAllEncryptionData();if(u.length>0&&(t.encryptionDataEncountered(u.map((function(e){return m({content:r},e)}))),w=!0,y.isUsed()))return}if("init"!==e.segmentType){var l=e.inbandEvents,d=e.predictedSegments,v=e.needsManifestRefresh;if(!(void 0!==d&&c.index.addPredictedSegments(d,e.segment),!0===v&&(t.needsManifestRefresh(),y.isUsed())||void 0!==l&&l.length>0&&(t.inbandEvent(l),y.isUsed()))){var p=S.uniqueId;(function(e,t){return qn.apply(this,arguments)})({playbackObserver:a,bufferGoal:f,content:r,initSegmentUniqueId:p,parsedSegment:e,segment:e.segment,segmentSink:o},y.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(C)}}else{if(c.index.isInitialized()||void 0===e.segmentList||c.index.initialize(e.segmentList),S.isLoaded=!0,null!==e.initializationData){var h=c.uniqueId;S.uniqueId=h,o.declareInitSegment(h,e.initializationData),function(e,t){return Hn.apply(this,arguments)}({playbackObserver:a,bufferGoal:f,content:r,initSegmentUniqueId:h,segment:e.segment,segmentData:e.initializationData,segmentSink:o},y.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(C)}R()}}}function C(e){y.isUsed()&&e instanceof ee||(y.cancel(),t.error(e))}};function Xn(e,t){for(var n=0;n<e.length;n++)if(e[n].infos.period.start>=t.start)return n>0?e[n-1]:null;return e.length>0?e[e.length-1]:null}function Zn(e,t){for(var n=0;n<e.length;n++)if(e[n].infos.period.start>t.start)return e[n];return null}function Jn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return er(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return er(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function tr(e,t,n,r,i){var a,o,s,u;if("lazy"===n.switchingMode)return{type:"continue",value:void 0};for(var l,d=r.getLastKnownInventory(),c=[],f=Jn(d);!(l=f()).done;){var v=l.value;v.infos.period.id!==e.id||v.infos.adaptation.id===t.id&&Ue(n.representationIds,v.infos.representation.id)||L(c,{start:null!==(a=v.bufferedStart)&&void 0!==a?a:v.start,end:null!==(o=v.bufferedEnd)&&void 0!==o?o:v.end})}for(var p,h=Jn(r.getPendingOperations());!(p=h()).done;){var m=p.value;if(m.type===bn.Push){var g=m.value.inventoryInfos;if(g.period.id===e.id&&(g.adaptation.id!==t.id||!Ue(n.representationIds,g.representation.id))){var y=g.segment.time;L(c,{start:y,end:y+g.segment.duration})}}}if(0===c.length)return{type:"continue",value:void 0};if("reload"===n.switchingMode){var _=i.getReadyState();if(void 0===_||_>1)return{type:"needs-reload",value:void 0}}var S="direct"===n.switchingMode,E=[],T=Xn(d,e);if(null!==T&&(void 0===T.bufferedEnd||e.start-T.bufferedEnd<1)&&E.push({start:0,end:e.start+1}),!S){var k=b.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,w=t.type,A=null!==(s=k[w].before)&&void 0!==s?s:0,I=null!==(u=k[w].after)&&void 0!==u?u:0,R=i.getCurrentTime();if(void 0===R)R=i.getReference().getValue().position.getPolled();E.push({start:R-A,end:R+I})}if(void 0!==e.end){var x=Zn(d,e);null!==x&&(void 0===x.bufferedStart||x.bufferedStart-e.end<1)&&E.push({start:e.end-1,end:Number.MAX_VALUE})}var C=F(c,E);return 0===C.length?{type:"continue",value:void 0}:S?{type:"flush-buffer",value:C}:{type:"clean-buffer",value:C}}function nr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return rr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function rr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ir=function(e,t,n){var r=e.playbackObserver,i=e.content,a=e.options,o=e.representationEstimator,s=e.segmentSink,l=e.segmentFetcherCreator,c=e.wantedBufferAhead,f=e.maxVideoBufferSize,v=i.manifest,h=i.period,g=i.adaptation,y=new Z;y.linkToSignal(n);var _,E,k=new Map,w=new G(null,y.signal),A=i.representations.getValue().representationIds,I=i.adaptation.representations.filter((function(e){return Ue(A,e.id)&&!1!==e.decipherable&&!1!==e.isSupported})),R=new G(I,y.signal),x=o({manifest:v,period:h,adaptation:g},w,R,r,y.signal),C=x.estimates,M=x.callbacks,P=l.createSegmentFetcher(g.type,{onRequestBegin:M.requestBegin,onRequestEnd:M.requestEnd,onProgress:M.requestProgress,onMetrics:M.metrics}),D=new G(0);return C.onUpdate((function(e){var n=e.bitrate,r=e.knownStableBitrate;a.enableFastSwitching&&D.setValueIfChanged(r),void 0!==n&&n!==_&&(_=n,T.debug("Stream: new "+g.type+" bitrate estimate",n),t.bitrateEstimateChange({type:g.type,bitrate:n}))}),{emitCurrentValue:!0,clearSignal:y.signal}),void i.representations.onUpdate((function(e){void 0!==E&&E.cancel();var n=i.representations.getValue().representationIds,r=i.adaptation.representations.filter((function(e){return Ue(n,e.id)}));R.setValueIfChanged(r),(E=new Z).linkToSignal(y.signal),function(e,t){return O.apply(this,arguments)}(e,E.signal).catch((function(e){!0===(null==E?void 0:E.isUsed())&&Z.isCancellationError(e)||(y.cancel(),t.error(e))}))}),{clearSignal:y.signal,emitCurrentValue:!0});function O(){return(O=d(p().mark((function e(n,i){var a,o,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=tr(h,g,n,s,r),e.t0=a.type,e.next="continue"===e.t0?4:"needs-reload"===e.t0?5:"flush-buffer"===e.t0||"clean-buffer"===e.t0?6:20;break;case 4:return e.abrupt("break",21);case 5:return e.abrupt("return",u((function(){r.listen((function(){if(!i.isCancelled()){var e=b.getCurrent().DELTA_POSITION_AFTER_RELOAD.bitrateSwitch;return t.waitingMediaSourceReload({bufferType:g.type,period:h,timeOffset:e,stayInPeriod:!0})}}),{includeLastObservation:!0,clearSignal:i})})));case 6:o=nr(a.value);case 7:if((l=o()).done){e.next=15;break}return d=l.value,e.next=11,s.removeBuffer(d.start,d.end);case 11:if(!i.isCancelled()){e.next=13;break}return e.abrupt("return");case 13:e.next=7;break;case 15:if("flush-buffer"!==a.type){e.next=19;break}if(t.needsBufferFlush(),!i.isCancelled()){e.next=19;break}return e.abrupt("return");case 19:return e.abrupt("break",21);case 20:X();case 21:N(i);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function N(e){var n=new Z;n.linkToSignal(e);var r=C.getValue().representation;if(null!==r){var i=new G(null,n.signal);C.onUpdate((function(e){if(null!==e.representation&&e.representation.id!==r.id)return e.urgent?(T.info("Stream: urgent Representation switch",g.type),i.setValue({urgent:!0})):(T.info("Stream: slow Representation switch",g.type),i.setValue({urgent:!1}))}),{clearSignal:n.signal,emitCurrentValue:!0});var a={type:g.type,adaptation:g,period:h,representation:r};if(w.setValue(r),!y.isUsed()&&(t.representationChange(a),!y.isUsed())){var o={streamStatusUpdate:t.streamStatusUpdate,encryptionDataEncountered:t.encryptionDataEncountered,manifestMightBeOufOfSync:t.manifestMightBeOufOfSync,needsManifestRefresh:t.needsManifestRefresh,inbandEvent:t.inbandEvent,warning:t.warning,error:function(e){y.cancel(),t.error(e)},addedSegment:function(e){M.addedSegment(e)},terminating:function(){if(!n.isUsed())return n.cancel(),N(e)}};L(r,i,o,e)}}}function L(e,n,i,o){var u=new Z;u.linkToSignal(o);var l=W(c,(function(t){return t*function(e){var t=k.get(e.id),n=void 0!==t?t:1;void 0===t&&k.set(e.id,n);return n}(e)}),u.signal),d="video"===g.type?f:new G(1/0);T.info("Stream: changing representation",g.type,e.id,e.bitrate);var p=m({},i,{error:function(t){var r,a=Ne(t,{defaultCode:"NONE",defaultReason:"Unknown `RepresentationStream` error"});if("BUFFER_FULL_ERROR"!==a.code)i.error(t);else{var s=c.getValue(),u=.7*(null!==(r=k.get(e.id))&&void 0!==r?r:1);if(u<=.05||s*u<=2)throw a;k.set(e.id,u),Mt(4e3,y.signal).then((function(){return L(e,n,i,o)})).catch(S)}},terminating:function(){u.cancel(),i.terminating()}});$n({playbackObserver:r,content:{representation:e,adaptation:g,period:h,manifest:v},segmentSink:s,segmentFetcher:P,terminate:n,options:{bufferGoal:l,maxBufferSize:d,drmSystemId:a.drmSystemId,fastSwitchThreshold:D}},p,o),v.addEventListener("manifestUpdate",(function(n){for(var r,i=nr(n.updatedPeriods);!(r=i()).done;){var a=r.value;if(a.period.id===h.id)for(var s,u=nr(a.result.updatedAdaptations);!(s=u()).done;){var l=s.value;if(l.adaptation===g.id)for(var d,c=nr(l.removedRepresentations);!(d=c()).done;){if(d.value===e.id){if(o.isCancelled())return;return t.waitingMediaSourceReload({bufferType:g.type,period:h,timeOffset:0,stayInPeriod:!0})}}}else if(a.period.start>h.start)break}}),o)}};function ar(e,t,n){if("function"==typeof String.prototype.startsWith)return e.startsWith(t,n);var r="number"==typeof n?Math.max(n,0):0;return e.substring(r,r+t.length)===t}var or=function(e,t){var n=e.split(";"),r=n[0],i=n.slice(1),a=t.split(";"),o=a[0],s=a.slice(1);if(r!==o)return!1;var u=ae(i,(function(e){return ar(e,"codecs=")})),l=ae(s,(function(e){return ar(e,"codecs=")}));if(void 0===u||void 0===l)return!1;var d=u.substring(7),c=l.substring(7);return d.split(".")[0]===c.split(".")[0]};function sr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ur(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ur(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ur(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function lr(e,t,n,r,i,a){var o,s,u,l;if(void 0!==e.codec&&"reload"===a.onCodecSwitch&&!function(e,t){return e.representations.some((function(e){return!0===e.isSupported&&!1!==e.decipherable&&or(e.getMimeTypeString(),t)}))}(n,e.codec))return{type:"needs-reload",value:void 0};for(var d,c=e.getLastKnownInventory(),f=[],v=sr(c);!(d=v()).done;){var p=d.value;p.infos.period.id===t.id&&p.infos.adaptation.id!==n.id&&L(f,{start:null!==(o=p.bufferedStart)&&void 0!==o?o:p.start,end:null!==(s=p.bufferedEnd)&&void 0!==s?s:p.end})}for(var h,m=sr(e.getPendingOperations());!(h=m()).done;){var g=h.value;if(g.type===bn.Push){var y=g.value.inventoryInfos;if(y.period.id===t.id&&y.adaptation.id!==n.id){var _=y.segment.time;L(f,{start:_,end:_+y.segment.duration})}}}if(0===f.length)return{type:"continue",value:void 0};if("reload"===r){var S=i.getReadyState();if(void 0===S||S>1)return{type:"needs-reload",value:void 0}}var E="direct"===r,T=[],k=Xn(c,t);if(null!==k&&(void 0===k.bufferedEnd||t.start-k.bufferedEnd<1)&&T.push({start:0,end:t.start+1}),!E){var w=n.type,A=b.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,I=null!==(u=A[w].before)&&void 0!==u?u:0,R=null!==(l=A[w].after)&&void 0!==l?l:0,x=i.getCurrentTime();if(void 0===x)x=i.getReference().getValue().position.getPolled();T.push({start:x-I,end:x+R})}if(void 0!==t.end){var C=Zn(c,t);null!==C&&(void 0===C.bufferedStart||C.bufferedStart-t.end<1)&&T.push({start:t.end-1,end:Number.MAX_VALUE})}var M=F(f,T);return 0===M.length?{type:"continue",value:void 0}:E&&"text"!==n.type?{type:"flush-buffer",value:M}:{type:"clean-buffer",value:M}}function dr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function fr(e,t,n){var r=e.getStatus(t);if("initialized"===r.type)return T.info("Stream: Reusing a previous SegmentSink for the type",t),r.value;var i=function(e){var t=e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable}));if(0===t.length){throw new Me("NO_PLAYABLE_REPRESENTATION","No Representation in the chosen "+e.type+" Adaptation can be played",{tracks:[Je(e)]})}return t[0].getMimeTypeString()}(n);return e.createSegmentSink(t,i)}function vr(e,t,n,r,i,a){var o=r.period,s=!1;function u(){var r=e.getReference().getValue(),a=t.getValue(),u=r.position.getWanted();void 0!==o.end&&u+a>=o.end&&(T.debug('Stream: full "empty" AdaptationStream',n),s=!0),i.streamStatusUpdate({period:o,bufferType:n,imminentDiscontinuity:null,position:u,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}t.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),e.listen(u,{includeLastObservation:!1,clearSignal:a}),u()}var pr=function(e,t,n){var r=e.bufferType,i=e.content,a=e.garbageCollectors,o=e.playbackObserver,s=e.representationEstimator,l=e.segmentFetcherCreator,c=e.segmentSinksStore,f=e.options,v=e.wantedBufferAhead,h=e.maxVideoBufferSize,g=i.manifest,y=i.period,_=new G(void 0,n);if(t.periodStreamReady({type:r,manifest:g,period:y,adaptationRef:_}),!n.isCancelled()){var S,E=!0;_.onUpdate((function(e){d(p().mark((function i(){var s,u,l,d,h,m,_,A,I,R,x,C,M,P,D,O,N,L;return p().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==e){i.next=2;break}return i.abrupt("return");case 2:if((u=new Z).linkToSignal(n),null==S||S.cancel(),S=u,null!==e){i.next=34;break}if(T.info("Stream: Set no "+r+" Adaptation. P:",y.start),"initialized"!==(l=c.getStatus(r)).type){i.next=26;break}if(T.info("Stream: Clearing previous "+r+" SegmentSink"),!Mn.isNative(r)){i.next=15;break}return i.abrupt("return",w(0,!0,u.signal));case 15:if(d=null!==(s=y.end)&&void 0!==s?s:1/0,!(y.start>d)){i.next=20;break}T.warn("Stream: Can't free buffer: period's start is after its end"),i.next=24;break;case 20:return i.next=22,l.value.removeBuffer(y.start,d);case 22:if(!u.isUsed()){i.next=24;break}return i.abrupt("return");case 24:i.next=30;break;case 26:if("uninitialized"!==l.type){i.next=30;break}if(c.disableSegmentSink(r),!u.isUsed()){i.next=30;break}return i.abrupt("return");case 30:if(t.adaptationChange({type:r,adaptation:null,period:y}),!u.isUsed()){i.next=33;break}return i.abrupt("return");case 33:return i.abrupt("return",vr(o,v,r,{period:y},t,u.signal));case 34:if(h=y.adaptations[r],void 0!==(m=ae(null!=h?h:[],(function(t){return t.id===e.adaptationId})))){i.next=40;break}return S.cancel(),T.warn("Stream: Unfound chosen Adaptation choice",e.adaptationId),i.abrupt("return");case 40:if(_=b.getCurrent(),A=_.DELTA_POSITION_AFTER_RELOAD,I=!1,!E){i.next=46;break}R=0,i.next=60;break;case 46:if(void 0===e.relativeResumingPosition){i.next=50;break}R=e.relativeResumingPosition,i.next=60;break;case 50:I=!0,i.t0=r,i.next="audio"===i.t0?54:"video"===i.t0?56:58;break;case 54:return R=A.trackSwitch.audio,i.abrupt("break",60);case 56:return R=A.trackSwitch.video,i.abrupt("break",60);case 58:return R=A.trackSwitch.other,i.abrupt("break",60);case 60:if(E=!1,!Mn.isNative(r)||"disabled"!==c.getStatus(r).type){i.next=63;break}return i.abrupt("return",w(R,!0,u.signal));case 63:if(g.addEventListener("manifestUpdate",(function(e){for(var t,n=dr(e.updatedPeriods);!(t=n()).done;){var r=t.value;if(r.period.id===y.id)for(var i,a=dr(r.result.removedAdaptations);!(i=a()).done;){if(i.value.id===m.id)return w(R,!0,u.signal)}else if(r.period.start>y.start)break}}),S.signal),x=e.representations,T.info("Stream: Updating "+r+" adaptation","A: "+m.id,"P: "+y.start),t.adaptationChange({type:r,adaptation:m,period:y}),!u.isUsed()){i.next=69;break}return i.abrupt("return");case 69:if(C=fr(c,r,m),"needs-reload"!==(M=lr(C,y,m,e.switchingMode,o,f)).type){i.next=73;break}return i.abrupt("return",w(R,!0,u.signal));case 73:return i.next=75,c.waitForUsableBuffers(u.signal);case 75:if(!u.isUsed()){i.next=77;break}return i.abrupt("return");case 77:if("flush-buffer"!==M.type&&"clean-buffer"!==M.type){i.next=91;break}P=dr(M.value);case 79:if((D=P()).done){i.next=87;break}return O=D.value,N=O.start,L=O.end,i.next=83,C.removeBuffer(N,L);case 83:if(!u.isUsed()){i.next=85;break}return i.abrupt("return");case 85:i.next=79;break;case 87:if("flush-buffer"!==M.type){i.next=91;break}if(t.needsBufferFlush({relativeResumingPosition:R,relativePosHasBeenDefaulted:I}),!u.isUsed()){i.next=91;break}return i.abrupt("return");case 91:a.get(C)(u.signal),k(m,x,C,u.signal);case 93:case"end":return i.stop()}}),i)})))().catch((function(e){e instanceof ee||(null==S||S.cancel(),t.error(e))}))}),{clearSignal:n,emitCurrentValue:!0})}function k(e,n,i,a){var u,d,p=(u=o,d=e.type,u.deriveReadOnlyObserver((function(e,t){var n=new G(r(),t);return e.onUpdate(i,{clearSignal:t,emitCurrentValue:!1}),n;function r(){var t=e.getValue(),n=t.buffered[d],r=null!==n?N(n,t.position.getWanted()):0;return m({},t,{bufferGap:r,buffered:n})}function i(){n.setValue(r())}})));ir({content:{manifest:g,period:y,adaptation:e,representations:n},options:f,playbackObserver:p,representationEstimator:s,segmentSink:i,segmentFetcherCreator:l,wantedBufferAhead:v,maxVideoBufferSize:h},Object.assign(Object.assign({},t),{error:function(e){if(!Mn.isNative(r)){T.error("Stream: "+r+" Stream crashed. Aborting it.",e instanceof Error?e:""),c.disposeSegmentSink(r);var n=Ne(e,{defaultCode:"NONE",defaultReason:"Unknown `AdaptationStream` error"});if(t.warning(n),a.isCancelled())return;return vr(o,v,r,{period:y},t,a)}T.error("Stream: "+r+" Stream crashed. Stopping playback.",e instanceof Error?e:""),t.error(e)}}),a)}function w(e,n,i){u((function(){o.listen((function(){i.isCancelled()||t.waitingMediaSourceReload({bufferType:r,period:y,timeOffset:e,stayInPeriod:n})}),{includeLastObservation:!0,clearSignal:i})}))}};function hr(e,t){if(0===t.length)return[];for(var n,r=[],i=e.getLastKnownInventory(),a=function(){var e=i[o];if(t.some((function(t){return e.infos.period.id===t.period.id&&e.infos.adaptation.id===t.adaptation.id&&e.infos.representation.id===t.representation.id}))){var n=e.bufferedStart,a=e.bufferedEnd;if(void 0===n||void 0===a)return T.warn("SO: No buffered start or end found from a segment."),{v:[{start:0,end:Number.MAX_VALUE}]};var s=r[r.length-1];void 0!==s&&s.end===n?s.end=a:r.push({start:n,end:a})}},o=0;o<i.length;o++)if(n=a())return n.v;return r}function mr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return gr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function gr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){if(0===t.length)return!1;var n=e.position.getPolled();return e.speed>=0?t[t.length-1].end>=n-5:t[0].start<=n+5}var _r=function(e,n,r,i,a,o,s,l){for(var c,f=e.manifest,v=e.initialPeriod,h=o.maxBufferAhead,m=o.maxBufferBehind,g=o.wantedBufferAhead,y=o.maxVideoBufferSize,_=b.getCurrent(),S=_.MINIMUM_MAX_BUFFER_AHEAD,E=_.MAXIMUM_MAX_BUFFER_AHEAD,k=_.MAXIMUM_MAX_BUFFER_BEHIND,w=new Pn((function(e){var t,r,i=e.bufferType,a=null!==(t=k[i])&&void 0!==t?t:1/0,o=null!==(r=E[i])&&void 0!==r?r:1/0;return function(t){Dn({segmentSink:e,playbackObserver:n,maxBufferBehind:W(m,(function(e){return Math.min(e,a)}),t),maxBufferAhead:W(h,(function(e){var t,n=Math.max(e,null!==(t=S[i])&&void 0!==t?t:0);return Math.min(n,o)}),t)},t)}})),A=mr(i.getBufferTypes());!(c=A()).done;){I(c.value,v)}function I(e,r){var a=new Jt((function(e,t){return e.start-t.start})),o=!1,c=new Z;return c.linkToSignal(l),n.listen((function(n){var r,i=n.position.getWanted();if(o&&function(e){var n=a.head(),r=a.last();if(void 0===n||void 0===r)return!0;return n.start>e||(t(r.end)?1/0:r.end)<e}(i)){for(T.info("Stream: Destroying all PeriodStreams due to out of bounds situation",e,i),o=!1;a.length()>0;){var u=a.get(a.length()-1);a.removeElement(u),s.periodStreamCleared({type:e,manifest:f,period:u})}c.cancel(),(c=new Z).linkToSignal(l);var d=null!==(r=f.getPeriodForTime(i))&&void 0!==r?r:f.getNextPeriod(i);if(void 0===d)return T.warn("Stream: The wanted position is not found in the Manifest."),void(o=!0);v(d)}}),{clearSignal:l,includeLastObservation:!0}),f.addEventListener("decipherabilityUpdate",(function(e){l.isCancelled()||function(e){return h.apply(this,arguments)}(e).catch((function(e){l.isCancelled()||(c.cancel(),s.error(e))}))}),l),v(r);function v(t){var n=Object.assign(Object.assign({},s),{waitingMediaSourceReload:function(e){var t=a.head();void 0===t||t.id!==e.period.id?s.lockedStream({bufferType:e.bufferType,period:e.period}):s.needsMediaSourceReload({timeOffset:e.timeOffset,minimumPosition:e.stayInPeriod?e.period.start:void 0,maximumPosition:e.stayInPeriod?e.period.end:void 0})},periodStreamReady:function(e){o=!0,a.add(e.period),s.periodStreamReady(e)},periodStreamCleared:function(e){a.removeElement(e.period),s.periodStreamCleared(e)},error:function(e){c.cancel(),s.error(e)}});R(e,t,n,c.signal)}function h(){return h=d(p().mark((function t(r){var d,h,m,g,y,_,b,S,E,k,w,A,I;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(d=i.getStatus(e),0!==(h=r.filter((function(t){return t.adaptation.type===e}))).length&&"initialized"===d.type&&!h.every((function(e){return!0===e.representation.decipherable}))){t.next=4;break}return t.abrupt("return");case 4:for(m=d.value,g=h.filter((function(e){return void 0===e.representation.decipherable})),y=h.filter((function(e){return!1===e.representation.decipherable})),_=hr(m,y),b=hr(m,g),o=!1,T.info("Stream: Destroying all PeriodStreams for decipherability matters",e);a.length()>0;)S=a.get(a.length()-1),a.removeElement(S),s.periodStreamCleared({type:e,manifest:f,period:S});c.cancel(),(c=new Z).linkToSignal(l),E=0,k=[].concat(_,b);case 16:if(!(E<k.length)){t.next=28;break}if(w=k[E],A=w.start,I=w.end,!l.isCancelled()){t.next=20;break}return t.abrupt("return");case 20:if(!(A<I)){t.next=25;break}if(!l.isCancelled()){t.next=23;break}return t.abrupt("return");case 23:return t.next=25,m.removeBuffer(A,I);case 25:E++,t.next=16;break;case 28:u((function(){if(!l.isCancelled()){var e=n.getReference().getValue();if(yr(e,_)){if(s.needsDecipherabilityFlush(),l.isCancelled())return}else if(yr(e,b)&&(s.needsBufferFlush(),l.isCancelled()))return;var t=e.position.getWanted(),r=f.getPeriodForTime(t);void 0!==r?v(r):s.error(new Me("MEDIA_TIME_NOT_FOUND","The wanted position is not found in the Manifest."))}}));case 29:case"end":return t.stop()}}),t)}))),h.apply(this,arguments)}}function R(e,t,l,d){T.info("Stream: Creating new Stream for",e,t.start);var c=null,v=new Z;v.linkToSignal(d),n.listen((function(n,r){var i=n.position;if(void 0!==t.end&&i.getWanted()>=t.end){var a=f.getPeriodAfter(t);if(t.containsTime(i.getWanted(),a))return;T.info("Stream: Destroying PeriodStream as the current playhead moved above it",e,t.start,i.getWanted(),t.end),r(),l.periodStreamCleared({type:e,manifest:f,period:t}),v.cancel()}}),{clearSignal:d,includeLastObservation:!0});var p,h={bufferType:e,content:{manifest:f,period:t},garbageCollectors:w,maxVideoBufferSize:y,segmentFetcherCreator:a,segmentSinksStore:i,options:o,playbackObserver:n,representationEstimator:r,wantedBufferAhead:g},m=Object.assign(Object.assign({},l),{streamStatusUpdate:function(n){if(n.hasFinishedLoading){var r=f.getPeriodAfter(t);null!==r&&function(t){if(null!==c){if(c.period.id===t.id)return;T.warn("Stream: Creating next `PeriodStream` while one was already created.",e,t.id,c.period.id),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel()}var n=new Z;n.linkToSignal(d),c={canceller:n,period:t},R(e,t,l,c.canceller.signal)}(r)}else null!==c&&(T.info("Stream: Destroying next PeriodStream due to current one being active",e,c.period.start),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel(),c=null);l.streamStatusUpdate(n)},error:function(e){null!==c&&(c.canceller.cancel(),c=null),v.cancel(),l.error(e)}});pr(h,m,v.signal),p=v.signal,f.addEventListener("manifestUpdate",(function(n){for(var r,i=mr(n.removedPeriods);!(r=i()).done;){var a=r.value;if(a.id===t.id){if(f.periods.length>0&&f.periods[0].start<=a.start)return u((function(){if(!p.isCancelled())return s.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})}))}else if(a.start>t.start)break}if(n.addedPeriods.length>0&&null!==c){var o=f.getPeriodAfter(t);null!==o&&c.period.id===o.id||(T.warn("Stream: Destroying next PeriodStream due to new one being added",e,c.period.start),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel(),c=null)}}),p)}},br=_r,Sr={createSync:function(e){return{syncValue:e,getValueAsAsync:function(){return Promise.resolve(e)}}},createAsync:function(e){var t=null;return e.then((function(e){t=e}),S),{syncValue:t,getValueAsAsync:function(){return e}}}},Er=new WeakMap,Tr={setState:function(e,t){Er.set(e,t)},getState:function(e){var t=Er.get(e);return void 0===t?null:t},clearState:function(e){Er.set(e,null)}};function kr(e){var t=Tr.getState(e);return null===t?null:[t.mediaKeySystemAccess.keySystem,t.mediaKeySystemAccess.getConfiguration()]}var wr=function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(i);function Ar(e,t){var n={audio:null,video:null,text:null};if(null!==t&&(n.text=t.getBufferedRanges()),null===e)return n;var r=ae(e.sourceBuffers,(function(e){return"audio"===e.type})),i=ae(e.sourceBuffers,(function(e){return"video"===e.type})),a=null==r?void 0:r.getBuffered();void 0!==a&&(n.audio=a);var o=null==i?void 0:i.getBuffered();return void 0!==o&&(n.video=o),n}function Ir(e,t,n){var r=t.autoPlay,i=t.initialPlayPerformed,a=t.manifest,o=t.mediaSource,s=t.speed,u=t.textDisplayer;return e.deriveReadOnlyObserver((function(e,t){var l=new Z;l.linkToSignal(t),l.linkToSignal(n);var d=new G(c(),l.signal);return s.onUpdate(f,{clearSignal:l.signal,emitCurrentValue:!1}),e.onUpdate(f,{clearSignal:l.signal,emitCurrentValue:!1}),d;function c(){var t=e.getValue(),n=s.getValue();return function(e,t){if(!t.isDynamic||t.isLastPeriodKnown){var n=t.periods[t.periods.length-1];if(void 0!==n&&void 0!==n.end){var r=e.position.getWanted();if(r>=n.start&&r>=n.end-1){var i=e.buffered;(0===i.length||i.end(i.length-1)<e.duration-1)&&e.position.forceWantedPosition(n.end-1)}}}}(t,a),{maximumPosition:We(a),bufferGap:t.bufferGap,position:t.position,buffered:Ar(o,u),duration:t.duration,rebuffering:t.rebuffering,freezing:t.freezing,paused:{last:t.paused,pending:Rr(i,r)},readyState:t.readyState,speed:n}}function f(){d.setValue(c())}}))}function Rr(e,t){return e.getValue()?void 0:!t}function xr(e){var n=e.textTracks;if(!t(n)){for(var r=0;r<n.length;r++)n[r].mode="disabled";if(e.hasChildNodes())for(var i=e.childNodes,a=i.length-1;a>=0;a--)if("track"===i[a].nodeName)try{e.removeChild(i[a])}catch(e){T.warn("Compat: Could not remove text track child from element.")}}e.src="",e.removeAttribute("src")}var Cr=s,Mr=void 0===Cr?void 0:t(Cr.MediaSource)?t(Cr.MozMediaSource)?t(Cr.WebKitMediaSource)?Cr.MSMediaSource:Cr.WebKitMediaSource:Cr.MozMediaSource:Cr.MediaSource;var Pr=["","webkit","moz","ms"];function Dr(e,t){return t.filter((function(t){return function(e,t){var n=document.createElement(e.tagName),r="on"+t;return r in n||(n.setAttribute(r,"return;"),"function"==typeof n[r])}(e,t)}))[0]}function Or(e,t){var n,r=function(e,t){return e.reduce((function(e,n){return e.concat((void 0===t?Pr:t).map((function(e){return e+n})))}),[])}(e,t);return function(e,t,i){if(!i.isCancelled()){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement){if(void 0===n&&(n=Dr(e,r)),!et(n))return void 0;e.addEventListener(n,t),i.register((function(){void 0!==n&&e.removeEventListener(n,t)}))}r.forEach((function(n){var r=!1;"function"==typeof e.addEventListener?e.addEventListener(n,t):(r=!0,e["on"+n]=t),i.register((function(){"function"==typeof e.removeEventListener&&e.removeEventListener(n,t),r&&delete e["on"+n]}))}))}}}function Nr(e,n){var r,i=function(e){var n,r=document;t(r.hidden)?t(r.mozHidden)?t(r.msHidden)?t(r.webkitHidden)||(n="webkit"):n="ms":n="moz":n="";var i=et(n)?n+"Hidden":"hidden",a=et(n)?n+"visibilitychange":"visibilitychange",o=document[i],s=new G(!o,e);return $r(document,a,(function(){var e=!document[i];s.setValueIfChanged(e)}),e),s}(n),a=new G(!0,n);return n.register((function(){clearTimeout(r),r=void 0})),i.onUpdate(o,{clearSignal:n}),e.onUpdate(o,{clearSignal:n}),o(),a;function o(){if(clearTimeout(r),r=void 0,e.getValue().isEnabled||i.getValue())a.setValueIfChanged(!0);else{var t=b.getCurrent().INACTIVITY_DELAY;r=setTimeout((function(){a.setValueIfChanged(!1)}),t)}}}function Lr(e){var n,r,i=t(s.devicePixelRatio)||0===s.devicePixelRatio?1:s.devicePixelRatio,a=new G({width:null===(n=s.screen)||void 0===n?void 0:n.width,height:null===(r=s.screen)||void 0===r?void 0:r.height,pixelRatio:i},e),o=setInterval((function(){var e=a.getValue();e.width===screen.width&&e.height===screen.height&&e.pixelRatio===i||a.setValue({width:screen.width,height:screen.height,pixelRatio:i})}),2e4);return e.register((function(){clearInterval(o)})),a}function Ur(e,n,r){var i=t(s.devicePixelRatio)||0===s.devicePixelRatio?1:s.devicePixelRatio,a=new G({width:e.clientWidth,height:e.clientHeight,pixelRatio:i},r),o=S;n.onUpdate(l,{clearSignal:r}),$r(s,"resize",l,r),$r(e,"enterpictureinpicture",l,r),$r(e,"leavepictureinpicture",l,r);var u=setInterval(l,2e4);return l(),r.register((function(){o(),clearInterval(u)})),a;function l(){o();var r=n.getValue(),s=r.pipWindow;if(r.isEnabled)if(t(s)){var u=a.getValue();void 0===u.width&&void 0===u.height&&u.pixelRatio===i||a.setValue({width:void 0,height:void 0,pixelRatio:i})}else{var l=function(){c()};s.addEventListener("resize",l),o=function(){s.removeEventListener("resize",l),o=S},c()}else{var d=a.getValue();d.width===e.clientWidth&&d.height===e.clientHeight&&d.pixelRatio===i||a.setValue({width:e.clientWidth,height:e.clientHeight,pixelRatio:i})}function c(){var e=a.getValue();e.width===(null==s?void 0:s.width)&&e.height===(null==s?void 0:s.height)&&e.pixelRatio===i||a.setValue({width:null==s?void 0:s.width,height:null==s?void 0:s.height,pixelRatio:i})}}}Or(["loadedmetadata"]),Or(["timeupdate"]),Or(["addtrack"]),Or(["removetrack"]);var Fr=Or(["sourceopen","webkitsourceopen"]),Br=Or(["sourceclose","webkitsourceclose"]),zr=Or(["sourceended","webkitsourceended"]),Vr=Or(["update"]),Kr=Or(["removesourcebuffer"]),Wr=Or(["keymessage","message"]),Gr=Or(["keyadded","ready"]),jr=Or(["keyerror","error"]),Hr=Or(["keystatuseschange"]),qr=Or(["seeking"]),Yr=Or(["seeked"]),Qr=Or(["ended"]);function $r(e,t,n,r){e.addEventListener(t,n),r.register((function(){e.removeEventListener(t,n)}))}function Xr(){for(var e,t=arguments.length,n=-1,r=0;++n<t;)r+="number"==typeof(e=n<0||arguments.length<=n?void 0:arguments[n])?e:e.length;var i=new Uint8Array(r),a=0;for(n=-1;++n<t;)"number"==typeof(e=n<0||arguments.length<=n?void 0:arguments[n])?a+=e:e.length>0&&(i.set(e,a),a+=e.length);return i}function Zr(e,t){return(e[t+0]<<8)+(e[t+1]<<0)}function Jr(e,t){return 65536*e[t+0]+256*e[t+1]+e[t+2]}function ei(e,t){return 16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3]}function ti(e,t){return 4294967296*(16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3])+16777216*e[t+4]+65536*e[t+5]+256*e[t+6]+e[t+7]}function ni(e){return new Uint8Array([e>>>8&255,255&e])}function ri(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}function ii(e){var t=e%4294967296,n=(e-t)/4294967296;return new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n,t>>>24&255,t>>>16&255,t>>>8&255,255&t])}function ai(e){return new Uint8Array([255&e,e>>>8&255,e>>>16&255,e>>>24&255])}function oi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return si(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return si(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function si(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ui(e,t){if(T.debug("Init: Trying to call endOfStream"),"open"===e.readyState){var n=e.sourceBuffers,r=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];r.updating&&t.push(r)}return t}(n);if(0===r.length)return T.info("Init: Triggering end of stream"),void e.endOfStream();T.debug("Init: Waiting SourceBuffers to be updated before calling endOfStream.");var i=new Z;i.linkToSignal(t);for(var a,o=oi(r);!(a=o()).done;){var s=a.value;Vr(s,(function(){i.cancel(),ui(e,t)}),i.signal)}Kr(n,(function(){i.cancel(),ui(e,t)}),i.signal)}else T.debug("Init: MediaSource not open, cancel endOfStream")}var li,di,ci,fi=!1,vi=!1,pi=!1,hi=!1,mi=!1,gi=!1,yi=!1,_i=!1,bi=!1,Si=!1,Ei=!1;o||(void 0!==s.MSInputMethodContext&&void 0!==document.documentMode?(vi=!0,pi=!0):"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&/(Trident|Edge)\//.test(navigator.userAgent)?pi=!0:-1!==navigator.userAgent.toLowerCase().indexOf("edg/")?fi=!0:-1!==navigator.userAgent.toLowerCase().indexOf("firefox")?hi=!0:"string"==typeof navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)?gi=!0:(Object.prototype.toString.call(s.HTMLElement).indexOf("Constructor")>=0||"[object SafariRemoteNotification]"===(null===(di=null===(li=s.safari)||void 0===li?void 0:li.pushNotification)||void 0===di?void 0:di.toString())||/Safari\/(\d+)/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&-1!==(null===(ci=navigator.vendor)||void 0===ci?void 0:ci.indexOf("Apple"))&&!/Chrome\/(\d+)/.test(navigator.userAgent)&&!/Chromium\/(\d+)/.test(navigator.userAgent))&&(mi=!0),/SamsungBrowser/.test(navigator.userAgent)&&(yi=!0),-1!==navigator.userAgent.indexOf("PlayStation 5")?Ei=!0:/Tizen/.test(navigator.userAgent)?_i=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(bi=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\/87/.test(navigator.userAgent)||(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\/79/.test(navigator.userAgent))):/[Pp]anasonic/.test(navigator.userAgent)?Si=!0:navigator.userAgent.indexOf("Xbox"));var Ti=31536e3,ki=function(){function e(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}var t=e.prototype;return t.updateDuration=function(e,t){null!==this._currentMediaSourceDurationUpdateCanceller&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new Z;var n=this._mediaSource,r=this._currentMediaSourceDurationUpdateCanceller.signal,i=function(e,t){var n=new G("open"===e.readyState,t);return Fr(e,(function(){T.debug("Init: Reacting to MediaSource open in duration updater"),n.setValueIfChanged(!0)}),t),zr(e,(function(){T.debug("Init: Reacting to MediaSource ended in duration updater"),n.setValueIfChanged(!1)}),t),Br(e,(function(){T.debug("Init: Reacting to MediaSource close in duration updater"),n.setValueIfChanged(!1)}),t),n}(n,r),a=new Z;a.linkToSignal(r),i.onUpdate((function(){if(a.cancel(),!i.getValue())return;(a=new Z).linkToSignal(r);var o=function(e,t){if(0===e.length){var n=new G(!1);return n.finish(),n}var r=new G(!1,t);o();for(var i=function(){var n=e[a];n.addEventListener("updatestart",o),n.addEventListener("update",o),t.register((function(){n.removeEventListener("updatestart",o),n.removeEventListener("update",o)}))},a=0;a<e.length;a++)i();return r;function o(){for(var t=0;t<e.length;t++){if(e[t].updating)return void r.setValueIfChanged(!0)}r.setValueIfChanged(!1)}}(n.sourceBuffers,a.signal),s=new Z;return s.linkToSignal(a.signal),o.onUpdate((function(r){s.cancel(),(s=new Z).linkToSignal(a.signal),r||Ai(n,e,t,s.signal)}),{clearSignal:a.signal,emitCurrentValue:!0})}),{emitCurrentValue:!0,clearSignal:r})},t.stopUpdating=function(){null!==this._currentMediaSourceDurationUpdateCanceller&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)},e}();function wi(e,t,n){var r=t;n||(r=Ei?1/0:Ii(t));for(var i=0,a=0;a<e.sourceBuffers.length;a++){var o=e.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===e.duration)return"success";if(i>r){if(i<e.duration)try{T.info("Init: Updating duration to what is currently buffered",i),e.duration=i}catch(e){return T.warn("Duration Updater: Can't update duration on the MediaSource.",e instanceof Error?e:""),"failed"}return"partial"}var u=e.duration;try{if(T.info("Init: Updating duration",r),e.duration=r,"open"===e.readyState&&!isFinite(r)){var l=Ii(t);T.info("Init: calling `mediaSource.setLiveSeekableRange`",l),e.setLiveSeekableRange(0,l)}}catch(e){return T.warn("Duration Updater: Can't update duration on the MediaSource.",e instanceof Error?e:""),"failed"}var d=Math.abs(e.duration-r);return d>=.1?d<Math.abs(e.duration-u)?"partial":"failed":"success"}function Ai(e,t,n,r){if("success"!==wi(e,t,n))var i=setTimeout((function(){a(),Ai(e,t,n,r)}),2e3),a=r.register((function(){clearTimeout(i)}))}function Ii(e){return Math.max(Math.pow(2,32),e+Ti)}function Ri(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return xi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function xi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ci=function(e){function n(n){var r;if((r=e.call(this)||this).id=n,r.sourceBuffers=[],r._canceller=new Z,t(Mr))throw new Me("MEDIA_SOURCE_NOT_SUPPORTED","No MediaSource Object was found in the current browser.");T.info("Init: Creating MediaSource");var i=new Mr;r.readyState=i.readyState;var a=i.handle;return r.handle=t(a)?{type:"media-source",value:i}:{type:"handle",value:a},r._mediaSource=i,r._durationUpdater=new ki(i),r._endOfStreamCanceller=null,Fr(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceOpen",null)}),r._canceller.signal),zr(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceEnded",null)}),r._canceller.signal),Br(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceClose",null)}),r._canceller.signal),r}f(n,e);var r=n.prototype;return r.addSourceBuffer=function(e,t){var n=this._mediaSource.addSourceBuffer(t),r=new Mi(e,t,n);return this.sourceBuffers.push(r),r},r.setDuration=function(e,t){this._durationUpdater.updateDuration(e,t)},r.interruptDurationSetting=function(){this._durationUpdater.stopUpdating()},r.maintainEndOfStream=function(){var e,t,n;null===this._endOfStreamCanceller&&(this._endOfStreamCanceller=new Z,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),T.debug("Init: end-of-stream order received."),e=this._mediaSource,t=this._endOfStreamCanceller.signal,(n=new Z).linkToSignal(t),Fr(e,(function(){T.debug("Init: MediaSource re-opened while end-of-stream is active"),n.cancel(),(n=new Z).linkToSignal(t),ui(e,n.signal)}),t),ui(e,n.signal))},r.stopEndOfStream=function(){null!==this._endOfStreamCanceller&&(T.debug("Init: resume-stream order received."),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)},r.dispose=function(){this.sourceBuffers.forEach((function(e){return e.dispose()})),this._canceller.cancel(),function(e){if("closed"!==e.readyState){for(var t=e.readyState,n=e.sourceBuffers,r=n.length-1;r>=0;r--){var i=n[r];try{if("open"===t){T.info("Init: Aborting SourceBuffer before removing");try{i.abort()}catch(e){}}T.info("Init: Removing SourceBuffer from mediaSource"),e.removeSourceBuffer(i)}catch(e){}}n.length>0&&T.info("Init: Not all SourceBuffers could have been removed.")}}(this._mediaSource)},n}(i),Mi=function(){function e(e,t,n){var r=this;this.type=e,this.codec=t,this._canceller=new Z,this._sourceBuffer=n,this._operationQueue=[],this._currentOperations=[];var i=function(e){var t;t=e instanceof Error?e:e.error instanceof Error?e.error:new Error("Unknown SourceBuffer Error");var n=r._currentOperations;if(r._currentOperations=[],0===n.length)T.error("SBI: error for an unknown operation",t);else for(var i,a=new Kn(t.name,t.message,"QuotaExceededError"===t.name),o=Ri(n);!(i=o()).done;){i.value.reject(a)}},a=function(){var e=r._currentOperations;r._currentOperations=[];try{for(var t,n=Ri(e);!(t=n()).done;){t.value.resolve(M(r._sourceBuffer.buffered))}}catch(t){for(var i,a=Ri(e);!(i=a()).done;){var o=i.value;t instanceof Error&&"InvalidStateError"===t.name?o.resolve([]):o.reject(t)}}r._performNextOperation()};n.addEventListener("error",i),n.addEventListener("updateend",a),this._canceller.signal.register((function(){n.removeEventListener("error",i),n.removeEventListener("updateend",a)}))}var t=e.prototype;return t.appendBuffer=function(){T.debug("SBI: receiving order to push data to the SourceBuffer",this.type);for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._addToQueue({operationName:0,params:t})},t.remove=function(e,t){return T.debug("SBI: receiving order to remove data from the SourceBuffer",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})},t.getBuffered=function(){try{return M(this._sourceBuffer.buffered)}catch(e){return T.error("Failed to get buffered time range of SourceBuffer",this.type,e instanceof Error?e:null),[]}},t.abort=function(){try{this._sourceBuffer.abort()}catch(e){T.debug("Init: Failed to abort SourceBuffer:",e instanceof Error?e:null)}this._emptyCurrentQueue()},t.dispose=function(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()},t._emptyCurrentQueue=function(){var e=new ee;this._currentOperations.length>0&&(this._currentOperations.forEach((function(t){t.reject(e)})),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach((function(t){t.reject(e)})),this._operationQueue=[])},t._addToQueue=function(e){var t=this;return new Promise((function(n,r){var i=0===t._operationQueue.length&&0===t._currentOperations.length,a=m({resolve:n,reject:r},e);t._operationQueue.push(a),i&&t._performNextOperation()}))},t._performNextOperation=function(){var e,t,n,r,i;if(0===this._currentOperations.length&&!this._sourceBuffer.updating){var a=this._operationQueue.shift();if(void 0!==a)if(0===a.operationName){this._currentOperations=[{operationName:0,resolve:a.resolve,reject:a.reject}];var o=a.params[0],s=a.params[1],u=o;if(this._operationQueue.length>0&&0===this._operationQueue[0].operationName){for(var l=[o instanceof ArrayBuffer?new Uint8Array(o):o instanceof Uint8Array?o:new Uint8Array(o.buffer)];0===(null===(e=this._operationQueue[0])||void 0===e?void 0:e.operationName);){var d=this._operationQueue[0],c=null!==(t=s.appendWindow)&&void 0!==t?t:[void 0,void 0],f=null!==(n=d.params[1].appendWindow)&&void 0!==n?n:[void 0,void 0],v=null!==(r=s.timestampOffset)&&void 0!==r?r:0,p=null!==(i=d.params[1].timestampOffset)&&void 0!==i?i:0;if(c[0]!==f[0]||c[1]!==f[1]||s.codec!==d.params[1].codec||v!==p)break;var h=d.params[0],m=void 0;m=h instanceof ArrayBuffer?new Uint8Array(h):h instanceof Uint8Array?h:new Uint8Array(h.buffer),l.push(m),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:d.resolve,reject:d.reject})}l.length>1&&(T.info("MMSI: Merging "+l.length+" segments together for perf",this.type),u=Xr.apply(void 0,l))}try{this._appendBufferNow(u,s)}catch(e){var g=e instanceof Error?new Kn(e.name,e.message,"QuotaExceededError"===e.name):new Kn("Error","Unknown SourceBuffer Error during appendBuffer",!1);this._currentOperations.forEach((function(e){e.reject(g)})),this._currentOperations=[]}}else{this._currentOperations=[a];var y=a.params,_=y[0],b=y[1];T.debug("SBI: removing data from SourceBuffer",this.type,_,b);try{this._sourceBuffer.remove(_,b)}catch(e){var S=e instanceof Error?new Kn(e.name,e.message,!1):new Kn("Error","Unknown SourceBuffer Error during remove",!1);a.reject(S),this._currentOperations=[]}}}},t._appendBufferNow=function(e,t){var n=this._sourceBuffer,r=t.codec,i=t.timestampOffset,a=t.appendWindow,o=void 0===a?[]:a;if(void 0!==r&&r!==this.codec){T.debug("SBI: updating codec",r);var s=function(e,t){if("function"==typeof e.changeType){try{e.changeType(t)}catch(e){return T.warn("Could not call 'changeType' on the given SourceBuffer:",e instanceof Error?e:""),!1}return!0}return!1}(n,r);s?this.codec=r:T.debug("SBI: could not update codec",r,this.codec)}if(void 0!==i&&n.timestampOffset!==i){var u=i;T.debug("SBI: updating timestampOffset",r,n.timestampOffset,u),n.timestampOffset=u}if(void 0===o[0])n.appendWindowStart>0&&(T.debug("SBI: re-setting `appendWindowStart` to `0`"),n.appendWindowStart=0);else if(o[0]!==n.appendWindowStart){if(o[0]>=n.appendWindowEnd){var l=o[0]+1;T.debug("SBI: pre-updating `appendWindowEnd`",l),n.appendWindowEnd=l}T.debug("SBI: setting `appendWindowStart`",o[0]),n.appendWindowStart=o[0]}void 0===o[1]?n.appendWindowEnd!==1/0&&(T.debug("SBI: re-setting `appendWindowEnd` to `Infinity`"),n.appendWindowEnd=1/0):o[1]!==n.appendWindowEnd&&(T.debug("SBI: setting `appendWindowEnd`",o[1]),n.appendWindowEnd=o[1]),T.debug("SBI: pushing segment",this.type),n.appendBuffer(e)},e}();var Pi,Di=Le();function Oi(e,t){if(null!==t&&e.src===t&&(T.info("Init: Clearing HTMLMediaElement's src"),xr(e)),null!==t)try{T.debug("Init: Revoking previous URL"),URL.revokeObjectURL(t)}catch(e){T.warn("Init: Error while revoking the media source URL",e instanceof Error?e:"")}}function Ni(e,t){return Ct(t,(function(n){var r=function(e,t){Oi(e,et(e.src)?e.src:null);var n=new Ci(Di());return t.register((function(){n.dispose()})),n}(e,t);if(r.addEventListener("mediaSourceOpen",(function(){T.info("Init: MediaSource opened"),n(r)}),t),T.info("MTCI: Attaching MediaSource URL to the media element"),"handle"===r.handle.type)e.srcObject=r.handle.value,t.register((function(){Oi(e,null)}));else{var i=URL.createObjectURL(r.handle.value);e.src=i,t.register((function(){Oi(e,i)}))}}))}function Li(e,n,r){var i;if(!t(r)){var a=Ve(e),o=We(e);if(!t(r.position))return T.debug("Init: using startAt.minimumPosition"),Math.max(Math.min(r.position,o),a);if(!t(r.wallClockTime)){T.debug("Init: using startAt.wallClockTime");var s=void 0===e.availabilityStartTime?0:e.availabilityStartTime,u=r.wallClockTime-s;return Math.max(Math.min(u,o),a)}if(!t(r.fromFirstPosition)){T.debug("Init: using startAt.fromFirstPosition");var l=r.fromFirstPosition;return l<=0?a:Math.min(o,a+l)}if(!t(r.fromLastPosition)){T.debug("Init: using startAt.fromLastPosition");var d=r.fromLastPosition;return d>=0?o:Math.max(a,o+d)}if(!t(r.fromLivePosition)){T.debug("Init: using startAt.fromLivePosition");var c=null!==(i=Ke(e))&&void 0!==i?i:o,f=r.fromLivePosition;return f>=0?c:Math.max(a,c+f)}if(!t(r.percentage)){T.debug("Init: using startAt.percentage");var v=r.percentage;return v>100?o:v<0?a:a+(o-a)*(+v/100)}}var p=Ve(e);if(e.isLive){var h,m=e.suggestedPresentationDelay,g=e.clockOffset,y=We(e),_=b.getCurrent().DEFAULT_LIVE_GAP;if(void 0===g)T.info("Init: no clock offset found for a live content, starting close to maximum available position"),h=y;else{T.info("Init: clock offset found for a live content, checking if we can start close to it");var S=void 0===e.availabilityStartTime?0:e.availabilityStartTime,E=(ne()+g)/1e3-S;h=Math.min(y,E)}var k=null!=m?m:n?_.LOW_LATENCY:_.DEFAULT;return T.debug("Init: "+h+" defined as the live time, applying a live gap of "+k),Math.max(h-k,p)}return T.info("Init: starting at the minimum available position:",p),p}function Ui(){return yi}function Fi(e,t,n,r){var i=new Z;i.linkToSignal(r);var a=new G(!1,i.signal);return e.listen((function(e){if(null===e.rebuffering&&null===e.freezing&&0!==e.readyState){if(!function(e,t){return!e||!gi||t}(n,t.hasAttribute("playsinline"))&&t.duration>0)return a.setValue(!0),void i.cancel();var r=Ei?4:3;return e.readyState>=r&&(null!==e.currentRange||e.ended)&&(!Ui()||t.duration>0)?(a.setValue(!0),void i.cancel()):void 0}}),{includeLastObservation:!0,clearSignal:i.signal}),a}function Bi(e,t){var n=e.mediaElement,r=e.playbackObserver,i=e.startTime,a=e.mustAutoPlay,o=e.isDirectfile,s=e.onWarning,u=new G(!1,t),l=new Promise((function(e,l){var d=t.register((function(e){l(e)}));if(!t.isCancelled()){var c=!1,f=function(e){r.setCurrentTime(e),c=!0};if(o&&"number"!=typeof i)r.listen((function(e,t){if(e.readyState>=1){t();var n="number"==typeof i?i:i();0!==n&&(gi?setTimeout((function(){f(n)}),0):f(n)),p()}}),{includeLastObservation:!0,clearSignal:t});else{var v="number"==typeof i?i:i();0!==v&&f(v),p()}}function p(){var i=!1;r.listen((function(o,f){if(i||0===o.seeking||(i=!0),(!c||i)&&0!==o.readyState){if(f(),Ui()&&0===n.duration){var v=new Me("MEDIA_ERR_NOT_LOADED_METADATA","Cannot load automatically: your browser falsely announced having loaded the content.");s(v)}t.isCancelled()||r.listen((function(r,i){0===r.seeking&&null===r.rebuffering&&r.readyState>=1&&(i(),function(){var r,i;if(T.info("Init: Can begin to play content"),!a)return n.autoplay&&T.warn("Init: autoplay is enabled on HTML media element. Media will play as soon as possible."),u.setValue(!0),u.finish(),d(),e({type:"skipped"});if(n.ended)return T.warn("Init: autoplay is enabled but the video is ended. Skipping autoplay to prevent video to start again"),u.setValue(!0),u.finish(),d(),e({type:"skipped"});try{i=null!==(r=n.play())&&void 0!==r?r:Promise.resolve()}catch(e){return d(),l(e)}i.then((function(){if(!t.isCancelled())return u.setValue(!0),u.finish(),d(),e({type:"autoplay"})})).catch((function(n){if(d(),!t.isCancelled()){if(n instanceof Error&&"NotAllowedError"===n.name){T.warn("Init: Media element can't play. It may be due to browser auto-play policies.");var r=new Me("MEDIA_ERR_BLOCKED_AUTOPLAY","Cannot trigger auto-play automatically: your browser does not allow it.");if(s(r),t.isCancelled())return;return e({type:"autoplay-blocked"})}l(n)}}))}())}),{includeLastObservation:!0,clearSignal:t})}}),{includeLastObservation:!0,clearSignal:t})}}));return{autoPlayResult:l,initialPlayPerformed:u}}function zi(e,t,n,r,i){if(0===t.length)return l("No `keySystems` option given.");if(null===ot.decrypt)return l("EME feature not activated.");var a=new Z;a.linkToSignal(i);var o=new G({initializationState:{type:"uninitialized",value:null},drmSystemId:void 0},i),s=ot.decrypt;if(!s.hasEmeApis())return l("EME API not available on the current page.");T.debug("Init: Creating ContentDecryptor");var u=new s(e,t);return u.addEventListener("stateChange",(function(e){if(e===Pi.WaitingForAttachment){var t=new G(!1);t.onUpdate((function(t,n){t&&(n(),e===Pi.WaitingForAttachment&&u.attach())}),{clearSignal:a.signal}),o.setValue({initializationState:{type:"awaiting-media-link",value:{isMediaLinked:t}},drmSystemId:u.systemId})}else e===Pi.ReadyForContent&&(o.setValue({initializationState:{type:"initialized",value:null},drmSystemId:u.systemId}),u.removeEventListener("stateChange"))})),u.addEventListener("error",(function(e){a.cancel(),r.onError(e)})),u.addEventListener("warning",(function(e){r.onWarning(e)})),u.addEventListener("blackListProtectionData",(function(e){r.onBlackListProtectionData(e)})),u.addEventListener("keyIdsCompatibilityUpdate",(function(e){r.onKeyIdsCompatibilityUpdate(e)})),n.onUpdate((function(e){null!==e&&u.onInitializationData(e)}),{clearSignal:a.signal}),a.signal.register((function(){u.dispose()})),o;function l(e){n.onUpdate((function(t,n){if(null!==t){n();var i=new Ce("MEDIA_IS_ENCRYPTED_ERROR",e);r.onError(i)}}),{clearSignal:i});var t=new G({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return t.finish(),t}}!function(e){e[e.Initializing=0]="Initializing",e[e.WaitingForAttachment=1]="WaitingForAttachment",e[e.ReadyForContent=2]="ReadyForContent",e[e.Error=3]="Error",e[e.Disposed=4]="Disposed"}(Pi||(Pi={}));var Vi=function(){function e(e){this._displayer=e}var t=e.prototype;return t.pushTextData=function(e){try{return Promise.resolve(this._displayer.pushTextData(e))}catch(e){return Promise.reject(e)}},t.remove=function(e,t){try{return Promise.resolve(this._displayer.removeBuffer(e,t))}catch(e){return Promise.reject(e)}},t.reset=function(){this._displayer.reset()},t.stop=function(){this._displayer.stop()},e}(),Ki=1/60,Wi=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._playbackObserver=t,i._manifest=n,i._speed=r,i._discontinuitiesStore=[],i._isStarted=!1,i._canceller=new Z,i}f(t,e);var n=t.prototype;return n.start=function(){var e=this;if(!this._isStarted){this._isStarted=!0;var t=new Hi(this._playbackObserver,this._speed);this._canceller.signal.register((function(){t.dispose()}));var n=null;this._playbackObserver.listen((function(r){var i,a=e._discontinuitiesStore,o=r.buffered,s=r.position,u=r.readyState,l=r.rebuffering,d=r.freezing,c=b.getCurrent(),f=c.BUFFER_DISCONTINUITY_THRESHOLD,v=c.FREEZING_STALLED_DELAY,p=c.UNFREEZING_SEEK_DELAY,h=c.UNFREEZING_DELTA_POSITION;if(null!==d){var m=ne(),g=null===n?d.timestamp:n.attemptTimestamp;if(!s.isAwaitingFuturePosition()&&m-g>p&&(T.warn("Init: trying to seek to un-freeze player"),e._playbackObserver.setCurrentTime(e._playbackObserver.getCurrentTime()+h),n={attemptTimestamp:m}),m-d.timestamp>v)return null===l?t.stopRebuffering():t.startRebuffering(),void e.trigger("stalled","freezing")}else n=null;if(null===l)return t.stopRebuffering(),1===u?(i=0!==r.seeking?1===r.seeking?"internal-seek":"seeking":"not-ready",void e.trigger("stalled",i)):void e.trigger("unstalled",null);var y="seeking"===l.reason&&1===r.seeking?"internal-seek":l.reason;if(s.isAwaitingFuturePosition())return t.stopRebuffering(),T.debug("Init: let rebuffering happen as we're awaiting a future position"),void e.trigger("stalled",y);if(t.startRebuffering(),null!==e._manifest){var _=l.position;if(null!=_&&e._speed.getValue()>0){var S=function(e,t,n){if(0===e.length)return null;for(var r=null,i=0;i<e.length;i++){var a=e[i].period;if(a.start>n)return r;var o=void 0;if(void 0===a.end||a.end>n){var s=e[i],u=s.discontinuity,l=s.position,d=u.start,c=u.end;if(n>=(null!=d?d:l)-Ki)if(null===c){var f=je(t,a);null!==f?o=f.start+Ki:T.warn("Init: discontinuity at Period's end but no next Period")}else n<c+Ki&&(o=c+Ki);void 0!==o&&(T.info("Init: discontinuity found",n,o),r=null!==r&&r>o?r:o)}}return r}(a,e._manifest,_);if(null!==S){var E=S+.001;if(!(E<=e._playbackObserver.getCurrentTime()))return T.warn("SA: skippable discontinuity found in the stream",s.getPolled(),E),e._playbackObserver.setCurrentTime(E),void e.trigger("warning",ji(_,E));T.info("Init: position to seek already reached, no seeking",e._playbackObserver.getCurrentTime(),E)}}var k=null!=_?_:s.getPolled(),w=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e.start(r);if(t<i)return i-t}return 1/0}(o,k);if(e._speed.getValue()>0&&w<f){var A=k+w+Ki;if(e._playbackObserver.getCurrentTime()<A)return T.warn("Init: discontinuity encountered inferior to the threshold",k,A,f),e._playbackObserver.setCurrentTime(A),void e.trigger("warning",ji(k,A))}for(var I=e._manifest.periods.length-2;I>=0;I--){var R=e._manifest.periods[I];if(void 0!==R.end&&R.end<=k){if(e._manifest.periods[I+1].start>k&&e._manifest.periods[I+1].start>e._playbackObserver.getCurrentTime()){var x=e._manifest.periods[I+1];return e._playbackObserver.setCurrentTime(x.start),void e.trigger("warning",ji(k,x.start))}break}}e.trigger("stalled",y)}else e.trigger("stalled",y)}),{includeLastObservation:!0,clearSignal:this._canceller.signal})}},n.updateDiscontinuityInfo=function(e){this._isStarted||this.start();var t=this._playbackObserver.getReference().getValue();!function(e,t,n){var r=Math.min(n.position.getPolled(),n.position.getWanted());for(;e.length>0&&void 0!==e[0].period.end&&e[0].period.end+10<r;)e.shift();var i=t.period,a=t.bufferType;if("audio"!==a&&"video"!==a)return;for(var o=0;o<e.length;o++)if(e[o].period.id===i.id){if(e[o].bufferType===a)return void(Gi(t)?e[o]=t:e.splice(o,1))}else if(e[o].period.start>i.start)return void(Gi(t)&&e.splice(o,0,t));Gi(t)&&e.push(t)}(this._discontinuitiesStore,e,t)},n.onLockedStream=function(e,t){var n;this._isStarted||this.start();var r=this._playbackObserver.getReference().getValue();if(!(!r.rebuffering||r.paused||this._speed.getValue()<=0||"audio"!==e&&"video"!==e)){var i=r.position.getWanted(),a=null!==(n=r.rebuffering.position)&&void 0!==n?n:i,o=t.start;i<o&&Math.abs(a-o)<1&&(T.warn("Init: rebuffering because of a future locked stream.\nTrying to unlock by seeking to the next Period"),this._playbackObserver.setCurrentTime(o+.001))}},n.destroy=function(){this._canceller.cancel()},t}(i);function Gi(e){return null!==e.discontinuity}function ji(e,t){return new Me("DISCONTINUITY_ENCOUNTERED","A discontinuity has been encountered at position "+String(e)+", seeked at position "+String(t))}var Hi=function(){function e(e,t){this._speedUpdateCanceller=new Z,this._isRebuffering=!1,this._playbackObserver=e,this._isDisposed=!1,this._speed=t,this._updateSpeed()}var t=e.prototype;return t.startRebuffering=function(){this._isRebuffering||this._isDisposed||(this._isRebuffering=!0,this._speedUpdateCanceller.cancel(),T.info("Init: Pause playback to build buffer"),this._playbackObserver.setPlaybackRate(0))},t.stopRebuffering=function(){this._isRebuffering&&!this._isDisposed&&(this._isRebuffering=!1,this._speedUpdateCanceller=new Z,this._updateSpeed())},t.dispose=function(){this._speedUpdateCanceller.cancel(),this._isDisposed=!0},t._updateSpeed=function(){var e=this;this._speed.onUpdate((function(t){T.info("Init: Resume playback speed",t),e._playbackObserver.setPlaybackRate(t)}),{clearSignal:this._speedUpdateCanceller.signal,emitCurrentValue:!0})},e}();var qi=function(e,t){return e.id===t.id&&e.start===t.start&&e.end===t.end};var Yi=function(e,t){for(var n=[],r=t.periods,i=0;i<r.length;i++){r[i].streamEvents.forEach((function(t){for(var r,i=t.start,a=t.end,o=t.id,s=t.data,u=0;u<e.length;u++){var l=e[u];if(qi(l,{id:o,start:i,end:a}))return void n.push(l)}if(void 0!==s.value.element)r=s.value.element;else{if(void 0===s.value.xmlData)return;var d=s.value.xmlData.namespaces.reduce((function(e,t){return e+"xmlns:"+t.key+'="'+t.value+'" '}),"<toremove ");d+=">";var c=(new DOMParser).parseFromString(d+s.value.xmlData.data+"</toremove>","application/xml").documentElement;r=c.children.length>0?c.children[0]:c.childNodes[0]}var f={type:s.type,value:Object.assign(Object.assign({},s.value),{element:r})};if(void 0===a){var v={start:i,id:o,data:f,publicEvent:{start:i,data:f}};n.push(v)}else{var p={start:i,end:a,id:o,data:f,publicEvent:{start:i,end:a,data:f}};n.push(p)}}))}return n};function Qi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $i(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function $i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Xi=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._manifest=t,i._mediaElement=n,i._playbackObserver=r,i._canceller=null,i._scheduledEventsRef=new G([]),i._eventsBeingPlayed=new WeakMap,i}f(t,e);var n=t.prototype;return n.start=function(){var e=this;if(null===this._canceller){this._canceller=new Z;var t=this._canceller.signal,n=this._playbackObserver,r=this._mediaElement,i=!1,a=new Z;a.linkToSignal(t),this._scheduledEventsRef.setValue(Yi([],this._manifest)),this._scheduledEventsRef.onUpdate((function(o){if(0!==o.length){if(!i){i=!0;var s=c(),u=function(){var t=c();e._emitStreamEvents(e._scheduledEventsRef.getValue(),s,t,a.signal),s=t},l=b.getCurrent().STREAM_EVENT_EMITTER_POLL_INTERVAL,d=setInterval(u,l);n.listen(u,{includeLastObservation:!1,clearSignal:a.signal}),a.signal.register((function(){clearInterval(d)}))}}else i&&(a.cancel(),(a=new Z).linkToSignal(t),i=!1);function c(){var e=n.getReference().getValue();return{currentTime:r.currentTime,isSeeking:0!==e.seeking}}}),{emitCurrentValue:!0,clearSignal:t})}},n.onManifestUpdate=function(e){var t=this._scheduledEventsRef.getValue();this._scheduledEventsRef.setValue(Yi(t,e))},n.stop=function(){null!==this._canceller&&(this._canceller.cancel(),this._canceller=null)},n._emitStreamEvents=function(e,t,n,r){for(var i=t.currentTime,a=n.isSeeking,o=n.currentTime,s=[],u=[],l=0;l<e.length;l++){var d=e[l],c=d.start,f=Zi(d)?d.end:void 0;this._eventsBeingPlayed.has(d)?(c>o||void 0!==f&&o>=f)&&(Zi(d)&&u.push(d.publicEvent),this._eventsBeingPlayed.delete(d)):c<=o&&void 0!==f&&o<f?(s.push({type:"stream-event",value:d.publicEvent}),this._eventsBeingPlayed.set(d,!0)):i<c&&o>=(null!=f?f:c)&&(a?s.push({type:"stream-event-skip",value:d.publicEvent}):(s.push({type:"stream-event",value:d.publicEvent}),Zi(d)&&u.push(d.publicEvent)))}if(s.length>0)for(var v,p=Qi(s);!(v=p()).done;){var h=v.value;if("stream-event"===h.type?this.trigger("event",h.value):this.trigger("eventSkip",h.value),r.isCancelled())return}if(u.length>0)for(var m,g=Qi(u);!(m=g()).done;){var y=m.value;if("function"==typeof y.onExit&&y.onExit(),r.isCancelled())return}},t}(i);function Zi(e){return void 0!==e.end}var Ji=Xi;function ea(e,n,r){function i(){var r,i,a=e.error;switch(t(a)||(r=a.code,i=a.message),r){case 1:return n(new Me("MEDIA_ERR_ABORTED",i=null!=i?i:"The fetching of the associated resource was aborted by the user's request."));case 2:return n(new Me("MEDIA_ERR_NETWORK",i=null!=i?i:"A network error occurred which prevented the media from being successfully fetched"));case 3:return n(new Me("MEDIA_ERR_DECODE",i=null!=i?i:"An error occurred while trying to decode the media resource"));case 4:return n(new Me("MEDIA_ERR_SRC_NOT_SUPPORTED",i=null!=i?i:"The media resource has been found to be unsuitable."));default:return n(new Me("MEDIA_ERR_UNKNOWN",i=null!=i?i:"The HTMLMediaElement errored due to an unknown reason."))}}r.isCancelled()||(e.addEventListener("error",i),r.register((function(){e.removeEventListener("error",i)})))}function ta(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return na(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return na(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function na(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ra=function(e){function t(t){var n;(n=e.call(this)||this)._settings=t,n._initCanceller=new Z,n._manifest=null;var r=void 0===t.url?void 0:[t.url];return n._manifestFetcher=new zt(r,t.transport,t.manifestRequestSettings),n}f(t,e);var n=t.prototype;return n.prepare=function(){var e=this;null===this._manifest&&(this._manifest=Sr.createAsync(Ct(this._initCanceller.signal,(function(t,n){e._manifestFetcher.addEventListener("warning",(function(t){return e.trigger("warning",t)})),e._manifestFetcher.addEventListener("error",(function(t){e.trigger("error",t),n(t)})),e._manifestFetcher.addEventListener("manifestReady",(function(e){t(e)}))}))),this._manifestFetcher.start(),this._initCanceller.signal.register((function(){e._manifestFetcher.dispose()})))},n.start=function(e,t){var n=this;this.prepare(),ea(e,(function(e){return n._onFatalError(e)}),this._initCanceller.signal);var r=new G(null,this._initCanceller.signal);this._initializeMediaSourceAndDecryption(e,r).then((function(i){return n._onInitialMediaSourceReady(e,i.mediaSource,t,i.drmSystemId,r,i.unlinkMediaSource)})).catch((function(e){n._onFatalError(e)}))},n.updateContentUrls=function(e,t){this._manifestFetcher.updateContentUrls(e,t)},n.dispose=function(){this._initCanceller.cancel()},n._onFatalError=function(e){this._initCanceller.isUsed()||(this._initCanceller.cancel(),this.trigger("error",e))},n._initializeMediaSourceAndDecryption=function(e,t){var n=this,r=this._initCanceller;return Ct(r.signal,(function(i){var a=n._settings.keySystems,o=zi(e,a,t,{onWarning:function(e){return n.trigger("warning",e)},onError:function(e){return n._onFatalError(e)},onBlackListProtectionData:function(e){d(p().mark((function t(){var r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==n._manifest){t.next=2;break}return t.abrupt("return");case 2:if(null===(r=n._manifest.syncValue)||void 0===r){t.next=6;break}t.t0=r,t.next=9;break;case 6:return t.next=8,n._manifest.getValueAsAsync();case 8:t.t0=t.sent;case 9:aa(t.t0,e);case 11:case"end":return t.stop()}}),t)})))().catch(S)},onKeyIdsCompatibilityUpdate:function(e){d(p().mark((function t(){var r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==n._manifest){t.next=2;break}return t.abrupt("return");case 2:if(null===(r=n._manifest.syncValue)||void 0===r){t.next=6;break}t.t0=r,t.next=9;break;case 6:return t.next=8,n._manifest.getValueAsAsync();case 8:t.t0=t.sent;case 9:ia(t.t0,e.whitelistedKeyIds,e.blacklistedKeyIds,e.delistedKeyIds);case 11:case"end":return t.stop()}}),t)})))().catch(S)}},r.signal);o.onUpdate((function(t,a){if("uninitialized"!==t.initializationState.type){a();var s=new Z;s.linkToSignal(r.signal),Ni(e,s.signal).then((function(e){var n=o.getValue();if("awaiting-media-link"===n.initializationState.type)n.initializationState.value.isMediaLinked.setValue(!0),o.onUpdate((function(t,n){if("initialized"===t.initializationState.type)return n(),void i({mediaSource:e,drmSystemId:t.drmSystemId,unlinkMediaSource:s})}),{emitCurrentValue:!0,clearSignal:r.signal});else if("initialized"===t.initializationState.type)return void i({mediaSource:e,drmSystemId:t.drmSystemId,unlinkMediaSource:s})})).catch((function(e){s.isUsed()||n._onFatalError(e)}))}}),{emitCurrentValue:!0,clearSignal:r.signal})}))},n._onInitialMediaSourceReady=function(){var e=d(p().mark((function e(t,n,r,i,a,o){var s,u,l,d,c,f,v,h,g,y,_,b,S,E,k,w,A,I,R,x,C,M=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(C=function(e,n,i,o){I({mediaElement:t,playbackObserver:r,mediaSource:e,initialTime:n,autoPlay:i,manifest:S,representationEstimator:k,segmentFetcherCreator:A,speed:h,protectionRef:a,bufferOptions:w},(function(e){if(o.cancel(),b.isUsed())return;if(R("reloadingMediaSource",e),b.isUsed())return;var n=new Z;n.linkToSignal(b.signal),Ni(t,n.signal).then((function(t){C(t,e.position,e.autoPlay,n)})).catch((function(e){n.isUsed()||x(e)}))}),o.signal)},u=this._settings,l=u.adaptiveOptions,d=u.autoPlay,c=u.bufferOptions,f=u.lowLatencyMode,v=u.segmentRequestOptions,h=u.speed,g=u.startAt,y=u.textTrackOptions,_=u.transport,b=this._initCanceller,$(this._manifest),e.prev=4,null===(s=this._manifest.syncValue)||void 0===s){e.next=9;break}e.t0=s,e.next=12;break;case 9:return e.next=11,this._manifest.getValueAsAsync();case 11:e.t0=e.sent;case 12:S=e.t0,e.next=18;break;case 15:return e.prev=15,e.t1=e.catch(4),e.abrupt("return");case 18:if(S.addEventListener("manifestUpdate",(function(e){M.trigger("manifestUpdate",e)}),b.signal),S.addEventListener("decipherabilityUpdate",(function(e){M.trigger("decipherabilityUpdate",e)}),b.signal),T.debug("Init: Calculating initial time"),E=Li(S,f,g),T.debug("Init: Initial time calculated:",E),k=Te(l),w=m({textTrackOptions:y,drmSystemId:i},c),A=new Zt(_,v,b.signal),this.trigger("manifestReady",S),!b.isUsed()){e.next=29;break}return e.abrupt("return");case 29:I=this._startBufferingOnMediaSource.bind(this),R=this.trigger.bind(this),x=this._onFatalError.bind(this),C(n,E,d,o);case 33:case"end":return e.stop()}}),e,this,[[4,15]])})));return function(t,n,r,i,a,o){return e.apply(this,arguments)}}(),n._startBufferingOnMediaSource=function(e,t,n){var r,i=this,a=e.autoPlay,o=e.bufferOptions,s=e.initialTime,u=e.manifest,l=e.mediaElement,d=e.mediaSource,c=e.playbackObserver,f=e.protectionRef,v=e.representationEstimator,p=e.segmentFetcherCreator,h=e.speed,m=null!==(r=u.getPeriodForTime(s))&&void 0!==r?r:u.getNextPeriod(s);if(void 0===m){var g=new Me("MEDIA_STARTING_TIME_NOT_FOUND","Wanted starting time not found in the Manifest.");return this._onFatalError(g)}var y=null,_=null;if("html"===this._settings.textTrackOptions.textTrackMode&&null!==ot.htmlTextDisplayer?_=new ot.htmlTextDisplayer(l,this._settings.textTrackOptions.textTrackElement):null!==ot.nativeTextDisplayer&&(_=new ot.nativeTextDisplayer(l)),null!==_){var S=new Vi(_);y=S,n.register((function(){S.stop(),null==_||_.stop()}))}var E=new Mn(d,"VIDEO"===l.nodeName,y);n.register((function(){E.disposeAll()}));var k=Bi({mediaElement:l,playbackObserver:c,startTime:s,mustAutoPlay:a,onWarning:function(e){i.trigger("warning",e)},isDirectfile:!1},n),w=k.autoPlayResult,A=k.initialPlayPerformed;if(!n.isCancelled()){A.onUpdate((function(e,t){if(e){t();var r=new Ji(u,l,c);u.addEventListener("manifestUpdate",(function(){r.onManifestUpdate(u)}),n),r.addEventListener("event",(function(e){i.trigger("streamEvent",e)}),n),r.addEventListener("eventSkip",(function(e){i.trigger("streamEventSkip",e)}),n),r.start(),n.register((function(){r.stop()}))}}),{clearSignal:n,emitCurrentValue:!0});var I=Ir(c,{autoPlay:a,manifest:u,mediaSource:d,textDisplayer:_,initialPlayPerformed:A,speed:h},n),R=this._createRebufferingController(c,u,h,n),x=new ln(E);c.listen((function(e){if(x.needToReload(e)){var n,r=c.getReference().getValue();n=r.position.isAwaitingFuturePosition()?r.position.getWanted():c.getCurrentTime();var i=A.getValue()?!c.getIsPaused():a;t({position:n,autoPlay:i})}}),{clearSignal:n}),I.listen((function(e){["video","audio","text"].forEach((function(t){var n,r=E.getStatus(t);"initialized"===r.type&&r.value.synchronizeInventory(null!==(n=e.buffered[t])&&void 0!==n?n:[])}))}),{clearSignal:n});var C=function(e,t,n,r,i,a){a.register((function(){t.interruptDurationSetting()}));var o=new nn(e,n,r.getBufferTypes());a.register((function(){o.dispose()})),o.addEventListener("warning",(function(e){return i.onWarning(e)})),o.addEventListener("periodChange",(function(e){return i.onPeriodChanged(e)})),o.addEventListener("endingPositionChange",(function(e){t.setDuration(e.endingPosition,e.isEnd)})),o.addEventListener("endOfStream",(function(){T.debug("Init: end-of-stream order received."),t.maintainEndOfStream()})),o.addEventListener("resumeStream",(function(){t.stopEndOfStream()}));var s=o.getCurrentEndingTime();return t.setDuration(s.endingPosition,s.isEnd),o}(u,d,I,E,{onWarning:function(e){return i.trigger("warning",e)},onPeriodChanged:function(e){return i.trigger("activePeriodChanged",{period:e})}},n);w.then((function(){Fi(c,l,!1,n).onUpdate((function(e,t){e&&(t(),i.trigger("loaded",{segmentSinksStore:E}))}),{emitCurrentValue:!0,clearSignal:n})})).catch((function(e){n.isCancelled()||i._onFatalError(e)}));var M=this;br({manifest:u,initialPeriod:m},I,v,E,p,o,{needsBufferFlush:function(e){var t,r,i=c.getCurrentTime(),a=null!==(t=null==e?void 0:e.relativeResumingPosition)&&void 0!==t?t:0,o=Boolean(null==e?void 0:e.relativePosHasBeenDefaulted);r=0===a&&o?i+.001:i+a,c.setCurrentTime(r),c.listen((function(e,t){(null!==e.currentRange||e.position.getPolled()>r+.1)&&(t(),c.setCurrentTime(e.position.getWanted()+.001))}),{includeLastObservation:!1,clearSignal:n})},streamStatusUpdate:function(e){var t=e.period,r=e.bufferType,i=e.imminentDiscontinuity,a=e.position;R.updateDiscontinuityInfo({period:t,bufferType:r,discontinuity:i,position:a}),n.isCancelled()||u.isLastPeriodKnown&&e.period.id===u.periods[u.periods.length-1].id&&(e.hasFinishedLoading||e.isEmptyStream?C.onLastSegmentFinishedLoading(e.bufferType):C.onLastSegmentLoadingResume(e.bufferType))},needsManifestRefresh:function(){return M._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync:function(){var e=b.getCurrent().OUT_OF_SYNC_MANIFEST_REFRESH_DELAY;M._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:e})},lockedStream:function(e){return R.onLockedStream(e.bufferType,e.period)},adaptationChange:function(e){M.trigger("adaptationChange",e),n.isCancelled()||C.onAdaptationChange(e.type,e.period,e.adaptation)},representationChange:function(e){M.trigger("representationChange",e),n.isCancelled()||C.onRepresentationChange(e.type,e.period)},inbandEvent:function(e){return M.trigger("inbandEvents",e)},warning:function(e){return M.trigger("warning",e)},periodStreamReady:function(e){return M.trigger("periodStreamReady",e)},periodStreamCleared:function(e){C.onPeriodCleared(e.type,e.period),n.isCancelled()||M.trigger("periodStreamCleared",e)},bitrateEstimateChange:function(e){return M.trigger("bitrateEstimateChange",e)},needsMediaSourceReload:function(e){var n,r,i,a=I.getReference().getValue(),o=a.position.isAwaitingFuturePosition()?a.position.getWanted():null!==(n=I.getCurrentTime())&&void 0!==n?n:a.position.getPolled(),s=null!==(i=null!==(r=a.paused.pending)&&void 0!==r?r:I.getIsPaused())&&void 0!==i?i:a.paused.last,u=o+e.timeOffset;void 0!==e.minimumPosition&&(u=Math.max(e.minimumPosition,u)),void 0!==e.maximumPosition&&(u=Math.min(e.maximumPosition,u)),t({position:u,autoPlay:!s})},needsDecipherabilityFlush:function(){var e,n,r,i,a,o=kr(l);if(void 0===(a=null==o?void 0:o[0])||a.indexOf("widevine")<0){var s=I.getReference().getValue(),u=s.position.isAwaitingFuturePosition()?s.position.getWanted():null!==(e=I.getCurrentTime())&&void 0!==e?e:s.position.getPolled(),d=null!==(r=null!==(n=s.paused.pending)&&void 0!==n?n:I.getIsPaused())&&void 0!==r?r:s.paused.last;t({position:u,autoPlay:!d})}else{var f=I.getReference().getValue(),v=f.position.isAwaitingFuturePosition()?f.position.getWanted():null!==(i=I.getCurrentTime())&&void 0!==i?i:f.position.getPolled();v+.001<f.duration?c.setCurrentTime(l.currentTime+.001):c.setCurrentTime(v)}},encryptionDataEncountered:function(e){for(var t,r=ta(e);!(t=r()).done;){var i=t.value;if(f.setValue(i),n.isCancelled())return}},error:function(e){return M._onFatalError(e)}},n)}},n._createRebufferingController=function(e,t,n,r){var i=this,a=new Wi(e,t,n);return a.addEventListener("stalled",(function(e){return i.trigger("stalled",e)})),a.addEventListener("unstalled",(function(){return i.trigger("unstalled",null)})),a.addEventListener("warning",(function(e){return i.trigger("warning",e)})),r.register((function(){return a.destroy()})),a.start(),a},t}(wr);function ia(e,t,n,r){e.updateRepresentationsDeciperability((function(e){var i=e.representation;if(void 0===i.contentProtections)return i.decipherable;var a=i.contentProtections.keyIds;if(void 0!==a)for(var o,s=ta(a);!(o=s()).done;){for(var u,l=o.value,d=ta(n);!(u=d()).done;){if(st(u.value,l.keyId))return!1}for(var c,f=ta(t);!(c=f()).done;){if(st(c.value,l.keyId))return!0}for(var v,p=ta(r);!(v=p()).done;){if(st(v.value,l.keyId))return}}return i.decipherable}))}function aa(e,t){e.updateRepresentationsDeciperability((function(e){var n,r,i=e.representation;if(!1===i.decipherable)return!1;for(var a,o,s=function(){var e=o.value;if((void 0===t.type||e.type===t.type)&&t.values.getFormattedValues().every((function(t){return e.values.some((function(e){return(void 0===t.systemId||e.systemId===t.systemId)&&st(e.data,t.data)}))})))return{v:!1}},u=ta(null!==(r=null===(n=i.contentProtections)||void 0===n?void 0:n.initData)&&void 0!==r?r:[]);!(o=u()).done;)if(a=s())return a.v;return i.decipherable}))}var oa=new Map;var sa=new(function(){function e(){this._cachedCodecSupport=new Map}return e.prototype.isSupported=function(e,n){var r=(null!=e?e:"")+';codecs="'+(null!=n?n:"")+'"',i=this._cachedCodecSupport.get(r);if(void 0!==i)return i;this._cachedCodecSupport.size>=50&&this._cachedCodecSupport.clear();var o=function(e){if(t(Mr))return a&&T.error("Compat: Cannot request codec support in a worker without MSE."),!1;if("function"==typeof Mr.isTypeSupported){var n=oa.get(e);if(void 0!==n)return n;var r=Mr.isTypeSupported(e);return oa.size>=200&&oa.clear(),oa.set(e,r),r}return!0}(r);return this._cachedCodecSupport.set(r,o),o},e}());function ua(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return la(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return la(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function la(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function da(e,t){for(var n,r=e,i=ua(t);!(n=i()).done;){var a=ca(r,n.value);if(null===a)return null;r=a}return r}function ca(e,t){var n=fa(e,t);return null!==n?e.subarray(n[1],n[2]):null}function fa(e,t){for(var n,r,i=e.length,a=0,o=0;a+8<=i;){if(o=ei(e,r=a),n=ei(e,r+=4),r+=4,0===o)o=i-a;else if(1===o){if(r+8>i)return null;o=ti(e,r),r+=8}if(o<0)throw new Error("ISOBMFF: Size out of range");if(n===t)return 1970628964===t&&(r+=16),[a,r,a+o];a+=o}return null}function va(e,t,n,r,i){for(var a,o=e.length,s=0;s<o;s+=a){var u=s;a=ei(e,u);var l=ei(e,u+=4);if(u+=4,0===a)a=o-s;else if(1===a){if(u+8>o)return;a=ti(e,u),u+=8}if(1970628964===l&&u+16<=o&&ei(e,u)===t&&ei(e,u+4)===n&&ei(e,u+8)===r&&ei(e,u+12)===i)return u+=16,e.subarray(u,s+a)}}function pa(e){var t=e.length;if(t<8)return T.warn("ISOBMFF: box inferior to 8 bytes, cannot find offsets"),null;var n=0,r=ei(e,n),i=ei(e,n+=4);if(n+=4,0===r)r=t;else if(1===r){if(n+8>t)return T.warn("ISOBMFF: box too short, cannot find offsets"),null;r=ti(e,n),n+=8}if(r<0)throw new Error("ISOBMFF: Size out of range");return 1970628964===i&&(n+=16),[0,n,r]}function ha(e){var t=ca(e,1836019558);return null===t?null:ca(t,1953653094)}function ma(e){var t=function(e,t){for(var n=[],r=e;;){var i=fa(r,t);if(null===i)return n;$(0!==i[2]&&r.length),n.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}(e,1836019558);return t.reduce((function(e,t){var n=ca(t,1953653094);return null!==n&&e.push(n),e}),[])}function ga(e){return ca(e,1835295092)}function ya(e,t){return void 0===t&&(t=0),ca(e.subarray(t),1701671783)}var _a=/^(?:[a-z]+:)?\/\//i,ba=/\/\.{1,2}\//;function Sa(){var e=arguments.length;if(0===e)return"";for(var t="",n=0;n<e;n++){var r=n<0||arguments.length<=n?void 0:arguments[n];"string"==typeof r&&""!==r&&(_a.test(r)?t=r:("/"===r[0]&&(r=r.substring(1)),"/"===t[t.length-1]&&(t=t.substring(0,t.length-1)),t=t+"/"+r))}return function(e){if(!ba.test(e))return e;for(var t=[],n=e.split("/"),r=0,i=n.length;r<i;r++)if(".."===n[r])t.pop();else{if("."===n[r])continue;t.push(n[r])}return t.join("/")}(t)}function Ea(e){var t=e.lastIndexOf("/");if(t<0)return e.length;if(_a.test(e)){var n=e.indexOf("/");if(n>=0&&t===n+1)return e.length}var r=e.indexOf("?");return r>=0&&r<t?Ea(e.substring(0,r)):t+1}var Ta="object"==typeof s&&"function"==typeof s.TextDecoder,ka="object"==typeof s&&"function"==typeof s.TextEncoder;function wa(e){if(Ta)try{return new TextDecoder("utf-16le").decode(e)}catch(e){var t=e instanceof Error?e:"";T.warn("Utils: could not use TextDecoder to parse UTF-16LE, fallbacking to another implementation",t)}for(var n="",r=0;r<e.length;r+=2)n+=String.fromCharCode((e[r+1]<<8)+e[r]);return n}function Aa(e){if(ka)try{return(new TextEncoder).encode(e)}catch(e){var t=e instanceof Error?e:"";T.warn("Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation",t)}var n,r=encodeURIComponent(e);if("function"==typeof unescape)n=unescape(r);else{var i=/[0-9a-fA-F]/,a=r.length;n="";for(var o=0;o<r.length;o++){var s=!1;if("%"===r[o])if(o<=a-6&&"u"===r[o+1]&&i.test(r[o+2])&&i.test(r[o+3])&&i.test(r[o+4])&&i.test(r[o+5])){var u=parseInt(r.substring(o+1,o+6),16);n+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(r[o+1])&&i.test(r[o+2])){var l=parseInt(r.substring(o+1,o+3),16);n+=String.fromCharCode(l),s=!0,o+=2}s||(n+=r[o])}}for(var d=new Uint8Array(n.length),c=0;c<n.length;c++)d[c]=255&n.charCodeAt(c);return d}function Ia(e,t){var n=e.toString(16);return n.length>=t?n:new Array(t-n.length+1).join("0")+n}function Ra(e){if(Ta)try{return(new TextDecoder).decode(e)}catch(e){var t=e instanceof Error?e:"";T.warn("Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation",t)}var n=e;239===n[0]&&187===n[1]&&191===n[2]&&(n=n.subarray(3));var r,i=function(e){for(var t="",n=0;n<e.length;n+=16e3){var r=e.subarray(n,n+16e3);t+=String.fromCharCode.apply(null,r)}return t}(n);if("function"==typeof escape)r=escape(i);else{var a=/[A-Za-z0-9*_\+-\.\/]/;r="";for(var o=0;o<i.length;o++)if(a.test(i[o]))r+=i[o];else{var s=i.charCodeAt(o);r+=s>=256?"%u"+Ia(s,4):"%"+Ia(s,2)}}return decodeURIComponent(r)}function xa(e){for(var t=e.length,n=new Uint8Array(t/2),r=0,i=0;r<t;r+=2,i++)n[i]=255&parseInt(e.substring(r,r+2),16);return n}function Ca(e,t){void 0===t&&(t="");for(var n="",r=0;r<e.byteLength;r++)n+=(e[r]>>>4).toString(16),n+=(15&e[r]).toString(16),t.length>0&&r<e.byteLength-1&&(n+=t);return n}function Ma(e){$(e.length);var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=new Uint8Array(16);return l[0]=i,l[1]=r,l[2]=n,l[3]=t,l[4]=o,l[5]=a,l[6]=u,l[7]=s,l.set(e.subarray(8,16),8),l}function Pa(e,t){for(var n=t;n<e.length;){if(0===e[n])break;n+=1}return{end:n+1,string:Ra(e.subarray(t,n))}}var Da=Math.pow(2,32)-1,Oa={};function Na(e){if(void 0!==Oa[e])return Oa[e];var t=Aa(e);return Oa[e]=t,t}function La(e,t){var n=t.length+8;return n<=Da?Xr(ri(n),Na(e),t):Xr(ri(1),Na(e),ii(n+8),t)}function Ua(e,t){return La(e,Xr.apply(void 0,t))}function Fa(e){var t=[];e.periods.forEach((function(n){var r=n.id;if(Ue(t,r)){T.warn("Two periods with the same ID found. Updating.");var i=r+"-dup";n.id=i,Fa(e),t.push(i)}else t.push(r);var a=n.adaptations,o=[];Object.keys(a).forEach((function(t){var n=a[t];void 0!==n&&n.forEach((function(t){var n=t.id;if(Ue(o,n)){T.warn("Two adaptations with the same ID found. Updating.",n);var r=n+"-dup";t.id=r,Fa(e),o.push(r)}else o.push(n);var i=[];t.representations.forEach((function(t){var n=t.id;if(Ue(i,n)){T.warn("Two representations with the same ID found. Updating.",n);var r=n+"-dup";t.id=r,Fa(e),i.push(r)}else i.push(n)}))}))}))}))}var Ba=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],za=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function Va(e){if(e>=za.length)throw new Error("Unable to parse base64 string.");var t=za[e];if(255===t)throw new Error("Unable to parse base64 string.");return t}function Ka(e){var t,n="",r=e.length;for(t=2;t<r;t+=3)n+=Ba[e[t-2]>>2],n+=Ba[(3&e[t-2])<<4|e[t-1]>>4],n+=Ba[(15&e[t-1])<<2|e[t]>>6],n+=Ba[63&e[t]];return t===r+1&&(n+=Ba[e[t-2]>>2],n+=Ba[(3&e[t-2])<<4],n+="=="),t===r&&(n+=Ba[e[t-2]>>2],n+=Ba[(3&e[t-2])<<4|e[t-1]>>4],n+=Ba[(15&e[t-1])<<2],n+="="),n}function Wa(e){var t=e.length%4,n=e;0!==t&&(T.warn("base64ToBytes: base64 given miss padding"),n+=3===t?"=":2===t?"==":"===");var r=n.indexOf("=");if(-1!==r&&r<n.length-2)throw new Error("Unable to parse base64 string.");for(var i,a=n.endsWith("==")?2:n.endsWith("=")?1:0,o=n.length,s=new Uint8Array(o/4*3),u=0,l=0;u<o;u+=4,l+=3)i=Va(n.charCodeAt(u))<<18|Va(n.charCodeAt(u+1))<<12|Va(n.charCodeAt(u+2))<<6|Va(n.charCodeAt(u+3)),s[l]=i>>16,s[l+1]=i>>8&255,s[l+2]=255&i;return s.subarray(0,s.length-a)}function Ga(e){return[{systemId:"edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",privateData:Xr([8,1,18,16],e)}]}function ja(e,t){if(void 0===t&&(t=Ga),null===e.firstElementChild||"ProtectionHeader"!==e.firstElementChild.nodeName)throw new Error("Protection should have ProtectionHeader child");var n=e.firstElementChild,r=Wa(null===n.textContent?"":n.textContent),i=xa(function(e){var t,n,r=((t=e)[0+(n=8)]<<0)+(t[n+1]<<8),i=wa(e.subarray(10,r+10)),a=(new DOMParser).parseFromString(i,"application/xml").querySelector("KID");if(null===a)throw new Error("Cannot parse PlayReady private data: invalid XML");return Ca(Ma(Wa(null===a.textContent?"":a.textContent))).toLowerCase()}(r)),a=n.getAttribute("SystemID");return{keyId:i,keySystems:[{systemId:(null!==a?a:"").toLowerCase().replace(/\{|\}/g,""),privateData:r}].concat(t(i))}}function Ha(e,n,r){var i,a=e.repeatCount;return a>=0?a:(i=t(n)?void 0!==r?r:Number.MAX_VALUE:n.start,Math.ceil((i-e.start)/e.duration)-1)}function qa(e,t,n){var r=e.start,i=e.duration;return i<=0?r:r+(Ha(e,t,n)+1)*i}function Ya(e,t){var n;return e*t.timescale+(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0)}function Qa(e,t){var n;return(e-(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0))/t.timescale}function $a(e,t,n){var r=e.timeline,i=Ya(t,e);if(i<0)return null;var a=function(e,t){for(var n=0,r=e.length;n<r;){var i=n+r>>>1;e[i].start<=t?n=i+1:r=i}return n-1}(r,i);if(a<0||a>=r.length-1)return null;var o=r[a];if(o.duration<=0)return null;var s=r[a+1];if(void 0===s)return null;var u=s.start;return i>=qa(o,s,n)&&i<u?Qa(u,e):null}function Xa(e,t){return e.replace(/\{start time\}/g,String(t))}function Za(e,t,n){var r=t-e;return r>0?Math.floor(r/n):0}function Ja(e,t){var n=e.repeatCount;if(void 0!==e.duration&&n<0){var r=void 0!==t?t.start:1/0;n=Math.ceil((r-e.start)/e.duration)-1}return n}var eo=function(){function e(e){var t=e.isLive,n=e.segmentPrivateInfos,r=e.media,i=e.sharedSmoothTimeline;if(this._sharedSmoothTimeline=i,this._initSegmentInfos={bitsPerSample:n.bitsPerSample,channels:n.channels,codecPrivateData:n.codecPrivateData,packetSize:n.packetSize,samplingRate:n.samplingRate,timescale:i.timescale,height:n.height,width:n.width,protection:n.protection},this._isLive=t,this._media=r,0!==i.timeline.length&&t){var a=i.timeline,o=i.validityTime,s=qa(a[a.length-1],null),u=o/1e3*i.timescale;this._scaledLiveGap=u-s}}var t=e.prototype;return t.getInitSegment=function(){return{id:"init",isInit:!0,privateInfos:{smoothInitSegment:this._initSegmentInfos},url:null,time:0,end:0,duration:0,timescale:1,complete:!0}},t.getSegments=function(e,t){this._refreshTimeline();for(var n,r=this._sharedSmoothTimeline,i=r.timescale,a=r.timeline,o=function(e,t,n){var r=void 0===e||0===e?1:e;return{up:t*r,to:(t+n)*r}}(i,e,t),s=o.up,u=o.to,l=this._media,d=[],c=a.length,f=void 0===this._scaledLiveGap?void 0:ne()/1e3*i-this._scaledLiveGap,v=0;v<c;v++){for(var p=a[v],h=p.duration,m=p.start,g=Ja(p,a[v+1]),y=Za(m,s,h),_=m+y*h,b=h;_<u&&y<=g&&(void 0===f||_+b<=f);){var S=_,E=void 0!==n?n+y:void 0,T={id:String(_),isInit:!1,time:S/i,end:(S+h)/i,duration:h/i,timescale:1,number:E,url:Xa(l,S),complete:!0,privateInfos:{smoothMediaSegment:{time:S,duration:h}}};d.push(T),_=m+ ++y*h}if(_>=u)return d;void 0!==n&&(n+=g+1)}return d},t.shouldRefresh=function(e,t){if(this._refreshTimeline(),!this._isLive)return!1;var n=this._sharedSmoothTimeline,r=n.timeline,i=n.timescale,a=r[r.length-1];if(void 0===a)return!1;var o=a.repeatCount,s=a.start+(o+1)*a.duration;return!(t*i<s)&&(e*i>=s||e*i>a.start+o*a.duration)},t.getFirstAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;return 0===t.length?null:t[0].start/n},t.getLastAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;if(void 0===this._scaledLiveGap)return qa(t[t.length-1],null)/n;for(var r=t.length-1;r>=0;r--)for(var i=t[r],a=ne()/1e3*n,o=i.start,s=i.duration,u=i.repeatCount;u>=0;u--){var l=o+s*(u+1);if(l<=a-this._scaledLiveGap)return l/n}},t.getEnd=function(){if(!this._isLive)return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(e,t){var n;if($(),this.isStillAwaitingFutureSegments())return!1;var r=this.getLastAvailablePosition();return!(void 0!==r&&t<r)&&(t>(null!==(n=this.getFirstAvailablePosition())&&void 0!==n?n:0)&&void 0)},t.checkDiscontinuity=function(e){return this._refreshTimeline(),$a(this._sharedSmoothTimeline,e,void 0)},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline();for(var t=this._sharedSmoothTimeline,n=t.timeline,r=t.timescale,i=0;i<n.length;i++){var a=n[i],o=a.start/r;if(o>e.time)return!1;if(o===e.time)return!0;if(a.repeatCount>=0&&void 0!==a.duration){var s=(o-a.start)/a.duration-1;return s%1==0&&s<=a.repeatCount}}return!1},t.canBeOutOfSyncError=function(e){return!!this._isLive&&(e instanceof Pe&&(e.isHttpError(404)||e.isHttpError(412)))},t._replace=function(e){this._initialScaledLastPosition=e._initialScaledLastPosition,this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.replace(e._sharedSmoothTimeline)},t._update=function(e){this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.update(e._sharedSmoothTimeline)},t.isStillAwaitingFutureSegments=function(){return this._isLive},t.isInitialized=function(){return!0},t.initialize=function(){T.error("A `SmoothRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(e,t){this._sharedSmoothTimeline.addPredictedSegments(e,t)},t._refreshTimeline=function(){this._sharedSmoothTimeline.refresh()},e}();function to(e,t){for(var n=0;e.length>0;){var r=e[0];if(r.start>=t)return n;if(-1===r.repeatCount)return n;if(0===r.repeatCount)e.shift(),n+=1;else{var i=e[1];if(void 0!==i&&i.start<=t)e.shift(),n+=1;else{if(r.duration<=0)return n;for(var a=r.start+r.duration,o=1;a<t&&o<=r.repeatCount;)a+=r.duration,o++;if(!(o>r.repeatCount)){var s=r.repeatCount-o;return r.start=a,r.repeatCount=s,n+=o}e.shift(),n=r.repeatCount+1}}}return n}function no(e,t){if(0===e.length)return e.push.apply(e,t),!0;if(0===t.length)return!1;var n=e.length,r=t[0].start;if(qa(e[n-1],t[0])<r)throw new Me("MANIFEST_UPDATE_ERROR","Cannot perform partial update: not enough data");for(var i=n-1;i>=0;i--){var a=e[i].start;if(a===r){var o=n-i;return e.splice.apply(e,[i,o].concat(t)),!1}if(a<r){var s=e[i];if(s.start+s.duration>r)return T.warn("RepresentationIndex: Manifest update removed all previous segments"),e.splice.apply(e,[0,n].concat(t)),!0;if(void 0===s.repeatCount||s.repeatCount<=0)return s.repeatCount<0&&(s.repeatCount=Math.floor((r-s.start)/s.duration)-1),e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1;if(s.start+s.duration*(s.repeatCount+1)<=r)return e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1;var u=(r-s.start)/s.duration-1;if(u%1==0&&s.duration===t[0].duration){var l=t[0].repeatCount<0?-1:t[0].repeatCount+u+1;return e.splice.apply(e,[i,n-i].concat(t)),e[i].start=s.start,e[i].repeatCount=l,!1}return T.warn("RepresentationIndex: Manifest update removed previous segments"),e[i].repeatCount=Math.floor(u),e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1}}var d=e[e.length-1],c=t[t.length-1];return void 0!==d.repeatCount&&d.repeatCount<0?d.start>c.start?(T.warn("RepresentationIndex: The new index is older than the previous one"),!1):(T.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0):d.start+d.duration*(d.repeatCount+1)>=c.start+c.duration*(c.repeatCount+1)?(T.warn("RepresentationIndex: The new index is older than the previous one"),!1):(T.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0)}function ro(e,t,n,r){var i=e[e.length-1],a=n.timescale===t?{time:n.time,duration:n.duration}:{time:n.time/n.timescale*t,duration:n.duration/n.timescale*t};return!(r.time===a.time)&&(a.time>=qa(i,null)&&(i.duration===a.duration?i.repeatCount++:e.push({duration:a.duration,start:a.time,repeatCount:0}),!0))}var io=function(){function e(e){var t=e.timeline,n=e.timescale,r=e.timeShiftBufferDepth,i=e.manifestReceivedTime;this.timeline=t,this.timescale=n;var a=null!=i?i:ne();if(this.validityTime=a,this._timeShiftBufferDepth=r,0!==t.length){var o=qa(t[t.length-1],null);this._initialScaledLastPosition=o}}var t=e.prototype;return t.refresh=function(){if(void 0!==this._initialScaledLastPosition){var e=this._timeShiftBufferDepth,t=(ne()-this.validityTime)/1e3+this._initialScaledLastPosition/this.timescale;if(void 0!==e){var n=(t-e)*this.timescale;to(this.timeline,n)}}},t.replace=function(e){var t=this.timeline,n=e.timeline,r=this.timescale,i=e.timescale;if(this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime,0!==t.length&&0!==n.length&&r===i){var a=t[t.length-1],o=n[n.length-1],s=qa(o,null);if(!(qa(a,null)<=s))for(var u=0;u<t.length;u++){var l=t[u],d=qa(l,null);if(d===s)return void(this.timeline=this.timeline.concat(t.slice(u+1)));if(d>s){if(l.duration!==o.duration)return;var c=s-l.start;if(0===c)return T.warn("Smooth Parser: a discontinuity detected in the previous manifest has been resolved."),void(this.timeline=this.timeline.concat(t.slice(u)));if(c<0||c%l.duration!=0)return;var f=c/l.duration-1,v=l.repeatCount-f;if(v<0)return;o.repeatCount+=v;var p=t.slice(u+1);return void(this.timeline=this.timeline.concat(p))}}}},t.update=function(e){no(this.timeline,e.timeline),this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime},t.addPredictedSegments=function(e,t){var n;if(void 0!==(null===(n=t.privateInfos)||void 0===n?void 0:n.smoothMediaSegment)){this.refresh();for(var r=0;r<e.length;r++)ro(this.timeline,this.timescale,e[r],t.privateInfos.smoothMediaSegment)}else T.warn("Smooth Parser: should only encounter SmoothRepresentationIndex")},e}();function ao(e,t,n){for(var r=e.firstElementChild,i=n;null!==r;)i=t(i,r.nodeName,r),r=r.nextElementSibling;return i}var oo={audio:"audio/mp4",video:"video/mp4",text:"application/ttml+xml"},so={AACL:"audio/mp4",AVC1:"video/mp4",H264:"video/mp4",TTML:"application/ttml+xml+mp4",DFXP:"application/ttml+xml+mp4"};var uo=function(e){void 0===e&&(e={});var n=void 0===e.referenceDateTime?Date.UTC(1970,0,1,0,0,0,0)/1e3:e.referenceDateTime,r=void 0===e.minRepresentationBitrate?0:e.minRepresentationBitrate,i=e.serverSyncInfos,a=void 0!==i?i.serverTimestamp-i.clientTime:void 0;function o(e,t){var n=ao(e,(function(e,t,n){return"CustomAttributes"===t&&e.push.apply(e,ao(n,(function(e,t,n){if("Attribute"===t){var r=n.getAttribute("Name"),i=n.getAttribute("Value");null!==r&&null!==i&&e.push(r+"="+i)}return e}),[])),e}),[]);function r(t){var n=e.getAttribute(t);return null===n?void 0:n}switch(t){case"audio":var i=r("AudioTag"),a=r("BitsPerSample"),o=r("Channels"),s=r("CodecPrivateData"),u=r("FourCC"),l=r("PacketSize"),d=r("SamplingRate"),c=r("Bitrate"),f=void 0===c?0:parseInt(c,10);if(f=isNaN(f)?0:f,void 0!==u&&void 0===so[u]||void 0===s)return T.warn("Smooth parser: Unsupported audio codec. Ignoring quality level."),null;var v=function(e,t){var n;return 0==(n="AACH"===t?5:et(e)?(248&parseInt(e.substring(0,2),16))>>3:2)?"mp4a.40.2":"mp4a.40."+n}(s,u);return{audiotag:void 0!==i?parseInt(i,10):i,bitrate:f,bitsPerSample:void 0!==a?parseInt(a,10):a,channels:void 0!==o?parseInt(o,10):o,codecPrivateData:s,codecs:v,customAttributes:n,mimeType:void 0!==u?so[u]:u,packetSize:void 0!==l?parseInt(l,10):l,samplingRate:void 0!==d?parseInt(d,10):d};case"video":var p=r("CodecPrivateData"),h=r("FourCC"),m=r("MaxWidth"),g=r("MaxHeight"),y=r("Bitrate"),_=void 0===y?0:parseInt(y,10);if(_=isNaN(_)?0:_,void 0!==h&&void 0===so[h]||void 0===p)return T.warn("Smooth parser: Unsupported video codec. Ignoring quality level."),null;var b=function(e){var t=/00000001\d7([0-9a-fA-F]{6})/.exec(e);return null!==t&&et(t[1])?"avc1."+t[1]:"avc1.4D401E"}(p);return{bitrate:_,customAttributes:n,mimeType:void 0!==h?so[h]:h,codecPrivateData:p,codecs:b,width:void 0!==m?parseInt(m,10):void 0,height:void 0!==g?parseInt(g,10):void 0};case"text":var S=r("CodecPrivateData"),E=r("FourCC"),k=r("Bitrate"),w=void 0===k?0:parseInt(k,10);return{bitrate:w=isNaN(w)?0:w,customAttributes:n,mimeType:void 0!==E?so[E]:E,codecPrivateData:null!=S?S:""};default:return T.error("Smooth Parser: Unrecognized StreamIndex type: "+t),null}}function s(e){var n=e.root,i=e.timescale,a=e.baseUrl,s=e.protections,u=e.timeShiftBufferDepth,l=e.manifestReceivedTime,d=e.isLive,c=n.getAttribute("Timescale"),f=null===c?i:+c;isNaN(f)&&(f=i);var v=n.getAttribute("Type");if(null===v)throw new Error("StreamIndex without type.");Ue(ze,v)||T.warn("Smooth Parser: Unrecognized adaptation type:",v);var p=v,h=n.getAttribute("Subtype"),g=n.getAttribute("Language"),y=n.getAttribute("Url"),_=null===y?"":y;var b,S=ao(n,(function(e,t,n){switch(t){case"QualityLevel":var i=o(n,p);if(null===i)return e;("video"!==p||i.bitrate>r)&&e.qualityLevels.push(i);break;case"c":e.cNodes.push(n)}return e}),{qualityLevels:[],cNodes:[]}),E=S.qualityLevels,k=S.cNodes,w=new io({timeline:(b=k,b.reduce((function(e,t,n){var r=t.getAttribute("d"),i=t.getAttribute("t"),a=t.getAttribute("r"),o=null!==a?+a-1:0,s=null!==i?+i:void 0,u=null!==r?+r:void 0;if(0===n)s=void 0===s||isNaN(s)?0:s;else{var l=e[n-1];if(void 0===s||isNaN(s)){if(void 0===l.duration||isNaN(l.duration))throw new Error("Smooth: Invalid CNodes. Missing timestamp.");s=l.start+l.duration*(l.repeatCount+1)}}if(void 0===u||isNaN(u)){var d=b[n+1];if(void 0===d)return e;var c=d.getAttribute("t"),f=et(c)?+c:null;if(null===f)throw new Error("Can't build index timeline from Smooth Manifest.");u=f-s}return e.push({duration:u,start:s,repeatCount:o}),e}),[])),timescale:f,timeShiftBufferDepth:u,manifestReceivedTime:l});$(E.length);var A=p+(et(g)?"_"+g:""),I=E.map((function(e){var n,r,i,o,u=(n=_,r=e.bitrate,i=e.customAttributes,n.replace(/\{bitrate\}/g,String(r)).replace(/{CustomAttributes}/g,i.length>0?i[0]:"")),l=et(e.mimeType)?e.mimeType:oo[p],c=e.codecs,f=A+"_"+(t(p)?"":p+"-")+(t(l)?"":l+"-")+(t(c)?"":c+"-")+String(e.bitrate),v=[];s.length>0&&(o=s[0],s.forEach((function(e){var t=e.keyId;e.keySystems.forEach((function(e){v.push({keyId:t,systemId:e.systemId})}))})));var h={bitsPerSample:e.bitsPerSample,channels:e.channels,codecPrivateData:e.codecPrivateData,packetSize:e.packetSize,samplingRate:e.samplingRate,height:e.height,width:e.width,protection:t(o)?void 0:{keyId:o.keyId}},g=new eo({isLive:d,sharedSmoothTimeline:w,media:u,segmentPrivateInfos:h}),y=m({},e,{index:g,cdnMetadata:[{baseUrl:a}],mimeType:l,codecs:c,id:f});if(v.length>0||void 0!==o){var b=void 0===o?[]:o.keySystems.map((function(e){var t=e.systemId,n=e.privateData,r=t.replace(/-/g,""),i=function(e,t){if(32!==e.length)throw new Error("HSS: wrong system id length");return La("pssh",Xr([0,0,0,0],xa(e),ri(t.length),t))}(r,n);return{systemId:r,data:i}}));if(b.length>0){var S=[{type:"cenc",values:b}];y.contentProtections={keyIds:v,initData:S}}else y.contentProtections={keyIds:v,initData:[]}}return y}));if("ADVT"===h)return null;var R={id:A,type:p,representations:I,language:null===g?void 0:g};return"text"===p&&"DESC"===h&&(R.closedCaption=!0),R}return function(r,i,o){var u="";if(void 0!==i){var l=Ea(i);u=i.substring(0,l)}var d=r.documentElement;if(t(d)||"SmoothStreamingMedia"!==d.nodeName)throw new Error("document root should be SmoothStreamingMedia");var c=d.getAttribute("MajorVersion"),f=d.getAttribute("MinorVersion");if(null===c||null===f||!/^[2]-[0-2]$/.test(c+"-"+f))throw new Error("Version should be 2.0, 2.1 or 2.2");var v=d.getAttribute("Timescale"),p=et(v)?+v:1e7;isNaN(p)&&(p=1e7);var h,m,g=ao(d,(function(t,n,r){switch(n){case"Protection":t.protections.push(ja(r,e.keySystems));break;case"StreamIndex":t.adaptationNodes.push(r)}return t}),{adaptationNodes:[],protections:[]}),y=g.protections,_=g.adaptationNodes,b="boolean"==typeof(h=d.getAttribute("IsLive"))?h:"string"==typeof h&&"TRUE"===h.toUpperCase();if(b){var S=d.getAttribute("DVRWindowLength");null===S||isNaN(+S)||0==+S||(m=+S/p)}var E,T,k,w,A,I,R,x=_.reduce((function(e,t){var n=s({root:t,baseUrl:u,timescale:p,protections:y,isLive:b,timeShiftBufferDepth:m,manifestReceivedTime:o});if(null===n)return e;var r=n.type,i=e[r];return void 0===i?e[r]=[n]:i.push(n),e}),{}),C=null,M=void 0!==x.video?x.video[0]:void 0,P=void 0!==x.audio?x.audio[0]:void 0;if(void 0!==M||void 0!==P){var D=[],O=[];if(void 0!==M){var N=M.representations[0];if(void 0!==N){var L=N.index.getFirstAvailablePosition(),U=N.index.getLastAvailablePosition();t(L)||D.push(L),t(U)||O.push(U)}}if(void 0!==P){var F=P.representations[0];if(void 0!==F){var B=F.index.getFirstAvailablePosition(),z=F.index.getLastAvailablePosition();t(B)||D.push(B),t(z)||O.push(z)}}D.length>0&&(A=Math.max.apply(Math,D)),O.length>0&&(I=Math.min.apply(Math,O),R=Math.max.apply(Math,O))}var V=d.getAttribute("Duration"),K=null!==V&&0!=+V?+V/p:void 0;if(b){E=e.suggestedPresentationDelay,T=n,k=null!=A?A:T;var W=R;void 0===W&&(W=Date.now()/1e3-T);var G=I;void 0===G&&(G=W),w={isLinear:!0,maximumSafePosition:G,livePosition:W,time:ne()},C=null!=m?m:null}else{k=null!=A?A:0;var j=I;void 0===j&&(j=void 0!==K?k+K:1/0),w={isLinear:!1,maximumSafePosition:j,livePosition:void 0,time:ne()}}var H=b?0:k,q=b?void 0:w.maximumSafePosition,Y={availabilityStartTime:void 0===T?0:T,clockOffset:a,isLive:b,isDynamic:b,isLastPeriodKnown:!0,timeBounds:{minimumSafePosition:k,timeshiftDepth:C,maximumTimeData:w},periods:[{adaptations:x,duration:void 0!==q?q-H:K,end:q,id:"gen-smooth-period-0",start:H}],suggestedPresentationDelay:E,transportType:"smooth",uris:t(i)?[]:[i]};return Fa(Y),Y}},lo=uo;var co=function(e){var n={url:e.url,headers:e.headers,responseType:t(e.responseType)?"json":e.responseType,timeout:e.timeout,connectionTimeout:e.connectionTimeout};return new Promise((function(r,i){var a,o,s=e.onProgress,u=e.cancelSignal,l=n.url,d=n.headers,c=n.responseType,f=n.timeout,v=n.connectionTimeout,p=new XMLHttpRequest;if(p.open("GET",l,!0),void 0!==f&&(p.timeout=f,a=setTimeout((function(){_(),i(new ke(l,p.status,we.TIMEOUT))}),f+3e3)),void 0!==v&&(o=setTimeout((function(){_(),p.readyState!==XMLHttpRequest.DONE&&p.abort(),i(new ke(l,p.status,we.TIMEOUT))}),v)),p.responseType=c,"document"===p.responseType&&p.overrideMimeType("text/xml"),!t(d)){var h=d;for(var m in h)h.hasOwnProperty(m)&&p.setRequestHeader(m,h[m])}var g=ne(),y=null;function _(){void 0!==a&&clearTimeout(a),void 0!==o&&clearTimeout(o),null!==y&&y()}void 0!==u&&(y=u.register((function(e){_(),p.readyState!==XMLHttpRequest.DONE&&p.abort(),i(e)})),u.isCancelled())||(p.onerror=function(){_(),i(new ke(l,p.status,we.ERROR_EVENT))},p.ontimeout=function(){_(),i(new ke(l,p.status,we.TIMEOUT))},void 0!==v&&(p.onreadystatechange=function(){p.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(o)}),void 0!==s&&(p.onprogress=function(e){var t=ne();s({url:l,duration:t-g,sendingTime:g,currentTime:t,size:e.loaded,totalSize:e.total})}),p.onload=function(e){if(p.readyState===XMLHttpRequest.DONE)if(_(),p.status>=200&&p.status<300){var n,a=ne(),o=p.response instanceof ArrayBuffer?p.response.byteLength:e.total,s=p.status,u=p.responseType,d=et(p.responseURL)?p.responseURL:l;if(t(n="json"===u?"object"==typeof p.response?p.response:function(e){try{return JSON.parse(e)}catch(e){return null}}(p.responseText):p.response))return void i(new ke(l,p.status,we.PARSE_ERROR));r({status:s,url:d,responseType:u,sendingTime:g,receivedTime:a,requestDuration:a-g,size:o,responseData:n})}else i(new ke(l,p.status,we.ERROR_HTTP_CODE))},p.send())}))};function fo(e,t){for(var n=e.length,r=0;r+8<=n;){var i=ei(e,r);if(0===i)i=n-r;else if(1===i){if(r+16>n)return-1;i=ti(e,r+8)}if(isNaN(i)||i<=0)return-1;if(ei(e,r+4)===t)return r+i<=n?r:-1;r+=i}return-1}function vo(e,t){if(t){if(fo(e,1718909296)<0)throw new De("INTEGRITY_ERROR","Incomplete `ftyp` box");if(fo(e,1836019574)<0)throw new De("INTEGRITY_ERROR","Incomplete `moov` box")}else{if(fo(e,1836019558)<0)throw new De("INTEGRITY_ERROR","Incomplete `moof` box");if(fo(e,1835295092)<0)throw new De("INTEGRITY_ERROR","Incomplete `mdat` box")}}function po(e,t){var n=e.customManifestLoader,r=function(e){return function(t,n,r){if(void 0===t)throw new Error("Cannot perform HTTP(s) request. URL not known");switch(e){case"arraybuffer":return co({url:t,responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});case"text":return co({url:t,responseType:"text",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});case"document":return co({url:t,responseType:"document",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});default:X()}}}(t);return"function"!=typeof n?r:function(e,t){return function(n,r,i){return new Promise((function(a,o){var s=Date.now()-ne(),u=!1,l={reject:function(e){var t,n;if(!u&&!i.isCancelled()){u=!0,i.deregister(c);var r=e,a=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching the Manifest through a custom manifestLoader.",s=new xt(a,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);o(s)}},resolve:function(e){if(!u&&!i.isCancelled()){u=!0,i.deregister(c);var t=void 0!==e.receivingTime?e.receivingTime-s:void 0,n=void 0!==e.sendingTime?e.sendingTime-s:void 0;a({responseData:e.data,size:e.size,requestDuration:e.duration,url:e.url,receivedTime:t,sendingTime:n})}},fallback:function(){u||i.isCancelled()||(u=!0,i.deregister(c),t(n,r,i).then(a,o))}},d=e({url:n,timeout:r.timeout},l);function c(e){u||(u=!0,"function"==typeof d&&d(),o(e))}i.register(c)}))}}(n,r)}function ho(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mo(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mo(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function mo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function go(e,t){var n=fa(e,1936286840);if(null===n)return null;var r,i=t,a=n[2]-n[0],o=n[1],s=e[o],u=ei(e,o+=8);if(o+=4,0===s)r=ei(e,o),i+=ei(e,o+=4)+a,o+=4;else{if(1!==s)return null;r=ti(e,o),i+=ti(e,o+=8)+a,o+=8}var l=[],d=Zr(e,o+=2);for(o+=2;--d>=0;){var c=ei(e,o);o+=4;var f=2147483647&c;if(1===(2147483648&c)>>>31)throw new Error("sidx with reference_type `1` not yet implemented");var v=ei(e,o);o+=4,o+=4,l.push({time:r,duration:v,timescale:u,range:[i,i+f-1]}),r+=v,i+=f}return l}function yo(e){var t=ca(e,1952868452);if(null!==t){var n=1,r=Jr(t,n);if(n+=3,(8&r)>0)return n+=4,(1&r)>0&&(n+=8),(2&r)>0&&(n+=4),ei(t,n)}}function _o(e){var t=ma(e);if(0!==t.length){for(var n,r=0,i=ho(t);!(n=i()).done;){var a=n.value,o=ca(a,1953658222);if(null===o)return;var s=0;if(o[s]>1)return;var u=Jr(o,s+=1);s+=3;var l=(256&u)>0,d=0;if(!l&&void 0===(d=yo(a)))return;var c=(1&u)>0,f=(4&u)>0,v=(512&u)>0,p=(1024&u)>0,h=(2048&u)>0,m=ei(o,s);s+=4,c&&(s+=4),f&&(s+=4);for(var g=m,y=0;g-- >0;)l?(y+=ei(o,s),s+=4):y+=d,v&&(s+=4),p&&(s+=4),h&&(s+=4);r+=y}return r}}function bo(e){var t=function(e){var t=ca(e,1836019574);if(null===t)return null;var n=ca(t,1953653099);return null===n?null:ca(n,1835297121)}(e);if(null!==t){var n=ca(t,1835296868);if(null!==n){var r=0,i=n[r];return r+=4,1===i?ei(n,r+16):0===i?ei(n,r+8):void 0}}}function So(e){var t=e.length;if(t<4)throw new Error("Cannot update box length: box too short");var n=ei(e,0);if(0===n){if(t>Da){var r=new Uint8Array(t+8);return r.set(ri(1),0),r.set(e.subarray(4,8),4),r.set(ii(t+8),8),r.set(e.subarray(8,t),16),r}return e.set(ri(t),0),e}if(1===n){if(t<16)throw new Error("Cannot update box length: box too short");return e.set(ii(t),8),e}if(t<=Da)return e.set(ri(t),0),e;var i=new Uint8Array(t+8);return i.set(ri(1),0),i.set(e.subarray(4,8),4),i.set(ii(t+8),8),i.set(e.subarray(8,t),16),i}function Eo(e,t,n,r,i){var a,o,s,u=[];if(i){var l=ha(e);null!==l?(s=function(e){var t=va(e,3565190898,3392751253,2387879627,2655430559);if(void 0===t)return[];for(var n=[],r=t[0],i=t[4],a=0;a<i;a++){var o=void 0,s=void 0;1===r?(s=ti(t,16*a+5),o=ti(t,16*a+5+8)):(s=ei(t,8*a+5),o=ei(t,8*a+5+4)),n.push({time:s,duration:o})}return n}(l),o=function(e){var t=va(e,1830656773,1121273062,2162299933,2952222642);if(void 0!==t)return{duration:ti(t,12),time:ti(t,4)}}(l)):T.warn("smooth: could not find traf atom")}if(void 0!==s)for(var d=0;d<s.length;d++)u.push({time:s[d].time,duration:s[d].duration,timescale:n});if(void 0!==o)return{nextSegments:u,chunkInfos:{time:o.time/n,duration:o.duration/n},scaledSegmentTime:o.time};if(t||!r.complete)return{nextSegments:u,chunkInfos:null,scaledSegmentTime:void 0};var c=r.duration*n,f=Math.min(.9*n,c/4),v=_o(e),p=void 0!==(null===(a=r.privateInfos)||void 0===a?void 0:a.smoothMediaSegment)?r.privateInfos.smoothMediaSegment.time:Math.round(r.time*n);return{nextSegments:u,chunkInfos:void 0!==v&&Math.abs(v-c)<=f?{time:r.time,duration:v/n}:{time:r.time,duration:r.duration},scaledSegmentTime:p}}function To(e){return"string"==typeof e&&e.indexOf("mp4")>=0}function ko(e,t){return La("schm",Xr(4,Aa(e),ri(t)))}function wo(e){return La("frma",Aa(e))}function Ao(e){var t=[7,[e.length]];return La("stsd",Xr.apply(void 0,t.concat(e)))}function Io(e,t,n){return La("tenc",Xr(6,[e,t],n))}function Ro(e,t,n,r,i){var a=[e,t,n];return void 0!==i&&a.push(La("senc",i),function(e){if(0===e.length)return La("saiz",new Uint8Array(0));var t=ei(e,0),n=ei(e,4),r=new Uint8Array(n+9);r.set(ri(n),5);for(var i,a,o=9,s=8;s<e.length;)s+=8,2==(2&t)?(a=2,s+=6*(i=Zr(e,s))+2):(i=0,a=0),r[o]=6*i+8+a,o++;return La("saiz",r)}(i),function(e,t,n,r){return La("saio",Xr(4,[0,0,0,1],ri(e.length+t.length+n.length+r.length+8+8+8+8)))}(r,e,t,n)),Ua("traf",a)}function xo(e,t){var n=fa(e,1836019558);if(null===n)throw new Error("Smooth: Invalid ISOBMFF given");var r=e.subarray(n[1],n[2]),i=function(e,t){var n=fa(e,t);return null!==n?e.subarray(n[0],n[2]):null}(r,1835427940),a=ca(r,1953653094);if(null===a||null===i)throw new Error("Smooth: Invalid ISOBMFF given");var o=fa(a,1952868452),s=fa(a,1953658222);if(null===o||null===s)throw new Error("Smooth: Invalid ISOBMFF given");var u=a.subarray(o[0],o[2]),l=a.subarray(s[0],s[2]);u.set([0,0,0,1],o[1]-o[0]+4);var d=function(e){return La("tfdt",Xr([1,0,0,0],ii(e)))}(t),c=function(e,t){var n=(1&e[t+3])>0;if(n)return e;var r=new Uint8Array(e.length+4);return r.set(e.subarray(0,t+8),0),r[t+3]=1|r[t+3],r.set([0,0,0,0],t+8),r.set(e.subarray(t+8,e.length),t+12),So(r)}(l,s[1]-s[0]),f=Ro(u,d,c,i,va(a,2721664850,1520127764,2722393154,2086964724)),v=Ua("moof",[i,f]),p=fa(v,1836019558),h=fa(f,1953653094),m=fa(c,1953658222);if(null===p||null===h||null===m)throw new Error("Smooth: Invalid moof, trun or traf generation");var g=p[1]-p[0]+i.length+(h[1]-h[0])+u.length+d.length+(m[1]-m[0])+8,y=n[2]-n[0],_=v.length-y,b=fa(e,1835295092);if(null===b)throw new Error("Smooth: Invalid ISOBMFF given");if(!pi&&(0===_||_<=-8)){var S=b[1];return v.set(ri(S),g),e.set(v,n[0]),_<=-8&&e.set(La("free",new Uint8Array(-_-8)),v.length),e}var E=b[1]+_;v.set(ri(E),g);var T=new Uint8Array(e.length+_),k=e.subarray(0,n[0]),w=e.subarray(n[2],e.length);return T.set(k,0),T.set(v,k.length),T.set(w,k.length+v.length),T}function Co(e){var t=e[0],n=e[1];return n===1/0?"bytes="+t+"-":"bytes="+t+"-"+n}function Mo(e,t,n,r,i,a){var o,s,u=Ua("stbl",[n,La("stts",new Uint8Array(8)),La("stsc",new Uint8Array(8)),La("stsz",new Uint8Array(12)),La("stco",new Uint8Array(8))]),l=function(e){return La("dref",Xr(7,[1],e))}(La("url ",new Uint8Array([0,0,0,1]))),d=Ua("dinf",[l]),c=Ua("minf",[r,d,u]),f=function(e){var t,n;switch(e){case"video":t="vide",n="VideoHandler";break;case"audio":t="soun",n="SoundHandler";break;default:t="hint",n=""}return La("hdlr",Xr(8,Aa(t),12,Aa(n),1))}(t),v=function(e){return La("mdhd",Xr(12,ri(e),8))}(e),p=Ua("mdia",[v,f,c]),h=function(e,t,n){return La("tkhd",Xr(ri(7),8,ri(n),20,[1,0,0,0],[0,1,0,0],12,[0,1,0,0],12,[64,0,0,0],ni(e),2,ni(t),2))}(i,a,1),m=Ua("trak",[h,p]),g=Ua("mvex",[La("trex",Xr(4,ri(1),[0,0,0,1],12))]),y=function(e,t){return La("mvhd",Xr(12,ri(e),4,[0,1],2,[1,0],10,[0,1],14,[0,1],14,[64,0,0,0],26,ni(t+1)))}(e,1),_=function(e,t,n){return Ua("moov",[e,t,n])}(y,g,m),b=(o="isom",s=["isom","iso2","iso6","avc1","dash"],La("ftyp",Xr.apply(void 0,[Aa(o),[0,0,0,1]].concat(s.map(Aa)))));return Xr(b,_)}function Po(e,t,n,r,i,a,o,s){var u=o.split("00000001"),l=u[1],d=u[2];if(void 0===l||void 0===d)throw new Error("Smooth: unsupported codec private data.");var c,f,v=function(e,t,n){var r;return r=2===n?1:4===n?3:0,La("avcC",Xr([1,e[1],e[2],e[3],252|r,225],ni(e.length),e,[1],ni(t.length),t))}(xa(l),xa(d),a);if(void 0===s){var p=function(e,t,n,r,i,a,o){return La("avc1",Xr(6,ni(1),16,ni(e),ni(t),ni(n),2,ni(r),6,[0,1,i.length],Aa(i),31-i.length,ni(a),[255,255],o))}(t,n,r,i,"AVC Coding",24,v);c=Ao([p])}else{var h=Ua("schi",[Io(1,8,s)]),m=ko("cenc",65536),g=function(e,t,n,r,i,a,o,s){return La("encv",Xr(6,ni(1),16,ni(e),ni(t),ni(n),2,ni(r),6,[0,1,i.length],Aa(i),31-i.length,ni(a),[255,255],o,s))}(t,n,r,i,"AVC Coding",24,v,Ua("sinf",[wo("avc1"),m,h]));c=Ao([g])}return Mo(e,"video",c,((f=new Uint8Array(12))[3]=1,La("vmhd",f)),t,n)}var Do=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function Oo(e,t,n,r,i,a,o){var s,u,l=function(e,t){return La("esds",Xr(4,[3,25],ni(e),[0,4,17,64,21],11,[5,2],xa(t),[6,1,2]))}(1,0===a.length?(s=i,u=t,Ca(ni((((63&2)<<4|31&Do.indexOf(s))<<4|31&u)<<3))):a),d=function(){if(void 0===o){var e=function(e,t,n,r,i,a){return La("mp4a",Xr(6,ni(e),8,ni(t),ni(n),2,ni(r),ni(i),2,a))}(1,t,n,r,i,l);return Ao([e])}var a=Ua("schi",[Io(1,8,o)]),s=ko("cenc",65536),u=Ua("sinf",[wo("mp4a"),s,a]),d=function(e,t,n,r,i,a,o){return La("enca",Xr(6,ni(e),8,ni(t),ni(n),2,ni(r),ni(i),2,a,o))}(1,t,n,r,i,l,u);return Ao([d])}();return Mo(e,"audio",d,La("smhd",new Uint8Array(8)),0,0)}function No(e,t,n,r,i,a){var o,s=t.segment.range;return Array.isArray(s)&&(o={Range:Co(s)}),co({url:e,responseType:"arraybuffer",headers:o,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:n.onProgress}).then((function(e){if(!To(t.mimeType)||!0!==a)return{resultType:"segment-loaded",resultData:e};var n=new Uint8Array(e.responseData);return vo(n,t.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},e),{responseData:n})}}))}var Lo=function(e){var t=e.checkMediaSegmentIntegrity,n=e.segmentLoader;return function(e,r,i,a,o){var s=r.segment;if(s.isInit){if(void 0===s.privateInfos||void 0===s.privateInfos.smoothInitSegment)throw new Error("Smooth: Invalid segment format");var u,l=s.privateInfos.smoothInitSegment,d=l.codecPrivateData,c=l.timescale,f=l.height,v=l.width,p=l.protection,h=void 0===p?{keyId:void 0,keySystems:void 0}:p;if(void 0===d)throw new Error("Smooth: no codec private data.");switch(r.type){case"video":u=Po(c,null!=v?v:0,null!=f?f:0,72,72,4,d,h.keyId);break;case"audio":var m=l.channels,g=void 0===m?0:m,y=l.bitsPerSample,_=void 0===y?0:y,b=l.packetSize,S=void 0===b?0:b,E=l.samplingRate;u=Oo(c,g,_,S,void 0===E?0:E,d,h.keyId);break;default:0,u=new Uint8Array(0)}return Promise.resolve({resultType:"segment-created",resultData:u})}return null===e?Promise.resolve({resultType:"segment-created",resultData:null}):"function"!=typeof n?No(e,r,o,i,a,t):new Promise((function(s,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a Smooth segment through a custom segmentLoader.",o=new xt(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(e){if(!d&&!a.isCancelled()){d=!0,a.deregister(p),To(r.mimeType)&&!0===t||s({resultType:"segment-loaded",resultData:{responseData:e.data,size:e.size,requestDuration:e.duration}});var n=e.data instanceof Uint8Array?e.data:new Uint8Array(e.data);vo(n,r.segment.isInit),s({resultType:"segment-loaded",resultData:{responseData:n,size:e.size,requestDuration:e.duration}})}},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),No(e,r,o,i,a,t).then(s,u))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:e},v=n(f,c);function p(e){d||((d=!0)||"function"!=typeof v||v(),u(e))}a.register(p)}))}};function Uo(e,t){return null===e?null:null===t.url?e.baseUrl:Sa(e.baseUrl,t.url)}var Fo=function(e){var t=lo(e),n=Lo(e),r={loadManifest:po({customManifestLoader:e.manifestLoader},"text"),parseManifest:function(n,r){var i,a=null!==(i=n.url)&&void 0!==i?i:r.originalUrl,o=n.receivedTime,s=n.responseData,u="string"==typeof s?(new DOMParser).parseFromString(s,"text/xml"):s,l=t(u,a,o),d=[];return{manifest:new It(l,{representationFilter:e.representationFilter},d),url:a,warnings:d}}},i={loadSegment:function(e,t,r,i,a){var o=Uo(e,t.segment);return n(o,t,r,i,a)},parseSegment:function(e,t,n){var r,i,a=t.segment,o=e.data,s=e.isChunked;if(null===o)return a.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var u=o instanceof Uint8Array?o:new Uint8Array(o);if(a.isInit){var l=null===(i=null===(r=a.privateInfos)||void 0===r?void 0:r.smoothInitSegment)||void 0===i?void 0:i.timescale;return{segmentType:"init",initializationData:o,initializationDataSize:o.byteLength,initTimescale:l,protectionData:[]}}var d=void 0!==n?Eo(u,s,n,a,t.isLive):null;if(null===d||null===d.chunkInfos||void 0===d.scaledSegmentTime)throw new Error("Smooth Segment without time information");var c=d.nextSegments,f=d.chunkInfos,v=xo(u,d.scaledSegmentTime),p=c.length>0?c:void 0;return{segmentType:"media",chunkData:v,chunkInfos:f,chunkOffset:0,chunkSize:v.length,protectionData:[],predictedSegments:p,appendWindow:[void 0,void 0]}}},a={loadSegment:function(t,n,r,i,a){var o=n.segment,s=Uo(t,o);return o.isInit||null===s?Promise.resolve({resultType:"segment-created",resultData:null}):To(n.mimeType)?co({url:s,responseType:"arraybuffer",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:a.onProgress}).then((function(t){if(!0!==e.checkMediaSegmentIntegrity)return{resultType:"segment-loaded",resultData:t};var r=new Uint8Array(t.responseData);return vo(r,n.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},t),{responseData:r})}})):co({url:s,responseType:"text",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:a.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))},parseSegment:function(e,t,n){var r,i,a,o=t.segment,s=t.language,u=t.mimeType,l=void 0===u?"":u,d=t.codecs,c=void 0===d?"":d,f=To(t.mimeType),v=e.data,p=e.isChunked;if(o.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if(null===v)return{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var h,m,g,y,_=null;if(f){var b;i=(b="string"==typeof v?Aa(v):v instanceof Uint8Array?v:new Uint8Array(v)).length;var S=void 0!==n?Eo(b,p,n,o,t.isLive):null;a=null==S?void 0:S.nextSegments,null===(_=null!==(r=null==S?void 0:S.chunkInfos)&&void 0!==r?r:null)?p?T.warn("Smooth: Unavailable time data for current text track."):(h=o.time,m=o.end):(h=_.time,m=void 0!==_.duration?_.time+_.duration:o.end);var E=c.toLowerCase();if("application/ttml+xml+mp4"===l||"stpp"===E||"stpp.ttml.im1t"===E)y="ttml";else{if("wvtt"!==E)throw new Error("could not find a text-track parser for the type "+l);y="vtt"}var k=ga(b);g=null===k?"":Ra(k)}else{var w;if(h=o.time,m=o.end,"string"!=typeof v){var A=v instanceof Uint8Array?v:new Uint8Array(v);i=A.length,w=Ra(A)}else w=v;switch(l){case"application/x-sami":case"application/smil":y="sami";break;case"application/ttml+xml":y="ttml";break;case"text/vtt":y="vtt"}if(void 0===y){if("srt"!==c.toLowerCase())throw new Error("could not find a text-track parser for the type "+l);y="srt"}g=w}return{segmentType:"media",chunkData:{type:y,data:g,start:h,end:m,language:s},chunkSize:i,chunkInfos:_,chunkOffset:null!=h?h:0,protectionData:[],predictedSegments:Array.isArray(a)&&a.length>0?a:void 0,appendWindow:[void 0,void 0]}}};return{manifest:r,audio:i,video:i,text:a}};function Bo(e){void 0===e.transports.smooth&&(e.transports.smooth=Fo),e.mainThreadMediaSourceInit=ra,e.codecSupportProber=sa}function zo(e){var t=Date.parse(e)-ne();if(!isNaN(t))return t;T.warn("DASH Parser: Invalid clock received: ",e)}function Vo(e){for(var t=e.representations,n=null,r=0;r<t.length;r++){var i=t[r].index.getLastAvailablePosition();if(void 0===i)return;null!==i&&(n=null===n?i:Math.min(n,i))}return null===n?null:n}function Ko(e){for(var t=e.representations,n=null,r=0;r<t.length;r++){var i=t[r].index.getFirstAvailablePosition();if(void 0===i)return;null!==i&&(n=null===n?i:Math.max(n,i))}return null===n?null:n}function Wo(e){if(0===e.length)throw new Error("DASH Parser: no period available for a dynamic content");var t=function(e){for(var t=0;t<=e.length-1;t++){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,o=null;if(void 0!==r){var s=Ko(r);if(void 0===s)return;a=s}if(void 0!==i){var u=Ko(i);if(void 0===u)return;o=u}if(void 0!==r&&null===a||void 0!==i&&null===o)return void T.info("Parser utils: found Period with no segment. ","Going to next one to calculate first position");if(null!==o)return null!==a?Math.max(a,o):o;if(null!==a)return a}}}(e),n=function(e){for(var t=e.length-1;t>=0;t--){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,o=null;if(void 0!==r){var s=Vo(r);if(void 0===s)return{safe:void 0,unsafe:void 0};a=s}if(void 0!==i){var u=Vo(i);if(void 0===u)return{safe:void 0,unsafe:void 0};o=u}if(void 0!==r&&null===a||void 0!==i&&null===o)return T.info("Parser utils: found Period with no segment. ","Going to previous one to calculate last position"),{safe:void 0,unsafe:void 0};if(null!==o)return null!==a?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(null!==a)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}(e);return{minimumSafePosition:t,maximumSafePosition:n.safe,maximumUnsafePosition:n.unsafe}}var Go=function(){function e(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=e.isDynamic&&void 0!==e.timeShiftBufferDepth?e.timeShiftBufferDepth:null,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}var t=e.prototype;return t.setLastPosition=function(e,t){this._lastPosition=e,this._positionTime=t},t.lastPositionIsKnown=function(){return this._isDynamic?void 0!==this._positionTime&&void 0!==this._lastPosition:void 0!==this._lastPosition},t.getEstimatedMinimumSegmentTime=function(){var e;if(!this._isDynamic||null===this._timeShiftBufferDepth)return 0;var t=null!==(e=this.getEstimatedLiveEdge())&&void 0!==e?e:this.getEstimatedMaximumPosition(0);return void 0!==t?t-this._timeShiftBufferDepth:void 0},t.getEstimatedLiveEdge=function(){if(this._isDynamic&&void 0!==this._serverTimestampOffset)return(ne()+this._serverTimestampOffset)/1e3-this._availabilityStartTime},t.getEstimatedMaximumPosition=function(e){if(!this._isDynamic)return this._lastPosition;var t=this.getEstimatedLiveEdge();return void 0!==t&&e!==1/0?t+e:void 0!==this._positionTime&&void 0!==this._lastPosition?Math.max(this._lastPosition-this._positionTime+ne()/1e3,0):this._lastPosition},e}();function jo(e,t){return"function"==typeof Array.prototype.flatMap?e.flatMap(t):e.reduce((function(e,n){var r=t(n);return Array.isArray(r)?(e.push.apply(e,r),e):(e.push(r),e)}),[])}function Ho(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return qo(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qo(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function qo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Yo=function(e,t){for(var n,r=Ho(t);!(n=r()).done;)for(var i,a=n.value,o=a.adaptation,s=Ho(a.trickModeAttachedAdaptationIds);!(i=s()).done;)for(var u,l=i.value,d=Ho(ze);!(u=d()).done;){var c=e[u.value];if(void 0!==c)for(var f,v=Ho(c);!(f=v()).done;){var p=f.value;p.id===l&&(void 0===p.trickModeTracks&&(p.trickModeTracks=[]),p.trickModeTracks.push(o))}}},Qo=["subtitle","caption"];function $o(e,t,n,r){function i(e,t){var n=e.split("/")[0];return Ue(ze,n)?n:"application/ttml+xml"===e||"application/mp4"===e&&null!==t&&void 0!==ae(t,(function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri&&Ue(Qo,e.value)}))?"text":void 0}function a(e){switch(e.substring(0,3)){case"avc":case"hev":case"hvc":case"vp8":case"vp9":case"av1":return"video";case"vtt":return"text"}switch(e.substring(0,4)){case"mp4a":return"audio";case"wvtt":case"stpp":return"text"}}if(null!==t){var o=i(t,r);if(void 0!==o)return o}if(null!==n){var s=a(n);if(void 0!==s)return s}for(var u=0;u<e.length;u++){var l=e[u].attributes,d=l.mimeType,c=l.codecs;if(void 0!==d){var f=i(d,r);if(void 0!==f)return f}if(void 0!==c){var v=a(c);if(void 0!==v)return v}}}var Xo=/[, ]+/g;function Zo(e,n){var r,i=e.initialization,a={};return void 0!==n&&(a.isEMSGWhitelisted=n),{id:"init",isInit:!0,time:0,end:0,duration:0,timescale:1,range:t(i)?void 0:i.range,indexRange:e.indexRange,url:null!==(r=null==i?void 0:i.url)&&void 0!==r?r:null,complete:!0,privateInfos:a,timestampOffset:-e.indexTimeOffset/e.timescale}}function Jo(e){return function(t,n,r){var i,a,o,s=et(r)?parseInt(r,10):1;return i=String(e),a=s,(o=i.toString()).length>=a?o:(new Array(a+1).join("0")+o).slice(-a)}}function es(e,t,n){return function(e,t,n){return-1===e.indexOf("$")?e:e.replace(/\$\$/g,"$").replace(/\$RepresentationID\$/g,String(t)).replace(/\$Bandwidth(\%0(\d+)d)?\$/g,Jo(void 0===n?0:n))}(e,t,n)}function ts(e,t){return function(n){return-1===n.indexOf("$")?n:n.replace(/\$\$/g,"$").replace(/\$Number(\%0(\d+)d)?\$/g,(function(e,n,r){if(void 0===t)throw new Error("Segment number not defined in a $Number$ scheme");return Jo(t)(e,n,r)})).replace(/\$Time(\%0(\d+)d)?\$/g,(function(t,n,r){if(void 0===e)throw new Error("Segment time not defined in a $Time$ scheme");return Jo(e)(t,n,r)}))}}function ns(e,t,n,r,i,a){for(var o,s,u,l=r.getEstimatedMaximumPosition(null!==(o=e.availabilityTimeOffset)&&void 0!==o?o:0),d=Math.min(t+n,null!=l?l:1/0),c=Ya(t,e),f=Ya(d,e),v=e.timeline,p=e.timescale,h=e.segmentUrlTemplate,m=e.startNumber,g=e.endNumber,y=null!=m?m:1,_=[],b=v.length,S=0;S<b;S++){var E=v[S],T=E.duration,k=E.start,w=E.range,A=void 0;A=void 0===l?i:Math.min(l*p,null!=i?i:1/0);for(var I=Ha(E,v[S+1],A),R=!1!==e.availabilityTimeComplete||S!==b-1&&0!==I,x=(s=T,u=void 0,(u=c-k)>0?Math.floor(u/s):0),C=k+x*T;C<f&&x<=I;){var M=y+x;if(void 0!==g&&M>g)break;var P=null===h?null:ts(C,M)(h),D=C-e.indexTimeOffset,O=T;D<0&&(O=T+D,D=0);var N={id:String(C),time:D/p,end:(D+O)/p,duration:O/p,isInit:!1,range:w,timescale:1,url:P,number:M,timestampOffset:-e.indexTimeOffset/p,complete:R,privateInfos:{isEMSGWhitelisted:a}};_.push(N),C=k+ ++x*T}if(C>=f)return _;if(y+=I+1,void 0!==g&&y>g)return _}return _}function rs(e,t){if(t.timescale!==e.timescale){var n=e.timescale;e.timeline.push({start:t.time/t.timescale*n,duration:t.duration/t.timescale*n,repeatCount:void 0===t.count?0:t.count,range:t.range})}else e.timeline.push({start:t.time,duration:t.duration,repeatCount:void 0===t.count?0:t.count,range:t.range});return!0}var is=function(){function e(e,n){var r,i,a,o,s,u=n.periodStart,l=n.periodEnd,d=n.representationId,c=n.representationBitrate,f=n.isEMSGWhitelisted,v=null!==(r=e.timescale)&&void 0!==r?r:1,p=(null!==(i=e.presentationTimeOffset)&&void 0!==i?i:0)-u*v,h=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:es(e.initialization.media,d,c),m=void 0===e.media?null:es(e.media,d,c);void 0!==e.initialization?s=e.initialization.range:void 0!==e.indexRange&&(s=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:p,initialization:{url:h,range:s},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:null!==(o=e.timeline)&&void 0!==o?o:[],timescale:v},this._manifestBoundsCalculator=n.manifestBoundsCalculator,this._scaledPeriodStart=Ya(u,this._index),this._scaledPeriodEnd=t(l)?void 0:Ya(l,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=f}var n=e.prototype;return n.getInitSegment=function(){return Zo(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,t){return ns(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)},n.shouldRefresh=function(){return!1},n.getFirstAvailablePosition=function(){var e=this._index;return 0===e.timeline.length?null:Qa(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)},n.getLastAvailablePosition=function(){var e,t=this._index.timeline;if(0===t.length)return null;var n=t[t.length-1];return Qa(Math.min(qa(n,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)},n.getEnd=function(){return this.getLastAvailablePosition()},n.awaitSegmentBetween=function(){return!1},n.isSegmentStillAvailable=function(){return!0},n.checkDiscontinuity=function(){return null},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){return!1},n.isInitialized=function(){return this._isInitialized},n.initialize=function(e){if(!this._isInitialized){for(var t=0;t<e.length;t++)rs(this._index,e[t]);this._isInitialized=!0}},n.addPredictedSegments=function(){T.warn("Cannot add predicted segments to a `BaseRepresentationIndex`")},n._replace=function(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted},n._update=function(){T.error("Base RepresentationIndex: Cannot update a SegmentList")},e}(),as=function(){function e(e,n){var r,i,a;if(void 0===e.duration)throw new Error("Invalid SegmentList: no duration");var o=n.periodStart,s=n.periodEnd,u=n.representationId,l=n.representationBitrate,d=n.isEMSGWhitelisted;this._isEMSGWhitelisted=d,this._periodStart=o,this._periodEnd=s;var c=null!==(r=e.presentationTimeOffset)&&void 0!==r?r:0,f=null!==(i=e.timescale)&&void 0!==i?i:1,v=c-o*f,p=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:es(e.initialization.media,u,l),h=e.list.map((function(e){return{url:void 0===e.media?null:es(e.media,u,l),mediaRange:e.mediaRange}}));this._index={list:h,timescale:f,duration:e.duration,indexTimeOffset:v,indexRange:e.indexRange,initialization:t(e.initialization)?void 0:{url:p,range:e.initialization.range}}}var n=e.prototype;return n.getInitSegment=function(){var e=Zo(this._index);return void 0===e.privateInfos&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e},n.getSegments=function(e,t){for(var n=this._index,r=n.duration,i=n.list,a=n.timescale,o=r/a,s=function(e,t,n){return[e*n,(e+t)*n]}(e-this._periodStart,t,a),u=s[0],l=s[1],d=Math.min(i.length-1,Math.floor(l/r)),c=[],f=Math.floor(u/r);f<=d;){var v=i[f].mediaRange,p=i[f].url,h=f*o+this._periodStart,m={id:String(f),time:h,isInit:!1,range:v,duration:o,timescale:1,end:h+o,url:p,timestampOffset:-n.indexTimeOffset/a,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};c.push(m),f++}return c},n.shouldRefresh=function(e,t){return!1},n.getFirstAvailablePosition=function(){return this._periodStart},n.getLastAvailablePosition=function(){var e,t=this._index,n=t.duration,r=t.list;return Math.min(r.length*n/t.timescale+this._periodStart,null!==(e=this._periodEnd)&&void 0!==e?e:1/0)},n.getEnd=function(){return this.getLastAvailablePosition()},n.awaitSegmentBetween=function(){return!1},n.isSegmentStillAvailable=function(){return!0},n.checkDiscontinuity=function(){return null},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){return!1},n.isInitialized=function(){return!0},n.initialize=function(){T.error("A `ListRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){T.warn("Cannot add predicted segments to a `ListRepresentationIndex`")},n._replace=function(e){this._index=e._index},n._update=function(){T.error("A `ListRepresentationIndex` cannot be updated")},e}();function os(e){return b.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*e}function ss(e,n,r){var i=e.start,a=e.duration,o=e.repeatCount;return void 0===i&&(null===n?i=0:t(n.duration)||(i=n.start+n.duration*(n.repeatCount+1))),void 0!==a&&!isNaN(a)||null===r||void 0===r.start||isNaN(r.start)||void 0===i||isNaN(i)||(a=r.start-i),void 0===i||isNaN(i)||void 0===a||isNaN(a)||void 0!==o&&isNaN(o)?(T.warn('DASH: A "S" Element could not have been parsed.'),null):{start:i,duration:a,repeatCount:void 0===o?0:o}}function us(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"t":var i=parseInt(r.value,10);isNaN(i)?T.warn('DASH: invalid t ("'+r.value+'")'):t.start=i;break;case"d":var a=parseInt(r.value,10);isNaN(a)?T.warn('DASH: invalid d ("'+r.value+'")'):t.duration=a;break;case"r":var o=parseInt(r.value,10);isNaN(o)?T.warn('DASH: invalid r ("'+r.value+'")'):t.repeatCount=o}}return t}function ls(e){for(var t=[],n=0;n<e.length;n++)t.push(us(e[n]));for(var r=[],i=0;i<t.length;i++){var a=ss(t[i],void 0===r[r.length-1]?null:r[r.length-1],void 0===t[i+1]?null:t[i+1]);null!==a&&r.push(a)}return r}function ds(e,t){var n,r=function(e,t){if(0===e.length||0===t.length)return null;var n=e[0].start,r=t[0].getAttribute("t"),i=null===r?null:parseInt(r,10);if(null===i||Number.isNaN(i))return null;if(n===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(n<i)for(var a=e[0],o=0;;){if(a.repeatCount>0){var s=i-a.start;if(s%a.duration==0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(++o>=e.length)return null;if((a=e[o]).start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}else for(var u=0,l=t[0],d=i;;){var c=l.getAttribute("d"),f=null===c?null:parseInt(c,10);if(null===f||Number.isNaN(f))return null;var v=l.getAttribute("r"),p=null===v?null:parseInt(v,10);if(null!==p){if(Number.isNaN(p)||p<0)return null;if(p>0){var h=n-d;if(h%f==0&&h/f<=p)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/f,prevSegmentsIdx:0,newElementsIdx:u}}d+=f*(p+1)}else d+=f;if(++u>=t.length)return null;var m=(l=t[u]).getAttribute("t"),g=null===m?null:parseInt(m,10);if(null!==g){if(Number.isNaN(g))return null;d=g}if(d===n)return{newElementsIdx:u,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(d>i)return null}}(t,e);if(null===r)return T.warn('DASH: Cannot perform "based" update. Common segment not found.'),ls(e);var i=r.prevSegmentsIdx,a=r.newElementsIdx,o=r.repeatNumberInPrevSegments,s=r.repeatNumberInNewElements,u=t.length-i+a-1;if(u>=e.length)return T.info('DASH: Cannot perform "based" update. New timeline too short'),ls(e);var l=t.slice(i);if(o>0){var d=l[0];d.start+=d.duration*o,l[0].repeatCount-=o}if(s>0&&0!==a)return T.info('DASH: Cannot perform "based" update. The new timeline has a different form.'),ls(e);var c=l[l.length-1],f=us(e[u]),v=(null!==(n=f.repeatCount)&&void 0!==n?n:0)-s;if(f.duration!==c.duration||c.repeatCount>v)return T.info('DASH: Cannot perform "based" update. The new timeline has a different form at the beginning.'),ls(e);void 0!==f.repeatCount&&f.repeatCount>c.repeatCount&&(c.repeatCount=f.repeatCount);for(var p=[],h=[],m=u+1;m<e.length;m++)h.push(us(e[m]));for(var g=0;g<h.length;g++){var y=ss(h[g],void 0===p[p.length-1]?c:p[p.length-1],void 0===h[g+1]?null:h[g+1]);null!==y&&p.push(y)}return l.concat(p)}var cs=function(){function e(n,r){var i,a,o,s,u;if(!e.isTimelineIndexArgument(n))throw new Error("The given index is not compatible with a TimelineRepresentationIndex.");var l=r.availabilityTimeComplete,d=r.availabilityTimeOffset,c=r.manifestBoundsCalculator,f=r.isDynamic,v=r.isLastPeriod,p=r.representationId,h=r.representationBitrate,m=r.periodStart,g=r.periodEnd,y=r.isEMSGWhitelisted,_=null!==(i=n.timescale)&&void 0!==i?i:1,b=(null!==(a=n.presentationTimeOffset)&&void 0!==a?a:0)-m*_;this._manifestBoundsCalculator=c,this._isEMSGWhitelisted=y,this._isLastPeriod=v,this._lastUpdate=null!==(o=r.receivedTime)&&void 0!==o?o:ne(),this._unsafelyBaseOnPreviousIndex=null,null!==r.unsafelyBaseOnPreviousRepresentation&&r.unsafelyBaseOnPreviousRepresentation.index instanceof e&&(r.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=r.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=f,this._parseTimeline=null!==(s=n.timelineParser)&&void 0!==s?s:null;var S,E=void 0===(null===(u=n.initialization)||void 0===u?void 0:u.media)?null:es(n.initialization.media,p,h),T=void 0===n.media?null:es(n.media,p,h);S=void 0===d&&void 0===l?1/0:null!=d?d:0,this._index={availabilityTimeComplete:null==l||l,availabilityTimeOffset:S,indexRange:n.indexRange,indexTimeOffset:b,initialization:t(n.initialization)?void 0:{url:E,range:n.initialization.range},segmentUrlTemplate:T,startNumber:n.startNumber,endNumber:n.endNumber,timeline:void 0===n.timeline?null:fs(n.timeline,n.startNumber,n.endNumber),timescale:_},this._scaledPeriodStart=Ya(m,this._index),this._scaledPeriodEnd=void 0===g?void 0:Ya(g,this._index)}var n=e.prototype;return n.getInitSegment=function(){return Zo(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,t){this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var n=this._index;return ns({segmentUrlTemplate:n.segmentUrlTemplate,startNumber:n.startNumber,endNumber:n.endNumber,timeline:n.timeline,timescale:n.timescale,indexTimeOffset:n.indexTimeOffset},e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)},n.shouldRefresh=function(){return!1},n.getFirstAvailablePosition=function(){this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var e=this._index.timeline;return 0===e.length?null:Qa(Math.max(this._scaledPeriodStart,e[0].start),this._index)},n.getLastAvailablePosition=function(){var e;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=vs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);return null===t?null:Qa(Math.min(t.end,null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)},n.getEnd=function(){var e;if(!this._isDynamic||this._isLastPeriod){if(this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;var t=this._index.timeline[this._index.timeline.length-1];return Qa(Math.min(qa(t,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)}},n.awaitSegmentBetween=function(e,t){var n,r;if($(),!this._isDynamic)return!1;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var i=this._index,a=i.timescale,o=i.timeline,s=os(a),u=Ya(t,this._index),l=vs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(null!==l&&Math.min(l.end,null!==(n=this._scaledPeriodEnd)&&void 0!==n?n:1/0)+s>=Math.min(u,null!==(r=this._scaledPeriodEnd)&&void 0!==r?r:1/0))return!1;var d=Ya(e,this._index);if(o.length>0&&null!==l&&!l.isLastOfTimeline&&d<qa(o[o.length-1],null,this._scaledPeriodEnd)+s+s)return!0;return!!this._isLastPeriod&&(void 0===this._scaledPeriodEnd?u+s>this._scaledPeriodStart&&void 0:d-s<this._scaledPeriodEnd&&u+s>this._scaledPeriodStart)},n.isSegmentStillAvailable=function(e){return!!e.isInit||(this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline()),function(e,n,r,i){var a=vs(n,r,i);if(null===a)return!1;for(var o=0;o<n.timeline.length;o++){if(a.timelineIdx<o)return!1;var s=n.timeline[o],u=(s.start-n.indexTimeOffset)/n.timescale;if(u>e.time)return!1;if(u===e.time)return void 0===s.range?void 0===e.range:!t(e.range)&&s.range[0]===e.range[0]&&s.range[1]===e.range[1];if(s.repeatCount>=0&&void 0!==s.duration){var l=(u-s.start)/s.duration-1;return l%1==0&&l<=a.newRepeatCount}}return!1}(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))},n.checkDiscontinuity=function(e){this._refreshTimeline();var t=this._index.timeline;return null===t&&(t=this._getTimeline(),this._index.timeline=t),$a({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)},n.canBeOutOfSyncError=function(e){return!!this._isDynamic&&(e instanceof Pe&&e.isHttpError(404))},n._replace=function(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod},n._update=function(e){null===this._index.timeline&&(this._index.timeline=this._getTimeline()),null===e._index.timeline&&(e._index.timeline=e._getTimeline()),no(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.availabilityTimeOffset=e._index.availabilityTimeOffset,this._index.availabilityTimeComplete=e._index.availabilityTimeComplete,this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod},n.isStillAwaitingFutureSegments=function(){var e;if(!this._isDynamic)return!1;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=this._index.timeline;if(0===t.length){if(void 0!==this._scaledPeriodEnd){var n=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(void 0!==n&&Ya(n,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}var r=os(this._index.timescale),i=vs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(null!==i&&!i.isLastOfTimeline){var a=Math.min(i.end,null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0);return!(void 0!==this._scaledPeriodEnd&&a+r>=this._scaledPeriodEnd)}return!!this._isLastPeriod&&(void 0===this._scaledPeriodEnd||qa(t[t.length-1],null,this._scaledPeriodEnd)+r<this._scaledPeriodEnd)},n.isInitialized=function(){return!0},n.initialize=function(){T.error("A `TimelineRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){T.warn("Cannot add predicted segments to a `TimelineRepresentationIndex`")},e.isTimelineIndexArgument=function(e){return"function"==typeof e.timelineParser||Array.isArray(e.timeline)},n._refreshTimeline=function(){if(null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._isDynamic){var e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(!t(e)){var n=Ya(e,this._index),r=to(this._index.timeline,n);void 0!==this._index.startNumber?this._index.startNumber+=r:void 0!==this._index.endNumber&&(this._index.startNumber=r+1)}}},n._getTimeline=function(){if(null===this._parseTimeline)return null!==this._index.timeline?this._index.timeline:(T.error("DASH: Timeline already lazily parsed."),[]);var e=this._parseTimeline();this._parseTimeline=null;var t,n=b.getCurrent().MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY;return null===this._unsafelyBaseOnPreviousIndex||e.length<n?fs(ls(e),this._index.startNumber,this._index.endNumber):(null===this._unsafelyBaseOnPreviousIndex._index.timeline?(t=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=t):t=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,fs(ds(e,t),this._index.startNumber,this._index.endNumber))},e}();function fs(e,t,n){if(void 0===n)return e;for(var r=null!=t?t:1,i=0;i<e.length;i++){var a=e[i];if((r+=a.repeatCount+1)>n){if(r===n+1)return e.slice(0,i+1);var o=e.slice(0,i),s=Object.assign({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,n-u),o.push(s),o}}return e}function vs(e,t,n){if(e.timeline.length<=0)return null;if(e.availabilityTimeOffset===1/0){var r=e.timeline.length-1,i=e.timeline[r];return{isLastOfTimeline:!0,timelineIdx:r,newRepeatCount:i.repeatCount,end:qa(i,null,n)}}var a=t.getEstimatedMaximumPosition(e.availabilityTimeOffset);if(void 0===a){var o=e.timeline.length-1,s=e.timeline[o];return{isLastOfTimeline:!0,timelineIdx:o,newRepeatCount:s.repeatCount,end:qa(s,null,n)}}for(var u=e.timeline.length-1;u>=e.timeline.length;u--){var l=e.timeline[u],d=l.start+l.duration;if(Qa(d,e)<=a){if(Qa(qa(l,e.timeline[u+1],n),e)<=a)return{isLastOfTimeline:u===e.timeline.length-1,timelineIdx:u,newRepeatCount:l.repeatCount,end:d};var c=Ya(a,e)-l.start,f=Math.floor(c/l.duration);return $(),{isLastOfTimeline:!1,timelineIdx:u,newRepeatCount:f-1,end:l.start+f*l.duration}}}return null}var ps=cs,hs=function(){function e(e,n){var r,i,a,o=n.availabilityTimeOffset,s=n.manifestBoundsCalculator,u=n.isDynamic,l=n.periodEnd,d=n.periodStart,c=n.representationId,f=n.representationBitrate,v=n.isEMSGWhitelisted,p=null!==(r=e.timescale)&&void 0!==r?r:1;this._availabilityTimeOffset=o,this._manifestBoundsCalculator=s;var h=null!==(i=e.presentationTimeOffset)&&void 0!==i?i:0,m=h-d*p;if(void 0===e.duration)throw new Error("Invalid SegmentTemplate: no duration");var g=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:es(e.initialization.media,c,f),y=void 0===e.media?null:es(e.media,c,f);this._index={duration:e.duration,timescale:p,indexRange:e.indexRange,indexTimeOffset:m,initialization:t(e.initialization)?void 0:{url:g,range:e.initialization.range},url:y,presentationTimeOffset:h,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=u,this._periodStart=d,this._scaledRelativePeriodEnd=void 0===l?void 0:(l-d)*p,this._isEMSGWhitelisted=v}var n=e.prototype;return n.getInitSegment=function(){return Zo(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,n){var r=this._index,i=r.duration,a=r.startNumber,o=r.endNumber,s=r.timescale,u=r.url,l=this._periodStart*s,d=this._scaledRelativePeriodEnd,c=e*s-l,f=(e+n)*s-l,v=this._getFirstSegmentStart(),p=this._getLastSegmentStart();if(t(v)||t(p))return[];var h=Math.max(v,c),m=Math.min(p,f);if(m+i<=h)return[];for(var g=[],y=null!=a?a:1,_=Math.floor(h/i),b=_*i;b<=m;b+=i){var S=_+y;if(void 0!==o&&S>o)return g;var E=!t(d)&&b+i>d?d-b:i,T=b+l,k=b+this._index.presentationTimeOffset,w=null===u?null:ts(k,S)(u),A={id:String(S),number:S,time:T/s,end:(T+E)/s,duration:E/s,timescale:1,isInit:!1,scaledDuration:E/s,url:w,timestampOffset:-r.indexTimeOffset/s,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};g.push(A),_++}return g},n.getFirstAvailablePosition=function(){var e=this._getFirstSegmentStart();return t(e)?e:e/this._index.timescale+this._periodStart},n.getLastAvailablePosition=function(){var e=this._getLastSegmentStart();if(t(e))return e;var n=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,null!=n?n:1/0)/this._index.timescale+this._periodStart},n.getEnd=function(){if(!this._isDynamic)return this.getLastAvailablePosition();var e=this._estimateRelativeScaledEnd();if(void 0!==e){var t=this._index.timescale;return(e+this._periodStart*t)/t}},n.awaitSegmentBetween=function(e,n){if($(),!this._isDynamic)return!1;var r=this._index.timescale,i=os(r),a=this._periodStart*r,o=e*r-a,s=n*r-a,u=this._getLastSegmentStart();if(t(u)){var l=this._estimateRelativeScaledEnd();return void 0===l?s+i>=0:s+i>=0&&o<l-i}var d=u+this._index.duration,c=this._estimateRelativeScaledEnd();return void 0===c?s>d-i:s>d-i&&o<c-i},n.shouldRefresh=function(){return!1},n.checkDiscontinuity=function(){return null},n.isSegmentStillAvailable=function(e){if(e.isInit)return!0;var t=this.getSegments(e.time,.1);return 0!==t.length&&(t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number)},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){if(!this._isDynamic)return!1;var e=this._estimateRelativeScaledEnd();if(void 0===e)return!0;var n=this._index.timescale,r=this._getLastSegmentStart();return!!t(r)||r+this._index.duration+os(n)<e},n.isInitialized=function(){return!0},n.initialize=function(){T.error("A `TemplateRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){T.warn("Cannot add predicted segments to a `TemplateRepresentationIndex`")},n._replace=function(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator},n._update=function(e){this._replace(e)},n._getFirstSegmentStart=function(){var e;if(!this._isDynamic)return 0;if(0===this._scaledRelativePeriodEnd||void 0===this._scaledRelativePeriodEnd){var t=this._manifestBoundsCalculator.getEstimatedMaximumPosition(null!==(e=this._availabilityTimeOffset)&&void 0!==e?e:0);if(void 0!==t&&t<this._periodStart)return null}var n=this._index,r=n.duration,i=n.timescale,a=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(void 0!==a){var o=a>this._periodStart?(a-this._periodStart)*i:0;return Math.floor(o/r)*r}},n._getLastSegmentStart=function(){var e,t,n=this._index,r=n.duration,i=n.timescale,a=n.endNumber,o=n.startNumber,s=void 0===o?1:o;if(this._isDynamic){var u=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(void 0!==u&&void 0!==this._scaledRelativePeriodEnd&&this._scaledRelativePeriodEnd<u-this._periodStart*this._index.timescale){var l=Math.ceil(this._scaledRelativePeriodEnd/r);return void 0!==a&&a-s+1<l&&(l=a-s+1),(l-1)*r}var d=this._manifestBoundsCalculator.getEstimatedMaximumPosition(null!==(e=this._availabilityTimeOffset)&&void 0!==e?e:0);if(void 0===d)return;var c=(d-this._periodStart)*i;if(c<0)return null;var f=Math.floor(c/r);return void 0!==a&&a-s+1<f&&(f=a-s+1),f<=0?null:(f-1)*r}var v=null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:0,p=Math.ceil(v/r);void 0!==a&&a-s+1<p&&(p=a-s+1);var h=(p-1)*r,m=b.getCurrent().MINIMUM_SEGMENT_SIZE*i;return void 0!==a||v-h>m||p<2?h:(p-2)*r},n._estimateRelativeScaledEnd=function(){var e,t;if(void 0!==this._index.endNumber){var n=this._index.endNumber-(null!==(e=this._index.startNumber)&&void 0!==e?e:1)+1;return Math.max(Math.min(n*this._index.duration,null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:1/0),0)}if(void 0!==this._scaledRelativePeriodEnd)return Math.max(this._scaledRelativePeriodEnd,0)},e}();function ms(e,t){var n;if(0===t.length)return e;var r=t.map((function(e){return{url:e.value}}));if(0===e.length)return r;for(var i=[],a=0;a<e.length;a++)for(var o=e[a],s=0;s<r.length;s++){var u=r[s],l=Sa(o.url,u.url);i.push({url:l,serviceLocation:null!==(n=u.serviceLocation)&&void 0!==n?n:o.serviceLocation})}return i}function gs(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ys(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ys(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ys(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _s(e){var t=e.adaptationProfiles,n=e.essentialProperties,r=e.supplementalProperties,i=e.manifestProfiles,a=e.codecs;if(-1!==((null!=t?t:"")+(null!=i?i:"")).indexOf("http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10")&&("hvc1.2.4.L153.B0"===a||"hev1.2.4.L153.B0"===a))return{colorDepth:10,eotf:"pq",colorSpace:"rec2020"};var o=ae([].concat(null!=n?n:[],null!=r?r:[]),(function(e){return"urn:mpeg:mpegB:cicp:TransferCharacteristics"===e.schemeIdUri}));if(void 0!==o)switch(o.value){case"15":return;case"16":return{eotf:"pq"};case"18":return{eotf:"hlg"}}return void 0!==a&&/^vp(08|09|10)/.exec(a)?function(e){var t,n,r,i=e.split("."),a=i[0],o=(i[1],i[2],i[3]),s=(i[4],i[5]),u=i[6],l=i[7];if(("vp08"===a||"vp09"===a||"vp10"===a)&&((void 0!==o&&"10"===o||"12"===o)&&(t=parseInt(o,10)),void 0!==u&&("16"===u?n="pq":"18"===u&&(n="hlg")),void 0!==s&&void 0!==l&&"09"===s&&"09"===l&&(r="rec2020"),void 0!==t&&void 0!==n))return{colorDepth:t,eotf:n,colorSpace:r}}(a):void 0}function bs(e,t,n){for(var r,i,a,o,s,u,l=[],d=function(){for(var e=u.value,d=void 0!==e.attributes.id?e.attributes.id:String(e.attributes.bitrate)+(void 0!==e.attributes.height?"-"+e.attributes.height:"")+(void 0!==e.attributes.width?"-"+e.attributes.width:"")+(void 0!==e.attributes.mimeType?"-"+e.attributes.mimeType:"")+(void 0!==e.attributes.codecs?"-"+e.attributes.codecs:"");l.some((function(e){return e.id===d}));)d+="-dup";var c,f=null!==(i=null===(r=n.unsafelyBaseOnPreviousAdaptation)||void 0===r?void 0:r.getRepresentation(d))&&void 0!==i?i:null,v=function(e,t){var n=[];if(void 0!==e.children.inbandEventStreams&&n.push.apply(n,e.children.inbandEventStreams),void 0!==t.children.inbandEventStreams&&n.push.apply(n,t.children.inbandEventStreams),0!==n.length)return n}(e,t),p=null!==(a=e.attributes.availabilityTimeComplete)&&void 0!==a?a:n.availabilityTimeComplete;void 0===e.attributes.availabilityTimeOffset&&void 0===n.availabilityTimeOffset||(c=(null!==(o=e.attributes.availabilityTimeOffset)&&void 0!==o?o:0)+(null!==(s=n.availabilityTimeOffset)&&void 0!==s?s:0));var h,g=function(e,t){var n,r,i,a=t.availabilityTimeOffset,o=t.manifestBoundsCalculator,s=t.isDynamic,u=t.end,l=t.start,d=t.receivedTime,c=t.unsafelyBaseOnPreviousRepresentation,f=t.inbandEventStreams,v={availabilityTimeComplete:void 0,availabilityTimeOffset:a,unsafelyBaseOnPreviousRepresentation:c,isEMSGWhitelisted:function(e){return void 0!==f&&f.some((function(t){return t.schemeIdUri===e.schemeIdUri}))},isLastPeriod:t.isLastPeriod,manifestBoundsCalculator:o,isDynamic:s,periodEnd:u,periodStart:l,receivedTime:d,representationBitrate:e.attributes.bitrate,representationId:e.attributes.id};if(void 0!==e.children.segmentBase){var p=e.children.segmentBase;i=new is(p,v)}else if(void 0!==e.children.segmentList){var h=e.children.segmentList;i=new as(h,v)}else if(void 0!==e.children.segmentTemplate||t.parentSegmentTemplates.length>0){var g=t.parentSegmentTemplates.slice(),y=e.children.segmentTemplate;void 0!==y&&g.push(y);var _=m.apply(void 0,[{}].concat(g));void 0===_.availabilityTimeOffset&&void 0===t.availabilityTimeOffset||(v.availabilityTimeOffset=(null!==(n=_.availabilityTimeOffset)&&void 0!==n?n:0)+(null!==(r=t.availabilityTimeOffset)&&void 0!==r?r:0)),i=ps.isTimelineIndexArgument(_)?new ps(_,v):new hs(_,v)}else{var b=t.adaptation.children;if(void 0!==b.segmentBase){var S=b.segmentBase;i=new is(S,v)}else if(void 0!==b.segmentList){var E=b.segmentList;i=new as(E,v)}else i=new hs({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:""},v)}return i}(e,m({},n,{availabilityTimeOffset:c,availabilityTimeComplete:p,unsafelyBaseOnPreviousRepresentation:f,adaptation:t,inbandEventStreams:v}));void 0===e.attributes.bitrate?(T.warn("DASH: No usable bitrate found in the Representation."),h=0):h=e.attributes.bitrate;var y,_,b,S=ms(n.baseURLs,e.children.baseURLs),E={bitrate:h,cdnMetadata:0===S.length?[{baseUrl:"",id:void 0}]:S.map((function(e){return{baseUrl:e.url,id:e.serviceLocation}})),index:g,id:d};void 0!==e.children.supplementalProperties&&ae(e.children.supplementalProperties,(function(e){return"tag:dolby.com,2018:dash:EC3_ExtensionType:2018"===e.schemeIdUri&&"JOC"===e.value}))&&(E.isSpatialAudio=!0),void 0!==e.attributes.codecs?y=e.attributes.codecs:void 0!==t.attributes.codecs&&(y=t.attributes.codecs),void 0!==y&&(y="mp4a.40.02"===y?"mp4a.40.2":y,E.codecs=y),void 0!==e.attributes.supplementalCodecs?_=e.attributes.supplementalCodecs:void 0!==t.attributes.supplementalCodecs&&(_=t.attributes.supplementalCodecs),void 0!==_&&(E.supplementalCodecs=et(b=_)?b.trim().replace(Xo,", "):""),void 0!==e.attributes.frameRate?E.frameRate=e.attributes.frameRate:void 0!==t.attributes.frameRate&&(E.frameRate=t.attributes.frameRate),void 0!==e.attributes.height?E.height=e.attributes.height:void 0!==t.attributes.height&&(E.height=t.attributes.height),void 0!==e.attributes.mimeType?E.mimeType=e.attributes.mimeType:void 0!==t.attributes.mimeType&&(E.mimeType=t.attributes.mimeType),void 0!==e.attributes.width?E.width=e.attributes.width:void 0!==t.attributes.width&&(E.width=t.attributes.width);var k=void 0!==t.children.contentProtections?t.children.contentProtections:[];if(void 0!==e.children.contentProtections&&k.push.apply(k,e.children.contentProtections),k.length>0){var w=k.reduce((function(e,t){var n;if(void 0!==t.attributes.schemeIdUri&&"urn:uuid:"===t.attributes.schemeIdUri.substring(0,9)&&(n=t.attributes.schemeIdUri.substring(9).replace(/-/g,"").toLowerCase()),void 0!==t.attributes.keyId&&t.attributes.keyId.length>0){var r={keyId:t.attributes.keyId,systemId:n};void 0===e.keyIds?e.keyIds=[r]:e.keyIds.push(r)}if(void 0!==n){for(var i,a=[],o=gs(t.children.cencPssh);!(i=o()).done;){var s=i.value;a.push({systemId:n,data:s})}if(a.length>0){var u,l=ae(e.initData,(function(e){return"cenc"===e.type}));if(void 0===l)e.initData.push({type:"cenc",values:a});else(u=l.values).push.apply(u,a)}}return e}),{keyIds:void 0,initData:[]});(Object.keys(w.initData).length>0||void 0!==w.keyIds&&w.keyIds.length>0)&&(E.contentProtections=w)}E.hdrInfo=_s({adaptationProfiles:t.attributes.profiles,supplementalProperties:t.children.supplementalProperties,essentialProperties:t.children.essentialProperties,manifestProfiles:n.manifestProfiles,codecs:y}),l.push(E)},c=gs(e);!(u=c()).done;)d();return l}function Ss(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Es(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Es(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Es(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ts(e){if(void 0===e)return!1;var t="urn:tva:metadata:cs:AudioPurposeCS:2007"===e.schemeIdUri&&"1"===e.value,n="urn:mpeg:dash:role:2011"===e.schemeIdUri&&"description"===e.value;return t||n}function ks(e,t){if(void 0!==e&&e.some((function(e){return"urn:tva:metadata:cs:AudioPurposeCS:2007"===e.schemeIdUri&&"2"===e.value})))return!0;if(void 0!==t&&t.some((function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri&&"caption"===e.value})))return!0;return!1}function ws(e){return void 0!==e&&("urn:mpeg:dash:role:2011"===e.schemeIdUri&&"sign"===e.value)}function As(e,t){if(et(e.attributes.id))return e.attributes.id;var n=t.isClosedCaption,r=t.isForcedSubtitle,i=t.isAudioDescription,a=t.isSignInterpreted,o=t.isTrickModeTrack,s=t.type;return et(e.attributes.language)&&(s+="-"+e.attributes.language),!0===n&&(s+="-cc"),!0===r&&(s+="-cc"),!0===i&&(s+="-ad"),!0===a&&(s+="-si"),o&&(s+="-trickMode"),et(e.attributes.contentType)&&(s+="-"+e.attributes.contentType),et(e.attributes.codecs)&&(s+="-"+e.attributes.codecs),et(e.attributes.mimeType)&&(s+="-"+e.attributes.mimeType),void 0!==e.attributes.frameRate&&(s+="-"+String(e.attributes.frameRate)),s}function Is(e){if(!t(e.children.supplementalProperties))for(var n,r=Ss(e.children.supplementalProperties);!(n=r()).done;){var i=n.value;if("urn:mpeg:dash:adaptation-set-switching:2016"===i.schemeIdUri&&!t(i.value))return i.value.split(",").map((function(e){return e.trim()})).filter((function(e){return e}))}return[]}function Rs(e,t){var n=t[1].priority-e[1].priority;return 0!==n?n:e[1].isMainAdaptation!==t[1].isMainAdaptation?e[1].isMainAdaptation?-1:1:e[1].indexInMpd-t[1].indexInMpd}function xs(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Cs(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cs(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Cs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ms=Le();function Ps(e,n){var r,i,o,s,u=[],l=function(e,n){var r=[];return e.forEach((function(i,a){var o,s;if(t(i.attributes.start))if(0===a)o=!n.isDynamic||t(n.availabilityStartTime)?0:n.availabilityStartTime;else{var u=r[r.length-1];if(t(u)||t(u.periodEnd))throw new Error("Missing start time when parsing periods.");o=u.periodEnd}else o=i.attributes.start;var l=e[a+1];t(i.attributes.duration)?a===e.length-1?s=n.duration:t(l.attributes.start)||(s=l.attributes.start-o):s=i.attributes.duration;var d=t(s)?void 0:o+s;r.push({periodStart:o,periodDuration:s,periodEnd:d})})),r}(e,n);if(l.length!==e.length)throw new Error("MPD parsing error: the time information are incoherent.");var d=n.isDynamic,c=n.manifestBoundsCalculator;d||t(n.duration)||c.setLastPosition(n.duration);for(var f=function(){var f,p=v===e.length-1,h=e[v],m=n.xlinkInfos.get(h),g=ms(n.baseURLs,h.children.baseURLs),y=l[v],_=y.periodStart,b=y.periodDuration,S=y.periodEnd;for(t(h.attributes.id)?(T.warn("DASH: No usable id found in the Period. Generating one."),f="gen-dash-period-"+Ms()):f=h.attributes.id;u.some((function(e){return e.id===f}));)f+="-dup";var E=void 0!==m?m.receivedTime:n.receivedTime,k=null!==(i=null===(r=n.unsafelyBaseOnPreviousManifest)||void 0===r?void 0:r.getPeriod(f))&&void 0!==i?i:null,w=h.attributes.availabilityTimeComplete,A=h.attributes.availabilityTimeOffset,I=n.manifestProfiles,R=h.children.segmentTemplate,x={availabilityTimeComplete:w,availabilityTimeOffset:A,baseURLs:g,manifestBoundsCalculator:c,end:S,isDynamic:d,isLastPeriod:p,manifestProfiles:I,receivedTime:E,segmentTemplate:R,start:_,unsafelyBaseOnPreviousPeriod:k},C=function(e,n){for(var r,i,a,o,s,u,l,d={video:[],audio:[],text:[]},c=[],f={},v=[],p=0;p<e.length;p++){var h=e[p],m=h.children,g=m.essentialProperties,y=m.roles,_=m.label,b=Array.isArray(y)&&y.some((function(e){return"main"===e.value}))&&y.some((function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri})),S=h.children.representations,E=null!==(r=h.attributes.availabilityTimeComplete)&&void 0!==r?r:n.availabilityTimeComplete,k=void 0;void 0===h.attributes.availabilityTimeOffset&&void 0===n.availabilityTimeOffset||(k=(null!==(i=h.attributes.availabilityTimeOffset)&&void 0!==i?i:0)+(null!==(a=n.availabilityTimeOffset)&&void 0!==a?a:0));var w=h.attributes.mimeType,A=h.attributes.codecs,I=$o(S,et(w)?w:null,et(A)?A:null,t(m.roles)?null:m.roles);if(void 0!==I){var R=null!==(o=h.attributes.selectionPriority)&&void 0!==o?o:1,x=h.attributes.id,C=Is(h),M=[];void 0!==n.segmentTemplate&&M.push(n.segmentTemplate),void 0!==h.children.segmentTemplate&&M.push(h.children.segmentTemplate);var P={availabilityTimeComplete:E,availabilityTimeOffset:k,baseURLs:ms(n.baseURLs,m.baseURLs),manifestBoundsCalculator:n.manifestBoundsCalculator,end:n.end,isDynamic:n.isDynamic,isLastPeriod:n.isLastPeriod,manifestProfiles:n.manifestProfiles,parentSegmentTemplates:M,receivedTime:n.receivedTime,start:n.start,unsafelyBaseOnPreviousAdaptation:null},D=Array.isArray(g)?ae(g,(function(e){return"http://dashif.org/guidelines/trickmode"===e.schemeIdUri})):void 0,O=null===(s=null==D?void 0:D.value)||void 0===s?void 0:s.split(" "),N=void 0!==O,L=m.accessibilities,U=void 0;void 0!==y&&y.some((function(e){return"dub"===e.value}))&&(U=!0);var F=void 0;F="text"===I&&ks(L,y);var z=void 0;"text"===I&&void 0!==y&&y.some((function(e){return"forced-subtitle"===e.value||"forced_subtitle"===e.value}))&&(z=!0);var V=void 0;"audio"!==I?V=!1:void 0!==L&&(V=L.some(Ts));var K=void 0;"video"!==I?K=!1:void 0!==L&&(K=L.some(ws));for(var W=As(h,{isAudioDescription:V,isForcedSubtitle:z,isClosedCaption:F,isSignInterpreted:K,isTrickModeTrack:N,type:I});Ue(v,W);)W+="-dup";var G=W;v.push(W),P.unsafelyBaseOnPreviousAdaptation=null!==(l=null===(u=n.unsafelyBaseOnPreviousPeriod)||void 0===u?void 0:u.getAdaptation(W))&&void 0!==l?l:null;var j={id:W,representations:bs(S,h,P),type:I,isTrickModeTrack:N};if(t(h.attributes.language)||(j.language=h.attributes.language),t(F)||(j.closedCaption=F),t(V)||(j.audioDescription=V),!0===U&&(j.isDub=!0),void 0!==z&&(j.forcedSubtitles=z),!0===K&&(j.isSignInterpreted=!0),void 0!==_&&(j.label=_),void 0!==O)c.push({adaptation:j,trickModeAttachedAdaptationIds:O});else{for(var H,q=-1,Y=function(){var e=H.value,t=f[e];if(void 0!==t&&t.newID!==G&&Ue(t.adaptationSetSwitchingIDs,x)){q=B(d[I],(function(t){return t[0].id===e}));var n,r=d[I][q];if(void 0!==r&&r[0].audioDescription===j.audioDescription&&r[0].closedCaption===j.closedCaption&&r[0].language===j.language)return T.info('DASH Parser: merging "switchable" AdaptationSets',x,e),(n=r[0].representations).push.apply(n,j.representations),r[1]={priority:Math.max(R,r[1].priority),isMainAdaptation:b||r[1].isMainAdaptation,indexInMpd:Math.min(p,r[1].indexInMpd)},1}},Q=Ss(C);!(H=Q()).done&&!Y(););q<0&&d[I].push([j,{priority:R,isMainAdaptation:b,indexInMpd:p}])}!t(x)&&t(f[x])&&(f[x]={newID:G,adaptationSetSwitchingIDs:C})}}var $=ze.reduce((function(e,t){var n=d[t];return n.length>0&&(n.sort(Rs),e[t]=n.map((function(e){return e[0]}))),e}),{});return d.video.sort(Rs),Yo($,c),$}(h.children.adaptations,x),M=(null!==(o=n.xmlNamespaces)&&void 0!==o?o:[]).concat(null!==(s=h.attributes.namespaces)&&void 0!==s?s:[]),P=function(e,t,n){for(var r,i,o,s=[],u=xs(e);!(o=u()).done;)for(var l,d=o.value,c=d.attributes,f=c.schemeIdUri,v=void 0===f?"":f,p=c.timescale,h=void 0===p?1:p,m=n.concat(null!==(r=d.attributes.namespaces)&&void 0!==r?r:[]),g=xs(d.children.events);!(l=g()).done;){var y=l.value;if(void 0!==y.eventStreamData){var _=(null!==(i=y.presentationTime)&&void 0!==i?i:0)/h+t,b=void 0===y.duration?void 0:_+y.duration/h,S=void 0,E=void 0;if(!a&&y.eventStreamData instanceof Element)S=y.eventStreamData;else try{E={namespaces:m,data:Ra(new Uint8Array(y.eventStreamData))}}catch(e){T.error("DASH: Error while parsing event-stream:",e instanceof Error?e.message:"Unknown error")}s.push({start:_,end:b,id:y.id,data:{type:"dash-event-stream",value:{schemeIdUri:v,timescale:h,element:S,xmlData:E}}})}}return s}(h.children.eventStreams,_,M),D={id:f,start:_,end:S,duration:b,adaptations:C,streamEvents:P};if(u.unshift(D),!c.lastPositionIsKnown()){var O=function(e){for(var n,r=null,i=!0,a=xs(jo(ge(e).filter((function(e){return!t(e)})),(function(e){return e})));!(n=a()).done;)for(var o,s=xs(n.value.representations);!(o=s()).done;){var u=o.value.index.getLastAvailablePosition();null!==u&&(i=!1,"number"==typeof u&&(r=t(r)?u:Math.max(r,u)))}if(!t(r))return r;if(i)return null;return}(C);if(d)if("number"==typeof O){var N=ne()/1e3;c.setLastPosition(O,N)}else{var L=Ds(n,_);if(void 0!==L){var U=L[0],F=L[1];c.setLastPosition(U,F)}}else"number"==typeof O&&c.setLastPosition(O)}},v=e.length-1;v>=0;v--)f();if(n.isDynamic&&!c.lastPositionIsKnown()){var p=Ds(n,0);if(void 0!==p){var h=p[0],m=p[1];c.setLastPosition(h,m)}}return function(e){if(0===e.length)return[];for(var t=[e[0]],n=1;n<e.length;n++){for(var r=e[n],i=t[t.length-1];(void 0===i.duration||i.start+i.duration>r.start)&&(T.warn("DASH: Updating overlapping Periods.",null==i?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0))&&(t.pop(),0!==t.length);)i=t[t.length-1];t.push(r)}return t}(u)}function Ds(e,n){if(t(e.clockOffset)){var r=Date.now()/1e3;if(r>=n)return T.warn("DASH Parser: no clock synchronization mechanism found. Using the system clock instead."),[r-e.availabilityStartTime,ne()/1e3]}else{var i=e.clockOffset/1e3-e.availabilityStartTime,a=ne()/1e3,o=a+i;if(o>=n)return[o,a]}}function Os(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ns(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ns(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ns(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ls=function e(n,r,i,a,o){void 0===o&&(o=new WeakMap);var s=n.children,u=n.attributes;if(t(r.externalClockOffset)){var l="dynamic"===u.type,d=ae(s.utcTimings,(function(e){return"urn:mpeg:dash:utc:direct:2014"===e.schemeIdUri&&!t(e.value)})),c=t(d)||t(d.value)?void 0:zo(d.value),f=t(c)||isNaN(c)?void 0:c;if(t(f)||!0===a){if(l&&!0!==a){var v=function(e){var t=e.children.utcTimings.filter((function(e){return("urn:mpeg:dash:utc:http-iso:2014"===e.schemeIdUri||"urn:mpeg:dash:utc:http-xsdate:2014"===e.schemeIdUri)&&void 0!==e.value}));return t.length>0?t[0].value:void 0}(n);if(!t(v)&&v.length>0)return{type:"needs-clock",value:{url:v,continue:function(t){return t.success?(r.externalClockOffset=zo(t.data),e(n,r,i,!0)):(i.push(t.error),T.warn("DASH Parser: Error on fetching the clock ressource",t.error),e(n,r,i,!0))}}}}}else r.externalClockOffset=f}for(var p=[],h=0;h<s.periods.length;h++){var m=s.periods[h].attributes,g=m.xlinkHref,y=m.xlinkActuate;t(g)||"onLoad"!==y||p.push({index:h,ressource:g})}return 0===p.length?function(e,n,r,i){var a,o,s,u,l,d,c,f=e.children,v=e.attributes,p="dynamic"===v.type,h=void 0!==n.url?[{url:n.url.substring(0,Ea(n.url))}]:[],m=ms(h,f.baseURLs),g=function(e,n){return"dynamic"!==e.type?0:t(e.availabilityStartTime)?null!=n?n:0:e.availabilityStartTime}(v,n.referenceDateTime),y=v.timeShiftBufferDepth,_=n.externalClockOffset,S=n.unsafelyBaseOnPreviousManifest,E=n.externalClockOffset,k=new Go({availabilityStartTime:g,isDynamic:p,timeShiftBufferDepth:y,serverTimestampOffset:E}),w={availabilityStartTime:g,baseURLs:m,clockOffset:_,duration:v.duration,isDynamic:p,manifestBoundsCalculator:k,manifestProfiles:e.attributes.profiles,receivedTime:n.manifestReceivedTime,timeShiftBufferDepth:y,unsafelyBaseOnPreviousManifest:S,xlinkInfos:i,xmlNamespaces:e.attributes.namespaces},A=Ps(f.periods,w),I=v.duration,R=null;void 0!==v.minimumUpdatePeriod&&v.minimumUpdatePeriod>=0&&(l=0===v.minimumUpdatePeriod?b.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:v.minimumUpdatePeriod);var x=Wo(A),C=x.minimumSafePosition,M=x.maximumSafePosition,P=x.maximumUnsafePosition,D=ne();if(p){var O;if(void 0!==M)O=M;else if(void 0===E)T.warn("DASH Parser: use system clock to define maximum position"),O=Date.now()/1e3-g;else O=(ne()+E)/1e3-g;var N=k.getEstimatedLiveEdge();void 0===N&&(N=void 0!==P?P:O),c={isLinear:!0,maximumSafePosition:O,livePosition:N,time:D},d=C,null!==(R=null!=y?y:null)&&void 0!==d&&N-d>R&&(R=N-d)}else{void 0===(d=C)&&(d=null!==(o=null===(a=A[0])||void 0===a?void 0:a.start)&&void 0!==o?o:0);var L=null!=I?I:1/0;if(void 0!==A[A.length-1]){var U=A[A.length-1],F=null!==(s=U.end)&&void 0!==s?s:void 0!==U.duration?U.start+U.duration:void 0;void 0!==F&&F<L&&(L=F)}void 0!==M&&M<L&&(L=M),c={isLinear:!1,maximumSafePosition:L,livePosition:void 0,time:D}}var B=!p||void 0===e.attributes.minimumUpdatePeriod&&(void 0!==(null===(u=A[A.length-1])||void 0===u?void 0:u.end)||void 0!==e.attributes.duration),z={availabilityStartTime:g,clockOffset:n.externalClockOffset,isDynamic:p,isLive:p,isLastPeriodKnown:B,periods:A,publishTime:v.publishTime,suggestedPresentationDelay:v.suggestedPresentationDelay,transportType:"dash",timeBounds:{minimumSafePosition:d,timeshiftDepth:R,maximumTimeData:c},lifetime:l,uris:t(n.url)?f.locations:[n.url].concat(f.locations)};return{type:"done",value:{parsed:z,warnings:r}}}(n,r,i,o):{type:"needs-xlinks",value:{xlinksUrls:p.map((function(e){return e.ressource})),continue:function(t){if(t.length!==p.length)throw new Error("DASH parser: wrong number of loaded ressources.");for(var u=t.length-1;u>=0;u--){var l,d=p[u].index,c=t[u],f=c.parsed,v=c.warnings,h=c.receivedTime,m=c.sendingTime,g=c.url;v.length>0&&i.push.apply(i,v);for(var y,_=Os(f);!(y=_()).done;){var b=y.value;o.set(b,{receivedTime:h,sendingTime:m,url:g})}(l=s.periods).splice.apply(l,[d,1].concat(f))}return e(n,r,i,a,o)}}}};function Us(e){var t=e.textContent,n=[];return null===t||0===t.length?[void 0,n]:[{value:t},n]}function Fs(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"id":t.id=r.value;break;case"lang":t.language=r.value;break;case"contentType":t.contentType=r.value;break;case"par":t.par=r.value}}return t}var Bs=/^P(([\d.]*)Y)?(([\d.]*)M)?(([\d.]*)D)?T?(([\d.]*)H)?(([\d.]*)M)?(([\d.]*)S)?/,zs=/([0-9]+)-([0-9]+)/;function Vs(e,t){return"true"===e?[!0,null]:"false"===e?[!1,null]:[!1,new Zs("`"+t+'` property is not a boolean value but "'+e+'"')]}function Ks(e,t){var n=parseInt(e,10);return isNaN(n)?[null,new Zs("`"+t+'` property is not an integer value but "'+e+'"')]:[n,null]}function Ws(e,t){if("INF"===e)return[1/0,null];var n=parseFloat(e);return isNaN(n)?[null,new Zs("`"+t+'` property is invalid: "'+e+'"')]:[n,null]}function Gs(e,t){if("true"===e)return[!0,null];if("false"===e)return[!1,null];var n=parseInt(e,10);return isNaN(n)?[null,new Zs("`"+t+'` property is not a boolean nor an integer but "'+e+'"')]:[n,null]}function js(e,t){var n=Date.parse(e);return isNaN(n)?[null,new Zs("`"+t+'` is in an invalid date format: "'+e+'"')]:[new Date(Date.parse(e)).getTime()/1e3,null]}function Hs(e,t){if(!et(e))return[0,new Zs("`"+t+"` property is empty")];var n=Bs.exec(e);return null===n?[null,new Zs("`"+t+'` property has an unrecognized format "'+e+'"')]:[365*parseFloat(et(n[2])?n[2]:"0")*24*60*60+30*parseFloat(et(n[4])?n[4]:"0")*24*60*60+24*parseFloat(et(n[6])?n[6]:"0")*60*60+60*parseFloat(et(n[8])?n[8]:"0")*60+60*parseFloat(et(n[10])?n[10]:"0")+parseFloat(et(n[12])?n[12]:"0"),null]}function qs(e,t){var n=zs.exec(e);return null===n?[null,new Zs("`"+t+'` property has an unrecognized format "'+e+'"')]:[[+n[1],+n[2]],null]}function Ys(e,t){try{return[Wa(e),null]}catch(n){return[null,new Zs("`"+t+'` is not a valid base64 string: "'+e+'"')]}}function Qs(e,t){var n=/^(\d+)\/(\d+)$/.exec(e);return null!==n?[+n[1]/+n[2],null]:Ws(e,t)}function $s(e){for(var t,n,r=0;r<e.attributes.length;r++){var i=e.attributes[r];switch(i.name){case"schemeIdUri":t=i.value;break;case"value":n=i.value}}return{schemeIdUri:t,value:n}}function Xs(e,t){return function(n,r){var i=r.asKey,a=(0,r.parser)(n,r.dashName),o=a[0],s=a[1];null!==s&&(T.warn(s.message),t.push(s)),null!==o&&(e[i]=o)}}var Zs=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(j(r),t.prototype),r.name="MPDError",r.message=n,r}return f(t,e),t}(Y(Error));function Js(e){var t=function(e){for(var t=[],n=[],r=0;r<e.length;r++)if(e[r].nodeType===Node.ELEMENT_NODE){var i=e[r];if("cenc:pssh"===i.nodeName){var a=i.textContent;if(null!==a&&a.length>0){var o=Ys(a,"cenc:pssh"),s=o[0],u=o[1];null!==u&&(T.warn(u.message),t.push(u)),null!==s&&n.push(s)}}}return[{cencPssh:n},t]}(e.childNodes),n=t[0],r=t[1];return[{children:n,attributes:function(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"schemeIdUri":t.schemeIdUri=r.value;break;case"value":t.value=r.value;break;case"cenc:default_KID":t.keyId=xa(r.value.replace(/-/g,""))}}return t}(e)},r]}function eu(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"range":r(a.value,{asKey:"range",parser:qs,dashName:"range"});break;case"sourceURL":t.media=a.value}}return[t,n]}function tu(e){for(var t={},n=[],r=Xs(t,n),i=e.childNodes,a=0;a<i.length;a++)if(i[a].nodeType===Node.ELEMENT_NODE){var o=i[a];if("Initialization"===o.nodeName){var s=eu(o),u=s[0],l=s[1];t.initialization=u,n=n.concat(l)}}for(var d=0;d<e.attributes.length;d++){var c=e.attributes[d];switch(c.name){case"timescale":r(c.value,{asKey:"timescale",parser:Ks,dashName:"timescale"});break;case"presentationTimeOffset":r(c.value,{asKey:"presentationTimeOffset",parser:Ws,dashName:"presentationTimeOffset"});break;case"indexRange":r(c.value,{asKey:"indexRange",parser:qs,dashName:"indexRange"});break;case"indexRangeExact":r(c.value,{asKey:"indexRangeExact",parser:Vs,dashName:"indexRangeExact"});break;case"availabilityTimeOffset":r(c.value,{asKey:"availabilityTimeOffset",parser:Ws,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(c.value,{asKey:"availabilityTimeComplete",parser:Vs,dashName:"availabilityTimeComplete"});break;case"duration":r(c.value,{asKey:"duration",parser:Ks,dashName:"duration"});break;case"startNumber":r(c.value,{asKey:"startNumber",parser:Ks,dashName:"startNumber"});break;case"endNumber":r(c.value,{asKey:"endNumber",parser:Ks,dashName:"endNumber"})}}return[t,n]}function nu(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"media":t.media=a.value;break;case"indexRange":r(a.value,{asKey:"indexRange",parser:qs,dashName:"indexRange"});break;case"index":t.index=a.value;break;case"mediaRange":r(a.value,{asKey:"mediaRange",parser:qs,dashName:"mediaRange"})}}return[t,n]}function ru(e){for(var t=tu(e),n=t[0],r=t[1],i=[],a=e.childNodes,o=0;o<a.length;o++)if(a[o].nodeType===Node.ELEMENT_NODE){var s=a[o];if("SegmentURL"===s.nodeName){var u=nu(s),l=u[0],d=u[1];i.push(l),r=r.concat(d)}}return[m(n,{list:i}),r]}function iu(e){var t=null;return function(){if(null===t){var n=e.getElementsByTagName("S");return t=n,n}return t}}function au(e){for(var n,r=tu(e),i=r[0],a=r[1],o=0;o<e.childNodes.length;o++)if(e.childNodes[o].nodeType===Node.ELEMENT_NODE){var s=e.childNodes[o];"SegmentTimeline"===s.nodeName&&(n=iu(s))}for(var u=m({},i,{duration:i.duration,timelineParser:n}),l=Xs(u,a),d=0;d<e.attributes.length;d++){var c=e.attributes[d];switch(c.nodeName){case"initialization":t(u.initialization)&&(u.initialization={media:c.value});break;case"index":u.index=c.value;break;case"availabilityTimeOffset":l(c.value,{asKey:"availabilityTimeOffset",parser:Ws,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":l(c.value,{asKey:"availabilityTimeComplete",parser:Vs,dashName:"availabilityTimeComplete"});break;case"media":u.media=c.value;break;case"bitstreamSwitching":l(c.value,{asKey:"bitstreamSwitching",parser:Vs,dashName:"bitstreamSwitching"})}}return[u,a]}function ou(e){var n=function(e){for(var n={baseURLs:[]},r=[],i=[],a=0;a<e.length;a++)if(e[a].nodeType===Node.ELEMENT_NODE){var o=e[a];switch(o.nodeName){case"BaseURL":var s=Us(o),u=s[0],l=s[1];void 0!==u&&n.baseURLs.push(u),i=i.concat(l);break;case"InbandEventStream":void 0===n.inbandEventStreams&&(n.inbandEventStreams=[]),n.inbandEventStreams.push($s(o));break;case"SegmentBase":var d=tu(o),c=d[0],f=d[1];n.segmentBase=c,f.length>0&&(i=i.concat(f));break;case"SegmentList":var v=ru(o),p=v[0],h=v[1];i=i.concat(h),n.segmentList=p;break;case"SegmentTemplate":var m=au(o),g=m[0],y=m[1];i=i.concat(y),n.segmentTemplate=g;break;case"ContentProtection":var _=Js(o),b=_[0],S=_[1];S.length>0&&(i=i.concat(S)),void 0!==b&&r.push(b);break;case"SupplementalProperty":t(n.supplementalProperties)?n.supplementalProperties=[$s(o)]:n.supplementalProperties.push($s(o))}}return r.length>0&&(n.contentProtections=r),[n,i]}(e.childNodes),r=n[0],i=n[1],a=function(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"audioSamplingRate":t.audioSamplingRate=a.value;break;case"bandwidth":r(a.value,{asKey:"bitrate",parser:Ks,dashName:"bandwidth"});break;case"codecs":t.codecs=a.value;break;case"codingDependency":r(a.value,{asKey:"codingDependency",parser:Vs,dashName:"codingDependency"});break;case"frameRate":r(a.value,{asKey:"frameRate",parser:Qs,dashName:"frameRate"});break;case"height":r(a.value,{asKey:"height",parser:Ks,dashName:"height"});break;case"id":t.id=a.value;break;case"maxPlayoutRate":r(a.value,{asKey:"maxPlayoutRate",parser:Ws,dashName:"maxPlayoutRate"});break;case"maximumSAPPeriod":r(a.value,{asKey:"maximumSAPPeriod",parser:Ws,dashName:"maximumSAPPeriod"});break;case"mimeType":t.mimeType=a.value;break;case"profiles":t.profiles=a.value;break;case"qualityRanking":r(a.value,{asKey:"qualityRanking",parser:Ks,dashName:"qualityRanking"});break;case"scte214:supplementalCodecs":t.supplementalCodecs=a.value;break;case"segmentProfiles":t.segmentProfiles=a.value;break;case"width":r(a.value,{asKey:"width",parser:Ks,dashName:"width"});break;case"availabilityTimeOffset":r(a.value,{asKey:"availabilityTimeOffset",parser:Ws,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(a.value,{asKey:"availabilityTimeComplete",parser:Vs,dashName:"availabilityTimeComplete"})}}return void 0===t.bitrate&&n.push(new Zs("No bitrate found on a Representation")),[t,n]}(e),o=a[0],s=a[1];return[{children:r,attributes:o},i.concat(s)]}function su(e){var n=function(e){for(var n={baseURLs:[],representations:[]},r=[],i=[],a=0;a<e.length;a++)if(e[a].nodeType===Node.ELEMENT_NODE){var o=e[a];switch(o.nodeName){case"Accessibility":void 0===n.accessibilities?n.accessibilities=[$s(o)]:n.accessibilities.push($s(o));break;case"BaseURL":var s=Us(o),u=s[0],l=s[1];void 0!==u&&n.baseURLs.push(u),l.length>0&&(i=i.concat(l));break;case"ContentComponent":n.contentComponent=Fs(o);break;case"EssentialProperty":t(n.essentialProperties)?n.essentialProperties=[$s(o)]:n.essentialProperties.push($s(o));break;case"InbandEventStream":void 0===n.inbandEventStreams&&(n.inbandEventStreams=[]),n.inbandEventStreams.push($s(o));break;case"Label":var d=o.textContent;null!=d&&(n.label=d);break;case"Representation":var c=ou(o),f=c[0],v=c[1];n.representations.push(f),v.length>0&&(i=i.concat(v));break;case"Role":t(n.roles)?n.roles=[$s(o)]:n.roles.push($s(o));break;case"SupplementalProperty":t(n.supplementalProperties)?n.supplementalProperties=[$s(o)]:n.supplementalProperties.push($s(o));break;case"SegmentBase":var p=tu(o),h=p[0],m=p[1];n.segmentBase=h,m.length>0&&(i=i.concat(m));break;case"SegmentList":var g=ru(o),y=g[0],_=g[1];n.segmentList=y,_.length>0&&(i=i.concat(_));break;case"SegmentTemplate":var b=au(o),S=b[0],E=b[1];n.segmentTemplate=S,E.length>0&&(i=i.concat(E));break;case"ContentProtection":var T=Js(o),k=T[0],w=T[1];w.length>0&&(i=i.concat(w)),void 0!==k&&r.push(k)}}return r.length>0&&(n.contentProtections=r),[n,i]}(e.childNodes),r=n[0],i=n[1],a=function(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"group":r(a.value,{asKey:"group",parser:Ks,dashName:"group"});break;case"lang":t.language=a.value;break;case"contentType":t.contentType=a.value;break;case"par":t.par=a.value;break;case"minBandwidth":r(a.value,{asKey:"minBitrate",parser:Ks,dashName:"minBandwidth"});break;case"maxBandwidth":r(a.value,{asKey:"maxBitrate",parser:Ks,dashName:"maxBandwidth"});break;case"minWidth":r(a.value,{asKey:"minWidth",parser:Ks,dashName:"minWidth"});break;case"maxWidth":r(a.value,{asKey:"maxWidth",parser:Ks,dashName:"maxWidth"});break;case"minHeight":r(a.value,{asKey:"minHeight",parser:Ks,dashName:"minHeight"});break;case"maxHeight":r(a.value,{asKey:"maxHeight",parser:Ks,dashName:"maxHeight"});break;case"minFrameRate":r(a.value,{asKey:"minFrameRate",parser:Qs,dashName:"minFrameRate"});break;case"maxFrameRate":r(a.value,{asKey:"maxFrameRate",parser:Qs,dashName:"maxFrameRate"});break;case"selectionPriority":r(a.value,{asKey:"selectionPriority",parser:Ks,dashName:"selectionPriority"});break;case"segmentAlignment":r(a.value,{asKey:"segmentAlignment",parser:Gs,dashName:"segmentAlignment"});break;case"subsegmentAlignment":r(a.value,{asKey:"subsegmentAlignment",parser:Gs,dashName:"subsegmentAlignment"});break;case"bitstreamSwitching":r(a.value,{asKey:"bitstreamSwitching",parser:Vs,dashName:"bitstreamSwitching"});break;case"audioSamplingRate":t.audioSamplingRate=a.value;break;case"codecs":t.codecs=a.value;break;case"scte214:supplementalCodecs":t.supplementalCodecs=a.value;break;case"codingDependency":r(a.value,{asKey:"codingDependency",parser:Vs,dashName:"codingDependency"});break;case"frameRate":r(a.value,{asKey:"frameRate",parser:Qs,dashName:"frameRate"});break;case"height":r(a.value,{asKey:"height",parser:Ks,dashName:"height"});break;case"maxPlayoutRate":r(a.value,{asKey:"maxPlayoutRate",parser:Ws,dashName:"maxPlayoutRate"});break;case"maximumSAPPeriod":r(a.value,{asKey:"maximumSAPPeriod",parser:Ws,dashName:"maximumSAPPeriod"});break;case"mimeType":t.mimeType=a.value;break;case"profiles":t.profiles=a.value;break;case"segmentProfiles":t.segmentProfiles=a.value;break;case"width":r(a.value,{asKey:"width",parser:Ks,dashName:"width"});break;case"availabilityTimeOffset":r(a.value,{asKey:"availabilityTimeOffset",parser:Ws,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(a.value,{asKey:"availabilityTimeComplete",parser:Vs,dashName:"availabilityTimeComplete"})}}return[t,n]}(e),o=a[0],s=a[1];return[{children:r,attributes:o},i.concat(s)]}function uu(e){for(var t={children:{events:[]},attributes:{}},n=[],r=Xs(t.attributes,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"schemeIdUri":t.attributes.schemeIdUri=a.value;break;case"timescale":r(a.value,{asKey:"timescale",parser:Ks,dashName:"timescale"});break;case"value":t.attributes.value=a.value}}for(var o=0;o<e.childNodes.length;o++)if(e.childNodes[o].nodeType===Node.ELEMENT_NODE){var s=e.childNodes[o];if("Event"===s.nodeName){var u=lu(s),l=u[0],d=u[1];t.children.events.push(l),d.length>0&&(n=n.concat(d))}}return[t,n]}function lu(e){for(var t={eventStreamData:e},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"presentationTime":r(a.value,{asKey:"presentationTime",parser:Ks,dashName:"presentationTime"});break;case"duration":r(a.value,{asKey:"duration",parser:Ks,dashName:"duration"});break;case"id":t.id=a.value}}return[t,n]}function du(e){var t=function(e){for(var t,n=[],r=[],i=[],a=[],o=0;o<e.length;o++)if(e[o].nodeType===Node.ELEMENT_NODE){var s=e[o];switch(s.nodeName){case"BaseURL":var u=Us(s),l=u[0],d=u[1];void 0!==l&&n.push(l),i=i.concat(d);break;case"AdaptationSet":var c=su(s),f=c[0],v=c[1];r.push(f),i=i.concat(v);break;case"EventStream":var p=uu(s),h=p[0],m=p[1];a.push(h),i=i.concat(m);break;case"SegmentTemplate":var g=au(s),y=g[0],_=g[1];t=y,_.length>0&&(i=i.concat(_))}}return[{baseURLs:n,adaptations:r,eventStreams:a,segmentTemplate:t},i]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"start":r(a.value,{asKey:"start",parser:Hs,dashName:"start"});break;case"duration":r(a.value,{asKey:"duration",parser:Hs,dashName:"duration"});break;case"bitstreamSwitching":r(a.value,{asKey:"bitstreamSwitching",parser:Vs,dashName:"bitstreamSwitching"});break;case"xlink:href":t.xlinkHref=a.value;break;case"xlink:actuate":t.xlinkActuate=a.value}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}function cu(e){var t=function(e){for(var t=[],n=[],r=[],i=[],a=[],o=0;o<e.length;o++)if(e[o].nodeType===Node.ELEMENT_NODE){var s=e[o];switch(s.nodeName){case"BaseURL":var u=Us(s),l=u[0],d=u[1];void 0!==l&&t.push(l),a=a.concat(d);break;case"Location":n.push(null===s.textContent?"":s.textContent);break;case"Period":var c=du(s),f=c[0],v=c[1];r.push(f),a=a.concat(v);break;case"UTCTiming":var p=$s(s);i.push(p)}}return[{baseURLs:t,locations:n,periods:r,utcTimings:i},a]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Xs(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"profiles":t.profiles=a.value;break;case"type":t.type=a.value;break;case"availabilityStartTime":r(a.value,{asKey:"availabilityStartTime",parser:js,dashName:"availabilityStartTime"});break;case"availabilityEndTime":r(a.value,{asKey:"availabilityEndTime",parser:js,dashName:"availabilityEndTime"});break;case"publishTime":r(a.value,{asKey:"publishTime",parser:js,dashName:"publishTime"});break;case"mediaPresentationDuration":r(a.value,{asKey:"duration",parser:Hs,dashName:"mediaPresentationDuration"});break;case"minimumUpdatePeriod":r(a.value,{asKey:"minimumUpdatePeriod",parser:Hs,dashName:"minimumUpdatePeriod"});break;case"minBufferTime":r(a.value,{asKey:"minBufferTime",parser:Hs,dashName:"minBufferTime"});break;case"timeShiftBufferDepth":r(a.value,{asKey:"timeShiftBufferDepth",parser:Hs,dashName:"timeShiftBufferDepth"});break;case"suggestedPresentationDelay":r(a.value,{asKey:"suggestedPresentationDelay",parser:Hs,dashName:"suggestedPresentationDelay"});break;case"maxSegmentDuration":r(a.value,{asKey:"maxSegmentDuration",parser:Hs,dashName:"maxSegmentDuration"});break;case"maxSubsegmentDuration":r(a.value,{asKey:"maxSubsegmentDuration",parser:Hs,dashName:"maxSubsegmentDuration"})}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}var fu=function(e,n){var r=e.documentElement;if(t(r)||"MPD"!==r.nodeName)throw new Error("DASH Parser: document root should be MPD");var i=cu(r),a=i[0],o=i[1];return function e(n){if("done"===n.type)return n;if("needs-clock"===n.type)return{type:"needs-resources",value:{urls:[n.value.url],format:"string",continue:function(t){if(1!==t.length)throw new Error("DASH parser: wrong number of loaded ressources.");var r=n.value.continue(t[0].responseData);return e(r)}}};if("needs-xlinks"===n.type)return{type:"needs-resources",value:{urls:n.value.xlinksUrls,format:"string",continue:function(r){for(var i=[],a=0;a<r.length;a++){var o=r[a],s=o.responseData,u=o.receivedTime,l=o.sendingTime,d=o.url;if(!s.success)throw s.error;var c="<root>"+s.data+"</root>",f=(new DOMParser).parseFromString(c,"text/xml");if(t(f)||0===f.children.length)throw new Error("DASH parser: Invalid external ressources");for(var v=f.children[0].children,p=[],h=[],m=0;m<v.length;m++)if(v[m].nodeType===Node.ELEMENT_NODE){var g=du(v[m]),y=g[0],_=g[1];h.push.apply(h,_),p.push(y)}i.push({url:d,receivedTime:u,sendingTime:l,parsed:p,warnings:h})}var b=n.value.continue(i);return e(b)}}};X()}(Ls(a,n,o))};function vu(e){var t=e.referenceDateTime,n=void 0!==e.serverSyncInfos?e.serverSyncInfos.serverTimestamp-e.serverSyncInfos.clientTime:void 0;return function(r,i,a,o,s){var u,l=r.responseData,d=i.externalClockOffset,c=null!==(u=r.url)&&void 0!==u?u:i.originalUrl,f=null!=n?n:d,v={unsafelyBaseOnPreviousManifest:i.unsafeMode?i.previousManifest:null,url:c,referenceDateTime:t,externalClockOffset:f},p=ot.dashParsers;if(null===p.wasm||"uninitialized"===p.wasm.status||"failure"===p.wasm.status)return T.debug("DASH: WASM MPD Parser not initialized. Running JS one."),g();var h=function(e){if(e instanceof ArrayBuffer)return e;if("string"==typeof e)return Aa(e).buffer;if(e instanceof Document)return Aa(e.documentElement.innerHTML).buffer;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return function(e){var t=new DataView(e);if(61371===t.getUint16(0)&&191===t.getUint8(2))return!0;if(65279===t.getUint16(0)||65534===t.getUint16(0))return!1;return!0}(h)?"initialized"===p.wasm.status?(T.debug("DASH: Running WASM MPD Parser."),y(p.wasm.runWasmParser(h,v))):(T.debug("DASH: Awaiting WASM initialization before parsing the MPD."),p.wasm.waitForInitialization().catch((function(){})).then((function(){return null===p.wasm||"initialized"!==p.wasm.status?(T.warn("DASH: WASM MPD parser initialization failed. Running JS parser instead"),g()):(T.debug("DASH: Running WASM MPD Parser."),y(p.wasm.runWasmParser(h,v)))}))):(T.info("DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one."),g());function g(){if(null===p.js)throw new Error("No MPD parser is imported");var e=function(e){if(e instanceof ArrayBuffer)return(new DOMParser).parseFromString(Ra(new Uint8Array(e)),"text/xml");if("string"==typeof e)return(new DOMParser).parseFromString(e,"text/xml");if(e instanceof Document)return e;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return y(p.js(e,v))}function y(t){if("done"===t.type){if(t.value.warnings.length>0&&a(t.value.warnings),o.isCancelled())return Promise.reject(o.cancellationError);var n=[];return{manifest:new It(t.value.parsed,e,n),url:c,warnings:n}}var r=t.value,i=r.urls.map((function(e){return s((function(){var t=b.getCurrent().DEFAULT_REQUEST_TIMEOUT,n=b.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return"string"===r.format?co({url:e,responseType:"text",timeout:t,connectionTimeout:n,cancelSignal:o}):co({url:e,responseType:"arraybuffer",timeout:t,connectionTimeout:n,cancelSignal:o})})).then((function(e){if("string"===r.format){if("string"!=typeof e.responseData)throw new Error("External DASH resources should have been a string");return m(e,{responseData:{success:!0,data:e.responseData}})}if(!(e.responseData instanceof ArrayBuffer))throw new Error("External DASH resources should have been ArrayBuffers");return m(e,{responseData:{success:!0,data:e.responseData}})}),(function(e){var t=Ne(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"An unknown error occured when parsing ressources."});return m({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:t}})}))}));return Promise.all(i).then((function(e){return r.format,y(r.continue(e))}))}}}var pu="function"==typeof Headers?Headers:null,hu="function"==typeof AbortController?AbortController:null;function mu(){return"function"==typeof s.fetch&&!t(hu)&&!t(pu)}function gu(e,t){return"audio"===e||"video"===e?"video/mp4"===t||"audio/mp4"===t?"mp4":"video/webm"===t||"audio/webm"===t?"webm":void 0:"text"===e&&"application/mp4"===t?"mp4":void 0}function yu(e){return function(t,n,r,i,a){return new Promise((function(s,u){var l=new Z,d=l.linkToSignal(i);function c(){l.signal.deregister(u),d()}l.signal.register(u),e(t,n,r,l.signal,Object.assign(Object.assign({},a),{onNewChunk:function(e){try{o(e),a.onNewChunk(e)}catch(e){c(),l.cancel(),u(e)}}})).then((function(e){if(c(),!l.isUsed()){if("segment-loaded"===e.resultType)try{o(e.resultData.responseData)}catch(e){return void u(e)}s(e)}}),(function(e){c(),u(e)}))}));function o(e){(e instanceof ArrayBuffer||e instanceof Uint8Array)&&"mp4"===gu(n.type,n.mimeType)&&vo(new Uint8Array(e),n.segment.isInit)}}}function _u(e,t){return null===e?null:null===t.url?e.baseUrl:Sa(e.baseUrl,t.url)}function bu(e,t,n,r,i){if(void 0===t.range)return co({url:e,responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(void 0===t.indexRange)return co({url:e,headers:{Range:Co(t.range)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(t.range[1]+1===t.indexRange[0])return co({url:e,headers:{Range:Co([t.range[0],t.indexRange[1]])},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));var a=co({url:e,headers:{Range:Co(t.range)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),o=co({url:e,headers:{Range:Co(t.indexRange)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then((function(t){var n=t[0],r=t[1],i=Xr(new Uint8Array(n.responseData),new Uint8Array(r.responseData)),a=Math.min(n.sendingTime,r.sendingTime),o=Math.max(n.receivedTime,r.receivedTime);return{resultType:"segment-loaded",resultData:{url:e,responseData:i,size:n.size+r.size,requestDuration:o-a,sendingTime:a,receivedTime:o}}}))}function Su(e,n,r,i,a){var o=n.segment,s=void 0!==o.range?{Range:Co(o.range)}:void 0,u=null;return function(e){var n;if(!t(e.headers))if(t(pu))n=e.headers;else{n=new pu;for(var r=Object.keys(e.headers),i=0;i<r.length;i++){var a=r[i];n.append(a,e.headers[a])}}T.debug("Fetch: Called with URL",e.url);var o,s,u=null,l=!1,c=!1,f=ne(),v=t(hu)?null:new hu;function h(){t(v)?T.warn("Fetch: AbortController API not available."):v.abort()}void 0!==e.timeout&&(o=setTimeout((function(){l=!0,void 0!==s&&clearTimeout(s),h()}),e.timeout)),void 0!==e.connectionTimeout&&(s=setTimeout((function(){c=!0,void 0!==o&&clearTimeout(o),h()}),e.connectionTimeout));var m=e.cancelSignal.register((function(e){u=e,h()})),g={method:"GET"};return void 0!==n&&(g.headers=n),g.signal=t(v)?null:v.signal,fetch(e.url,g).then((function(n){if(void 0!==s&&clearTimeout(s),n.status>=300)throw T.warn("Fetch: Request HTTP Error",n.status,n.url),new ke(n.url,n.status,we.ERROR_HTTP_CODE);if(t(n.body))throw new ke(n.url,n.status,we.PARSE_ERROR);var r=n.headers.get("Content-Length"),i=t(r)||isNaN(+r)?void 0:+r,a=n.body.getReader(),u=0;return l();function l(){return c.apply(this,arguments)}function c(){return(c=d(p().mark((function r(){var s,d,c,v,h;return p().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,a.read();case 2:if((s=r.sent).done||t(s.value)){r.next=11;break}return u+=s.value.byteLength,d=ne(),c={url:n.url,currentTime:d,duration:d-f,sendingTime:f,chunkSize:s.value.byteLength,chunk:s.value.buffer,size:u,totalSize:i},e.onData(c),r.abrupt("return",l());case 11:if(!s.done){r.next=17;break}return void 0!==o&&clearTimeout(o),m(),v=ne(),h=v-f,r.abrupt("return",{requestDuration:h,receivedTime:v,sendingTime:f,size:u,status:n.status,url:n.url});case 17:return r.abrupt("return",l());case 18:case"end":return r.stop()}}),r)})))).apply(this,arguments)}})).catch((function(t){if(null!==u)throw u;if(m(),l)throw T.warn("Fetch: Request timed out."),new ke(e.url,0,we.TIMEOUT);if(c)throw T.warn("Fetch: Request connection timed out."),new ke(e.url,0,we.TIMEOUT);if(t instanceof ke)throw t;throw T.warn("Fetch: Request Error",t instanceof Error?t.toString():""),new ke(e.url,0,we.ERROR_EVENT)}))}({url:e,headers:s,onData:function(e){var t=new Uint8Array(e.chunk),n=function(e){for(var t=0,n=[],r=null;t<e.length;){var i=fo(r=e.subarray(t,1/0),1836019558);if(i<0)break;var a=t+i+ei(e,i+t);if(a>e.length)break;var o=fo(r,1835295092);if(o<0)break;var s=t+o+ei(e,o+t);if(s>e.length)break;var u=Math.max(a,s),l=e.subarray(t,u);n.push(l),t=u}return 0===n.length?[null,r]:[Xr.apply(void 0,n),r]}(null!==u?Xr(u,t):t),r=n[0];u=n[1],null!==r&&(i.onNewChunk(r),a.isCancelled())||(i.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize}),a.isCancelled())},timeout:r.timeout,cancelSignal:a}).then((function(e){return{resultType:"chunk-complete",resultData:e}}))}function Eu(e,t,n,r,i,a){if(t.segment.isInit)return bu(e,t.segment,r,a,i);var o=gu(t.type,t.mimeType);if(n&&("mp4"===o||void 0===o)){if(mu())return Su(e,t,r,i,a);Be("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}var s=t.segment;return co({url:e,responseType:"arraybuffer",headers:void 0!==s.range?{Range:Co(s.range)}:void 0,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}var Tu="function"==typeof Uint8Array.prototype.slice?function(e,t,n){return e.slice(t,n)}:function(e,t,n){return new Uint8Array(Array.prototype.slice.call(e,t,n))};function ku(e,t){if(e[t]>1)T.warn("ISOBMFF: un-handled PSSH version");else{var n=t+4;if(!(n+16>e.length))return Ca(Tu(e,n,n+16))}}var wu=408125543,Au=357149030,Iu=2807729,Ru=17545,xu=475249515,Cu=187,Mu=179,Pu=183,Du=241;function Ou(e,t,n,r){for(var i=r[0],a=r[1],o=i;o<a;){var s=Fu(n,o);if(null===s)return null;var u=s.value,l=o+s.length,d=Bu(n,l);if(null===d)return null;var c=l+d.length,f=c+d.value;if(u===e)return[c,f];if(t.length>0)for(var v=0;v<t.length;v++){if(u===t[v])return Ou(e,t.slice(v+1,t.length),n,[c,f])}o=f}return null}function Nu(e,t){var n=Ou(Iu,[wu,Au],e,[t,e.length]);if(null===n)return null;var r=n[1]-n[0];return 1e9/zu(e,n[0],r)}function Lu(e,t){var n=Ou(Ru,[wu,Au],e,[t,e.length]);if(null===n)return null;var r=n[1]-n[0];return 4===r?function(e,t){return new DataView(e.buffer).getFloat32(t)}(e,n[0]):8===r?function(e,t){return new DataView(e.buffer).getFloat64(t)}(e,n[0]):null}function Uu(e,t){for(var n=1;n<=8;n++)if(e[t]>=Math.pow(2,8-n))return n}function Fu(e,t){var n=Uu(e,t);if(void 0===n)return T.warn("webm: unrepresentable length"),null;if(t+n>e.length)return T.warn("webm: impossible length"),null;for(var r=0,i=0;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return{length:n,value:r}}function Bu(e,t){var n=Uu(e,t);if(void 0===n)return T.warn("webm: unrepresentable length"),null;if(t+n>e.length)return T.warn("webm: impossible length"),null;for(var r=(e[t]&(1<<8-n)-1)*Math.pow(2,8*(n-1)),i=1;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return{length:n,value:r}}function zu(e,t,n){for(var r=0,i=0;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return r}function Vu(e,t,n,r){var i=function(e){var t=ha(e);if(null!==t){var n=ca(t,1952867444);if(null!==n){var r=n[0];return 1===r?ti(n,4):0===r?ei(n,4):void 0}}}(e);if(void 0===i||void 0===r)return null;var a,o=void 0!==n.timestampOffset?i+n.timestampOffset*r:i,s=_o(e);if(o<0&&(void 0!==s&&(s+=o),o=0),t||!n.complete)return void 0===s&&T.warn("DASH: Chunked segments should indicate a duration through their trun boxes"),{time:o/r,duration:void 0!==s?s/r:void 0};var u=n.duration*r,l=Math.min(.9*r,u/4);return void 0!==s&&Math.abs(s-u)<=l&&(a=s),{time:o/r,duration:void 0!==a?a/r:a}}function Ku(e,t){if(0!==e.length){var n=e.reduce((function(e,t){return"urn:mpeg:dash:event:2012"===t.schemeIdUri&&"1"===t.value?(void 0===e.manifestRefreshEventsFromEMSGs&&(e.manifestRefreshEventsFromEMSGs=[]),e.manifestRefreshEventsFromEMSGs.push(t)):(void 0===e.EMSGs&&(e.EMSGs=[]),e.EMSGs.push(t)),e}),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),r=n.manifestRefreshEventsFromEMSGs,i=n.EMSGs,a=null==i?void 0:i.map((function(e){return{type:"emsg",value:e}})),o=void 0!==t&&void 0!==r&&function(e,t){if(e.length<=0)return!1;for(var n=e.length,r=0;r<n;r++){var i=t,a=Ra(e[r].messageData),o=Date.parse(a);if(void 0===i||void 0===o||isNaN(o)||o>=i)return!0}return!1}(r,t);return{inbandEvents:a,needsManifestRefresh:o}}}function Wu(e){var n=e.__priv_patchLastSegmentInSidx;return function(e,r,i){var a,o,s=r.segment,u=r.periodStart,l=r.periodEnd,d=e.data,c=e.isChunked,f=[u,l];if(null===d)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:f};var v=d instanceof Uint8Array?d:new Uint8Array(d),p=gu(r.type,r.mimeType),h="mp4"===p||void 0===p,m=[];if(h){var g,y=function(e){var t=0,n=ca(e,1836019574);if(null===n)return[];for(var r=[];t<n.length;){var i=void 0;try{i=fa(n,1886614376)}catch(e){var a=e instanceof Error?e:"";return T.warn("Error while removing PSSH from ISOBMFF",a),r}if(null===i)return r;var o=Tu(n,i[0],i[2]),s=ku(o,i[1]-i[0]);void 0!==s&&r.push({systemId:s,data:o}),n[i[0]+4]=102,n[i[0]+5]=114,n[i[0]+6]=101,n[i[0]+7]=101,t=i[2]}return r}(v);s.isInit&&(g=null!==(a=function(e){var t=da(e,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(null===t)return null;var n=t.subarray(8),r=ca(n,1701733238),i=0;if(null===r?(i=28,r=ca(n,1701733217)):i=78,null===r)return null;var a=da(r.subarray(i),[1936289382,1935894633,1952804451]);return null===a||a.byteLength<24?null:a.subarray(8,24)}(v))&&void 0!==a?a:void 0),(y.length>0||void 0!==g)&&m.push({initDataType:"cenc",keyId:g,initData:y})}if(!s.isInit){var _=h?Vu(v,c,s,i):null,b=null!==(o=s.timestampOffset)&&void 0!==o?o:0;if(h){var S=function(e){for(var t=[],n=0;n<e.length;){var r=ya(e,n);if(null===r)break;var i=r.length;n+=i;var a=r[0];if(0!==a)T.warn("ISOBMFF: EMSG version "+a.toString()+" not supported.");else{var o=4,s=Pa(r,o),u=s.end,l=s.string,d=Pa(r,o=u),c=d.end,f=d.string,v=ei(r,o=c),p=ei(r,o+=4),h=ei(r,o+=4),m=ei(r,o+=4);o+=4;var g={schemeIdUri:l,value:f,timescale:v,presentationTimeDelta:p,eventDuration:h,id:m,messageData:r.subarray(o,i)};t.push(g)}}if(0!==t.length)return t}(v);if(void 0!==S){var E=Ku(S.filter((function(e){return void 0!==s.privateInfos&&void 0!==s.privateInfos.isEMSGWhitelisted&&s.privateInfos.isEMSGWhitelisted(e)})),r.manifestPublishTime);if(void 0!==E){var k=E.needsManifestRefresh,w=E.inbandEvents;return{segmentType:"media",chunkData:v,chunkSize:v.length,chunkInfos:_,chunkOffset:b,appendWindow:f,inbandEvents:w,protectionData:m,needsManifestRefresh:k}}}}return{segmentType:"media",chunkData:v,chunkSize:v.length,chunkInfos:_,chunkOffset:b,protectionData:m,appendWindow:f}}var A,I,R=s.indexRange;if("webm"===p)A=function(e,t){var n=Ou(wu,[],e,[t,e.length]);if(null===n)return null;var r=n[0],i=n[1],a=Nu(e,r);if(null===a)return null;var o=Lu(e,r);if(null===o)return null;var s=Ou(xu,[],e,[r,i]);if(null===s)return null;for(var u=[],l=s[0];l<s[1];){var d=Ou(Cu,[],e,[l,s[1]]);if(null===d)break;var c=Ou(Mu,[],e,[d[0],d[1]]);if(null===c)return null;var f=zu(e,c[0],c[1]-c[0]),v=Ou(Du,[Pu],e,[d[0],d[1]]);if(null===v)return null;var p=zu(e,v[0],v[1]-v[0])+r;u.push({time:f,rangeStart:p}),l=d[1]}for(var h=[],m=0;m<u.length;m++){var g=u[m];m===u.length-1?h.push({time:g.time,timescale:a,duration:0===m?o:o-g.time,range:[g.rangeStart,1/0]}):h.push({time:g.time,timescale:a,duration:u[m+1].time-g.time,range:[g.rangeStart,u[m+1].rangeStart-1]})}return h}(v,0);else if(h&&(A=go(v,Array.isArray(R)?R[0]:0),!0===n&&null!==A&&A.length>0)){var x=A[A.length-1];Array.isArray(x.range)&&(x.range[1]=1/0)}h?I=bo(v):"webm"===p&&(I=Nu(v,0));var C=t(I)?void 0:I;return{segmentType:"init",initializationData:v,initializationDataSize:v.length,protectionData:m,initTimescale:C,segmentList:null!=A?A:void 0}}}function Gu(e,t,n,r){var i,a,o=e.segment,s=e.language,u=e.codecs;if(o.isInit)return null;null===n?r?(i=o.time,a=o.end):T.warn("Transport: Unavailable time data for current text track."):(i=n.time,void 0!==n.duration?a=i+n.duration:!r&&o.complete&&(a=i+o.duration));var l=function(e){if(void 0===e)throw new Error("Cannot parse subtitles: unknown format");switch(e.toLowerCase()){case"stpp":case"stpp.ttml.im1t":return"ttml";case"wvtt":return"vtt"}throw new Error('The codec used for the subtitles "'+e+'" is not managed yet.')}(u),d=function(e){var t=ga(e);return null===t?"":Ra(t)}(t);return{data:d,type:l,language:s,start:i,end:a}}function ju(e,t,n){var r,i,a=e.segment;return a.isInit?null:(n?T.warn("Transport: Unavailable time data for current text track."):(r=a.time,a.complete&&(i=a.time+a.duration)),{data:t,type:function(e,t){switch(t){case"application/ttml+xml":return"ttml";case"application/x-sami":case"application/smil":return"sami";case"text/vtt":return"vtt"}if(void 0!==e&&"srt"===e.toLowerCase())return"srt";throw new Error("could not find a text-track parser for the type "+(null!=t?t:""))}(e.codecs,e.mimeType),language:e.language,start:r,end:i})}function Hu(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=e.data,l=e.isChunked;if(null===u)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:null!==(i=s.timestampOffset)&&void 0!==i?i:0,protectionData:[],appendWindow:[a,o]};var d=gu(n.type,n.mimeType);if("webm"===d)throw new Error("Text tracks with a WEBM container are not yet handled.");return"mp4"===d?function(e,t,n,r,i){var a,o,s=n.segment,u=s.isInit,l=s.indexRange;if(o="string"==typeof e?Aa(e):e instanceof Uint8Array?e:new Uint8Array(e),u){var d=go(o,Array.isArray(l)?l[0]:0);if(!0===i&&null!==d&&d.length>0){var c=d[d.length-1];Array.isArray(c.range)&&(c.range[1]=1/0)}return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:bo(o),segmentList:null!=d?d:void 0}}var f=Vu(o,t,s,r),v=Gu(n,o,f,t),p=null!==(a=s.timestampOffset)&&void 0!==a?a:0;return{segmentType:"media",chunkData:v,chunkSize:o.length,chunkInfos:f,chunkOffset:p,protectionData:[],appendWindow:[n.periodStart,n.periodEnd]}}(u,l,n,r,t):function(e,t,n){var r,i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=s.timestampOffset,l=void 0===u?0:u;if(s.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if("string"!=typeof e){var d=e instanceof Uint8Array?e:new Uint8Array(e);r=Ra(d),i=d.length}else r=e;return{segmentType:"media",chunkData:ju(n,r,t),chunkSize:i,chunkInfos:null,chunkOffset:l,protectionData:[],appendWindow:[a,o]}}(u,l,n)}}var qu=function(e){var t=po({customManifestLoader:e.manifestLoader},null===ot.dashParsers.wasm||"initialized"!==ot.dashParsers.wasm.status&&"initializing"!==ot.dashParsers.wasm.status?"arraybuffer":"text"),n=vu(e),r=function(e){var t=e.lowLatencyMode,n=e.segmentLoader;return!0!==e.checkMediaSegmentIntegrity?r:yu(r);function r(e,r,i,a,o){var s=_u(e,r.segment);return null===s?Promise.resolve({resultType:"segment-created",resultData:null}):t||void 0===n?Eu(s,r,t,i,o,a):new Promise((function(e,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a DASH segment through a custom segmentLoader.",o=new xt(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(t){d||a.isCancelled()||(d=!0,a.deregister(p),e({resultType:"segment-loaded",resultData:{responseData:t.data,size:t.size,requestDuration:t.duration}}))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),Eu(s,r,t,i,o,a).then(e,u))}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:s},v=n(f,c);function p(e){d||(d=!0,"function"==typeof v&&v(),u(e))}a.register(p)}))}}(e),i=Wu(e),a=function(e){var t=e.lowLatencyMode;return!0!==e.checkMediaSegmentIntegrity?n:yu(n);function n(e,n,r,i,a){var o=n.segment,s=o.range,u=_u(e,o);if(null===u)return Promise.resolve({resultType:"segment-created",resultData:null});if(o.isInit)return bu(u,o,r,i,a);var l=gu(n.type,n.mimeType),d="mp4"===l||void 0===l;if(t&&d){if(mu())return Su(u,n,r,a,i);Be("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}return d?co({url:u,responseType:"arraybuffer",headers:Array.isArray(s)?{Range:Co(s)}:null,timeout:r.timeout,connectionTimeout:r.connectionTimeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}})):co({url:u,responseType:"text",headers:Array.isArray(s)?{Range:Co(s)}:null,timeout:r.timeout,connectionTimeout:r.connectionTimeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}}(e);return{manifest:{loadManifest:t,parseManifest:n},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:Hu(e)}}};function Yu(e){void 0===e.transports.dash&&(e.transports.dash=qu),e.dashParsers.js=fu,e.mainThreadMediaSourceInit=ra,e.codecSupportProber=sa}var Qu=function(e){function n(t){var n;return(n=e.call(this)||this)._settings=t,n._initCanceller=new Z,n}f(n,e);var r=n.prototype;return r.prepare=function(){},r.start=function(e,t){var n=this,r=this._initCanceller.signal,i=this._settings,a=i.keySystems,o=i.speed,s=i.url;xr(e);var u=new G(null);u.finish();var l=zi(e,a,u,{onError:function(e){return n._onFatalError(e)},onWarning:function(e){return n.trigger("warning",e)},onBlackListProtectionData:S,onKeyIdsCompatibilityUpdate:S},r);ea(e,(function(e){return n._onFatalError(e)}),r);var d=new Wi(t,null,o);d.addEventListener("stalled",(function(e){return n.trigger("stalled",e)})),d.addEventListener("unstalled",(function(){return n.trigger("unstalled",null)})),d.addEventListener("warning",(function(e){return n.trigger("warning",e)})),r.register((function(){d.destroy()})),d.start(),l.onUpdate((function(i,a){"uninitialized"!==i.initializationState.type&&(a(),T.info("Setting URL to HTMLMediaElement",s),e.src=s,r.register((function(){T.info("Init: Removing directfile src from media element",e.src),xr(e)})),"awaiting-media-link"===i.initializationState.type?(i.initializationState.value.isMediaLinked.setValue(!0),l.onUpdate((function(r,i){"initialized"===r.initializationState.type&&(i(),n._seekAndPlay(e,t))}),{emitCurrentValue:!0,clearSignal:r})):($(i.initializationState.type),n._seekAndPlay(e,t)))}),{emitCurrentValue:!0,clearSignal:r})},r.updateContentUrls=function(e,t){throw new Error("Cannot update content URL of directfile contents")},r.dispose=function(){this._initCanceller.cancel()},r._onFatalError=function(e){this._initCanceller.cancel(),this.trigger("error",e)},r._seekAndPlay=function(e,n){var r=this,i=this._initCanceller.signal,a=this._settings,o=a.autoPlay,s=a.startAt;Bi({mediaElement:e,playbackObserver:n,startTime:function(){T.debug("Init: Calculating initial time");var n=function(e,n){if(t(n))return 0;if(!t(n.position))return n.position;if(!t(n.wallClockTime))return n.wallClockTime;if(!t(n.fromFirstPosition))return n.fromFirstPosition;var r=e.duration;if("number"==typeof n.fromLastPosition)return t(r)||!isFinite(r)?(T.warn("startAt.fromLastPosition set but no known duration, beginning at 0."),0):Math.max(0,r+n.fromLastPosition);if("number"==typeof n.fromLivePosition){var i=e.seekable.length>0?e.seekable.end(0):r;return t(i)?(T.warn("startAt.fromLivePosition set but no known live position, beginning at 0."),0):Math.max(0,i+n.fromLivePosition)}if(!t(n.percentage)){if(t(r)||!isFinite(r))return T.warn("startAt.percentage set but no known duration, beginning at 0."),0;var a=n.percentage;return a>=100?r:a<=0?0:r*(+a/100)}return 0}(e,s);return T.debug("Init: Initial time calculated:",n),n},mustAutoPlay:o,onWarning:function(e){return r.trigger("warning",e)},isDirectfile:!0},i).autoPlayResult.then((function(){return Fi(n,e,!0,i).onUpdate((function(e,t){e&&(t(),r.trigger("loaded",{segmentSinksStore:null}))}),{emitCurrentValue:!0,clearSignal:i})})).catch((function(e){i.isCancelled()||r._onFatalError(e)}))},n}(wr);function $u(e,t){var n;if(t.length!==e.length)return!0;for(var r=0;r<t.length;r++)if(t[r].nativeTrack!==(null===(n=e[r])||void 0===n?void 0:n.nativeTrack))return!0;return!1}function Xu(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_audio_"+o+"_"+s.toString();r[o]=s+1;var l={language:a.language,id:u,normalized:it(a.language),audioDescription:"descriptions"===a.kind||"description"===a.kind,representations:[]};n.push({track:l,nativeTrack:a})}return n}function Zu(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_text_"+o+"_"+s.toString();r[o]=s+1;var l="forced"===a.kind||void 0,d={language:a.language,forced:l,label:a.label,id:u,normalized:it(a.language),closedCaption:"captions"===a.kind};n.push({track:d,nativeTrack:a})}return n}function Ju(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_video_"+o+"_"+s.toString();r[o]=s+1,n.push({track:{id:u,representations:[]},nativeTrack:a})}return n}var el=function(e){function n(t){var n,r,i,a;return(n=e.call(this)||this)._nativeAudioTracks=t.audioTracks,n._nativeVideoTracks=t.videoTracks,n._nativeTextTracks=t.textTracks,n._audioTracks=void 0!==n._nativeAudioTracks?Xu(n._nativeAudioTracks):[],n._videoTracks=void 0!==n._nativeVideoTracks?Ju(n._nativeVideoTracks):[],n._textTracks=void 0!==n._nativeTextTracks?Zu(n._nativeTextTracks):[],n._lastEmittedNativeAudioTrack=null===(r=n._getCurrentAudioTrack())||void 0===r?void 0:r.nativeTrack,n._lastEmittedNativeVideoTrack=null===(i=n._getCurrentVideoTrack())||void 0===i?void 0:i.nativeTrack,n._lastEmittedNativeTextTrack=null===(a=n._getCurrentTextTrack())||void 0===a?void 0:a.nativeTrack,n._handleNativeTracksCallbacks(),n}f(n,e);var r=n.prototype;return r.setAudioTrackById=function(e){for(var t=0;t<this._audioTracks.length;t++){var n=this._audioTracks[t],r=n.track,i=n.nativeTrack;if(r.id===e)return this._enableAudioTrackFromIndex(t),void(this._audioTrackLockedOn=i)}throw new Error("Audio track not found.")},r.disableTextTrack=function(){tl(this._textTracks),this._textTrackLockedOn=null},r.setTextTrackById=function(e){for(var t=!1,n=0;n<this._textTracks.length;n++){var r=this._textTracks[n],i=r.track,a=r.nativeTrack;i.id===e?(a.mode="showing",t=!0,this._textTrackLockedOn=a):"showing"!==a.mode&&"hidden"!==a.mode||(a.mode="disabled")}if(!t)throw new Error("Text track not found.")},r.disableVideoTrack=function(){rl(this._videoTracks),this._videoTrackLockedOn=null},r.setVideoTrackById=function(e){for(var t=0;t<this._videoTracks.length;t++){var n=this._videoTracks[t],r=n.track,i=n.nativeTrack;if(r.id===e)return i.selected=!0,void(this._videoTrackLockedOn=i)}throw new Error("Video track not found.")},r.getChosenAudioTrack=function(){var e=this._getCurrentAudioTrack();return t(e)?e:e.track},r.getChosenTextTrack=function(){var e=this._getCurrentTextTrack();return t(e)?e:e.track},r.getChosenVideoTrack=function(){var e=this._getCurrentVideoTrack();return t(e)?e:e.track},r.getAvailableAudioTracks=function(){return this._audioTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,language:t.language,normalized:t.normalized,audioDescription:t.audioDescription,active:n.enabled,representations:t.representations}}))},r.getAvailableTextTracks=function(){return this._textTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,label:t.label,forced:t.forced,language:t.language,normalized:t.normalized,closedCaption:t.closedCaption,active:"showing"===n.mode}}))},r.getAvailableVideoTracks=function(){return this._videoTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,representations:t.representations,active:n.selected}}))},r.dispose=function(){void 0!==this._nativeVideoTracks&&(this._nativeVideoTracks.onchange=null,this._nativeVideoTracks.onaddtrack=null,this._nativeVideoTracks.onremovetrack=null),void 0!==this._nativeAudioTracks&&(this._nativeAudioTracks.onchange=null,this._nativeAudioTracks.onaddtrack=null,this._nativeAudioTracks.onremovetrack=null),void 0!==this._nativeTextTracks&&(this._nativeTextTracks.onchange=null,this._nativeTextTracks.onaddtrack=null,this._nativeTextTracks.onremovetrack=null),this.removeEventListener()},r._getCurrentAudioTrack=function(){if(void 0!==this._nativeAudioTracks){for(var e=0;e<this._audioTracks.length;e++){var t=this._audioTracks[e];if(t.nativeTrack.enabled)return t}return null}},r._getCurrentVideoTrack=function(){if(void 0!==this._nativeVideoTracks){for(var e=0;e<this._videoTracks.length;e++){var t=this._videoTracks[e];if(t.nativeTrack.selected)return t}return null}},r._getCurrentTextTrack=function(){if(void 0!==this._nativeTextTracks){for(var e=0;e<this._textTracks.length;e++){var t=this._textTracks[e];if("showing"===t.nativeTrack.mode)return t}return null}},r._setPreviouslyLockedAudioTrack=function(){if(void 0!==this._audioTrackLockedOn)if(null===this._audioTrackLockedOn)for(var e=0;e<this._audioTracks.length;e++){this._audioTracks[e].nativeTrack.enabled=!1}else for(var t=0;t<this._audioTracks.length;t++){if(this._audioTracks[t].nativeTrack===this._audioTrackLockedOn)return void this._enableAudioTrackFromIndex(t)}},r._setPreviouslyLockedTextTrack=function(){if(void 0!==this._textTrackLockedOn)if(null!==this._textTrackLockedOn)for(var e=0;e<this._textTracks.length;e++){var t=this._textTracks[e].nativeTrack;if(t===this._textTrackLockedOn)return nl(this._textTracks,t),void("showing"!==t.mode&&(t.mode="showing"))}else tl(this._textTracks)},r._setPreviouslyLockedVideoTrack=function(){if(void 0!==this._videoTrackLockedOn)if(null!==this._videoTrackLockedOn)for(var e=0;e<this._videoTracks.length;e++){var t=this._videoTracks[e].nativeTrack;if(t===this._videoTrackLockedOn)return void(t.selected=!0)}else rl(this._videoTracks)},r._handleNativeTracksCallbacks=function(){var e=this;void 0!==this._nativeAudioTracks&&(this._nativeAudioTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeAudioTracks){var r=Xu(e._nativeAudioTracks);if($u(e._audioTracks,r)){e._audioTracks=r,e._setPreviouslyLockedAudioTrack(),e.trigger("availableAudioTracksChange",e.getAvailableAudioTracks());var i=e._getCurrentAudioTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeAudioTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeAudioTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeAudioTracks){var r=Xu(e._nativeAudioTracks);if($u(e._audioTracks,r)){e._audioTracks=r,e.trigger("availableAudioTracksChange",e.getAvailableAudioTracks());var i=e._getCurrentAudioTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeAudioTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeAudioTracks.onchange=function(){if(void 0!==e._audioTracks)for(var t=0;t<e._audioTracks.length;t++){var n=e._audioTracks[t],r=n.track,i=n.nativeTrack;if(i.enabled)return void(i!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",r),e._lastEmittedNativeAudioTrack=i))}null!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null),e._lastEmittedNativeAudioTrack=null)}),void 0!==this._nativeTextTracks&&(this._nativeTextTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeTextTracks){var r=Zu(e._nativeTextTracks);if($u(e._textTracks,r)){e._textTracks=r,e._setPreviouslyLockedTextTrack(),e.trigger("availableTextTracksChange",e.getAvailableTextTracks());var i=e._getCurrentTextTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeTextTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeTextTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeTextTracks){var r=Zu(e._nativeTextTracks);if($u(e._textTracks,r)){e._textTracks=r,e._setPreviouslyLockedTextTrack(),e.trigger("availableTextTracksChange",e.getAvailableTextTracks());var i=e._getCurrentTextTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeTextTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeTextTracks.onchange=function(){if(void 0!==e._textTracks)for(var t=0;t<e._textTracks.length;t++){var n=e._textTracks[t],r=n.track,i=n.nativeTrack;if("showing"===i.mode)return void(i!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",r),e._lastEmittedNativeTextTrack=i))}null!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null),e._lastEmittedNativeTextTrack=null)}),void 0!==this._nativeVideoTracks&&(this._nativeVideoTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeVideoTracks){var r=Ju(e._nativeVideoTracks);if($u(e._videoTracks,r)){e._videoTracks=r,e._setPreviouslyLockedVideoTrack(),e.trigger("availableVideoTracksChange",e.getAvailableVideoTracks());var i=e._getCurrentVideoTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeVideoTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeVideoTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeVideoTracks){var r=Ju(e._nativeVideoTracks);if($u(e._videoTracks,r)){e._videoTracks=r,e._setPreviouslyLockedVideoTrack(),e.trigger("availableVideoTracksChange",e.getAvailableVideoTracks());var i=e._getCurrentVideoTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeVideoTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeVideoTracks.onchange=function(){if(void 0!==e._videoTracks)for(var t=0;t<e._videoTracks.length;t++){var n=e._videoTracks[t],r=n.track,i=n.nativeTrack;if(i.selected)return void(i!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",r),e._lastEmittedNativeVideoTrack=i))}null!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null),e._lastEmittedNativeVideoTrack=null)})},r._enableAudioTrackFromIndex=function(e){!function(e,t){for(var n=0;n<e.length;n++)_i&&n===t||(e[n].enabled=!1);t<0||t>=e.length||(e[t].enabled=!0)}(this._audioTracks.map((function(e){return e.nativeTrack})),e)},n}(i);function tl(e){for(var t=0;t<e.length;t++){e[t].nativeTrack.mode="disabled"}}function nl(e,t){for(var n=0;n<e.length;n++){var r=e[n].nativeTrack;r===t||"showing"!==r.mode&&"hidden"!==r.mode||(r.mode="disabled")}}function rl(e){for(var t=0;t<e.length;t++){e[t].nativeTrack.selected=!1}}function il(e){e.directfile={initDirectFile:Qu,mediaElementTracksStore:el}}var al,ol=s.WebKitMediaKeys;function sl(e){return sl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},sl(e)}function ul(e){var t=function(e,t){if("object"!=sl(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=sl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==sl(t)?t:String(t)}function ll(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ul(r.key),r)}}function dl(e,t,n){return t&&ll(e.prototype,t),n&&ll(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}void 0!==ol&&"function"==typeof ol.isTypeSupported&&"function"==typeof ol.prototype.createSession&&"function"==typeof HTMLMediaElement.prototype.webkitSetMediaKeys&&(al=ol);var cl,fl=function(){function e(e,t,n){this._keyType=e,this._mediaKeys=t,this._configuration=n}var t=e.prototype;return t.createMediaKeys=function(){var e=this;return new Promise((function(t){return t(e._mediaKeys)}))},t.getConfiguration=function(){return this._configuration},dl(e,[{key:"keySystem",get:function(){return this._keyType}}]),e}(),vl=s.MSMediaKeys;function pl(e){try{var t=e();return"object"==typeof t&&null!==t&&"function"==typeof t.then?t:Promise.resolve(t)}catch(e){return Promise.reject(e)}}void 0!==vl&&void 0!==vl.prototype&&"function"==typeof vl.isTypeSupported&&"function"==typeof vl.prototype.createSession&&(cl=vl);var hl,ml=function(e){function n(t){var n;return(n=e.call(this)||this).expiration=NaN,n.keyStatuses=new Map,n._mk=t,n._sessionClosingCanceller=new Z,n.closed=new Promise((function(e){n._sessionClosingCanceller.signal.register((function(){return e()}))})),n.update=function(e){return new Promise((function(t,r){if(void 0===n._ss)return r("MediaKeySession not set.");try{t(n._ss.update(e,""))}catch(e){r(e)}}))},n}f(n,e);var r=n.prototype;return r.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r;r=t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer),n._ss=n._mk.createSession("video/mp4",r),Wr(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"message",e)}),n._sessionClosingCanceller.signal),Gr(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyadded",e)}),n._sessionClosingCanceller.signal),jr(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyerror",e)}),n._sessionClosingCanceller.signal),e()}))},r.close=function(){var e=this;return new Promise((function(n){t(e._ss)||(e._ss.close(),e._ss=void 0),e._sessionClosingCanceller.cancel(),n()}))},r.load=function(){return Promise.resolve(!1)},r.remove=function(){return Promise.resolve()},dl(n,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._ss)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),n}(i),gl=function(){function e(e){if(void 0===cl)throw new Error("No MSMediaKeys API.");this._mediaKeys=new cl(e)}var t=e.prototype;return t._setVideo=function(e){var t=this;return pl((function(){t._videoElement=e,void 0!==t._videoElement.msSetMediaKeys&&t._videoElement.msSetMediaKeys(t._mediaKeys)}))},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new ml(this._mediaKeys)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();var yl=s.MozMediaKeys;function _l(e){return"function"==typeof(null==e?void 0:e.webkitGenerateKeyRequest)}void 0!==yl&&void 0!==yl.prototype&&"function"==typeof yl.isTypeSupported&&"function"==typeof yl.prototype.createSession&&(hl=yl);var bl=function(e){function t(t,n){var r;(r=e.call(this)||this)._vid=t,r._key=n,r.sessionId="",r._closeSession=S,r.keyStatuses=new Map,r.expiration=NaN;var i=function(e){r.trigger(e.type,e)};return r.closed=new Promise((function(e){r._closeSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.removeEventListener(e,i),t.removeEventListener("webkit"+e,i)})),e()}})),["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.addEventListener(e,i),t.addEventListener("webkit"+e,i)})),r}f(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){try{if(t._key.indexOf("clearkey")>=0){var i=e instanceof ArrayBuffer?new Uint8Array(e):e,a=JSON.parse(Ra(i)),o=Wa(a.keys[0].k),s=Wa(a.keys[0].kid);n(t._vid.webkitAddKey(t._key,o,s,""))}else n(t._vid.webkitAddKey(t._key,e,null,""))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){n._vid.webkitGenerateKeyRequest(n._key,t),e()}))},n.close=function(){var e=this;return new Promise((function(t){e._closeSession(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},t}(i),Sl=function(){function e(e){this._keySystem=e}var n=e.prototype;return n._setVideo=function(e){var t=this;return pl((function(){if(!_l(e))throw new Error("Video not attached to the MediaKeys");t._videoElement=e}))},n.createSession=function(){if(t(this._videoElement))throw new Error("Video not attached to the MediaKeys");return new bl(this._videoElement,this._keySystem)},n.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();function El(e,t){var n=e instanceof Uint8Array?e:new Uint8Array(e),r=t instanceof Uint8Array?t:new Uint8Array(t),i=function(e,t){return e[t+0]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]}(n,0);if(i+4!==n.length)throw new Error("Unsupported WebKit initData.");var a=wa(n),o=a.indexOf("skd://"),s=function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint8Array(t),r=0;r<n.length;r+=2){var i=e.charCodeAt(r/2);n[r]=255&i,n[r+1]=i>>8&255}return n}(o>-1?a.substring(o+6):a),u=0,l=new Uint8Array(n.byteLength+4+s.byteLength+4+r.byteLength);return l.set(n),u+=n.length,l.set(ai(s.byteLength),u),u+=4,l.set(s,u),u+=s.byteLength,l.set(ai(r.byteLength),u),u+=4,l.set(r,u),l}function Tl(e,t){var n=e;return pl((function(){if(void 0===n.webkitSetMediaKeys)throw new Error("No webKitMediaKeys API.");n.webkitSetMediaKeys(t)}))}var kl=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._serverCertificate=r,i._videoElement=t,i._keyType=n,i._unbindSession=S,i._closeSession=S,i.closed=new Promise((function(e){i._closeSession=e})),i.keyStatuses=new Map,i.expiration=NaN,i}f(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){if(void 0===t._nativeSession||void 0===t._nativeSession.update||"function"!=typeof t._nativeSession.update)return r("Unavailable WebKit key session.");try{var i;i=e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e.buffer),n(t._nativeSession.update(i))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r,i,a=n._videoElement;if(void 0===(null===(r=a.webkitKeys)||void 0===r?void 0:r.createSession))throw new Error("No WebKitMediaKeys API.");if(ar(n._keyType,"com.apple.fps")){if(void 0===n._serverCertificate)throw new Error("A server certificate is needed for creating fairplay session.");i=El(t,n._serverCertificate)}else i=t;var o=a.webkitKeys.createSession("video/mp4",i);if(null==o)throw new Error("Impossible to get the key sessions");n._listenEvent(o),n._nativeSession=o,e()}))},n.close=function(){var e=this;return new Promise((function(t,n){e._unbindSession(),e._closeSession(),void 0!==e._nativeSession?(e._nativeSession.close(),t()):n("No session to close.")}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},n._listenEvent=function(e){var t=this;this._unbindSession();var n=function(e){t.trigger(e.type,e)};["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.addEventListener(t,n),e.addEventListener("webkit"+t,n)})),this._unbindSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.removeEventListener(t,n),e.removeEventListener("webkit"+t,n)}))}},dl(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._nativeSession)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(i),wl=function(){function e(e){if(void 0===al)throw new Error("No WebKitMediaKeys API.");this._keyType=e,this._mediaKeys=new al(e)}var t=e.prototype;return t._setVideo=function(e){if(this._videoElement=e,void 0===this._videoElement)throw new Error("Video not attached to the MediaKeys");return Tl(this._videoElement,this._mediaKeys)},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new kl(this._videoElement,this._keyType,this._serverCertificate)},t.setServerCertificate=function(e){return this._serverCertificate=e,Promise.resolve()},e}();function Al(){if(void 0===al)throw new Error("No WebKitMediaKeys API.");return{isTypeSupported:al.isTypeSupported,createCustomMediaKeys:function(e){return new wl(e)},setMediaKeys:function(e,t){if(null===t)return Tl(e,t);if(!(t instanceof wl))throw new Error("Custom setMediaKeys is supposed to be called with webkit custom MediaKeys.");return t._setVideo(e)}}}var Il=function(e){var n,r,i,a,u=Rl;if("standard"!==e&&("auto"!==e||(mi||gi)&&void 0!==al)||!o&&t(navigator.requestMediaKeySystemAccess)){var l,d;if("webkit"===e&&void 0!==al){i=Or(["needkey"]);var c=Al();l=c.isTypeSupported,d=c.createCustomMediaKeys,u=c.setMediaKeys,a="webkit"}else if(_l(null===(n=s.HTMLVideoElement)||void 0===n?void 0:n.prototype)){i=Or(["needkey"]);var f={isTypeSupported:function(e){var n=document.querySelector("video");return t(n)&&(n=document.createElement("video")),!t(n)&&"function"==typeof n.canPlayType&&!!n.canPlayType("video/mp4",e)},createCustomMediaKeys:function(e){return new Sl(e)},setMediaKeys:function(e,t){if(null===t)return Promise.resolve(void 0);if(!(t instanceof Sl))throw new Error("Custom setMediaKeys is supposed to be called with old webkit custom MediaKeys.");return t._setVideo(e)}};l=f.isTypeSupported,d=f.createCustomMediaKeys,u=f.setMediaKeys,a="older-webkit"}else if(void 0!==al){i=Or(["needkey"]);var v=Al();l=v.isTypeSupported,d=v.createCustomMediaKeys,u=v.setMediaKeys,a="webkit"}else if(vi&&void 0!==cl){i=Or(["encrypted","needkey"]);var p={isTypeSupported:function(e,t){if(void 0===cl)throw new Error("No MSMediaKeys API.");return void 0!==t?cl.isTypeSupported(e,t):cl.isTypeSupported(e)},createCustomMediaKeys:function(e){return new gl(e)},setMediaKeys:function(e,t){if(null===t)return Promise.resolve(void 0);if(!(t instanceof gl))throw new Error("Custom setMediaKeys is supposed to be called with IE11 custom MediaKeys.");return t._setVideo(e)}};l=p.isTypeSupported,d=p.createCustomMediaKeys,u=p.setMediaKeys,a="ms"}else if(void 0!==hl){i=Or(["encrypted","needkey"]);var h={isTypeSupported:function(e,t){if(void 0===hl)throw new Error("No MozMediaKeys API.");return void 0!==t?hl.isTypeSupported(e,t):hl.isTypeSupported(e)},createCustomMediaKeys:function(e){if(void 0===hl)throw new Error("No MozMediaKeys API.");return new hl(e)},setMediaKeys:function(e,t){return pl((function(){var n=e;if(void 0===n.mozSetMediaKeys||"function"!=typeof n.mozSetMediaKeys)throw new Error("Can't set video on MozMediaKeys.");return n.mozSetMediaKeys(t)}))}};l=h.isTypeSupported,d=h.createCustomMediaKeys,u=h.setMediaKeys,a="moz"}else{i=Or(["encrypted","needkey"]);var m=s.MediaKeys,g=function(){if(void 0===m)throw new Me("MEDIA_KEYS_NOT_SUPPORTED","No `MediaKeys` implementation found in the current browser.");if(void 0===m.isTypeSupported){throw new Error("This browser seems to be unable to play encrypted contents currently.Note: Some browsers do not allow decryption in some situations, like when not using HTTPS.")}};l=function(e){return g(),$(m.isTypeSupported),m.isTypeSupported(e)},d=function(e){return g(),new m(e)},a="unknown"}r=function(e,n){if(!l(e))return Promise.reject(new Error("Unsupported key type"));for(var r=0;r<n.length;r++){var i=n[r],a=i.videoCapabilities,o=i.audioCapabilities,s=i.initDataTypes,u=i.distinctiveIdentifier,c=!0;if(c=(c=c&&(t(s)||s.some((function(e){return"cenc"===e}))))&&"required"!==u){var f={initDataTypes:["cenc"],distinctiveIdentifier:"not-allowed",persistentState:"required",sessionTypes:["temporary","persistent-license"]};void 0!==a&&(f.videoCapabilities=a),void 0!==o&&(f.audioCapabilities=o);var v=d(e);return Promise.resolve(new fl(e,v,f))}}return Promise.reject(new Error("Unsupported configuration"))}}else r=function(){var e;return(e=navigator).requestMediaKeySystemAccess.apply(e,arguments)},i=Or(["encrypted"]),a="standard";return{requestMediaKeySystemAccess:r,onEncrypted:i,setMediaKeys:u,implementation:a}}("auto");function Rl(e,t){try{var n,r=e;return"function"==typeof r.setMediaKeys?n=r.setMediaKeys(t):"function"==typeof r.webkitSetMediaKeys?n=r.webkitSetMediaKeys(t):"function"==typeof r.mozSetMediaKeys?n=r.mozSetMediaKeys(t):"function"==typeof r.msSetMediaKeys&&null!==t&&(n=r.msSetMediaKeys(t)),"object"==typeof n&&null!==n&&"function"==typeof n.then?n:Promise.resolve(n)}catch(e){return Promise.reject(e)}}var xl=Il,Cl=ei(Aa("pssh"),0);function Ml(e,t){for(var n=0;n<e.length;n++){var r=e[n];if((void 0===t.systemId||void 0===r.systemId||t.systemId===r.systemId)&&st(t.data,r.data))return!0}return!1}function Pl(e){var n=e.initData,r=e.initDataType;if(t(n))return T.warn("Compat: No init data found on media encrypted event."),null;var i=function(e){for(var t=[],n=0;n<e.length;){if(e.length<n+8||ei(e,n+4)!==Cl)return T.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var r=ei(new Uint8Array(e),n);if(n+r>e.length)return T.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var i=e.subarray(n,n+r),a={systemId:ku(i,8),data:i};Ml(t,a)?T.warn("Compat: Duplicated PSSH found in initialization data, removing it."):t.push(a),n+=r}return n!==e.length?(T.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}]):t}(new Uint8Array(n));return{type:r,values:i}}function Dl(e){return Tr.setState(e,null),xl.setMediaKeys(e,null).then((function(){T.info("DRM: MediaKeys disabled with success")})).catch((function(e){T.error("DRM: Could not disable MediaKeys",e instanceof Error?e:"Unknown Error")}))}function Ol(){return(Ol=d(p().mark((function e(t,n,r){var i,a,o,s,u,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.emeImplementation,a=n.keySystemOptions,o=n.loadedSessionsStore,s=n.mediaKeySystemAccess,u=n.mediaKeys,l=Tr.getState(t),d=null!==l&&l.loadedSessionsStore!==o?l.loadedSessionsStore.closeAllSessions():Promise.resolve(),e.next=5,d;case 5:if(!r.isCancelled()){e.next=7;break}throw r.cancellationError;case 7:if(Tr.setState(t,{emeImplementation:i,keySystemOptions:a,mediaKeySystemAccess:s,mediaKeys:u,loadedSessionsStore:o}),t.mediaKeys!==u){e.next=10;break}return e.abrupt("return");case 10:T.info("DRM: Attaching MediaKeys to the media element"),i.setMediaKeys(t,u).then((function(){T.info("DRM: MediaKeys attached with success")})).catch((function(e){T.error("DRM: Could not set MediaKeys",e instanceof Error?e:"Unknown Error")}));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Nl(e){if(""===e.sessionId)return!1;var t=e.keyStatuses,n=[];return t.forEach((function(e){n.push(e)})),n.length<=0?(T.debug("DRM: isSessionUsable: MediaKeySession given has an empty keyStatuses",e.sessionId),!1):Ue(n,"expired")?(T.debug("DRM: isSessionUsable: MediaKeySession given has an expired key",e.sessionId),!1):Ue(n,"internal-error")?(T.debug("DRM: isSessionUsable: MediaKeySession given has a key with an internal-error",e.sessionId),!1):(T.debug("DRM: isSessionUsable: MediaKeySession is usable",e.sessionId),!0)}function Ll(e,t,n,r){var i=e.loadedSessionsStore,a=e.persistentSessionsStore;return"temporary"===n?Ul(i,t):null===a?(T.warn("DRM: Cannot create persistent MediaKeySession, PersistentSessionsStore not created."),Ul(i,t)):function(e,t,n,r){return Fl.apply(this,arguments)}(i,a,t,r)}function Ul(e,t){T.info("DRM: Creating a new temporary session");var n=e.createSession(t,"temporary");return Promise.resolve({type:"created-session",value:n})}function Fl(){return Fl=d(p().mark((function e(t,n,r,i){var a,o,s,u,l,c;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=function(){return c=d(p().mark((function e(){var o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===i.cancellationError){e.next=2;break}throw i.cancellationError;case 2:return T.info("DRM: Removing previous persistent session."),null!==(o=n.get(r))&&n.delete(o.sessionId),e.prev=5,e.next=8,t.closeSession(a.mediaKeySession);case 8:e.next=15;break;case 10:if(e.prev=10,e.t0=e.catch(5),""===a.mediaKeySession.sessionId){e.next=14;break}throw e.t0;case 14:t.removeSessionWithoutClosingIt(a.mediaKeySession);case 15:if(null===i.cancellationError){e.next=17;break}throw i.cancellationError;case 17:return s=t.createSession(r,"persistent-license"),e.abrupt("return",{type:"created-session",value:s});case 19:case"end":return e.stop()}}),e,null,[[5,10]])}))),c.apply(this,arguments)},l=function(){return c.apply(this,arguments)},null===i.cancellationError){e.next=4;break}throw i.cancellationError;case 4:if(T.info("DRM: Creating persistent MediaKeySession"),a=t.createSession(r,"persistent-license"),null!==(o=n.getAndReuse(r))){e.next=9;break}return e.abrupt("return",{type:"created-session",value:a});case 9:return e.prev=9,e.next=12,t.loadPersistentSession(a.mediaKeySession,o.sessionId);case 12:if(s=e.sent){e.next=19;break}return T.warn("DRM: No data stored for the loaded session"),n.delete(o.sessionId),t.removeSessionWithoutClosingIt(a.mediaKeySession),u=t.createSession(r,"persistent-license"),e.abrupt("return",{type:"created-session",value:u});case 19:if(!s||!Nl(a.mediaKeySession)){e.next=23;break}return n.add(r,r.keyIds,a.mediaKeySession),T.info("DRM: Succeeded to load persistent session."),e.abrupt("return",{type:"loaded-persistent-session",value:a});case 23:return T.warn("DRM: Previous persistent session not usable anymore."),e.abrupt("return",l());case 27:return e.prev=27,e.t0=e.catch(9),T.warn("DRM: Unable to load persistent session: "+(e.t0 instanceof Error?e.t0.toString():"Unknown Error")),e.abrupt("return",l());case 31:case"end":return e.stop()}}),e,null,[[9,27]])}))),Fl.apply(this,arguments)}function Bl(e,t){return zl.apply(this,arguments)}function zl(){return(zl=d(p().mark((function e(t,n){var r,i,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n<0||n>=t.getLength())){e.next=2;break}return e.abrupt("return");case 2:for(T.info("DRM: LSS cache limit exceeded",n,t.getLength()),r=[],i=t.getAll().slice(),a=i.length-n,o=0;o<a;o++)s=i[o],r.push(t.closeSession(s.mediaKeySession));return e.next=9,Promise.all(r);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Vl(e,t,n,r,i){return Kl.apply(this,arguments)}function Kl(){return(Kl=d(p().mark((function e(t,n,r,i,a){var o,s,u,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null,s=n.loadedSessionsStore,u=n.persistentSessionsStore,null===(l=s.reuse(t))){e.next=11;break}if(!Nl(o=l.mediaKeySession)){e.next=10;break}return T.info("DRM: Reuse loaded session",o.sessionId),e.abrupt("return",{type:"loaded-open-session",value:{mediaKeySession:o,sessionType:l.sessionType,keySessionRecord:l.keySessionRecord}});case 10:null!==u&&""!==l.mediaKeySession.sessionId&&u.delete(l.mediaKeySession.sessionId);case 11:if(null===o){e.next=16;break}return e.next=14,s.closeSession(o);case 14:if(null===a.cancellationError){e.next=16;break}throw a.cancellationError;case 16:return e.next=18,Bl(s,i);case 18:if(null===a.cancellationError){e.next=20;break}throw a.cancellationError;case 20:return e.next=22,Ll(n,t,r,a);case 22:return d=e.sent,e.abrupt("return",{type:d.type,value:{mediaKeySession:d.value.mediaKeySession,sessionType:d.value.sessionType,keySessionRecord:d.value.keySessionRecord}});case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Wl(e,n,r){var i=n.getConfiguration();if(vi||t(i))return null;var a=e.filter((function(e){return e.type===r.type&&(!!(t(e.persistentLicenseConfig)&&"required"!==e.persistentState||"required"===i.persistentState)&&("required"!==e.distinctiveIdentifier||"required"===i.distinctiveIdentifier))}))[0];return void 0!==a?{keySystemOptions:a,keySystemAccess:n}:null}function Gl(e){var n=e.keyName,r=e.keyType,i=e.keySystemOptions,a=["temporary"],o="optional",s="optional";t(i.persistentLicenseConfig)||(o="required",a.push("persistent-license")),t(i.persistentState)||(o=i.persistentState),t(i.distinctiveIdentifier)||(s=i.distinctiveIdentifier);var u,l,d=b.getCurrent(),c=d.EME_DEFAULT_AUDIO_CODECS,f=d.EME_DEFAULT_VIDEO_CODECS,v=d.EME_DEFAULT_WIDEVINE_ROBUSTNESSES,p=d.EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES,h=i.audioCapabilitiesConfig,m=i.videoCapabilitiesConfig;if("full"===(null==h?void 0:h.type))u=h.value;else{var g;0===(g="robustness"===(null==h?void 0:h.type)?h.value:"widevine"===n?v:"com.microsoft.playready.recommendation"===r?p:[]).length&&g.push(void 0);var y="contentType"===(null==h?void 0:h.type)?h.value:c;u=jo(g,(function(e){return y.map((function(t){return void 0!==e?{contentType:t,robustness:e}:{contentType:t}}))}))}if("full"===(null==m?void 0:m.type))l=m.value;else{var _;0===(_="robustness"===(null==m?void 0:m.type)?m.value:"widevine"===n?v:"com.microsoft.playready.recommendation"===r?p:[]).length&&_.push(void 0);var S="contentType"===(null==m?void 0:m.type)?m.value:f;l=jo(_,(function(e){return S.map((function(t){return void 0!==e?{contentType:t,robustness:e}:{contentType:t}}))}))}var E={initDataTypes:["cenc"],videoCapabilities:l,audioCapabilities:u,distinctiveIdentifier:s,persistentState:o,sessionTypes:a};return[E,Object.assign(Object.assign({},E),{audioCapabilities:void 0,videoCapabilities:void 0})]}function jl(e,n,r){T.info("DRM: Searching for compatible MediaKeySystemAccess");var i=Tr.getState(e);if(null!==i&&xl.implementation===i.emeImplementation.implementation){var a=Wl(n,i.mediaKeySystemAccess,i.keySystemOptions);if(null!==a)return T.info("DRM: Found cached compatible keySystem"),Promise.resolve({type:"reuse-media-key-system-access",value:{mediaKeySystemAccess:a.keySystemAccess,options:a.keySystemOptions}})}var o=n.reduce((function(e,n){var r,i=b.getCurrent().EME_KEY_SYSTEMS[n.type];if(t(i)){var a=function(e){for(var t=b.getCurrent().EME_KEY_SYSTEMS,n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];if(Ue(t[i],e))return i}}(n.type);r=[{keyName:a,keyType:n.type,keySystemOptions:n}]}else r=i.map((function(e){return{keyName:n.type,keyType:e,keySystemOptions:n}}));return e.concat(r)}),[]);return s(0);function s(e){return u.apply(this,arguments)}function u(){return(u=d(p().mark((function e(n){var i,a,u,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n>=o.length)){e.next=2;break}throw new Ce("INCOMPATIBLE_KEYSYSTEMS","No key system compatible with your wanted configuration has been found in the current browser.");case 2:if(!t(xl.requestMediaKeySystemAccess)){e.next=4;break}throw new Error("requestMediaKeySystemAccess is not implemented in your browser.");case 4:return i=o[n],a=i.keyType,u=i.keySystemOptions,l=Gl(i),T.debug("DRM: Request keysystem access "+a+","+(n+1)+" of "+o.length),e.prev=8,e.next=11,xl.requestMediaKeySystemAccess(a,l);case 11:return d=e.sent,T.info("DRM: Found compatible keysystem",a,n+1),e.abrupt("return",{type:"create-media-key-system-access",value:{options:u,mediaKeySystemAccess:d}});case 16:if(e.prev=16,e.t0=e.catch(8),T.debug("DRM: Rejected access to keysystem",a,n+1),null===r.cancellationError){e.next=21;break}throw r.cancellationError;case 21:return e.abrupt("return",s(n+1));case 22:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}}function Hl(e,t,n){var r;T.debug("Compat: Calling generateRequest on the MediaKeySession");try{r=function(e){T.info("Compat: Trying to move CENC PSSH from init data at the end of it.");for(var t=!1,n=new Uint8Array,r=new Uint8Array,i=0;i<e.length;){if(e.length<i+8||ei(e,i+4)!==Cl)throw T.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var a=ei(new Uint8Array(e),i);if(i+a>e.length)throw T.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var o=e.subarray(i,i+a);if(16===e[i+12]&&119===e[i+13]&&239===e[i+14]&&236===e[i+15]&&192===e[i+16]&&178===e[i+17]&&77===e[i+18]&&2===e[i+19]&&172===e[i+20]&&227===e[i+21]&&60===e[i+22]&&30===e[i+23]&&82===e[i+24]&&226===e[i+25]&&251===e[i+26]&&75===e[i+27]){var s=pa(o),u=null===s?void 0:o[s[1]];T.info("Compat: CENC PSSH found with version",u),void 0===u?T.warn("Compat: could not read version of CENC PSSH"):t===(1===u)?n=Xr(n,o):1===u?(T.warn("Compat: cenc version 1 encountered, removing every other cenc pssh box."),n=o,t=!0):T.warn("Compat: filtering out cenc pssh box with wrong version",u)}else r=Xr(r,o);i+=a}if(i!==e.length)throw T.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");return Xr(r,n)}(n)}catch(e){r=n}var i=null!=t?t:"";return e.generateRequest(i,r).catch((function(t){if(""!==i||!(t instanceof TypeError))throw t;return T.warn('Compat: error while calling `generateRequest` with an empty initialization data type. Retrying with a default "cenc" value.',t),e.generateRequest("cenc",r)}))}var ql=100;function Yl(e,t){return Ql.apply(this,arguments)}function Ql(){return(Ql=d(p().mark((function e(t,n){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.info("DRM: Load persisted session",n),e.next=3,t.load(n);case 3:if((r=e.sent)&&!(t.keyStatuses.size>0)){e.next=6;break}return e.abrupt("return",r);case 6:return e.abrupt("return",new Promise((function(e){t.addEventListener("keystatuseschange",i);var n=setTimeout(i,ql);function i(){clearTimeout(n),t.removeEventListener("keystatuseschange",i),e(r)}})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $l(e){var t=new Z;return Promise.race([e.close().then((function(){t.cancel()})),e.closed.then((function(){t.cancel()})),function(){return n.apply(this,arguments)}()]);function n(){return(n=d(p().mark((function e(){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Mt(1e3,t.signal);case 3:return e.next=5,r();case 5:e.next=13;break;case 7:if(e.prev=7,e.t0=e.catch(0),!(e.t0 instanceof ee)){e.next=11;break}return e.abrupt("return");case 11:n=e.t0 instanceof Error?e.t0.message:"Unknown error made it impossible to close the session",T.error("DRM: "+n);case 13:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function r(){return i.apply(this,arguments)}function i(){return(i=d(p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.update(new Uint8Array(1));case 3:n.next=13;break;case 5:if(n.prev=5,n.t0=n.catch(0),!t.isUsed()){n.next=9;break}return n.abrupt("return");case 9:if(!(n.t0 instanceof Error&&"The session is already closed."===n.t0.message)){n.next=11;break}return n.abrupt("return");case 11:return n.next=13,Mt(1e3,t.signal);case 13:if(!t.isUsed()){n.next=15;break}return n.abrupt("return");case 15:throw new Error("Compat: Couldn't know if session is closed");case 16:case"end":return n.stop()}}),n,null,[[0,5]])})))).apply(this,arguments)}}function Xl(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Zl(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Zl(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Zl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Jl(e,t){for(var n,r,i=function(){var e=r.value;if(!t.some((function(t){return st(t,e)})))return{v:!1}},a=Xl(e);!(r=a()).done;)if(n=i())return n.v;return!0}function ed(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return td(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return td(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function td(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var nd=function(){function e(e){this._initializationData=e,this._keyIds=null}var t=e.prototype;return t.associateKeyIds=function(e){null===this._keyIds&&(this._keyIds=[]);for(var t=0,n=Array.from(e);t<n.length;t++){var r=n[t];this.isAssociatedWithKeyId(r)||this._keyIds.push(r)}},t.isAssociatedWithKeyId=function(e){if(null===this._keyIds)return!1;for(var t,n=ed(this._keyIds);!(t=n()).done;){if(st(t.value,e))return!0}return!1},t.getAssociatedKeyIds=function(){return null===this._keyIds?[]:this._keyIds},t.isCompatibleWith=function(e){var t=e.keyIds;if(void 0!==t&&t.length>0){if(null!==this._keyIds&&Jl(t,this._keyIds))return!0;if(void 0!==this._initializationData.keyIds)return Jl(t,this._initializationData.keyIds)}return this._checkInitializationDataCompatibility(e)},t._checkInitializationDataCompatibility=function(e){return void 0!==e.keyIds&&e.keyIds.length>0&&void 0!==this._initializationData.keyIds?Jl(e.keyIds,this._initializationData.keyIds):this._initializationData.type===e.type&&this._initializationData.values.isCompatibleWith(e.values)},e}();function rd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return id(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return id(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function id(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ad=function(){function e(e){this._mediaKeys=e,this._storage=[]}var n=e.prototype;return n.createSession=function(e,n){var r=this,i=new nd(e);T.debug("DRM-LSS: calling `createSession`",n);var a=this._mediaKeys.createSession(n),o={mediaKeySession:a,sessionType:n,keySessionRecord:i,isGeneratingRequest:!1,isLoadingPersistentSession:!1,closingStatus:{type:"none"}};return t(a.closed)||a.closed.then((function(){T.info("DRM-LSS: session was closed, removing it.",a.sessionId);var e=r.getIndex(i);e>=0&&r._storage[e].mediaKeySession===a&&r._storage.splice(e,1)})).catch((function(e){T.warn("DRM-LSS: MediaKeySession.closed rejected: "+e)})),this._storage.push(Object.assign({},o)),T.debug("DRM-LSS: MediaKeySession added",o.sessionType,this._storage.length),o},n.reuse=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.keySessionRecord.isCompatibleWith(e))return this._storage.splice(t,1),this._storage.push(n),T.debug("DRM-LSS: Reusing session:",n.mediaKeySession.sessionId,n.sessionType),Object.assign({},n)}return null},n.getEntryForSession=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.mediaKeySession===e)return Object.assign({},n)}return null},n.generateLicenseRequest=function(){var e=d(p().mark((function e(t,n,r){var i,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=rd(this._storage);case 1:if((o=a()).done){e.next=8;break}if((s=o.value).mediaKeySession!==t){e.next=6;break}return i=s,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==i){e.next=11;break}return T.error("DRM-LSS: generateRequest error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Hl(t,n,r));case 11:if(i.isGeneratingRequest=!0,"none"===i.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,Hl(t,n,r);case 17:e.next=26;break;case 19:if(e.prev=19,e.t0=e.catch(14),void 0!==i){e.next=23;break}throw e.t0;case 23:throw i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start(),e.t0;case 26:if(void 0!==i){e.next=28;break}return e.abrupt("return",void 0);case 28:i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start();case 30:case"end":return e.stop()}}),e,this,[[14,19]])})));return function(t,n,r){return e.apply(this,arguments)}}(),n.loadPersistentSession=function(){var e=d(p().mark((function e(t,n){var r,i,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=rd(this._storage);case 1:if((a=i()).done){e.next=8;break}if((o=a.value).mediaKeySession!==t){e.next=6;break}return r=o,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==r){e.next=11;break}return T.error("DRM-LSS: loadPersistentSession error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Yl(t,n));case 11:if(r.isLoadingPersistentSession=!0,"none"===r.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,Yl(t,n);case 17:s=e.sent,e.next=27;break;case 20:if(e.prev=20,e.t0=e.catch(14),void 0!==r){e.next=24;break}throw e.t0;case 24:throw r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.t0;case 27:if(void 0!==r){e.next=29;break}return e.abrupt("return",s);case 29:return r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.abrupt("return",s);case 32:case"end":return e.stop()}}),e,this,[[14,20]])})));return function(t,n){return e.apply(this,arguments)}}(),n.closeSession=function(){var e=d(p().mark((function e(t){var n,r,i,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=rd(this._storage);case 1:if((i=r()).done){e.next=8;break}if((a=i.value).mediaKeySession!==t){e.next=6;break}return n=a,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==n){e.next=11;break}return T.warn("DRM-LSS: No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Promise.resolve(!1));case 11:return e.abrupt("return",this._closeEntry(n));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getLength=function(){return this._storage.length},n.getAll=function(){return this._storage},n.closeAllSessions=function(){var e=d(p().mark((function e(){var t,n,r=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._storage,T.debug("DRM-LSS: Closing all current MediaKeySessions",t.length),this._storage=[],n=t.map((function(e){return r._closeEntry(e)})),e.next=6,Promise.all(n);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.removeSessionWithoutClosingIt=function(e){$(e.sessionId);for(var t=this._storage.length-1;t>=0;t--){if(this._storage[t].mediaKeySession===e)return T.debug("DRM-LSS: Removing session without closing it",e.sessionId),this._storage.splice(t,1),!0}return!1},n.getIndex=function(e){for(var t=0;t<this._storage.length;t++){if(this._storage[t].keySessionRecord===e)return t}return-1},n._closeEntry=function(){var e=d(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.mediaKeySession,e.abrupt("return",new Promise((function(e,r){function i(){void 0!==t&&(t.closingStatus={type:"pending"}),od(n).then((function(){void 0!==t&&(t.closingStatus={type:"done"}),e(!0)})).catch((function(e){void 0!==t&&(t.closingStatus={type:"failed"}),r(e)}))}void 0!==t&&(t.isLoadingPersistentSession||t.isGeneratingRequest)?t.closingStatus={type:"awaiting",start:i}:i()})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e}();function od(e){return sd.apply(this,arguments)}function sd(){return(sd=d(p().mark((function e(t){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.debug("DRM: Trying to close a MediaKeySession",t.sessionId),e.prev=1,e.next=4,$l(t);case 4:return T.debug("DRM: Succeeded to close MediaKeySession"),e.abrupt("return");case 8:return e.prev=8,e.t0=e.catch(1),T.error("DRM: Could not close MediaKeySession: "+(e.t0 instanceof Error?e.t0.toString():"Unknown error")),e.abrupt("return");case 12:case"end":return e.stop()}}),e,null,[[1,8]])})))).apply(this,arguments)}function ud(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e[n],t&=t;return t}var ld=function(){function e(e){this.initData=e}return e.prototype.toJSON=function(){return Ka(this.initData)},e.decode=function(e){return Wa(e)},e}();function dd(e,t){var n,r;return null!==(r=null!==(n=cd(e,t))&&void 0!==n?n:cd(t,e))&&void 0!==r&&r}function cd(e,t){if(0===e.length)return!1;if(t.length<e.length)return null;for(var n=e[0],r=0,i=0;i<t.length;i++){var a=t[i];if(a.systemId===n.systemId){if(a.hash!==n.hash)return!1;if(!st(n.data instanceof Uint8Array?n.data:"string"==typeof n.data?ld.decode(n.data):n.data.initData,a.data instanceof Uint8Array?a.data:"string"==typeof a.data?ld.decode(a.data):a.data.initData))return!1;if(t.length-i<e.length)return null;for(r=1;r<e.length;r++){var o=e[r];for(i+=1;i<t.length;i++){var s=t[i];if(o.systemId===s.systemId){if(o.hash!==s.hash)return!1;if(!st(o.data instanceof Uint8Array?o.data:"string"==typeof o.data?ld.decode(o.data):o.data.initData,s.data instanceof Uint8Array?s.data:"string"==typeof s.data?ld.decode(s.data):s.data.initData))return!1;break}}if(r===t.length)return null}return!0}}return null}function fd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function vd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function pd(e){!function(e,n,r){for(var i in void 0===r&&(r="object"),$(t(e)),n)n.hasOwnProperty(i)&&$((e[i],n[i]),n[i])}(e,{save:"function",load:"function"},"persistentLicenseConfig")}var hd=function(){function e(e){pd(e),this._entries=[],this._storage=e;try{var t=this._storage.load();Array.isArray(t)||(t=[]),this._entries=t}catch(e){T.warn("DRM-PSS: Could not get entries from license storage",e instanceof Error?e:""),this.dispose()}}var n=e.prototype;return n.getLength=function(){return this._entries.length},n.getAll=function(){return this._entries},n.get=function(e){var t=this._getIndex(e);return-1===t?null:this._entries[t]},n.getAndReuse=function(e){var t=this._getIndex(e);if(-1===t)return null;var n=this._entries.splice(t,1)[0];return this._entries.push(n),n},n.add=function(e,n,r){var i;if(!t(r)&&et(r.sessionId)){var a=r.sessionId,o=this._getIndex(e);if(o>=0){var s=void 0===n?3:4,u=this._entries[o];if((null!==(i=u.version)&&void 0!==i?i:-1)>=s&&a===u.sessionId)return;T.info("DRM-PSS: Updating session info.",a),this._entries.splice(o,1)}else T.info("DRM-PSS: Add new session",a);var l=e.values.getFormattedValues().map((function(e){var t=e.systemId,n=e.data;return{systemId:t,hash:e.hash,data:new ld(n)}}));void 0===n?this._entries.push({version:3,sessionId:a,values:l,initDataType:e.type}):this._entries.push({version:4,sessionId:a,keyIds:n.map((function(e){return new ld(e)})),values:l,initDataType:e.type}),this._save()}else T.warn("DRM-PSS: Invalid Persisten Session given.")},n.delete=function(e){for(var t=-1,n=0;n<this._entries.length;n++){if(this._entries[n].sessionId===e){t=n;break}}if(-1!==t){var r=this._entries[t];T.warn("DRM-PSS: Delete session from store",r.sessionId),this._entries.splice(t,1),this._save()}else T.warn("DRM-PSS: initData to delete not found.")},n.deleteOldSessions=function(e){T.info("DRM-PSS: Deleting last "+e+" sessions."),e<=0||(e<=this._entries.length?this._entries.splice(0,e):(T.warn("DRM-PSS: Asked to remove more information that it contains",e,this._entries.length),this._entries=[]),this._save())},n.dispose=function(){this._entries=[],this._save()},n._getIndex=function(e){var t=this,n=null;function r(){if(null===n){var t=e.values.constructRequestData();n={initData:t,initDataHash:ud(t)}}return n}for(var i,a=function(){var n=t._entries[o];if(n.initDataType===e.type)switch(n.version){case 4:if(void 0!==e.keyIds){if(e.keyIds.every((function(e){for(var t,r=Ka(e),i=fd(n.keyIds);!(t=i()).done;){var a=t.value;if("string"==typeof a){if(r===a)return!0}else if(st(a.initData,e))return!0}return!1})))return{v:o}}else if(dd(e.values.getFormattedValues(),n.values))return{v:o};break;case 3:if(dd(e.values.getFormattedValues(),n.values))return{v:o};break;case 2:var i=r(),a=i.initData,s=i.initDataHash;if(n.initDataHash===s)try{if(st("string"==typeof n.initData?ld.decode(n.initData):n.initData.initData,a))return{v:o}}catch(e){T.warn("DRM-PSS: Could not decode initialization data.",e instanceof Error?e:"")}break;case 1:var u=r(),l=u.initData,d=u.initDataHash;if(n.initDataHash===d){if(void 0===n.initData.length)return{v:o};if(st(n.initData,l))return{v:o}}break;default:var c=r().initDataHash;if(n.initData===c)return{v:o}}},o=0;o<this._entries.length;o++)if(i=a())return i.v;return-1},n._save=function(){try{this._storage.save(this._entries)}catch(t){var e=t instanceof Error?t:void 0;T.warn("DRM-PSS: Could not save MediaKeySession information",e)}},e}();var md=new WeakMap,gd={prepare:function(e){md.set(e,null)},set:function(e,t){var n=t instanceof Uint8Array?t:new Uint8Array(t instanceof ArrayBuffer?t:t.buffer),r=ud(n);md.set(e,{hash:r,serverCertificate:n})},hasOne:function(e){var t=md.get(e);return void 0!==t&&(null!==t||void 0)},has:function(e,t){var n=md.get(e);if(null==n)return!1;var r=n.hash,i=n.serverCertificate,a=t instanceof Uint8Array?t:new Uint8Array(t instanceof ArrayBuffer?t:t.buffer);if(ud(a)!==r||i.length!==a.length)return!1;for(var o=0;o<i.length;o++)if(i[o]!==a[o])return!1;return!0}};function yd(e,t,n){return _d.apply(this,arguments)}function _d(){return(_d=d(p().mark((function e(n,r,i){var a,o,s,u,l,d,c,f,v,h;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,jl(n,r,i);case 2:if(a=e.sent,null===i.cancellationError){e.next=5;break}throw i.cancellationError;case 5:if(o=a.value,s=o.options,u=o.mediaKeySystemAccess,l=Tr.getState(n),p=void 0,p=s.persistentLicenseConfig,d=t(p)?null:(T.debug("DRM: Set the given license storage"),new hd(p)),bi||Si||null===l||"reuse-media-key-system-access"!==a.type){e.next=12;break}if(c=l.mediaKeys,f=l.loadedSessionsStore,!1!==gd.hasOne(c)&&(t(s.serverCertificate)||!gd.has(c,s.serverCertificate))){e.next=12;break}return e.abrupt("return",{mediaKeys:c,mediaKeySystemAccess:u,stores:{loadedSessionsStore:f,persistentSessionsStore:d},options:s});case 12:return e.next=14,bd(u);case 14:return v=e.sent,T.info("DRM: MediaKeys created with success"),h=new ad(v),e.abrupt("return",{mediaKeys:v,mediaKeySystemAccess:u,stores:{loadedSessionsStore:h,persistentSessionsStore:d},options:s});case 18:case"end":return e.stop()}var p}),e)})))).apply(this,arguments)}function bd(e){return Sd.apply(this,arguments)}function Sd(){return(Sd=d(p().mark((function e(t){var n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.info("DRM: Calling createMediaKeys on the MediaKeySystemAccess"),e.prev=1,e.next=4,t.createMediaKeys();case 4:return n=e.sent,e.abrupt("return",n);case 8:throw e.prev=8,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.message:"Unknown error when creating MediaKeys.",new Ce("CREATE_MEDIA_KEYS_ERROR",r);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})))).apply(this,arguments)}function Ed(){return(Ed=d(p().mark((function e(t,n,r){var i,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,yd(t,n,r);case 2:if(i=e.sent,a=i.mediaKeys,!(null!==t.mediaKeys&&void 0!==t.mediaKeys&&a!==t.mediaKeys)){e.next=13;break}if(T.debug("DRM: Disabling old MediaKeys"),!bi){e.next=12;break}return e.next=10,Dl(t);case 10:e.next=13;break;case 12:Dl(t).catch(S);case 13:return e.abrupt("return",i);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Td(e,t,n){var r=Dt(e*Math.pow(2,t-1));return Math.min(r,n)}var kd=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(j(r),t.prototype),r.reason=n,r}return f(t,e),t}(Y(Error)),wd={EXPIRED:"expired",INTERNAL_ERROR:"internal-error",OUTPUT_RESTRICTED:"output-restricted"};function Ad(e,t,n){var r,i=t.onKeyInternalError,a=t.onKeyOutputRestricted,o=t.onKeyExpiration,s=[],u=[],l=[];return e.keyStatuses.forEach((function(e,t){var r="string"==typeof e?[e,t]:[t,e],d=r[0],c=function(e,t){return-1!==e.indexOf("playready")&&(pi||fi)?Ma(t):t}(n,new Uint8Array(r[1])),f={keyId:c.buffer,keyStatus:d};switch(T.hasLevel("DEBUG")&&T.debug("DRM: key status update ("+Ca(c)+"): "+d),d){case wd.EXPIRED:var v=new Ce("KEY_STATUS_CHANGE_ERROR","A decryption key expired ("+Ca(c)+")",{keyStatuses:[f].concat(l)});if("error"===o||void 0===o)throw v;switch(o){case"close-session":throw new kd(v);case"fallback":s.push(c);break;default:"continue"===o||void 0===o?u.push(c):X()}l.push(f);break;case wd.INTERNAL_ERROR:var p=new Ce("KEY_STATUS_CHANGE_ERROR",'A "'+d+'" status has been encountered ('+Ca(c)+")",{keyStatuses:[f].concat(l)});switch(i){case void 0:case"error":throw p;case"close-session":throw new kd(p);case"fallback":s.push(c);break;case"continue":u.push(c);break;default:if(void 0===i)throw p;X()}l.push(f);break;case wd.OUTPUT_RESTRICTED:var h=new Ce("KEY_STATUS_CHANGE_ERROR",'A "'+d+'" status has been encountered ('+Ca(c)+")",{keyStatuses:[f].concat(l)});switch(a){case void 0:case"error":throw h;case"fallback":s.push(c);break;case"continue":u.push(c);break;default:if(void 0===a)throw h;X()}l.push(f);break;default:u.push(c)}})),l.length>0&&(r=new Ce("KEY_STATUS_CHANGE_ERROR","One or several problematic key statuses have been encountered",{keyStatuses:l})),{warning:r,blacklistedKeyIds:s,whitelistedKeyIds:u}}function Id(e,n,r,i,a){T.info("DRM: Binding session events",e.sessionId);var o=n.getLicenseConfig,s=void 0===o?{}:o,u=new Z;return u.linkToSignal(a),t(e.closed)||e.closed.then((function(){return u.cancel()})).catch((function(e){a.isCancelled()||(u.cancel(),i.onError(e))})),jr(e,(function(e){u.cancel(),i.onError(new Ce("KEY_ERROR",e.type))}),u.signal),Hr(e,(function(){try{l()}catch(e){if(a.isCancelled()||u.isUsed()&&e instanceof J)return;u.cancel(),i.onError(e)}}),u.signal),Wr(e,(function(r){var a,o=r,l=new Uint8Array(o.message),c=et(o.messageType)?o.messageType:"license-request";T.info("DRM: Received message event, type "+c,e.sessionId),function(e,n,r){var i=n.baseDelay,a=n.maxDelay,o=n.totalRetry,s=n.shouldRetry,u=n.onRetry,l=0;return c();function c(){return f.apply(this,arguments)}function f(){return(f=d(p().mark((function n(){var d,f,v;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===r.cancellationError){n.next=2;break}throw r.cancellationError;case 2:return n.prev=2,n.next=5,e();case 5:return d=n.sent,n.abrupt("return",d);case 9:if(n.prev=9,n.t0=n.catch(2),null===r.cancellationError){n.next=13;break}throw r.cancellationError;case 13:if(!(!t(s)&&!s(n.t0)||l++>=o)){n.next=15;break}throw n.t0;case 15:return"function"==typeof u&&u(n.t0,l),f=Td(i,l,a),n.next=19,Wn(f);case 19:return v=c(),n.abrupt("return",v);case 21:case"end":return n.stop()}}),n,null,[[2,9]])})))).apply(this,arguments)}}((function(){return function(e,r){var i;return new Promise((function(a,o){try{T.debug("DRM: Calling `getLicense`",r);var u=n.getLicense(e,r),l=t(s.timeout)?1e4:s.timeout;l>=0&&(i=setTimeout((function(){o(new Md('"getLicense" timeout exceeded ('+l+" ms)"))}),l)),Promise.resolve(u).then(d,c)}catch(e){c(e)}function d(e){void 0!==i&&clearTimeout(i),a(e)}function c(e){void 0!==i&&clearTimeout(i),o(e)}}))}(l,c)}),{totalRetry:null!=(a=s.retry)?a:2,baseDelay:200,maxDelay:3e3,shouldRetry:function(e){return e instanceof Md||t(e)||!0!==e.noRetry},onRetry:function(e){return i.onWarning(Rd(e))}},u.signal).then((function(n){if(u.isUsed())return Promise.resolve();if(t(n))T.info("DRM: No license given, skipping session.update");else try{return function(e,t){return xd.apply(this,arguments)}(e,n)}catch(e){u.cancel(),i.onError(e)}})).catch((function(e){if(!u.isUsed()){u.cancel();var n=Rd(e);if(!t(e))if(!0===e.fallbackOnLastTry)return T.warn("DRM: Last `getLicense` attempt failed. Blacklisting the current session."),void i.onError(new Cd(n));i.onError(n)}}))}),u.signal),void l();function l(){if(T.info("DRM: keystatuseschange event received",e.sessionId),!u.isUsed()&&0!==e.keyStatuses.size){var t=Ad(e,n,r),a=t.warning,o=t.blacklistedKeyIds,s=t.whitelistedKeyIds;void 0!==a&&(i.onWarning(a),u.isUsed())||i.onKeyUpdate({whitelistedKeyIds:s,blacklistedKeyIds:o})}}}function Rd(e){if(e instanceof Md)return new Ce("KEY_LOAD_TIMEOUT","The license server took too much time to respond.");var n=new Ce("KEY_LOAD_ERROR","An error occured when calling `getLicense`.");return!t(e)&&et(e.message)&&(n.message=e.message),n}function xd(){return(xd=d(p().mark((function e(t,n){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.info("DRM: Updating MediaKeySession with message"),e.prev=1,e.next=4,t.update(n);case 4:e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.toString():"`session.update` failed",new Ce("KEY_UPDATE_ERROR",r);case 10:T.info("DRM: MediaKeySession update succeeded.");case 11:case"end":return e.stop()}}),e,null,[[1,6]])})))).apply(this,arguments)}var Cd=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(j(r),t.prototype),r.sessionError=n,r}return f(t,e),t}(Y(Error)),Md=function(e){function t(t){var n;return n=e.call(this)||this,Object.setPrototypeOf(j(n),Cd.prototype),n.message=t,n}return f(t,e),t}(Y(Error));function Pd(e,t){return Dd.apply(this,arguments)}function Dd(){return(Dd=d(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.setServerCertificate(n);case 3:return r=e.sent,e.abrupt("return",r);case 7:throw e.prev=7,e.t0=e.catch(0),T.warn("DRM: mediaKeys.setServerCertificate returned an error",e.t0 instanceof Error?e.t0:""),i=e.t0 instanceof Error?e.t0.toString():"`setServerCertificate` error",new Ce("LICENSE_SERVER_CERTIFICATE_ERROR",i);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function Od(e,t){return Nd.apply(this,arguments)}function Nd(){return(Nd=d(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!0!==gd.hasOne(t)){e.next=3;break}return T.info("DRM: The MediaKeys already has a server certificate, skipping..."),e.abrupt("return",{type:"already-has-one"});case 3:if("function"==typeof t.setServerCertificate){e.next=6;break}return T.warn("DRM: Could not set the server certificate. mediaKeys.setServerCertificate is not a function"),e.abrupt("return",{type:"method-not-implemented"});case 6:return T.info("DRM: Setting server certificate on the MediaKeys"),gd.prepare(t),e.prev=8,e.next=11,Pd(t,n);case 11:return r=e.sent,gd.set(t,n),e.abrupt("return",{type:"success",value:r});case 16:return e.prev=16,e.t0=e.catch(8),i=Oe(e.t0)?e.t0:new Ce("LICENSE_SERVER_CERTIFICATE_ERROR","Unknown error when setting the server certificate."),e.abrupt("return",{type:"error",value:i});case 20:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}function Ld(e,t){if(!(isNaN(t)||t<0||t>=e.getLength())){var n=e.getLength(),r=n-t;T.info("DRM: Too many stored persistent sessions, removing some.",n,r),e.deleteOldSessions(r)}}var Ud=function(){function e(e){this._innerValues=e,this._lazyFormattedValues=null}var t=e.prototype;return t.constructRequestData=function(){return Xr.apply(void 0,this._innerValues.map((function(e){return e.data})))},t.isCompatibleWith=function(t){var n=t instanceof e?t.getFormattedValues():t;return dd(this.getFormattedValues(),n)},t.getFormattedValues=function(){return null===this._lazyFormattedValues&&(this._lazyFormattedValues=this._innerValues.slice().sort((function(e,t){return e.systemId===t.systemId?0:void 0===e.systemId?1:void 0===t.systemId||e.systemId<t.systemId?-1:1})).map((function(e){var t=e.systemId,n=e.data;return{systemId:t,data:n,hash:ud(n)}}))),this._lazyFormattedValues},e}();function Fd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Bd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Bd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Bd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var zd=function(e){function n(n,r){var i;i=e.call(this)||this,T.debug("DRM: Starting ContentDecryptor logic.");var a=new Z;return i._currentSessions=[],i._canceller=a,i._initDataQueue=[],i._stateData={state:Pi.Initializing,isMediaKeysAttached:0,isInitDataQueueLocked:!0,data:null},i.error=null,xl.onEncrypted(n,(function(e){T.debug("DRM: Encrypted event received from media element.");var t=Pl(e);null!==t&&i.onInitializationData(t)}),a.signal),function(e,t,n){return Ed.apply(this,arguments)}(n,r,a.signal).then((function(e){var r,a,o=e.options,s=e.mediaKeySystemAccess;(t(o.persistentLicenseConfig)||!0===o.persistentLicenseConfig.disableRetroCompatibility)&&(r=ar(a=s.keySystem,"com.microsoft.playready")||"com.chromecast.playready"===a||"com.youtube.playready"===a?"9a04f07998404286ab92e65be0885f95":"com.widevine.alpha"===a?"edef8ba979d64acea3c827dcd51d21ed":ar(a,"com.apple.fps")?"94ce86fb07ff4f43adb893d2fa968ca2":ar(a,"com.nagra.")?"adb41c242dbf4a6d958b4457c0d27b95":void 0),i.systemId=r,i._stateData.state===Pi.Initializing&&(i._stateData={state:Pi.WaitingForAttachment,isInitDataQueueLocked:!0,isMediaKeysAttached:0,data:{mediaKeysInfo:e,mediaElement:n}},i.trigger("stateChange",i._stateData.state))})).catch((function(e){i._onFatalError(e)})),i}f(n,e),n.hasEmeApis=function(){return!t(xl.requestMediaKeySystemAccess)};var r=n.prototype;return r.getState=function(){return this._stateData.state},r.attach=function(){var e=this;if(this._stateData.state!==Pi.WaitingForAttachment)throw new Error("`attach` should only be called when in the WaitingForAttachment state");if(0===this._stateData.isMediaKeysAttached){var n=this._stateData.data,r=n.mediaElement,i=n.mediaKeysInfo,a=i.options,o=i.mediaKeys,s=i.mediaKeySystemAccess,u=i.stores;if(!(!0===a.disableMediaKeysAttachmentLock)||(this._stateData={state:Pi.ReadyForContent,isInitDataQueueLocked:!0,isMediaKeysAttached:1,data:{mediaKeysInfo:i,mediaElement:r}},this.trigger("stateChange",this._stateData.state),!this._isStopped())){this._stateData.isMediaKeysAttached=1;var l={emeImplementation:xl,loadedSessionsStore:u.loadedSessionsStore,mediaKeySystemAccess:s,mediaKeys:o,keySystemOptions:a};T.debug("DRM: Attaching current MediaKeys"),function(e,t,n){return Ol.apply(this,arguments)}(r,l,this._canceller.signal).then(d(p().mark((function n(){var r,s,u;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e._stateData.isMediaKeysAttached=2,t(r=a.serverCertificate)){n.next=7;break}return n.next=5,Od(o,r);case 5:"error"===(s=n.sent).type&&e.trigger("warning",s.value);case 7:if(!e._isStopped()){n.next=9;break}return n.abrupt("return");case 9:u=e._stateData.state,e._stateData={state:Pi.ReadyForContent,isMediaKeysAttached:2,isInitDataQueueLocked:!1,data:{mediaKeysData:i}},u!==Pi.ReadyForContent&&e.trigger("stateChange",Pi.ReadyForContent),e._isStopped()||e._processCurrentInitDataQueue();case 13:case"end":return n.stop()}}),n)})))).catch((function(t){e._onFatalError(t)}))}}else T.warn("DRM: ContentDecryptor's `attach` method called more than once.")},r.dispose=function(){this.removeEventListener(),this._stateData={state:Pi.Disposed,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("stateChange",this._stateData.state)},r.onInitializationData=function(e){var t=this;if(!1===this._stateData.isInitDataQueueLocked){var n=this._stateData.data.mediaKeysData,r=Object.assign(Object.assign({},e),{values:new Ud(e.values)});this._processInitializationData(r,n).catch((function(e){t._onFatalError(e)}))}else{if(this._isStopped())throw new Error("ContentDecryptor either disposed or stopped.");this._initDataQueue.push(e)}},r._processInitializationData=function(){var e=d(p().mark((function e(n,r){var i,a,o,s,u,l,d,c,f,v,h,m,g,y,_,S,E,k,w,A,I,R,x,C,M,P,D,O,N,L,U,F,B,z=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.mediaKeySystemAccess,a=r.stores,o=r.options,!this._tryToUseAlreadyCreatedSession(n,r)&&!this._isStopped()){e.next=3;break}return e.abrupt("return");case 3:if("content"!==o.singleLicensePer){e.next=15;break}if(void 0===(s=ae(this._currentSessions,(function(e){return"created-session"===e.source})))){e.next=13;break}if(void 0!==(u=n.keyIds)){e.next=10;break}return void 0===n.content?T.warn("DRM: Unable to fallback from a non-decipherable quality."):this.trigger("blackListProtectionData",n),e.abrupt("return");case 10:return s.record.associateKeyIds(u),void 0!==n.content&&(T.hasLevel("DEBUG")&&(l=u.reduce((function(e,t){return e+", "+Ca(t)}),""),T.debug("DRM: Blacklisting new key ids",l)),this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:u,delistedKeyIds:[]})),e.abrupt("return");case 13:e.next=42;break;case 15:if("periods"!==o.singleLicensePer||void 0===n.content){e.next=42;break}d=n.content.period,c=this._currentSessions.filter((function(e){return"created-session"===e.source})),Gd(f=new Set,d),v=Fd(c);case 21:if((h=v()).done){e.next=42;break}m=h.value,g=Array.from(f),y=0,_=g;case 25:if(!(y<_.length)){e.next=40;break}if(S=_[y],!m.record.isAssociatedWithKeyId(S)){e.next=37;break}m.record.associateKeyIds(f.values()),E=p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=w.value,m.keyStatuses.whitelisted.some((function(e){return st(e,t)}))||m.keyStatuses.blacklisted.some((function(e){return st(e,t)}))||m.keyStatuses.blacklisted.push(t);case 2:case"end":return e.stop()}}),e)})),k=Fd(g);case 31:if((w=k()).done){e.next=35;break}return e.delegateYield(E(),"t0",33);case 33:e.next=31;break;case 35:return this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:m.keyStatuses.whitelisted,blacklistedKeyIds:m.keyStatuses.blacklisted,delistedKeyIds:[]}),e.abrupt("return");case 37:y++,e.next=25;break;case 40:e.next=21;break;case 42:return this._lockInitDataQueue(),t(o.persistentLicenseConfig)?A="temporary":Vd(i)?A="persistent-license":(T.warn('DRM: Cannot create "persistent-license" session: not supported'),A="temporary"),I=b.getCurrent(),R=I.EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS,x=I.EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION,C="number"==typeof o.maxSessionCacheSize?o.maxSessionCacheSize:R,e.next=48,Vl(n,a,A,C,this._canceller.signal);case 48:if(M=e.sent,!this._isStopped()){e.next=51;break}return e.abrupt("return");case 51:if(P={record:M.value.keySessionRecord,source:M.type,keyStatuses:{whitelisted:[],blacklisted:[]},blacklistedSessionError:null},this._currentSessions.push(P),D=M.value,O=D.mediaKeySession,N=D.sessionType,L=!1,Id(O,o,i.keySystem,{onKeyUpdate:function(e){var t=Kd(n,P.record,o.singleLicensePer,"created-session"===P.source,e.whitelistedKeyIds,e.blacklistedKeyIds);if(P.record.associateKeyIds(t.whitelisted),P.record.associateKeyIds(t.blacklisted),P.keyStatuses={whitelisted:t.whitelisted,blacklisted:t.blacklisted},0!==P.record.getAssociatedKeyIds().length&&"persistent-license"===N&&null!==a.persistentSessionsStore&&!L){var r=a.persistentSessionsStore;Ld(r,x-1),r.add(n,P.record.getAssociatedKeyIds(),O),L=!0}void 0!==n.content&&z.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:t.whitelisted,blacklistedKeyIds:t.blacklisted,delistedKeyIds:[]}),z._unlockInitDataQueue()},onWarning:function(e){z.trigger("warning",e)},onError:function(e){var t;if(e instanceof kd){T.warn("DRM: A session's closing condition has been triggered"),z._lockInitDataQueue();var r=z._currentSessions.indexOf(P);return r>=0&&z._currentSessions.splice(r),void 0!==n.content&&z.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:[],delistedKeyIds:P.record.getAssociatedKeyIds()}),null===(t=a.persistentSessionsStore)||void 0===t||t.delete(O.sessionId),a.loadedSessionsStore.closeSession(O).catch((function(e){var t=e instanceof Error?e:"unknown error";T.warn("DRM: failed to close expired session",t)})).then((function(){return z._unlockInitDataQueue()})).catch((function(e){return z._onFatalError(e)})),void(z._isStopped()||z.trigger("warning",e.reason))}e instanceof Cd?(P.blacklistedSessionError=e,void 0!==n.content&&(T.info("DRM: blacklisting Representations based on protection data."),z.trigger("blackListProtectionData",n)),z._unlockInitDataQueue()):z._onFatalError(e)}},this._canceller.signal),void 0!==o.singleLicensePer&&"init-data"!==o.singleLicensePer||this._unlockInitDataQueue(),"created-session"!==M.type){e.next=72;break}return U=n.values.constructRequestData(),e.prev=59,e.next=62,a.loadedSessionsStore.generateLicenseRequest(O,n.type,U);case 62:e.next=72;break;case 64:if(e.prev=64,e.t1=e.catch(59),null!==(F=a.loadedSessionsStore.getEntryForSession(O))&&"none"===F.closingStatus.type){e.next=71;break}return(B=this._currentSessions.indexOf(P))>=0&&this._currentSessions.splice(B,1),e.abrupt("return",Promise.resolve());case 71:throw new Ce("KEY_GENERATE_REQUEST_ERROR",e.t1 instanceof Error?e.t1.toString():"Unknown error");case 72:return e.abrupt("return",Promise.resolve());case 73:case"end":return e.stop()}}),e,this,[[59,64]])})));return function(t,n){return e.apply(this,arguments)}}(),r._tryToUseAlreadyCreatedSession=function(e,n){var r=n.stores,i=n.options,a=ae(this._currentSessions,(function(t){return t.record.isCompatibleWith(e)}));if(void 0===a)return!1;if(!t(a.blacklistedSessionError))return void 0===e.type||void 0===e.content?(T.error("DRM: This initialization data has already been blacklisted but the current content is not known."),!0):(T.info("DRM: This initialization data has already been blacklisted. Blacklisting the related content."),this.trigger("blackListProtectionData",e),!0);if(void 0!==e.keyIds){var o;if(void 0===i.singleLicensePer||"init-data"===i.singleLicensePer){var s=a.keyStatuses.blacklisted;o=function(e,t){for(var n,r,i=function(){var e=r.value;if(t.some((function(t){return st(t,e)})))return{v:!0}},a=Xl(e);!(r=a()).done;)if(n=i())return n.v;return!1}(e.keyIds,s)}else{var u=a.keyStatuses.whitelisted;o=!Jl(e.keyIds,u)}if(o)return void 0===e.content?(T.error("DRM: Cannot forbid key id, the content is unknown."),!0):(T.info("DRM: Current initialization data is linked to blacklisted keys. Marking Representations as not decipherable"),this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:e.keyIds,delistedKeyIds:[]}),!0)}if(null!==r.loadedSessionsStore.reuse(e))return T.debug("DRM: Init data already processed. Skipping it."),!0;var l=this._currentSessions.indexOf(a);return-1===l?T.error("DRM: Unable to remove processed init data: not found."):(T.debug("DRM: A session from a processed init data is not available anymore. Re-processing it."),this._currentSessions.splice(l,1)),!1},r._onFatalError=function(e){if(!this._canceller.isUsed()){var t=e instanceof Error?e:new De("NONE","Unknown decryption error");this.error=t,this._initDataQueue.length=0,this._stateData={state:Pi.Error,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("error",t),this._stateData.state===Pi.Error&&this.trigger("stateChange",this._stateData.state)}},r._isStopped=function(){return this._stateData.state===Pi.Disposed||this._stateData.state===Pi.Error},r._processCurrentInitDataQueue=function(){for(;!1===this._stateData.isInitDataQueueLocked;){var e=this._initDataQueue.shift();if(void 0===e)return;this.onInitializationData(e)}},r._lockInitDataQueue=function(){!1===this._stateData.isInitDataQueueLocked&&(this._stateData.isInitDataQueueLocked=!0)},r._unlockInitDataQueue=function(){2===this._stateData.isMediaKeysAttached?(this._stateData.isInitDataQueueLocked=!1,this._processCurrentInitDataQueue()):T.error("DRM: Trying to unlock in the wrong state")},n}(i);function Vd(e){var t=e.getConfiguration().sessionTypes;return void 0!==t&&Ue(t,"persistent-license")}function Kd(e,t,n,r,i,a){for(var o,s,u=[].concat(i,a),l=function(){var e=s.value;u.some((function(t){return st(t,e)}))||(T.hasLevel("DEBUG")&&T.debug("DRM: KeySessionRecord's key missing in the license, blacklisting it",Ca(e)),u.push(e))},d=Fd(t.getAssociatedKeyIds());!(s=d()).done;)l();if(void 0!==n&&"init-data"!==n){var c=e.keyIds,f=e.content;if(void 0!==c){var v=c.filter((function(e){return!u.some((function(t){return st(t,e)}))}));v.length>0&&(T.hasLevel("DEBUG")&&T.debug("DRM: init data keys missing in the license, blacklisting them",v.map((function(e){return Ca(e)})).join(", ")),u.push.apply(u,v))}if(r&&void 0!==f)if("content"===n){for(var p,h=new Set,m=Fd(f.manifest.periods);!(p=m()).done;){Gd(h,p.value)}Wd(h,u)}else if("periods"===n)for(var g,y=Fd(f.manifest.periods);!(g=y()).done;){var _=g.value,b=new Set;if(Gd(b,_),(null===(o=e.content)||void 0===o?void 0:o.period.id)===_.id)Wd(b,u);else for(var S=Array.from(b),E=function(){var e=w[k];if(u.some((function(t){return st(t,e)})))return Wd(b,u),1},k=0,w=S;k<w.length&&!E();k++);}}return{whitelisted:i,blacklisted:u.slice(i.length)}}function Wd(e,t){for(var n=Array.from(e.values()),r=function(){var e=a[i];t.some((function(t){return st(t,e)}))||t.push(e)},i=0,a=n;i<a.length;i++)r()}function Gd(e,n){for(var r,i=Fd(me(n.adaptations).reduce((function(e,n){return t(n)?e:e.concat(n)}),[]));!(r=i()).done;)for(var a,o=Fd(r.value.representations);!(a=o()).done;){var s=a.value;if(void 0!==s.contentProtections&&void 0!==s.contentProtections.keyIds)for(var u,l=Fd(s.contentProtections.keyIds);!(u=l()).done;){var d=u.value;e.add(d.keyId)}}}var jd=zd;function Hd(e){e.decrypt=jd}function qd(e,t){if(hi&&function(e,t){var n=e.activeCues;if(null===n)return!1;for(var r=0;r<n.length;r++)if(n[r]===t)return!0;return!1}(e,t)){var n=e.mode;e.mode="hidden";try{e.removeCue(t)}catch(e){T.warn("Compat: Could not remove cue from text track.")}e.mode=n}else try{e.removeCue(t)}catch(e){T.warn("Compat: Could not remove cue from text track.")}}var Yd=function(){function e(){this._ranges=[],this.length=0}var t=e.prototype;return t.insert=function(e,t){L(this._ranges,{start:e,end:t}),this.length=this._ranges.length},t.remove=function(e,t){var n=[];e>0&&n.push({start:0,end:e}),t<1/0&&n.push({start:t,end:1/0}),this._ranges=function(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=U(i,t);if(a.length>0)for(var o=0;o<a.length;o++){var s=a[o];n.push({start:Math.max(i.start,s.start),end:Math.min(i.end,s.end)})}}return n}(this._ranges,n),this.length=this._ranges.length},t.start=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].start},t.end=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].end},e}();var Qd=function(){function e(e){T.debug("NTD: Creating NativeTextDisplayer");var t=function(e){var t,n,r,i="subtitles";if(pi){var a=e.textTracks.length;(n=a>0?e.textTracks[a-1]:e.addTextTrack(i)).mode=null!==(t=n.SHOWING)&&void 0!==t?t:"showing"}else r=document.createElement("track"),e.appendChild(r),n=r.track,r.kind=i,n.mode="showing";return{track:n,trackElement:r}}(e),n=t.track,r=t.trackElement;this._buffered=new Yd,this._videoElement=e,this._track=n,this._trackElement=r}var t=e.prototype;return t.pushTextData=function(e){var t,n;if(T.debug("NTD: Appending new native text tracks"),null===e.chunk)return M(this._buffered);var r,i,a=e.timestampOffset,o=e.appendWindow,s=e.chunk,u=s.start,l=s.end,d=s.data,c=s.type,f=s.language,v=null!==(t=o[0])&&void 0!==t?t:0,p=null!==(n=o[1])&&void 0!==n?n:1/0,h=function(e,t,n,r){T.debug("NTSB: Finding parser for native text tracks:",e);var i=ot.nativeTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");T.debug("NTSB: Parser found, parsing...");var a=i(t,n,r);return T.debug("NTSB: Parsed successfully!",a.length),a}(c,d,a,f);if(0!==v&&p!==1/0){for(var m=0;m<h.length&&h[m].endTime<=v;)m++;for(h.splice(0,m),m=0;m<h.length&&h[m].startTime<v;)h[m].startTime=v,m++;for(m=h.length-1;m>=0&&h[m].startTime>=p;)m--;for(h.splice(m,h.length),m=h.length-1;m>=0&&h[m].endTime>p;)h[m].endTime=p,m--}if(void 0!==u)r=Math.max(v,u);else{if(h.length<=0)return T.warn("NTD: Current text tracks have no cues nor start time. Aborting"),M(this._buffered);T.warn("NTD: No start time given. Guessing from cues."),r=h[0].startTime}if(void 0!==l)i=Math.min(p,l);else{if(h.length<=0)return T.warn("NTD: Current text tracks have no cues nor end time. Aborting"),M(this._buffered);T.warn("NTD: No end time given. Guessing from cues."),i=h[h.length-1].endTime}if(i<=r)return T.warn("NTD: Invalid text track appended: ","the start time is inferior or equal to the end time."),M(this._buffered);if(h.length>0){var g=h[0],y=this._track.cues;null!==y&&y.length>0&&g.startTime<y[y.length-1].startTime&&this._removeData(g.startTime,1/0);for(var _=0;_<h.length;_++)this._track.addCue(h[_])}return this._buffered.insert(r,i),M(this._buffered)},t.removeBuffer=function(e,t){return this._removeData(e,t),M(this._buffered)},t.getBufferedRanges=function(){return M(this._buffered)},t.reset=function(){T.debug("NTD: Aborting NativeTextDisplayer"),this._removeData(0,1/0);var e=this._trackElement,t=this._videoElement;if(void 0!==e&&t.hasChildNodes())try{t.removeChild(e)}catch(e){T.warn("NTD: Can't remove track element from the video")}var n=this._track.mode;this._track.mode="disabled",this._track.mode=n,void 0!==this._trackElement&&(this._trackElement.innerHTML="")},t.stop=function(){T.debug("NTD: Aborting NativeTextDisplayer"),this._removeData(0,1/0);var e=this._trackElement,t=this._videoElement;if(void 0!==e&&t.hasChildNodes())try{t.removeChild(e)}catch(e){T.warn("NTD: Can't remove track element from the video")}this._track.mode="disabled",void 0!==this._trackElement&&(this._trackElement.innerHTML="")},t._removeData=function(e,t){T.debug("NTD: Removing native text track data",e,t);var n=this._track,r=n.cues;if(null!==r)for(var i=r.length-1;i>=0;i--){var a=r[i],o=a.startTime,s=a.endTime;o>=e&&o<=t&&s<=t&&qd(n,a)}this._buffered.remove(e,t)},e}(),$d=Qd,Xd=/(\d+) (\d+)/;function Zd(e,t,n,r){for(var i,a={},o=e.slice(),s=function(){var e=t[u];if(void 0!==e){var i,s;if(e.nodeType===Node.ELEMENT_NODE)for(var l=e,d=0;d<=l.attributes.length-1;d++){var c=l.attributes[d],f=c.name;if("style"===f)i=c.value;else if("region"===f)s=c.value;else{var v=f.substring(4);if(Ue(o,v)&&(a[v]=c.value,o.splice(d,1),0===o.length))return{v:a}}}if(et(i)){var p=ae(n,(function(e){return e.id===i}));if(void 0!==p)for(var h=0;h<=o.length-1;h++){var m=o[h];if(!et(a[m])&&et(p.style[m])){if(a[m]=p.style[m],o.splice(h,1),0===o.length)return{v:a};h--}}}if(et(s)){var g=ae(r,(function(e){return e.id===s}));if(void 0!==g)for(var y=0;y<=o.length-1;y++){var _=o[y];if(!et(a[_])&&et(g.style[_])){if(a[_]=g.style[_],o.splice(y,1),0===o.length)return{v:a};y--}}}}},u=0;u<=t.length-1;u++)if(i=s())return i.v;return a}function Jd(e){if(e.nodeType!==Node.ELEMENT_NODE)return{};for(var t=e,n={},r=0;r<=t.attributes.length-1;r++){var i=t.attributes[r];if(ar(i.name,"tts"))n[i.name.substring(4)]=i.value}return n}function ec(e,t){if(!(e.parentNode instanceof Element))return[];return function e(n){var r=[];n.tagName.toLowerCase()===t.toLowerCase()&&r.push(n);var i=n.parentNode;return i instanceof Element&&r.push.apply(r,e(i)),r}(e.parentNode)}function tc(e){var t=ec(e,"div");if(0===t.length){var n=ec(e,"tt:div");n.length>0&&(t=n)}return t}function nc(e){return"br"===e.nodeName||"tt:br"===e.nodeName}function rc(e){return"span"===e.nodeName||"tt:span"===e.nodeName}var ic=["align","backgroundColor","color","direction","display","displayAlign","extent","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","opacity","origin","overflow","padding","textAlign","textDecoration","textOutline","unicodeBidi","visibility","wrapOption","writingMode"];function ac(e,t){var n=[],r=(new DOMParser).parseFromString(e,"text/xml");if(null!=r){var i=r.getElementsByTagName("tt")[0];if(void 0===i)if(void 0===(i=r.getElementsByTagNameNS("*","tt")[0]))throw new Error("invalid XML");for(var a=function(e){var t=e.getElementsByTagName("body");if(t.length>0)return t[0];var n=e.getElementsByTagName("tt:body");return n.length>0?n[0]:null}(i),o=function(e){var t=e.getElementsByTagName("style");if(t.length>0)return t;var n=e.getElementsByTagName("tt:style");return n.length>0?n:t}(i),s=function(e){var t=e.getElementsByTagName("region");if(t.length>0)return t;var n=e.getElementsByTagName("tt:region");return n.length>0?n:t}(i),u=function(e){var t=e.getElementsByTagName("p");if(t.length>0)return t;var n=e.getElementsByTagName("tt:p");return n.length>0?n:t}(i),l=function(e){var t=e.getAttribute("ttp:frameRate"),n=e.getAttribute("ttp:subFramRate"),r=e.getAttribute("ttp:tickRate"),i=e.getAttribute("ttp:frameRateMultiplier"),a=e.getAttribute("xml:space"),o=e.getAttribute("ttp:cellResolution"),s={columns:32,rows:15};if(null!==o){var u=Xd.exec(o);if(null===u||u.length<3)T.warn("TTML Parser: Invalid cellResolution");else{var l=parseInt(u[1],10),d=parseInt(u[2],10);isNaN(l)||isNaN(d)?T.warn("TTML Parser: Invalid cellResolution"):s={columns:l,rows:d}}}if(et(a)&&"default"!==a&&"preserve"!==a)throw new Error("Invalid spacing style");var c=Number(t);(isNaN(c)||c<=0)&&(c=30);var f=Number(n);(isNaN(f)||f<=0)&&(f=1);var v=Number(r);(isNaN(v)||v<=0)&&(v=void 0);var p=c,h=null!=f?f:1,m=null!=a?a:"default",g=null!=v?v:c*f;if(null!==i){var y=/^(\d+) (\d+)$/g.exec(i);null!==y&&(p=c*(Number(y[1])/Number(y[2])))}return{cellResolution:s,tickRate:g,frameRate:p,subFrameRate:h,spaceStyle:m}}(i),d=[],c=0;c<=o.length-1;c++){var f=o[c];if(f instanceof Element){var v=f.getAttribute("xml:id");if(null!==v){var p=f.getAttribute("style"),h=null===p?[]:p.split(" ");d.push({id:v,style:Jd(f),extendsStyles:h})}}}!function(e){var t=[];function n(r,i){t.push(i);for(var a=function(){var i=r.extendsStyles[o],a=B(e,(function(e){return e.id===i}));if(a<0)T.warn("TTML Parser: unknown style inheritance: "+i);else{var s=e[a];Ue(t,a)?T.warn("TTML Parser: infinite style inheritance loop avoided"):n(s,a),r.style=m({},s.style,r.style)}},o=0;o<r.extendsStyles.length;o++)a();r.extendsStyles.length=0}for(var r=0;r<e.length;r++)n(e[r],r),t.length=0}(d);for(var g=[],y=function(){var e=s[_];if(e instanceof Element){var t=e.getAttribute("xml:id");if(null!==t){var n=Jd(e),r=e.getAttribute("style");if(et(r)){var i=ae(d,(function(e){return e.id===r}));void 0!==i&&(n=m({},i.style,n))}g.push({id:t,style:n,extendsStyles:[]})}}},_=0;_<=s.length-1;_++)y();for(var b=Zd(ic,null!==a?[a]:[],d,g),S="default"===(null!==a?a.getAttribute("xml:space"):void 0)||"default"===l.spaceStyle,E=0;E<u.length;E++){var k=u[E];if(k instanceof Element){var w=tc(k),A=m({},b,Zd(ic,[k].concat(w),d,g)),I=k.getAttribute("xml:space"),R=et(I)?"default"===I:S,x={paragraph:k,timeOffset:t,idStyles:d,regionStyles:g,body:a,paragraphStyle:A,ttParams:l,shouldTrimWhiteSpace:R};null!==x&&n.push(x)}}}return n}function oc(e){return"function"==typeof s.VTTCue&&e instanceof s.VTTCue}function sc(e,n,r){if(e>=n)return T.warn("Compat: Invalid cue times: "+e+" - "+n),null;if(t(s.VTTCue)){if(t(s.TextTrackCue))throw new Error("VTT cues not supported in your target");return new TextTrackCue(e,n,r)}return new VTTCue(e,n,r)}var uc=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,lc=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,dc=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d{2,})$/,cc=/^(\d*\.?\d*)f$/,fc=/^(\d*\.?\d*)t$/,vc=/^(?:(\d*\.?\d*)h)?(?:(\d*\.?\d*)m)?(?:(\d*\.?\d*)s)?(?:(\d*\.?\d*)ms)?$/,pc=/^(\d{1,2}|100)% (\d{1,2}|100)%$/,hc=/^((?:\+|\-)?\d*(?:\.\d+)?)(px|em|c|%|rh|rw)$/,mc=/^#([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})$/,gc=/^#([0-9A-f])([0-9A-f])([0-9A-f])([0-9A-f])$/,yc=/^rgb\( *(\d+) *, *(\d+) *, *(\d+) *\)/,_c=/^rgba\( *(\d+) *, *(\d+) *, *(\d+) *, *(\d+) *\)/;function bc(e,t){var n=e.exec(t);if(null===n||""===n[0])return null;var r=Number(n[1]);isNaN(r)&&(r=0);var i=Number(n[2]);isNaN(i)&&(i=0);var a=Number(n[3]);isNaN(a)&&(a=0);var o=Number(n[4]);return isNaN(o)&&(o=0),o/1e3+a+60*i+3600*r}var Sc=function(e,t){return uc.test(e)?function(e,t){var n=uc.exec(t),r=Number(n[1]),i=Number(n[2]),a=Number(n[3]),o=Number(n[4]),s=Number(n[5]);isNaN(s)&&(s=0);return o+=s/e.subFrameRate,a+=o/e.frameRate,a+60*i+3600*r}(t,e):lc.test(e)?bc(lc,e):dc.test(e)?bc(dc,e):cc.test(e)?function(e,t){var n=cc.exec(t);return Number(n[1])/e.frameRate}(t,e):fc.test(e)?function(e,t){var n=fc.exec(t);return Number(n[1])/e.tickRate}(t,e):vc.test(e)?bc(vc,e):void 0};function Ec(e,n){var r=e.getAttribute("begin"),i=e.getAttribute("dur"),a=e.getAttribute("end"),o=et(r)?Sc(r,n):null,s=et(i)?Sc(i,n):null,u=et(a)?Sc(a,n):null;if(t(o)||t(u)&&t(s))throw new Error("Invalid text cue");return{start:o,end:t(u)?o+s:u}}var Tc={left:"start",center:"center",right:"end",start:"start",end:"end"},kc={left:"line-left",center:"center",right:"line-right"};function wc(e){var n=e.paragraph,r=e.timeOffset,i=e.paragraphStyle,a=e.ttParams,o=e.shouldTrimWhiteSpace;if(!n.hasAttribute("begin")&&!n.hasAttribute("end")&&/^\s*$/.test(null===n.textContent?"":n.textContent))return null;var s=Ec(n,a),u=s.start,l=s.end,d=function(e,t){function n(e,t){for(var r=e.childNodes,i="",a=0;a<r.length;a++){var o=r[a];if("#text"===o.nodeName){var s=o.textContent;if(null===s&&(s=""),t){var u=s.trim();s=u=u.replace(/\s+/g," ")}i+=s.replace(/&|\u0026/g,"&").replace(/<|\u003C/g,"<").replace(/>|\u2265/g,">").replace(/\u200E/g,"‎").replace(/\u200F/g,"‏").replace(/\u00A0/g," ")}else if(nc(o))i+="\n";else if(rc(o)&&o.nodeType===Node.ELEMENT_NODE&&o.childNodes.length>0){var l=o.getAttribute("xml:space");i+=n(o,et(l)?"default"===l:t)}}return i}return n(e,t)}(n,o),c=sc(u+r,l+r,d);return null===c?null:(oc(c)&&function(e,n){var r=n.extent;if(et(r)){var i=pc.exec(r);t(i)||(e.size=Number(i[1]))}switch(n.writingMode){case"tb":case"tblr":e.vertical="lr";break;case"tbrl":e.vertical="rl"}var a=n.origin;if(et(a)){t(pc.exec(a))}var o=n.align;if(et(o)){e.align=o,"center"===o&&("center"!==e.align&&(e.align="middle"),e.position="auto");var s=kc[o];e.positionAlign=void 0===s?"":s;var u=Tc[o];e.lineAlign=void 0===u?"":u}}(c,i),c)}var Ac=function(e,t){for(var n=ac(e,t),r=[],i=0;i<n.length;i++){var a=wc(n[i]);null!==a&&r.push(a)}return r};function Ic(e){e.nativeTextTracksParsers.ttml=Ac,e.nativeTextDisplayer=$d}var Rc=/&#([0-9]+);/g,xc=/<br>/gi,Cc=/<style[^>]*>([\s\S]*?)<\/style[^>]*>/i,Mc=/\s*<p (?:class=([^>]+))?>(.*)/i,Pc=/<sync[^>]+?start="?([0-9]*)"?[^0-9]/i;function Dc(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}var Oc=function(e,n,r){var i,a,o=/<sync[ >]/gi,s=/<sync[ >]|<\/body>/gi,u=[],l=Cc.exec(e),d=null!==l?l[1]:"";s.exec(e);var c,f=function(e){for(var n=/\.(\S+)\s*{([^}]*)}/gi,r={},i=n.exec(e);Array.isArray(i);){var a=i[1],o=Dc(i[2],"lang");t(a)||t(o)||(r[o]=a),i=n.exec(e)}return r}(d);if(et(r)&&void 0===(c=f[r]))throw new Error("sami: could not find lang "+r+" in CSS");for(;i=o.exec(e),a=s.exec(e),null!==i||null!==a;){if(null===i||null===a||i.index>=a.index)throw new Error("parse error");var v=e.slice(i.index,a.index),p=Pc.exec(v);if(null===p)throw new Error("parse error (sync time attribute)");var h=+p[1];if(isNaN(h))throw new Error("parse error (sync time attribute NaN)");m(v.split("\n"),h/1e3)}return function(e){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=i.start,o=i.end,s=i.text;if(et(s)&&!t(o)){var u=sc(a,o,s);null!==u&&n.push(u)}}return n}(u);function m(e,t){for(var r,i,a=e.length;--a>=0;)if(null!==(r=Mc.exec(e[a]))){var o=r,s=o[1],l=o[2];c===s&&(" "===l?u[u.length-1].end=t:u.push({text:(i=l,i.replace(xc,"\n").replace(Rc,(function(e,t){return String.fromCharCode(Number(t))}))),start:t+n}))}}};function Nc(e){e.nativeTextTracksParsers.sami=Oc,e.nativeTextDisplayer=$d}function Lc(e){for(var t=0;t<e.length;){if(""===e[t])return t+1;t++}return t}function Uc(e,t){return"string"==typeof e[t]&&/^STYLE( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}function Fc(e,t){var n=e[t];if(void 0===n||""===n||Uc(e,t)||function(e,t){return"string"==typeof e[t]&&/^REGION( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}(e,t)||function(e,t){return"string"==typeof e[t]&&/^NOTE( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}(e,t))return!1;if(n.indexOf("--\x3e")>=0)return!0;var r=e[t+1];return void 0!==r&&r.indexOf("--\x3e")>=0}function Bc(e,t){for(var n=t+1;et(e[n]);)n++;return n}function zc(e,t){for(var n=[],r=t;r<e.length;r++)if(Fc(e,r)){var i=Bc(e,r);n.push(e.slice(r,i)),r=i}else if(et(e[r]))for(;et(e[r]);)r++;return n}function Vc(e){var t=e.split(":").reverse();if(et(t[2])||et(t[1])){var n=et(t[2])?parseInt(t[2],10):0,r=parseInt(t[1],10),i=parseFloat(t[0].replace(",","."));if(isNaN(n)||isNaN(r)||isNaN(i))return;return 60*n*60+60*r+i}}function Kc(e,t){var n,r,i,a=/-->/;if(a.test(e[0]))n=e[0],r=e.slice(1,e.length);else{if(!a.test(e[1]))return null;i=e[0],n=e[1],r=e.slice(2,e.length)}var o=function(e){var t=/^([\d:.]+)[ |\t]+-->[ |\t]+([\d:.]+)[ |\t]*(.*)$/.exec(e);if(null===t)return null;var n=Vc(t[1]),r=Vc(t[2]);return void 0===n||void 0===r?null:{start:n,end:r,settings:t[3].split(/ |\t/).reduce((function(e,t){var n=t.split(":");return 2===n.length&&(e[n[0]]=n[1]),e}),{})}}(n);return null===o?null:{start:o.start+t,end:o.end+t,settings:o.settings,payload:r,header:i}}function Wc(e,t){if(!et(e.vertical)||"rl"!==e.vertical&&"lr"!==e.vertical||(t.vertical=e.vertical),et(e.line)){var n=/^(\d+(\.\d+)?)%(,([a-z]+))?/.exec(e.line);if(Array.isArray(n))t.line=Number(n[1]),t.snapToLines=!1,Ue(["start","center","end"],n[4])&&(t.lineAlign=n[4]);else{var r=/^(-?\d+)(,([a-z]+))?/.exec(e.line);Array.isArray(r)&&(t.line=Number(r[1]),t.snapToLines=!0,Ue(["start","center","end"],r[3])&&(t.lineAlign=r[3]))}}if(et(e.position)){var i=/^([\d\.]+)%(?:,(line-left|line-right|center))?$/.exec(e.position);if(Array.isArray(i)&&i.length>=2){var a=parseInt(i[1],10);isNaN(a)||(t.position=a,void 0!==i[2]&&(t.positionAlign=i[2]))}}et(e.size)&&(t.size=e.size),"string"==typeof e.align&&Ue(["start","center","end","left"],e.align)&&(t.align=e.align)}var Gc=function(e,t){var n=e.split(/\r\n|\n|\r/);if(!/^WEBVTT($| |\t)/.test(n[0]))throw new Error("Can't parse WebVTT: Invalid file.");for(var r,i=zc(n,Lc(n)),a=[],o=0;o<i.length;o++){var s=Kc(i[o],t);if(null!==s){var u=sc((r=s).start,r.end,r.payload.join("\n"));null!==u&&(oc(u)&&Wc(s.settings,u),a.push(u))}}return a};function jc(e){e.nativeTextTracksParsers.vtt=Gc,e.nativeTextDisplayer=$d}function Hc(e,t){for(var n=t+1;et(e[n]);)n++;return n}function qc(e){for(var t=[],n=0;n<e.length;n++)if(et(e[n])){var r=Hc(e,n),i=e.slice(n,r);i.length>0&&(1===i.length?i[0].indexOf("--\x3e")>=0&&t.push(i):(i[1].indexOf("--\x3e")>=0||i[0].indexOf("--\x3e")>=0)&&t.push(i)),n=r}return t}function Yc(e){var t=e.split(":");if(et(t[2])){var n=parseInt(t[0],10),r=parseInt(t[1],10),i=parseFloat(t[2].replace(",","."));if(isNaN(n)||isNaN(r)||isNaN(i))return;return 60*n*60+60*r+i}}function Qc(e,t){if(0===e.length)return null;var n,r,i=[];if(et(e[1])&&-1!==e[1].indexOf("--\x3e")){var a=e[1].split("--\x3e").map((function(e){return e.trim()}));n=a[0],r=a[1],i=e.slice(2,e.length)}if(!et(n)||!et(r)){var o=e[0].split("--\x3e").map((function(e){return e.trim()}));n=o[0],r=o[1],i=e.slice(1,e.length)}if(!et(n)||!et(r))return null;var s=Yc(n),u=Yc(r);return void 0===s||void 0===u?null:{start:s+t,end:u+t,payload:i}}function $c(e,t){for(var n,r,i,a,o,s=qc(e.split(/\r\n|\n|\r/)),u=[],l=0;l<s.length;l++){var d=Qc(s[l],t);if(null!==d){var c=(r=void 0,i=void 0,a=void 0,o=void 0,r=(n=d).start,i=n.end,a=n.payload,o=a.join("\n"),sc(r,i,o));null!==c&&u.push(c)}}return u}function Xc(e){e.nativeTextTracksParsers.srt=$c,e.nativeTextDisplayer=$d}var Zc=s.ResizeObserver;function Jc(e,t,n){return void 0===n&&(n=.2),Math.abs(e-t)<=Math.min(n,.2)}function ef(e,t){for(var n=e.length-1;n>=0;n--){if(e[n].start<t)return e.slice(0,n+1)}return[]}function tf(e,t){for(var n=0;n<e.length;n++){if(e[n].end>t)return e.slice(n,e.length)}return[]}function nf(e,t,n){var r=Math.max(e.start,t),i=ef(e.cues,t),a={start:e.start,end:r,cues:i},o=Math.min(n,e.end),s=tf(e.cues,n);return[a,{start:o,end:e.end,cues:s}]}var rf=function(){function e(){this._cuesBuffer=[]}var t=e.prototype;return t.isEmpty=function(){return 0===this._cuesBuffer.length},t.get=function(e){for(var t=this._cuesBuffer,n=[],r=t.length-1;r>=0;r--){var i=t[r];if(e<i.end&&e>=i.start){for(var a=i.cues,o=0;o<a.length;o++)e>=a[o].start&&e<a[o].end&&n.push(a[o].element);if(0===n.length&&a.length>0)for(var s=0;s<a.length;s++)(Jc(e,a[s].start,.001)||Jc(e,a[s].end,.001))&&n.push(a[s].element);return n}}return[]},t.remove=function(e,t){for(var n=Math.max(e,t),r=this._cuesBuffer,i=0;i<r.length;i++)if(r[i].end>e){var a=r[i];if(a.start>=n)return;if(a.end>=n){if(e<=a.start)a.cues=tf(a.cues,n),a.start=n;else{var o=nf(a,e,n),s=o[0],u=o[1];this._cuesBuffer[i]=s,r.splice(i+1,0,u)}return}a.start>=e?(r.splice(i,1),i--):(a.cues=ef(a.cues,e),a.end=Math.max(e,a.start))}},t.insert=function(e,t,n){var r=this._cuesBuffer,i={start:t,end:n,cues:e},a=Math.abs(t-n)/5;function o(e){var t=r[e];void 0===t||Jc(i.end,t.end,a)?r[e]=i:(t.start>=i.end||(t.cues=tf(t.cues,i.end),t.start=i.end),r.splice(e,0,i))}for(var s=0;s<r.length;s++){var u=r[s];if(t<u.end){if(Jc(t,u.start,a)){if(Jc(n,u.end,a))return void(r[s]=i);if(n<u.end)return u.cues=tf(u.cues,n),u.start=n,void r.splice(s,0,i);do{r.splice(s,1),u=r[s]}while(void 0!==u&&n>u.end);return void o(s)}if(t<u.start){if(n<u.start)return void r.splice(s,0,i);if(Jc(n,u.start,a))return u.start=n,void r.splice(s,0,i);if(Jc(n,u.end,a))return void r.splice(s,1,i);if(n<u.end)return u.cues=tf(u.cues,n),u.start=n,void r.splice(s,0,i);do{r.splice(s,1),u=r[s]}while(void 0!==u&&n>u.end);return void o(s)}if(Jc(u.end,n,a))return u.cues=ef(u.cues,t),u.end=t,void r.splice(s+1,0,i);if(u.end>n){var l=nf(u,t,n),d=l[0],c=l[1];return this._cuesBuffer[s]=d,r.splice(s+1,0,i),void r.splice(s+2,0,c)}u.cues=ef(u.cues,t),u.end=t;var f=s+1;for(u=r[f];void 0!==u&&n>u.end;)r.splice(f,1),u=r[f];return void o(f)}}if(r.length){var v=r[r.length-1];Jc(v.end,t,a)&&(v.end=t)}r.push(i)},e}();function af(e,t,n,r){for(var i=[t/n.columns,e/n.rows],a=r.getElementsByClassName("proportional-style"),o=0;o<a.length;o++){var s=a[o];if(s instanceof HTMLElement){var u=s.getAttribute("data-proportional-font-size");null===u||isNaN(+u)||(s.style.fontSize=String(+u*i[1])+"px");var l=s.getAttribute("data-proportional-width");null===l||isNaN(+l)||(s.style.width=String(+l*i[0])+"px");var d=s.getAttribute("data-proportional-height");null===d||isNaN(+d)||(s.style.height=String(+d*i[1])+"px");var c=s.getAttribute("data-proportional-line-height");null===c||isNaN(+c)||(s.style.lineHeight=String(+c*i[1])+"px");var f=s.getAttribute("data-proportional-left");null===f||isNaN(+f)||(s.style.left=String(+f*i[0])+"px");var v=s.getAttribute("data-proportional-top");null===v||isNaN(+v)||(s.style.top=String(+v*i[1])+"px");var p=s.getAttribute("data-proportional-padding-top");null===p||isNaN(+p)||(s.style.paddingTop=String(+p*i[1])+"px");var h=s.getAttribute("data-proportional-padding-bottom");null===h||isNaN(+h)||(s.style.paddingBottom=String(+h*i[1])+"px");var m=s.getAttribute("data-proportional-padding-left");null===m||isNaN(+m)||(s.style.paddingLeft=String(+m*i[0])+"px");var g=s.getAttribute("data-proportional-padding-right");null===g||isNaN(+g)||(s.style.paddingRight=String(+g*i[0])+"px")}}return a.length>0}function of(e,t){try{e.removeChild(t)}catch(e){T.warn("HTD: Can't remove text track: not in the element.")}}function sf(e){var t=e.getAttribute("data-resolution-rows"),n=e.getAttribute("data-resolution-columns");if(null===t||null===n)return null;var r=parseInt(t,10),i=parseInt(n,10);return null===r||null===i?null:{rows:r,columns:i}}var uf,lf=function(){function e(e,t){T.debug("HTD: Creating HTMLTextDisplayer"),this._buffered=new Yd,this._videoElement=e,this._textTrackElement=t,this._sizeUpdateCanceller=new Z,this._subtitlesIntervalCanceller=new Z,this._buffer=new rf,this._currentCues=[],this._isAutoRefreshing=!1}var t=e.prototype;return t.pushTextData=function(e){var t,n;T.debug("HTD: Appending new html text tracks");var r=e.timestampOffset,i=e.appendWindow,a=e.chunk;if(null===a)return M(this._buffered);var o,s,u=a.start,l=a.end,d=a.data,c=a.type,f=a.language,v=null!==(t=i[0])&&void 0!==t?t:0,p=null!==(n=i[1])&&void 0!==n?n:1/0,h=function(e,t,n,r){T.debug("HTSB: Finding parser for html text tracks:",e);var i=ot.htmlTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");T.debug("HTSB: Parser found, parsing...");var a=i(t,n,r);return T.debug("HTTB: Parsed successfully!",a.length),a}(c,d,r,f);if(0!==v&&p!==1/0){for(var m=0;m<h.length&&h[m].end<=v;)m++;for(h.splice(0,m),m=0;m<h.length&&h[m].start<v;)h[m].start=v,m++;for(m=h.length-1;m>=0&&h[m].start>=p;)m--;for(h.splice(m,h.length),m=h.length-1;m>=0&&h[m].end>p;)h[m].end=p,m--}if(void 0!==u)o=Math.max(v,u);else{if(h.length<=0)return T.warn("HTD: Current text tracks have no cues nor start time. Aborting"),M(this._buffered);T.warn("HTD: No start time given. Guessing from cues."),o=h[0].start}if(void 0!==l)s=Math.min(p,l);else{if(h.length<=0)return T.warn("HTD: Current text tracks have no cues nor end time. Aborting"),M(this._buffered);T.warn("HTD: No end time given. Guessing from cues."),s=h[h.length-1].end}return s<=o?(T.warn("HTD: Invalid text track appended: ","the start time is inferior or equal to the end time."),M(this._buffered)):(this._buffer.insert(h,o,s),this._buffered.insert(o,s),this._isAutoRefreshing||this._buffer.isEmpty()||this.autoRefreshSubtitles(this._subtitlesIntervalCanceller.signal),M(this._buffered))},t.removeBuffer=function(e,t){return T.debug("HTD: Removing html text track data",e,t),this._buffer.remove(e,t),this._buffered.remove(e,t),this._isAutoRefreshing&&this._buffer.isEmpty()&&(this.refreshSubtitles(),this._isAutoRefreshing=!1,this._subtitlesIntervalCanceller.cancel(),this._subtitlesIntervalCanceller=new Z),M(this._buffered)},t.getBufferedRanges=function(){return M(this._buffered)},t.reset=function(){T.debug("HTD: Resetting HTMLTextDisplayer"),this.stop(),this._subtitlesIntervalCanceller=new Z},t.stop=function(){this._subtitlesIntervalCanceller.isUsed()||(T.debug("HTD: Stopping HTMLTextDisplayer"),this._disableCurrentCues(),this._buffer.remove(0,1/0),this._buffered.remove(0,1/0),this._isAutoRefreshing=!1,this._subtitlesIntervalCanceller.cancel())},t._disableCurrentCues=function(){if(this._sizeUpdateCanceller.cancel(),this._currentCues.length>0){for(var e=0;e<this._currentCues.length;e++)of(this._textTrackElement,this._currentCues[e].element);this._currentCues=[]}},t._displayCues=function(e){if(!(this._currentCues.length===e.length&&this._currentCues.every((function(t,n){return t.element===e[n]})))){this._sizeUpdateCanceller.cancel();for(var t=0;t<this._currentCues.length;t++)of(this._textTrackElement,this._currentCues[t].element);this._currentCues=[];for(var n=0;n<e.length;n++){var r=e[n],i=sf(r);this._currentCues.push({element:r,resolution:i}),this._textTrackElement.appendChild(r)}var a=this._currentCues.filter((function(e){return null!==e.resolution}));if(a.length>0){this._sizeUpdateCanceller=new Z,this._sizeUpdateCanceller.linkToSignal(this._subtitlesIntervalCanceller.signal);var o=b.getCurrent().TEXT_TRACK_SIZE_CHECKS_INTERVAL,s=function(e,t,n){var r=e.getBoundingClientRect(),i=r.height,a=r.width,o=new G({height:i,width:a},n),s=i,u=a;if(void 0!==Zc){var l=new Zc((function(e){if(0!==e.length){var t=e[0].contentRect,n=t.height,r=t.width;n===s&&r===u||(s=n,u=r,o.setValue({height:n,width:r}))}else T.error("Compat: Resized but no observed element.")}));l.observe(e),n.register((function(){l.disconnect()}))}else{var d=setInterval((function(){var t=e.getBoundingClientRect(),n=t.height,r=t.width;n===s&&r===u||(s=n,u=r,o.setValue({height:n,width:r}))}),t);n.register((function(){clearInterval(d)}))}return o}(this._textTrackElement,o,this._sizeUpdateCanceller.signal);s.onUpdate((function(e){for(var t=e.height,n=e.width,r=0;r<a.length;r++){var i=a[r];af(t,n,i.resolution,i.element)}}),{clearSignal:this._sizeUpdateCanceller.signal,emitCurrentValue:!0})}}},t.autoRefreshSubtitles=function(e){var t=this;if(!this._isAutoRefreshing&&!e.isCancelled()){var n=null,r=b.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL,i=function(){t._isAutoRefreshing=!1,null!==n&&(n.cancel(),n=null)},a=function(){i(),t._isAutoRefreshing=!0,(n=new Z).linkToSignal(e);var a=setInterval((function(){return t.refreshSubtitles()}),r);n.signal.register((function(){clearInterval(a)})),t.refreshSubtitles()};qr(this._videoElement,(function(){i(),t._disableCurrentCues()}),e),Yr(this._videoElement,a,e),Qr(this._videoElement,a,e),a()}},t.refreshSubtitles=function(){var e,t=b.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL;e=this._videoElement.paused||this._videoElement.playbackRate<=0?this._videoElement.currentTime:Math.max(this._videoElement.currentTime+t/1e3/2,0);var n=this._buffer.get(e);0===n.length?this._disableCurrentCues():this._displayCues(n)},e}(),df=lf;function cf(e){return void 0===e.extent&&void 0===e.origin&&void 0===e.displayAlign&&void 0===e.display&&void 0===e.textAlign&&void 0===e.fontSize}function ff(e){e.extent="70% 20%",e.fontSize="1c",e.origin="15% 80%",e.displayAlign="before",e.textAlign="center"}function vf(e,t){(void 0===uf&&(uf=void 0!==e.classList&&"function"==typeof e.classList.add),uf)?e.classList.add(t):(" "+e.className+" ").indexOf(" "+t+" ")<0&&(e.className+=" "+t)}function pf(e,t){var n=t;return et(t)&&t.trim().endsWith("%")&&(n=t.trim().slice(0,-1),n=(parseInt(n,10)/100).toString()+"em"),"-1px -1px "+n+" "+e+",1px -1px "+n+" "+e+",-1px 1px "+n+" "+e+",1px 1px "+n+" "+e}function hf(e){var n;return t(n=mc.exec(e))?t(n=gc.exec(e))?t(n=yc.exec(e))?t(n=_c.exec(e))?e:"rgba("+String(+n[1])+","+String(+n[2])+","+String(+n[3])+","+String(+n[4]/255)+")":"rgb("+String(+n[1])+","+String(+n[2])+","+String(+n[3])+")":"rgba("+String(parseInt(n[1]+n[1],16))+","+String(parseInt(n[2]+n[2],16))+","+String(parseInt(n[3]+n[3],16))+","+String(parseInt(n[4]+n[4],16)/255)+")":"rgba("+String(parseInt(n[1],16))+","+String(parseInt(n[2],16))+","+String(parseInt(n[3],16))+","+String(parseInt(n[4],16)/255)+")"}var mf=["color","direction","display","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","textOutline","unicodeBidi","visibility","wrapOption"];function gf(e,t,n){var r=t.color;et(r)&&(e.style.color=hf(r));var i=t.backgroundColor;et(i)&&(e.style.backgroundColor=hf(i));var a=t.textOutline;if(et(a)){var o=a.trim().replace(/\s+/g," ").split(" "),s=o.length;if(3===s){var u=hf(o[0]),l=o[1];e.style.textShadow=pf(u,l)}else if(et(r)&&1===s){var d=o[0];e.style.textShadow=pf(r,d)}else if(2===s){var c=/^[#A-Z]/i.test(o[0]);if(c!==/^[0-9]/.test(o[0]))if(c){var f=hf(o[0]),v=o[1];e.style.textShadow=pf(f,v)}else if(et(r)){var p=o[0];e.style.textShadow=pf(r,p)}}}var h=t.textDecoration;if(et(h))switch(h){case"noUnderline":case"noLineThrough":case"noOverline":e.style.textDecoration="none";break;case"lineThrough":e.style.textDecoration="line-through";break;default:e.style.textDecoration=h}var m=t.fontFamily;if(et(m))switch(m){case"proportionalSansSerif":e.style.fontFamily="Arial, Helvetica, Liberation Sans, sans-serif";break;case"monospaceSansSerif":case"sansSerif":e.style.fontFamily="sans-serif";break;case"monospaceSerif":case"default":e.style.fontFamily="Courier New, Liberation Mono, monospace";break;case"proportionalSerif":e.style.fontFamily="serif";break;default:e.style.fontFamily=m}var g=t.fontStyle;et(g)&&(e.style.fontStyle=g);var y=t.fontWeight;et(y)&&(e.style.fontWeight=y);var _=t.fontSize;et(_)?function(e,t){var n=t.trim().split(" ");if(0!==n.length){var r=hc.exec(n[0]);if(null!==r)if("px"===r[2]||"em"===r[2])e.style.fontSize=r[1]+r[2];else if("c"===r[2])e.style.position="relative",vf(e,"proportional-style"),e.setAttribute("data-proportional-font-size",r[1]);else if("%"===r[2]){var i=Number(r[1]);isNaN(i)?T.warn('TTML Parser: could not parse fontSize value "'+r[1]+'" into a number'):(e.style.position="relative",vf(e,"proportional-style"),e.setAttribute("data-proportional-font-size",String(i/100)))}else T.warn("TTML Parser: unhandled fontSize unit:",r[2])}}(e,_):(vf(e,"proportional-style"),e.setAttribute("data-proportional-font-size","1"));var b=t.direction;et(b)&&(e.style.direction=b);var S=t.unicodeBidi;if(et(S))switch(S){case"bidiOverride":e.style.unicodeBidi="bidi-override";break;case"embed":e.style.unicodeBidi="embed";break;default:e.style.unicodeBidi="normal"}var E=t.visibility;et(E)&&(e.style.visibility=E),"none"===t.display&&(e.style.display="none");var k=t.wrapOption;e.style.whiteSpace="noWrap"===k?n?"nowrap":"pre":n?"normal":"pre-wrap"}function yf(e,t){e.style.color="white",e.style.position="absolute";var n=t.extent;et(n)&&function(e,t){var n=t.trim();if("auto"!==n){var r=n.split(" ");if(2===r.length){var i=hc.exec(r[0]),a=hc.exec(r[1]);null!==i&&null!==a&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.width=i[1]+i[2]:"c"===i[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-width",i[1])):T.warn("TTML Parser: unhandled extent unit:",i[2]),"px"===a[2]||"%"===a[2]||"em"===a[2]?e.style.height=a[1]+a[2]:"c"===a[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-height",a[1])):T.warn("TTML Parser: unhandled extent unit:",a[2]))}}}(e,n),et(t.writingMode);var r=t.overflow;e.style.overflow=et(r)?r:"hidden";var i=t.padding;et(i)&&function(e,t){var n=t.trim().split(" ");if(!(n.length<1)){var r=hc.exec(n[0]);if(null!==r){if("px"===r[2]||"%"===r[2]||"em"===r[2]){var i=r[1]+r[2];1===n.length?e.style.padding=i:2===n.length?(e.style.paddingTop=i,e.style.paddingBottom=i):e.style.paddingTop=i}else"c"===r[2]?(vf(e,"proportional-style"),1===n.length?(e.setAttribute("data-proportional-padding-top",r[1]),e.setAttribute("data-proportional-padding-bottom",r[1]),e.setAttribute("data-proportional-padding-left",r[1]),e.setAttribute("data-proportional-padding-right",r[1])):2===n.length?(e.setAttribute("data-proportional-padding-top",r[1]),e.setAttribute("data-proportional-padding-bottom",r[1])):e.setAttribute("data-proportional-padding-top",r[1])):T.warn("TTML Parser: unhandled padding unit:",r[2]);if(1!==n.length){var a=hc.exec(n[1]);if(null!==a){if("px"===a[2]||"%"===a[2]||"em"===a[2]){var o=a[1]+a[2];n.length<4?(e.style.paddingLeft=o,e.style.paddingRight=o):e.style.paddingRight=o}else"c"===a[2]?(vf(e,"proportional-style"),n.length<4?(e.setAttribute("data-proportional-padding-left",a[1]),e.setAttribute("data-proportional-padding-right",a[1])):e.setAttribute("data-proportional-padding-right",a[1])):T.warn("TTML Parser: unhandled padding unit:",a[2]);if(2!==n.length){var s=hc.exec(n[2]);if(null!==s){if("px"===s[2]||"%"===s[2]||"em"===s[2]){var u=s[1]+s[2];e.style.paddingBottom=u}else"c"===s[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-padding-bottom",s[1])):T.warn("TTML Parser: unhandled padding unit:",s[2]);if(3!==n.length){var l=hc.exec(n[3]);if(null!==l)if("px"===l[2]||"%"===l[2]||"em"===l[2]){var d=l[1]+l[2];e.style.paddingLeft=d}else"c"===l[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-padding-left",l[1])):T.warn("TTML Parser: unhandled padding unit:",l[2])}}}}}}}}(e,i);var a=t.origin;et(a)&&function(e,t){var n=t.trim();if("auto"!==n){var r=n.split(" ");if(2===r.length){var i=hc.exec(r[0]),a=hc.exec(r[1]);null!==i&&null!==a&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.left=i[1]+i[2]:"c"===i[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-left",i[1])):T.warn("TTML Parser: unhandled origin unit:",i[2]),"px"===a[2]||"%"===a[2]||"em"===a[2]?e.style.top=a[1]+a[2]:"c"===a[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-top",a[1])):T.warn("TTML Parser: unhandled origin unit:",a[2]))}}}(e,a);var o=t.displayAlign;if(et(o))switch(e.style.display="flex",e.style.flexDirection="column",o){case"before":e.style.justifyContent="flex-start";break;case"center":e.style.justifyContent="center";break;case"after":e.style.justifyContent="flex-end"}var s=t.opacity;et(s)&&(e.style.opacity=s);var u=t.visibility;et(u)&&(e.style.visibility=u),"none"===t.display&&(e.style.display="none")}function _f(e,t){e.style.margin="0px",vf(e,"proportional-style"),e.setAttribute("data-proportional-font-size","1");var n=t.backgroundColor;et(n)&&(e.style.backgroundColor=hf(n));var r=t.lineHeight;et(r)&&function(e,t){var n=t.trim(),r=n.split(" ");if("auto"!==n){var i=hc.exec(r[0]);null!==i&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.lineHeight=i[1]+i[2]:"c"===i[2]?(vf(e,"proportional-style"),e.setAttribute("data-proportional-line-height",i[1])):T.warn("TTML Parser: unhandled lineHeight unit:",i[2]))}}(e,r);var i=t.textAlign;if(et(i))switch(i){case"center":e.style.textAlign="center";break;case"left":case"start":e.style.textAlign="left";break;case"right":case"end":e.style.textAlign="right"}}function bf(e,t,n){var r=document.createElement("span"),i=null===e.textContent?"":e.textContent;if(n){var a=i.trim();i=a=a.replace(/\s+/g," ")}var o=document.createTextNode(i);return r.appendChild(o),r.className="rxp-texttrack-span",gf(r,t,n),r}function Sf(e,t,n,r,i,a){var o=a.cellResolution,s=a.shouldTrimWhiteSpace,u=tc(e),l=document.createElement("DIV");if(l.className="rxp-texttrack-region",l.setAttribute("data-resolution-columns",String(o.columns)),l.setAttribute("data-resolution-rows",String(o.rows)),yf(l,i),null!==t){var d=Zd(["backgroundColor"],[].concat(u,[t]),r,n).bodyBackgroundColor;et(d)&&(l.style.backgroundColor=hf(d))}var c=document.createElement("p");c.className="rxp-texttrack-p",_f(c,i);for(var f=function(e,t,n,r,i){return function e(r,i,a,o){for(var s=r.childNodes,u=[],l=0;l<s.length;l++){var d=s[l];if("#text"===d.nodeName){var c=Zd(["backgroundColor"],a,n,t).backgroundColor;et(c)?i.backgroundColor=c:delete i.backgroundColor;var f=bf(d,i,o);u.push(f)}else if(nc(d)){var v=document.createElement("BR");u.push(v)}else if(rc(d)&&d.nodeType===Node.ELEMENT_NODE&&d.childNodes.length>0){var p=d.getAttribute("xml:space"),h=et(p)?"default"===p:o,g=m({},i,Zd(mf,[d],n,t));u.push.apply(u,e(d,g,[d].concat(a),h))}}return u}(e,m({},r),[],i)}(e,n,r,i,s),v=0;v<f.length;v++)c.appendChild(f[v]);return l.appendChild(c),l}function Ef(e){var t=e.paragraph,n=e.ttParams,r=e.body,i=e.regionStyles,a=e.idStyles,o=e.paragraphStyle,s=e.timeOffset,u=e.shouldTrimWhiteSpace;if(!t.hasAttribute("begin")&&!t.hasAttribute("end")&&/^\s*$/.test(null===t.textContent?"":t.textContent))return null;var l=n.cellResolution,d=Ec(t,n);return{start:d.start+s,end:d.end+s,element:Sf(t,r,i,a,o,{cellResolution:l,shouldTrimWhiteSpace:u})}}var Tf=function(e,t){for(var n=ac(e,t),r=[],i=0;i<n.length;i++){var a=n[i].paragraphStyle;cf(a)&&ff(a);var o=Ef(n[i]);null!==o&&r.push(o)}return r};function kf(e){e.htmlTextTracksParsers.ttml=Tf,e.htmlTextDisplayer=df}var wf=/&#([0-9]+);/g,Af=/<br>/gi,If=/<style[^>]*>([\s\S]*?)<\/style[^>]*>/i,Rf=/\s*<p (?:class=([^>]+))?>(.*)/i,xf=/<sync[^>]+?start="?([0-9]*)"?[^0-9]/i;function Cf(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}var Mf=function(e,n,r){var i,a,o=/<sync[ >]/gi,s=/<sync[ >]|<\/body>/gi,u=[],l=If.exec(e),d=Array.isArray(l)?l[1]:"";s.exec(e);var c,f=function(e){for(var n=/\.(\S+)\s*{([^}]*)}/gi,r={},i=n.exec(e);null!==i;){var a=i[1],o=Cf(i[2],"lang");t(a)||t(o)||(r[o]=a),i=n.exec(e)}return r}(d),v=function(e){var t=/p\s*{([^}]*)}/gi.exec(e);return null===t?"":t[1]}(d);if(et(r)&&void 0===(c=f[r]))throw new Error("sami: could not find lang "+r+" in CSS");for(;i=o.exec(e),a=s.exec(e),null!==i||null!==a;){if(null===i||null===a||i.index>=a.index)throw new Error("parse error");var p=e.slice(i.index,a.index),h=xf.exec(p);if(!Array.isArray(h))throw new Error("parse error (sync time attribute)");var m=+h[1];if(isNaN(m))throw new Error("parse error (sync time attribute NaN)");g(p.split("\n"),m/1e3)}return u;function g(e,t){for(var r=e.length;--r>=0;){var i=Rf.exec(e[r]);if(Array.isArray(i)){var a=i[1],o=i[2];if(c===a)if(" "===o)u[u.length-1].end=t;else{var s=document.createElement("DIV");s.className="rxp-texttrack-region";var l=document.createElement("DIV");l.className="rxp-texttrack-div",l.style.position="absolute",l.style.bottom="0",l.style.width="100%",l.style.color="#fff",l.style.textShadow="-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000";var d=document.createElement("div");d.className="rxp-texttrack-p",et(v)&&(d.style.cssText=v);for(var f=o.split(Af),p=0;p<f.length;p++){0!==p&&d.appendChild(document.createElement("BR"));var h=document.createElement("SPAN");h.className="rxp-texttrack-span",h.textContent=f[p].replace(wf,(function(e,t){return String.fromCharCode(Number(t))})),d.appendChild(h)}l.appendChild(d),s.appendChild(l),u.push({element:s,start:t+n,end:-1})}}}}};function Pf(e){e.htmlTextTracksParsers.sami=Mf,e.htmlTextDisplayer=df}var Df={white:"#ffffff",lime:"#00ff00",cyan:"#00ffff",red:"#ff0000",yellow:"#ffff00",magenta:"#ff00ff",blue:"#0000ff",black:"#000000"};function Of(e){var t=Object.keys(Df).reduce((function(e,t){return e[t]="color: "+Df[t]+";",e["bg_"+t]="background-color: "+Df[t]+";",e}),{}),n="";return e.forEach((function(e){if(e.length>=2)for(var r=function(r){var a=e[r];if(Array.isArray(/::cue {/.exec(a)))for(a=e[++r];et(a)&&!Array.isArray(/}/.exec(a))&&0!==a.length;)n+=a,a=e[++r];else{for(var o=[],s=/::cue\(\.?(.*?)\)(?:,| {)/.exec(a);et(a)&&Array.isArray(s);)o.push(s[1]),a=e[++r],s=/::cue\(\.?(.*?)\)(?:,| {)/.exec(a);for(var u="";et(a)&&!Array.isArray(/}/.exec(a))&&0!==a.length;)u+=a,a=e[++r];o.forEach((function(e){void 0===t[e]?t[e]=u:t[e]+=u}))}i=r},i=1;i<e.length;i++)r(i)})),{classes:t,global:n}}function Nf(e,t){var n,r=["u","i","b"],i=e.nodeName.toLowerCase().split(".")[0];if(Ue(["u","i","b","c","#text"],i))if("#text"===i){var a=e.wholeText.split("\n");n=document.createElement("span");for(var o=0;o<a.length;o++)if(o>0&&n.appendChild(document.createElement("br")),a[o].length>0){var s=document.createTextNode(a[o]);n.appendChild(s)}}else{var u=e.nodeName.toLowerCase().split("."),l=[];if(u.forEach((function(e){et(t[e])&&l.push(t[e])})),0!==l.length){var d=document.createAttribute("style");l.forEach((function(e){d.value+=e}));var c=Ue(r,i)?i:"span";(n=document.createElement(c)).setAttributeNode(d)}else{var f=Ue(r,i)?i:"span";n=document.createElement(f)}for(var v=0;v<e.childNodes.length;v++){var p=Nf(e.childNodes[v],t);n.appendChild(p)}}else{n=document.createElement("span");for(var h=0;h<e.childNodes.length;h++){var m=Nf(e.childNodes[h],t);n.appendChild(m)}}return n}var Lf,Uf,Ff,Bf=function(e){if(!(void 0!==e&&0!==ge(e).length))return"text-align:center";var t=zf(e),n=Wf(e);return"position: absolute;margin: 0;transform: translate("+t.offset+"%,"+n.offset+"%);width: "+qf(e.size)+"%;left: "+t.position+"%;top: "+(null!==n.position?n.position+"%":"auto")+";text-align: "+Hf(e.align)+";"};!function(e){e.LINE_LEFT="line-left",e.CENTER="center",e.LINE_RIGHT="line-right"}(Lf||(Lf={})),function(e){e.LEFT="left",e.CENTER="center",e.RIGHT="right"}(Uf||(Uf={})),function(e){e.START="start",e.CENTER="center",e.END="end"}(Ff||(Ff={}));var zf=function(e){return{position:Vf(e),offset:Kf(e)}},Vf=function(e){var t,n=Qf(e.position);if(null!==n)return n;var r=Hf(e.align);return((t={})[Uf.LEFT]=0,t[Uf.CENTER]=50,t[Uf.RIGHT]=100,t)[r]},Kf=function(e){var t,n,r,i,a=((t={})[Lf.LINE_LEFT]=0,t[Lf.CENTER]=-50,t[Lf.LINE_RIGHT]=-100,t),o=void 0!==e.position?(r=e.position,i=/,(line-left|line-right|center)/.exec(r),!Array.isArray(i)||i.length<2?null:i[1]):null;return null!==o?a[o]:((n={})[Uf.LEFT]=0,n[Uf.CENTER]=-50,n[Uf.RIGHT]=-100,n)[void 0!==e.align?Hf(e.align):Uf.CENTER]},Wf=function(e){return{position:Gf(e.line),offset:jf(e.line)}},Gf=function(e){return Qf(e)},jf=function(e){var t,n=((t={})[Ff.START]=0,t[Ff.CENTER]=-50,t[Ff.END]=-100,t);if(void 0===e)return n[Ff.START];var r,i=(r=/,(start|center|end)/.exec(e),!Array.isArray(r)||r.length<2?null:r[1]);return null!==i?n[i]:n[Ff.START]},Hf=function(e){switch(e){case"left":case"start":return"left";case"right":case"end":return"right";default:return"center"}},qf=function(e){return Yf(e,100)},Yf=function(e,t){var n=Qf(e);return null!==n?n:t},Qf=function(e){if(void 0===e)return null;var t=/^([\d.]+)%/.exec(e);return!Array.isArray(t)||t.length<2?null:parseInt(t[1],10)};function $f(e,t){var n=e.start,r=e.end,i=e.settings,a=e.header,o=e.payload,s=document.createElement("div"),u=document.createAttribute("style");u.value="width:100%;height:100%;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;",s.setAttributeNode(u);var l=document.createElement("p"),d=function(e){var t=document.createAttribute("style");return t.value=Bf(e),t}(i);l.setAttributeNode(d);var c=document.createElement("span"),f=document.createAttribute("style");f.value="background-color:rgba(0,0,0,0.8);color:white;",c.setAttributeNode(f);var v=t.global,p=t.classes,h=[v,et(a)?p[a]:void 0].filter((function(e){return void 0!==e})).join("");return f.value+=h,c.setAttributeNode(f),function(e,t){for(var n=e.replace(/<[0-9]{2}:[0-9]{2}.[0-9]{3}>/,"").replace(/<([u,i,b,c])(\..*?)?(?: .*?)?>(.*?)<\/\1>/g,"<$1$2>$3</$1$2>"),r=(new DOMParser).parseFromString(n,"text/html").body.childNodes,i=[],a=0;a<r.length;a++)i.push(Nf(r[a],t));return i}(o.join("\n"),p).forEach((function(e){c.appendChild(e)})),s.appendChild(l),l.appendChild(c),{start:n,end:r,element:s}}var Xf=function(e,t){var n=e.split(/\r\n|\n|\r/g),r=[];if(null===/^WEBVTT( |\t|\n|\r|$)/.exec(n[0]))throw new Error("Can't parse WebVTT: Invalid File.");for(var i=Lc(n),a=function(e,t){for(var n=[],r=t;r<e.length;r++)if(Uc(e,r)){var i=r;for(r++;et(e[r]);)r++;var a=e.slice(i,r);n.push(a)}else if(et(e[r]))for(;et(e[r]);)r++;return n}(n,i),o=zc(n,i),s=Of(a),u=0;u<o.length;u++){var l=Kc(o[u],t);if(null!==l){var d=$f(l,s);r.push(d)}}return r};function Zf(e){e.htmlTextTracksParsers.vtt=Xf,e.htmlTextDisplayer=df}function Jf(e,t){for(var n=qc(e.split(/\r\n|\n|\r/)),r=[],i=0;i<n.length;i++){var a=Qc(n[i],t);if(null!==a){var o=ev(a);null!==o&&r.push(o)}}return r}function ev(e){var t=e.start,n=e.end,r=e.payload,i=document.createElement("div");i.className="rxp-texttrack-p",i.style.fontSize="28px",i.style.position="absolute",i.style.bottom="5%",i.style.width="100%",i.style.textAlign="center",i.style.color="#fff",i.style.textShadow="-1px -1px 2px #000,1px -1px 2px #000,-1px 1px 2px #000,1px 1px 2px #000";for(var a=0;a<r.length;a++){0!==a&&i.appendChild(document.createElement("br"));var o=tv(r[a]);i.appendChild(o)}return{start:t,end:n,element:i}}function tv(e){var t=document.createElement("div");t.innerHTML=e;return function e(t){var n=t.childNodes,r=document.createElement("span");r.className="rxp-texttrack-span";for(var i=0;i<n.length;i++){var a=n[i];if("#text"===a.nodeName){for(var o=a.wholeText.split("\n"),s=0;s<o.length;s++)if(0!==s&&r.appendChild(document.createElement("br")),o[s].length>0){var u=document.createTextNode(o[s]);r.appendChild(u)}}else if("B"===a.nodeName){var l=e(a);l.style.fontWeight="bold",r.appendChild(l)}else if("I"===a.nodeName){var d=e(a);d.style.fontStyle="italic",r.appendChild(d)}else if("U"===a.nodeName){var c=e(a);c.style.textDecoration="underline",r.appendChild(c)}else if(nv(a)&&"string"==typeof a.color){var f=e(a);f.style.color=a.color,r.appendChild(f)}else{var v=e(a);r.appendChild(v)}}return r}(t)}function nv(e){return"FONT"===e.nodeName&&"color"in e}function rv(e){e.htmlTextTracksParsers.srt=Jf,e.htmlTextDisplayer=df}function iv(){if(!hi)return!0;var e=function(){if(!hi)return T.warn("Compat: Can't access Firefox version on no firefox browser."),null;var e=navigator.userAgent,t=/Firefox\/([0-9]+)\./.exec(e);if(null===t)return-1;var n=parseInt(t[1],10);return isNaN(n)?-1:n}();if(null===e||e<67)return!0;var t=null===HTMLVideoElement||void 0===HTMLVideoElement?void 0:HTMLVideoElement.prototype;return void 0!==(null==t?void 0:t.requirePictureInPicture)}function av(e){var t=e;if("function"==typeof t.getStartDate){var n=t.getStartDate();if("object"==typeof n&&null!==n){var r=+n;if(!isNaN(r))return r/1e3}else if("number"==typeof n&&!isNaN(n))return n}}var ov="function"==typeof MediaSource&&!0===MediaSource.canConstructInDedicatedWorker,sv="object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate,uv=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(j(i),t.prototype),i.name="WorkerInitializationError",i.type="WORKER_INITIALIZATION_ERROR",i.code=n,i.message=xe(i.code,r),i}return f(t,e),t}(Y(Error));var lv=_i;function dv(e,t,n){var r=t(e.getReference(),n);return{getCurrentTime:function(){return e.getCurrentTime()},getReadyState:function(){return e.getReadyState()},getPlaybackRate:function(){return e.getPlaybackRate()},getIsPaused:function(){return e.getIsPaused()},getReference:function(){return r},listen:function(e,t){var i;n.isCancelled()||!0===(null===(i=null==t?void 0:t.clearSignal)||void 0===i?void 0:i.isCancelled())||r.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},deriveReadOnlyObserver:function(e){return dv(this,e,n)}}}var cv=function(){function e(e,t){this._last=e,this._wanted=t}var t=e.prototype;return t.serialize=function(){return[this._last,this._wanted]},t.getPolled=function(){return this._last},t.getWanted=function(){var e;return null!==(e=this._wanted)&&void 0!==e?e:this._last},t.forceWantedPosition=function(e){this._wanted=e},t.isAwaitingFuturePosition=function(){return null!==this._wanted},e}(),fv=["canplay","ended","play","pause","seeking","seeked","loadedmetadata","ratechange"],vv=function(){function e(e,t){var n=this;this._internalSeeksIncoming=[],this._mediaElement=e,this._withMediaSource=t.withMediaSource,this._lowLatencyMode=t.lowLatencyMode,this._canceller=new Z,this._observationRef=this._createSharedReference(),this._expectedSeekingPosition=null,this._pendingSeek=null;var r=function(){if(null!==n._pendingSeek){var e=n._pendingSeek;n._pendingSeek=null,n._actuallySetCurrentTime(e)}};e.addEventListener("loadedmetadata",r),this._canceller.signal.register((function(){e.removeEventListener("loadedmetadata",r)}))}var t=e.prototype;return t.stop=function(){this._canceller.cancel()},t.getCurrentTime=function(){return this._mediaElement.currentTime},t.getPlaybackRate=function(){return this._mediaElement.playbackRate},t.getIsPaused=function(){return this._mediaElement.paused},t.setCurrentTime=function(e){this._mediaElement.readyState>=1?this._actuallySetCurrentTime(e):(this._internalSeeksIncoming=[],this._pendingSeek=e,this._generateObservationForEvent("manual"))},t.setPlaybackRate=function(e){this._mediaElement.playbackRate=e},t.getReadyState=function(){return this._mediaElement.readyState},t.getReference=function(){return this._observationRef},t.listen=function(e,t){var n;if(this._canceller.isUsed()||!0===(null===(n=null==t?void 0:t.clearSignal)||void 0===n?void 0:n.isCancelled()))return S;this._observationRef.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},t.deriveReadOnlyObserver=function(e){return dv(this,e,this._canceller.signal)},t._actuallySetCurrentTime=function(e){T.info("API: Seeking internally",e),this._internalSeeksIncoming.push(e),this._mediaElement.currentTime=e},t._createSharedReference=function(){var e=this;if(void 0!==this._observationRef)return this._observationRef;var t,n=b.getCurrent(),r=n.SAMPLING_INTERVAL_MEDIASOURCE,i=n.SAMPLING_INTERVAL_LOW_LATENCY,a=n.SAMPLING_INTERVAL_NO_MEDIASOURCE,o=new G(this._getCurrentObservation("init"),this._canceller.signal);t=this._lowLatencyMode?i:this._withMediaSource?r:a;var s=function(){e._generateObservationForEvent("timeupdate")},u=setInterval(s,t),l=fv.map((function(n){var r=function(){clearInterval(u),u=setInterval(s,t),e._generateObservationForEvent(n)};return e._mediaElement.addEventListener(n,r),function(){e._mediaElement.removeEventListener(n,r)}}));return this._canceller.signal.register((function(){clearInterval(u),l.forEach((function(e){return e()})),o.finish()})),o},t._getCurrentObservation=function(e){var t,n,r=e,i=void 0===this._observationRef?function(e){var t=hv(e);return m(t,{rebuffering:null,event:"init",seeking:0,position:new cv(t.position,null),freezing:null,bufferGap:0,currentRange:null})}(this._mediaElement):this._observationRef.getValue(),a=!1,o=this._pendingSeek,s=hv(this._mediaElement),u=s.buffered,l=s.readyState,d=s.position,c=s.seeking;if("seeking"===r)if(this._internalSeeksIncoming.length>0){a=!0,r="internal-seeking";var f=this._internalSeeksIncoming.shift();this._expectedSeekingPosition=lv?Math.max(d,null!=f?f:0):d}else this._expectedSeekingPosition=d;else c?this._expectedSeekingPosition=Math.max(d,null!==(t=this._expectedSeekingPosition)&&void 0!==t?t:0):lv&&null!==this._expectedSeekingPosition&&d<this._expectedSeekingPosition?o=this._expectedSeekingPosition:this._expectedSeekingPosition=null;c&&1===i.seeking&&"seeking"!==e&&(a=!0);var v,p,h=null!==(n=this._expectedSeekingPosition)&&void 0!==n?n:d;!this._withMediaSource&&0===u.length&&l>=3?(v=void 0,p=void 0):p=null!==(v=P(u,h))?v.end-h:1/0;var g,y=function(e){var t,n,r=e.previousObservation,i=e.currentObservation,a=e.basePosition,o=e.observationEvent,s=e.withMediaSource,u=e.lowLatencyMode,l=e.bufferGap,d=e.currentRange,c=b.getCurrent().REBUFFERING_GAP,f=i.position,v=i.duration,p=i.paused,h=i.readyState,m=i.ended,g=r.rebuffering,y=r.event,_=r.position,S=function(e,t,n,r,i){var a=b.getCurrent().REBUFFERING_GAP,o=i?"LOW_LATENCY":"DEFAULT";if(void 0===t)return n&&Math.abs(r-e)<=a[o];return null!==t&&r-t.end<=a[o]}(a,d,m,v,u),E=h>=1&&"loadedmetadata"!==o&&null===g&&!(S||m),T=null,k=u?c.LOW_LATENCY:c.DEFAULT;if(s){if(E)l===1/0?(t=!0,T=a):void 0===l?h<3&&(t=!0,T=void 0):l<=k&&(t=!0,T=a+l);else if(null!==g){var w=pv(g,u);!0!==t&&null!==g&&h>1&&(S||m||void 0!==l&&isFinite(l)&&l>w)||void 0===l&&h>=3?n=!0:void 0===l?T=void 0:l===1/0?T=a:l<=w&&(T=a+l)}}else E&&(!p&&"timeupdate"===o&&"timeupdate"===y&&f===_.getPolled()||"seeking"===o&&(l===1/0||void 0===l&&h<3))?t=!0:null!==g&&("seeking"!==o&&f!==_.getPolled()||"canplay"===o||void 0===l&&h>=3||void 0!==l&&l<1/0&&(l>pv(g,u)||S||m))&&(n=!0);if(!0===n)return null;var A;if(!0===t||null!==g)return A="seeking"===o||null!==g&&"seeking"===g.reason||i.seeking?"seeking":1===h?"not-ready":"buffering",null!==g&&g.reason===A?{reason:g.reason,timestamp:g.timestamp,position:T}:{reason:A,timestamp:ne(),position:T};return null}({previousObservation:i,currentObservation:s,basePosition:h,observationEvent:r,lowLatencyMode:this._lowLatencyMode,withMediaSource:this._withMediaSource,bufferGap:p,currentRange:v}),_=function(e,t,n,r){var i=b.getCurrent().MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING;if(e.freezing)return t.ended||t.paused||0===t.readyState||0===t.playbackRate||e.position.getPolled()!==t.position?null:e.freezing;return"timeupdate"===n&&void 0!==r&&r>i&&!t.ended&&!t.paused&&t.readyState>=1&&0!==t.playbackRate&&t.position===e.position.getPolled()?{timestamp:ne()}:null}(i,s,r,p);g=a?1:c?2:0;var S=m({},s,{position:new cv(s.position,o),event:r,seeking:g,rebuffering:y,freezing:_,bufferGap:p,currentRange:v});return T.hasLevel("DEBUG")&&T.debug("API: current media element state tick","event",S.event,"position",S.position.getPolled(),"seeking",S.seeking,"internalSeek",a,"rebuffering",null!==S.rebuffering,"freezing",null!==S.freezing,"ended",S.ended,"paused",S.paused,"playbackRate",S.playbackRate,"readyState",S.readyState,"pendingPosition",o),S},t._generateObservationForEvent=function(e){var t=this._getCurrentObservation(e);T.hasLevel("DEBUG")&&T.debug("API: current playback timeline:\n"+function(e,t){for(var n="",r="",i=0;i<e.length;i++){var a=e.start(i),o=e.end(i),s=a.toFixed(2),u=o.toFixed(2),l=s+"|=="+(o-a).toFixed(2)+"==|"+u;if(n+=l,0===r.length&&o>t){var d=n.length-Math.floor(l.length/2);r=" ".repeat(d)+"^"+t}if(i<e.length-1){var c=e.start(i+1),f=" ~"+(c-o).toFixed(2)+"~ ";if(n+=f,0===r.length&&t<c){var v=n.length-Math.floor(f.length/2);r=" ".repeat(v)+"^"+t}}}0===r.length&&(r=" ".repeat(n.length)+"^"+t);return n+"\n"+r}(t.buffered,t.position.getPolled()),"\n"+e),this._observationRef.setValue(t)},e}();function pv(e,t){if(null===e)return 0;var n=t?"LOW_LATENCY":"DEFAULT",r=b.getCurrent(),i=r.RESUME_GAP_AFTER_SEEKING,a=r.RESUME_GAP_AFTER_NOT_ENOUGH_DATA,o=r.RESUME_GAP_AFTER_BUFFERING;switch(e.reason){case"seeking":return i[n];case"not-ready":return a[n];case"buffering":return o[n]}}function hv(e){return{buffered:e.buffered,position:e.currentTime,duration:e.duration,ended:e.ended,paused:e.paused,playbackRate:e.playbackRate,readyState:e.readyState,seeking:e.seeking}}function mv(e){return gv.apply(this,arguments)}function gv(){return(gv=d(p().mark((function e(t){var n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==(n=Tr.getState(t))){e.next=3;break}return e.abrupt("return",void 0);case 3:return T.info("DRM: Disposing of the current MediaKeys"),r=n.loadedSessionsStore,Tr.clearState(t),e.next=8,r.closeAllSessions();case 8:return e.abrupt("return",Promise.race([n.emeImplementation.setMediaKeys(t,null).catch((function(e){T.error("DRM: Could not reset MediaKeys",e instanceof Error?e:"Unknown Error")})),Wn(1e3)]));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yv(e){if(T.info("DRM: Clearing-up DRM session."),vi)return T.info("DRM: disposing current MediaKeys."),mv(e);var t=Tr.getState(e);return null!==t&&!0===t.keySystemOptions.closeSessionsOnStop?(T.info("DRM: closing all current sessions."),t.loadedSessionsStore.closeAllSessions()):(T.info("DRM: Nothing to clear. Returning right away. No state =",null===t),Promise.resolve())}var _v=function(e){function t(t){var n;return(n=e.call(this)||this)._canceller=new Z,n._adaptationRef=t,n._updateToken=!1,n.refresh=S,n}f(t,e);var n=t.prototype;return n.start=function(e){if(this._updateToken=!0,null===e)return this._lastEmitted=null,this._updateToken=!1,void this._adaptationRef.setValue(null);var t=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:e.adaptation,switchingMode:e.switchingMode,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:e.adaptation.id,switchingMode:e.switchingMode,representations:t,relativeResumingPosition:void 0}))},n.updateTrack=function(e){if(this._updateToken=!0,null===e){if(null===this._lastEmitted)return;return this._updateToken=!1,this._canceller.cancel(),this._canceller=new Z,this._lastEmitted=null,void this._adaptationRef.setValue(null)}var t=e.adaptation,n=e.switchingMode,r=e.relativeResumingPosition;this._canceller.cancel(),this._canceller=new Z;var i=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:t,switchingMode:n,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:t.id,switchingMode:n,representations:i,relativeResumingPosition:r}))},n._constructLockedRepresentationsReference=function(e){var t=new G({representationIds:[],switchingMode:"lazy"}),n=this;return this.refresh=r,this._canceller.signal.register((function(){n.refresh=S})),e.lockedRepresentations.onUpdate(r,{clearSignal:this._canceller.signal,emitCurrentValue:!1}),r(),t;function r(){var r,i,a=e.lockedRepresentations.getValue();if(null===a)i=e.adaptation.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})),r="lazy";else{var o=a.representationIds;if(r=a.switchingMode,0===(i=e.adaptation.representations.filter((function(e){return Ue(o,e.id)})).filter((function(e){return!0===e.isSupported&&!1!==e.decipherable}))).length)return void n.trigger("noPlayableLockedRepresentation",null)}if(i.length<=0)return e.adaptation.isSupported=!1,void n.trigger("noPlayableRepresentation",null);var s=t.getValue(),u=i.map((function(e){return e.id})).slice().sort();if(u.length===s.representationIds.length){for(var l=0;l<u.length;l++)if(s.representationIds[l]!==u[l])return void t.setValue({representationIds:u,switchingMode:r})}else t.setValue({representationIds:u,switchingMode:r})}},n.dispose=function(){this.removeEventListener(),this._canceller.cancel(),this._adaptationRef.finish()},t}(i);function bv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Sv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Sv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Sv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ev=function(e){function n(t){var n,r;return(n=e.call(this)||this)._storedPeriodInfo=[],n._isDisposed=!1,n._cachedPeriodInfo=new WeakMap,n._isTrickModeTrackEnabled=t.preferTrickModeTracks,n._defaultAudioTrackSwitchingMode=null!==(r=t.defaultAudioTrackSwitchingMode)&&void 0!==r?r:b.getCurrent().DEFAULT_AUDIO_TRACK_SWITCHING_MODE,n}f(n,e);var r=n.prototype;return r.getAvailablePeriods=function(){return this._storedPeriodInfo.reduce((function(e,t){return t.isPeriodAdvertised&&e.push(Iv(t.period)),e}),[])},r.onManifestUpdate=function(e){for(var t,n,r,i,a,o,s,u=this,l=b.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=e.periods,c=[],f=0,v=function(e){var i=u._storedPeriodInfo[e].period,a=d[f];if(void 0===a)for(var o=u._storedPeriodInfo.length-1;o>=e;o--)u._storedPeriodInfo[o].inManifest=!1,kv(u._storedPeriodInfo[o])&&u._removePeriodObject(o);else if(i===a){f++;var s=u._storedPeriodInfo[e].text.storedSettings;if(null!==s)if(!Ge(a,"text").some((function(e){return e.id===s.adaptation.id}))){T.warn("TS: Chosen text Adaptation not available anymore");var v=u._storedPeriodInfo[e];if(v.text.storedSettings=null,u.trigger("trackUpdate",{period:Iv(a),trackType:"text",reason:"missing"}),u._isDisposed)return{v:void 0};var h=Tv(u._storedPeriodInfo,v.period.id);void 0!==h&&null===h.text.storedSettings&&(null===(t=h.text.dispatcher)||void 0===t||t.updateTrack(null))}var m=u._storedPeriodInfo[e].video.storedSettings;if(null!==m){var g=Ge(a,"video");if(!g.some((function(e){return e.id===m.adaptation.id}))){T.warn("TS: Chosen video Adaptation not available anymore");var y,_=u._storedPeriodInfo[e];if(0===g.length)y=null;else{var b=g[0],S=wv(b,u._isTrickModeTrackEnabled),E=new G(null);y={adaptationBase:b,adaptation:S,switchingMode:l,lockedRepresentations:E}}if(_.video.storedSettings=y,u.trigger("trackUpdate",{period:Iv(a),trackType:"video",reason:"missing"}),u._isDisposed)return{v:void 0};var k=Tv(u._storedPeriodInfo,_.period.id);void 0!==k&&k.video.storedSettings===y&&(null===(n=k.video.dispatcher)||void 0===n||n.updateTrack(y))}}var w=u._storedPeriodInfo[e].audio.storedSettings;if(null!==w){var A=Ge(a,"audio");if(!A.some((function(e){return e.id===w.adaptation.id}))){T.warn("TS: Chosen audio Adaptation not available anymore");var I=u._storedPeriodInfo[e],R=0===A.length?null:{adaptation:A[0],switchingMode:u._defaultAudioTrackSwitchingMode,lockedRepresentations:new G(null)};if(I.audio.storedSettings=R,u.trigger("trackUpdate",{period:Iv(a),trackType:"audio",reason:"missing"}),u._isDisposed)return{v:void 0};var x=Tv(u._storedPeriodInfo,I.period.id);void 0!==x&&x.audio.storedSettings===R&&(null===(r=x.audio.dispatcher)||void 0===r||r.updateTrack(R))}}}else if(i.start<=a.start)u._storedPeriodInfo[e].inManifest=!1,kv(u._storedPeriodInfo[e])&&(u._removePeriodObject(e),e--);else{var C=Av(a,!0,u._isTrickModeTrackEnabled,u._defaultAudioTrackSwitchingMode);u._storedPeriodInfo.splice(e,0,C),c.push(C),f++}p=e},p=0;p<this._storedPeriodInfo.length;p++)if(s=v(p))return s.v;if(f<d.length){var h,m=d.slice(f).map((function(e){return Av(e,!0,u._isTrickModeTrackEnabled,u._defaultAudioTrackSwitchingMode)}));(h=this._storedPeriodInfo).push.apply(h,m),c.push.apply(c,m)}for(var g,y=bv(this._storedPeriodInfo);!(g=y()).done;){var _=g.value;null===(i=_.audio.dispatcher)||void 0===i||i.refresh(),null===(a=_.video.dispatcher)||void 0===a||a.refresh(),null===(o=_.text.dispatcher)||void 0===o||o.refresh()}},r.onDecipherabilityUpdates=function(){for(var e,t,n,r,i=bv(this._storedPeriodInfo);!(r=i()).done;){var a=r.value;null===(e=a.audio.dispatcher)||void 0===e||e.refresh(),null===(t=a.video.dispatcher)||void 0===t||t.refresh(),null===(n=a.text.dispatcher)||void 0===n||n.refresh()}},r.addTrackReference=function(e,n,r){var i=this,a=Tv(this._storedPeriodInfo,n.id);if(void 0===a){a=Av(n,!1,this._isTrickModeTrackEnabled,this._defaultAudioTrackSwitchingMode);for(var o=!1,s=0;s<this._storedPeriodInfo.length;s++)this._storedPeriodInfo[s].period.start>n.start&&(this._storedPeriodInfo.splice(s,0,a),o=!0);o||this._storedPeriodInfo.push(a)}if(a.isPeriodAdvertised||(a.isPeriodAdvertised=!0,this.trigger("newAvailablePeriods",[{id:n.id,start:n.start,end:n.end}]),!this._isDisposed))if(null===a[e].dispatcher){var u=a[e].storedSettings,l=new _v(r);a[e].dispatcher=l,l.addEventListener("noPlayableRepresentation",(function(){var r,a,o,s,u=ae(null!==(r=n.adaptations[e])&&void 0!==r?r:[],(function(e){return!1!==e.isSupported&&e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})).length>0}));if(void 0===u){var l=new Me("NO_PLAYABLE_REPRESENTATION","No "+e+" Representation can be played",{tracks:void 0});return i.trigger("error",l),void i.dispose()}var d=null===(a=Tv(i._storedPeriodInfo,n.id))||void 0===a?void 0:a[e];if(!t(d)){var c={adaptation:u,switchingMode:"audio"===e?i._defaultAudioTrackSwitchingMode:"reload",lockedRepresentations:new G(null)};d.storedSettings=c,i.trigger("trackUpdate",{period:Iv(n),trackType:e,reason:"no-playable-representation"}),i._isDisposed||t(d=null===(o=Tv(i._storedPeriodInfo,n.id))||void 0===o?void 0:o[e])||d.storedSettings!==c||null===(s=d.dispatcher)||void 0===s||s.updateTrack(c)}})),l.addEventListener("noPlayableLockedRepresentation",(function(){null==u||u.lockedRepresentations.setValue(null),i.trigger("brokenRepresentationsLock",{period:{id:n.id,start:n.start,end:n.end},trackType:e})})),l.start(u)}else T.error("TS: Subject already added for "+e+" and Period "+n.start)},r.removeTrackReference=function(e,t){var n=function(e,t){for(var n=0;n<e.length;n++){if(e[n].period.id===t.id)return n}}(this._storedPeriodInfo,t);if(void 0!==n){var r=this._storedPeriodInfo[n],i=r[e];null!==(null==i?void 0:i.dispatcher)?(i.dispatcher.dispose(),i.dispatcher=null,kv(r)&&this._removePeriodObject(n)):T.warn("TS: TrackDispatcher already removed for "+e+" and Period "+t.start)}else T.warn("TS: "+e+" not found for period",t.start)},r.getPeriodObjectFromPeriod=function(e){var t=Tv(this._storedPeriodInfo,e.id);return void 0===t&&void 0!==e?this._cachedPeriodInfo.get(e):t},r.getPeriodObjectFromId=function(e){return Tv(this._storedPeriodInfo,e)},r.disableVideoTrickModeTracks=function(){this._isTrickModeTrackEnabled&&(this._isTrickModeTrackEnabled=!1,this._resetVideoTrackChoices("trickmode-disabled"))},r.enableVideoTrickModeTracks=function(){this._isTrickModeTrackEnabled||(this._isTrickModeTrackEnabled=!0,this._resetVideoTrackChoices("trickmode-enabled"))},r.resetPeriodObjects=function(){for(var e,t,n,r=this._storedPeriodInfo.length-1;r>=0;r--){var i=this._storedPeriodInfo[r];null===(e=i.audio.dispatcher)||void 0===e||e.dispose(),i.audio.dispatcher=null,null===(t=i.video.dispatcher)||void 0===t||t.dispose(),i.video.dispatcher=null,null===(n=i.text.dispatcher)||void 0===n||n.dispose(),i.text.dispatcher=null,i.inManifest||this._removePeriodObject(r)}},r.isTrickModeEnabled=function(){return this._isTrickModeTrackEnabled},r.setAudioTrack=function(e){var t=e.periodRef,n=e.trackId,r=e.switchingMode,i=e.lockedRepresentations,a=e.relativeResumingPosition;return this._setAudioOrTextTrack({bufferType:"audio",periodRef:t,trackId:n,switchingMode:null!=r?r:this._defaultAudioTrackSwitchingMode,lockedRepresentations:i,relativeResumingPosition:a})},r.setTextTrack=function(e,t){return this._setAudioOrTextTrack({bufferType:"text",periodRef:e,trackId:t,switchingMode:"direct",lockedRepresentations:null,relativeResumingPosition:void 0})},r._setAudioOrTextTrack=function(e){var t,n,r=e.bufferType,i=e.periodRef,a=e.trackId,o=e.switchingMode,s=e.lockedRepresentations,u=e.relativeResumingPosition,l=i.period,d=ae(null!==(t=l.adaptations[r])&&void 0!==t?t:[],(function(e){var t=e.id;return!0===e.isSupported&&t===a}));if(void 0===d)throw new Error("Wanted "+r+" track not found.");var c,f=i[r];if(null===s)c=new G(null);else{var v=this._getRepresentationsToLock(d,s),p="audio"===r?this._defaultAudioTrackSwitchingMode:"direct";c=new G({representationIds:v,switchingMode:p})}var h={adaptation:d,switchingMode:o,lockedRepresentations:c,relativeResumingPosition:u};if(f.storedSettings=h,this.trigger("trackUpdate",{period:Iv(l),trackType:r,reason:"manual"}),!this._isDisposed){var m=Tv(this._storedPeriodInfo,l.id);void 0!==m&&m[r].storedSettings===h&&(null===(n=m[r].dispatcher)||void 0===n||n.updateTrack(h))}},r.setVideoTrack=function(e){var t,n,r=e.periodRef,i=e.trackId,a=e.switchingMode,o=e.lockedRepresentations,s=e.relativeResumingPosition,u=r.period,l=ae(null!==(t=u.adaptations.video)&&void 0!==t?t:[],(function(e){var t=e.id;return!0===e.isSupported&&t===i}));if(void 0===l)throw new Error("Wanted video track not found.");var d,c=b.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,f=r.video,v=wv(l,this._isTrickModeTrackEnabled);if(null===o)d=new G(null);else{var p=this._getRepresentationsToLock(l,o);d=new G({representationIds:p,switchingMode:c})}var h={adaptationBase:l,switchingMode:null!=a?a:c,adaptation:v,relativeResumingPosition:s,lockedRepresentations:d};if(f.storedSettings=h,this.trigger("trackUpdate",{period:Iv(u),trackType:"video",reason:"manual"}),!this._isDisposed){var m=Tv(this._storedPeriodInfo,u.id);void 0!==m&&m.video.storedSettings===h&&(null===(n=m.video.dispatcher)||void 0===n||n.updateTrack(h))}},r.disableTrack=function(e,t){var n,r,i=e[t];if(null!==i.storedSettings&&("text"!==t&&(null===(n=e[t].storedSettings)||void 0===n||n.lockedRepresentations.finish()),i.storedSettings=null,this.trigger("trackUpdate",{period:Iv(e.period),trackType:t,reason:"manual"}),!this._isDisposed)){var a=Tv(this._storedPeriodInfo,e.period.id);void 0!==a&&null===a[t].storedSettings&&(null===(r=a[t].dispatcher)||void 0===r||r.updateTrack(null))}},r.getChosenAudioTrack=function(e){return null===e.audio.storedSettings?null:Ye(e.audio.storedSettings.adaptation,!0)},r.getChosenTextTrack=function(e){return null===e.text.storedSettings?null:Qe(e.text.storedSettings.adaptation)},r.getChosenVideoTrack=function(e){return null===e.video.storedSettings?null:$e(e.video.storedSettings.adaptation,!0)},r.getAvailableAudioTracks=function(e){var t=e.audio.storedSettings,n=null!==t?t.adaptation.id:null;return Ge(e.period,"audio").map((function(e){var t=null!==n&&n===e.id;return m(Ye(e,!0),{active:t})}))},r.getAvailableTextTracks=function(e){var t=e.text.storedSettings,n=null!==t?t.adaptation.id:null;return Ge(e.period,"text").map((function(e){var t=null!==n&&n===e.id;return m(Qe(e),{active:t})}))},r.getAvailableVideoTracks=function(e){var t=e.video.storedSettings,n=null===t?void 0:t.adaptation.id;return Ge(e.period,"video").map((function(e){var t=null!==n&&n===e.id,r=$e(e,!0),i=void 0!==r.trickModeTracks?r.trickModeTracks.map((function(e){var t=null!==n&&n===e.id;return m(e,{active:t})})):[],a=m(r,{active:t});return void 0!==i&&(a.trickModeTracks=i),a}))},r.getLockedAudioRepresentations=function(e){var t=e.audio.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representationIds},r.getLockedVideoRepresentations=function(e){var t=e.video.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representationIds},r.lockAudioRepresentations=function(e,t){var n,r=e.audio.storedSettings;if(null!==r){var i=b.getCurrent().DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representationIds:a,switchingMode:o})}},r.lockVideoRepresentations=function(e,t){var n,r=e.video.storedSettings;if(null!==r){var i=b.getCurrent().DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representationIds:a,switchingMode:o})}},r.unlockAudioRepresentations=function(e){var t=e.audio.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.unlockVideoRepresentations=function(e){var t=e.video.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.dispose=function(){for(this._isDisposed=!0;;){var e=this._storedPeriodInfo.pop();if(void 0===e)return;e.isRemoved=!0}},r._resetVideoTrackChoices=function(e){for(var t,n=0;n<this._storedPeriodInfo.length;n++){var r=this._storedPeriodInfo[n];if(null!==r.video.storedSettings){var i=r.video.storedSettings.adaptationBase;if(null!==i){var a=wv(i,this._isTrickModeTrackEnabled);r.video.storedSettings.adaptationBase=i,r.video.storedSettings.adaptation=a}}}for(var o=this._storedPeriodInfo.slice(),s=0;s<o.length;s++){var u=o[s].period,l=o[s].video.storedSettings;if(this.trigger("trackUpdate",{period:Iv(u),trackType:"video",reason:e}),this._isDisposed)return;var d=Tv(this._storedPeriodInfo,u.id);void 0!==d&&d.video.storedSettings===l&&(null===(t=d.video.dispatcher)||void 0===t||t.updateTrack(l))}},r._removePeriodObject=function(e){var t=this._storedPeriodInfo[e];this._storedPeriodInfo[e].isRemoved=!0,this._storedPeriodInfo.splice(e,1),this._cachedPeriodInfo.set(t.period,t)},r._getRepresentationsToLock=function(e,t){var n=t.reduce((function(t,n){var r=ae(e.representations,(function(e){return e.id===n}));return void 0===r?T.warn("API: Wanted locked Representation not found."):t.push(r.id),t}),[]);if(0===n.length)throw new Error("Cannot lock Representations: None of the given Representation id are found");return n},n}(i);function Tv(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.period.id===t)return r}}function kv(e){var t,n,r;return!e.inManifest&&null===(null===(t=e.text)||void 0===t?void 0:t.dispatcher)&&null===(null===(n=e.audio)||void 0===n?void 0:n.dispatcher)&&null===(null===(r=e.video)||void 0===r?void 0:r.dispatcher)}function wv(e,t){var n;return t&&void 0!==(null===(n=e.trickModeTracks)||void 0===n?void 0:n[0])?e.trickModeTracks[0]:e}function Av(e,t,n,r){var i,a,o=Ge(e,"audio")[0],s=Ge(e,"video")[0],u=wv(s,n),l=b.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=void 0!==o?{adaptation:o,switchingMode:r,lockedRepresentations:new G(null)}:null,c=void 0!==u?{adaptation:u,adaptationBase:s,switchingMode:l,lockedRepresentations:new G(null)}:null,f=null,v=(null!==(i=e.adaptations.text)&&void 0!==i?i:[]).filter((function(e){return!0===e.isForcedSubtitles}));if(v.length>0){if(null!=o){var p=ae(v,(function(e){return e.normalizedLanguage===o.normalizedLanguage}));void 0!==p&&(f=p)}null===f&&(f=null!==(a=ae(v,(function(e){return void 0===e.normalizedLanguage})))&&void 0!==a?a:null)}var h=null;return null!==f&&(h={adaptation:f,switchingMode:"direct",lockedRepresentations:new G(null)}),{period:e,inManifest:t,isPeriodAdvertised:!1,isRemoved:!1,audio:{storedSettings:d,dispatcher:null},video:{storedSettings:c,dispatcher:null},text:{storedSettings:h,dispatcher:null}}}function Iv(e){return{start:e.start,end:e.end,id:e.id}}var Rv=Ev;function xv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Cv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Cv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Mv(e,n){var r=b.getCurrent().FORCED_ENDED_THRESHOLD;if(e.ended)return"ENDED";if(null!==n){var i=Math.abs(e.duration-e.currentTime);return!t(r)&&i<r?"ENDED":"seeking"===n?"SEEKING":"freezing"===n?"FREEZING":"BUFFERING"}return e.paused?"PAUSED":"PLAYING"}function Pv(e){return"LOADING"!==e&&"RELOADING"!==e&&"STOPPED"!==e}function Dv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ov(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ov(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ov(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Nv=Le(),Lv=["manifestLoader","segmentLoader"],Uv=function(n){function r(e){var r;void 0===e&&(e={}),r=n.call(this)||this;var i=function(e){var n,r,i,a,o,s,u=b.getCurrent(),l=u.DEFAULT_BASE_BANDWIDTH,d=u.DEFAULT_VIDEO_RESOLUTION_LIMIT,c=u.DEFAULT_MAX_BUFFER_AHEAD,f=u.DEFAULT_MAX_BUFFER_BEHIND,v=u.DEFAULT_MAX_VIDEO_BUFFER_SIZE,p=u.DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN,h=u.DEFAULT_WANTED_BUFFER_AHEAD;if(t(e.maxBufferAhead))n=c;else if(n=Number(e.maxBufferAhead),isNaN(n))throw new Error("Invalid maxBufferAhead parameter. Should be a number.");if(t(e.maxBufferBehind))r=f;else if(r=Number(e.maxBufferBehind),isNaN(r))throw new Error("Invalid maxBufferBehind parameter. Should be a number.");if(t(e.wantedBufferAhead))i=h;else if(i=Number(e.wantedBufferAhead),isNaN(i))throw new Error("Invalid wantedBufferAhead parameter. Should be a number.");if(t(e.maxVideoBufferSize))a=v;else if(a=Number(e.maxVideoBufferSize),isNaN(a))throw new Error("Invalid maxVideoBufferSize parameter. Should be a number.");var m=t(e.videoResolutionLimit)?d:e.videoResolutionLimit,g=t(e.throttleVideoBitrateWhenHidden)?p:!!e.throttleVideoBitrateWhenHidden;if(t(e.videoElement))o=document.createElement("video");else{if(!(e.videoElement instanceof HTMLMediaElement))throw new Error("Invalid videoElement parameter. Should be a HTMLMediaElement.");o=e.videoElement}if(t(e.baseBandwidth))s=l;else if(s=Number(e.baseBandwidth),isNaN(s))throw new Error("Invalid baseBandwidth parameter. Should be a number.");return{maxBufferAhead:n,maxBufferBehind:r,videoResolutionLimit:m,videoElement:o,wantedBufferAhead:i,maxVideoBufferSize:a,throttleVideoBitrateWhenHidden:g,baseBandwidth:s}}(e),a=i.baseBandwidth,o=i.videoResolutionLimit,s=i.maxBufferAhead,u=i.maxBufferBehind,l=i.throttleVideoBitrateWhenHidden,d=i.videoElement,c=i.wantedBufferAhead,f=i.maxVideoBufferSize;d.preload="auto",r.version="4.0.0-dev.2024022600",r.log=T,r.state="STOPPED",r.videoElement=d;var v=new Z;r._destroyCanceller=v,r._priv_pictureInPictureRef=function(e,t){var n=e;if(!0===n.webkitSupportsPresentationMode&&"function"==typeof n.webkitSetPresentationMode){var r="picture-in-picture"===n.webkitPresentationMode,i=new G({isEnabled:r,pipWindow:null},t);return $r(n,"webkitpresentationmodechanged",(function(){var e="picture-in-picture"===n.webkitPresentationMode;i.setValue({isEnabled:e,pipWindow:null})}),t),i}var a=document.pictureInPictureElement===n,o=new G({isEnabled:a,pipWindow:null},t);return $r(n,"enterpictureinpicture",(function(e){var t;o.setValue({isEnabled:!0,pipWindow:null!==(t=e.pictureInPictureWindow)&&void 0!==t?t:null})}),t),$r(n,"leavepictureinpicture",(function(){o.setValue({isEnabled:!1,pipWindow:null})}),t),o}(d,v.signal),r._priv_speed=new G(d.playbackRate,r._destroyCanceller.signal),r._priv_preferTrickModeTracks=!1,r._priv_contentLock=new G(!1,r._destroyCanceller.signal),r._priv_bufferOptions={wantedBufferAhead:new G(c,r._destroyCanceller.signal),maxBufferAhead:new G(s,r._destroyCanceller.signal),maxBufferBehind:new G(u,r._destroyCanceller.signal),maxVideoBufferSize:new G(f,r._destroyCanceller.signal)},r._priv_bitrateInfos={lastBitrates:{audio:a,video:a}},r._priv_throttleVideoBitrateWhenHidden=l,r._priv_videoResolutionLimit=o,r._priv_currentError=null,r._priv_contentInfos=null,r._priv_contentEventsMemory={},r._priv_reloadingMetadata={},r._priv_lastAutoPlay=!1,r._priv_worker=null;var p=function(){r.trigger("volumeChange",{volume:d.volume,muted:d.muted})};return d.addEventListener("volumechange",p),v.signal.register((function(){d.removeEventListener("volumechange",p)})),r}f(r,n),r.addFeatures=function(e){!function(e){for(var n=0;n<e.length;n++){var r=e[n];if("function"==typeof r)r(at);else{if(t(r)||"function"!=typeof r._addFeature)throw new Error("Unrecognized feature");r._addFeature(at)}}}(e)};var i=r.prototype;return i.attachWorker=function(t){var n=this;return new Promise((function(r,i){var a;if("function"!=typeof Worker)return T.warn("API: Cannot rely on a WebWorker: Worker API unavailable"),i(new uv("INCOMPATIBLE_ERROR","Worker unavailable"));if(!sv)return T.warn("API: Cannot rely on a WebWorker: WebAssembly unavailable"),i(new uv("INCOMPATIBLE_ERROR","WebAssembly unavailable"));if("string"==typeof t.workerUrl)n._priv_worker=new Worker(t.workerUrl);else{var o=URL.createObjectURL(t.workerUrl);n._priv_worker=new Worker(o),URL.revokeObjectURL(o)}n._priv_worker.onerror=function(e){null!==n._priv_worker&&(n._priv_worker.terminate(),n._priv_worker=null),T.error("API: Unexpected worker error",e.error instanceof Error?e.error:void 0),i(new uv("UNKNOWN_ERROR",'Unexpected Worker "error" event'))};n._priv_worker.addEventListener("message",(function e(t){var a=t.data;"init-error"===a.type?(T.warn("API: Processing InitError worker message: detaching worker"),null!==n._priv_worker&&(n._priv_worker.removeEventListener("message",e),n._priv_worker.terminate(),n._priv_worker=null),i(new uv("SETUP_ERROR","Worker parser initialization failed: "+a.value.errorMessage))):"init-success"===a.type&&(T.info("API: InitSuccess received from worker."),null!==n._priv_worker&&n._priv_worker.removeEventListener("message",e),r())})),T.debug("---\x3e Sending To Worker:","init"),n._priv_worker.postMessage({type:"init",value:{dashWasmUrl:t.dashWasmUrl,logLevel:T.getLevel(),sendBackLogs:e(),date:Date.now(),timestamp:ne(),hasVideo:"video"===(null===(a=n.videoElement)||void 0===a?void 0:a.nodeName.toLowerCase()),hasMseInWorker:ov}}),T.addEventListener("onLogLevelChange",(function(t){null!==n._priv_worker&&(T.debug("---\x3e Sending To Worker:","log-level-update"),n._priv_worker.postMessage({type:"log-level-update",value:{logLevel:t,sendBackLogs:e()}}))}),n._destroyCanceller.signal)}))},i.getCurrentModeInformation=function(){return null===this._priv_contentInfos?null:{isDirectFile:this._priv_contentInfos.isDirectFile,useWorker:this._priv_contentInfos.useWorker}},i.addEventListener=function(e,t){return n.prototype.addEventListener.call(this,e,t)},i.stop=function(){null!==this._priv_contentInfos&&this._priv_contentInfos.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),"STOPPED"!==this.state&&this._priv_setPlayerState("STOPPED")},i.dispose=function(){this.stop(),null!==this.videoElement&&mv(this.videoElement).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";T.error("API: Could not dispose decryption resources: "+t)})),this._destroyCanceller.cancel(),this._priv_reloadingMetadata={},this.videoElement=null,null!==this._priv_worker&&(this._priv_worker.terminate(),this._priv_worker=null)},i.loadVideo=function(e){var n=function(e){var n,r,i,a,o,s,u,l,d,c,f=b.getCurrent(),v=f.DEFAULT_AUTO_PLAY,p=f.DEFAULT_CODEC_SWITCHING_BEHAVIOR,h=f.DEFAULT_ENABLE_FAST_SWITCHING,g=f.DEFAULT_TEXT_TRACK_MODE;if(t(e))throw new Error("No option set on loadVideo");if(t(e.url)){if(t(e.initialManifest)&&t(e.manifestLoader))throw new Error("Unable to load a content: no url set on loadVideo.\nPlease provide at least either an `url` argument, a `initialManifest` option or a `manifestLoader` option so the RxPlayer can load the content.")}else a=String(e.url);if(t(e.transport))throw new Error("No transport set on loadVideo");o=String(e.transport);var y=t(e.autoPlay)?v:!!e.autoPlay;if(t(e.keySystems))s=[];else for(var _,S=xv(s=Array.isArray(e.keySystems)?e.keySystems:[e.keySystems]);!(_=S()).done;){var E=_.value;if("string"!=typeof E.type||"function"!=typeof E.getLicense)throw new Error("Invalid key system given: Missing type string or getLicense callback")}var k=void 0!==e.lowLatencyMode&&!!e.lowLatencyMode,w=e.initialManifest,A=null!==(n=e.minimumManifestUpdateInterval)&&void 0!==n?n:0,I=null!==(r=e.defaultAudioTrackSwitchingMode)&&void 0!==r?r:void 0;void 0===I||Ue(["seamless","direct","reload"],I)||(T.warn("The `defaultAudioTrackSwitchingMode` loadVideo option must match one of the following strategy name:\n- `seamless`\n- `direct`\n- `reload`"),I=void 0);var R=t(e.onCodecSwitch)?p:e.onCodecSwitch;if(Ue(["continue","reload"],R)||(T.warn("The `onCodecSwitch` loadVideo option must match one of the following string:\n- `continue`\n- `reload`\nIf badly set, "+p+" will be used as default"),R=p),t(e.textTrackMode))u=g;else{if("native"!==e.textTrackMode&&"html"!==e.textTrackMode)throw new Error("Invalid textTrackMode.");u=e.textTrackMode}if("html"===u){if(t(e.textTrackElement))throw new Error('You have to provide a textTrackElement in "html" textTrackMode.');if(!(e.textTrackElement instanceof HTMLElement))throw new Error("textTrackElement should be an HTMLElement.");d=e.textTrackElement}else t(e.textTrackElement)||T.warn('API: You have set a textTrackElement without being in an "html" textTrackMode. It will be ignored.');if(t(e.mode))l="auto";else{if(!Ue(["auto","multithread","main"],e.mode))throw new Error("Invalid `mode` option.");l=e.mode}var x=t(e.enableFastSwitching)?h:e.enableFastSwitching;if(!t(e.startAt))if("wallClockTime"in e.startAt&&e.startAt.wallClockTime instanceof Date){var C=e.startAt.wallClockTime.getTime()/1e3;c=m({},e.startAt,{wallClockTime:C})}else c=e.startAt;var M=null!==(i=e.requestConfig)&&void 0!==i?i:{};return{__priv_patchLastSegmentInSidx:e.__priv_patchLastSegmentInSidx,__priv_manifestUpdateUrl:e.__priv_manifestUpdateUrl,checkMediaSegmentIntegrity:e.checkMediaSegmentIntegrity,autoPlay:y,defaultAudioTrackSwitchingMode:I,enableFastSwitching:x,initialManifest:w,keySystems:s,lowLatencyMode:k,manifestLoader:e.manifestLoader,minimumManifestUpdateInterval:A,requestConfig:M,onCodecSwitch:R,referenceDateTime:e.referenceDateTime,representationFilter:e.representationFilter,segmentLoader:e.segmentLoader,serverSyncInfos:e.serverSyncInfos,startAt:c,textTrackElement:d,textTrackMode:u,transport:o,mode:l,url:a}}(e);T.info("API: Calling loadvideo",n.url,n.transport),this._priv_reloadingMetadata={options:n},this._priv_initializeContentPlayback(n),this._priv_lastAutoPlay=n.autoPlay},i.reload=function(e){var t,n,r,i,a,o,s=this._priv_reloadingMetadata,u=s.options,l=s.manifest,d=s.reloadPosition,c=s.reloadInPause;if(void 0===u)throw new Error("API: Can't reload without having previously loaded a content.");if(function(e){var t,n,r,i;if(null===e||"object"!=typeof e&&void 0!==e)throw new Error("API: reload - Invalid options format.");if(null===(null==e?void 0:e.reloadAt)||"object"!=typeof(null==e?void 0:e.reloadAt)&&void 0!==(null==e?void 0:e.reloadAt))throw new Error("API: reload - Invalid 'reloadAt' option format.");if("number"!=typeof(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position)&&void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.position))throw new Error("API: reload - Invalid 'reloadAt.position' option format.");if("number"!=typeof(null===(r=null==e?void 0:e.reloadAt)||void 0===r?void 0:r.relative)&&void 0!==(null===(i=null==e?void 0:e.reloadAt)||void 0===i?void 0:i.relative))throw new Error("API: reload - Invalid 'reloadAt.relative' option format.");if(!Array.isArray(null==e?void 0:e.keySystems)&&void 0!==(null==e?void 0:e.keySystems))throw new Error("API: reload - Invalid 'keySystems' option format.");if(void 0!==(null==e?void 0:e.autoPlay)&&"boolean"!=typeof e.autoPlay)throw new Error("API: reload - Invalid 'autoPlay' option format.")}(e),void 0!==(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position))i={position:e.reloadAt.position};else if(void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.relative)){if(void 0===d)throw new Error("Can't reload to a relative position when previous content was not loaded.");i={position:e.reloadAt.relative+d}}else void 0!==d&&(i={position:d});void 0!==(null==e?void 0:e.autoPlay)?a=e.autoPlay:void 0!==c&&(a=!c),void 0!==(null==e?void 0:e.keySystems)?o=e.keySystems:void 0!==(null===(r=this._priv_reloadingMetadata.options)||void 0===r?void 0:r.keySystems)&&(o=this._priv_reloadingMetadata.options.keySystems);var f=Object.assign(Object.assign({},u),{initialManifest:l});void 0!==i&&(f.startAt=i),void 0!==a&&(f.autoPlay=a),void 0!==o&&(f.keySystems=o),this._priv_initializeContentPlayback(f)},i.createDebugElement=function(e){if(null===ot.createDebugElement)throw new Error("Feature `DEBUG_ELEMENT` not added to the RxPlayer");var t=new Z;return ot.createDebugElement(e,this,t.signal),{dispose:function(){t.cancel()}}},i._priv_initializeContentPlayback=function(e){var n,r,i,a,o,s,u=this,l=e.autoPlay,d=e.defaultAudioTrackSwitchingMode,c=e.enableFastSwitching,f=e.initialManifest,v=e.keySystems,p=e.lowLatencyMode,h=e.minimumManifestUpdateInterval,g=e.requestConfig,y=e.onCodecSwitch,_=e.startAt,b=e.transport,S=e.checkMediaSegmentIntegrity,E=e.manifestLoader,k=e.referenceDateTime,w=e.segmentLoader,A=e.serverSyncInfos,I=e.mode,R=e.__priv_manifestUpdateUrl,x=e.__priv_patchLastSegmentInSidx,C=e.url;if(null===this.videoElement)throw new Error("the attached video element is disposed");var M,P,D="directfile"===b,O=new Z,N=this.videoElement,L=!1,U=null;if(D){if(null===ot.directfile)throw this.stop(),this._priv_currentError=null,new Error("DirectFile feature not activated in your build.");if(t(C))throw new Error("No URL for a DirectFile content");if(T.info("API: Initializing DirectFile mode in the main thread"),U=this._priv_initializeMediaElementTracksStore(O.signal),O.isUsed())return;M=new ot.directfile.initDirectFile({autoPlay:l,keySystems:v,speed:this._priv_speed,startAt:_,url:C})}else{var F={lowLatencyMode:p,maxRetry:null===(n=g.manifest)||void 0===n?void 0:n.maxRetry,requestTimeout:null===(r=g.manifest)||void 0===r?void 0:r.timeout,connectionTimeout:null===(i=g.manifest)||void 0===i?void 0:i.connectionTimeout,minimumManifestUpdateInterval:h,initialManifest:f},B=iv(),z={throttleBitrate:{},limitResolution:{}};this._priv_throttleVideoBitrateWhenHidden&&(B?z.throttleBitrate={video:W(Nr(this._priv_pictureInPictureRef,O.signal),(function(e){return e?1/0:0}),O.signal)}:T.warn("API: Can't apply throttleVideoBitrateWhenHidden because browser can't be trusted for visibility.")),"videoElement"===this._priv_videoResolutionLimit?B?z.limitResolution={video:Ur(N,this._priv_pictureInPictureRef,O.signal)}:T.warn("API: Can't apply videoResolutionLimit because browser can't be trusted for video size."):"screen"===this._priv_videoResolutionLimit&&(z.limitResolution={video:Lr(O.signal)});var V={initialBitrates:this._priv_bitrateInfos.lastBitrates,lowLatencyMode:p,throttlers:z},K="native"===e.textTrackMode?{textTrackMode:"native"}:{textTrackMode:"html",textTrackElement:e.textTrackElement},j=m({enableFastSwitching:c,onCodecSwitch:y},this._priv_bufferOptions),H={lowLatencyMode:p,maxRetry:null===(a=g.segment)||void 0===a?void 0:a.maxRetry,requestTimeout:null===(o=g.segment)||void 0===o?void 0:o.timeout,connectionTimeout:null===(s=g.segment)||void 0===s?void 0:s.connectionTimeout},q=null!==ot.multithread&&null!==this._priv_worker&&"dash"===b&&Lv.every((function(n){return t(e[n])}))&&"function"!=typeof e.representationFilter;if("main"===I||"auto"===I&&!q){if(null===ot.mainThreadMediaSourceInit)throw new Error("Cannot load video, neither in a WebWorker nor with the `MEDIA_SOURCE_MAIN` feature");var Y=ot.transports[b];if("function"!=typeof Y)throw this.stop(),this._priv_currentError=null,new Error('transport "'+b+'" not supported');var Q="string"==typeof e.representationFilter?(P=e.representationFilter,new Function("return ("+P+"(arguments[0], arguments[1]))")):e.representationFilter;T.info("API: Initializing MediaSource mode in the main thread");var X=Y({lowLatencyMode:p,checkMediaSegmentIntegrity:S,manifestLoader:E,referenceDateTime:k,representationFilter:Q,segmentLoader:w,serverSyncInfos:A,__priv_manifestUpdateUrl:R,__priv_patchLastSegmentInSidx:x});M=new ot.mainThreadMediaSourceInit({adaptiveOptions:V,autoPlay:l,bufferOptions:j,keySystems:v,lowLatencyMode:p,transport:X,manifestRequestSettings:F,segmentRequestOptions:H,speed:this._priv_speed,startAt:_,textTrackOptions:K,url:C})}else{if(null===ot.multithread)throw new Error("Cannot load video in multithread mode: `MULTI_THREAD` feature not imported.");if(null===this._priv_worker)throw new Error("Cannot load video in multithread mode: `attachWorker` method not called.");$(e.representationFilter),L=!0,T.info("API: Initializing MediaSource mode in a WebWorker");var J={lowLatencyMode:p,checkMediaSegmentIntegrity:S,referenceDateTime:k,serverSyncInfos:A,manifestLoader:void 0,segmentLoader:void 0,representationFilter:e.representationFilter,__priv_manifestUpdateUrl:R,__priv_patchLastSegmentInSidx:x};M=new ot.multithread.init({adaptiveOptions:V,autoPlay:l,bufferOptions:j,keySystems:v,lowLatencyMode:p,transportOptions:J,manifestRequestSettings:F,segmentRequestOptions:H,speed:this._priv_speed,startAt:_,textTrackOptions:K,worker:this._priv_worker,url:C})}}var ee={contentId:Nv(),originalUrl:C,currentContentCanceller:O,defaultAudioTrackSwitchingMode:d,initializer:M,isDirectFile:D,segmentSinksStore:null,manifest:null,currentPeriod:null,activeAdaptations:null,activeRepresentations:null,tracksStore:null,mediaElementTracksStore:U,useWorker:L};M.addEventListener("error",(function(e){u._priv_onFatalError(e,ee)})),M.addEventListener("warning",(function(e){var t=Ne(e,{defaultCode:"NONE",defaultReason:"An unknown error happened."});T.warn("API: Sending warning:",t),u.trigger("warning",t)})),M.addEventListener("reloadingMediaSource",(function(e){ee.segmentSinksStore=null,null!==ee.tracksStore&&ee.tracksStore.resetPeriodObjects(),u._priv_lastAutoPlay=e.autoPlay})),M.addEventListener("inbandEvents",(function(e){return u.trigger("inbandEvents",e)})),M.addEventListener("streamEvent",(function(e){return u.trigger("streamEvent",e)})),M.addEventListener("streamEventSkip",(function(e){return u.trigger("streamEventSkip",e)})),M.addEventListener("activePeriodChanged",(function(e){return u._priv_onActivePeriodChanged(ee,e)})),M.addEventListener("periodStreamReady",(function(e){return u._priv_onPeriodStreamReady(ee,e)})),M.addEventListener("periodStreamCleared",(function(e){return u._priv_onPeriodStreamCleared(ee,e)})),M.addEventListener("representationChange",(function(e){return u._priv_onRepresentationChange(ee,e)})),M.addEventListener("adaptationChange",(function(e){return u._priv_onAdaptationChange(ee,e)})),M.addEventListener("bitrateEstimateChange",(function(e){return u._priv_onBitrateEstimateChange(e)})),M.addEventListener("manifestReady",(function(e){return u._priv_onManifestReady(ee,e)})),M.addEventListener("manifestUpdate",(function(e){return u._priv_onManifestUpdate(ee,e)})),M.addEventListener("decipherabilityUpdate",(function(e){return u._priv_onDecipherabilityUpdate(ee,e)})),M.addEventListener("loaded",(function(e){ee.segmentSinksStore=e.segmentSinksStore})),M.prepare(),this.stop();var te=new vv(N,{withMediaSource:!D,lowLatencyMode:p});O.signal.register((function(){te.stop()}));var ne=function(e,t,n,r){var i=new G("LOADING",r);e.addEventListener("loaded",(function(){if("LOADING"===i.getValue()){if(i.setValue("LOADED"),!r.isCancelled()){var e=Mv(t,null);"PAUSED"!==e&&i.setValue(e)}}else"RELOADING"===i.getValue()?i.setValue(Mv(t,null)):o(null)}),r),e.addEventListener("reloadingMediaSource",(function(){Pv(i.getValue())&&i.setValueIfChanged("RELOADING")}),r);var a=null;return e.addEventListener("stalled",(function(e){e!==a&&(o(e),a=e)}),r),e.addEventListener("unstalled",(function(){null!==a&&(o(null),a=null)}),r),n.listen((function(e){Ue(["seeking","ended","play","pause"],e.event)&&o(a)}),{clearSignal:r}),i;function o(e){if(Pv(i.getValue())){var n=Mv(t,e);"LOADED"===i.getValue()&&"PAUSED"===n||i.setValueIfChanged(n)}}}(M,N,te,O.signal);O.signal.register((function(){M.dispose()}));var re=function(e){switch(e){case"STOPPED":case"RELOADING":case"LOADING":break;case"ENDED":u._priv_reloadingMetadata.reloadInPause=!0,u._priv_reloadingMetadata.reloadPosition=te.getReference().getValue().position.getPolled();break;default:var t=te.getReference().getValue();u._priv_reloadingMetadata.reloadInPause=t.paused,u._priv_reloadingMetadata.reloadPosition=t.position.getWanted()}},ie=null,ae=function(e){null!==ie&&(ie.cancel(),ie=null),ne.onUpdate((function(t,n){var r,i,a,o;Pv(t)&&(n(),null!==ie&&ie.cancel(),(ie=new Z).linkToSignal(O.signal),e!==!N.paused&&(N.paused?u.trigger("pause",null):u.trigger("play",null)),r=N,i=function(){return u.trigger("play",null)},a=function(){return u.trigger("pause",null)},(o=O.signal).isCancelled()||null===r||(r.addEventListener("play",i),r.addEventListener("pause",a),o.register((function(){r.removeEventListener("play",i),r.removeEventListener("pause",a)}))))}),{emitCurrentValue:!1,clearSignal:O.signal})};ae(l),M.addEventListener("reloadingMediaSource",(function(e){ae(e.autoPlay)})),this._priv_currentError=null,this._priv_contentInfos=ee;var oe=null;ne.onUpdate((function(e){re(e),u._priv_setPlayerState(e),O.isUsed()||(null!==oe?Pv(u.state)||(oe.cancel(),oe=null):Pv(u.state)&&((oe=new Z).linkToSignal(O.signal),function(e,t,n,r,i){if(!i.isCancelled()&&null!==e){var a=2===t.getReference().getValue().seeking;a&&(n(),i.isCancelled())||t.listen((function(e){"seeking"===e.event?(a=!0,n()):a&&"seeked"===e.event&&(a=!1,r())}),{includeLastObservation:!0,clearSignal:i})}}(N,te,(function(){return u.trigger("seeking",null)}),(function(){return u.trigger("seeked",null)}),oe.signal)))}),{emitCurrentValue:!0,clearSignal:O.signal}),te.listen((function(e){re(u.state),u._priv_triggerPositionUpdate(ee,e)}),{clearSignal:O.signal}),O.signal.register((function(){M.removeEventListener()})),this._priv_contentLock.onUpdate((function(e,t){e||(t(),M.start(N,te))}),{emitCurrentValue:!0,clearSignal:O.signal})},i.getError=function(){return this._priv_currentError},i.getVideoElement=function(){return this.videoElement},i.getPlayerState=function(){return this.state},i.isContentLoaded=function(){return!Ue(["LOADING","RELOADING","STOPPED"],this.state)},i.isBuffering=function(){return Ue(["BUFFERING","SEEKING","LOADING","RELOADING"],this.state)},i.isPaused=function(){return!this.videoElement||(Ue(["LOADING","RELOADING"],this.state)?!this._priv_lastAutoPlay:this.videoElement.paused)},i.isLive=function(){if(null===this._priv_contentInfos)return!1;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return!t&&null!==n&&n.isLive},i.areTrickModeTracksEnabled=function(){return this._priv_preferTrickModeTracks},i.getContentUrls=function(){if(null!==this._priv_contentInfos){var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest,r=e.originalUrl;return t?void 0===r?void 0:[r]:null!==n?n.uris:void 0}},i.updateContentUrls=function(e,t){if(null===this._priv_contentInfos)throw new Error("No content loaded");var n=!0===(null==t?void 0:t.refresh);this._priv_contentInfos.initializer.updateContentUrls(e,n)},i.getMediaDuration=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration},i.getCurrentBufferGap=function(){if(null===this.videoElement)throw new Error("Disposed player");var e,t,n,r=this.videoElement,i=(e=r.buffered,t=r.currentTime,null!==(n=P(e,t))?n.end-t:1/0);return i===1/0?0:i},i.getWallClockTime=function(){if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)return this.videoElement.currentTime;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){var r=av(this.videoElement);return(null!=r?r:0)+this.videoElement.currentTime}return null!==n?this.videoElement.currentTime+(void 0!==n.availabilityStartTime?n.availabilityStartTime:0):0},i.getPosition=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.currentTime},i.getLastStoredContentPosition=function(){return this._priv_reloadingMetadata.reloadPosition},i.getPlaybackRate=function(){return this._priv_speed.getValue()},i.setPlaybackRate=function(e,n){var r;e!==this._priv_speed.getValue()&&this._priv_speed.setValue(e);var i=null==n?void 0:n.preferTrickModeTracks;if("boolean"==typeof i){this._priv_preferTrickModeTracks=i;var a=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.tracksStore;t(a)||(i&&!a.isTrickModeEnabled()?a.enableVideoTrickModeTracks():!i&&a.isTrickModeEnabled()&&a.disableVideoTrickModeTracks())}},i.getVideoRepresentation=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e)return e.video},i.getAudioRepresentation=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e)return e.audio},i.play=function(){var e=this;if(null===this.videoElement)throw new Error("Disposed player");var n=this.videoElement.play();return t(n)||"function"!=typeof n.catch?Promise.resolve():n.catch((function(t){if("NotAllowedError"===t.name){var n=new Me("MEDIA_ERR_PLAY_NOT_ALLOWED",t.toString());e.trigger("warning",n)}throw t}))},i.pause=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.pause()},i.seekTo=function(e){var n;if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)throw new Error("player: no content loaded");var r,i=this._priv_contentInfos,a=i.isDirectFile,o=i.manifest;if(!a&&null===o)throw new Error("player: the content did not load yet");if("number"==typeof e)r=e;else if("object"==typeof e){var s=e,u=this.videoElement.currentTime;if(t(s.relative))if(t(s.position)){if(t(s.wallClockTime))throw new Error('invalid time object. You must set one of the following properties: "relative", "position" or "wallClockTime"');if(null!==o)r=s.wallClockTime-(null!==(n=o.availabilityStartTime)&&void 0!==n?n:0);else if(a&&null!==this.videoElement){var l=av(this.videoElement);void 0!==l&&(r=s.wallClockTime-l)}void 0===r&&(r=s.wallClockTime)}else r=s.position;else r=u+s.relative}if(void 0===r)throw new Error("invalid time given");return T.info("API: API Seek to",r),this.videoElement.currentTime=r,r},i.getVolume=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.volume},i.setVolume=function(e){if(null===this.videoElement)throw new Error("Disposed player");var t=this.videoElement;e!==t.volume&&(t.volume=e)},i.isMute=function(){var e;return!0===(null===(e=this.videoElement)||void 0===e?void 0:e.muted)},i.mute=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.muted||(this.videoElement.muted=!0)},i.unMute=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.muted&&(this.videoElement.muted=!1)},i.setMaxBufferBehind=function(e){this._priv_bufferOptions.maxBufferBehind.setValue(e)},i.setMaxBufferAhead=function(e){this._priv_bufferOptions.maxBufferAhead.setValue(e)},i.setWantedBufferAhead=function(e){this._priv_bufferOptions.wantedBufferAhead.setValue(e)},i.setMaxVideoBufferSize=function(e){this._priv_bufferOptions.maxVideoBufferSize.setValue(e)},i.getMaxBufferBehind=function(){return this._priv_bufferOptions.maxBufferBehind.getValue()},i.getMaxBufferAhead=function(){return this._priv_bufferOptions.maxBufferAhead.getValue()},i.getWantedBufferAhead=function(){return this._priv_bufferOptions.wantedBufferAhead.getValue()},i.getMaxVideoBufferSize=function(){return this._priv_bufferOptions.maxVideoBufferSize.getValue()},i.getCurrentPeriod=function(){var e,n=null===(e=this._priv_contentInfos)||void 0===e?void 0:e.currentPeriod;return t(n)?null:{id:n.id,start:n.start,end:n.end}},i.getKeySystemConfiguration=function(){if(null===this.videoElement)throw new Error("Disposed player");var e=kr(this.videoElement);return null===e?null:{keySystem:e[0],configuration:e[1]}},i.getAvailablePeriods=function(){if(null===this._priv_contentInfos)return[];var e=this._priv_contentInfos,t=e.isDirectFile,n=e.tracksStore;return t||null===n?[]:n.getAvailablePeriods().slice()},i.getAvailableAudioTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableAudioTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableAudioTracks(t))&&void 0!==n?n:[]}))},i.getAvailableTextTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableTextTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableTextTracks(t))&&void 0!==n?n:[]}))},i.getAvailableVideoTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableVideoTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableVideoTracks(t))&&void 0!==n?n:[]}))},i.getAudioTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenAudioTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenAudioTrack(t)}))}},i.getTextTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenTextTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenTextTrack(t)}))}},i.getVideoTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenVideoTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenVideoTrack(t)}))}},i.setAudioTrack=function(e){var t;if(null===this._priv_contentInfos)throw new Error("No content loaded");var n,r,i,a=this._priv_contentInfos,o=a.isDirectFile,s=a.mediaElementTracksStore;if(o)try{var u="string"==typeof e?e:e.trackId;return void(null==s||s.setAudioTrackById(u))}catch(e){throw new Error("player: unknown audio track")}var l,d=null;return"string"==typeof e?r=e:(r=e.trackId,n=e.periodId,i=e.switchingMode,d=null!==(t=e.lockedRepresentations)&&void 0!==t?t:null,l=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,t){return e.setAudioTrack({periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:d,relativeResumingPosition:l})}))},i.setTextTrack=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r=this._priv_contentInfos,i=r.isDirectFile,a=r.mediaElementTracksStore;if(i)try{var o="string"==typeof e?e:e.trackId;return void(null==a||a.setTextTrackById(o))}catch(e){throw new Error("player: unknown text track")}return"string"==typeof e?n=e:(n=e.trackId,t=e.periodId),this._priv_callTracksStoreGetterSetter(t,void 0,(function(e,t){return e.setTextTrack(t,n)}))},i.disableTextTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(!n)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.disableTrack(t,"text")}));null==r||r.disableTextTrack()}},i.setVideoTrack=function(e){var t;if(null===this._priv_contentInfos)throw new Error("No content loaded");var n,r,i,a=this._priv_contentInfos,o=a.isDirectFile,s=a.mediaElementTracksStore;if(o)try{var u="string"==typeof e?e:e.trackId;return void(null==s||s.setVideoTrackById(u))}catch(e){throw new Error("player: unknown video track")}var l,d=null;return"string"==typeof e?r=e:(r=e.trackId,n=e.periodId,i=e.switchingMode,d=null!==(t=e.lockedRepresentations)&&void 0!==t?t:null,l=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,t){return e.setVideoTrack({periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:d,relativeResumingPosition:l})}))},i.disableVideoTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;return n&&null!==r?r.disableVideoTrack():this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.disableTrack(t,"video")}))}},i.lockVideoRepresentations=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r;if(this._priv_contentInfos.isDirectFile)throw new Error("Cannot lock video Representations in directfile mode.");return Array.isArray(e)?(t=e,n=void 0):(t=e.representations,n=e.periodId,r=e.switchingMode),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,n){return e.lockVideoRepresentations(n,{representations:t,switchingMode:r})}))},i.lockAudioRepresentations=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r;if(this._priv_contentInfos.isDirectFile)throw new Error("Cannot lock audio Representations in directfile mode.");return Array.isArray(e)?(t=e,n=void 0):(t=e.representations,n=e.periodId,r=e.switchingMode),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,n){return e.lockAudioRepresentations(n,{representations:t,switchingMode:r})}))},i.getLockedVideoRepresentations=function(e){return null===this._priv_contentInfos||this._priv_contentInfos.isDirectFile?null:this._priv_callTracksStoreGetterSetter(e,null,(function(e,t){return e.getLockedVideoRepresentations(t)}))},i.getLockedAudioRepresentations=function(e){return null===this._priv_contentInfos||this._priv_contentInfos.isDirectFile?null:this._priv_callTracksStoreGetterSetter(e,null,(function(e,t){return e.getLockedAudioRepresentations(t)}))},i.unlockVideoRepresentations=function(e){if(null!==this._priv_contentInfos&&!this._priv_contentInfos.isDirectFile)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.unlockVideoRepresentations(t)}))},i.unlockAudioRepresentations=function(e){if(null!==this._priv_contentInfos&&!this._priv_contentInfos.isDirectFile)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.unlockAudioRepresentations(t)}))},i.getMinimumPosition=function(){if(null===this._priv_contentInfos)return null;if(this._priv_contentInfos.isDirectFile)return 0;var e=this._priv_contentInfos.manifest;return null!==e?Ve(e):null},i.getLivePosition=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return t?void 0:!0!==(null==n?void 0:n.isLive)?null:Ke(n)},i.getMaximumPosition=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration}return null!==n?n.isDynamic||null===this.videoElement?We(n):this.videoElement.duration:null},i.__priv_getSegmentSinkContent=function(e){if(null===this._priv_contentInfos||null===this._priv_contentInfos.segmentSinksStore)return null;var t=this._priv_contentInfos.segmentSinksStore.getStatus(e);return"initialized"===t.type?t.value.getLastKnownInventory():null},i.__priv_getManifest=function(){return null===this._priv_contentInfos?null:this._priv_contentInfos.manifest},i.__priv_getCurrentAdaptation=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,n=e.currentPeriod,r=e.activeAdaptations;return null===n||null===r||t(r[n.id])?null:r[n.id]},i.__priv_getCurrentRepresentations=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,n=e.currentPeriod,r=e.activeRepresentations;return null===n||null===r||t(r[n.id])?null:r[n.id]},i._priv_cleanUpCurrentContentState=function(){var e,n,r,i,a=this;T.debug("Locking `contentLock` to clean-up the current content."),this._priv_contentLock.setValue(!0),null===(n=null===(e=this._priv_contentInfos)||void 0===e?void 0:e.tracksStore)||void 0===n||n.dispose(),null===(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.mediaElementTracksStore)||void 0===i||i.dispose(),this._priv_contentInfos=null,this._priv_contentEventsMemory={};var o=function(){null!==a.videoElement&&(T.debug("Unlocking `contentLock`. Next content can begin."),a._priv_contentLock.setValue(!1))};t(this.videoElement)?o():yv(this.videoElement).then((function(){T.debug("API: DRM session cleaned-up with success!"),o()}),(function(e){T.error("API: An error arised when trying to clean-up the DRM session:"+(e instanceof Error?e.toString():"Unknown Error")),o()}))},i._priv_onManifestReady=function(e,t){var n,r=this;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){e.manifest=t,0===t.manifestFormat&&(this._priv_reloadingMetadata.manifest=t);var i=new Rv({preferTrickModeTracks:this._priv_preferTrickModeTracks,defaultAudioTrackSwitchingMode:e.defaultAudioTrackSwitchingMode});e.tracksStore=i,i.addEventListener("newAvailablePeriods",(function(e){r.trigger("newAvailablePeriods",e)})),i.addEventListener("brokenRepresentationsLock",(function(e){r.trigger("brokenRepresentationsLock",e)})),i.addEventListener("trackUpdate",(function(e){var t,n;r.trigger("trackUpdate",e);var i=null!==(n=null===(t=r._priv_contentInfos)||void 0===t?void 0:t.currentPeriod)&&void 0!==n?n:void 0;"no-playable-representation"===e.reason&&e.period.id===(null==i?void 0:i.id)&&r._priv_onAvailableTracksMayHaveChanged(e.trackType)})),e.tracksStore.addEventListener("warning",(function(e){r.trigger("warning",e)})),e.tracksStore.addEventListener("error",(function(t){r._priv_onFatalError(t,e)})),e.tracksStore.onManifestUpdate(t)}},i._priv_onManifestUpdate=function(e,n){var r,i,a;if(null!==this._priv_contentInfos&&null!==this._priv_contentInfos.manifest){t(null==e?void 0:e.tracksStore)||e.tracksStore.onManifestUpdate(this._priv_contentInfos.manifest);var o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,s=null===(a=this._priv_contentInfos)||void 0===a?void 0:a.tracksStore;if(void 0!==o&&!t(s))for(var u,l=Dv(n.updatedPeriods);!(u=l()).done;){var d=u.value;if(d.period.id===o.id&&(d.result.addedAdaptations.length>0||d.result.removedAdaptations.length>0)){if(void 0===s.getPeriodObjectFromPeriod(o))return;this._priv_onAvailableTracksMayHaveChanged("audio"),this._priv_onAvailableTracksMayHaveChanged("text"),this._priv_onAvailableTracksMayHaveChanged("video")}}}},i._priv_onDecipherabilityUpdate=function(e,n){if(null!==e&&null!==e.manifest){t(null==e?void 0:e.tracksStore)||e.tracksStore.onDecipherabilityUpdates();for(var r,i=n.reduce((function(t,n){var r,i,a;if(!(void 0!==ae(t,(function(e){return e[0].id===n.period.id&&e[1]===n.adaptation.type})))){var o=e.tracksStore;if(null===o)return t;var s=!1,u=o.getPeriodObjectFromPeriod(n.period);if(void 0===u)return t;switch(n.adaptation.type){case"audio":s=(null===(r=o.getChosenAudioTrack(u))||void 0===r?void 0:r.id)===n.adaptation.id;break;case"video":s=(null===(i=o.getChosenVideoTrack(u))||void 0===i?void 0:i.id)===n.adaptation.id;break;case"text":s=(null===(a=o.getChosenTextTrack(u))||void 0===a?void 0:a.id)===n.adaptation.id}s&&t.push([n.period,n.adaptation.type])}return t}),[]),a=Dv(i);!(r=a()).done;){var o=r.value,s=o[0],u=o[1];this._priv_triggerEventIfNotStopped("representationListUpdate",{period:{start:s.start,end:s.end,id:s.id},trackType:u,reason:"decipherability-update"},e.currentContentCanceller.signal)}}},i._priv_onActivePeriodChanged=function(e,n){var r,i,a,o,s,u,l=n.period;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){e.currentPeriod=l;var d=e.currentContentCanceller.signal;this._priv_contentEventsMemory.periodChange!==l&&(this._priv_contentEventsMemory.periodChange=l,this._priv_triggerEventIfNotStopped("periodChange",{start:l.start,end:l.end,id:l.id},d)),this._priv_triggerEventIfNotStopped("availableAudioTracksChange",this.getAvailableAudioTracks(),d),this._priv_triggerEventIfNotStopped("availableTextTracksChange",this.getAvailableTextTracks(),d),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",this.getAvailableVideoTracks(),d);var c=null===(i=this._priv_contentInfos)||void 0===i?void 0:i.tracksStore;if(t(c))this._priv_triggerEventIfNotStopped("audioTrackChange",null,d),this._priv_triggerEventIfNotStopped("textTrackChange",null,d),this._priv_triggerEventIfNotStopped("videoTrackChange",null,d);else{var f=c.getPeriodObjectFromPeriod(l);if(f){var v=c.getChosenAudioTrack(f);this._priv_triggerEventIfNotStopped("audioTrackChange",v,d);var p=c.getChosenTextTrack(f);this._priv_triggerEventIfNotStopped("textTrackChange",p,d);var h=c.getChosenVideoTrack(f);this._priv_triggerEventIfNotStopped("videoTrackChange",h,d)}}var m=null!==(o=null===(a=this.__priv_getCurrentRepresentations())||void 0===a?void 0:a.audio)&&void 0!==o?o:null;this._priv_triggerEventIfNotStopped("audioRepresentationChange",m,d);var g=null!==(u=null===(s=this.__priv_getCurrentRepresentations())||void 0===s?void 0:s.video)&&void 0!==u?u:null;this._priv_triggerEventIfNotStopped("videoRepresentationChange",g,d)}},i._priv_onPeriodStreamReady=function(e,n){var r;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var i=n.type,a=n.period,o=n.adaptationRef,s=e.tracksStore;switch(i){case"video":case"audio":case"text":t(s)?(T.error("API: TracksStore not instanciated for a new "+i+" period"),o.setValue(null)):s.addTrackReference(i,a,o);break;default:X()}}},i._priv_onPeriodStreamCleared=function(e,n){var r;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var i=n.type,a=n.period,o=e.tracksStore;switch(i){case"audio":case"text":case"video":t(o)||o.removeTrackReference(i,a)}var s=e.activeAdaptations,u=e.activeRepresentations;if(!t(s)&&!t(s[a.id])){var l=s[a.id];delete l[i],0===Object.keys(l).length&&delete s[a.id]}if(!t(u)&&!t(u[a.id])){var d=u[a.id];delete d[i],0===Object.keys(d).length&&delete u[a.id]}}},i._priv_onAdaptationChange=function(e,n){var r,i=n.type,a=n.adaptation,o=n.period;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){null===e.activeAdaptations&&(e.activeAdaptations={});var s,u=e.activeAdaptations,l=e.currentPeriod,d=u[o.id];if(t(d))u[o.id]=((s={})[i]=a,s);else d[i]=a;var c=e.tracksStore,f=e.currentContentCanceller.signal;if(null!==c&&null!==l&&!t(o)&&o.id===l.id){var v=c.getPeriodObjectFromPeriod(o);if(void 0===v)return;switch(i){case"audio":var p=c.getChosenAudioTrack(v);this._priv_triggerEventIfNotStopped("audioTrackChange",p,f);break;case"text":var h=c.getChosenTextTrack(v);this._priv_triggerEventIfNotStopped("textTrackChange",h,f);break;case"video":var m=c.getChosenVideoTrack(v);this._priv_triggerEventIfNotStopped("videoTrackChange",m,f)}}}},i._priv_onRepresentationChange=function(e,n){var r,i=n.type,a=n.period,o=n.representation;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){null===e.activeRepresentations&&(e.activeRepresentations={});var s,u=e.activeRepresentations,l=e.currentPeriod,d=u[a.id];if(t(d))u[a.id]=((s={})[i]=o,s);else d[i]=o;if(!t(a)&&null!==l&&l.id===a.id){var c=this._priv_contentInfos.currentContentCanceller.signal;"video"===i?this._priv_triggerEventIfNotStopped("videoRepresentationChange",o,c):"audio"===i&&this._priv_triggerEventIfNotStopped("audioRepresentationChange",o,c)}}},i._priv_onBitrateEstimateChange=function(e){var t=e.type,n=e.bitrate;void 0!==n&&(this._priv_bitrateInfos.lastBitrates[t]=n),this.trigger("__priv_bitrateEstimateChange",{type:t,bitrate:n})},i._priv_setPlayerState=function(e){this.state!==e&&(this.state=e,T.info("API: playerStateChange event",e),this.trigger("playerStateChange",e))},i._priv_triggerPositionUpdate=function(e,n){var r,i;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var a=e.isDirectFile,o=e.manifest;if((a||null!==o)&&!t(n)){var s=null!==o?We(o):void 0,u={position:n.position.getPolled(),duration:n.duration,playbackRate:n.playbackRate,maximumPosition:s,bufferGap:void 0!==n.bufferGap&&isFinite(n.bufferGap)?n.bufferGap:0};if(null!==o&&o.isLive&&n.position.getPolled()>0){var l=null!==(i=o.availabilityStartTime)&&void 0!==i?i:0;u.wallClockTime=n.position.getPolled()+l;var d=Ke(o);void 0!==d&&(u.liveGap=d-n.position.getPolled())}else if(a&&null!==this.videoElement){var c=av(this.videoElement);void 0!==c&&(u.wallClockTime=c+n.position.getPolled())}this.trigger("positionUpdate",u)}}},i._priv_triggerEventIfNotStopped=function(e,t,n){n.isCancelled()||this.trigger(e,t)},i._priv_initializeMediaElementTracksStore=function(e){var t,n,r,i=this;$(ot.directfile),$(this.videoElement);var a=new ot.directfile.mediaElementTracksStore(this.videoElement);return this._priv_triggerEventIfNotStopped("availableAudioTracksChange",a.getAvailableAudioTracks(),e),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",a.getAvailableVideoTracks(),e),this._priv_triggerEventIfNotStopped("availableTextTracksChange",a.getAvailableTextTracks(),e),this._priv_triggerEventIfNotStopped("audioTrackChange",null!==(t=a.getChosenAudioTrack())&&void 0!==t?t:null,e),this._priv_triggerEventIfNotStopped("textTrackChange",null!==(n=a.getChosenTextTrack())&&void 0!==n?n:null,e),this._priv_triggerEventIfNotStopped("videoTrackChange",null!==(r=a.getChosenVideoTrack())&&void 0!==r?r:null,e),a.addEventListener("availableVideoTracksChange",(function(e){return i.trigger("availableVideoTracksChange",e)})),a.addEventListener("availableAudioTracksChange",(function(e){return i.trigger("availableAudioTracksChange",e)})),a.addEventListener("availableTextTracksChange",(function(e){return i.trigger("availableTextTracksChange",e)})),a.addEventListener("audioTrackChange",(function(e){return i.trigger("audioTrackChange",e)})),a.addEventListener("videoTrackChange",(function(e){return i.trigger("videoTrackChange",e)})),a.addEventListener("textTrackChange",(function(e){return i.trigger("textTrackChange",e)})),a},i._priv_callTracksStoreGetterSetter=function(e,t,n){var r,i;if(null===this._priv_contentInfos||null===this._priv_contentInfos.tracksStore)return T.warn("API: Trying to call track API too soon"),t;var a=this._priv_contentInfos.tracksStore,o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,s=null!=e?e:null==o?void 0:o.id;if(void 0===s)return t;var u=s===(null==o?void 0:o.id)?a.getPeriodObjectFromPeriod(o):a.getPeriodObjectFromId(s);return void 0===u?t:n(a,u)},i._priv_onAvailableTracksMayHaveChanged=function(e,n){var r=this._priv_contentInfos;if(null!==r){var i=r.currentPeriod,a=r.tracksStore,o=r.currentContentCanceller.signal;if(!t(i)&&null!==a){var s=null!=n?n:a.getPeriodObjectFromPeriod(i);if(void 0!==s)switch(e){case"video":var u=a.getAvailableVideoTracks(s);this._priv_triggerEventIfNotStopped("availableVideoTracksChange",null!=u?u:[],o);break;case"audio":var l=a.getAvailableAudioTracks(s);this._priv_triggerEventIfNotStopped("availableAudioTracksChange",null!=l?l:[],o);break;case"text":var d=a.getAvailableTextTracks(s);this._priv_triggerEventIfNotStopped("availableTextTracksChange",null!=d?d:[],o);break;default:X()}}}},i._priv_onFatalError=function(e,t){var n=Ne(e,{defaultCode:"NONE",defaultReason:"An unknown error stopped content playback."});n.fatal=!0,t.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this._priv_currentError=n,T.error("API: The player stopped because of an error",n),this._priv_setPlayerState("STOPPED"),this._priv_currentError===n&&this.trigger("error",n)},dl(r,null,[{key:"ErrorTypes",get:function(){return Ie}},{key:"ErrorCodes",get:function(){return Re}},{key:"LogLevel",get:function(){return T.getLevel()},set:function(e){T.setLevel(e)}}]),r}(i);Uv.version="4.0.0-dev.2024022600";var Fv=Uv;!function(){if(!o&&!t(s.WebKitSourceBuffer)&&void 0===s.WebKitSourceBuffer.prototype.addEventListener){var e=s.WebKitSourceBuffer.prototype;for(var n in i.prototype)i.prototype.hasOwnProperty(n)&&(e[n]=i.prototype[n]);e._listeners=[],e._emitUpdate=function(e,t){var n=this;u((function(){n.trigger(e,t),n.updating=!1,n.trigger("updateend")}))},e.appendBuffer=function(e){if(this.updating)throw new Error("updating");this.trigger("updatestart"),this.updating=!0;try{this.append(e)}catch(e){return void this._emitUpdate("error",e)}this._emitUpdate("update")}}}(),Fv.addFeatures([Bo,Yu,il,Hd,Ic,Nc,jc,Xc,kf,Pf,Zf,rv]),e()&&T.setLevel("DEBUG");var Bv=Fv}(),r=r.default}()}));
|